@hookflo/tern 3.0.2 → 3.0.3

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.
@@ -109,7 +109,7 @@ exports.platformAlgorithmConfigs = {
109
109
  signatureFormat: 'v1={signature}',
110
110
  payloadFormat: '{id}.{timestamp}.{body}',
111
111
  encoding: 'base64',
112
- secretEncoding: 'base64',
112
+ secretEncoding: 'utf8',
113
113
  idHeader: 'webhook-id',
114
114
  },
115
115
  },
@@ -41,11 +41,7 @@ class AlgorithmBasedVerifier extends base_1.WebhookVerifier {
41
41
  case "comma-separated": {
42
42
  const sigMap = this.parseDelimitedHeader(headerValue);
43
43
  const signatureKey = this.config.customConfig?.signatureKey || "v1";
44
- return [
45
- sigMap[signatureKey],
46
- sigMap.signature,
47
- sigMap.v1,
48
- ].filter((value) => Boolean(value));
44
+ return [sigMap[signatureKey], sigMap.signature, sigMap.v1].filter((value) => Boolean(value));
49
45
  }
50
46
  case "raw":
51
47
  default:
@@ -174,12 +170,13 @@ class AlgorithmBasedVerifier extends base_1.WebhookVerifier {
174
170
  const secretEncoding = this.config.customConfig?.secretEncoding || "base64";
175
171
  let secretMaterial = this.secret;
176
172
  if (secretEncoding === "base64") {
177
- const base64Secret = this.secret.includes("_")
178
- ? this.secret.split("_").slice(1).join("_")
179
- : this.secret;
180
- secretMaterial = new Uint8Array(Buffer.from(base64Secret, "base64"));
173
+ let rawSecret = this.secret;
174
+ const lastUnderscore = rawSecret.lastIndexOf("_");
175
+ if (lastUnderscore !== -1) {
176
+ rawSecret = rawSecret.slice(lastUnderscore + 1);
177
+ }
178
+ secretMaterial = new Uint8Array(Buffer.from(rawSecret, "base64"));
181
179
  }
182
- // 'utf8', 'raw', or anything else → use secret as-is
183
180
  const hmac = (0, crypto_1.createHmac)(algorithm, secretMaterial);
184
181
  hmac.update(payload);
185
182
  const expectedSignature = hmac.digest("base64");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hookflo/tern",
3
- "version": "3.0.2",
3
+ "version": "3.0.3",
4
4
  "description": "A robust, scalable webhook verification framework supporting multiple platforms and signature algorithms",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",