@webiny/utils 5.43.4 → 5.43.5-beta.0

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 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 interface ICacheKeyOptions {
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 _crypto = _interopRequireDefault(require("crypto"));
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 = (input, options) => {
17
+ const createCacheKey = input => {
18
18
  const key = getCacheKey(input);
19
- return _crypto.default.createHash(options?.algorithm || "sha1").update(key).digest(options?.encoding || "hex");
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":["_crypto","_interopRequireDefault","require","getCacheKey","input","JSON","stringify","createCacheKey","options","key","crypto","createHash","algorithm","update","digest","encoding","exports"],"sources":["cacheKey.ts"],"sourcesContent":["import crypto, { BinaryToTextEncoding } from \"crypto\";\n\nexport type ICacheKeyKeys = Record<string, any> | string | number;\n\nexport interface ICacheKeyOptions {\n algorithm?: CacheKeyAlgorithmType;\n encoding?: BinaryToTextEncoding;\n}\n\nexport type CacheKeyAlgorithmType = \"md5\" | \"sha1\" | \"sha224\" | \"sha256\" | \"sha384\" | \"sha512\";\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, options?: ICacheKeyOptions): string => {\n const key = getCacheKey(input);\n return crypto\n .createHash(options?.algorithm || \"sha1\")\n .update(key)\n .digest(options?.encoding || \"hex\");\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAWA,MAAMC,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,GAAGA,CAACH,KAAoB,EAAEI,OAA0B,KAAa;EACxF,MAAMC,GAAG,GAAGN,WAAW,CAACC,KAAK,CAAC;EAC9B,OAAOM,eAAM,CACRC,UAAU,CAACH,OAAO,EAAEI,SAAS,IAAI,MAAM,CAAC,CACxCC,MAAM,CAACJ,GAAG,CAAC,CACXK,MAAM,CAACN,OAAO,EAAEO,QAAQ,IAAI,KAAK,CAAC;AAC3C,CAAC;AAACC,OAAA,CAAAT,cAAA,GAAAA,cAAA","ignoreList":[]}
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 _mdbid = _interopRequireDefault(require("mdbid"));
9
- // @ts-expect-error `mdbid` package has no types
10
-
11
- const mdbid = () => (0, _mdbid.default)();
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":["_mdbid","_interopRequireDefault","require","mdbid","generateId","exports"],"sources":["mdbid.ts"],"sourcesContent":["// @ts-expect-error `mdbid` package has no types\nimport generateId from \"mdbid\";\n\nexport const mdbid = (): string => generateId();\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AADA;;AAGO,MAAMC,KAAK,GAAGA,CAAA,KAAc,IAAAC,cAAU,EAAC,CAAC;AAACC,OAAA,CAAAF,KAAA,GAAAA,KAAA","ignoreList":[]}
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.4",
3
+ "version": "5.43.5-beta.0",
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
- "@webiny/error": "5.43.4",
19
- "@webiny/plugins": "5.43.4",
18
+ "@noble/hashes": "1.8.0",
19
+ "@webiny/error": "5.43.5-beta.0",
20
+ "@webiny/plugins": "5.43.5-beta.0",
21
+ "bson-objectid": "2.0.4",
20
22
  "jsonpack": "1.1.5",
21
- "mdbid": "1.0.0",
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.4",
28
+ "@webiny/project-utils": "5.43.5-beta.0",
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": "3db1bdbd80b3d7721a159f0e032c357d57c25b9d"
46
+ "gitHead": "ef7e31164536a2202dbc0946b412238612e7cae2"
46
47
  }