@webiny/utils 5.43.4 → 5.43.5-beta.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.
- package/cacheKey.d.ts +1 -8
- package/cacheKey.js +5 -4
- package/cacheKey.js.map +1 -1
- package/mdbid.js +4 -4
- package/mdbid.js.map +1 -1
- package/package.json +8 -7
package/cacheKey.d.ts
CHANGED
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { BinaryToTextEncoding } from "crypto";
|
|
3
1
|
export type ICacheKeyKeys = Record<string, any> | string | number;
|
|
4
|
-
export
|
|
5
|
-
algorithm?: CacheKeyAlgorithmType;
|
|
6
|
-
encoding?: BinaryToTextEncoding;
|
|
7
|
-
}
|
|
8
|
-
export type CacheKeyAlgorithmType = "md5" | "sha1" | "sha224" | "sha256" | "sha384" | "sha512";
|
|
9
|
-
export declare const createCacheKey: (input: ICacheKeyKeys, options?: ICacheKeyOptions) => string;
|
|
2
|
+
export declare const createCacheKey: (input: ICacheKeyKeys) => string;
|
package/cacheKey.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.createCacheKey = void 0;
|
|
8
|
-
var
|
|
7
|
+
var _sha = require("@noble/hashes/sha2");
|
|
8
|
+
var _utils = require("@noble/hashes/utils");
|
|
9
9
|
const getCacheKey = input => {
|
|
10
10
|
if (typeof input === "string") {
|
|
11
11
|
return input;
|
|
@@ -14,9 +14,10 @@ const getCacheKey = input => {
|
|
|
14
14
|
}
|
|
15
15
|
return JSON.stringify(input);
|
|
16
16
|
};
|
|
17
|
-
const createCacheKey =
|
|
17
|
+
const createCacheKey = input => {
|
|
18
18
|
const key = getCacheKey(input);
|
|
19
|
-
|
|
19
|
+
const hash = (0, _sha.sha256)((0, _utils.utf8ToBytes)(key));
|
|
20
|
+
return (0, _utils.bytesToHex)(hash);
|
|
20
21
|
};
|
|
21
22
|
exports.createCacheKey = createCacheKey;
|
|
22
23
|
|
package/cacheKey.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_sha","require","_utils","getCacheKey","input","JSON","stringify","createCacheKey","key","hash","sha256","utf8ToBytes","bytesToHex","exports"],"sources":["cacheKey.ts"],"sourcesContent":["import { sha256 } from \"@noble/hashes/sha2\";\nimport { utf8ToBytes, bytesToHex } from \"@noble/hashes/utils\";\n\nexport type ICacheKeyKeys = Record<string, any> | string | number;\n\nconst getCacheKey = (input: ICacheKeyKeys): string => {\n if (typeof input === \"string\") {\n return input;\n } else if (typeof input === \"number\") {\n return `${input}`;\n }\n return JSON.stringify(input);\n};\n\nexport const createCacheKey = (input: ICacheKeyKeys): string => {\n const key = getCacheKey(input);\n\n const hash = sha256(utf8ToBytes(key));\n\n return bytesToHex(hash);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAIA,MAAME,WAAW,GAAIC,KAAoB,IAAa;EAClD,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB,CAAC,MAAM,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAClC,OAAO,GAAGA,KAAK,EAAE;EACrB;EACA,OAAOC,IAAI,CAACC,SAAS,CAACF,KAAK,CAAC;AAChC,CAAC;AAEM,MAAMG,cAAc,GAAIH,KAAoB,IAAa;EAC5D,MAAMI,GAAG,GAAGL,WAAW,CAACC,KAAK,CAAC;EAE9B,MAAMK,IAAI,GAAG,IAAAC,WAAM,EAAC,IAAAC,kBAAW,EAACH,GAAG,CAAC,CAAC;EAErC,OAAO,IAAAI,iBAAU,EAACH,IAAI,CAAC;AAC3B,CAAC;AAACI,OAAA,CAAAN,cAAA,GAAAA,cAAA","ignoreList":[]}
|
package/mdbid.js
CHANGED
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.mdbid = void 0;
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
var _bsonObjectid = _interopRequireDefault(require("bson-objectid"));
|
|
9
|
+
const mdbid = () => {
|
|
10
|
+
return (0, _bsonObjectid.default)().toHexString();
|
|
11
|
+
};
|
|
12
12
|
exports.mdbid = mdbid;
|
|
13
13
|
|
|
14
14
|
//# sourceMappingURL=mdbid.js.map
|
package/mdbid.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_bsonObjectid","_interopRequireDefault","require","mdbid","ObjectID","toHexString","exports"],"sources":["mdbid.ts"],"sourcesContent":["import ObjectID from \"bson-objectid\";\n\nexport const mdbid = () => {\n return ObjectID().toHexString();\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,KAAK,GAAGA,CAAA,KAAM;EACvB,OAAO,IAAAC,qBAAQ,EAAC,CAAC,CAACC,WAAW,CAAC,CAAC;AACnC,CAAC;AAACC,OAAA,CAAAH,KAAA,GAAAA,KAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/utils",
|
|
3
|
-
"version": "5.43.
|
|
3
|
+
"version": "5.43.5-beta.1",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"repository": {
|
|
@@ -15,16 +15,17 @@
|
|
|
15
15
|
"directory": "dist"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"@webiny/
|
|
18
|
+
"@noble/hashes": "1.8.0",
|
|
19
|
+
"@webiny/error": "5.43.5-beta.1",
|
|
20
|
+
"@webiny/plugins": "5.43.5-beta.1",
|
|
21
|
+
"bson-objectid": "2.0.4",
|
|
20
22
|
"jsonpack": "1.1.5",
|
|
21
|
-
"
|
|
22
|
-
"nanoid": "3.3.8",
|
|
23
|
+
"nanoid": "3.3.11",
|
|
23
24
|
"nanoid-dictionary": "4.3.0",
|
|
24
25
|
"p-retry": "4.6.2"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
|
-
"@webiny/project-utils": "5.43.
|
|
28
|
+
"@webiny/project-utils": "5.43.5-beta.1",
|
|
28
29
|
"rimraf": "6.0.1",
|
|
29
30
|
"typescript": "5.3.3"
|
|
30
31
|
},
|
|
@@ -42,5 +43,5 @@
|
|
|
42
43
|
]
|
|
43
44
|
}
|
|
44
45
|
},
|
|
45
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "14be514b21ee0029c2a3f2a5ca6ac119e29ca12b"
|
|
46
47
|
}
|