@hardlydifficult/worker-server 1.0.16 → 1.0.18

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.
@@ -1,6 +1,8 @@
1
1
  /**
2
- * Timing-safe string comparison to prevent brute-force attacks.
3
- * Always takes constant time regardless of where strings differ.
2
+ * Constant-time string comparison to prevent timing attacks.
3
+ *
4
+ * Pads both values to the same length before comparing so the timing-safe
5
+ * compare path is always executed, even for different-length inputs.
4
6
  */
5
7
  export declare function safeCompare(a: string, b: string): boolean;
6
8
  //# sourceMappingURL=safeCompare.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"safeCompare.d.ts","sourceRoot":"","sources":["../src/safeCompare.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAWzD"}
1
+ {"version":3,"file":"safeCompare.d.ts","sourceRoot":"","sources":["../src/safeCompare.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAczD"}
@@ -3,17 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.safeCompare = safeCompare;
4
4
  const crypto_1 = require("crypto");
5
5
  /**
6
- * Timing-safe string comparison to prevent brute-force attacks.
7
- * Always takes constant time regardless of where strings differ.
6
+ * Constant-time string comparison to prevent timing attacks.
7
+ *
8
+ * Pads both values to the same length before comparing so the timing-safe
9
+ * compare path is always executed, even for different-length inputs.
8
10
  */
9
11
  function safeCompare(a, b) {
10
12
  const bufA = Buffer.from(a);
11
13
  const bufB = Buffer.from(b);
12
- if (bufA.length !== bufB.length) {
13
- // Compare bufA against itself so the timing is consistent
14
- (0, crypto_1.timingSafeEqual)(bufA, bufA);
15
- return false;
16
- }
17
- return (0, crypto_1.timingSafeEqual)(bufA, bufB);
14
+ const maxLength = Math.max(bufA.length, bufB.length);
15
+ const paddedA = Buffer.alloc(maxLength);
16
+ const paddedB = Buffer.alloc(maxLength);
17
+ bufA.copy(paddedA);
18
+ bufB.copy(paddedB);
19
+ const valuesMatch = (0, crypto_1.timingSafeEqual)(paddedA, paddedB);
20
+ return bufA.length === bufB.length && valuesMatch;
18
21
  }
19
22
  //# sourceMappingURL=safeCompare.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"safeCompare.js","sourceRoot":"","sources":["../src/safeCompare.ts"],"names":[],"mappings":";;AAMA,kCAWC;AAjBD,mCAAyC;AAEzC;;;GAGG;AACH,SAAgB,WAAW,CAAC,CAAS,EAAE,CAAS;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE5B,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;QAChC,0DAA0D;QAC1D,IAAA,wBAAe,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC5B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,IAAA,wBAAe,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC"}
1
+ {"version":3,"file":"safeCompare.js","sourceRoot":"","sources":["../src/safeCompare.ts"],"names":[],"mappings":";;AAQA,kCAcC;AAtBD,mCAAyC;AAEzC;;;;;GAKG;AACH,SAAgB,WAAW,CAAC,CAAS,EAAE,CAAS;IAC9C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAE5B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACrD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAExC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACnB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEnB,MAAM,WAAW,GAAG,IAAA,wBAAe,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAEtD,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,IAAI,WAAW,CAAC;AACpD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hardlydifficult/worker-server",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [
@@ -31,7 +31,8 @@
31
31
  ".": {
32
32
  "types": "./dist/index.d.ts",
33
33
  "import": "./dist/index.js",
34
- "require": "./dist/index.js"
34
+ "require": "./dist/index.js",
35
+ "default": "./dist/index.js"
35
36
  }
36
37
  }
37
38
  }