tool-db 2.5.3 → 2.5.4

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.
Files changed (171) hide show
  1. package/README.md +82 -82
  2. package/bundle.js +1 -1
  3. package/dist/adapters-base/networkAdapter.d.ts +58 -58
  4. package/dist/adapters-base/networkAdapter.js +215 -215
  5. package/dist/adapters-base/storageAdapter.d.ts +11 -11
  6. package/dist/adapters-base/storageAdapter.js +35 -35
  7. package/dist/adapters-base/userAdapter.d.ts +15 -15
  8. package/dist/adapters-base/userAdapter.js +41 -41
  9. package/dist/crdt/baseCrdt.d.ts +9 -9
  10. package/dist/crdt/baseCrdt.js +26 -26
  11. package/dist/crdt/counterCrdt.d.ts +30 -30
  12. package/dist/crdt/counterCrdt.js +105 -105
  13. package/dist/crdt/listCrdt.d.ts +42 -42
  14. package/dist/crdt/listCrdt.js +158 -158
  15. package/dist/crdt/mapCrdt.d.ts +32 -32
  16. package/dist/crdt/mapCrdt.js +117 -117
  17. package/dist/index.d.ts +34 -34
  18. package/dist/index.js +82 -82
  19. package/dist/logger.d.ts +2 -2
  20. package/dist/logger.js +28 -28
  21. package/dist/messageHandlers/handleCrdtGet.d.ts +2 -2
  22. package/dist/messageHandlers/handleCrdtGet.js +49 -28
  23. package/dist/messageHandlers/handleCrdtGet.js.map +1 -1
  24. package/dist/messageHandlers/handleCrdtPut.d.ts +2 -2
  25. package/dist/messageHandlers/handleCrdtPut.js +102 -92
  26. package/dist/messageHandlers/handleCrdtPut.js.map +1 -1
  27. package/dist/messageHandlers/handleGet.d.ts +2 -2
  28. package/dist/messageHandlers/handleGet.js +49 -28
  29. package/dist/messageHandlers/handleGet.js.map +1 -1
  30. package/dist/messageHandlers/handlePing.d.ts +2 -2
  31. package/dist/messageHandlers/handlePing.js +35 -35
  32. package/dist/messageHandlers/handlePing.js.map +1 -1
  33. package/dist/messageHandlers/handlePong.d.ts +2 -2
  34. package/dist/messageHandlers/handlePong.js +25 -25
  35. package/dist/messageHandlers/handlePut.d.ts +2 -2
  36. package/dist/messageHandlers/handlePut.js +77 -56
  37. package/dist/messageHandlers/handlePut.js.map +1 -1
  38. package/dist/messageHandlers/handleQuery.d.ts +2 -2
  39. package/dist/messageHandlers/handleQuery.js +43 -22
  40. package/dist/messageHandlers/handleQuery.js.map +1 -1
  41. package/dist/messageHandlers/handleSubscribe.d.ts +2 -2
  42. package/dist/messageHandlers/handleSubscribe.js +43 -43
  43. package/dist/server.d.ts +1 -1
  44. package/dist/server.js +8 -8
  45. package/dist/shared.d.ts +2 -2
  46. package/dist/shared.js +6 -6
  47. package/dist/toolDbAnonSignIn.d.ts +2 -2
  48. package/dist/toolDbAnonSignIn.js +6 -6
  49. package/dist/toolDbClientOnMessage.d.ts +2 -2
  50. package/dist/toolDbClientOnMessage.js +58 -58
  51. package/dist/toolDbCrdtGet.d.ts +9 -9
  52. package/dist/toolDbCrdtGet.js +76 -76
  53. package/dist/toolDbCrdtGet.js.map +1 -1
  54. package/dist/toolDbCrdtPut.d.ts +9 -9
  55. package/dist/toolDbCrdtPut.js +62 -62
  56. package/dist/toolDbCrdtPut.js.map +1 -1
  57. package/dist/toolDbGet.d.ts +9 -9
  58. package/dist/toolDbGet.js +76 -76
  59. package/dist/toolDbGet.js.map +1 -1
  60. package/dist/toolDbKeysSignIn.d.ts +2 -2
  61. package/dist/toolDbKeysSignIn.js +15 -15
  62. package/dist/toolDbPut.d.ts +9 -9
  63. package/dist/toolDbPut.js +68 -68
  64. package/dist/toolDbPut.js.map +1 -1
  65. package/dist/toolDbQueryKeys.d.ts +8 -8
  66. package/dist/toolDbQueryKeys.js +65 -65
  67. package/dist/toolDbQueryKeys.js.map +1 -1
  68. package/dist/toolDbSignIn.d.ts +2 -2
  69. package/dist/toolDbSignIn.js +26 -26
  70. package/dist/toolDbSignIn.js.map +1 -1
  71. package/dist/toolDbSignUp.d.ts +2 -2
  72. package/dist/toolDbSignUp.js +100 -100
  73. package/dist/toolDbSignUp.js.map +1 -1
  74. package/dist/toolDbSubscribe.d.ts +9 -9
  75. package/dist/toolDbSubscribe.js +49 -49
  76. package/dist/toolDbSubscribe.js.map +1 -1
  77. package/dist/toolDbVerificationWrapper.d.ts +2 -2
  78. package/dist/toolDbVerificationWrapper.js +97 -97
  79. package/dist/tooldb.d.ts +108 -108
  80. package/dist/tooldb.js +285 -285
  81. package/dist/types/message.d.ts +100 -100
  82. package/dist/types/message.js +16 -16
  83. package/dist/types/tooldb.d.ts +84 -84
  84. package/dist/types/tooldb.js +2 -2
  85. package/dist/utils/catchReturn.d.ts +1 -1
  86. package/dist/utils/catchReturn.js +7 -7
  87. package/dist/utils/encoding/arrayBufferToHex.d.ts +1 -1
  88. package/dist/utils/encoding/arrayBufferToHex.js +18 -18
  89. package/dist/utils/encoding/arrayBufferToString.d.ts +1 -1
  90. package/dist/utils/encoding/arrayBufferToString.js +11 -11
  91. package/dist/utils/encoding/hexToArrayBuffer.d.ts +1 -1
  92. package/dist/utils/encoding/hexToArrayBuffer.js +14 -14
  93. package/dist/utils/encoding/hexToString.d.ts +1 -1
  94. package/dist/utils/encoding/hexToString.js +11 -11
  95. package/dist/utils/encoding/hexToUint8.d.ts +1 -1
  96. package/dist/utils/encoding/hexToUint8.js +7 -7
  97. package/dist/utils/encoding/stringToArrayBuffer.d.ts +1 -1
  98. package/dist/utils/encoding/stringToArrayBuffer.js +11 -11
  99. package/dist/utils/getPeerSignature.d.ts +2 -2
  100. package/dist/utils/getPeerSignature.js +8 -8
  101. package/dist/utils/getTimestamp.d.ts +1 -1
  102. package/dist/utils/getTimestamp.js +6 -6
  103. package/dist/utils/proofOfWork.d.ts +4 -4
  104. package/dist/utils/proofOfWork.js +15 -15
  105. package/dist/utils/randomAnimal.d.ts +1 -1
  106. package/dist/utils/randomAnimal.js +76 -76
  107. package/dist/utils/sha1.d.ts +1 -1
  108. package/dist/utils/sha1.js +12 -12
  109. package/dist/utils/sha256.d.ts +3 -3
  110. package/dist/utils/sha256.js +12 -12
  111. package/dist/utils/textRandom.d.ts +1 -1
  112. package/dist/utils/textRandom.js +14 -14
  113. package/dist/utils/uniq.d.ts +1 -1
  114. package/dist/utils/uniq.js +6 -6
  115. package/dist/utils/verifyMessage.d.ts +8 -8
  116. package/dist/utils/verifyMessage.js +128 -128
  117. package/dist/utils/verifyPeer.d.ts +2 -2
  118. package/dist/utils/verifyPeer.js +14 -14
  119. package/lib/adapters-base/networkAdapter.ts +217 -217
  120. package/lib/adapters-base/storageAdapter.ts +35 -35
  121. package/lib/adapters-base/userAdapter.ts +49 -49
  122. package/lib/crdt/baseCrdt.ts +21 -21
  123. package/lib/crdt/counterCrdt.ts +111 -111
  124. package/lib/crdt/listCrdt.ts +190 -190
  125. package/lib/crdt/mapCrdt.ts +119 -119
  126. package/lib/index.ts +42 -42
  127. package/lib/logger.ts +30 -30
  128. package/lib/messageHandlers/handleCrdtGet.ts +34 -29
  129. package/lib/messageHandlers/handleCrdtPut.ts +123 -118
  130. package/lib/messageHandlers/handleGet.ts +34 -29
  131. package/lib/messageHandlers/handlePing.ts +40 -40
  132. package/lib/messageHandlers/handlePong.ts +30 -30
  133. package/lib/messageHandlers/handlePut.ts +59 -54
  134. package/lib/messageHandlers/handleQuery.ts +30 -25
  135. package/lib/messageHandlers/handleSubscribe.ts +46 -46
  136. package/lib/server.ts +7 -7
  137. package/lib/shared.ts +5 -5
  138. package/lib/toolDbAnonSignIn.ts +5 -5
  139. package/lib/toolDbClientOnMessage.ts +75 -75
  140. package/lib/toolDbCrdtGet.ts +83 -82
  141. package/lib/toolDbCrdtPut.ts +78 -77
  142. package/lib/toolDbGet.ts +81 -80
  143. package/lib/toolDbKeysSignIn.ts +16 -16
  144. package/lib/toolDbPut.ts +84 -83
  145. package/lib/toolDbQueryKeys.ts +65 -64
  146. package/lib/toolDbSignIn.ts +32 -31
  147. package/lib/toolDbSignUp.ts +72 -71
  148. package/lib/toolDbSubscribe.ts +54 -53
  149. package/lib/toolDbVerificationWrapper.ts +55 -55
  150. package/lib/tooldb.ts +316 -316
  151. package/lib/types/message.ts +133 -133
  152. package/lib/types/tooldb.ts +97 -97
  153. package/lib/utils/catchReturn.ts +4 -4
  154. package/lib/utils/encoding/arrayBufferToHex.ts +18 -18
  155. package/lib/utils/encoding/arrayBufferToString.ts +8 -8
  156. package/lib/utils/encoding/hexToArrayBuffer.ts +13 -13
  157. package/lib/utils/encoding/hexToString.ts +8 -8
  158. package/lib/utils/encoding/hexToUint8.ts +5 -5
  159. package/lib/utils/encoding/stringToArrayBuffer.ts +8 -8
  160. package/lib/utils/getPeerSignature.ts +12 -12
  161. package/lib/utils/getTimestamp.ts +3 -3
  162. package/lib/utils/proofOfWork.ts +16 -16
  163. package/lib/utils/randomAnimal.ts +77 -77
  164. package/lib/utils/sha1.ts +7 -7
  165. package/lib/utils/sha256.ts +7 -7
  166. package/lib/utils/textRandom.ts +11 -11
  167. package/lib/utils/uniq.ts +3 -3
  168. package/lib/utils/verifyMessage.ts +88 -88
  169. package/lib/utils/verifyPeer.ts +15 -15
  170. package/package.json +2 -2
  171. package/tsconfig.json +14 -14
@@ -1,101 +1,101 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var _1 = require(".");
40
- function toolDbSignUp(user, password) {
41
- return __awaiter(this, void 0, void 0, function () {
42
- var userRoot;
43
- var _this = this;
44
- return __generator(this, function (_a) {
45
- userRoot = "==".concat(user);
46
- return [2 /*return*/, new Promise(function (resolve, reject) {
47
- _this.getData(userRoot, false, 3000)
48
- .then(function (data) {
49
- if (data === null) {
50
- var account_1 = new _this.options.userAdapter(_this);
51
- account_1.encryptAccount((0, _1.sha256)(password)).then(function (userData) {
52
- var timestamp = new Date().getTime();
53
- var userDataString = "".concat(JSON.stringify(userData)).concat(account_1.getAddress()).concat(timestamp);
54
- (0, _1.proofOfWork)(userDataString, 0)
55
- .then(function (_a) {
56
- var hash = _a.hash, nonce = _a.nonce;
57
- account_1.signData(hash).then(function (signature) {
58
- var signupMessage = {
59
- k: userRoot,
60
- a: account_1.getAddress() || "",
61
- n: nonce,
62
- t: timestamp,
63
- h: hash,
64
- s: signature,
65
- v: userData,
66
- c: null,
67
- };
68
- _this.logger("SIGNUP PUT", userRoot, signupMessage);
69
- var finalMsg = {
70
- type: "put",
71
- id: (0, _1.textRandom)(10),
72
- to: [],
73
- data: signupMessage,
74
- };
75
- _this.network.sendToAll(finalMsg);
76
- _this.store
77
- .put(userRoot, JSON.stringify(signupMessage))
78
- .catch(function (e) {
79
- // do nothing
80
- })
81
- .finally(function () {
82
- resolve(finalMsg);
83
- });
84
- });
85
- })
86
- .catch(reject);
87
- });
88
- }
89
- else {
90
- reject(new Error("User already exists!"));
91
- }
92
- })
93
- .catch(function () {
94
- reject(new Error("Could not fetch user"));
95
- });
96
- })];
97
- });
98
- });
99
- }
100
- exports.default = toolDbSignUp;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var _1 = require(".");
40
+ function toolDbSignUp(user, password, to) {
41
+ return __awaiter(this, void 0, void 0, function () {
42
+ var userRoot;
43
+ var _this = this;
44
+ return __generator(this, function (_a) {
45
+ userRoot = "==".concat(user);
46
+ return [2 /*return*/, new Promise(function (resolve, reject) {
47
+ _this.getData(userRoot, false, 3000, to)
48
+ .then(function (data) {
49
+ if (data === null) {
50
+ var account_1 = new _this.options.userAdapter(_this);
51
+ account_1.encryptAccount((0, _1.sha256)(password)).then(function (userData) {
52
+ var timestamp = new Date().getTime();
53
+ var userDataString = "".concat(JSON.stringify(userData)).concat(account_1.getAddress()).concat(timestamp);
54
+ (0, _1.proofOfWork)(userDataString, 0)
55
+ .then(function (_a) {
56
+ var hash = _a.hash, nonce = _a.nonce;
57
+ account_1.signData(hash).then(function (signature) {
58
+ var signupMessage = {
59
+ k: userRoot,
60
+ a: account_1.getAddress() || "",
61
+ n: nonce,
62
+ t: timestamp,
63
+ h: hash,
64
+ s: signature,
65
+ v: userData,
66
+ c: null,
67
+ };
68
+ _this.logger("SIGNUP PUT", userRoot, signupMessage);
69
+ var finalMsg = {
70
+ type: "put",
71
+ id: (0, _1.textRandom)(10),
72
+ to: to || [],
73
+ data: signupMessage,
74
+ };
75
+ _this.network.sendToAll(finalMsg);
76
+ _this.store
77
+ .put(userRoot, JSON.stringify(signupMessage))
78
+ .catch(function (e) {
79
+ // do nothing
80
+ })
81
+ .finally(function () {
82
+ resolve(finalMsg);
83
+ });
84
+ });
85
+ })
86
+ .catch(reject);
87
+ });
88
+ }
89
+ else {
90
+ reject(new Error("User already exists!"));
91
+ }
92
+ })
93
+ .catch(function () {
94
+ reject(new Error("Could not fetch user"));
95
+ });
96
+ })];
97
+ });
98
+ });
99
+ }
100
+ exports.default = toolDbSignUp;
101
101
  //# sourceMappingURL=toolDbSignUp.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toolDbSignUp.js","sourceRoot":"","sources":["../lib/toolDbSignUp.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sBAOW;AAEX,SAA8B,YAAY,CAExC,IAAY,EACZ,QAAgB;;;;;YAEV,QAAQ,GAAG,YAAK,IAAI,CAAE,CAAC;YAC7B,sBAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;oBACjC,KAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC;yBAChC,IAAI,CAAC,UAAC,IAAI;wBACT,IAAI,IAAI,KAAK,IAAI,EAAE;4BACjB,IAAM,SAAO,GAAG,IAAI,KAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAI,CAAC,CAAC;4BACnD,SAAO,CAAC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AK,CAAC;wBACL,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC;oBAC5C,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,EAAC;;;CACJ;AA9DD,+BA8DC"}
@@ -1,9 +1,9 @@
1
- import { ToolDb } from ".";
2
- /**
3
- * Subscribe to all PUT updates for this key.
4
- * @param key key of the data
5
- * @param userNamespaced If this key bolongs to a user or its public. Making it
6
- * private will enforce validation for our address and signatures.
7
- * @returns Promise<Data>
8
- */
9
- export default function toolDbSubscribe(this: ToolDb, key: string, userNamespaced?: boolean): Promise<void>;
1
+ import { ToolDb } from ".";
2
+ /**
3
+ * Subscribe to all PUT updates for this key.
4
+ * @param key key of the data
5
+ * @param userNamespaced If this key bolongs to a user or its public. Making it
6
+ * private will enforce validation for our address and signatures.
7
+ * @returns Promise<Data>
8
+ */
9
+ export default function toolDbSubscribe(this: ToolDb, key: string, userNamespaced?: boolean, to?: string[]): Promise<void>;
@@ -1,50 +1,50 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var _1 = require(".");
4
- /**
5
- * Subscribe to all PUT updates for this key.
6
- * @param key key of the data
7
- * @param userNamespaced If this key bolongs to a user or its public. Making it
8
- * private will enforce validation for our address and signatures.
9
- * @returns Promise<Data>
10
- */
11
- function toolDbSubscribe(key, userNamespaced) {
12
- var _this = this;
13
- if (userNamespaced === void 0) { userNamespaced = false; }
14
- return new Promise(function (resolve, reject) {
15
- if (userNamespaced && _this.userAccount.getAddress() === undefined) {
16
- reject(new Error("You are not authorized yet!"));
17
- return;
18
- }
19
- var finalKey = userNamespaced
20
- ? ":".concat(_this.userAccount.getAddress(), ".").concat(key)
21
- : key;
22
- _this.logger("SUBSCRIBE", finalKey);
23
- var msgId = (0, _1.textRandom)(10);
24
- _this.network.sendToAll({
25
- type: "subscribe",
26
- key: finalKey,
27
- to: [],
28
- id: msgId,
29
- });
30
- _this.store
31
- .get(finalKey)
32
- .then(function (data) {
33
- try {
34
- var message = JSON.parse(data);
35
- _this.triggerKeyListener(finalKey, message);
36
- }
37
- catch (e) {
38
- // do nothing
39
- }
40
- })
41
- .catch(function (e) {
42
- // do nothing
43
- })
44
- .finally(function () {
45
- resolve();
46
- });
47
- });
48
- }
49
- exports.default = toolDbSubscribe;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var _1 = require(".");
4
+ /**
5
+ * Subscribe to all PUT updates for this key.
6
+ * @param key key of the data
7
+ * @param userNamespaced If this key bolongs to a user or its public. Making it
8
+ * private will enforce validation for our address and signatures.
9
+ * @returns Promise<Data>
10
+ */
11
+ function toolDbSubscribe(key, userNamespaced, to) {
12
+ var _this = this;
13
+ if (userNamespaced === void 0) { userNamespaced = false; }
14
+ return new Promise(function (resolve, reject) {
15
+ if (userNamespaced && _this.userAccount.getAddress() === undefined) {
16
+ reject(new Error("You are not authorized yet!"));
17
+ return;
18
+ }
19
+ var finalKey = userNamespaced
20
+ ? ":".concat(_this.userAccount.getAddress(), ".").concat(key)
21
+ : key;
22
+ _this.logger("SUBSCRIBE", finalKey);
23
+ var msgId = (0, _1.textRandom)(10);
24
+ _this.network.sendToAll({
25
+ type: "subscribe",
26
+ key: finalKey,
27
+ to: to || [],
28
+ id: msgId,
29
+ });
30
+ _this.store
31
+ .get(finalKey)
32
+ .then(function (data) {
33
+ try {
34
+ var message = JSON.parse(data);
35
+ _this.triggerKeyListener(finalKey, message);
36
+ }
37
+ catch (e) {
38
+ // do nothing
39
+ }
40
+ })
41
+ .catch(function (e) {
42
+ // do nothing
43
+ })
44
+ .finally(function () {
45
+ resolve();
46
+ });
47
+ });
48
+ }
49
+ exports.default = toolDbSubscribe;
50
50
  //# sourceMappingURL=toolDbSubscribe.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toolDbSubscribe.js","sourceRoot":"","sources":["../lib/toolDbSubscribe.ts"],"names":[],"mappings":";;AAAA,sBAAuC;AAEvC;;;;;;GAMG;AACH,SAAwB,eAA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;AA5CD,kCA4CC"}
@@ -1,2 +1,2 @@
1
- import { ToolDb, VerificationData } from ".";
2
- export default function toolDbVerificationWrapper(this: ToolDb, data: VerificationData<any>): Promise<unknown>;
1
+ import { ToolDb, VerificationData } from ".";
2
+ export default function toolDbVerificationWrapper(this: ToolDb, data: VerificationData<any>): Promise<unknown>;
@@ -1,98 +1,98 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- var _1 = require(".");
40
- function toolDbVerificationWrapper(data) {
41
- var _this = this;
42
- // This wrapper function adds our custom verification functions to all messages.
43
- return new Promise(function (resolve) {
44
- _this.verifyMessage(data, _this.options.pow).then(function (verified) { return __awaiter(_this, void 0, void 0, function () {
45
- var skipCustom_1;
46
- var _this = this;
47
- return __generator(this, function (_a) {
48
- if (verified) {
49
- skipCustom_1 = true;
50
- this._customVerificator.forEach(function (listener) {
51
- if (listener && data.k && data.k.startsWith(listener.key)) {
52
- skipCustom_1 = false;
53
- var previousData_1 = undefined;
54
- // Get the previously stored value of this key
55
- _this.store
56
- .get(data.k)
57
- .then(function (prev) {
58
- try {
59
- previousData_1 = JSON.parse(prev);
60
- }
61
- catch (e) {
62
- // do nothing
63
- }
64
- })
65
- .catch(function (e) {
66
- // do nothing
67
- })
68
- .finally(function () {
69
- listener
70
- .fn(data, previousData_1)
71
- .then(function (verified) {
72
- if (verified) {
73
- resolve(_1.VerifyResult.Verified);
74
- }
75
- else {
76
- resolve(_1.VerifyResult.CustomVerificationFailed);
77
- }
78
- })
79
- .catch(function (e) {
80
- resolve(_1.VerifyResult.CustomVerificationFailed);
81
- });
82
- });
83
- }
84
- });
85
- if (skipCustom_1) {
86
- resolve(verified);
87
- }
88
- }
89
- else {
90
- resolve(_1.VerifyResult.InvalidVerification);
91
- }
92
- return [2 /*return*/];
93
- });
94
- }); });
95
- });
96
- }
97
- exports.default = toolDbVerificationWrapper;
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ var _1 = require(".");
40
+ function toolDbVerificationWrapper(data) {
41
+ var _this = this;
42
+ // This wrapper function adds our custom verification functions to all messages.
43
+ return new Promise(function (resolve) {
44
+ _this.verifyMessage(data, _this.options.pow).then(function (verified) { return __awaiter(_this, void 0, void 0, function () {
45
+ var skipCustom_1;
46
+ var _this = this;
47
+ return __generator(this, function (_a) {
48
+ if (verified) {
49
+ skipCustom_1 = true;
50
+ this._customVerificator.forEach(function (listener) {
51
+ if (listener && data.k && data.k.startsWith(listener.key)) {
52
+ skipCustom_1 = false;
53
+ var previousData_1 = undefined;
54
+ // Get the previously stored value of this key
55
+ _this.store
56
+ .get(data.k)
57
+ .then(function (prev) {
58
+ try {
59
+ previousData_1 = JSON.parse(prev);
60
+ }
61
+ catch (e) {
62
+ // do nothing
63
+ }
64
+ })
65
+ .catch(function (e) {
66
+ // do nothing
67
+ })
68
+ .finally(function () {
69
+ listener
70
+ .fn(data, previousData_1)
71
+ .then(function (verified) {
72
+ if (verified) {
73
+ resolve(_1.VerifyResult.Verified);
74
+ }
75
+ else {
76
+ resolve(_1.VerifyResult.CustomVerificationFailed);
77
+ }
78
+ })
79
+ .catch(function (e) {
80
+ resolve(_1.VerifyResult.CustomVerificationFailed);
81
+ });
82
+ });
83
+ }
84
+ });
85
+ if (skipCustom_1) {
86
+ resolve(verified);
87
+ }
88
+ }
89
+ else {
90
+ resolve(_1.VerifyResult.InvalidVerification);
91
+ }
92
+ return [2 /*return*/];
93
+ });
94
+ }); });
95
+ });
96
+ }
97
+ exports.default = toolDbVerificationWrapper;
98
98
  //# sourceMappingURL=toolDbVerificationWrapper.js.map