@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.
|
@@ -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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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