@isnap/sdk 2.3.0 → 2.3.1-next.43615425532.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.
Files changed (94) hide show
  1. package/CHANGELOG.md +65 -40
  2. package/README.md +361 -167
  3. package/dist/client.d.ts +37 -49
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/client.js +47 -58
  6. package/dist/client.js.map +1 -1
  7. package/dist/config.d.ts +6 -6
  8. package/dist/config.js +6 -6
  9. package/dist/generated/openapi.d.ts +910 -91
  10. package/dist/index.d.ts +3 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -0
  13. package/dist/index.js.map +1 -1
  14. package/dist/internal/sleep.d.ts +2 -2
  15. package/dist/internal/sleep.js +5 -5
  16. package/dist/internal/sleep.js.map +1 -1
  17. package/dist/resources/apps.d.ts +11 -18
  18. package/dist/resources/apps.d.ts.map +1 -1
  19. package/dist/resources/apps.js +11 -18
  20. package/dist/resources/apps.js.map +1 -1
  21. package/dist/resources/area-codes.d.ts +5 -6
  22. package/dist/resources/area-codes.d.ts.map +1 -1
  23. package/dist/resources/area-codes.js +5 -6
  24. package/dist/resources/area-codes.js.map +1 -1
  25. package/dist/resources/attachments.d.ts +51 -17
  26. package/dist/resources/attachments.d.ts.map +1 -1
  27. package/dist/resources/attachments.js +42 -22
  28. package/dist/resources/attachments.js.map +1 -1
  29. package/dist/resources/byod.d.ts +14 -4
  30. package/dist/resources/byod.d.ts.map +1 -1
  31. package/dist/resources/byod.js +14 -4
  32. package/dist/resources/byod.js.map +1 -1
  33. package/dist/resources/chats.d.ts +32 -22
  34. package/dist/resources/chats.d.ts.map +1 -1
  35. package/dist/resources/chats.js +31 -21
  36. package/dist/resources/chats.js.map +1 -1
  37. package/dist/resources/fleet.d.ts +23 -0
  38. package/dist/resources/fleet.d.ts.map +1 -0
  39. package/dist/resources/fleet.js +20 -0
  40. package/dist/resources/fleet.js.map +1 -0
  41. package/dist/resources/lines.d.ts +258 -268
  42. package/dist/resources/lines.d.ts.map +1 -1
  43. package/dist/resources/lines.js +251 -266
  44. package/dist/resources/lines.js.map +1 -1
  45. package/dist/resources/lookup.d.ts +10 -13
  46. package/dist/resources/lookup.d.ts.map +1 -1
  47. package/dist/resources/lookup.js +10 -13
  48. package/dist/resources/lookup.js.map +1 -1
  49. package/dist/resources/macos-sessions.d.ts +42 -36
  50. package/dist/resources/macos-sessions.d.ts.map +1 -1
  51. package/dist/resources/macos-sessions.js +24 -22
  52. package/dist/resources/macos-sessions.js.map +1 -1
  53. package/dist/resources/messages.d.ts +35 -25
  54. package/dist/resources/messages.d.ts.map +1 -1
  55. package/dist/resources/messages.js +30 -19
  56. package/dist/resources/messages.js.map +1 -1
  57. package/dist/resources/preorders.d.ts +42 -47
  58. package/dist/resources/preorders.d.ts.map +1 -1
  59. package/dist/resources/preorders.js +42 -47
  60. package/dist/resources/preorders.js.map +1 -1
  61. package/dist/resources/trial.d.ts +30 -21
  62. package/dist/resources/trial.d.ts.map +1 -1
  63. package/dist/resources/trial.js +30 -21
  64. package/dist/resources/trial.js.map +1 -1
  65. package/dist/resources/webhooks.d.ts +39 -22
  66. package/dist/resources/webhooks.d.ts.map +1 -1
  67. package/dist/resources/webhooks.js +39 -22
  68. package/dist/resources/webhooks.js.map +1 -1
  69. package/dist/retry.d.ts +9 -10
  70. package/dist/retry.d.ts.map +1 -1
  71. package/dist/retry.js +11 -12
  72. package/dist/retry.js.map +1 -1
  73. package/dist/types.d.ts +10 -0
  74. package/dist/types.d.ts.map +1 -1
  75. package/dist/version.d.ts +1 -1
  76. package/dist/version.d.ts.map +1 -1
  77. package/dist/version.js +13 -37
  78. package/dist/version.js.map +1 -1
  79. package/dist/webhooks/parse.d.ts +10 -9
  80. package/dist/webhooks/parse.d.ts.map +1 -1
  81. package/dist/webhooks/parse.js +14 -13
  82. package/dist/webhooks/parse.js.map +1 -1
  83. package/dist/webhooks/types.d.ts +75 -111
  84. package/dist/webhooks/types.d.ts.map +1 -1
  85. package/dist/webhooks/types.js.map +1 -1
  86. package/dist/webhooks/verify.d.ts +27 -29
  87. package/dist/webhooks/verify.d.ts.map +1 -1
  88. package/dist/webhooks/verify.js +29 -35
  89. package/dist/webhooks/verify.js.map +1 -1
  90. package/examples/handle-webhook.ts +146 -0
  91. package/examples/paginate-messages.ts +54 -0
  92. package/examples/send-message.ts +37 -0
  93. package/examples/upload-attachment.ts +91 -0
  94. package/package.json +4 -8
@@ -1,9 +1,9 @@
1
1
  import type { Message, ReactionType } from '../resources/messages.js';
2
2
  /**
3
- * Common envelope for every webhook event. Per contract §4.1: every
4
- * delivery body is shaped `{ api_version, event_id, event_type,
5
- * created_at, trace_id?, data }`. `data` is a per-event-type payload —
6
- * the type guards below narrow it to a typed shape.
3
+ * What every webhook event has in common: `api_version`, `event_id`,
4
+ * `event_type`, `created_at`, `trace_id` and `data`. `api_version` is the
5
+ * string `v1`. The content of `data` depends on the event type: narrow the
6
+ * event with a type guard such as `isMessageEvent`.
7
7
  */
8
8
  export interface WebhookEventBase {
9
9
  api_version: string;
@@ -14,22 +14,21 @@ export interface WebhookEventBase {
14
14
  data: Record<string, unknown> & WebhookPartnerMetadata;
15
15
  }
16
16
  /**
17
- * The two keys EVERY event's `data` carries, whatever its family (WHA-3655).
18
- * Both are always present: `null` means "untagged" or "not applicable", never
19
- * a key that was left out.
17
+ * The two keys the `data` of every event carries, whatever its family. Both
18
+ * are always present, and `null` when there is no metadata.
20
19
  *
21
- * - `metadata` — your own tags on the event's primary resource: the line for
22
- * `line.*`, the message for `message.*`, the reacted-to message for
23
- * `reaction.*`, the rented session for `macos_session.*`, the trial for
24
- * `trial.*`, the pre-order for `pre_order.*`. Always `null` for
25
- * `typing_indicator.*`, `binding.*` and `webhook.*`, whose resources take
26
- * no tags.
27
- * - `line_metadata` — your own tags on the line the event is tied to, `null`
28
- * when there is none (or it is not your line). On `line.*` it is the same
29
- * object as `metadata`, so one key attributes every event to a line.
20
+ * - `metadata`: your metadata on the resource the event is about: the line
21
+ * for `line.*`, the message for `message.*`, the message reacted to for
22
+ * `reaction.*`, the hosted macOS session for `macos_session.*`, the trial
23
+ * for `trial.*`, the pre-order for `pre_order.*`. Always `null` for
24
+ * `typing_indicator.*`, `binding.*` and `webhook.*`.
25
+ * - `line_metadata`: your metadata on the line the event is tied to, `null`
26
+ * when there is no such line or when it is not yours. On `line.*` it is the
27
+ * same object as `metadata`. On `macos_session.*` the line is the one the
28
+ * session hosts.
30
29
  *
31
- * Both are a snapshot taken when the event was emitted: a retry or a replay
32
- * carries the tags as they stood then, not as they stand now.
30
+ * Both are a snapshot taken when the event was created: a retry or a replay
31
+ * carries the same values.
33
32
  */
34
33
  export type WebhookPartnerMetadata = {
35
34
  metadata: Record<string, unknown> | null;
@@ -43,48 +42,31 @@ export interface MessageEvent extends WebhookEventBase {
43
42
  } & WebhookPartnerMetadata;
44
43
  }
45
44
  export type ReactionEventType = 'reaction.added' | 'reaction.received' | 'reaction.removed';
46
- /** Keys every `reaction.*` delivery carries, whatever its direction. */
45
+ /** Keys every `reaction.*` event carries, whatever its direction. */
47
46
  type ReactionEventDataBase = {
48
47
  parent_message_id: string;
49
48
  reaction_id: string;
50
49
  reaction_type: ReactionType;
51
50
  reaction_emoji: string | null;
52
- /**
53
- * The `line_<base62>` publicId of the line the tapback happened on, and the
54
- * routing key a consumer should prefer (WHA-3183). It is the line of the
55
- * PARENT message — for a shared-plan parent the customer's virtual line, never
56
- * the physical pool carrier the reporting session runs on.
57
- *
58
- * REQUIRED, not optional: both producers resolve it before they enqueue, and a
59
- * consumer that has not persisted the parent has no other handle on the
60
- * delivery. Declaring it optional would let that consumer compile against a
61
- * payload it cannot route.
62
- */
51
+ /** The `line_` id of the line of the message reacted to. */
63
52
  line_id: string;
64
53
  removed_at?: string;
65
54
  };
66
55
  /**
67
- * The `data` payload of a `reaction.*` delivery, per contract §4.3.2. It is
68
- * FLAT — the fields sit directly on `data`, not under a `reaction` key (a
69
- * nested `{ reaction }` shape was declared here until WHA-2193 and no
70
- * producer ever emitted it).
56
+ * The `data` of a `reaction.*` event. The fields sit directly on `data`.
71
57
  *
72
- * Discriminated on `direction`, because the handle key differs by family and
73
- * that asymmetry is deliberate on the producer side: an inbound tapback names
74
- * the counterparty who reacted to us (`from_handle`), an outbound one names
75
- * the line that acted (`actor_handle`). Reading the wrong one is a compile
76
- * error — narrow on `direction` first. `reaction.removed` is the only event
77
- * that fires in both directions.
58
+ * It is a union on `direction`, because the handle key differs: an inbound
59
+ * reaction names the contact who reacted (`from_handle`), an outbound one
60
+ * names the line's own handle (`actor_handle`). Reading the wrong key is a
61
+ * compile error: narrow on `direction` first. `reaction.removed` is the only
62
+ * event sent in both directions.
78
63
  *
79
- * Timestamps are optional because each delivery carries exactly one of them
80
- * (`received_at` inbound-add, `added_at` outbound-add, `removed_at` either
81
- * direction). Keeping them optional also lets a future `reaction.*` member
82
- * with a new timestamp key narrow without an SDK release.
64
+ * Each event carries exactly one of the timestamps: `received_at` for a
65
+ * reaction a contact adds, `added_at` for a reaction you add, `removed_at`
66
+ * for a removal in either direction.
83
67
  *
84
- * `reaction_type` is the widened set that includes `custom` (WHA-2102): a
85
- * counterparty may send an arbitrary emoji, and `reaction_emoji` then carries
86
- * it verbatim — or `null` when the bridge supplied none. For the 6 classic
87
- * tapbacks the emoji is always server-derived (WHA-2100).
68
+ * `reaction_type` includes `custom`: a contact can react with any emoji, and
69
+ * `reaction_emoji` then carries it, or `null` when none was reported.
88
70
  */
89
71
  export type ReactionEventData = (ReactionEventDataBase & {
90
72
  direction: 'inbound';
@@ -99,15 +81,13 @@ export interface ReactionEvent extends WebhookEventBase {
99
81
  event_type: `reaction.${string}`;
100
82
  data: ReactionEventData & WebhookPartnerMetadata;
101
83
  }
102
- export type LineEventType = 'line.connected' | 'line.disconnected' | 'line.offline' | 'line.degraded' | 'line.apple_id_flagged' | 'line.quota_warning' | 'line.quota_exceeded' | 'line.capability_changed' | 'line.terminated' | 'line.variant_changed' | 'line.variant_scheduled' | 'line.variant_unscheduled';
84
+ export type LineEventType = 'line.connected' | 'line.disconnected' | 'line.offline' | 'line.degraded' | 'line.apple_id_flagged' | 'line.quota_warning' | 'line.quota_exceeded' | 'line.capability_changed' | 'line.terminated' | 'line.variant_changed' | 'line.variant_scheduled' | 'line.variant_unscheduled' | 'line.phone_number_changed';
103
85
  /**
104
- * `data` is intentionally typed as `Record<string, unknown>` until the
105
- * contract pins per-event-type field shapes. Today's payloads vary by
106
- * event (e.g. `line.apple_id_flagged` carries `flag_reason`,
107
- * `line.quota_warning` carries `bucket` + `usage`), and surfacing a
108
- * union with optional fields would let TypeScript autocomplete suggest
109
- * keys that aren't present at runtime. Tighten when the contract is
110
- * amended to specify the per-event shapes.
86
+ * `data` is typed as `Record<string, unknown>` because its fields depend on
87
+ * the event type: for example `line.quota_warning` carries `bucket`, `used`
88
+ * and `limit`, and `line.terminated` carries `line` and `origin`. Read the
89
+ * fields of each event type from the documentation and check them at run
90
+ * time.
111
91
  */
112
92
  export interface LineEvent extends WebhookEventBase {
113
93
  event_type: `line.${string}`;
@@ -115,27 +95,25 @@ export interface LineEvent extends WebhookEventBase {
115
95
  }
116
96
  export type TypingIndicatorEventType = 'typing_indicator.started' | 'typing_indicator.stopped';
117
97
  /**
118
- * `data` is intentionally `Record<string, unknown>` — the partner-facing
119
- * shape is not yet documented in the contract. See `LineEvent` for the
120
- * same rationale.
98
+ * Sent when a contact starts or stops typing in a chat with the line. `data`
99
+ * is typed as `Record<string, unknown>`: see `LineEvent`.
121
100
  */
122
101
  export interface TypingIndicatorEvent extends WebhookEventBase {
123
102
  event_type: `typing_indicator.${string}`;
124
103
  data: Record<string, unknown> & WebhookPartnerMetadata;
125
104
  }
126
105
  export type TrialEventType = 'trial.linked' | 'trial.dormant' | 'trial.reactivated' | 'trial.bind_conflict' | 'trial.revoked';
127
- /** See `LineEvent` for why `data` is loose. */
106
+ /** `data` is typed as `Record<string, unknown>`: see `LineEvent`. */
128
107
  export interface TrialEvent extends WebhookEventBase {
129
108
  event_type: `trial.${string}`;
130
109
  data: Record<string, unknown> & WebhookPartnerMetadata;
131
110
  }
132
111
  export type PreOrderEventType = 'pre_order.fulfilled' | 'pre_order.cancelled';
133
112
  /**
134
- * Pre-order lifecycle events fired when ops procures hardware against a
135
- * customer pre-order. `pre_order.fulfilled` carries the freshly-activated
136
- * `line_id` so partner dashboards can wire it without a follow-up GET.
137
- * `data` is left loose for the same reason as `LineEvent` until the
138
- * per-event-type shapes are pinned in the contract.
113
+ * `pre_order.fulfilled` is sent when the line of a pre-order is handed over,
114
+ * and carries its `line_id`. `pre_order.cancelled` is sent when you cancel a
115
+ * draft pre-order. `data` is typed as `Record<string, unknown>`: see
116
+ * `LineEvent`.
139
117
  */
140
118
  export interface PreOrderEvent extends WebhookEventBase {
141
119
  event_type: `pre_order.${string}`;
@@ -143,20 +121,16 @@ export interface PreOrderEvent extends WebhookEventBase {
143
121
  }
144
122
  export type BindingEventType = 'binding.released';
145
123
  /**
146
- * Shared-plan contact-binding lifecycle (contract §4.3.7). Fires on the
147
- * VIRTUAL line when a `(virtual line, contact handle)` leg is torn down.
148
- * `data` carries `{ line_id, contact_handle, outbound_number (nullable),
149
- * released_at, reason: 'inactivity' | 'carrier_terminated' | 'reclaimed' |
150
- * 'moved' | 'owner_contact' }` — the
151
- * `outbound_number` being the physical line's number the contact knew,
152
- * since that association is exactly what the release severs.
124
+ * `binding.released` is sent when the pairing between a shared line and one
125
+ * contact ends. `data` carries `line_id` (the shared line), `contact_handle`,
126
+ * `outbound_number` (the number the contact saw, or `null`), `released_at`
127
+ * and `reason` (`inactivity`, `carrier_terminated`, `reclaimed`, `moved`,
128
+ * `owner_contact` or `pool_removed`). The list of reasons can grow: handle a
129
+ * value you do not know as a release. `pool_removed`, on an inbound-first
130
+ * line, means the number left the line's inbound pool.
153
131
  *
154
- * Left as `Record<string, unknown>` for the same reason as `LineEvent`:
155
- * `event_type` is the template literal `binding.${string}` so the guard
156
- * keeps prefix-matching, and a concrete `data` shape here would mistype
157
- * any future `binding.*` event. There is deliberately no
158
- * `binding.created` — the first outbound to a new contact already
159
- * signals it via `message.queued`.
132
+ * `data` is typed as `Record<string, unknown>`: see `LineEvent`. No event
133
+ * announces the start of a pairing.
160
134
  */
161
135
  export interface BindingEvent extends WebhookEventBase {
162
136
  event_type: `binding.${string}`;
@@ -164,57 +138,47 @@ export interface BindingEvent extends WebhookEventBase {
164
138
  }
165
139
  export type MacosSessionEventType = 'macos_session.rented' | 'macos_session.released';
166
140
  /**
167
- * Rented hosted macOS session lifecycle (contract §4.3.8). Fires on the
168
- * PARTNER, never on a line, and only for the two changes the partner did
169
- * NOT just cause — `rent`, `cancel` and `uncancel` are synchronous verbs
170
- * whose own response already told the caller what happened.
141
+ * Events about a hosted macOS session. `data` has no `line_id`, and a webhook
142
+ * subscription limited to `line_ids` does not receive them. `line_metadata` is
143
+ * your metadata on the line the session hosts (for `macos_session.released`,
144
+ * the line it hosted until then), and `null` when it hosts none of your lines.
145
+ * `rent`, `cancel` and `uncancel` send no event: their own result says what
146
+ * happened.
171
147
  *
172
- * `macos_session.rented` is iSnap attaching a session OUT OF BAND: the
173
- * fulfilment of a `rent` refused for want of stock, or the migration of a
174
- * tenancy that predates the surface. `data` carries
175
- * `{ macos_session_id, anniversary_at, rented_at }`.
148
+ * `macos_session.rented` is sent when iSnap assigns a session to your account
149
+ * outside your own `rent` call. `data` carries `macos_session_id`,
150
+ * `anniversary_at` and `rented_at`.
176
151
  *
177
- * `macos_session.released` is the seat going back to stock. `data` carries
178
- * `{ macos_session_id, anniversary_at (nullable), cancel_at (nullable),
179
- * released_at, reason: 'cancelled' | 'detached_by_admin' }` — `reason`
180
- * separating the cancellation coming due from an operator handing the
152
+ * `macos_session.released` is sent when the rental of a session ends. `data`
153
+ * carries `macos_session_id`, `anniversary_at` and `cancel_at` (both can be
154
+ * `null`), `released_at` and `reason`: `cancelled` when your scheduled
155
+ * cancellation was carried out, `detached_by_admin` when iSnap took the
181
156
  * session back.
182
157
  *
183
- * Routed by ACCOUNT, not by line: a rented session has no line by
184
- * construction, so there is no `line_id` on this payload.
185
- *
186
- * Left as `Record<string, unknown>` for the same reason as `LineEvent`:
187
- * `event_type` is the template literal `macos_session.${string}` so the
188
- * guard keeps prefix-matching, and a concrete `data` shape here would
189
- * mistype any future `macos_session.*` event.
158
+ * `data` is typed as `Record<string, unknown>`: see `LineEvent`.
190
159
  */
191
160
  export interface MacosSessionEvent extends WebhookEventBase {
192
161
  event_type: `macos_session.${string}`;
193
162
  data: Record<string, unknown> & WebhookPartnerMetadata;
194
163
  }
195
164
  /**
196
- * Administrative synthetic probe — the suspended-state health check that
197
- * decides whether a disabled subscription can be resumed. Not a partner
198
- * business event, but consumers do receive it, so it gets an alias and a
199
- * guard like every other family.
165
+ * `webhook.test` is the probe iSnap sends to a suspended webhook
166
+ * subscription. There is nothing to process: return a `2xx`.
200
167
  *
201
- * Named `Admin*` after the backend's `ADMIN_EVENTS` catalog constant
202
- * while the wire prefix is `webhook.` (and `isAdminEvent` matches that
203
- * prefix). The names deliberately differ: `WebhookEvent*` is already
204
- * taken by the union and the envelope base, so an accurate
205
- * `WebhookEventType` here would collide with both.
168
+ * The type is named `Admin*` while the event type starts with `webhook.`
169
+ * (which `isAdminEvent` matches), because `WebhookEvent` and
170
+ * `WebhookEventBase` already name the union and the common shape.
206
171
  */
207
172
  export type AdminEventType = 'webhook.test';
208
- /** See `LineEvent` for why `data` is loose. */
173
+ /** `data` is typed as `Record<string, unknown>`: see `LineEvent`. */
209
174
  export interface AdminEvent extends WebhookEventBase {
210
175
  event_type: `webhook.${string}`;
211
176
  data: Record<string, unknown> & WebhookPartnerMetadata;
212
177
  }
213
178
  /**
214
- * Discriminated union over the typed event families plus `WebhookEventBase`
215
- * as the catch-all for event types not yet known to this SDK version.
216
- * Use a type guard (`isMessageEvent`, `isReactionEvent`, ...) to narrow
217
- * inside an event handler:
179
+ * Union of the event families, plus `WebhookEventBase` for an event type this
180
+ * SDK version does not know. Narrow it with a type guard (`isMessageEvent`,
181
+ * `isReactionEvent` and the others) inside an event handler:
218
182
  *
219
183
  * ```ts
220
184
  * function handle(event: WebhookEvent) {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAErE;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,sBAAsB,CAAA;CACvD;AAED;;;;;;;;;;;;;;;;;GAiBG;AAIH,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IACxC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;CAC9C,CAAA;AA0BD,MAAM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,mBAAmB,GACnB,cAAc,GACd,mBAAmB,GACnB,gBAAgB,GAChB,kBAAkB,GAClB,cAAc,GACd,mBAAmB,GAMnB,4BAA4B,CAAA;AAEhC,MAAM,WAAW,YAAa,SAAQ,gBAAgB;IACpD,UAAU,EAAE,WAAW,MAAM,EAAE,CAAA;IAC/B,IAAI,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,sBAAsB,CAAA;CACpD;AAID,MAAM,MAAM,iBAAiB,GACzB,gBAAgB,GAChB,mBAAmB,GACnB,kBAAkB,CAAA;AAEtB,wEAAwE;AACxE,KAAK,qBAAqB,GAAG;IAC3B,iBAAiB,EAAE,MAAM,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rD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,YAAY,CAAC,CAAA;AAClD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAuB;IACpD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,KAAuB;IACzD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAA;AACtD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAuB;IAClD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;AAChD,CAAC"}
@@ -1,48 +1,46 @@
1
1
  import type { WebhookEventBase } from './types.js';
2
2
  export interface VerifyWebhookOptions {
3
3
  /**
4
- * Maximum drift in seconds between the request timestamp and the
5
- * verifier's clock. Defaults to 300 (5 minutes) per contract §4.4.
6
- * Set higher only if your server is reverse-proxied through a queue
7
- * that may stall messages.
4
+ * Largest accepted difference, in seconds, between `webhook-timestamp` and
5
+ * the verifier's clock, earlier or later. Default 300. It must
6
+ * be a finite number of 0 or more. `0` requires the same second: it does not
7
+ * turn the check off.
8
8
  */
9
9
  tolerance?: number;
10
10
  /**
11
- * Override the "now" clock — exposed primarily so tests can pin a
12
- * deterministic time. Returns unix seconds.
11
+ * Replace the clock with a function that returns the current time in Unix
12
+ * seconds. For tests that need a fixed time.
13
13
  */
14
14
  now?: () => number;
15
15
  }
16
16
  type WebhookHeaders = Record<string, string | string[] | undefined> | Headers;
17
17
  /**
18
- * Verify an incoming webhook delivery against its **Standard Webhooks**
19
- * signature (https://www.standardwebhooks.com): `webhook-id`,
20
- * `webhook-timestamp`, and `webhook-signature` carrying `v1,` + base64
21
- * `HMAC-SHA256(key, "<webhook-id>.<webhook-timestamp>.<rawBody>")`, where
22
- * the key is the base64 decoding of the secret without its `whsec_`
23
- * prefix. Pass the secret string exactly as the dashboard shows it.
18
+ * Verify a webhook delivery, then return the parsed event. Deliveries are
19
+ * signed according to Standard Webhooks (https://www.standardwebhooks.com).
20
+ * The function reads the `webhook-id`, `webhook-timestamp` and
21
+ * `webhook-signature` headers and checks `v1,` followed by the base64
22
+ * HMAC-SHA256 of `<webhook-id>.<webhook-timestamp>.<rawBody>`. The key is the
23
+ * base64 decoding of the secret without its `whsec_` prefix. Pass the secret
24
+ * exactly as the API returned it.
24
25
  *
25
- * This is the only scheme iSnap signs with. The former `X-iSnap-Signature`
26
- * / `X-iSnap-Timestamp` pair is no longer sent and no longer accepted: a
27
- * request that carries only those headers is rejected.
26
+ * `rawBody` is the request body exactly as received, as a string. A body that
27
+ * was parsed and serialized again fails verification.
28
28
  *
29
- * Throws `WebhookSignatureError` on missing headers, malformed
30
- * timestamp, expired timestamp (outside `tolerance`), or signature
31
- * mismatch. Returns the parsed event envelope on success.
29
+ * `headers` is a `Headers` object or a plain object, such as the
30
+ * `req.headers` of Node.js. Header names are case-insensitive.
32
31
  *
33
- * `secret` may be a single secret string OR an array — pass `[newSecret,
34
- * oldSecret]` during the 5-minute rotate-secret grace window so both
35
- * still validate. The verifier tries each in order and returns on the
36
- * first match.
32
+ * `secret` is one secret or an array of secrets: the delivery is accepted when
33
+ * any entry matches. After `webhooks.rotateSecret`, iSnap signs with the new
34
+ * secret only. Passing `[newSecret, oldSecret]` covers a request that was
35
+ * signed before the rotation and is still in transit.
37
36
  *
38
- * Headers may be a `Record<string, string>` (e.g. Express's `req.headers`)
39
- * or a `Headers` instance — both are read case-insensitively.
37
+ * Throws `WebhookSignatureError` when a header is missing, when the timestamp
38
+ * is malformed or outside `options.tolerance`, when no secret is given, when
39
+ * the signature matches no secret, and when the body is not a valid event.
40
+ * The `X-iSnap-Signature` and `X-iSnap-Timestamp` headers are not read.
40
41
  *
41
- * **Consumers MUST dedupe by `event.event_id`** (also sent as `webhook-id`)
42
- * — retries replay the same envelope (same `event_id`, same body,
43
- * refreshed timestamp and signature). Without consumer-side dedup, an
44
- * at-least-once delivery model produces duplicate side-effects on the
45
- * partner system.
42
+ * The function does not deduplicate. A retry or a replay carries the same
43
+ * `event_id`, also sent as `webhook-id`: deduplicate on `event_id`.
46
44
  */
47
45
  export declare function verifyWebhook(rawBody: string, headers: WebhookHeaders, secret: string | readonly string[], options?: VerifyWebhookOptions): WebhookEventBase;
48
46
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/webhooks/verify.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIlD,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AAED,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,OAAO,CAAA;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EAClC,OAAO,GAAE,oBAAyB,GACjC,gBAAgB,CA6ClB"}
1
+ {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/webhooks/verify.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIlD,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CACnB;AAED,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,GAAG,OAAO,CAAA;AAE7E;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,EAClC,OAAO,GAAE,oBAAyB,GACjC,gBAAgB,CAyClB"}
@@ -3,34 +3,32 @@ import { WebhookSignatureError } from '../errors.js';
3
3
  import { parseWebhookEvent } from './parse.js';
4
4
  const DEFAULT_TOLERANCE_SECONDS = 300;
5
5
  /**
6
- * Verify an incoming webhook delivery against its **Standard Webhooks**
7
- * signature (https://www.standardwebhooks.com): `webhook-id`,
8
- * `webhook-timestamp`, and `webhook-signature` carrying `v1,` + base64
9
- * `HMAC-SHA256(key, "<webhook-id>.<webhook-timestamp>.<rawBody>")`, where
10
- * the key is the base64 decoding of the secret without its `whsec_`
11
- * prefix. Pass the secret string exactly as the dashboard shows it.
6
+ * Verify a webhook delivery, then return the parsed event. Deliveries are
7
+ * signed according to Standard Webhooks (https://www.standardwebhooks.com).
8
+ * The function reads the `webhook-id`, `webhook-timestamp` and
9
+ * `webhook-signature` headers and checks `v1,` followed by the base64
10
+ * HMAC-SHA256 of `<webhook-id>.<webhook-timestamp>.<rawBody>`. The key is the
11
+ * base64 decoding of the secret without its `whsec_` prefix. Pass the secret
12
+ * exactly as the API returned it.
12
13
  *
13
- * This is the only scheme iSnap signs with. The former `X-iSnap-Signature`
14
- * / `X-iSnap-Timestamp` pair is no longer sent and no longer accepted: a
15
- * request that carries only those headers is rejected.
14
+ * `rawBody` is the request body exactly as received, as a string. A body that
15
+ * was parsed and serialized again fails verification.
16
16
  *
17
- * Throws `WebhookSignatureError` on missing headers, malformed
18
- * timestamp, expired timestamp (outside `tolerance`), or signature
19
- * mismatch. Returns the parsed event envelope on success.
17
+ * `headers` is a `Headers` object or a plain object, such as the
18
+ * `req.headers` of Node.js. Header names are case-insensitive.
20
19
  *
21
- * `secret` may be a single secret string OR an array — pass `[newSecret,
22
- * oldSecret]` during the 5-minute rotate-secret grace window so both
23
- * still validate. The verifier tries each in order and returns on the
24
- * first match.
20
+ * `secret` is one secret or an array of secrets: the delivery is accepted when
21
+ * any entry matches. After `webhooks.rotateSecret`, iSnap signs with the new
22
+ * secret only. Passing `[newSecret, oldSecret]` covers a request that was
23
+ * signed before the rotation and is still in transit.
25
24
  *
26
- * Headers may be a `Record<string, string>` (e.g. Express's `req.headers`)
27
- * or a `Headers` instance — both are read case-insensitively.
25
+ * Throws `WebhookSignatureError` when a header is missing, when the timestamp
26
+ * is malformed or outside `options.tolerance`, when no secret is given, when
27
+ * the signature matches no secret, and when the body is not a valid event.
28
+ * The `X-iSnap-Signature` and `X-iSnap-Timestamp` headers are not read.
28
29
  *
29
- * **Consumers MUST dedupe by `event.event_id`** (also sent as `webhook-id`)
30
- * — retries replay the same envelope (same `event_id`, same body,
31
- * refreshed timestamp and signature). Without consumer-side dedup, an
32
- * at-least-once delivery model produces duplicate side-effects on the
33
- * partner system.
30
+ * The function does not deduplicate. A retry or a replay carries the same
31
+ * `event_id`, also sent as `webhook-id`: deduplicate on `event_id`.
34
32
  */
35
33
  export function verifyWebhook(rawBody, headers, secret, options = {}) {
36
34
  const msgId = getHeader(headers, 'webhook-id');
@@ -58,13 +56,9 @@ export function verifyWebhook(rawBody, headers, secret, options = {}) {
58
56
  throw new WebhookSignatureError('webhook-signature carries no v1 signature');
59
57
  }
60
58
  const signedPayload = `${msgId}.${timestamp}.${rawBody}`;
61
- // Multi-secret loop returns early on first match — this is a minor
62
- // timing side-channel during the rotate-secret grace window (an
63
- // attacker who controls request timing could distinguish "matched first
64
- // candidate" from "matched second"). Practical exploit value is near
65
- // zero: knowing which secret matched does not help forge signatures
66
- // for either secret. Worth revisiting if real partners run rotation
67
- // through hostile networks.
59
+ // The loop over the secrets returns at the first match, so when several
60
+ // secrets are passed, timing can reveal which one matched. Knowing which
61
+ // secret matched does not help forge a signature for either.
68
62
  for (const candidate of candidates) {
69
63
  const expected = createHmac('sha256', standardWebhookKey(candidate))
70
64
  .update(signedPayload)
@@ -78,15 +72,15 @@ export function verifyWebhook(rawBody, headers, secret, options = {}) {
78
72
  throw new WebhookSignatureError('Webhook signature did not match any provided secret');
79
73
  }
80
74
  // The Standard Webhooks key: the base64 decoding of the secret without its
81
- // `whsec_` prefix — what every official Standard Webhooks library derives
82
- // from the same string. iSnap secrets are `whsec_` followed by hex, which is
83
- // valid base64, so the dashboard string works as-is here and there.
75
+ // `whsec_` prefix. An iSnap secret is `whsec_` followed by hexadecimal
76
+ // characters, which are valid base64, so the secret is passed as the API
77
+ // returned it.
84
78
  function standardWebhookKey(secret) {
85
79
  const encoded = secret.startsWith('whsec_') ? secret.slice('whsec_'.length) : secret;
86
80
  return Buffer.from(encoded, 'base64');
87
81
  }
88
82
  function checkTimestamp(tsHeader, headerName, options) {
89
- // Strict integer-only check — `Number.parseInt` would happily accept
83
+ // Strict integer-only check: `Number.parseInt` would happily accept
90
84
  // `"1714478400foo"` and silently truncate. The HMAC compare downstream
91
85
  // catches the resulting payload mismatch, but rejecting earlier here
92
86
  // surfaces a clearer error and avoids one unnecessary HMAC computation.
@@ -98,7 +92,7 @@ function checkTimestamp(tsHeader, headerName, options) {
98
92
  throw new WebhookSignatureError(`Malformed ${headerName}: ${tsHeader}`);
99
93
  }
100
94
  const tolerance = options.tolerance ?? DEFAULT_TOLERANCE_SECONDS;
101
- // Validate before use — `Math.abs(...) > NaN` is always false (so the
95
+ // Validate before use: `Math.abs(...) > NaN` is always false (so the
102
96
  // replay-window check would silently pass), `Math.abs(...) > -1` is
103
97
  // always true (every timestamp rejected), and `Infinity` makes every
104
98
  // timestamp pass. Reject the bad inputs explicitly so misuse fails
@@ -1 +1 @@
1
- {"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/webhooks/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EA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