@nest-boot/hash 7.0.2 → 7.2.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.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Estimates the entropy of a string in bits.
3
+ * This is a simple approximation that helps detect low-entropy secrets.
4
+ *
5
+ * @param str - The string to estimate entropy for
6
+ * @returns The estimated entropy in bits
7
+ */
8
+ export declare function estimateEntropy(str: string): number;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.estimateEntropy = estimateEntropy;
4
+ /**
5
+ * Estimates the entropy of a string in bits.
6
+ * This is a simple approximation that helps detect low-entropy secrets.
7
+ *
8
+ * @param str - The string to estimate entropy for
9
+ * @returns The estimated entropy in bits
10
+ */
11
+ function estimateEntropy(str) {
12
+ const unique = new Set(str).size;
13
+ if (unique === 0)
14
+ return 0;
15
+ return Math.log2(Math.pow(unique, str.length));
16
+ }
17
+ //# sourceMappingURL=estimate-entropy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-entropy.js","sourceRoot":"","sources":["../../src/utils/estimate-entropy.ts"],"names":[],"mappings":";;AAOA,0CAIC;AAXD;;;;;;GAMG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;IACjC,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AACjD,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const estimate_entropy_1 = require("./estimate-entropy");
4
+ describe("estimateEntropy", () => {
5
+ it("should return 0 for empty string", () => {
6
+ expect((0, estimate_entropy_1.estimateEntropy)("")).toBe(0);
7
+ });
8
+ it("should return positive entropy for non-empty string", () => {
9
+ expect((0, estimate_entropy_1.estimateEntropy)("abc")).toBeGreaterThan(0);
10
+ });
11
+ it("should return higher entropy for more unique characters", () => {
12
+ const lowEntropy = (0, estimate_entropy_1.estimateEntropy)("aaa");
13
+ const highEntropy = (0, estimate_entropy_1.estimateEntropy)("abc");
14
+ expect(highEntropy).toBeGreaterThan(lowEntropy);
15
+ });
16
+ });
17
+ //# sourceMappingURL=estimate-entropy.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-entropy.spec.js","sourceRoot":"","sources":["../../src/utils/estimate-entropy.spec.ts"],"names":[],"mappings":";;AAAA,yDAAqD;AAErD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,CAAC,IAAA,kCAAe,EAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,MAAM,CAAC,IAAA,kCAAe,EAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,UAAU,GAAG,IAAA,kCAAe,EAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,WAAW,GAAG,IAAA,kCAAe,EAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,CAAC,WAAW,CAAC,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@nest-boot/hash",
3
- "version": "7.0.2",
3
+ "version": "7.2.0",
4
4
  "description": "",
5
- "author": "d4rkcr0w <me@d4rkcr0w.com>",
5
+ "author": {
6
+ "name": "Xudong Huang",
7
+ "email": "me@huangxudong.com",
8
+ "url": "https://www.huangxudong.com/"
9
+ },
6
10
  "homepage": "",
7
11
  "license": "MIT",
8
12
  "main": "dist/index.js",
@@ -30,7 +34,7 @@
30
34
  "ts-jest": "^29.4.4",
31
35
  "typescript": "^5.9.3",
32
36
  "@nest-boot/eslint-config": "^7.0.2",
33
- "@nest-boot/eslint-plugin": "^7.0.3",
37
+ "@nest-boot/eslint-plugin": "^7.0.4",
34
38
  "@nest-boot/tsconfig": "^7.0.1"
35
39
  },
36
40
  "peerDependencies": {