update dependencies and devDependencies, fix breaking changes from myster-box
authorJustin Wind <justin.wind+git@gmail.com>
Sat, 18 Mar 2023 20:51:01 +0000 (13:51 -0700)
committerJustin Wind <justin.wind+git@gmail.com>
Sat, 18 Mar 2023 20:51:01 +0000 (13:51 -0700)
package-lock.json
package.json
src/common.js
src/manager.js
test/src/common.js

index c116e343cebfeb218887ea370995fb97c537a37c..fe76f2de9ada302366d227a7a3c7837e99cca43d 100644 (file)
       "dependencies": {
         "@squeep/amqp-helper": "git+https://git.squeep.com/squeep-amqp-helper#v1.0.0",
         "@squeep/api-dingus": "git+https://git.squeep.com/squeep-api-dingus/#v1.2.9",
-        "@squeep/authentication-module": "git+https://git.squeep.com/squeep-authentication-module/#v1.2.12",
+        "@squeep/authentication-module": "git+https://git.squeep.com/squeep-authentication-module/#v1.3.0",
         "@squeep/chores": "git+https://git.squeep.com/squeep-chores/#v1.0.0",
         "@squeep/html-template-helper": "git+https://git.squeep.com/squeep-html-template-helper#v1.4.0",
         "@squeep/indieauth-helper": "git+https://git.squeep.com/squeep-indieauth-helper/#v1.2.2",
         "@squeep/logger-json-console": "git+https://git.squeep.com/squeep-logger-json-console#v1.0.2",
-        "@squeep/mystery-box": "^1.2.2",
+        "@squeep/mystery-box": "^2.0.1",
         "@squeep/resource-authentication-module": "git+https://git.squeep.com/squeep-resource-authentication-module#v1.0.0",
         "@squeep/roman": "^1.0.0",
         "@squeep/web-linking": "^1.0.7",
       }
     },
     "node_modules/@squeep/authentication-module": {
-      "version": "1.2.12",
-      "resolved": "git+https://git.squeep.com/squeep-authentication-module/#9a7d5352698481c0857ba8827e31c7cb97625133",
+      "version": "1.3.0",
+      "resolved": "git+https://git.squeep.com/squeep-authentication-module/#6557437fcef1d780b54e39ab93e07a6be36e4447",
       "license": "ISC",
       "dependencies": {
         "@squeep/api-dingus": "git+https://git.squeep.com/squeep-api-dingus/#v1.2.9",
         "@squeep/html-template-helper": "git+https://git.squeep.com/squeep-html-template-helper#v1.4.0",
-        "@squeep/indieauth-helper": "git+https://git.squeep.com/squeep-indieauth-helper/#v1.1.7",
-        "@squeep/mystery-box": "^1.2.0"
+        "@squeep/indieauth-helper": "git+https://git.squeep.com/squeep-indieauth-helper/#v1.2.0",
+        "@squeep/mystery-box": "^2.0.1"
       },
       "engines": {
         "node": ">=14"
       },
       "optionalDependencies": {
-        "argon2": "^0.30.1",
+        "argon2": "^0.30.3",
         "node-linux-pam": "^0.2.1"
       }
     },
       }
     },
     "node_modules/@squeep/mystery-box": {
-      "version": "1.2.2",
-      "resolved": "https://registry.npmjs.org/@squeep/mystery-box/-/mystery-box-1.2.2.tgz",
-      "integrity": "sha512-pbepyJEqnA48ABzthhnOXUFMOGP417gKbZiIRit54iYZ0ZaMg1NWAs2ha5c//Q7hU94A8jPnsRFDtyMCvliNeg==",
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/@squeep/mystery-box/-/mystery-box-2.0.1.tgz",
+      "integrity": "sha512-is8Uqvcm27pm49ZaQL/KOizo89SiTuTZElQoyuPX34TvcnsOTN2eN2YxdVSwKusZwYi+mmE8brrAtBcM/Ttpwg==",
       "engines": {
         "node": "^14 >=14.18.0 || >=15.7.0"
       }
       }
     },
     "node_modules/aproba": {
-      "version": "1.2.0",
-      "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
-      "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==",
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz",
+      "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==",
       "optional": true
     },
     "node_modules/archy": {
         "node": ">=0.10.0"
       }
     },
+    "node_modules/node-linux-pam/node_modules/aproba": {
+      "version": "1.2.0",
+      "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
+      "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==",
+      "optional": true
+    },
     "node_modules/node-linux-pam/node_modules/are-we-there-yet": {
       "version": "1.1.7",
       "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.7.tgz",
       }
     },
     "@squeep/authentication-module": {
-      "version": "git+https://git.squeep.com/squeep-authentication-module/#9a7d5352698481c0857ba8827e31c7cb97625133",
-      "from": "@squeep/authentication-module@git+https://git.squeep.com/squeep-authentication-module/#v1.2.12",
+      "version": "git+https://git.squeep.com/squeep-authentication-module/#6557437fcef1d780b54e39ab93e07a6be36e4447",
+      "from": "@squeep/authentication-module@git+https://git.squeep.com/squeep-authentication-module/#v1.3.0",
       "requires": {
         "@squeep/api-dingus": "git+https://git.squeep.com/squeep-api-dingus/#v1.2.9",
         "@squeep/html-template-helper": "git+https://git.squeep.com/squeep-html-template-helper#v1.4.0",
-        "@squeep/indieauth-helper": "git+https://git.squeep.com/squeep-indieauth-helper/#v1.1.7",
-        "@squeep/mystery-box": "^1.2.0",
-        "argon2": "^0.30.1",
+        "@squeep/indieauth-helper": "git+https://git.squeep.com/squeep-indieauth-helper/#v1.2.0",
+        "@squeep/mystery-box": "^2.0.1",
+        "argon2": "^0.30.3",
         "node-linux-pam": "^0.2.1"
       }
     },
       "from": "@squeep/logger-json-console@git+https://git.squeep.com/squeep-logger-json-console#v1.0.2"
     },
     "@squeep/mystery-box": {
-      "version": "1.2.2",
-      "resolved": "https://registry.npmjs.org/@squeep/mystery-box/-/mystery-box-1.2.2.tgz",
-      "integrity": "sha512-pbepyJEqnA48ABzthhnOXUFMOGP417gKbZiIRit54iYZ0ZaMg1NWAs2ha5c//Q7hU94A8jPnsRFDtyMCvliNeg=="
+      "version": "2.0.1",
+      "resolved": "https://registry.npmjs.org/@squeep/mystery-box/-/mystery-box-2.0.1.tgz",
+      "integrity": "sha512-is8Uqvcm27pm49ZaQL/KOizo89SiTuTZElQoyuPX34TvcnsOTN2eN2YxdVSwKusZwYi+mmE8brrAtBcM/Ttpwg=="
     },
     "@squeep/resource-authentication-module": {
       "version": "git+https://git.squeep.com/squeep-resource-authentication-module#69a2f5e7d73dd3f58e07b652c306daa8b253245d",
       }
     },
     "aproba": {
-      "version": "1.2.0",
-      "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
-      "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==",
+      "version": "2.0.0",
+      "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz",
+      "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==",
       "optional": true
     },
     "archy": {
           "integrity": "sha512-TIGnTpdo+E3+pCyAluZvtED5p5wCqLdezCyhPZzKPcxvFplEt4i+W7OONCKgeZFT3+y5NZZfOOS/Bdcanm1MYA==",
           "optional": true
         },
+        "aproba": {
+          "version": "1.2.0",
+          "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
+          "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==",
+          "optional": true
+        },
         "are-we-there-yet": {
           "version": "1.1.7",
           "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.7.tgz",
index 880d15d3d7c3bfbc2ae95f83fd02c2100cc552c6..c9140829e6fcfafc52b10cb9d8adccee0c373661 100644 (file)
   "dependencies": {
     "@squeep/amqp-helper": "git+https://git.squeep.com/squeep-amqp-helper#v1.0.0",
     "@squeep/api-dingus": "git+https://git.squeep.com/squeep-api-dingus/#v1.2.9",
-    "@squeep/authentication-module": "git+https://git.squeep.com/squeep-authentication-module/#v1.2.12",
+    "@squeep/authentication-module": "git+https://git.squeep.com/squeep-authentication-module/#v1.3.0",
     "@squeep/chores": "git+https://git.squeep.com/squeep-chores/#v1.0.0",
     "@squeep/html-template-helper": "git+https://git.squeep.com/squeep-html-template-helper#v1.4.0",
     "@squeep/indieauth-helper": "git+https://git.squeep.com/squeep-indieauth-helper/#v1.2.2",
     "@squeep/logger-json-console": "git+https://git.squeep.com/squeep-logger-json-console#v1.0.2",
-    "@squeep/mystery-box": "^1.2.2",
+    "@squeep/mystery-box": "^2.0.1",
     "@squeep/resource-authentication-module": "git+https://git.squeep.com/squeep-resource-authentication-module#v1.0.0",
     "@squeep/roman": "^1.0.0",
     "@squeep/web-linking": "^1.0.7",
index d58f53525812e9ff5e4790972e4936ceb7dd743c..90ae9d2e8e982664e148e641af3afca2b03ba4a9 100644 (file)
@@ -151,6 +151,28 @@ const dateToEpoch = (date) => {
   return Math.ceil(dateMs / 1000);
 };
 
+
+const omit = (o, props) => {
+  return Object.fromEntries(Object.entries(o).filter(([k]) => !props.includes(k)))
+};
+
+
+/**
+ * Log Mystery Box statistics events.
+ * @param {Console} logger
+ * @param {String} scope
+ */
+const mysteryBoxLogger = (logger, scope) => {
+  return (s) => {
+    logger.debug(scope, `${s.packageName}@${s.packageVersion}:${s.method}`, omit(s, [
+      'packageName',
+      'packageVersion',
+      'method',
+    ]));
+  };
+};
+
+
 module.exports = {
   ...common,
   axiosResponseLogData,
@@ -159,7 +181,9 @@ module.exports = {
   ensureArray,
   freezeDeep,
   logTruncate,
+  mysteryBoxLogger,
   newSecret,
+  omit,
   randomBytesAsync,
   validScope,
   validError,
index 0d4302772b7405ce4539cb55640d5a3b9da011a1..01a941643e093ba10a17dd86b5cd39c700214b3b 100644 (file)
@@ -28,7 +28,8 @@ class Manager {
     if (options.queues.amqp.url) {
       this.queuePublisher = new QueuePublisher(logger, options.queues.amqp);
     }
-    this.mysteryBox = new MysteryBox(logger, options);
+    this.mysteryBox = new MysteryBox(options);
+    this.mysteryBox.on('statistics', common.mysteryBoxLogger(logger, _fileScope(this.constructor.name)));
 
     // We need to know how the outside world sees us, to verify if a
     // profile indicates us as the auth server.
index 1115f0ab5114c40466147bf821313f796a54e229..a24db1f2b761605c9e0a7adc56008f2f71d319eb 100644 (file)
@@ -2,6 +2,8 @@
 'use strict';
 
 const assert = require('assert');
+const sinon = require('sinon');
+const StubLogger = require('../stub-logger');
 const common = require('../../src/common');
 
 describe('Common', function () {
@@ -178,4 +180,43 @@ describe('Common', function () {
     });
   }); // dateToEpoch
 
+  describe('omit', function () {
+    it('covers', function () {
+      const obj = {
+        foo: true,
+        bar: 'bar',
+        baz: {
+          quux: false,
+        },
+      };
+      const omitted = ['bar', 'baz'];
+      const expected = {
+        foo: true,
+      };
+      const result = common.omit(obj, omitted);
+      assert.deepStrictEqual(result, expected);
+    });
+  }); // omit
+
+  describe('mysteryBoxLogger', function () {
+    let mbl, stubLogger;
+    beforeEach(function () {
+      stubLogger = new StubLogger();
+      stubLogger._reset();
+      mbl = common.mysteryBoxLogger(stubLogger, 'test:scope');
+    });
+    afterEach(function () {
+      sinon.restore();
+    });
+    it('covers', function () {
+      const stat = {
+        packageName: 'fake-mystery-box',
+        packageVersion: '0.0.0',
+        data: 'exists',
+      };
+      mbl(stat);
+      assert(stubLogger.debug.called);
+    });
+  }); // mysteryBoxLogger
+
 }); // Common