@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.
- package/dist/safeCompare.d.ts +4 -2
- package/dist/safeCompare.d.ts.map +1 -1
- package/dist/safeCompare.js +11 -8
- package/dist/safeCompare.js.map +1 -1
- package/package.json +3 -2
package/dist/safeCompare.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
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
|
|
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"}
|
package/dist/safeCompare.js
CHANGED
|
@@ -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
|
-
*
|
|
7
|
-
*
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
package/dist/safeCompare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safeCompare.js","sourceRoot":"","sources":["../src/safeCompare.ts"],"names":[],"mappings":";;
|
|
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.
|
|
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
|
}
|