@zap-studio/webhooks 0.4.0 → 1.1.0

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/CHANGELOG.md CHANGED
@@ -1,10 +1,36 @@
1
- ## @zap-studio/webhooks@0.4.0
1
+ # Changelog
2
2
 
3
- ### Rework the package on Web API `Request`/`Response` (breaking)
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [1.1.0]
8
+
9
+ ### Added
10
+
11
+ `WebhookRouter` (and `createWebhookRouter(...)`) gain an optional `logger?: Logger` option (from `@zap-studio/logger`). When provided, it logs each delivery attempt and handler dispatch at `debug`, and verification failures and unmatched routes at `warn`. Omitting it keeps zero logging overhead. See [Logging](https://www.zapstudio.dev/webhooks/logging).
12
+
13
+ ## [1.0.0]
14
+
15
+ ### Changed
16
+
17
+ `WebhookRouter`'s stateless private static methods (`runBeforeHooks`, `runAfterHooks`, `createHandlerEntry`, `parseRequestBody`, `validatePayload`, `executeHandler`) are now module-level functions in `router.ts`. Internal-only change; the public API (`WebhookRouter`, `createWebhookRouter`, `.register()`, `.handle()`) is unaffected.
18
+
19
+ HMAC signature verification decodes the incoming header's hex signature to bytes and compares it against the computed digest byte-for-byte, instead of hex-encoding the digest and comparing hex text. Behavior is unchanged for valid requests; this only affects internals (fewer bytes compared, and the header's hex is no longer case-normalized as text since decoding handles case natively).
20
+
21
+ `constantTimeEquals` moved from `utils.ts` into `verify.ts` (its only consumer) and now compares `Uint8Array`s (bytes) instead of strings. Still exported from `@zap-studio/webhooks` and `@zap-studio/webhooks/verify`.
22
+
23
+ ### Removed
24
+
25
+ Removed the `./utils` subpath export.
26
+
27
+ ## [0.4.0]
28
+
29
+ ### Changed
4
30
 
5
31
  The custom `NormalizedRequest`/`NormalizedResponse` contract is gone. `router.handle` now takes a standard Web API `Request` and returns a standard `Response`, so the router plugs directly into fetch-native runtimes (Bun, Deno, Cloudflare Workers, Next.js route handlers, Hono) with no adapter layer.
6
32
 
7
- Breaking changes:
33
+ **Breaking changes:**
8
34
 
9
35
  - `handle(req: NormalizedRequest): Promise<NormalizedResponse>` → `handle(request: Request): Promise<Response>`.
10
36
  - Handlers receive `{ request, rawBody, path, payload }` (a `WebhookContext` plus the validated `payload`) and return a `Response` or `undefined` (default `200` `"ok"`). The `ack` helper is removed — use `Response.json(body, init)`.
@@ -14,73 +40,68 @@ Breaking changes:
14
40
 
15
41
  Behavior kept: hook execution order, prefix semantics (default `/webhooks/`), exact-match routing, HMAC verification, and the `404`/`400`/`500` error body shapes. Unknown routes now return `404` without reading the request body.
16
42
 
17
- ## @zap-studio/webhooks@0.3.0
43
+ ## [0.3.0]
18
44
 
19
- ### Migrate to ultracite lint/format; make the adapter contract generic
45
+ ### Changed
20
46
 
21
47
  `Adapter` and `BaseAdapter` are now generic over the framework request/response types (`Adapter<TReq, TRes>`, `BaseAdapter<TReq, TRes>`), replacing the previous per-method generics. The mapping members (`toNormalizedRequest`, `toFrameworkResponse`, `handleWebhook`) are now arrow properties, so custom adapters must override them with property syntax rather than method syntax.
22
48
 
23
- Also: `register()` now returns `this`, error hooks always receive a real `Error` instance, and `rawBody` is typed as `Uint8Array`.
24
-
25
- # @zap-studio/webhooks
49
+ Also: `register()` now returns `this`, error hooks always receive a real `Error` instance, and `rawBody` is typed as `Uint8Array`. Internal formatting and lint cleanup migrated to ultracite.
26
50
 
27
- ## 0.2.2
51
+ ## [0.2.2]
28
52
 
29
- ### Dependencies
53
+ ### Changed
30
54
 
31
55
  - Updated dependency `@zap-studio/validation` to `0.3.4`.
32
56
 
33
- ## 0.2.1
34
-
35
- ### Fixed
36
-
37
- - 3a950dc: Preserve registered hook assignment types while keeping the schema-first router API unchanged.
57
+ ## [0.2.1]
38
58
 
39
59
  ### Changed
40
60
 
41
61
  - 5fa58b1: Reduced webhook router complexity by consolidating hook normalization and handler entry creation.
42
62
  - 7004e9f: Allow explicit `undefined` in option handling, then follow with d707800 to remove redundant `| undefined` unions from public types.
43
63
  - 9f31f87: Switched the package build to ESNext-aligned output and updated package tooling and publish metadata.
64
+ - Updated dependency `@zap-studio/validation` to `0.3.3`.
44
65
 
45
- ### Dependencies
66
+ ### Fixed
46
67
 
47
- - Updated dependency `@zap-studio/validation` to `0.3.3`.
68
+ - 3a950dc: Preserve registered hook assignment types while keeping the schema-first router API unchanged.
48
69
 
49
- ## 0.2.0
70
+ ## [0.2.0]
50
71
 
51
- ### Minor Changes
72
+ ### Changed
52
73
 
53
74
  - c686862: Switch `createHmacVerifier` to Web Crypto and standardize the verifier around string secrets.
54
75
 
55
76
  This change removes the Node `crypto` dependency from the verifier path, keeps `req.rawBody` as `Uint8Array`, simplifies `createHmacVerifier` to take a string secret, and adds public `VerificationError` in `@zap-studio/webhooks/errors` for verifier setup and signature failures.
56
77
 
57
- ## 0.1.4
78
+ ## [0.1.4]
58
79
 
59
- ### Patch Changes
80
+ ### Changed
60
81
 
61
82
  - e26293e: Updated dependencies.
62
83
  - @zap-studio/validation@0.3.2
63
84
 
64
- ## 0.1.3
85
+ ## [0.1.3]
65
86
 
66
- ### Patch Changes
87
+ ### Changed
67
88
 
68
89
  - 5ea3d3b: Updated dependencies.
69
90
  - @zap-studio/validation@0.3.1
70
91
 
71
- ## 0.1.2
92
+ ## [0.1.2]
72
93
 
73
- ### Patch Changes
94
+ ### Fixed
74
95
 
75
96
  - c209a27: Fix payload schema validation internals to use the current async `standardValidate` options API (`{ throwOnError: false }`), restoring typecheck compatibility after the validation helper signature update.
76
97
 
77
- ## 0.1.1
98
+ ## [0.1.1]
78
99
 
79
- ### Dependencies
100
+ ### Changed
80
101
 
81
102
  - f75b984: Updated dependency `@zap-studio/validation` to `0.3.0`.
82
103
 
83
- ## 0.1.0
104
+ ## [0.1.0]
84
105
 
85
106
  ### Added
86
107
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 alexandretrotel
3
+ Copyright (c) 2026 Alexandre Trotel
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,66 +2,53 @@
2
2
 
3
3
  Schema-first, type-safe webhook routing built on the standard Web API [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) and [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) primitives, with runtime-agnostic signature verification support.
4
4
 
5
- Works with any validation library that implements [Standard Schema](https://github.com/standard-schema/standard-schema), including Zod, Valibot, and ArkType.
5
+ Full documentation: [zapstudio.dev/webhooks](https://www.zapstudio.dev/webhooks)
6
6
 
7
- ## Why this package exists
8
-
9
- Webhook handlers usually repeat the same plumbing:
10
-
11
- - verify request authenticity
12
- - parse and validate payloads
13
- - route by event path
14
- - normalize success/error responses
15
-
16
- `@zap-studio/webhooks` isolates that plumbing so your handler code stays focused on business logic.
17
-
18
- Schemas are the source of truth, and payload types are inferred from them.
19
-
20
- ## Install
7
+ ## Installation
21
8
 
22
9
  ```bash
23
10
  npm install @zap-studio/webhooks
24
11
  ```
25
12
 
26
- ## Quickstart
13
+ You also need a schema library that implements [Standard Schema](https://github.com/standard-schema/standard-schema), such as Zod, Valibot, or ArkType.
14
+
15
+ ## Features
16
+
17
+ - **Web API native** — `handle(request: Request)` returns a `Response`, so the router plugs directly into Bun, Deno, Cloudflare Workers, Next.js route handlers, Hono, and any other fetch-compatible runtime.
18
+ - **Type-safe routing** — handler payload types are inferred from the route schema.
19
+ - **Standard Schema validation** — bring Zod, Valibot, ArkType, or any compatible library.
20
+ - **Signature verification** — built-in HMAC verifier with constant-time comparison, or plug in your own `verify` function.
21
+ - **Lifecycle hooks** — global `before`, `after`, and `onError` hooks for cross-cutting behavior.
22
+ - **Runtime-agnostic** — uses the Web Crypto API, not Node-specific APIs.
23
+ - **Optional logging** through `createWebhookRouter({ logger })` ([`@zap-studio/logger`](https://www.npmjs.com/package/@zap-studio/logger)) — omit it and there's zero logging overhead.
24
+ - **Tree-shakeable** — validation and hook-running internals are standalone functions; unused exports are dropped by any modern bundler.
25
+
26
+ ## Quick Start
27
27
 
28
28
  ```ts
29
+ import { ConsoleLogger } from "@zap-studio/logger";
29
30
  import { createWebhookRouter } from "@zap-studio/webhooks";
30
31
  import { z } from "zod";
31
32
 
32
- const router = createWebhookRouter({
33
- prefix: "/webhooks", // default
34
- });
33
+ const logger = new ConsoleLogger({ minLevel: "debug" });
34
+ const router = createWebhookRouter({ prefix: "/webhooks", logger });
35
35
 
36
36
  router.register("/payments/succeeded", {
37
- schema: z.object({
38
- id: z.string(),
39
- amount: z.number().positive(),
40
- currency: z.string().length(3),
41
- }),
37
+ schema: z.object({ id: z.string(), amount: z.number().positive() }),
42
38
  handler: ({ payload }) => {
43
39
  // payload is inferred from schema
44
- return Response.json(`processed ${payload.id}`);
40
+ return Response.json({ processed: payload.id });
45
41
  },
46
42
  });
47
43
 
48
- // Any fetch-compatible runtime: Bun, Deno, Cloudflare Workers, ...
49
44
  export default {
50
45
  fetch: (request: Request) => router.handle(request),
51
46
  };
52
47
  ```
53
48
 
54
- `router.handle` takes a standard `Request` and returns a standard `Response`, so the router plugs directly into any fetch-native runtime — no adapter layer needed.
55
-
56
- Handlers can return a `Response`, or `undefined` to let the router reply with its default `200` acknowledgement.
57
-
58
- ### Paths and the prefix
59
-
60
- Routes are registered with a leading slash (`"/payments/succeeded"`) and matched relative to the router's `prefix` (default `"/webhooks"`, no trailing slash) — so the example above answers on `/webhooks/payments/succeeded`. Paths are normalized internally: missing leading slashes are added, trailing slashes stripped, and duplicate slashes collapsed, on both registered routes and incoming request URLs. Set `prefix: ""` (or `"/"`) to mount routes at the root.
61
-
62
- ## Runtime integration
49
+ ## Web API Native
63
50
 
64
- Because `handle(request)` speaks fetch, integration is one line in most environments:
51
+ `handle(request: Request)` returns a `Response`, so the router plugs directly into any fetch-compatible runtime.
65
52
 
66
53
  ```ts
67
54
  // Bun / Deno / Cloudflare Workers
@@ -74,150 +61,95 @@ export const POST = (request: Request) => router.handle(request);
74
61
  app.all("/webhooks/*", (c) => router.handle(c.req.raw));
75
62
  ```
76
63
 
77
- For raw Node `http` servers, use a fetch-to-Node bridge such as [`srvx`](https://srvx.h3.dev) or [`@hono/node-server`](https://github.com/honojs/node-server).
64
+ ## Type-Safe Routing
78
65
 
79
- ## The webhook context
80
-
81
- Hooks, verifiers, and handlers all receive a context object instead of the raw request stream. The router reads the request body exactly once, so the exact bytes stay available for signature verification:
66
+ Handler payload types are inferred from the route schema.
82
67
 
83
68
  ```ts
84
- interface WebhookContext {
85
- request: Request; // headers, method, url — body already consumed
86
- rawBody: Uint8Array; // exact request body bytes
87
- path: string; // matched route key, e.g. "/payments/succeeded"
88
- }
69
+ router.register("/payments/succeeded", {
70
+ schema: z.object({ id: z.string(), amount: z.number() }),
71
+ handler: ({ payload }) => {
72
+ // payload.id: string, payload.amount: number inferred from schema
73
+ return Response.json({ ok: true });
74
+ },
75
+ });
89
76
  ```
90
77
 
91
- Handlers additionally receive `payload`, the schema-validated body.
78
+ ## Standard Schema Validation
92
79
 
93
- ## GitHub webhook example
80
+ Bring Zod, Valibot, ArkType, or any compatible library.
94
81
 
95
82
  ```ts
96
- import { createHmacVerifier, createWebhookRouter } from "@zap-studio/webhooks";
97
83
  import { z } from "zod";
84
+ // or: import * as v from "valibot"; import { type } from "arktype";
98
85
 
99
- const router = createWebhookRouter({
100
- verify: createHmacVerifier({
101
- headerName: "x-hub-signature-256",
102
- secret: process.env.GITHUB_WEBHOOK_SECRET!,
103
- }),
104
- });
105
-
106
- router.register("/github/push", {
107
- schema: z.object({
108
- ref: z.string(),
109
- repository: z.object({
110
- full_name: z.string(),
111
- }),
112
- }),
113
- handler: ({ payload }) => {
114
- console.log(`[github] ${payload.repository.full_name} ${payload.ref}`);
115
- return undefined; // default 200 "ok"
116
- },
86
+ router.register("/event", {
87
+ schema: z.object({ id: z.string() }),
88
+ handler: ({ payload }) => Response.json(payload),
117
89
  });
118
90
  ```
119
91
 
120
- ## Stripe webhook example
92
+ ## Signature Verification
121
93
 
122
- ```ts
123
- import Stripe from "stripe";
124
- import { createWebhookRouter } from "@zap-studio/webhooks";
125
- import { z } from "zod";
94
+ Built-in HMAC verifier with constant-time comparison, or plug in your own `verify` function.
126
95
 
127
- const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
96
+ ```ts
97
+ import {
98
+ createHmacVerifier,
99
+ createWebhookRouter,
100
+ VerificationError,
101
+ } from "@zap-studio/webhooks";
128
102
 
129
103
  const router = createWebhookRouter({
130
- verify: ({ request, rawBody }) => {
131
- const signature = request.headers.get("stripe-signature");
132
- if (!signature) {
133
- throw new Error("Missing Stripe signature");
134
- }
135
-
136
- stripe.webhooks.constructEvent(
137
- Buffer.from(rawBody),
138
- signature,
139
- process.env.STRIPE_WEBHOOK_SECRET!
140
- );
141
- },
142
- });
143
-
144
- router.register("/stripe/payment_intent.succeeded", {
145
- schema: z.object({
146
- id: z.string(),
147
- object: z.literal("event"),
148
- type: z.literal("payment_intent.succeeded"),
104
+ verify: createHmacVerifier({
105
+ headerName: "x-hub-signature-256",
106
+ secret: process.env.WEBHOOK_SECRET!,
149
107
  }),
150
- handler: ({ payload }) => {
151
- console.log(`[stripe] event ${payload.id} (${payload.type})`);
152
- return Response.json("received");
108
+ onError: (error) => {
109
+ if (error instanceof VerificationError) {
110
+ return Response.json({ error: "invalid signature" }, { status: 401 });
111
+ }
153
112
  },
154
113
  });
155
114
  ```
156
115
 
157
- ## Lifecycle hooks
116
+ ## Lifecycle Hooks
158
117
 
159
- Lifecycle hooks let you apply cross-cutting behavior without duplicating code in each handler:
160
-
161
- - `before`: run logic before verify/validation/handler (logging, tracing, rate-limit checks)
162
- - `after`: run logic after successful handler execution (metrics, audit logs)
163
- - `onError`: map thrown errors to consistent responses and centralize error reporting
118
+ Global `before`, `after`, and `onError` hooks for cross-cutting behavior.
164
119
 
165
120
  ```ts
166
121
  const router = createWebhookRouter({
167
- before: (ctx) => {
168
- console.log("incoming", ctx.path);
169
- },
170
- after: (_ctx, response) => {
171
- console.log("status", response.status);
172
- },
122
+ before: (ctx) => console.log("incoming", ctx.path),
123
+ after: (_ctx, response) => console.log("status", response.status),
173
124
  onError: (error) => Response.json({ error: error.message }, { status: 500 }),
174
125
  });
175
126
  ```
176
127
 
177
- After-hooks receive the outgoing `Response` as-is. If a hook needs to read the body, call `response.clone()` first so the stream sent to the client stays readable:
128
+ ## Runtime-Agnostic
129
+
130
+ Uses the Web Crypto API, not Node-specific APIs.
178
131
 
179
132
  ```ts
180
- const router = createWebhookRouter({
181
- after: async (_ctx, response) => {
182
- const body = await response.clone().json();
183
- console.log("responded with", body);
184
- },
133
+ // Uses globalThis.crypto.subtle — no Node `crypto` import required
134
+ const verify = createHmacVerifier({
135
+ headerName: "x-hub-signature-256",
136
+ secret: process.env.WEBHOOK_SECRET!,
185
137
  });
186
138
  ```
187
139
 
188
- ## Verification helper
189
-
190
- `@zap-studio/webhooks` exports `createHmacVerifier`, a small helper that builds a `verify` function for HMAC-signed webhook providers.
140
+ ## Logging
191
141
 
192
- It does not depend on Node APIs. The verifier uses the Web Crypto API, so it works in any runtime that provides `globalThis.crypto.subtle`.
193
-
194
- - reads a signature from the header you choose
195
- - computes an HMAC from `ctx.rawBody`
196
- - compares signatures in constant time
197
- - uses the Web Crypto API instead of Node `crypto`
198
- - works across runtimes that provide `globalThis.crypto.subtle`
199
- - expects a string secret
200
- - throws `VerificationError` on verifier setup or signature failures
142
+ Pass a `logger?: Logger` from [`@zap-studio/logger`](https://www.npmjs.com/package/@zap-studio/logger) to `createWebhookRouter(...)` to observe delivery attempts, dispatch, verification failures, and unmatched routes. Omit it and nothing is logged.
201
143
 
202
144
  ```ts
203
- import { createHmacVerifier, VerificationError } from "@zap-studio/webhooks";
204
-
205
- const verify = createHmacVerifier({
206
- headerName: "x-hub-signature-256",
207
- secret: process.env.WEBHOOK_SECRET!,
208
- algo: "sha256", // optional, defaults to sha256
209
- });
145
+ import { ConsoleLogger } from "@zap-studio/logger";
146
+ import { createWebhookRouter } from "@zap-studio/webhooks";
210
147
 
211
- try {
212
- await verify(ctx);
213
- } catch (error) {
214
- if (error instanceof VerificationError) {
215
- console.error("webhook verification failed", error.message);
216
- }
217
- }
148
+ const logger = new ConsoleLogger({ minLevel: "debug" });
149
+ const router = createWebhookRouter({ prefix: "/webhooks", logger });
218
150
  ```
219
151
 
220
- Use this when your provider uses standard HMAC signatures. For providers with custom signing formats, pass your own `verify` function.
152
+ Each delivery attempt and handler dispatch logs at `debug`; verification failures and unmatched routes log at `warn`.
221
153
 
222
154
  ## Runtime Support
223
155
 
package/dist/errors.d.ts CHANGED
@@ -9,6 +9,22 @@
9
9
  *
10
10
  * This error is used by verifier helpers such as `createHmacVerifier` so
11
11
  * callers can distinguish verification failures from other webhook errors.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { VerificationError } from "@zap-studio/webhooks";
16
+ *
17
+ * const response = await router.handle(request);
18
+ * // Verification failures surface as a 500 response by default, or via onError:
19
+ * const routerWithHandler = createWebhookRouter({
20
+ * verify: createHmacVerifier({ headerName: "x-signature", secret }),
21
+ * onError: (error) => {
22
+ * if (error instanceof VerificationError) {
23
+ * return Response.json({ error: error.message }, { status: 401 });
24
+ * }
25
+ * },
26
+ * });
27
+ * ```
12
28
  */
13
29
  declare class VerificationError extends Error {
14
30
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;cAYa,0BAA0B;;;;;;EAMrC,YAAY"}
1
+ {"version":3,"file":"errors.d.ts","names":[],"sources":["../src/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4Ba,0BAA0B;;;;;;EAMrC,YAAY"}
package/dist/errors.js CHANGED
@@ -9,6 +9,22 @@
9
9
  *
10
10
  * This error is used by verifier helpers such as `createHmacVerifier` so
11
11
  * callers can distinguish verification failures from other webhook errors.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { VerificationError } from "@zap-studio/webhooks";
16
+ *
17
+ * const response = await router.handle(request);
18
+ * // Verification failures surface as a 500 response by default, or via onError:
19
+ * const routerWithHandler = createWebhookRouter({
20
+ * verify: createHmacVerifier({ headerName: "x-signature", secret }),
21
+ * onError: (error) => {
22
+ * if (error instanceof VerificationError) {
23
+ * return Response.json({ error: error.message }, { status: 401 });
24
+ * }
25
+ * },
26
+ * });
27
+ * ```
12
28
  */
13
29
  var VerificationError = class extends Error {
14
30
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Error primitives for webhook verification failures.\n *\n * @module @zap-studio/webhooks/errors\n */\n\n/**\n * Error thrown when webhook request verification fails.\n *\n * This error is used by verifier helpers such as `createHmacVerifier` so\n * callers can distinguish verification failures from other webhook errors.\n */\nexport class VerificationError extends Error {\n /**\n * Creates a verification error with a human-readable message.\n *\n * @param message - Error message describing the verification failure.\n */\n constructor(message: string) {\n super(message);\n this.name = \"VerificationError\";\n }\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,oBAAb,cAAuC,MAAM;;;;;;CAM3C,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * Error primitives for webhook verification failures.\n *\n * @module @zap-studio/webhooks/errors\n */\n\n/**\n * Error thrown when webhook request verification fails.\n *\n * This error is used by verifier helpers such as `createHmacVerifier` so\n * callers can distinguish verification failures from other webhook errors.\n *\n * @example\n * ```ts\n * import { VerificationError } from \"@zap-studio/webhooks\";\n *\n * const response = await router.handle(request);\n * // Verification failures surface as a 500 response by default, or via onError:\n * const routerWithHandler = createWebhookRouter({\n * verify: createHmacVerifier({ headerName: \"x-signature\", secret }),\n * onError: (error) => {\n * if (error instanceof VerificationError) {\n * return Response.json({ error: error.message }, { status: 401 });\n * }\n * },\n * });\n * ```\n */\nexport class VerificationError extends Error {\n /**\n * Creates a verification error with a human-readable message.\n *\n * @param message - Error message describing the verification failure.\n */\n constructor(message: string) {\n super(message);\n this.name = \"VerificationError\";\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAa,oBAAb,cAAuC,MAAM;;;;;;CAM3C,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { VerificationError } from "./errors.js";
2
- import { AfterHook, BeforeHook, ErrorHook, HandlerContext, HandlerMap, InferSchemaOutput, InferWebhookMapFromRoutes, RegisterOptions, SchemaRouteOptions, SchemaRoutes, VerifyFn, WebhookContext, WebhookHandler } from "./types.js";
3
- import { WebhookRouter, WebhookRouterOptions, createWebhookRouter } from "./router.js";
4
- import { constantTimeEquals } from "./utils.js";
5
- import { createHmacVerifier } from "./verify.js";
2
+ import { AfterHook, BeforeHook, ErrorHook, HandlerContext, HandlerMap, InferSchemaOutput, InferWebhookMapFromRoutes, RegisterOptions, SchemaRouteOptions, SchemaRoutes, VerifyFn, WebhookContext, WebhookHandler, WebhookRouterOptions } from "./types.js";
3
+ import { WebhookRouter, createWebhookRouter } from "./router.js";
4
+ import { constantTimeEquals, createHmacVerifier } from "./verify.js";
6
5
  export { type AfterHook, type BeforeHook, type ErrorHook, type HandlerContext, type HandlerMap, type InferSchemaOutput, type InferWebhookMapFromRoutes, type RegisterOptions, type SchemaRouteOptions, type SchemaRoutes, VerificationError, type VerifyFn, type WebhookContext, type WebhookHandler, WebhookRouter, type WebhookRouterOptions, constantTimeEquals, createHmacVerifier, createWebhookRouter };
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { VerificationError } from "./errors.js";
2
2
  import { WebhookRouter, createWebhookRouter } from "./router.js";
3
- import { constantTimeEquals } from "./utils.js";
4
- import { createHmacVerifier } from "./verify.js";
3
+ import { constantTimeEquals, createHmacVerifier } from "./verify.js";
5
4
  export { VerificationError, WebhookRouter, constantTimeEquals, createHmacVerifier, createWebhookRouter };