@mxraven/mail 0.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/LICENSE +201 -0
- package/README.md +215 -0
- package/dist/feedback/index.cjs +246 -0
- package/dist/feedback/index.cjs.map +1 -0
- package/dist/feedback/index.d.cts +149 -0
- package/dist/feedback/index.d.cts.map +1 -0
- package/dist/feedback/index.d.ts +149 -0
- package/dist/feedback/index.d.ts.map +1 -0
- package/dist/feedback/index.js +243 -0
- package/dist/feedback/index.js.map +1 -0
- package/dist/index.cjs +2708 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +323 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +323 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2703 -0
- package/dist/index.js.map +1 -0
- package/dist/webhook/index.cjs +417 -0
- package/dist/webhook/index.cjs.map +1 -0
- package/dist/webhook/index.d.cts +411 -0
- package/dist/webhook/index.d.cts.map +1 -0
- package/dist/webhook/index.d.ts +411 -0
- package/dist/webhook/index.d.ts.map +1 -0
- package/dist/webhook/index.js +409 -0
- package/dist/webhook/index.js.map +1 -0
- package/package.json +101 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
//#region src/webhook/payload.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* mxRaven webhook payload shapes.
|
|
4
|
+
*/
|
|
5
|
+
/** Identifies the shape of a decoded webhook payload. */
|
|
6
|
+
export declare const eventType: {
|
|
7
|
+
/** A `DELIVER_WEBHOOK` delivery carrying a complete inbound message. */
|
|
8
|
+
readonly inboundEmail: "inbound_email";
|
|
9
|
+
/** A `NOTIFY_WEBHOOK` delivery carrying the status of an object-storage write. */
|
|
10
|
+
readonly storageStatus: "s3_egress_status";
|
|
11
|
+
/**
|
|
12
|
+
* A `NOTIFY_WEBHOOK` delivery carrying the status of an SMTP delivery.
|
|
13
|
+
*
|
|
14
|
+
* The SMTP producer does not send an `event_type` field, so this value is
|
|
15
|
+
* assigned by {@link decode}.
|
|
16
|
+
*/
|
|
17
|
+
readonly deliveryStatus: "delivery_status";
|
|
18
|
+
};
|
|
19
|
+
/** Identifies the shape of a decoded webhook payload. */
|
|
20
|
+
type EventType = (typeof eventType)[keyof typeof eventType];
|
|
21
|
+
/** The lifecycle state reported by a delivery-status webhook. */
|
|
22
|
+
export declare const statusOutcome: {
|
|
23
|
+
/** A delivery attempt started. */
|
|
24
|
+
readonly attempted: "attempted";
|
|
25
|
+
/** The destination accepted the message. */
|
|
26
|
+
readonly delivered: "delivered";
|
|
27
|
+
/** The destination temporarily rejected the message. */
|
|
28
|
+
readonly deferred: "deferred";
|
|
29
|
+
/** Delivery failed permanently. */
|
|
30
|
+
readonly failed: "failed";
|
|
31
|
+
/** The delivery deadline passed before success. */
|
|
32
|
+
readonly expired: "expired";
|
|
33
|
+
/** Delivery was skipped by a suppression rule. It is reported for SMTP deliveries only. */
|
|
34
|
+
readonly suppressed: "suppressed";
|
|
35
|
+
};
|
|
36
|
+
/** The lifecycle state reported by a delivery-status webhook. */
|
|
37
|
+
type StatusOutcome = (typeof statusOutcome)[keyof typeof statusOutcome];
|
|
38
|
+
/**
|
|
39
|
+
* The final routing action recorded for an inbound message.
|
|
40
|
+
*
|
|
41
|
+
* Values are the mxRaven worker enum names.
|
|
42
|
+
*/
|
|
43
|
+
export declare const terminalAction: {
|
|
44
|
+
/** Deliver through a dedicated IP pool. */
|
|
45
|
+
readonly deliverDedicated: "TERMINAL_ACTION_TYPE_DELIVER_DEDICATED";
|
|
46
|
+
/** Relay through the configured smarthost. */
|
|
47
|
+
readonly smarthostRelay: "TERMINAL_ACTION_TYPE_SMARTHOST_RELAY";
|
|
48
|
+
/** Deliver to a webhook endpoint. */
|
|
49
|
+
readonly deliverWebhook: "TERMINAL_ACTION_TYPE_DELIVER_WEBHOOK";
|
|
50
|
+
/** Forward the message to an SMTP destination. */
|
|
51
|
+
readonly smtpForward: "TERMINAL_ACTION_TYPE_SMTP_FORWARD";
|
|
52
|
+
/** Relay the message to another MX. */
|
|
53
|
+
readonly relay: "TERMINAL_ACTION_TYPE_RELAY";
|
|
54
|
+
/** Store the message in object storage. */
|
|
55
|
+
readonly s3Store: "TERMINAL_ACTION_TYPE_S3_STORE";
|
|
56
|
+
/** Send an automatic reply. */
|
|
57
|
+
readonly autoReply: "TERMINAL_ACTION_TYPE_AUTO_REPLY";
|
|
58
|
+
/** Accept and discard the message. */
|
|
59
|
+
readonly drop: "TERMINAL_ACTION_TYPE_DROP";
|
|
60
|
+
/** Reject the message. */
|
|
61
|
+
readonly reject: "TERMINAL_ACTION_TYPE_REJECT";
|
|
62
|
+
/** Deliver the message normally. */
|
|
63
|
+
readonly deliver: "TERMINAL_ACTION_TYPE_DELIVER";
|
|
64
|
+
/** Handle a DSN at an SRS return address. */
|
|
65
|
+
readonly srsReturn: "TERMINAL_ACTION_TYPE_SRS_RETURN";
|
|
66
|
+
/** Generate a local DSN. */
|
|
67
|
+
readonly localDsn: "TERMINAL_ACTION_TYPE_LOCAL_DSN";
|
|
68
|
+
};
|
|
69
|
+
/** The final routing action recorded for an inbound message. */
|
|
70
|
+
type TerminalAction = (typeof terminalAction)[keyof typeof terminalAction];
|
|
71
|
+
/** A decoded webhook delivery. */
|
|
72
|
+
type Event = {
|
|
73
|
+
readonly type: typeof eventType.inboundEmail;
|
|
74
|
+
readonly inboundEmail: InboundEmail;
|
|
75
|
+
} | {
|
|
76
|
+
readonly type: typeof eventType.deliveryStatus;
|
|
77
|
+
readonly deliveryStatus: DeliveryStatus;
|
|
78
|
+
} | {
|
|
79
|
+
readonly type: typeof eventType.storageStatus;
|
|
80
|
+
readonly storageStatus: StorageStatus;
|
|
81
|
+
};
|
|
82
|
+
/** The final routing outcome for an inbound message. */
|
|
83
|
+
interface RoutingDecision {
|
|
84
|
+
/** The final terminal action. Values are the mxRaven worker enum names. */
|
|
85
|
+
readonly terminal_action: TerminalAction;
|
|
86
|
+
/** The rule that selected the terminal action, when one matched. */
|
|
87
|
+
readonly matched_rule_id?: string;
|
|
88
|
+
/** Whether the listener default was used because no rule produced a terminal action. */
|
|
89
|
+
readonly used_listener_default: boolean;
|
|
90
|
+
}
|
|
91
|
+
/** Spam and malware scan results. */
|
|
92
|
+
interface Verdicts {
|
|
93
|
+
/** The scanner action description. */
|
|
94
|
+
readonly action: string;
|
|
95
|
+
/** The spam score that was assigned. */
|
|
96
|
+
readonly score: number;
|
|
97
|
+
/** The threshold the message was compared against. */
|
|
98
|
+
readonly required_score: number;
|
|
99
|
+
/** Whether the message was classified as spam. */
|
|
100
|
+
readonly is_spam: boolean;
|
|
101
|
+
/** Whether malware was detected. */
|
|
102
|
+
readonly has_malware: boolean;
|
|
103
|
+
/** The detected malware signatures. */
|
|
104
|
+
readonly malware_names: readonly string[];
|
|
105
|
+
/** Whether scanning was skipped. */
|
|
106
|
+
readonly is_skipped: boolean;
|
|
107
|
+
/** The scanner error, when scanning failed. */
|
|
108
|
+
readonly error: string;
|
|
109
|
+
}
|
|
110
|
+
/** The SMTP envelope of a message. */
|
|
111
|
+
interface WebhookEnvelope {
|
|
112
|
+
/** The envelope sender. It may be empty for a null reverse-path. */
|
|
113
|
+
readonly mail_from: string;
|
|
114
|
+
/** The envelope recipients. */
|
|
115
|
+
readonly rcpt_to: readonly string[];
|
|
116
|
+
}
|
|
117
|
+
/** A summary of the parsed message headers. */
|
|
118
|
+
interface MessageSummary {
|
|
119
|
+
/** The decoded Subject header. */
|
|
120
|
+
readonly subject?: string;
|
|
121
|
+
/** The decoded From mailboxes. */
|
|
122
|
+
readonly from?: readonly string[];
|
|
123
|
+
/** The decoded To mailboxes. */
|
|
124
|
+
readonly to?: readonly string[];
|
|
125
|
+
/** The decoded Cc mailboxes. */
|
|
126
|
+
readonly cc?: readonly string[];
|
|
127
|
+
/** The Message-ID header. */
|
|
128
|
+
readonly message_id?: string;
|
|
129
|
+
/** The raw Date header. */
|
|
130
|
+
readonly date?: string;
|
|
131
|
+
}
|
|
132
|
+
/** One message header occurrence. */
|
|
133
|
+
interface HeaderField {
|
|
134
|
+
/** The header field name. */
|
|
135
|
+
readonly name: string;
|
|
136
|
+
/** The header field value. */
|
|
137
|
+
readonly value: string;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Time-limited access to the raw RFC 822 message.
|
|
141
|
+
*
|
|
142
|
+
* Use {@link fetchRawEmail} to download the content.
|
|
143
|
+
*/
|
|
144
|
+
interface RawEmail {
|
|
145
|
+
/** The message download URL. */
|
|
146
|
+
readonly url: string;
|
|
147
|
+
/** The authorization scheme, normally `Bearer`. */
|
|
148
|
+
readonly token_type?: string;
|
|
149
|
+
/** The bearer token for the download URL. Treat it as a secret and do not log it. */
|
|
150
|
+
readonly access_token: string;
|
|
151
|
+
/** The Unix time, in seconds, when the token expires. */
|
|
152
|
+
readonly expires_at_utc?: number;
|
|
153
|
+
/** The raw message size. */
|
|
154
|
+
readonly size_bytes?: number;
|
|
155
|
+
/** The lowercase hex SHA-256 of the raw message bytes. */
|
|
156
|
+
readonly sha256_hex?: string;
|
|
157
|
+
/** The parsed message media type. */
|
|
158
|
+
readonly content_type?: string;
|
|
159
|
+
}
|
|
160
|
+
/** The `DELIVER_WEBHOOK` payload. */
|
|
161
|
+
interface InboundEmail {
|
|
162
|
+
/** Always `inbound_email`. */
|
|
163
|
+
readonly event_type: string;
|
|
164
|
+
/** The delivery task identifier, stable across retries. */
|
|
165
|
+
readonly task_id: string;
|
|
166
|
+
/** The owning tenant. */
|
|
167
|
+
readonly tenant_id: string;
|
|
168
|
+
/** The listener that accepted the message. */
|
|
169
|
+
readonly listener_id: string;
|
|
170
|
+
/** The delivery attempt number, starting at 1. */
|
|
171
|
+
readonly attempt: number;
|
|
172
|
+
/** The Unix time, in seconds, when mxRaven accepted the message. */
|
|
173
|
+
readonly accepted_at_utc: number;
|
|
174
|
+
/** The Unix time, in seconds, when this delivery was built. */
|
|
175
|
+
readonly occurred_at_utc: number;
|
|
176
|
+
/** The final routing outcome. */
|
|
177
|
+
readonly routing_decision: RoutingDecision;
|
|
178
|
+
/** The spam and malware scan results, when scanning ran. */
|
|
179
|
+
readonly verdicts?: Verdicts;
|
|
180
|
+
/** The SMTP envelope. */
|
|
181
|
+
readonly envelope: WebhookEnvelope;
|
|
182
|
+
/** The parsed message header summary. */
|
|
183
|
+
readonly message: MessageSummary;
|
|
184
|
+
/** Every message header in the order received. */
|
|
185
|
+
readonly headers: readonly HeaderField[];
|
|
186
|
+
/** Time-limited access to the raw RFC 822 message. */
|
|
187
|
+
readonly raw_email: RawEmail;
|
|
188
|
+
}
|
|
189
|
+
/** The SMTP `NOTIFY_WEBHOOK` payload. */
|
|
190
|
+
interface DeliveryStatus {
|
|
191
|
+
/** The delivery task identifier, stable across attempts. */
|
|
192
|
+
readonly task_id: string;
|
|
193
|
+
/** The owning tenant. */
|
|
194
|
+
readonly tenant_id: string;
|
|
195
|
+
/** The source listener. */
|
|
196
|
+
readonly listener_id: string;
|
|
197
|
+
/** The delivery outcome. */
|
|
198
|
+
readonly status: StatusOutcome;
|
|
199
|
+
/** The delivery attempt number, starting at 1. */
|
|
200
|
+
readonly attempt: number;
|
|
201
|
+
/** The Unix time, in seconds, when mxRaven accepted the message. */
|
|
202
|
+
readonly accepted_at_utc: number;
|
|
203
|
+
/** The Unix time, in seconds, when this status was built. */
|
|
204
|
+
readonly occurred_at_utc: number;
|
|
205
|
+
/** The egress source address, when known. */
|
|
206
|
+
readonly source_ip?: string;
|
|
207
|
+
/** The recipient domain. */
|
|
208
|
+
readonly destination_domain?: string;
|
|
209
|
+
/** The remote MTA hostname, when known. */
|
|
210
|
+
readonly remote_host?: string;
|
|
211
|
+
/** The remote SMTP reply code. */
|
|
212
|
+
readonly smtp_code?: number;
|
|
213
|
+
/** The RFC 3463 enhanced status code. */
|
|
214
|
+
readonly enhanced_status_code?: string;
|
|
215
|
+
/** The remote reply text, truncated to 512 bytes. */
|
|
216
|
+
readonly remote_response?: string;
|
|
217
|
+
/** The Unix time, in seconds, of the next attempt for a deferred status. */
|
|
218
|
+
readonly next_retry_at_utc?: number;
|
|
219
|
+
/** Links a generated DSN back to its original task. */
|
|
220
|
+
readonly correlation_task_id?: string;
|
|
221
|
+
}
|
|
222
|
+
/** The object-storage `NOTIFY_WEBHOOK` payload. */
|
|
223
|
+
interface StorageStatus {
|
|
224
|
+
/** Always `s3_egress_status`. */
|
|
225
|
+
readonly event_type: string;
|
|
226
|
+
/** The storage task identifier. */
|
|
227
|
+
readonly task_id?: string;
|
|
228
|
+
/** The owning tenant. */
|
|
229
|
+
readonly tenant_id?: string;
|
|
230
|
+
/** The source listener. */
|
|
231
|
+
readonly listener_id?: string;
|
|
232
|
+
/** The storage outcome. */
|
|
233
|
+
readonly status: StatusOutcome;
|
|
234
|
+
/** The delivery attempt number, starting at 1. */
|
|
235
|
+
readonly attempt: number;
|
|
236
|
+
/** The Unix time, in seconds, when mxRaven accepted the message. */
|
|
237
|
+
readonly accepted_at_utc?: number;
|
|
238
|
+
/** The Unix time, in seconds, when this status was built. */
|
|
239
|
+
readonly occurred_at_utc: number;
|
|
240
|
+
/** The storage integration identifier. */
|
|
241
|
+
readonly storage_ref?: string;
|
|
242
|
+
/** The destination bucket. */
|
|
243
|
+
readonly bucket_name?: string;
|
|
244
|
+
/** The stored object key. */
|
|
245
|
+
readonly object_key?: string;
|
|
246
|
+
/** The storage endpoint host. */
|
|
247
|
+
readonly endpoint_host?: string;
|
|
248
|
+
/** The storage provider response status. */
|
|
249
|
+
readonly status_code?: number;
|
|
250
|
+
/** The storage provider error code. */
|
|
251
|
+
readonly error_code?: string;
|
|
252
|
+
/** The failure description, truncated to 512 bytes. */
|
|
253
|
+
readonly message?: string;
|
|
254
|
+
/** The Unix time, in seconds, of the next attempt for a deferred status. */
|
|
255
|
+
readonly next_retry_at_utc?: number;
|
|
256
|
+
}
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/webhook/decode.d.ts
|
|
259
|
+
/**
|
|
260
|
+
* Decodes a webhook payload.
|
|
261
|
+
*
|
|
262
|
+
* Dispatching is based on the payload's `event_type` field. SMTP delivery
|
|
263
|
+
* statuses do not carry an `event_type`, so a body with a `status` field and no
|
|
264
|
+
* recognized event type is decoded as a delivery status.
|
|
265
|
+
*
|
|
266
|
+
* @param body - The raw JSON payload bytes, or a decoded string.
|
|
267
|
+
* @returns The decoded event.
|
|
268
|
+
* @throws `Error` When the body is not valid JSON or the payload is
|
|
269
|
+
* unrecognized.
|
|
270
|
+
*
|
|
271
|
+
* @public
|
|
272
|
+
*/
|
|
273
|
+
export declare function decode(body: Uint8Array | string): Event;
|
|
274
|
+
//#endregion
|
|
275
|
+
//#region src/webhook/errors.d.ts
|
|
276
|
+
/**
|
|
277
|
+
* A webhook signature did not match the request.
|
|
278
|
+
*
|
|
279
|
+
* @public
|
|
280
|
+
*/
|
|
281
|
+
export declare class InvalidSignatureError extends Error {
|
|
282
|
+
/**
|
|
283
|
+
* @param message - A human-readable description.
|
|
284
|
+
*/
|
|
285
|
+
constructor(message?: string);
|
|
286
|
+
}
|
|
287
|
+
//#endregion
|
|
288
|
+
//#region src/webhook/raw.d.ts
|
|
289
|
+
/** A minimal `fetch`-compatible function. @public */
|
|
290
|
+
type FetchLike = (url: string, init?: RequestInit) => Promise<Response>;
|
|
291
|
+
/** Options for {@link fetchRawEmail}. */
|
|
292
|
+
interface FetchRawEmailOptions {
|
|
293
|
+
/** Cancels the download. */
|
|
294
|
+
readonly signal?: AbortSignal;
|
|
295
|
+
/** The `fetch` implementation to use. Defaults to the global `fetch`. */
|
|
296
|
+
readonly fetch?: FetchLike;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Downloads the raw RFC 822 message referenced by a `DELIVER_WEBHOOK` payload.
|
|
300
|
+
*
|
|
301
|
+
* The payload's short-lived bearer token is sent in the `Authorization` header,
|
|
302
|
+
* and the downloaded bytes are verified against the declared size and SHA-256
|
|
303
|
+
* digest. Treat `raw_email.access_token` as a secret and do not log it.
|
|
304
|
+
*
|
|
305
|
+
* @param raw - The `raw_email` object from an inbound-email payload.
|
|
306
|
+
* @param options - An optional cancellation signal and `fetch` implementation.
|
|
307
|
+
* @returns The exact message bytes.
|
|
308
|
+
* @throws `Error` When the URL or token is empty, the response is unsuccessful,
|
|
309
|
+
* or the downloaded bytes fail the size or digest check.
|
|
310
|
+
*
|
|
311
|
+
* @example
|
|
312
|
+
* ```ts
|
|
313
|
+
* const bytes = await fetchRawEmail(event.inboundEmail.rawEmail, { signal });
|
|
314
|
+
* ```
|
|
315
|
+
*
|
|
316
|
+
* @public
|
|
317
|
+
*/
|
|
318
|
+
export declare function fetchRawEmail(raw: RawEmail, options?: FetchRawEmailOptions): Promise<Uint8Array>;
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/webhook/verifier.d.ts
|
|
321
|
+
/**
|
|
322
|
+
* The mxRaven signature headers.
|
|
323
|
+
*
|
|
324
|
+
* HTTP header names are case-insensitive; these constants carry the canonical
|
|
325
|
+
* spelling used by mxRaven.
|
|
326
|
+
*/
|
|
327
|
+
export declare const webhookHeaders: {
|
|
328
|
+
/** The delivery ID, which is the delivery task ID. */
|
|
329
|
+
readonly webhookId: "X-MxRaven-Webhook-ID";
|
|
330
|
+
/** The Unix signing time in seconds. */
|
|
331
|
+
readonly timestamp: "X-MxRaven-Timestamp";
|
|
332
|
+
/** The `sha256=<hex>` HMAC. */
|
|
333
|
+
readonly signature: "X-MxRaven-Signature";
|
|
334
|
+
/** The signing key ID. */
|
|
335
|
+
readonly signatureKid: "X-MxRaven-Signature-Kid";
|
|
336
|
+
};
|
|
337
|
+
/** Options for a {@link Verifier}. */
|
|
338
|
+
interface VerifierOptions {
|
|
339
|
+
/** The signing secret, used as literal bytes and not decoded. */
|
|
340
|
+
readonly secret?: string;
|
|
341
|
+
/** Per-key secrets for key rotation, keyed by signing key ID. */
|
|
342
|
+
readonly keys?: ReadonlyMap<string, string>;
|
|
343
|
+
/** The maximum accepted clock skew in milliseconds. Defaults to 5 minutes; `0` disables the check. */
|
|
344
|
+
readonly tolerance?: number;
|
|
345
|
+
/** The maximum request body size in bytes. Defaults to 1 MiB. */
|
|
346
|
+
readonly maxBodyBytes?: number;
|
|
347
|
+
}
|
|
348
|
+
/** Per-call options for verification. */
|
|
349
|
+
interface VerifyOptions {
|
|
350
|
+
/** Cancels the body read. */
|
|
351
|
+
readonly signal?: AbortSignal;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Verifies the signature of an mxRaven webhook request.
|
|
355
|
+
*
|
|
356
|
+
* A verifier is safe for concurrent use once constructed. Configure it with a
|
|
357
|
+
* signing secret or with per-key secrets for rotation.
|
|
358
|
+
*
|
|
359
|
+
* @example
|
|
360
|
+
* ```ts
|
|
361
|
+
* const secret = process.env.MXRAVEN_WEBHOOK_SECRET;
|
|
362
|
+
* if (secret === undefined || secret === "") {
|
|
363
|
+
* throw new Error("MXRAVEN_WEBHOOK_SECRET is required");
|
|
364
|
+
* }
|
|
365
|
+
*
|
|
366
|
+
* const verifier = new Verifier({ secret });
|
|
367
|
+
* const event = await verifier.verifyAndDecode(request);
|
|
368
|
+
* ```
|
|
369
|
+
*
|
|
370
|
+
* @public
|
|
371
|
+
*/
|
|
372
|
+
export declare class Verifier {
|
|
373
|
+
private readonly secret;
|
|
374
|
+
private readonly keys;
|
|
375
|
+
private readonly tolerance;
|
|
376
|
+
private readonly maxBodyBytes;
|
|
377
|
+
/**
|
|
378
|
+
* @param options - The signing secret and verification limits.
|
|
379
|
+
* @throws `Error` When no secret is provided or an option is invalid.
|
|
380
|
+
*/
|
|
381
|
+
constructor(options?: VerifierOptions);
|
|
382
|
+
/**
|
|
383
|
+
* Verifies a request's signature.
|
|
384
|
+
*
|
|
385
|
+
* The body is read from a clone, so the caller can still read the original
|
|
386
|
+
* request body afterwards.
|
|
387
|
+
*
|
|
388
|
+
* @param request - The incoming request.
|
|
389
|
+
* @param options - An optional cancellation signal.
|
|
390
|
+
* @throws {@link InvalidSignatureError} When the signature does not match.
|
|
391
|
+
* @throws `Error` When required headers are missing, the timestamp is stale,
|
|
392
|
+
* or the body exceeds the configured limit.
|
|
393
|
+
*/
|
|
394
|
+
verify(request: Request, options?: VerifyOptions): Promise<void>;
|
|
395
|
+
/**
|
|
396
|
+
* Verifies a request and decodes its payload.
|
|
397
|
+
*
|
|
398
|
+
* @param request - The incoming request.
|
|
399
|
+
* @param options - An optional cancellation signal.
|
|
400
|
+
* @returns The decoded event.
|
|
401
|
+
* @throws {@link InvalidSignatureError} When the signature does not match.
|
|
402
|
+
* @throws `Error` When verification or decoding fails.
|
|
403
|
+
*/
|
|
404
|
+
verifyAndDecode(request: Request, options?: VerifyOptions): Promise<Event>;
|
|
405
|
+
private readBody;
|
|
406
|
+
private check;
|
|
407
|
+
private secretFor;
|
|
408
|
+
}
|
|
409
|
+
//#endregion
|
|
410
|
+
export type { DeliveryStatus, Event, EventType, FetchLike, FetchRawEmailOptions, HeaderField, InboundEmail, MessageSummary, RawEmail, RoutingDecision, StatusOutcome, StorageStatus, TerminalAction, Verdicts, VerifierOptions, VerifyOptions, WebhookEnvelope };
|
|
411
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/webhook/payload.ts","../../src/webhook/decode.ts","../../src/webhook/errors.ts","../../src/webhook/raw.ts","../../src/webhook/verifier.ts"],"mappings":";;;;;qBAKa;;;;;;;;;;;;;;KAeD,oBAAoB,wBAAwB;;qBAG3C;;;;;;;;;;;;;;;KAgBD,wBAAwB,4BAA4B;;;;;;qBAOnD;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BD,yBAAyB,6BAA6B;;KAGtD;WACG,aAAa,UAAU;WAAuB,cAAc;;WAC5D,aAAa,UAAU;WAAyB,gBAAgB;;WAChE,aAAa,UAAU;WAAwB,eAAe;;;UAG5D;;WAEN,iBAAiB;;WAEjB;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;;;;;;UAQM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA,kBAAkB;;WAElB,WAAW;;WAEX,UAAU;;WAEV,SAAS;;WAET,kBAAkB;;WAElB,WAAW;;;UAIL;;WAEN;;WAEA;;WAEA;;WAEA,QAAQ;;WAER;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;UAIM;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA,QAAQ;;WAER;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;;;;;;;;;;wBC7OK,OAAO,MAAM,sBAAsB;;;;;;;;qBCrBtC,8BAA8B;;;;EAI7B,YAAA;;;;;KCIF,aAAa,aAAa,OAAO,gBAAgB,QAAQ;;UAGpD;;WAEN,SAAS;;WAET,QAAQ;;;;;;;;;;;;;;;;;;;;;;wBAuBG,cACpB,KAAK,UACL,UAAS,uBACR,QAAQ;;;;;;;;;qBC5BE;;;;;;;;;;;UAYI;;WAEN;;WAEA,OAAO;;WAEP;;WAEA;;;UAIM;;WAEN,SAAS;;;;;;;;;;;;;;;;;;;;;qBAyBP;mBACM;mBACA;mBACA;mBACA;;;;;EAML,YAAA,UAAS;;;;;;;;;;;;;EA+Cf,OAAO,SAAS,SAAS,UAAS,gBAAqB;;;;;;;;;;EAcvD,gBAAgB,SAAS,SAAS,UAAS,gBAAqB,QAAQ;UAMhE;UAKN;UA+CA"}
|