@forwardimpact/librpc 0.1.93 → 0.1.95

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/auth.js +9 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forwardimpact/librpc",
3
- "version": "0.1.93",
3
+ "version": "0.1.95",
4
4
  "description": "gRPC framework and utilities for Guide",
5
5
  "license": "Apache-2.0",
6
6
  "author": "D. Olsson <hi@senzilla.io>",
@@ -25,7 +25,7 @@
25
25
  "node": ">=18.0.0"
26
26
  },
27
27
  "scripts": {
28
- "test": "bun run node --test test/*.test.js"
28
+ "test": "bun test test/*.test.js"
29
29
  },
30
30
  "dependencies": {
31
31
  "@forwardimpact/libcli": "^0.1.0",
@@ -35,7 +35,7 @@
35
35
  "@grpc/grpc-js": "^1.14.3"
36
36
  },
37
37
  "devDependencies": {
38
- "@forwardimpact/libharness": "^0.1.5"
38
+ "@forwardimpact/libharness": "^0.1.14"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
package/src/auth.js CHANGED
@@ -101,14 +101,21 @@ export class HmacAuth {
101
101
  };
102
102
  }
103
103
 
104
- // Verify HMAC signature
104
+ // Verify HMAC signature (timing-safe comparison)
105
105
  const payload = `${serviceId}:${timestamp}`;
106
106
  const expectedSignature = crypto
107
107
  .createHmac("sha256", this.#secret)
108
108
  .update(payload)
109
109
  .digest("hex");
110
110
 
111
- if (providedSignature !== expectedSignature) {
111
+ const signaturesMatch =
112
+ providedSignature.length === expectedSignature.length &&
113
+ crypto.timingSafeEqual(
114
+ Buffer.from(providedSignature),
115
+ Buffer.from(expectedSignature),
116
+ );
117
+
118
+ if (!signaturesMatch) {
112
119
  return {
113
120
  isValid: false,
114
121
  serviceId: null,