@palbase/backend 12.0.0 → 12.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/index.cjs +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1292,6 +1292,24 @@ function getWebhookConfig(ctor) {
|
|
|
1292
1292
|
"@Webhook requires either a `provider` preset or an explicit `signature` \u2014 an endpoint with no verification would accept forged deliveries"
|
|
1293
1293
|
);
|
|
1294
1294
|
}
|
|
1295
|
+
if (meta.signature) {
|
|
1296
|
+
const sig = meta.signature;
|
|
1297
|
+
if (!sig.header) {
|
|
1298
|
+
throw new Error("@Webhook signature requires `header` \u2014 the header the signature arrives in");
|
|
1299
|
+
}
|
|
1300
|
+
if (sig.algo !== "hmac-sha256" && sig.algo !== "hmac-sha1") {
|
|
1301
|
+
throw new Error(`@Webhook signature has an unsupported algo "${sig.algo}"`);
|
|
1302
|
+
}
|
|
1303
|
+
if (sig.encoding !== "hex" && sig.encoding !== "base64") {
|
|
1304
|
+
throw new Error(`@Webhook signature has an unsupported encoding "${sig.encoding}"`);
|
|
1305
|
+
}
|
|
1306
|
+
if (!sig.signs?.includes("{body}")) {
|
|
1307
|
+
throw new Error("@Webhook signature `signs` must contain {body} \u2014 signing a constant is not a signature");
|
|
1308
|
+
}
|
|
1309
|
+
if (sig.signs.includes("{ts}") && !sig.timestampHeader) {
|
|
1310
|
+
throw new Error("@Webhook signature uses {ts} but declares no `timestampHeader` to read it from");
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1295
1313
|
if (!meta.secret?.env) {
|
|
1296
1314
|
throw new Error('@Webhook requires `secret: { env: "VAR_NAME" }`');
|
|
1297
1315
|
}
|