@isnap/sdk 2.3.0 → 2.3.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/CHANGELOG.md +65 -40
- package/README.md +360 -167
- package/dist/client.d.ts +35 -49
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +44 -58
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +6 -6
- package/dist/config.js +6 -6
- package/dist/generated/openapi.d.ts +403 -14
- package/dist/internal/sleep.d.ts +2 -2
- package/dist/internal/sleep.js +5 -5
- package/dist/internal/sleep.js.map +1 -1
- package/dist/resources/apps.d.ts +11 -18
- package/dist/resources/apps.d.ts.map +1 -1
- package/dist/resources/apps.js +11 -18
- package/dist/resources/apps.js.map +1 -1
- package/dist/resources/area-codes.d.ts +5 -6
- package/dist/resources/area-codes.d.ts.map +1 -1
- package/dist/resources/area-codes.js +5 -6
- package/dist/resources/area-codes.js.map +1 -1
- package/dist/resources/attachments.d.ts +51 -17
- package/dist/resources/attachments.d.ts.map +1 -1
- package/dist/resources/attachments.js +42 -22
- package/dist/resources/attachments.js.map +1 -1
- package/dist/resources/byod.d.ts +14 -4
- package/dist/resources/byod.d.ts.map +1 -1
- package/dist/resources/byod.js +14 -4
- package/dist/resources/byod.js.map +1 -1
- package/dist/resources/chats.d.ts +30 -22
- package/dist/resources/chats.d.ts.map +1 -1
- package/dist/resources/chats.js +29 -21
- package/dist/resources/chats.js.map +1 -1
- package/dist/resources/lines.d.ts +240 -266
- package/dist/resources/lines.d.ts.map +1 -1
- package/dist/resources/lines.js +240 -266
- package/dist/resources/lines.js.map +1 -1
- package/dist/resources/lookup.d.ts +10 -13
- package/dist/resources/lookup.d.ts.map +1 -1
- package/dist/resources/lookup.js +10 -13
- package/dist/resources/lookup.js.map +1 -1
- package/dist/resources/macos-sessions.d.ts +42 -36
- package/dist/resources/macos-sessions.d.ts.map +1 -1
- package/dist/resources/macos-sessions.js +24 -22
- package/dist/resources/macos-sessions.js.map +1 -1
- package/dist/resources/messages.d.ts +35 -25
- package/dist/resources/messages.d.ts.map +1 -1
- package/dist/resources/messages.js +30 -19
- package/dist/resources/messages.js.map +1 -1
- package/dist/resources/preorders.d.ts +42 -47
- package/dist/resources/preorders.d.ts.map +1 -1
- package/dist/resources/preorders.js +42 -47
- package/dist/resources/preorders.js.map +1 -1
- package/dist/resources/trial.d.ts +30 -21
- package/dist/resources/trial.d.ts.map +1 -1
- package/dist/resources/trial.js +30 -21
- package/dist/resources/trial.js.map +1 -1
- package/dist/resources/webhooks.d.ts +39 -22
- package/dist/resources/webhooks.d.ts.map +1 -1
- package/dist/resources/webhooks.js +39 -22
- package/dist/resources/webhooks.js.map +1 -1
- package/dist/retry.d.ts +9 -10
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +11 -12
- package/dist/retry.js.map +1 -1
- package/dist/types.d.ts +10 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +13 -37
- package/dist/version.js.map +1 -1
- package/dist/webhooks/parse.d.ts +10 -9
- package/dist/webhooks/parse.d.ts.map +1 -1
- package/dist/webhooks/parse.js +14 -13
- package/dist/webhooks/parse.js.map +1 -1
- package/dist/webhooks/types.d.ts +74 -110
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/webhooks/types.js.map +1 -1
- package/dist/webhooks/verify.d.ts +27 -29
- package/dist/webhooks/verify.d.ts.map +1 -1
- package/dist/webhooks/verify.js +29 -35
- package/dist/webhooks/verify.js.map +1 -1
- package/examples/handle-webhook.ts +146 -0
- package/examples/paginate-messages.ts +54 -0
- package/examples/send-message.ts +37 -0
- package/examples/upload-attachment.ts +91 -0
- package/package.json +4 -8
package/dist/webhooks/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Message, ReactionType } from '../resources/messages.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
|
18
|
-
*
|
|
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
|
|
22
|
-
* `line.*`, the message for `message.*`, the reacted
|
|
23
|
-
* `reaction.*`, the
|
|
24
|
-
* `trial.*`, the pre-order for `pre_order.*`. Always `null` for
|
|
25
|
-
* `typing_indicator.*`, `binding.*` and `webhook
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
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
|
|
32
|
-
* carries the
|
|
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.*`
|
|
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`
|
|
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
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* the
|
|
75
|
-
*
|
|
76
|
-
*
|
|
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
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
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`
|
|
85
|
-
*
|
|
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';
|
|
@@ -101,13 +83,11 @@ export interface ReactionEvent extends WebhookEventBase {
|
|
|
101
83
|
}
|
|
102
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';
|
|
103
85
|
/**
|
|
104
|
-
* `data` is
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
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
|
-
*
|
|
119
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* `
|
|
137
|
-
* `
|
|
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
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* `
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
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
|
-
*
|
|
155
|
-
*
|
|
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
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
-
*
|
|
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
|
|
173
|
-
*
|
|
174
|
-
*
|
|
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
|
|
178
|
-
* `
|
|
179
|
-
*
|
|
180
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
197
|
-
*
|
|
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
|
-
*
|
|
202
|
-
*
|
|
203
|
-
*
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
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,CA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AAsB,CAAA;CACvD;AAID;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,YAAY,GACpB,YAAY,GACZ,aAAa,GACb,SAAS,GACT,oBAAoB,GACpB,UAAU,GACV,aAAa,GACb,YAAY,GACZ,iBAAiB,GACjB,UAAU,GACV,gBAAgB,CAAA;AAIpB,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,YAAY,CAE7E;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,aAAa,CAE/E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,SAAS,CAEvE;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,gBAAgB,GACtB,KAAK,IAAI,oBAAoB,CAE/B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,UAAU,CAEzE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,aAAa,CAE/E;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,YAAY,CAE7E;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,iBAAiB,CAEvF;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,gBAAgB,GAAG,KAAK,IAAI,UAAU,CAEzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/webhooks/types.ts"],"names":[],"mappings":"AAyUA,6EAA6E;AAE7E,MAAM,UAAU,cAAc,CAAC,KAAuB;IACpD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAuB;IACrD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;AACjD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,KAAuB;IACjD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;AAC7C,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,KAAuB;IAEvB,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAAA;AACzD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAuB;IAClD,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;AAC9C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAuB;IACrD,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
|
-
*
|
|
5
|
-
* verifier's clock
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
-
*
|
|
12
|
-
*
|
|
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
|
|
19
|
-
*
|
|
20
|
-
* `webhook-
|
|
21
|
-
* `
|
|
22
|
-
*
|
|
23
|
-
*
|
|
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
|
-
*
|
|
26
|
-
*
|
|
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
|
-
*
|
|
30
|
-
*
|
|
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`
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
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
|
-
*
|
|
39
|
-
* or
|
|
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
|
-
*
|
|
42
|
-
*
|
|
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
|
|
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"}
|
package/dist/webhooks/verify.js
CHANGED
|
@@ -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
|
|
7
|
-
*
|
|
8
|
-
* `webhook-
|
|
9
|
-
* `
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
|
-
*
|
|
14
|
-
*
|
|
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
|
-
*
|
|
18
|
-
*
|
|
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`
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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
|
-
*
|
|
27
|
-
* or
|
|
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
|
-
*
|
|
30
|
-
*
|
|
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
|
-
//
|
|
62
|
-
// timing
|
|
63
|
-
//
|
|
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
|
|
82
|
-
//
|
|
83
|
-
//
|
|
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
|
|
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
|
|
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,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAG9C,MAAM,yBAAyB,GAAG,GAAG,CAAA;AAmBrC
|
|
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,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAG9C,MAAM,yBAAyB,GAAG,GAAG,CAAA;AAmBrC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAe,EACf,OAAuB,EACvB,MAAkC,EAClC,UAAgC,EAAE;IAElC,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;IAC9C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,qBAAqB,CAAC,2BAA2B,CAAC,CAAA;IAC9D,CAAC;IACD,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAA;IACxD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,qBAAqB,CAAC,kCAAkC,CAAC,CAAA;IACrE,CAAC;IACD,MAAM,SAAS,GAAG,SAAS,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAA;IACzD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,qBAAqB,CAAC,k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