wingbot-mongodb 3.2.5-test.1 → 3.2.6-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"parent":null,"pid":26311,"argv":["/usr/local/bin/node","/Users/david/Development/wingbot-mongodb/node_modules/.bin/mocha","./test"],"execArgv":[],"cwd":"/Users/david/Development/wingbot-mongodb","time":1681982211291,"ppid":26310,"coverageFilename":"/Users/david/Development/wingbot-mongodb/.nyc_output/fb200475-7184-4caf-a314-c2fe4216d1dc.json","externalId":"","uuid":"fb200475-7184-4caf-a314-c2fe4216d1dc","files":["/Users/david/Development/wingbot-mongodb/src/BaseStorage.js","/Users/david/Development/wingbot-mongodb/src/defaultLogger.js","/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js","/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js","/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js","/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js","/Users/david/Development/wingbot-mongodb/src/tokenFactory.js","/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js","/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js","/Users/david/Development/wingbot-mongodb/src/StateStorage.js"]}
1
+ {"parent":null,"pid":38479,"argv":["/usr/local/bin/node","/Users/david/Development/wingbot-mongodb/node_modules/.bin/mocha","./test"],"execArgv":[],"cwd":"/Users/david/Development/wingbot-mongodb","time":1692102034748,"ppid":38478,"coverageFilename":"/Users/david/Development/wingbot-mongodb/.nyc_output/1091dc07-773b-48f1-9817-b8048f05d575.json","externalId":"","uuid":"1091dc07-773b-48f1-9817-b8048f05d575","files":["/Users/david/Development/wingbot-mongodb/src/BaseStorage.js","/Users/david/Development/wingbot-mongodb/src/defaultLogger.js","/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js","/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js","/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js","/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js","/Users/david/Development/wingbot-mongodb/src/tokenFactory.js","/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js","/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js","/Users/david/Development/wingbot-mongodb/src/StateStorage.js"]}
@@ -1 +1 @@
1
- {"processes":{"fb200475-7184-4caf-a314-c2fe4216d1dc":{"parent":null,"children":[]}},"files":{"/Users/david/Development/wingbot-mongodb/src/BaseStorage.js":["fb200475-7184-4caf-a314-c2fe4216d1dc"],"/Users/david/Development/wingbot-mongodb/src/defaultLogger.js":["fb200475-7184-4caf-a314-c2fe4216d1dc"],"/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js":["fb200475-7184-4caf-a314-c2fe4216d1dc"],"/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js":["fb200475-7184-4caf-a314-c2fe4216d1dc"],"/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js":["fb200475-7184-4caf-a314-c2fe4216d1dc"],"/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js":["fb200475-7184-4caf-a314-c2fe4216d1dc"],"/Users/david/Development/wingbot-mongodb/src/tokenFactory.js":["fb200475-7184-4caf-a314-c2fe4216d1dc"],"/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js":["fb200475-7184-4caf-a314-c2fe4216d1dc"],"/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js":["fb200475-7184-4caf-a314-c2fe4216d1dc"],"/Users/david/Development/wingbot-mongodb/src/StateStorage.js":["fb200475-7184-4caf-a314-c2fe4216d1dc"]},"externalIds":{}}
1
+ {"processes":{"1091dc07-773b-48f1-9817-b8048f05d575":{"parent":null,"children":[]}},"files":{"/Users/david/Development/wingbot-mongodb/src/BaseStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/defaultLogger.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/AttachmentCache.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/AuditLogStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/BotConfigStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/BotTokenStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/tokenFactory.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/ChatLogStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/NotificationsStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"],"/Users/david/Development/wingbot-mongodb/src/StateStorage.js":["1091dc07-773b-48f1-9817-b8048f05d575"]},"externalIds":{}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot-mongodb",
3
- "version": "3.2.5-test.1",
3
+ "version": "3.2.6-alpha.1",
4
4
  "description": "MongoDB storage for wingbot.ai",
5
5
  "main": "src/main.js",
6
6
  "scripts": {
@@ -31,6 +31,17 @@ function getNestedObjects (obj, nested, attr = null, ret = {}) {
31
31
  return ret;
32
32
  }
33
33
 
34
+ /**
35
+ *
36
+ * @template T
37
+ * @param {string} k
38
+ * @param {T} v
39
+ * @returns {T|null}
40
+ */
41
+ function signReplacer (k, v) {
42
+ return v === undefined ? null : v;
43
+ }
44
+
34
45
  class BaseStorage {
35
46
 
36
47
  static netFailuresIntervalMs = 600000; // 10 minutes
@@ -371,10 +382,6 @@ class BaseStorage {
371
382
  const objToSign = this._objectToSign(object);
372
383
  const sign = this._signWithSecret(objToSign, secret);
373
384
 
374
- if (this.logSig) {
375
- this._log.log(`sign ${this._collectionName}`, JSON.stringify(objToSign, null, 2));
376
- }
377
-
378
385
  return Object.assign(objToSign, {
379
386
  sign
380
387
  });
@@ -413,7 +420,7 @@ class BaseStorage {
413
420
  */
414
421
  _signWithSecret (objToSign, secret, previous = null) {
415
422
  const h = crypto.createHmac('sha3-224', secret)
416
- .update(JSON.stringify(objToSign));
423
+ .update(JSON.stringify(objToSign, signReplacer));
417
424
 
418
425
  if (previous) {
419
426
  h.update(previous);
@@ -114,7 +114,6 @@ class ChatLogStorage extends BaseStorage {
114
114
  const compare = this._signWithSecret(objToSign, secret);
115
115
  const ok = compare === sign;
116
116
  if (!ok) {
117
- this._log.log(`compare ${this._collectionName}`, JSON.stringify(objToSign, null, 2));
118
117
  this._log.error(`ChatLog: found wrong signature at pageId: "${r.pageId}", senderId: "${r.senderId}", at: ${r.timestamp}`, r);
119
118
  }
120
119