@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 CHANGED
@@ -2217,6 +2217,24 @@ function getWebhookConfig(ctor) {
2217
2217
  "@Webhook requires either a `provider` preset or an explicit `signature` \u2014 an endpoint with no verification would accept forged deliveries"
2218
2218
  );
2219
2219
  }
2220
+ if (meta.signature) {
2221
+ const sig = meta.signature;
2222
+ if (!sig.header) {
2223
+ throw new Error("@Webhook signature requires `header` \u2014 the header the signature arrives in");
2224
+ }
2225
+ if (sig.algo !== "hmac-sha256" && sig.algo !== "hmac-sha1") {
2226
+ throw new Error(`@Webhook signature has an unsupported algo "${sig.algo}"`);
2227
+ }
2228
+ if (sig.encoding !== "hex" && sig.encoding !== "base64") {
2229
+ throw new Error(`@Webhook signature has an unsupported encoding "${sig.encoding}"`);
2230
+ }
2231
+ if (!sig.signs?.includes("{body}")) {
2232
+ throw new Error("@Webhook signature `signs` must contain {body} \u2014 signing a constant is not a signature");
2233
+ }
2234
+ if (sig.signs.includes("{ts}") && !sig.timestampHeader) {
2235
+ throw new Error("@Webhook signature uses {ts} but declares no `timestampHeader` to read it from");
2236
+ }
2237
+ }
2220
2238
  if (!meta.secret?.env) {
2221
2239
  throw new Error('@Webhook requires `secret: { env: "VAR_NAME" }`');
2222
2240
  }