@hookflo/tern 3.0.0 → 3.0.1
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/verifiers/algorithms.js +18 -5
- package/package.json +1 -1
|
@@ -114,10 +114,18 @@ class AlgorithmBasedVerifier extends base_1.WebhookVerifier {
|
|
|
114
114
|
const customFormat = this.config.customConfig.payloadFormat;
|
|
115
115
|
if (customFormat.includes("{id}") && customFormat.includes("{timestamp}")) {
|
|
116
116
|
const id = request.headers.get(this.config.customConfig.idHeader || "x-webhook-id");
|
|
117
|
-
const timestamp = request.headers.get(this.config.timestampHeader ||
|
|
117
|
+
const timestamp = request.headers.get(this.config.timestampHeader ||
|
|
118
|
+
this.config.customConfig?.timestampHeader ||
|
|
119
|
+
"x-webhook-timestamp");
|
|
120
|
+
// if either is missing payload will be malformed — fail explicitly
|
|
121
|
+
if (!id || !timestamp) {
|
|
122
|
+
throw new Error(`Missing required headers for payload construction: ${!id ? this.config.customConfig.idHeader || "x-webhook-id" : ""} ${!timestamp
|
|
123
|
+
? this.config.timestampHeader || "x-webhook-timestamp"
|
|
124
|
+
: ""}`.trim());
|
|
125
|
+
}
|
|
118
126
|
return customFormat
|
|
119
|
-
.replace("{id}", id || "")
|
|
120
|
-
.replace("{timestamp}", timestamp || "")
|
|
127
|
+
.replace("{id}", id.trim() || "")
|
|
128
|
+
.replace("{timestamp}", timestamp.trim() || "")
|
|
121
129
|
.replace("{body}", rawBody);
|
|
122
130
|
}
|
|
123
131
|
if (customFormat.includes("{timestamp}") &&
|
|
@@ -187,7 +195,9 @@ class AlgorithmBasedVerifier extends base_1.WebhookVerifier {
|
|
|
187
195
|
case "workos":
|
|
188
196
|
case "sentry":
|
|
189
197
|
case "sanity":
|
|
190
|
-
metadata.id = request.headers.get(this.config.idHeader ||
|
|
198
|
+
metadata.id = request.headers.get(this.config.idHeader ||
|
|
199
|
+
this.config.customConfig?.idHeader ||
|
|
200
|
+
"webhook-id");
|
|
191
201
|
break;
|
|
192
202
|
default:
|
|
193
203
|
if (this.config.idHeader) {
|
|
@@ -201,7 +211,10 @@ class AlgorithmBasedVerifier extends base_1.WebhookVerifier {
|
|
|
201
211
|
exports.AlgorithmBasedVerifier = AlgorithmBasedVerifier;
|
|
202
212
|
class GenericHMACVerifier extends AlgorithmBasedVerifier {
|
|
203
213
|
resolveSentryPayloadCandidates(rawBody, request) {
|
|
204
|
-
const candidates = [
|
|
214
|
+
const candidates = [
|
|
215
|
+
this.formatPayload(rawBody, request),
|
|
216
|
+
rawBody,
|
|
217
|
+
];
|
|
205
218
|
if (this.config.payloadFormat === "json-stringified") {
|
|
206
219
|
try {
|
|
207
220
|
const parsed = JSON.parse(rawBody);
|
package/package.json
CHANGED