@voiceflow/common 7.13.4 → 7.15.2
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/build/common/crypto/hex2abc.d.ts +7 -0
- package/build/common/crypto/hex2abc.js +32 -0
- package/build/common/crypto/hex2abc.js.map +1 -0
- package/build/common/crypto/index.d.ts +1 -0
- package/build/common/crypto/index.js +3 -1
- package/build/common/crypto/index.js.map +1 -1
- package/build/common/crypto/murmurhash.d.ts +4 -0
- package/build/common/crypto/murmurhash.js +16 -0
- package/build/common/crypto/murmurhash.js.map +1 -0
- package/build/esm/crypto/hex2abc.d.ts +7 -0
- package/build/esm/crypto/hex2abc.js +28 -0
- package/build/esm/crypto/hex2abc.js.map +1 -0
- package/build/esm/crypto/index.d.ts +1 -0
- package/build/esm/crypto/index.js +1 -0
- package/build/esm/crypto/index.js.map +1 -1
- package/build/esm/crypto/murmurhash.d.ts +4 -0
- package/build/esm/crypto/murmurhash.js +12 -0
- package/build/esm/crypto/murmurhash.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hex2abc = void 0;
|
|
4
|
+
const mapping = {
|
|
5
|
+
a: 'a',
|
|
6
|
+
b: 'b',
|
|
7
|
+
c: 'c',
|
|
8
|
+
d: 'd',
|
|
9
|
+
e: 'e',
|
|
10
|
+
f: 'f',
|
|
11
|
+
0: 'g',
|
|
12
|
+
1: 'h',
|
|
13
|
+
2: 'i',
|
|
14
|
+
3: 'j',
|
|
15
|
+
4: 'k',
|
|
16
|
+
5: 'l',
|
|
17
|
+
6: 'm',
|
|
18
|
+
7: 'n',
|
|
19
|
+
8: 'o',
|
|
20
|
+
9: 'p',
|
|
21
|
+
// Just in case someone passes a string like 0xabc
|
|
22
|
+
x: 'x',
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Turns a hexadecimal string into lowercase alphabetical characters.
|
|
26
|
+
*
|
|
27
|
+
* @param hex - The hexadecimal string to convert
|
|
28
|
+
* @returns A string of lowercase alphabetical characters
|
|
29
|
+
*/
|
|
30
|
+
const hex2abc = (hex) => Array.prototype.map.call(hex.toLowerCase(), (char) => mapping[char]).join('');
|
|
31
|
+
exports.hex2abc = hex2abc;
|
|
32
|
+
//# sourceMappingURL=hex2abc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex2abc.js","sourceRoot":"","sources":["../../../src/crypto/hex2abc.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;IACd,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IAEN,kDAAkD;IAClD,CAAC,EAAE,GAAG;CACE,CAAC;AAEX;;;;;GAKG;AACI,MAAM,OAAO,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAA4B,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAAzI,QAAA,OAAO,WAAkI"}
|
|
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Synchronous = exports.Base64 = void 0;
|
|
6
|
+
exports.Synchronous = exports.MurmurHash = exports.Base64 = void 0;
|
|
7
7
|
var base64_1 = require("./base64");
|
|
8
8
|
Object.defineProperty(exports, "Base64", { enumerable: true, get: function () { return __importDefault(base64_1).default; } });
|
|
9
|
+
var murmurhash_1 = require("./murmurhash");
|
|
10
|
+
Object.defineProperty(exports, "MurmurHash", { enumerable: true, get: function () { return __importDefault(murmurhash_1).default; } });
|
|
9
11
|
var synchronous_1 = require("./synchronous");
|
|
10
12
|
Object.defineProperty(exports, "Synchronous", { enumerable: true, get: function () { return __importDefault(synchronous_1).default; } });
|
|
11
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/crypto/index.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA6C;AAApC,iHAAA,OAAO,OAAU;AAC1B,6CAAuD;AAA9C,2HAAA,OAAO,OAAe"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/crypto/index.ts"],"names":[],"mappings":";;;;;;AAAA,mCAA6C;AAApC,iHAAA,OAAO,OAAU;AAC1B,2CAAqD;AAA5C,yHAAA,OAAO,OAAc;AAC9B,6CAAuD;AAA9C,2HAAA,OAAO,OAAe"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MurmurHash = void 0;
|
|
4
|
+
const murmurhash_wasm_1 = require("murmurhash-wasm");
|
|
5
|
+
const hex2abc_1 = require("./hex2abc");
|
|
6
|
+
class MurmurHash {
|
|
7
|
+
static hash(key, seed = 0) {
|
|
8
|
+
const hash = murmurhash_wasm_1.MurmurHash3.hash32(key, seed);
|
|
9
|
+
const value = hash.readUInt32BE();
|
|
10
|
+
const hex = value.toString(16);
|
|
11
|
+
return hex2abc_1.hex2abc(hex);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.MurmurHash = MurmurHash;
|
|
15
|
+
exports.default = MurmurHash;
|
|
16
|
+
//# sourceMappingURL=murmurhash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"murmurhash.js","sourceRoot":"","sources":["../../../src/crypto/murmurhash.ts"],"names":[],"mappings":";;;AAAA,qDAA8C;AAE9C,uCAA2C;AAE3C,MAAa,UAAU;IACd,MAAM,CAAC,IAAI,CAAC,GAAW,EAAE,IAAI,GAAG,CAAC;QACtC,MAAM,IAAI,GAAG,6BAAW,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAClC,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAE/B,OAAO,iBAAO,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;CACF;AARD,gCAQC;AAED,kBAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const mapping = {
|
|
2
|
+
a: 'a',
|
|
3
|
+
b: 'b',
|
|
4
|
+
c: 'c',
|
|
5
|
+
d: 'd',
|
|
6
|
+
e: 'e',
|
|
7
|
+
f: 'f',
|
|
8
|
+
0: 'g',
|
|
9
|
+
1: 'h',
|
|
10
|
+
2: 'i',
|
|
11
|
+
3: 'j',
|
|
12
|
+
4: 'k',
|
|
13
|
+
5: 'l',
|
|
14
|
+
6: 'm',
|
|
15
|
+
7: 'n',
|
|
16
|
+
8: 'o',
|
|
17
|
+
9: 'p',
|
|
18
|
+
// Just in case someone passes a string like 0xabc
|
|
19
|
+
x: 'x',
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Turns a hexadecimal string into lowercase alphabetical characters.
|
|
23
|
+
*
|
|
24
|
+
* @param hex - The hexadecimal string to convert
|
|
25
|
+
* @returns A string of lowercase alphabetical characters
|
|
26
|
+
*/
|
|
27
|
+
export const hex2abc = (hex) => Array.prototype.map.call(hex.toLowerCase(), (char) => mapping[char]).join('');
|
|
28
|
+
//# sourceMappingURL=hex2abc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hex2abc.js","sourceRoot":"","sources":["../../../src/crypto/hex2abc.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;IACd,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IACN,CAAC,EAAE,GAAG;IAEN,kDAAkD;IAClD,CAAC,EAAE,GAAG;CACE,CAAC;AAEX;;;;;GAKG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAA4B,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/crypto/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/crypto/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MurmurHash3 } from 'murmurhash-wasm';
|
|
2
|
+
import { hex2abc } from "./hex2abc";
|
|
3
|
+
export class MurmurHash {
|
|
4
|
+
static hash(key, seed = 0) {
|
|
5
|
+
const hash = MurmurHash3.hash32(key, seed);
|
|
6
|
+
const value = hash.readUInt32BE();
|
|
7
|
+
const hex = value.toString(16);
|
|
8
|
+
return hex2abc(hex);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export default MurmurHash;
|
|
12
|
+
//# sourceMappingURL=murmurhash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"murmurhash.js","sourceRoot":"","sources":["../../../src/crypto/murmurhash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,kBAAyB;AAE3C,MAAM,OAAO,UAAU;IACd,MAAM,CAAC,IAAI,CAAC,GAAW,EAAE,IAAI,GAAG,CAAC;QACtC,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAClC,MAAM,GAAG,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAE/B,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;CACF;AAED,eAAe,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voiceflow/common",
|
|
3
3
|
"description": "Junk drawer of utility functions",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.15.2",
|
|
5
5
|
"author": "Voiceflow",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/voiceflow/libs/issues"
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"cuid": "^2.1.8",
|
|
14
14
|
"dayjs": "^1.10.7",
|
|
15
15
|
"lodash": "^4.17.21",
|
|
16
|
+
"murmurhash-wasm": "^1.3.0",
|
|
16
17
|
"number-to-words": "^1.2.4",
|
|
17
18
|
"typescript-fsa": "3.0.0"
|
|
18
19
|
},
|
|
@@ -72,5 +73,5 @@
|
|
|
72
73
|
"test:single": "NODE_ENV=test ts-mocha --paths --config config/tests/mocharc.yml",
|
|
73
74
|
"test:unit": "NODE_ENV=test nyc --report-dir=nyc_coverage_unit ts-mocha --paths --config config/tests/mocharc.yml 'tests/**/*.unit.ts'"
|
|
74
75
|
},
|
|
75
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "e1457b7ca2fbcd636c865b8f3deb80f93b219cfa"
|
|
76
77
|
}
|