@instantdb/webhooks 0.0.0 → 1.0.26-branch-webhooks-sdk.25754446577.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.
@@ -1,36 +1,38 @@
1
-
2
- 
3
- > @instantdb/webhooks@0.0.0 build /Users/daniel/projects/instant-private/client/packages/webhooks
4
- > rm -rf dist; npm run build:tshy && npm run check-exports
5
-
6
-
7
- > @instantdb/webhooks@0.0.0 build:tshy
8
- > tshy
9
-
10
- ⠙
11
- > @instantdb/webhooks@0.0.0 check-exports
12
- > attw --pack .
13
-
14
- 
15
- @instantdb/webhooks v0.0.0
16
-
17
- Build tools:
18
- - @arethetypeswrong/cli@^0.17.4
19
- - typescript@^5.9.3
20
- - tshy@^3.0.2
21
-
22
-  No problems found 🌟
23
-
24
-
25
- ┌───────────────────┬────────────────────────────────────┬───────────────────────┐
26
- │ │ "@instantdb/webhooks/package.json" │ "@instantdb/webhooks" │
27
- ├───────────────────┼────────────────────────────────────┼───────────────────────┤
28
- │ node10 │ 🟢 (JSON) │ 🟢 │
29
- ├───────────────────┼────────────────────────────────────┼───────────────────────┤
30
- │ node16 (from CJS) │ 🟢 (JSON) │ 🟢 (CJS) │
31
- ├───────────────────┼────────────────────────────────────┼───────────────────────┤
32
- │ node16 (from ESM) │ 🟢 (JSON) │ 🟢 (ESM) │
33
- ├───────────────────┼────────────────────────────────────┼───────────────────────┤
34
- │ bundler │ 🟢 (JSON) │ 🟢 │
35
- └───────────────────┴────────────────────────────────────┴───────────────────────┘
36
- ⠙
1
+
2
+ > @instantdb/webhooks@1.0.26-branch-webhooks-sdk.25754446577.1 build /home/runner/work/instant/instant/client/packages/webhooks
3
+ > rm -rf dist; npm run build:tshy && npm run check-exports
4
+
5
+ npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
6
+ npm warn Unknown user config "always-auth". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
7
+
8
+ > @instantdb/webhooks@1.0.26-branch-webhooks-sdk.25754446577.1 build:tshy
9
+ > tshy
10
+
11
+ npm warn Unknown env config "verify-deps-before-run". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
12
+ npm warn Unknown user config "always-auth". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
13
+
14
+ > @instantdb/webhooks@1.0.26-branch-webhooks-sdk.25754446577.1 check-exports
15
+ > attw --pack .
16
+
17
+
18
+ @instantdb/webhooks v1.0.26-branch-webhooks-sdk.25754446577.1
19
+
20
+ Build tools:
21
+ - @arethetypeswrong/cli@^0.17.4
22
+ - typescript@^5.9.3
23
+ - tshy@^3.0.2
24
+
25
+ No problems found 🌟
26
+
27
+
28
+ ┌───────────────────┬────────────────────────────────────┬───────────────────────┐
29
+ │ │ "@instantdb/webhooks/package.json" │ "@instantdb/webhooks" │
30
+ ├───────────────────┼────────────────────────────────────┼───────────────────────┤
31
+ │ node10 │ 🟢 (JSON) │ 🟢 │
32
+ ├───────────────────┼────────────────────────────────────┼───────────────────────┤
33
+ │ node16 (from CJS) │ 🟢 (JSON) │ 🟢 (CJS) │
34
+ ├───────────────────┼────────────────────────────────────┼───────────────────────┤
35
+ │ node16 (from ESM) │ 🟢 (JSON) │ 🟢 (ESM) │
36
+ ├───────────────────┼────────────────────────────────────┼───────────────────────┤
37
+ │ bundler │ 🟢 (JSON) │ 🟢 │
38
+ └───────────────────┴────────────────────────────────────┴───────────────────────┘
@@ -1,4 +1,4 @@
1
- import { InstantSchemaDef, ResolveAttrs } from '@instantdb/core';
1
+ import { InstantSchemaDef, InstantUnknownSchema, ResolveAttrs } from '@instantdb/core';
2
2
  type Config<Schema extends InstantSchemaDef<any, any, any>> = {
3
3
  appId?: string | null | undefined;
4
4
  adminToken?: string | null | undefined;
@@ -82,11 +82,8 @@ export type WebhookInfo = {
82
82
  /** HTTPS endpoint that Instant POSTs to. */
83
83
  url: string;
84
84
  };
85
- /**
86
- * The entity types (namespaces) this webhook listens to. `null` if every
87
- * etype the webhook referenced has since been removed from the schema.
88
- */
89
- etypes: string[] | null;
85
+ /** The entity types (namespaces) this webhook listens to. */
86
+ etypes: string[];
90
87
  /** Which write actions trigger delivery. */
91
88
  actions: WebhookAction[];
92
89
  /** Whether the webhook is currently delivering events. */
@@ -132,8 +129,7 @@ export type WebhookAttempt = {
132
129
  export type WebhookEventInfo = {
133
130
  /**
134
131
  * Instant Sequence Number — a stable, totally ordered identifier for the
135
- * event. Doubles as the pagination cursor and is used to address the event
136
- * in {@link WebhooksManager.getEvent} and {@link WebhooksManager.resendEvent}.
132
+ * event.
137
133
  */
138
134
  isn: string;
139
135
  /** Current stage in the delivery lifecycle. */
@@ -242,6 +238,9 @@ export declare class WebhooksManager<Schema extends InstantSchemaDef<any, any, a
242
238
  * public host, if `etypes` doesn't reference any entity in the app's
243
239
  * schema, if `actions` is empty, or if the app has hit its webhook limit.
244
240
  *
241
+ * An app may have at most **100 active webhooks** at a time; {@link delete}
242
+ * a webhook to free up a slot before creating another.
243
+ *
245
244
  * @example
246
245
  * const webhook = await db.webhooks.manager.create({
247
246
  * url: 'https://example.com/instant',
@@ -334,6 +333,9 @@ export declare class Webhooks<Schema extends InstantSchemaDef<any, any, any>> {
334
333
  * {@link WebhookHandlers} object suitable for {@link processPayload} and
335
334
  * {@link processRequest}.
336
335
  *
336
+ * If you already have a {@link Webhooks} instance, prefer the instance
337
+ * form (`db.webhooks.helpers()`) — it infers `Schema` automatically.
338
+ *
337
339
  * @example
338
340
  * const { typedHandlers, combineHandlers } = Webhooks.helpers<typeof schema>();
339
341
  * const handlers = combineHandlers(
@@ -342,7 +344,15 @@ export declare class Webhooks<Schema extends InstantSchemaDef<any, any, any>> {
342
344
  * typedHandlers('$default', (record) => { ... }),
343
345
  * );
344
346
  */
345
- static helpers<Schema extends InstantSchemaDef<any, any, any>>(): WebhookHelpers<Schema>;
347
+ static helpers<Schema extends InstantSchemaDef<any, any, any> = InstantUnknownSchema>(): WebhookHelpers<Schema>;
348
+ /**
349
+ * Instance form of {@link Webhooks.helpers} that infers `Schema` from this
350
+ * instance — no `<typeof schema>` type argument required.
351
+ *
352
+ * @example
353
+ * const { typedHandlers, combineHandlers } = db.webhooks.helpers();
354
+ */
355
+ helpers(): WebhookHelpers<Schema>;
346
356
  constructor(config: Config<Schema>, jsonFetch?: JsonFetch);
347
357
  /** Fetches Instant's JWK set for verifying webhook signatures. */
348
358
  fetchJwks(): Promise<any>;
@@ -405,7 +415,7 @@ export declare class Webhooks<Schema extends InstantSchemaDef<any, any, any>> {
405
415
  * all handlers complete and will reject if any of the handlers fails.
406
416
  *
407
417
  * @example
408
- * const { typedHandlers, combineHandlers } = Webhooks.helpers<typeof schema>();
418
+ * const { typedHandlers, combineHandlers } = db.webhooks.helpers();
409
419
  *
410
420
  * const handlers = combineHandlers(
411
421
  * typedHandlers('posts', 'create', async (record) => {
@@ -425,6 +435,136 @@ export declare class Webhooks<Schema extends InstantSchemaDef<any, any, any>> {
425
435
  tolerance?: number | null | undefined;
426
436
  receivedAt?: Date | null | undefined;
427
437
  } | null | undefined): Promise<void>;
438
+ /**
439
+ * Adapter for frameworks that hand you a Node-style `http.IncomingMessage`
440
+ * (Next.js Pages Router, Express, Koa, etc.) instead of a Web `Request`.
441
+ * Wraps the request in a Web `Request` and delegates to
442
+ * {@link processRequest}. You still send the HTTP response yourself.
443
+ *
444
+ * The raw body is required for signature verification. The adapter picks
445
+ * it up from one of:
446
+ *
447
+ * - `req.body` if it's a `Buffer` or `Uint8Array` (set by middleware like
448
+ * `express.raw({ type: 'application/json' })`)
449
+ * - `req.body` if it's a string (set by middleware like `express.text()`)
450
+ * - otherwise the unconsumed request stream
451
+ *
452
+ * Don't use a JSON body parser on this route — `express.json()` and
453
+ * `bodyParser: true` in Next.js both parse the body into an object,
454
+ * destroying the raw bytes the signature was computed over.
455
+ *
456
+ * @example
457
+ * // Next.js Pages Router (`pages/api/webhooks.ts`)
458
+ * import type { NextApiRequest, NextApiResponse } from 'next';
459
+ *
460
+ * export const config = { api: { bodyParser: false } };
461
+ *
462
+ * const { typedHandlers, combineHandlers } = db.webhooks.helpers();
463
+ *
464
+ * const handlers = combineHandlers(
465
+ * typedHandlers('posts', 'create', async (record) => {
466
+ * await sendNewPostEmail(record.after);
467
+ * }),
468
+ * typedHandlers('$default', (record) => {
469
+ * console.log('unhandled record', record);
470
+ * }),
471
+ * );
472
+ *
473
+ * export default async function handler(
474
+ * req: NextApiRequest,
475
+ * res: NextApiResponse,
476
+ * ) {
477
+ * try {
478
+ * await db.webhooks.processNodeRequest(handlers, req);
479
+ * res.status(200).end();
480
+ * } catch (e) {
481
+ * res.status(400).json({ error: String(e) });
482
+ * }
483
+ * }
484
+ *
485
+ * @example
486
+ * // Express — skip the JSON body parser on the webhook route and use
487
+ * // `express.raw()` so `req.body` arrives as a Buffer.
488
+ * import express from 'express';
489
+ *
490
+ * const app = express();
491
+ *
492
+ * app.use((req, res, next) => {
493
+ * if (req.originalUrl === '/webhooks/instant') return next();
494
+ * express.json()(req, res, next);
495
+ * });
496
+ *
497
+ * app.post(
498
+ * '/webhooks/instant',
499
+ * express.raw({ type: 'application/json' }),
500
+ * async (req, res) => {
501
+ * try {
502
+ * await db.webhooks.processNodeRequest(handlers, req);
503
+ * res.status(200).end();
504
+ * } catch (e) {
505
+ * res.status(400).json({ error: String(e) });
506
+ * }
507
+ * },
508
+ * );
509
+ *
510
+ * @example
511
+ * // Koa — `ctx.req` is the raw IncomingMessage. If `koa-bodyparser` (or
512
+ * // similar) runs on this route it consumes the stream, so either skip it
513
+ * // here or pull the raw body yourself and shim it onto the request:
514
+ * import Koa from 'koa';
515
+ * import Router from '@koa/router';
516
+ * import rawBody from 'raw-body';
517
+ *
518
+ * const router = new Router();
519
+ *
520
+ * router.post('/webhooks/instant', async (ctx) => {
521
+ * try {
522
+ * await db.webhooks.processNodeRequest(handlers, ctx.req, {
523
+ * body: rawBody(ctx.req), // adapter awaits the Promise
524
+ * });
525
+ * ctx.status = 200;
526
+ * } catch (e) {
527
+ * ctx.status = 400;
528
+ * ctx.body = { error: String(e) };
529
+ * }
530
+ * });
531
+ *
532
+ * @example
533
+ * // NestJS (Express adapter). With `rawBody: true` on the factory, Nest
534
+ * // populates `req.rawBody` itself — just pass `req`.
535
+ * import { Controller, Post, Req, HttpCode } from '@nestjs/common';
536
+ * import type { Request } from 'express';
537
+ *
538
+ * @Controller('webhooks')
539
+ * export class WebhooksController {
540
+ * @Post('instant')
541
+ * @HttpCode(200)
542
+ * async handle(@Req() req: Request) {
543
+ * await db.webhooks.processNodeRequest(handlers, req);
544
+ * }
545
+ * }
546
+ *
547
+ * // (Pair with `NestFactory.create(AppModule, { rawBody: true })` in main.ts.)
548
+ */
549
+ processNodeRequest(handlers: WebhookHandlers<Schema>, req: {
550
+ url?: string;
551
+ method?: string;
552
+ headers: Record<string, string | string[] | undefined>;
553
+ body?: unknown;
554
+ rawBody?: unknown;
555
+ [Symbol.asyncIterator]?: () => AsyncIterableIterator<Uint8Array | string>;
556
+ }, opts?: {
557
+ /**
558
+ * Raw body to use instead of reading from `req`. Useful for
559
+ * frameworks that hand you the body separately from the request
560
+ * object (e.g. NestJS `@RawBody()`, Koa with `raw-body`).
561
+ * Accepts a `Buffer` / `Uint8Array`, a string, or a Promise of
562
+ * either.
563
+ */
564
+ body?: unknown;
565
+ tolerance?: number | null | undefined;
566
+ receivedAt?: Date | null | undefined;
567
+ } | null | undefined): Promise<void>;
428
568
  }
429
569
  export {};
430
570
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,gBAAgB,EAChB,YAAY,EAEb,MAAM,iBAAiB,CAAC;AAEzB,KAAK,MAAM,CAAC,MAAM,SAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI;IAC5D,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;I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AAI,CAAC,EAAE,OAAO,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;QACtC,UAAU,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC;KACtC,GACD,IAAI,GACJ,SAAS,GACZ,OAAO,CAAC,IAAI,CAAC;CAmFjB"}
@@ -64,7 +64,6 @@ function hexToUint8Array(hexString) {
64
64
  }
65
65
  return bytes;
66
66
  }
67
- // XXX: Test in nextjs app router
68
67
  // XXX: Test in nextjs pages router
69
68
  // XXX: Test with express, deno, koa, nestjs
70
69
  // XXX: Test with cloudflare
@@ -151,7 +150,7 @@ function toWebhookInfo(raw) {
151
150
  return {
152
151
  id: raw.id,
153
152
  sink: raw.sink,
154
- etypes: raw.etypes ?? null,
153
+ etypes: raw.etypes ?? [],
155
154
  actions: raw.actions,
156
155
  status: raw.status,
157
156
  disabledReason: raw.disabled_reason ?? null,
@@ -234,6 +233,9 @@ class WebhooksManager {
234
233
  * public host, if `etypes` doesn't reference any entity in the app's
235
234
  * schema, if `actions` is empty, or if the app has hit its webhook limit.
236
235
  *
236
+ * An app may have at most **100 active webhooks** at a time; {@link delete}
237
+ * a webhook to free up a slot before creating another.
238
+ *
237
239
  * @example
238
240
  * const webhook = await db.webhooks.manager.create({
239
241
  * url: 'https://example.com/instant',
@@ -362,6 +364,9 @@ class Webhooks {
362
364
  * {@link WebhookHandlers} object suitable for {@link processPayload} and
363
365
  * {@link processRequest}.
364
366
  *
367
+ * If you already have a {@link Webhooks} instance, prefer the instance
368
+ * form (`db.webhooks.helpers()`) — it infers `Schema` automatically.
369
+ *
365
370
  * @example
366
371
  * const { typedHandlers, combineHandlers } = Webhooks.helpers<typeof schema>();
367
372
  * const handlers = combineHandlers(
@@ -397,6 +402,16 @@ class Webhooks {
397
402
  combineHandlers: combineHandlers,
398
403
  };
399
404
  }
405
+ /**
406
+ * Instance form of {@link Webhooks.helpers} that infers `Schema` from this
407
+ * instance — no `<typeof schema>` type argument required.
408
+ *
409
+ * @example
410
+ * const { typedHandlers, combineHandlers } = db.webhooks.helpers();
411
+ */
412
+ helpers() {
413
+ return Webhooks.helpers();
414
+ }
400
415
  constructor(config, jsonFetch) {
401
416
  this.appId = config.appId;
402
417
  this.schema = config.schema;
@@ -525,7 +540,7 @@ class Webhooks {
525
540
  * all handlers complete and will reject if any of the handlers fails.
526
541
  *
527
542
  * @example
528
- * const { typedHandlers, combineHandlers } = Webhooks.helpers<typeof schema>();
543
+ * const { typedHandlers, combineHandlers } = db.webhooks.helpers();
529
544
  *
530
545
  * const handlers = combineHandlers(
531
546
  * typedHandlers('posts', 'create', async (record) => {
@@ -546,6 +561,196 @@ class Webhooks {
546
561
  const payload = await this.fetchPayloads(body);
547
562
  await this.processPayload(handlers, payload);
548
563
  }
564
+ /**
565
+ * Adapter for frameworks that hand you a Node-style `http.IncomingMessage`
566
+ * (Next.js Pages Router, Express, Koa, etc.) instead of a Web `Request`.
567
+ * Wraps the request in a Web `Request` and delegates to
568
+ * {@link processRequest}. You still send the HTTP response yourself.
569
+ *
570
+ * The raw body is required for signature verification. The adapter picks
571
+ * it up from one of:
572
+ *
573
+ * - `req.body` if it's a `Buffer` or `Uint8Array` (set by middleware like
574
+ * `express.raw({ type: 'application/json' })`)
575
+ * - `req.body` if it's a string (set by middleware like `express.text()`)
576
+ * - otherwise the unconsumed request stream
577
+ *
578
+ * Don't use a JSON body parser on this route — `express.json()` and
579
+ * `bodyParser: true` in Next.js both parse the body into an object,
580
+ * destroying the raw bytes the signature was computed over.
581
+ *
582
+ * @example
583
+ * // Next.js Pages Router (`pages/api/webhooks.ts`)
584
+ * import type { NextApiRequest, NextApiResponse } from 'next';
585
+ *
586
+ * export const config = { api: { bodyParser: false } };
587
+ *
588
+ * const { typedHandlers, combineHandlers } = db.webhooks.helpers();
589
+ *
590
+ * const handlers = combineHandlers(
591
+ * typedHandlers('posts', 'create', async (record) => {
592
+ * await sendNewPostEmail(record.after);
593
+ * }),
594
+ * typedHandlers('$default', (record) => {
595
+ * console.log('unhandled record', record);
596
+ * }),
597
+ * );
598
+ *
599
+ * export default async function handler(
600
+ * req: NextApiRequest,
601
+ * res: NextApiResponse,
602
+ * ) {
603
+ * try {
604
+ * await db.webhooks.processNodeRequest(handlers, req);
605
+ * res.status(200).end();
606
+ * } catch (e) {
607
+ * res.status(400).json({ error: String(e) });
608
+ * }
609
+ * }
610
+ *
611
+ * @example
612
+ * // Express — skip the JSON body parser on the webhook route and use
613
+ * // `express.raw()` so `req.body` arrives as a Buffer.
614
+ * import express from 'express';
615
+ *
616
+ * const app = express();
617
+ *
618
+ * app.use((req, res, next) => {
619
+ * if (req.originalUrl === '/webhooks/instant') return next();
620
+ * express.json()(req, res, next);
621
+ * });
622
+ *
623
+ * app.post(
624
+ * '/webhooks/instant',
625
+ * express.raw({ type: 'application/json' }),
626
+ * async (req, res) => {
627
+ * try {
628
+ * await db.webhooks.processNodeRequest(handlers, req);
629
+ * res.status(200).end();
630
+ * } catch (e) {
631
+ * res.status(400).json({ error: String(e) });
632
+ * }
633
+ * },
634
+ * );
635
+ *
636
+ * @example
637
+ * // Koa — `ctx.req` is the raw IncomingMessage. If `koa-bodyparser` (or
638
+ * // similar) runs on this route it consumes the stream, so either skip it
639
+ * // here or pull the raw body yourself and shim it onto the request:
640
+ * import Koa from 'koa';
641
+ * import Router from '@koa/router';
642
+ * import rawBody from 'raw-body';
643
+ *
644
+ * const router = new Router();
645
+ *
646
+ * router.post('/webhooks/instant', async (ctx) => {
647
+ * try {
648
+ * await db.webhooks.processNodeRequest(handlers, ctx.req, {
649
+ * body: rawBody(ctx.req), // adapter awaits the Promise
650
+ * });
651
+ * ctx.status = 200;
652
+ * } catch (e) {
653
+ * ctx.status = 400;
654
+ * ctx.body = { error: String(e) };
655
+ * }
656
+ * });
657
+ *
658
+ * @example
659
+ * // NestJS (Express adapter). With `rawBody: true` on the factory, Nest
660
+ * // populates `req.rawBody` itself — just pass `req`.
661
+ * import { Controller, Post, Req, HttpCode } from '@nestjs/common';
662
+ * import type { Request } from 'express';
663
+ *
664
+ * @Controller('webhooks')
665
+ * export class WebhooksController {
666
+ * @Post('instant')
667
+ * @HttpCode(200)
668
+ * async handle(@Req() req: Request) {
669
+ * await db.webhooks.processNodeRequest(handlers, req);
670
+ * }
671
+ * }
672
+ *
673
+ * // (Pair with `NestFactory.create(AppModule, { rawBody: true })` in main.ts.)
674
+ */
675
+ async processNodeRequest(handlers, req, opts) {
676
+ let rawBody;
677
+ let bodyWasReserialized = false;
678
+ // Priority: an explicit `opts.body`, then `req.rawBody` (set by
679
+ // middleware like Firebase Functions or body-parser's `verify` hook),
680
+ // then `req.body`, then the unconsumed request stream.
681
+ let bodyValue = opts?.body ?? req.rawBody ?? req.body;
682
+ // Allow callers to pass a Promise (e.g. the result of `raw-body(ctx.req)`
683
+ // in Koa) without having to await first.
684
+ if (bodyValue != null &&
685
+ typeof bodyValue.then === 'function') {
686
+ bodyValue = await bodyValue;
687
+ }
688
+ if (typeof bodyValue === 'string') {
689
+ rawBody = bodyValue;
690
+ }
691
+ else if (bodyValue instanceof Uint8Array) {
692
+ rawBody = new TextDecoder('utf-8').decode(bodyValue);
693
+ }
694
+ else if (bodyValue != null && typeof bodyValue === 'object') {
695
+ // A JSON parser middleware (e.g. `express.json()`) has consumed the
696
+ // stream and handed us a parsed object. Re-serialize and try anyway —
697
+ // for Instant's webhook body shape this typically round-trips to the
698
+ // bytes the server signed. If it doesn't, we surface a targeted error
699
+ // below.
700
+ try {
701
+ rawBody = JSON.stringify(bodyValue);
702
+ bodyWasReserialized = true;
703
+ }
704
+ catch {
705
+ throw new core_1.InstantError('Webhook request body has already been parsed and could not be re-serialized. Configure this route to receive the raw request body instead of parsed JSON.');
706
+ }
707
+ }
708
+ else if (req[Symbol.asyncIterator]) {
709
+ const encoder = new TextEncoder();
710
+ const chunks = [];
711
+ for await (const chunk of req) {
712
+ chunks.push(typeof chunk === 'string' ? encoder.encode(chunk) : chunk);
713
+ }
714
+ let total = 0;
715
+ for (const c of chunks)
716
+ total += c.byteLength;
717
+ const buf = new Uint8Array(total);
718
+ let offset = 0;
719
+ for (const c of chunks) {
720
+ buf.set(c, offset);
721
+ offset += c.byteLength;
722
+ }
723
+ rawBody = new TextDecoder('utf-8').decode(buf);
724
+ }
725
+ else {
726
+ throw new core_1.InstantError('Could not read the webhook request body. Pass a Node IncomingMessage with an unconsumed stream, or set `req.body` to the raw bytes (Buffer/Uint8Array) or string.');
727
+ }
728
+ const host = typeof req.headers.host === 'string' ? req.headers.host : 'localhost';
729
+ const url = new URL(req.url ?? '/', `https://${host}`);
730
+ const headers = new Headers();
731
+ for (const [k, v] of Object.entries(req.headers)) {
732
+ if (typeof v === 'string')
733
+ headers.set(k, v);
734
+ else if (Array.isArray(v))
735
+ headers.set(k, v.join(', '));
736
+ }
737
+ const webReq = new Request(url, {
738
+ method: req.method ?? 'POST',
739
+ headers,
740
+ body: rawBody,
741
+ });
742
+ try {
743
+ await this.processRequest(handlers, webReq, opts);
744
+ }
745
+ catch (e) {
746
+ if (bodyWasReserialized &&
747
+ e instanceof core_1.InstantError &&
748
+ e.message === 'Instant Signature did not validate') {
749
+ throw new core_1.InstantError('Webhook signature did not validate. The request body was re-serialized from a parsed JSON object, which can produce different bytes than the server signed. Configure this route to receive the raw request body instead of parsed JSON.', { hint: e.hint });
750
+ }
751
+ throw e;
752
+ }
753
+ }
549
754
  }
550
755
  exports.Webhooks = Webhooks;
551
756
  //# sourceMappingURL=index.js.map