tool-db 2.5.0 → 2.5.3
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.
- package/README.md +82 -1
- package/bundle.js +1 -0
- package/dist/adapters-base/networkAdapter.d.ts +58 -0
- package/dist/adapters-base/networkAdapter.js +216 -0
- package/dist/adapters-base/networkAdapter.js.map +1 -0
- package/dist/adapters-base/storageAdapter.d.ts +11 -0
- package/dist/adapters-base/storageAdapter.js +36 -0
- package/dist/adapters-base/storageAdapter.js.map +1 -0
- package/dist/adapters-base/userAdapter.d.ts +15 -0
- package/dist/adapters-base/userAdapter.js +42 -0
- package/dist/adapters-base/userAdapter.js.map +1 -0
- package/dist/crdt/baseCrdt.d.ts +9 -0
- package/dist/crdt/baseCrdt.js +27 -0
- package/dist/crdt/baseCrdt.js.map +1 -0
- package/dist/crdt/counterCrdt.d.ts +30 -0
- package/dist/crdt/counterCrdt.js +106 -0
- package/dist/crdt/counterCrdt.js.map +1 -0
- package/dist/crdt/listCrdt.d.ts +42 -0
- package/dist/crdt/listCrdt.js +159 -0
- package/dist/crdt/listCrdt.js.map +1 -0
- package/dist/crdt/mapCrdt.d.ts +32 -0
- package/dist/crdt/mapCrdt.js +118 -0
- package/dist/crdt/mapCrdt.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +83 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +2 -0
- package/dist/logger.js +29 -0
- package/dist/logger.js.map +1 -0
- package/dist/messageHandlers/handleCrdtGet.d.ts +2 -0
- package/dist/messageHandlers/handleCrdtGet.js +29 -0
- package/dist/messageHandlers/handleCrdtGet.js.map +1 -0
- package/dist/messageHandlers/handleCrdtPut.d.ts +2 -0
- package/dist/messageHandlers/handleCrdtPut.js +93 -0
- package/dist/messageHandlers/handleCrdtPut.js.map +1 -0
- package/dist/messageHandlers/handleGet.d.ts +2 -0
- package/dist/messageHandlers/handleGet.js +29 -0
- package/dist/messageHandlers/handleGet.js.map +1 -0
- package/dist/messageHandlers/handlePing.d.ts +2 -0
- package/dist/messageHandlers/handlePing.js +36 -0
- package/dist/messageHandlers/handlePing.js.map +1 -0
- package/dist/messageHandlers/handlePong.d.ts +2 -0
- package/dist/messageHandlers/handlePong.js +26 -0
- package/dist/messageHandlers/handlePong.js.map +1 -0
- package/dist/messageHandlers/handlePut.d.ts +2 -0
- package/dist/messageHandlers/handlePut.js +57 -0
- package/dist/messageHandlers/handlePut.js.map +1 -0
- package/dist/messageHandlers/handleQuery.d.ts +2 -0
- package/dist/messageHandlers/handleQuery.js +23 -0
- package/dist/messageHandlers/handleQuery.js.map +1 -0
- package/dist/messageHandlers/handleSubscribe.d.ts +2 -0
- package/dist/messageHandlers/handleSubscribe.js +44 -0
- package/dist/messageHandlers/handleSubscribe.js.map +1 -0
- package/dist/server.d.ts +1 -0
- package/dist/server.js +9 -0
- package/dist/server.js.map +1 -0
- package/dist/shared.d.ts +2 -0
- package/dist/shared.js +7 -0
- package/dist/shared.js.map +1 -0
- package/dist/toolDbAnonSignIn.d.ts +2 -0
- package/dist/toolDbAnonSignIn.js +7 -0
- package/dist/toolDbAnonSignIn.js.map +1 -0
- package/dist/toolDbClientOnMessage.d.ts +2 -0
- package/dist/toolDbClientOnMessage.js +59 -0
- package/dist/toolDbClientOnMessage.js.map +1 -0
- package/dist/toolDbCrdtGet.d.ts +9 -0
- package/dist/toolDbCrdtGet.js +77 -0
- package/dist/toolDbCrdtGet.js.map +1 -0
- package/dist/toolDbCrdtPut.d.ts +9 -0
- package/dist/toolDbCrdtPut.js +63 -0
- package/dist/toolDbCrdtPut.js.map +1 -0
- package/dist/toolDbGet.d.ts +9 -0
- package/dist/toolDbGet.js +77 -0
- package/dist/toolDbGet.js.map +1 -0
- package/dist/toolDbKeysSignIn.d.ts +2 -0
- package/dist/toolDbKeysSignIn.js +16 -0
- package/dist/toolDbKeysSignIn.js.map +1 -0
- package/dist/toolDbPut.d.ts +9 -0
- package/dist/toolDbPut.js +69 -0
- package/dist/toolDbPut.js.map +1 -0
- package/dist/toolDbQueryKeys.d.ts +8 -0
- package/dist/toolDbQueryKeys.js +66 -0
- package/dist/toolDbQueryKeys.js.map +1 -0
- package/dist/toolDbSignIn.d.ts +2 -0
- package/dist/toolDbSignIn.js +27 -0
- package/dist/toolDbSignIn.js.map +1 -0
- package/dist/toolDbSignUp.d.ts +2 -0
- package/dist/toolDbSignUp.js +101 -0
- package/dist/toolDbSignUp.js.map +1 -0
- package/dist/toolDbSubscribe.d.ts +9 -0
- package/dist/toolDbSubscribe.js +50 -0
- package/dist/toolDbSubscribe.js.map +1 -0
- package/dist/toolDbVerificationWrapper.d.ts +2 -0
- package/dist/toolDbVerificationWrapper.js +98 -0
- package/dist/toolDbVerificationWrapper.js.map +1 -0
- package/dist/tooldb.d.ts +108 -0
- package/dist/tooldb.js +286 -0
- package/dist/tooldb.js.map +1 -0
- package/dist/types/message.d.ts +100 -0
- package/dist/types/message.js +17 -0
- package/dist/types/message.js.map +1 -0
- package/dist/types/tooldb.d.ts +84 -0
- package/dist/types/tooldb.js +3 -0
- package/dist/types/tooldb.js.map +1 -0
- package/dist/utils/catchReturn.d.ts +1 -0
- package/dist/utils/catchReturn.js +8 -0
- package/dist/utils/catchReturn.js.map +1 -0
- package/dist/utils/encoding/arrayBufferToHex.d.ts +1 -0
- package/dist/utils/encoding/arrayBufferToHex.js +19 -0
- package/dist/utils/encoding/arrayBufferToHex.js.map +1 -0
- package/dist/utils/encoding/arrayBufferToString.d.ts +1 -0
- package/dist/utils/encoding/arrayBufferToString.js +12 -0
- package/dist/utils/encoding/arrayBufferToString.js.map +1 -0
- package/dist/utils/encoding/hexToArrayBuffer.d.ts +1 -0
- package/dist/utils/encoding/hexToArrayBuffer.js +15 -0
- package/dist/utils/encoding/hexToArrayBuffer.js.map +1 -0
- package/dist/utils/encoding/hexToString.d.ts +1 -0
- package/dist/utils/encoding/hexToString.js +12 -0
- package/dist/utils/encoding/hexToString.js.map +1 -0
- package/dist/utils/encoding/hexToUint8.d.ts +1 -0
- package/dist/utils/encoding/hexToUint8.js +8 -0
- package/dist/utils/encoding/hexToUint8.js.map +1 -0
- package/dist/utils/encoding/stringToArrayBuffer.d.ts +1 -0
- package/dist/utils/encoding/stringToArrayBuffer.js +12 -0
- package/dist/utils/encoding/stringToArrayBuffer.js.map +1 -0
- package/dist/utils/getPeerSignature.d.ts +2 -0
- package/dist/utils/getPeerSignature.js +9 -0
- package/dist/utils/getPeerSignature.js.map +1 -0
- package/dist/utils/getTimestamp.d.ts +1 -0
- package/dist/utils/getTimestamp.js +7 -0
- package/dist/utils/getTimestamp.js.map +1 -0
- package/dist/utils/proofOfWork.d.ts +4 -0
- package/dist/utils/proofOfWork.js +16 -0
- package/dist/utils/proofOfWork.js.map +1 -0
- package/dist/utils/randomAnimal.d.ts +1 -0
- package/dist/utils/randomAnimal.js +77 -0
- package/dist/utils/randomAnimal.js.map +1 -0
- package/dist/utils/sha1.d.ts +1 -0
- package/dist/utils/sha1.js +13 -0
- package/dist/utils/sha1.js.map +1 -0
- package/dist/utils/sha256.d.ts +3 -0
- package/dist/utils/sha256.js +13 -0
- package/dist/utils/sha256.js.map +1 -0
- package/dist/utils/textRandom.d.ts +1 -0
- package/dist/utils/textRandom.js +15 -0
- package/dist/utils/textRandom.js.map +1 -0
- package/dist/utils/uniq.d.ts +1 -0
- package/dist/utils/uniq.js +7 -0
- package/dist/utils/uniq.js.map +1 -0
- package/dist/utils/verifyMessage.d.ts +8 -0
- package/dist/utils/verifyMessage.js +129 -0
- package/dist/utils/verifyMessage.js.map +1 -0
- package/dist/utils/verifyPeer.d.ts +2 -0
- package/dist/utils/verifyPeer.js +15 -0
- package/dist/utils/verifyPeer.js.map +1 -0
- package/lib/adapters-base/networkAdapter.ts +217 -215
- package/lib/adapters-base/storageAdapter.ts +35 -35
- package/lib/adapters-base/userAdapter.ts +49 -49
- package/lib/crdt/baseCrdt.ts +21 -21
- package/lib/crdt/counterCrdt.ts +111 -111
- package/lib/crdt/listCrdt.ts +190 -190
- package/lib/crdt/mapCrdt.ts +119 -119
- package/lib/index.ts +42 -42
- package/lib/logger.ts +30 -30
- package/lib/messageHandlers/handleCrdtGet.ts +29 -29
- package/lib/messageHandlers/handleCrdtPut.ts +118 -118
- package/lib/messageHandlers/handleGet.ts +29 -29
- package/lib/messageHandlers/handlePing.ts +40 -40
- package/lib/messageHandlers/handlePong.ts +30 -30
- package/lib/messageHandlers/handlePut.ts +54 -54
- package/lib/messageHandlers/handleQuery.ts +25 -25
- package/lib/messageHandlers/handleSubscribe.ts +46 -46
- package/lib/server.ts +7 -7
- package/lib/shared.ts +5 -5
- package/lib/toolDbAnonSignIn.ts +5 -5
- package/lib/toolDbClientOnMessage.ts +75 -75
- package/lib/toolDbCrdtGet.ts +82 -82
- package/lib/toolDbCrdtPut.ts +77 -77
- package/lib/toolDbGet.ts +80 -80
- package/lib/toolDbKeysSignIn.ts +16 -16
- package/lib/toolDbPut.ts +83 -83
- package/lib/toolDbQueryKeys.ts +64 -64
- package/lib/toolDbSignIn.ts +31 -31
- package/lib/toolDbSignUp.ts +71 -71
- package/lib/toolDbSubscribe.ts +53 -53
- package/lib/toolDbVerificationWrapper.ts +55 -55
- package/lib/tooldb.ts +316 -314
- package/lib/types/message.ts +133 -133
- package/lib/types/tooldb.ts +97 -89
- package/lib/utils/catchReturn.ts +4 -4
- package/lib/utils/encoding/arrayBufferToHex.ts +18 -18
- package/lib/utils/encoding/arrayBufferToString.ts +8 -8
- package/lib/utils/encoding/hexToArrayBuffer.ts +13 -13
- package/lib/utils/encoding/hexToString.ts +8 -8
- package/lib/utils/encoding/hexToUint8.ts +5 -5
- package/lib/utils/encoding/stringToArrayBuffer.ts +8 -8
- package/lib/utils/getPeerSignature.ts +12 -12
- package/lib/utils/getTimestamp.ts +3 -3
- package/lib/utils/proofOfWork.ts +16 -16
- package/lib/utils/randomAnimal.ts +77 -77
- package/lib/utils/sha1.ts +7 -7
- package/lib/utils/sha256.ts +7 -7
- package/lib/utils/textRandom.ts +11 -11
- package/lib/utils/uniq.ts +3 -3
- package/lib/utils/verifyMessage.ts +88 -88
- package/lib/utils/verifyPeer.ts +15 -15
- package/package.json +4 -3
- package/tsconfig.json +14 -14
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function arrayBufferToString(arr) {
|
|
4
|
+
var byteArray = new Uint8Array(arr);
|
|
5
|
+
var byteString = "";
|
|
6
|
+
for (var i = 0; i < byteArray.byteLength; i += 1) {
|
|
7
|
+
byteString += String.fromCodePoint(byteArray[i]);
|
|
8
|
+
}
|
|
9
|
+
return byteString;
|
|
10
|
+
}
|
|
11
|
+
exports.default = arrayBufferToString;
|
|
12
|
+
//# sourceMappingURL=arrayBufferToString.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arrayBufferToString.js","sourceRoot":"","sources":["../../../lib/utils/encoding/arrayBufferToString.ts"],"names":[],"mappings":";;AAAA,SAAwB,mBAAmB,CAAC,GAAgB;IAC1D,IAAM,SAAS,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,UAAU,GAAG,EAAE,CAAC;IACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC,EAAE;QAChD,UAAU,IAAI,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;KAClD;IACD,OAAO,UAAU,CAAC;AACpB,CAAC;AAPD,sCAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function hexToArrayBuffer(hex: string): ArrayBuffer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function hexToArrayBuffer(hex) {
|
|
4
|
+
var pairs = hex.toUpperCase().match(/[\dA-F]{2}/gi);
|
|
5
|
+
if (!pairs)
|
|
6
|
+
return new Uint8Array();
|
|
7
|
+
// convert the octets to integers
|
|
8
|
+
var integers = pairs.map(function (s) {
|
|
9
|
+
return parseInt(s, 16);
|
|
10
|
+
});
|
|
11
|
+
var array = new Uint8Array(integers);
|
|
12
|
+
return array.buffer;
|
|
13
|
+
}
|
|
14
|
+
exports.default = hexToArrayBuffer;
|
|
15
|
+
//# sourceMappingURL=hexToArrayBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hexToArrayBuffer.js","sourceRoot":"","sources":["../../../lib/utils/encoding/hexToArrayBuffer.ts"],"names":[],"mappings":";;AAAA,SAAwB,gBAAgB,CAAC,GAAW;IAClD,IAAM,KAAK,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAEtD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,UAAU,EAAE,CAAC;IAEpC,iCAAiC;IACjC,IAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,IAAM,KAAK,GAAG,IAAI,UAAU,CAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,KAAK,CAAC,MAAM,CAAC;AACtB,CAAC;AAZD,mCAYC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function hexToString(hexString: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function hexToString(hexString) {
|
|
4
|
+
var hex = hexString.toString();
|
|
5
|
+
var str = "";
|
|
6
|
+
for (var n = 0; n < hex.length; n += 2) {
|
|
7
|
+
str += String.fromCharCode(parseInt(hex.substr(n, 2), 16));
|
|
8
|
+
}
|
|
9
|
+
return str;
|
|
10
|
+
}
|
|
11
|
+
exports.default = hexToString;
|
|
12
|
+
//# sourceMappingURL=hexToString.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hexToString.js","sourceRoot":"","sources":["../../../lib/utils/encoding/hexToString.ts"],"names":[],"mappings":";;AAAA,SAAwB,WAAW,CAAC,SAAiB;IACnD,IAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;IACjC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACtC,GAAG,IAAI,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;KAC5D;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAPD,8BAOC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function hexToUint8(hex: string): Uint8Array;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var __1 = require("../..");
|
|
4
|
+
function hexToUint8(hex) {
|
|
5
|
+
return new Uint8Array((0, __1.hexToArrayBuffer)(hex));
|
|
6
|
+
}
|
|
7
|
+
exports.default = hexToUint8;
|
|
8
|
+
//# sourceMappingURL=hexToUint8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hexToUint8.js","sourceRoot":"","sources":["../../../lib/utils/encoding/hexToUint8.ts"],"names":[],"mappings":";;AAAA,2BAAyC;AAEzC,SAAwB,UAAU,CAAC,GAAW;IAC5C,OAAO,IAAI,UAAU,CAAC,IAAA,oBAAgB,EAAC,GAAG,CAAC,CAAC,CAAC;AAC/C,CAAC;AAFD,6BAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function stringToArrayBuffer(str: string): ArrayBuffer;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function stringToArrayBuffer(str) {
|
|
4
|
+
var buf = new ArrayBuffer(str.length);
|
|
5
|
+
var bufView = new Uint8Array(buf);
|
|
6
|
+
for (var i = 0, strLen = str.length; i < strLen; i += 1) {
|
|
7
|
+
bufView[i] = str.charCodeAt(i);
|
|
8
|
+
}
|
|
9
|
+
return buf;
|
|
10
|
+
}
|
|
11
|
+
exports.default = stringToArrayBuffer;
|
|
12
|
+
//# sourceMappingURL=stringToArrayBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringToArrayBuffer.js","sourceRoot":"","sources":["../../../lib/utils/encoding/stringToArrayBuffer.ts"],"names":[],"mappings":";;AAAA,SAAwB,mBAAmB,CAAC,GAAW;IACrD,IAAM,GAAG,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACxC,IAAM,OAAO,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAC;IACpC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QACvD,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;KAChC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAPD,sCAOC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var __1 = require("..");
|
|
4
|
+
function getPeerSignature(account, topic, timestamp, host, port) {
|
|
5
|
+
var dataToSign = (0, __1.sha256)("".concat(topic, "-").concat(timestamp, "-").concat(host, ":").concat(port));
|
|
6
|
+
return account.signData(dataToSign);
|
|
7
|
+
}
|
|
8
|
+
exports.default = getPeerSignature;
|
|
9
|
+
//# sourceMappingURL=getPeerSignature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPeerSignature.js","sourceRoot":"","sources":["../../lib/utils/getPeerSignature.ts"],"names":[],"mappings":";;AAAA,wBAA+C;AAE/C,SAAwB,gBAAgB,CACtC,OAA0B,EAC1B,KAAa,EACb,SAAiB,EACjB,IAAY,EACZ,IAAY;IAEZ,IAAM,UAAU,GAAG,IAAA,UAAM,EAAC,UAAG,KAAK,cAAI,SAAS,cAAI,IAAI,cAAI,IAAI,CAAE,CAAC,CAAC;IACnE,OAAO,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC;AATD,mCASC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getTimestamp(): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTimestamp.js","sourceRoot":"","sources":["../../lib/utils/getTimestamp.ts"],"names":[],"mappings":";;AAAA,SAAwB,YAAY;IAClC,OAAO,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;AAC9B,CAAC;AAFD,+BAEC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var __1 = require("..");
|
|
4
|
+
function proofOfWork(value, difficulty) {
|
|
5
|
+
return new Promise(function (resolve) {
|
|
6
|
+
var nonce = 0;
|
|
7
|
+
var hash = (0, __1.sha256)("".concat(value).concat(nonce));
|
|
8
|
+
while (hash.substring(0, difficulty) !== Array(difficulty + 1).join("0")) {
|
|
9
|
+
nonce += 1;
|
|
10
|
+
hash = (0, __1.sha256)("".concat(value).concat(nonce));
|
|
11
|
+
}
|
|
12
|
+
resolve({ nonce: nonce, hash: hash });
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
exports.default = proofOfWork;
|
|
16
|
+
//# sourceMappingURL=proofOfWork.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proofOfWork.js","sourceRoot":"","sources":["../../lib/utils/proofOfWork.ts"],"names":[],"mappings":";;AAAA,wBAA4B;AAE5B,SAAwB,WAAW,CACjC,KAAa,EACb,UAAkB;IAElB,OAAO,IAAI,OAAO,CAAC,UAAC,OAAO;QACzB,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,IAAI,GAAG,IAAA,UAAM,EAAC,UAAG,KAAK,SAAG,KAAK,CAAE,CAAC,CAAC;QACtC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,KAAK,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACxE,KAAK,IAAI,CAAC,CAAC;YACX,IAAI,GAAG,IAAA,UAAM,EAAC,UAAG,KAAK,SAAG,KAAK,CAAE,CAAC,CAAC;SACnC;QACD,OAAO,CAAC,EAAE,KAAK,OAAA,EAAE,IAAI,MAAA,EAAE,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC;AAbD,8BAaC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function randomAnimal(): string;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var adjectives = [
|
|
4
|
+
"Fast",
|
|
5
|
+
"Slow",
|
|
6
|
+
"Cute",
|
|
7
|
+
"Evil",
|
|
8
|
+
"Anxious",
|
|
9
|
+
"Cursed",
|
|
10
|
+
"Average",
|
|
11
|
+
"Zombie",
|
|
12
|
+
"Smart",
|
|
13
|
+
"Small",
|
|
14
|
+
"Tall",
|
|
15
|
+
"Amazing",
|
|
16
|
+
"Splendid",
|
|
17
|
+
"Fat",
|
|
18
|
+
"Invisible",
|
|
19
|
+
"Regular",
|
|
20
|
+
"Domestic",
|
|
21
|
+
"Unique",
|
|
22
|
+
"Soft",
|
|
23
|
+
"Lazy",
|
|
24
|
+
"Angry",
|
|
25
|
+
"Relaxed",
|
|
26
|
+
"Huge",
|
|
27
|
+
"Shy",
|
|
28
|
+
"Playful",
|
|
29
|
+
"Creepy",
|
|
30
|
+
"Ancient",
|
|
31
|
+
"Beautiful",
|
|
32
|
+
];
|
|
33
|
+
var animals = [
|
|
34
|
+
"Snake",
|
|
35
|
+
"Monkey",
|
|
36
|
+
"Platypus",
|
|
37
|
+
"Fox",
|
|
38
|
+
"Lynx",
|
|
39
|
+
"Pug",
|
|
40
|
+
"Chicken",
|
|
41
|
+
"Slug",
|
|
42
|
+
"Snail",
|
|
43
|
+
"Pig",
|
|
44
|
+
"Cow",
|
|
45
|
+
"Sheep",
|
|
46
|
+
"Horse",
|
|
47
|
+
"Squirrel",
|
|
48
|
+
"Turtle",
|
|
49
|
+
"Unicorn",
|
|
50
|
+
"Dragon",
|
|
51
|
+
"Dolphin",
|
|
52
|
+
"Cat",
|
|
53
|
+
"Chow Chow",
|
|
54
|
+
"Elephant",
|
|
55
|
+
"Meerkat",
|
|
56
|
+
"Polar Bear",
|
|
57
|
+
"Bear",
|
|
58
|
+
"Rabbit",
|
|
59
|
+
"Koala",
|
|
60
|
+
"Parrot",
|
|
61
|
+
"Raven",
|
|
62
|
+
"Frog",
|
|
63
|
+
"Rat",
|
|
64
|
+
"Mouse",
|
|
65
|
+
"Bee",
|
|
66
|
+
"Tiger",
|
|
67
|
+
"Lion",
|
|
68
|
+
"Giraffe",
|
|
69
|
+
"Ant",
|
|
70
|
+
"Spider",
|
|
71
|
+
"Zebra",
|
|
72
|
+
];
|
|
73
|
+
function randomAnimal() {
|
|
74
|
+
return "".concat(adjectives[Math.floor(Math.random() * adjectives.length)], " ").concat(animals[Math.floor(Math.random() * animals.length)]);
|
|
75
|
+
}
|
|
76
|
+
exports.default = randomAnimal;
|
|
77
|
+
//# sourceMappingURL=randomAnimal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"randomAnimal.js","sourceRoot":"","sources":["../../lib/utils/randomAnimal.ts"],"names":[],"mappings":";;AAAA,IAAM,UAAU,GAAG;IACjB,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,SAAS;IACT,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,OAAO;IACP,OAAO;IACP,MAAM;IACN,SAAS;IACT,UAAU;IACV,KAAK;IACL,WAAW;IACX,SAAS;IACT,UAAU;IACV,QAAQ;IACR,MAAM;IACN,MAAM;IACN,OAAO;IACP,SAAS;IACT,MAAM;IACN,KAAK;IACL,SAAS;IACT,QAAQ;IACR,SAAS;IACT,WAAW;CACZ,CAAC;AAEF,IAAM,OAAO,GAAG;IACd,OAAO;IACP,QAAQ;IACR,UAAU;IACV,KAAK;IACL,MAAM;IACN,KAAK;IACL,SAAS;IACT,MAAM;IACN,OAAO;IACP,KAAK;IACL,KAAK;IACL,OAAO;IACP,OAAO;IACP,UAAU;IACV,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,SAAS;IACT,KAAK;IACL,WAAW;IACX,UAAU;IACV,SAAS;IACT,YAAY;IACZ,MAAM;IACN,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,OAAO;IACP,MAAM;IACN,KAAK;IACL,OAAO;IACP,KAAK;IACL,OAAO;IACP,MAAM;IACN,SAAS;IACT,KAAK;IACL,QAAQ;IACR,OAAO;CACR,CAAC;AAEF,SAAwB,YAAY;IAClC,OAAO,UAAG,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,cACjE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CACnD,CAAC;AACL,CAAC;AAJD,+BAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function sha1(str: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var crypto_1 = __importDefault(require("crypto"));
|
|
7
|
+
function sha1(str) {
|
|
8
|
+
var hash = crypto_1.default.createHash("sha1");
|
|
9
|
+
hash.update(str);
|
|
10
|
+
return hash.digest("hex");
|
|
11
|
+
}
|
|
12
|
+
exports.default = sha1;
|
|
13
|
+
//# sourceMappingURL=sha1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha1.js","sourceRoot":"","sources":["../../lib/utils/sha1.ts"],"names":[],"mappings":";;;;;AAAA,kDAA4B;AAE5B,SAAwB,IAAI,CAAC,GAAW;IACtC,IAAM,IAAI,GAAG,gBAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAJD,uBAIC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var crypto_1 = __importDefault(require("crypto"));
|
|
7
|
+
function sha256(str) {
|
|
8
|
+
var hash = crypto_1.default.createHash("sha256");
|
|
9
|
+
hash.update(str);
|
|
10
|
+
return hash.digest("hex");
|
|
11
|
+
}
|
|
12
|
+
exports.default = sha256;
|
|
13
|
+
//# sourceMappingURL=sha256.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sha256.js","sourceRoot":"","sources":["../../lib/utils/sha256.ts"],"names":[],"mappings":";;;;;AAAA,kDAA4C;AAE5C,SAAwB,MAAM,CAAC,GAAe;IAC5C,IAAM,IAAI,GAAG,gBAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAJD,yBAIC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function textRandom(_l?: number, _c?: string): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
function textRandom(_l, _c) {
|
|
4
|
+
if (_l === void 0) { _l = 24; }
|
|
5
|
+
var l = _l;
|
|
6
|
+
var s = "";
|
|
7
|
+
var c = _c || "0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";
|
|
8
|
+
while (l > 0) {
|
|
9
|
+
s += c.charAt(Math.floor(Math.random() * c.length));
|
|
10
|
+
l -= 1;
|
|
11
|
+
}
|
|
12
|
+
return s;
|
|
13
|
+
}
|
|
14
|
+
exports.default = textRandom;
|
|
15
|
+
//# sourceMappingURL=textRandom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"textRandom.js","sourceRoot":"","sources":["../../lib/utils/textRandom.ts"],"names":[],"mappings":";;AAAA,SAAwB,UAAU,CAAC,EAAO,EAAE,EAAW;IAApB,mBAAA,EAAA,OAAO;IACxC,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,IAAI,CAAC,GAAG,EAAE,CAAC;IACX,IAAM,CAAC,GACL,EAAE,IAAI,+DAA+D,CAAC;IACxE,OAAO,CAAC,GAAG,CAAC,EAAE;QACZ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QACpD,CAAC,IAAI,CAAC,CAAC;KACR;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAVD,6BAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function uniq<T>(array: T[]): T[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniq.js","sourceRoot":"","sources":["../../lib/utils/uniq.ts"],"names":[],"mappings":";;AAAA,SAAwB,IAAI,CAAI,KAAU;IACxC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AACpC,CAAC;AAFD,uBAEC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ToolDb, VerifyResult, VerificationData } from "..";
|
|
2
|
+
/**
|
|
3
|
+
* Verifies a message validity (PoW, Address, timestamp, signatures)
|
|
4
|
+
* @param msg AnyMessage
|
|
5
|
+
* @param pow amount of proof of work required, number of leading zeroes (default is 0/no pow)
|
|
6
|
+
* @returns boolean or undefined if the message type does not match
|
|
7
|
+
*/
|
|
8
|
+
export default function verifyMessage<T>(this: ToolDb, msg: Partial<VerificationData<T>>, pow?: number): Promise<VerifyResult>;
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
/**
|
|
41
|
+
* Verifies a message validity (PoW, Address, timestamp, signatures)
|
|
42
|
+
* @param msg AnyMessage
|
|
43
|
+
* @param pow amount of proof of work required, number of leading zeroes (default is 0/no pow)
|
|
44
|
+
* @returns boolean or undefined if the message type does not match
|
|
45
|
+
*/
|
|
46
|
+
function verifyMessage(msg, pow) {
|
|
47
|
+
if (pow === void 0) { pow = 0; }
|
|
48
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
49
|
+
var strData, addressNamespace, key, data, verified, _a;
|
|
50
|
+
return __generator(this, function (_b) {
|
|
51
|
+
switch (_b.label) {
|
|
52
|
+
case 0:
|
|
53
|
+
strData = JSON.stringify(msg.v);
|
|
54
|
+
if (msg.t === undefined ||
|
|
55
|
+
msg.k === undefined ||
|
|
56
|
+
msg.h === undefined ||
|
|
57
|
+
msg.a === undefined ||
|
|
58
|
+
msg.s === undefined ||
|
|
59
|
+
msg.c === undefined) {
|
|
60
|
+
return [2 /*return*/, __1.VerifyResult.InvalidData];
|
|
61
|
+
}
|
|
62
|
+
// Max clock shift allowed is 30 seconds.
|
|
63
|
+
// Ten seconds was my original threshold but it failed some times.
|
|
64
|
+
if (msg.t > new Date().getTime() + 30000) {
|
|
65
|
+
// this.logger("Invalid message timestamp.");
|
|
66
|
+
return [2 /*return*/, __1.VerifyResult.InvalidTimestamp];
|
|
67
|
+
}
|
|
68
|
+
addressNamespace = false;
|
|
69
|
+
if (msg.k.slice(0, 1) == ":") {
|
|
70
|
+
addressNamespace = msg.k.split(".")[0].slice(1);
|
|
71
|
+
}
|
|
72
|
+
if (!(msg.k.slice(0, 2) == "==")) return [3 /*break*/, 2];
|
|
73
|
+
key = msg.k;
|
|
74
|
+
return [4 /*yield*/, this.store
|
|
75
|
+
.get(key)
|
|
76
|
+
.then(function (data) {
|
|
77
|
+
try {
|
|
78
|
+
var message = JSON.parse(data);
|
|
79
|
+
return message;
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
.catch(function () {
|
|
86
|
+
return null;
|
|
87
|
+
})];
|
|
88
|
+
case 1:
|
|
89
|
+
data = _b.sent();
|
|
90
|
+
if (data && data.a !== msg.a)
|
|
91
|
+
return [2 /*return*/, __1.VerifyResult.CantOverwrite];
|
|
92
|
+
_b.label = 2;
|
|
93
|
+
case 2:
|
|
94
|
+
if (addressNamespace && addressNamespace !== msg.a) {
|
|
95
|
+
// this.logger("Provided address does not match");
|
|
96
|
+
return [2 /*return*/, __1.VerifyResult.AddressMismatch];
|
|
97
|
+
}
|
|
98
|
+
// Verify hash and nonce (adjust zeroes for difficulty of the network)
|
|
99
|
+
// While this POW does not enforce security per-se, it does make it harder
|
|
100
|
+
// for attackers to spam the network, and could be adjusted by peers.
|
|
101
|
+
// Disabled for now because it is painful on large requests
|
|
102
|
+
if (pow > 0) {
|
|
103
|
+
if (msg.h.slice(0, pow) !== new Array(pow).fill("0").join("")) {
|
|
104
|
+
// this.logger("No valid hash (no pow)");
|
|
105
|
+
return [2 /*return*/, __1.VerifyResult.NoProofOfWork];
|
|
106
|
+
}
|
|
107
|
+
if ((0, __1.sha256)("".concat(strData).concat(msg.a).concat(msg.t).concat(msg.n)) !== msg.h) {
|
|
108
|
+
// this.logger("Specified hash does not generate a valid pow");
|
|
109
|
+
return [2 /*return*/, __1.VerifyResult.InvalidHashNonce];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (!this.userAccount) return [3 /*break*/, 4];
|
|
113
|
+
return [4 /*yield*/, this.userAccount.verifySignature(msg)];
|
|
114
|
+
case 3:
|
|
115
|
+
_a = _b.sent();
|
|
116
|
+
return [3 /*break*/, 5];
|
|
117
|
+
case 4:
|
|
118
|
+
_a = false;
|
|
119
|
+
_b.label = 5;
|
|
120
|
+
case 5:
|
|
121
|
+
verified = _a;
|
|
122
|
+
// this.logger(`Signature validation: ${verified ? "Sucess" : "Failed"}`);
|
|
123
|
+
return [2 /*return*/, verified ? __1.VerifyResult.Verified : __1.VerifyResult.InvalidSignature];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
exports.default = verifyMessage;
|
|
129
|
+
//# sourceMappingURL=verifyMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyMessage.js","sourceRoot":"","sources":["../../lib/utils/verifyMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wBAAoE;AAEpE;;;;;GAKG;AACH,SAA8B,aAAa,CAEzC,GAAiC,EACjC,GAAO;IAAP,oBAAA,EAAA,OAAO;;;;;;oBAGD,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;oBAEtC,IACE,GAAG,CAAC,CAAC,KAAK,SAAS;wBACnB,GAAG,CAAC,CAAC,KAAK,SAAS;wBACnB,GAAG,CAAC,CAAC,KAAK,SAAS;wBACnB,GAAG,CAAC,CAAC,KAAK,SAAS;wBACnB,GAAG,CAAC,CAAC,KAAK,SAAS;wBACnB,GAAG,CAAC,CAAC,KAAK,SAAS,EACnB;wBACA,sBAAO,gBAAY,CAAC,WAAW,EAAC;qBACjC;oBAED,yCAAyC;oBACzC,kEAAkE;oBAClE,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,EAAE;wBACxC,6CAA6C;wBAC7C,sBAAO,gBAAY,CAAC,gBAAgB,EAAC;qBACtC;oBAGG,gBAAgB,GAAmB,KAAK,CAAC;oBAC7C,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,GAAG,EAAE;wBAC5B,gBAAgB,GAAG,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;qBACjD;yBAIG,CAAA,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAA,EAAzB,wBAAyB;oBACrB,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC;oBACL,qBAAM,IAAI,CAAC,KAAK;6BAC1B,GAAG,CAAC,GAAG,CAAC;6BACR,IAAI,CAAC,UAAC,IAAI;4BACT,IAAI;gCACF,IAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gCACjC,OAAO,OAAO,CAAC;6BAChB;4BAAC,OAAO,CAAC,EAAE;gCACV,OAAO,IAAI,CAAC;6BACb;wBACH,CAAC,CAAC;6BACD,KAAK,CAAC;4BACL,OAAO,IAAI,CAAC;wBACd,CAAC,CAAC,EAAA;;oBAZE,IAAI,GAAG,SAYT;oBACJ,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;wBAAE,sBAAO,gBAAY,CAAC,aAAa,EAAC;;;oBAGlE,IAAI,gBAAgB,IAAI,gBAAgB,KAAK,GAAG,CAAC,CAAC,EAAE;wBAClD,kDAAkD;wBAClD,sBAAO,gBAAY,CAAC,eAAe,EAAC;qBACrC;oBAED,sEAAsE;oBACtE,0EAA0E;oBAC1E,qEAAqE;oBACrE,2DAA2D;oBAC3D,IAAI,GAAG,GAAG,CAAC,EAAE;wBACX,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;4BAC7D,yCAAyC;4BACzC,sBAAO,gBAAY,CAAC,aAAa,EAAC;yBACnC;wBAED,IAAI,IAAA,UAAM,EAAC,UAAG,OAAO,SAAG,GAAG,CAAC,CAAC,SAAG,GAAG,CAAC,CAAC,SAAG,GAAG,CAAC,CAAC,CAAE,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE;4BAC1D,+DAA+D;4BAC/D,sBAAO,gBAAY,CAAC,gBAAgB,EAAC;yBACtC;qBACF;yBAEgB,IAAI,CAAC,WAAW,EAAhB,wBAAgB;oBAC7B,qBAAM,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,GAAG,CAAC,EAAA;;oBAA3C,KAAA,SAA2C,CAAA;;;oBAC3C,KAAA,KAAK,CAAA;;;oBAFH,QAAQ,KAEL;oBACT,0EAA0E;oBAE1E,sBAAO,QAAQ,CAAC,CAAC,CAAC,gBAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,gBAAY,CAAC,gBAAgB,EAAC;;;;CACzE;AA/ED,gCA+EC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var __1 = require("..");
|
|
4
|
+
function verifyPeer(tooldb, peer) {
|
|
5
|
+
var data = (0, __1.sha256)("".concat(peer.topic, "-").concat(peer.timestamp, "-").concat(peer.host, ":").concat(peer.port));
|
|
6
|
+
// its not really a message but this function works with a Partial
|
|
7
|
+
// I want to keep it like this so the signature verification is in a single place
|
|
8
|
+
return tooldb.verifyMessage({
|
|
9
|
+
h: data,
|
|
10
|
+
a: peer.address,
|
|
11
|
+
s: peer.sig,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
exports.default = verifyPeer;
|
|
15
|
+
//# sourceMappingURL=verifyPeer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verifyPeer.js","sourceRoot":"","sources":["../../lib/utils/verifyPeer.ts"],"names":[],"mappings":";;AAAA,wBAA0C;AAE1C,SAAwB,UAAU,CAAC,MAAc,EAAE,IAAU;IAC3D,IAAM,IAAI,GAAG,IAAA,UAAM,EACjB,UAAG,IAAI,CAAC,KAAK,cAAI,IAAI,CAAC,SAAS,cAAI,IAAI,CAAC,IAAI,cAAI,IAAI,CAAC,IAAI,CAAE,CAC5D,CAAC;IAEF,kEAAkE;IAClE,iFAAiF;IACjF,OAAO,MAAM,CAAC,aAAa,CAAC;QAC1B,CAAC,EAAE,IAAI;QACP,CAAC,EAAE,IAAI,CAAC,OAAO;QACf,CAAC,EAAE,IAAI,CAAC,GAAG;KACZ,CAAC,CAAC;AACL,CAAC;AAZD,6BAYC"}
|