@primitivedotdev/sdk 0.24.0 → 0.25.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/dist/api/generated/sdk.gen.js +29 -17
- package/dist/api/index.d.ts +3 -2
- package/dist/api/index.js +6 -0
- package/dist/api/verify-signature.js +198 -0
- package/dist/{api-BjzvA2Fy.js → api-CoP5vKPK.js} +170 -19
- package/dist/contract/index.d.ts +1 -1
- package/dist/contract/index.js +1 -1
- package/dist/errors-C53fe686.d.ts +245 -0
- package/dist/errors-x91I_yEt.js +287 -0
- package/dist/{index-CDlwyxdp.d.ts → index-Dbx9udpX.d.ts} +2 -210
- package/dist/{index-QTYQpSFt.d.ts → index-DdITDPea.d.ts} +105 -5
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/openapi/openapi.generated.js +21 -1
- package/dist/openapi/operations.generated.js +15 -3
- package/dist/webhook/errors.js +224 -0
- package/dist/webhook/index.d.ts +2 -2
- package/dist/webhook/index.js +2 -2
- package/dist/{webhook-rUjGV6Zu.js → webhook-DJkfUnFZ.js} +2 -220
- package/oclif.manifest.json +23 -2
- package/package.json +1 -1
- package/dist/received-email-D6tKtWwW.js +0 -69
- package/dist/received-email-DNjpq_Wt.d.ts +0 -37
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { m as ReceivedEmail } from "./errors-C53fe686.js";
|
|
2
2
|
|
|
3
3
|
//#region src/api/generated/core/auth.gen.d.ts
|
|
4
4
|
type AuthToken = string | undefined;
|
|
@@ -3369,7 +3369,19 @@ type UpdateFunctionResponses = {
|
|
|
3369
3369
|
};
|
|
3370
3370
|
type UpdateFunctionResponse = UpdateFunctionResponses[keyof UpdateFunctionResponses];
|
|
3371
3371
|
type TestFunctionData = {
|
|
3372
|
-
body?:
|
|
3372
|
+
body?: {
|
|
3373
|
+
/**
|
|
3374
|
+
* Override the synthetic local-part. When set, the
|
|
3375
|
+
* test email is sent to `<local_part>@<picked-domain>`
|
|
3376
|
+
* instead of the default
|
|
3377
|
+
* `__primitive_function_test+<random>@<picked-domain>`.
|
|
3378
|
+
* Must start with an alphanumeric and contain only
|
|
3379
|
+
* letters, digits, dots, plus signs, hyphens, or
|
|
3380
|
+
* underscores; 1-64 characters total.
|
|
3381
|
+
*
|
|
3382
|
+
*/
|
|
3383
|
+
local_part?: string;
|
|
3384
|
+
};
|
|
3373
3385
|
path: {
|
|
3374
3386
|
/**
|
|
3375
3387
|
* Resource UUID
|
|
@@ -4104,8 +4116,14 @@ declare const updateFunction: <ThrowOnError extends boolean = false>(options: Op
|
|
|
4104
4116
|
* Send a test invocation
|
|
4105
4117
|
*
|
|
4106
4118
|
* Sends a real test email from a Primitive-controlled sender to a
|
|
4107
|
-
*
|
|
4108
|
-
*
|
|
4119
|
+
* local-part on one of the org's verified inbound domains. By
|
|
4120
|
+
* default the recipient is a synthetic
|
|
4121
|
+
* `__primitive_function_test+<random>@<domain>` address that
|
|
4122
|
+
* every handler's catch-all routing receives identically; pass
|
|
4123
|
+
* `local_part` to override and exercise routing logic that
|
|
4124
|
+
* branches on a specific recipient (the common pattern when one
|
|
4125
|
+
* function handles multiple inboxes like `summarize@` and
|
|
4126
|
+
* `action@`). The function fires through the normal MX delivery
|
|
4109
4127
|
* path, so reply / send-mail calls from inside the handler
|
|
4110
4128
|
* against the inbound's `email.id` work the same as in
|
|
4111
4129
|
* production. Returns immediately after the send is queued; the
|
|
@@ -4115,6 +4133,8 @@ declare const updateFunction: <ThrowOnError extends boolean = false>(options: Op
|
|
|
4115
4133
|
* Requires that the function is currently `deployed`. Returns 422
|
|
4116
4134
|
* if the function is in `pending` or `failed` state, or if the
|
|
4117
4135
|
* org has no verified inbound domain to receive the test mail.
|
|
4136
|
+
* Returns 400 if `local_part` is set to a value that does not
|
|
4137
|
+
* match the local-part character set.
|
|
4118
4138
|
*
|
|
4119
4139
|
*/
|
|
4120
4140
|
declare const testFunction: <ThrowOnError extends boolean = false>(options: Options<TestFunctionData, ThrowOnError>) => RequestResult<TestFunctionResponses, TestFunctionErrors, ThrowOnError, "fields">;
|
|
@@ -4172,6 +4192,86 @@ declare const deleteFunctionSecret: <ThrowOnError extends boolean = false>(optio
|
|
|
4172
4192
|
*/
|
|
4173
4193
|
declare const setFunctionSecret: <ThrowOnError extends boolean = false>(options: Options<SetFunctionSecretData, ThrowOnError>) => RequestResult<SetFunctionSecretResponses, SetFunctionSecretErrors, ThrowOnError, "fields">;
|
|
4174
4194
|
//#endregion
|
|
4195
|
+
//#region src/api/verify-signature.d.ts
|
|
4196
|
+
/**
|
|
4197
|
+
* Workers-safe webhook signature verification.
|
|
4198
|
+
*
|
|
4199
|
+
* Mirrors `verifyWebhookSignature` from `@primitivedotdev/sdk` but
|
|
4200
|
+
* implements the HMAC-SHA256 step with the Web Crypto API
|
|
4201
|
+
* (`crypto.subtle`) instead of `node:crypto`. The Node version is
|
|
4202
|
+
* still the right choice for server-side handlers running on Node
|
|
4203
|
+
* (it's measurably faster and supports Buffer bodies); this one
|
|
4204
|
+
* exists so a Primitive Function handler can bundle the verifier
|
|
4205
|
+
* without dragging in a `node:crypto` polyfill that inflates the
|
|
4206
|
+
* deploy artifact past the size cap.
|
|
4207
|
+
*
|
|
4208
|
+
* Available natively in Workers, Node 22+, browsers, Deno, and Bun.
|
|
4209
|
+
* Zero polyfill weight, zero new runtime dependencies.
|
|
4210
|
+
*
|
|
4211
|
+
* Surface contract matches the Node verifier exactly: same input
|
|
4212
|
+
* shape, same `WebhookVerificationError` class, same set of error
|
|
4213
|
+
* codes. Existing callers can swap the import path with no other
|
|
4214
|
+
* code changes:
|
|
4215
|
+
*
|
|
4216
|
+
* // Node (existing):
|
|
4217
|
+
* import { verifyWebhookSignature } from '@primitivedotdev/sdk';
|
|
4218
|
+
*
|
|
4219
|
+
* // Workers / in-handler (this file):
|
|
4220
|
+
* import { verifyWebhookSignature } from '@primitivedotdev/sdk/api';
|
|
4221
|
+
*/
|
|
4222
|
+
declare const PRIMITIVE_SIGNATURE_HEADER = "Primitive-Signature";
|
|
4223
|
+
interface VerifyOptions {
|
|
4224
|
+
/**
|
|
4225
|
+
* The raw request body string. MUST be the exact bytes Primitive
|
|
4226
|
+
* signed; re-serializing parsed JSON produces a different string
|
|
4227
|
+
* and the verification will fail.
|
|
4228
|
+
*/
|
|
4229
|
+
rawBody: string;
|
|
4230
|
+
/** Value of the `Primitive-Signature` header. */
|
|
4231
|
+
signatureHeader: string;
|
|
4232
|
+
/** Webhook signing secret. Auto-injected into Function handlers as `env.PRIMITIVE_WEBHOOK_SECRET`. */
|
|
4233
|
+
secret: string;
|
|
4234
|
+
/** Max age in seconds (default: 300). */
|
|
4235
|
+
toleranceSeconds?: number;
|
|
4236
|
+
/** Override current time for testing (unix seconds). */
|
|
4237
|
+
nowSeconds?: number;
|
|
4238
|
+
}
|
|
4239
|
+
/**
|
|
4240
|
+
* Verify a webhook signature using the Web Crypto API.
|
|
4241
|
+
*
|
|
4242
|
+
* Throws `WebhookVerificationError` on failure with a specific error
|
|
4243
|
+
* code matching the Node verifier's set. Returns `true` on success.
|
|
4244
|
+
*
|
|
4245
|
+
* @example
|
|
4246
|
+
* ```typescript
|
|
4247
|
+
* import {
|
|
4248
|
+
* verifyWebhookSignature,
|
|
4249
|
+
* WebhookVerificationError,
|
|
4250
|
+
* PRIMITIVE_SIGNATURE_HEADER,
|
|
4251
|
+
* } from '@primitivedotdev/sdk/api';
|
|
4252
|
+
*
|
|
4253
|
+
* export default {
|
|
4254
|
+
* async fetch(request: Request, env: { PRIMITIVE_WEBHOOK_SECRET: string }) {
|
|
4255
|
+
* const rawBody = await request.text();
|
|
4256
|
+
* try {
|
|
4257
|
+
* await verifyWebhookSignature({
|
|
4258
|
+
* rawBody,
|
|
4259
|
+
* signatureHeader: request.headers.get(PRIMITIVE_SIGNATURE_HEADER) ?? '',
|
|
4260
|
+
* secret: env.PRIMITIVE_WEBHOOK_SECRET,
|
|
4261
|
+
* });
|
|
4262
|
+
* } catch (err) {
|
|
4263
|
+
* if (err instanceof WebhookVerificationError) {
|
|
4264
|
+
* return new Response('invalid signature', { status: 401 });
|
|
4265
|
+
* }
|
|
4266
|
+
* throw err;
|
|
4267
|
+
* }
|
|
4268
|
+
* // ... process the webhook
|
|
4269
|
+
* },
|
|
4270
|
+
* };
|
|
4271
|
+
* ```
|
|
4272
|
+
*/
|
|
4273
|
+
declare function verifyWebhookSignature(opts: VerifyOptions): Promise<true>;
|
|
4274
|
+
//#endregion
|
|
4175
4275
|
//#region src/api/index.d.ts
|
|
4176
4276
|
declare const DEFAULT_API_BASE_URL_1 = "https://www.primitive.dev/api/v1";
|
|
4177
4277
|
declare const DEFAULT_API_BASE_URL_2 = "https://api.primitive.dev/v1";
|
|
@@ -4327,4 +4427,4 @@ declare function createPrimitiveClient(options?: PrimitiveClientOptions): Primit
|
|
|
4327
4427
|
declare function client(options?: PrimitiveClientOptions): PrimitiveClient;
|
|
4328
4428
|
declare const operations: typeof sdk_gen_d_exports;
|
|
4329
4429
|
//#endregion
|
|
4330
|
-
export {
|
|
4430
|
+
export { pollCliLogin as $, StorageStats as $a, ReplayDeliveryError as $i, DownloadRawEmailErrors as $n, Config as $o, GetWebhookSecretError as $r, CreateFunctionSecretData as $t, deleteEmail as A, SendMailInput as Aa, ListFunctionSecretsData as Ai, DeleteFunctionResponses as An, UpdateEndpointResponse as Ao, GetEmailResponse as Ar, CliLogoutResponse as At, getFunction as B, SentEmailSummary as Ba, ListSentEmailsData as Bi, DiscardEmailContentError as Bn, UpdateFunctionErrors as Bo, GetSendPermissionsResponse as Br, CreateFilterData as Bt, addDomain as C, SearchEmailsResponse as Ca, ListEndpointsResponses as Ci, DeleteFilterErrors as Cn, UpdateDomainInput as Co, GetAccountError as Cr, AddDomainResponses as Ct, createFunction as D, SendEmailErrors as Da, ListFiltersErrors as Di, DeleteFunctionError as Dn, UpdateEndpointError as Do, GetEmailData as Dr, CliLogoutError as Dt, createFilter as E, SendEmailError as Ea, ListFiltersError as Ei, DeleteFunctionData as En, UpdateEndpointData as Eo, GetAccountResponses as Er, CliLogoutData as Et, discardEmailContent as F, SendPermissionRule as Fa, ListFunctionsData as Fi, DeleteFunctionSecretResponses as Fn, UpdateFilterInput as Fo, GetFunctionResponse as Fr, CreateEndpointError as Ft, listDeliveries as G, SetFunctionSecretResponse as Ga, PaginationMeta as Gi, DomainVerifyResult as Gn, VerifyDomainData as Go, GetSentEmailResponse as Gr, CreateFilterResponses as Gt, getSentEmail as H, SetFunctionSecretError as Ha, ListSentEmailsErrors as Hi, DiscardEmailContentResponse as Hn, UpdateFunctionResponse as Ho, GetSentEmailData as Hr, CreateFilterErrors as Ht, downloadAttachments as I, SendPermissionYourDomain as Ia, ListFunctionsError as Ii, DeliveryStatus as In, UpdateFilterResponse as Io, GetFunctionResponses as Ir, CreateEndpointErrors as It, listEndpoints as J, StartCliLoginError as Ja, PollCliLoginErrors as Ji, DownloadAttachmentsErrors as Jn, VerifyDomainResponse as Jo, GetStorageStatsError as Jr, CreateFunctionErrors as Jt, listDomains as K, SetFunctionSecretResponses as Ka, PollCliLoginData as Ki, DownloadAttachmentsData as Kn, VerifyDomainError as Ko, GetSentEmailResponses as Kr, CreateFunctionData as Kt, downloadRawEmail as L, SendPermissionsMeta as La, ListFunctionsErrors as Li, DeliverySummary as Ln, UpdateFilterResponses as Lo, GetSendPermissionsData as Lr, CreateEndpointInput as Lt, deleteFilter as M, SendPermissionAddress as Ma, ListFunctionSecretsErrors as Mi, DeleteFunctionSecretError as Mn, UpdateFilterData as Mo, GetFunctionData as Mr, CliLogoutResult as Mt, deleteFunction as N, SendPermissionAnyRecipient as Na, ListFunctionSecretsResponse as Ni, DeleteFunctionSecretErrors as Nn, UpdateFilterError as No, GetFunctionError as Nr, ClientOptions as Nt, createFunctionSecret as O, SendEmailResponse as Oa, ListFiltersResponse as Oi, DeleteFunctionErrors as On, UpdateEndpointErrors as Oo, GetEmailError as Or, CliLogoutErrors as Ot, deleteFunctionSecret as P, SendPermissionManagedZone as Pa, ListFunctionSecretsResponses as Pi, DeleteFunctionSecretResponse as Pn, UpdateFilterErrors as Po, GetFunctionErrors as Pr, CreateEndpointData as Pt, listSentEmails as Q, StartCliLoginResponses as Qa, ReplayDeliveryData as Qi, DownloadRawEmailError as Qn, ClientOptions$1 as Qo, GetWebhookSecretData as Qr, CreateFunctionResult as Qt, getAccount as R, SentEmailDetail as Ra, ListFunctionsResponse as Ri, DiscardContentResult as Rn, UpdateFunctionData as Ro, GetSendPermissionsError as Rr, CreateEndpointResponse as Rt, Options as S, SearchEmailsErrors as Sa, ListEndpointsResponse as Si, DeleteFilterError as Sn, UpdateDomainErrors as So, GetAccountData as Sr, AddDomainResponse as St, createEndpoint as T, SendEmailData as Ta, ListFiltersData as Ti, DeleteFilterResponses as Tn, UpdateDomainResponses as To, GetAccountResponse as Tr, CliLoginStartResult as Tt, getStorageStats as U, SetFunctionSecretErrors as Ua, ListSentEmailsResponse as Ui, DiscardEmailContentResponses as Un, UpdateFunctionResponses as Uo, GetSentEmailError as Ur, CreateFilterInput as Ut, getSendPermissions as V, SetFunctionSecretData as Va, ListSentEmailsError as Vi, DiscardEmailContentErrors as Vn, UpdateFunctionInput as Vo, GetSendPermissionsResponses as Vr, CreateFilterError as Vt, getWebhookSecret as W, SetFunctionSecretInput as Wa, ListSentEmailsResponses as Wi, Domain as Wn, VerifiedDomain as Wo, GetSentEmailErrors as Wr, CreateFilterResponse as Wt, listFunctionSecrets as X, StartCliLoginInput as Xa, PollCliLoginResponse as Xi, DownloadAttachmentsResponses as Xn, WebhookSecret as Xo, GetStorageStatsResponse as Xr, CreateFunctionResponse as Xt, listFilters as Y, StartCliLoginErrors as Ya, PollCliLoginInput as Yi, DownloadAttachmentsResponse as Yn, VerifyDomainResponses as Yo, GetStorageStatsErrors as Yr, CreateFunctionInput as Yt, listFunctions as Z, StartCliLoginResponse as Za, PollCliLoginResponses as Zi, DownloadRawEmailData as Zn, Client as Zo, GetStorageStatsResponses as Zr, CreateFunctionResponses as Zt, createPrimitiveClient as _, RotateWebhookSecretErrors as _a, ListEmailsResponse as _i, DeleteEndpointError as _n, UpdateAccountInput as _o, FunctionListItem as _r, AccountUpdated as _t, PrimitiveApiClientOptions as a, ReplayEmailWebhooksErrors as aa, ListDeliveriesError as ai, Cursor as an, TestEndpointResponses as ao, EmailSearchFacets as ar, Auth as as, sendEmail as at, VerifyOptions as b, SearchEmailsData as ba, ListEndpointsError as bi, DeleteEndpointResponses as bn, UpdateDomainData as bo, GateDenial as br, AddDomainErrors as bt, PrimitiveClient as c, ReplayResult as ca, ListDeliveriesResponses as ci, DeleteDomainErrors as cn, TestFunctionErrors as co, EmailSearchResult as cr, testEndpoint as ct, RequestOptions as d, ReplyToEmailErrors as da, ListDomainsErrors as di, DeleteEmailData as dn, TestInvocationResult as do, EmailWebhookStatus as dr, updateDomain as dt, ReplayDeliveryErrors as ea, GetWebhookSecretErrors as ei, CreateFunctionSecretError as en, SuccessEnvelope as eo, DownloadRawEmailResponse as er, CreateClientConfig as es, replayDelivery as et, SendInput as f, ReplyToEmailResponse as fa, ListDomainsResponse as fi, DeleteEmailError as fn, TestResult as fo, Endpoint as fr, updateEndpoint as ft, createPrimitiveApiClient as g, RotateWebhookSecretError as ga, ListEmailsErrors as gi, DeleteEndpointData as gn, UpdateAccountErrors as go, FunctionDetail as gr, Account as gt, client as h, RotateWebhookSecretData as ha, ListEmailsError as hi, DeleteEmailResponses as hn, UpdateAccountError as ho, FunctionDeployStatus as hr, verifyDomain as ht, PrimitiveApiClient as i, ReplayEmailWebhooksError as ia, ListDeliveriesData as ii, CreateFunctionSecretResponses as in, TestEndpointResponse as io, EmailSearchFacetBucket as ir, ResponseStyle as is, searchEmails as it, deleteEndpoint as j, SendMailResult as ja, ListFunctionSecretsError as ji, DeleteFunctionSecretData as jn, UpdateEndpointResponses as jo, GetEmailResponses as jr, CliLogoutResponses as jt, deleteDomain as k, SendEmailResponses as ka, ListFiltersResponses as ki, DeleteFunctionResponse as kn, UpdateEndpointInput as ko, GetEmailErrors as kr, CliLogoutInput as kt, PrimitiveClientOptions as l, ReplyToEmailData as la, ListDomainsData as li, DeleteDomainResponse as ln, TestFunctionResponse as lo, EmailStatus as lr, testFunction as lt, SendThreadInput as m, ResourceId as ma, ListEmailsData as mi, DeleteEmailResponse as mn, UpdateAccountData as mo, Filter as mr, updateFunction as mt, DEFAULT_API_BASE_URL_2 as n, ReplayDeliveryResponses as na, GetWebhookSecretResponses as ni, CreateFunctionSecretInput as nn, TestEndpointError as no, EmailDetail as nr, RequestOptions$1 as ns, replyToEmail as nt, PrimitiveApiError as o, ReplayEmailWebhooksResponse as oa, ListDeliveriesErrors as oi, DeleteDomainData as on, TestFunctionData as oo, EmailSearchHighlights as or, setFunctionSecret as ot, SendResult as p, ReplyToEmailResponses as pa, ListDomainsResponses as pi, DeleteEmailErrors as pn, UnverifiedDomain as po, ErrorResponse as pr, updateFilter as pt, listEmails as q, StartCliLoginData as qa, PollCliLoginError as qi, DownloadAttachmentsError as qn, VerifyDomainErrors as qo, GetStorageStatsData as qr, CreateFunctionError as qt, ForwardInput as r, ReplayEmailWebhooksData as ra, Limit as ri, CreateFunctionSecretResponse as rn, TestEndpointErrors as ro, EmailDetailReply as rr, RequestResult as rs, rotateWebhookSecret as rt, PrimitiveApiErrorDetails as s, ReplayEmailWebhooksResponses as sa, ListDeliveriesResponse as si, DeleteDomainError as sn, TestFunctionError as so, EmailSearchMeta as sr, startCliLogin as st, DEFAULT_API_BASE_URL_1 as t, ReplayDeliveryResponse as ta, GetWebhookSecretResponse as ti, CreateFunctionSecretErrors as tn, TestEndpointData as to, DownloadRawEmailResponses as tr, Options$1 as ts, replayEmailWebhooks as tt, ReplyInput as u, ReplyToEmailError as ua, ListDomainsError as ui, DeleteDomainResponses as un, TestFunctionResponses as uo, EmailSummary as ur, updateAccount as ut, operations as v, RotateWebhookSecretResponse as va, ListEmailsResponses as vi, DeleteEndpointErrors as vn, UpdateAccountResponse as vo, FunctionSecretListItem as vr, AddDomainData as vt, cliLogout as w, SearchEmailsResponses as wa, ListEnvelope as wi, DeleteFilterResponse as wn, UpdateDomainResponse as wo, GetAccountErrors as wr, CliLoginPollResult as wt, verifyWebhookSignature as x, SearchEmailsError as xa, ListEndpointsErrors as xi, DeleteFilterData as xn, UpdateDomainError as xo, GateFix as xr, AddDomainInput as xt, PRIMITIVE_SIGNATURE_HEADER as y, RotateWebhookSecretResponses as ya, ListEndpointsData as yi, DeleteEndpointResponse as yn, UpdateAccountResponses as yo, FunctionSecretWriteResult as yr, AddDomainError as yt, getEmail as z, SentEmailStatus as za, ListFunctionsResponses as zi, DiscardEmailContentData as zn, UpdateFunctionError as zo, GetSendPermissionsErrors as zr, CreateEndpointResponses as zt };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A as UnknownEvent, C as ParsedDataFailed, D as RawContentDownloadOnly, E as RawContent, M as WebhookAttachment, N as WebhookEvent, O as RawContentInline, S as ParsedDataComplete, T as ParsedStatus, _ as ForwardResultInline, a as DmarcPolicy, b as KnownWebhookEvent, c as EmailAnalysis, d as EventType, f as ForwardAnalysis, g as ForwardResultAttachmentSkipped, h as ForwardResultAttachmentAnalyzed, i as DkimSignature, j as ValidateEmailAuthResult, k as SpfResult, l as EmailAuth, m as ForwardResult, n as AuthVerdict, o as DmarcResult, p as ForwardOriginalSender, r as DkimResult, s as EmailAddress, t as AuthConfidence, u as EmailReceivedEvent, v as ForwardVerdict, w as ParsedError, x as ParsedData, y as ForwardVerification } from "./types-9vXGZjPd.js";
|
|
2
|
-
import { a as
|
|
3
|
-
import { _ as createPrimitiveClient, c as PrimitiveClient, f as SendInput, h as client, l as PrimitiveClientOptions, m as SendThreadInput, o as PrimitiveApiError, p as SendResult, r as ForwardInput, u as ReplyInput } from "./index-
|
|
4
|
-
import { A as VerifyOptions,
|
|
2
|
+
import { _ as buildForwardSubject, a as RawEmailDecodeErrorCode, b as normalizeReceivedEmail, c as WebhookPayloadError, d as WebhookValidationErrorCode, f as WebhookVerificationError, g as ReceivedEmailThread, h as ReceivedEmailAddress, i as RawEmailDecodeError, l as WebhookPayloadErrorCode, m as ReceivedEmail, n as PrimitiveWebhookError, o as VERIFICATION_ERRORS, p as WebhookVerificationErrorCode, r as RAW_EMAIL_ERRORS, s as WebhookErrorCode, t as PAYLOAD_ERRORS, u as WebhookValidationError, v as buildReplySubject, x as parseHeaderAddress, y as formatAddress } from "./errors-C53fe686.js";
|
|
3
|
+
import { _ as createPrimitiveClient, c as PrimitiveClient, f as SendInput, h as client, l as PrimitiveClientOptions, m as SendThreadInput, o as PrimitiveApiError, p as SendResult, r as ForwardInput, u as ReplyInput } from "./index-DdITDPea.js";
|
|
4
|
+
import { A as VerifyOptions, C as signStandardWebhooksPayload, D as PRIMITIVE_CONFIRMED_HEADER, E as LEGACY_SIGNATURE_HEADER, F as VerifyDownloadTokenResult, I as generateDownloadToken, L as verifyDownloadToken, M as verifyWebhookSignature, N as GenerateDownloadTokenOptions, O as PRIMITIVE_SIGNATURE_HEADER, P as VerifyDownloadTokenOptions, R as safeValidateEmailReceivedEvent, S as StandardWebhooksVerifyOptions, T as LEGACY_CONFIRMED_HEADER, _ as emailReceivedEventJsonSchema, a as confirmedHeaders, b as STANDARD_WEBHOOK_TIMESTAMP_HEADER, c as handleWebhook, d as isRawIncluded, f as parseWebhookEvent, g as validateEmailAuth, h as WEBHOOK_VERSION, i as WebhookHeaders, j as signWebhookPayload, k as SignResult, l as isDownloadExpired, m as verifyRawEmailDownload, n as HandleWebhookOptions, o as decodeRawEmail, p as receive, r as ReceiveRequestOptions, s as getDownloadTimeRemaining, t as DecodeRawEmailOptions, u as isEmailReceivedEvent, v as STANDARD_WEBHOOK_ID_HEADER, w as verifyStandardWebhooksSignature, x as StandardWebhooksSignResult, y as STANDARD_WEBHOOK_SIGNATURE_HEADER, z as validateEmailReceivedEvent } from "./index-Dbx9udpX.js";
|
|
5
5
|
|
|
6
6
|
//#region src/index.d.ts
|
|
7
7
|
declare const primitive: {
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { a as PrimitiveClient, c as createPrimitiveClient, i as PrimitiveApiError, o as client } from "./api-
|
|
3
|
-
import { A as PRIMITIVE_CONFIRMED_HEADER,
|
|
1
|
+
import { a as VERIFICATION_ERRORS, c as WebhookVerificationError, d as formatAddress, f as normalizeReceivedEmail, i as RawEmailDecodeError, l as buildForwardSubject, n as PrimitiveWebhookError, o as WebhookPayloadError, p as parseHeaderAddress, r as RAW_EMAIL_ERRORS, s as WebhookValidationError, t as PAYLOAD_ERRORS, u as buildReplySubject } from "./errors-x91I_yEt.js";
|
|
2
|
+
import { a as PrimitiveClient, c as createPrimitiveClient, i as PrimitiveApiError, o as client } from "./api-CoP5vKPK.js";
|
|
3
|
+
import { A as PRIMITIVE_CONFIRMED_HEADER, C as STANDARD_WEBHOOK_ID_HEADER, D as verifyStandardWebhooksSignature, E as signStandardWebhooksPayload, F as verifyDownloadToken, I as safeValidateEmailReceivedEvent, L as validateEmailReceivedEvent, M as signWebhookPayload, N as verifyWebhookSignature, O as LEGACY_CONFIRMED_HEADER, P as generateDownloadToken, S as emailReceivedEventJsonSchema, T as STANDARD_WEBHOOK_TIMESTAMP_HEADER, _ as DmarcResult, a as isDownloadExpired, b as ParsedStatus, c as parseWebhookEvent, d as WEBHOOK_VERSION, f as validateEmailAuth, g as DmarcPolicy, h as DkimResult, i as handleWebhook, j as PRIMITIVE_SIGNATURE_HEADER, k as LEGACY_SIGNATURE_HEADER, l as receive, m as AuthVerdict, n as decodeRawEmail, o as isEmailReceivedEvent, p as AuthConfidence, r as getDownloadTimeRemaining, s as isRawIncluded, t as confirmedHeaders, u as verifyRawEmailDownload, v as EventType, w as STANDARD_WEBHOOK_SIGNATURE_HEADER, x as SpfResult, y as ForwardVerdict } from "./webhook-DJkfUnFZ.js";
|
|
4
4
|
//#region src/index.ts
|
|
5
5
|
const primitive = {
|
|
6
6
|
client,
|
|
@@ -2569,10 +2569,30 @@ export const openapiDocument = {
|
|
|
2569
2569
|
"post": {
|
|
2570
2570
|
"operationId": "testFunction",
|
|
2571
2571
|
"summary": "Send a test invocation",
|
|
2572
|
-
"description": "Sends a real test email from a Primitive-controlled sender to a\
|
|
2572
|
+
"description": "Sends a real test email from a Primitive-controlled sender to a\nlocal-part on one of the org's verified inbound domains. By\ndefault the recipient is a synthetic\n`__primitive_function_test+<random>@<domain>` address that\nevery handler's catch-all routing receives identically; pass\n`local_part` to override and exercise routing logic that\nbranches on a specific recipient (the common pattern when one\nfunction handles multiple inboxes like `summarize@` and\n`action@`). The function fires through the normal MX delivery\npath, so reply / send-mail calls from inside the handler\nagainst the inbound's `email.id` work the same as in\nproduction. Returns immediately after the send is queued; the\ninvocation appears on the function's invocations list within a\nfew seconds.\n\nRequires that the function is currently `deployed`. Returns 422\nif the function is in `pending` or `failed` state, or if the\norg has no verified inbound domain to receive the test mail.\nReturns 400 if `local_part` is set to a value that does not\nmatch the local-part character set.\n",
|
|
2573
2573
|
"tags": [
|
|
2574
2574
|
"Functions"
|
|
2575
2575
|
],
|
|
2576
|
+
"requestBody": {
|
|
2577
|
+
"required": false,
|
|
2578
|
+
"content": {
|
|
2579
|
+
"application/json": {
|
|
2580
|
+
"schema": {
|
|
2581
|
+
"type": "object",
|
|
2582
|
+
"properties": {
|
|
2583
|
+
"local_part": {
|
|
2584
|
+
"type": "string",
|
|
2585
|
+
"description": "Override the synthetic local-part. When set, the\ntest email is sent to `<local_part>@<picked-domain>`\ninstead of the default\n`__primitive_function_test+<random>@<picked-domain>`.\nMust start with an alphanumeric and contain only\nletters, digits, dots, plus signs, hyphens, or\nunderscores; 1-64 characters total.\n",
|
|
2586
|
+
"minLength": 1,
|
|
2587
|
+
"maxLength": 64,
|
|
2588
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$",
|
|
2589
|
+
"example": "summarize"
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
},
|
|
2576
2596
|
"responses": {
|
|
2577
2597
|
"200": {
|
|
2578
2598
|
"description": "Test send queued",
|
|
@@ -3034,8 +3034,8 @@ export const operationManifest = [
|
|
|
3034
3034
|
"binaryResponse": false,
|
|
3035
3035
|
"bodyRequired": false,
|
|
3036
3036
|
"command": "test-function",
|
|
3037
|
-
"description": "Sends a real test email from a Primitive-controlled sender to a\
|
|
3038
|
-
"hasJsonBody":
|
|
3037
|
+
"description": "Sends a real test email from a Primitive-controlled sender to a\nlocal-part on one of the org's verified inbound domains. By\ndefault the recipient is a synthetic\n`__primitive_function_test+<random>@<domain>` address that\nevery handler's catch-all routing receives identically; pass\n`local_part` to override and exercise routing logic that\nbranches on a specific recipient (the common pattern when one\nfunction handles multiple inboxes like `summarize@` and\n`action@`). The function fires through the normal MX delivery\npath, so reply / send-mail calls from inside the handler\nagainst the inbound's `email.id` work the same as in\nproduction. Returns immediately after the send is queued; the\ninvocation appears on the function's invocations list within a\nfew seconds.\n\nRequires that the function is currently `deployed`. Returns 422\nif the function is in `pending` or `failed` state, or if the\norg has no verified inbound domain to receive the test mail.\nReturns 400 if `local_part` is set to a value that does not\nmatch the local-part character set.\n",
|
|
3038
|
+
"hasJsonBody": true,
|
|
3039
3039
|
"method": "POST",
|
|
3040
3040
|
"operationId": "testFunction",
|
|
3041
3041
|
"path": "/functions/{id}/test",
|
|
@@ -3049,7 +3049,19 @@ export const operationManifest = [
|
|
|
3049
3049
|
}
|
|
3050
3050
|
],
|
|
3051
3051
|
"queryParams": [],
|
|
3052
|
-
"requestSchema":
|
|
3052
|
+
"requestSchema": {
|
|
3053
|
+
"type": "object",
|
|
3054
|
+
"properties": {
|
|
3055
|
+
"local_part": {
|
|
3056
|
+
"type": "string",
|
|
3057
|
+
"description": "Override the synthetic local-part. When set, the\ntest email is sent to `<local_part>@<picked-domain>`\ninstead of the default\n`__primitive_function_test+<random>@<picked-domain>`.\nMust start with an alphanumeric and contain only\nletters, digits, dots, plus signs, hyphens, or\nunderscores; 1-64 characters total.\n",
|
|
3058
|
+
"minLength": 1,
|
|
3059
|
+
"maxLength": 64,
|
|
3060
|
+
"pattern": "^[A-Za-z0-9][A-Za-z0-9._+-]{0,63}$",
|
|
3061
|
+
"example": "summarize"
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
},
|
|
3053
3065
|
"responseSchema": {
|
|
3054
3066
|
"type": "object",
|
|
3055
3067
|
"description": "Metadata returned by POST /functions/{id}/test. The send is\nqueued; the actual invocation lands on the function's\ninvocations list a few seconds later as the inbound mail\ntraverses the MX path.\n",
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// -----------------------------------------------------------------------------
|
|
2
|
+
// Error Definitions (Single Source of Truth)
|
|
3
|
+
// -----------------------------------------------------------------------------
|
|
4
|
+
/**
|
|
5
|
+
* Verification error definitions.
|
|
6
|
+
* Use these for documentation, dashboards, and i18n.
|
|
7
|
+
*/
|
|
8
|
+
export const VERIFICATION_ERRORS = {
|
|
9
|
+
INVALID_SIGNATURE_HEADER: {
|
|
10
|
+
message: "Missing or malformed Primitive-Signature header",
|
|
11
|
+
suggestion: "Check that you're reading the correct header (Primitive-Signature) and it's being passed correctly from your web framework.",
|
|
12
|
+
},
|
|
13
|
+
TIMESTAMP_OUT_OF_RANGE: {
|
|
14
|
+
message: "Timestamp is too old (possible replay attack)",
|
|
15
|
+
suggestion: "This could indicate a replay attack, network delay, or server clock drift. Check your server's time is synced.",
|
|
16
|
+
},
|
|
17
|
+
SIGNATURE_MISMATCH: {
|
|
18
|
+
message: "Signature doesn't match expected value",
|
|
19
|
+
suggestion: "Verify the webhook secret matches and you're using the raw request body (not re-serialized JSON).",
|
|
20
|
+
},
|
|
21
|
+
MISSING_SECRET: {
|
|
22
|
+
message: "No webhook secret was provided",
|
|
23
|
+
suggestion: "Pass your webhook secret from the Primitive dashboard. Check that the environment variable is set.",
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Payload parsing error definitions.
|
|
28
|
+
* Use these for documentation, dashboards, and i18n.
|
|
29
|
+
*/
|
|
30
|
+
export const PAYLOAD_ERRORS = {
|
|
31
|
+
PAYLOAD_NULL: {
|
|
32
|
+
message: "Webhook payload is null",
|
|
33
|
+
suggestion: "Ensure you're passing the parsed JSON body, not null. Check your framework's body parsing middleware.",
|
|
34
|
+
},
|
|
35
|
+
PAYLOAD_UNDEFINED: {
|
|
36
|
+
message: "Webhook payload is undefined",
|
|
37
|
+
suggestion: "The payload was not provided. Make sure you're passing the request body to the handler.",
|
|
38
|
+
},
|
|
39
|
+
PAYLOAD_WRONG_TYPE: {
|
|
40
|
+
message: "Webhook payload must be an object",
|
|
41
|
+
suggestion: "The payload should be a parsed JSON object. Check that you're not passing a string or other primitive.",
|
|
42
|
+
},
|
|
43
|
+
PAYLOAD_IS_ARRAY: {
|
|
44
|
+
message: "Webhook payload is an array, expected object",
|
|
45
|
+
suggestion: "Primitive webhooks are single event objects, not arrays. Check the payload structure.",
|
|
46
|
+
},
|
|
47
|
+
PAYLOAD_MISSING_EVENT: {
|
|
48
|
+
message: "Webhook payload missing 'event' field",
|
|
49
|
+
suggestion: "All webhook payloads must have an 'event' field. This may not be a valid Primitive webhook.",
|
|
50
|
+
},
|
|
51
|
+
PAYLOAD_UNKNOWN_EVENT: {
|
|
52
|
+
message: "Unknown webhook event type",
|
|
53
|
+
suggestion: "This event type is not recognized. You may need to update your SDK or handle unknown events gracefully.",
|
|
54
|
+
},
|
|
55
|
+
PAYLOAD_EMPTY_BODY: {
|
|
56
|
+
message: "Request body is empty",
|
|
57
|
+
suggestion: "The request body was empty. Ensure the webhook is sending data and your framework is parsing it correctly.",
|
|
58
|
+
},
|
|
59
|
+
JSON_PARSE_FAILED: {
|
|
60
|
+
message: "Failed to parse JSON body",
|
|
61
|
+
suggestion: "The request body is not valid JSON. Check the raw body content and Content-Type header.",
|
|
62
|
+
},
|
|
63
|
+
INVALID_ENCODING: {
|
|
64
|
+
message: "Invalid body encoding",
|
|
65
|
+
suggestion: "The request body encoding is not supported. Primitive webhooks use UTF-8 encoded JSON.",
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Raw email decode error definitions.
|
|
70
|
+
* Use these for documentation, dashboards, and i18n.
|
|
71
|
+
*/
|
|
72
|
+
export const RAW_EMAIL_ERRORS = {
|
|
73
|
+
NOT_INCLUDED: {
|
|
74
|
+
message: "Raw email content not included inline",
|
|
75
|
+
suggestion: "Use the download URL at event.email.content.download.url to fetch the raw email.",
|
|
76
|
+
},
|
|
77
|
+
INVALID_BASE64: {
|
|
78
|
+
message: "Raw email content is not valid base64",
|
|
79
|
+
suggestion: "The raw email data is malformed. Fetch the raw email from the download URL or regenerate the webhook payload.",
|
|
80
|
+
},
|
|
81
|
+
HASH_MISMATCH: {
|
|
82
|
+
message: "SHA-256 hash verification failed",
|
|
83
|
+
suggestion: "The raw email data may be corrupted. Try downloading from the URL instead.",
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Base class for all Primitive webhook errors.
|
|
88
|
+
*
|
|
89
|
+
* Catch this to handle any error from the SDK in a single catch block.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* import { handleWebhook, PrimitiveWebhookError } from '@primitivedotdev/sdk';
|
|
94
|
+
*
|
|
95
|
+
* try {
|
|
96
|
+
* const event = handleWebhook({ body, headers, secret });
|
|
97
|
+
* } catch (err) {
|
|
98
|
+
* if (err instanceof PrimitiveWebhookError) {
|
|
99
|
+
* console.error(`[${err.code}] ${err.message}`);
|
|
100
|
+
* return res.status(400).json({ error: err.code });
|
|
101
|
+
* }
|
|
102
|
+
* throw err;
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
export class PrimitiveWebhookError extends Error {
|
|
107
|
+
/**
|
|
108
|
+
* Formats the error for logging/display.
|
|
109
|
+
*/
|
|
110
|
+
toString() {
|
|
111
|
+
return `${this.name} [${this.code}]: ${this.message}\n\nSuggestion: ${this.suggestion}`;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Serializes cleanly for structured logging (Datadog, CloudWatch, etc.)
|
|
115
|
+
*/
|
|
116
|
+
toJSON() {
|
|
117
|
+
return {
|
|
118
|
+
name: this.name,
|
|
119
|
+
code: this.code,
|
|
120
|
+
message: this.message,
|
|
121
|
+
suggestion: this.suggestion,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Error thrown when webhook signature verification fails.
|
|
127
|
+
*
|
|
128
|
+
* Use the `code` property to programmatically handle specific error cases.
|
|
129
|
+
*/
|
|
130
|
+
export class WebhookVerificationError extends PrimitiveWebhookError {
|
|
131
|
+
code;
|
|
132
|
+
suggestion;
|
|
133
|
+
constructor(code, message, suggestion) {
|
|
134
|
+
super(message ?? VERIFICATION_ERRORS[code].message);
|
|
135
|
+
this.name = "WebhookVerificationError";
|
|
136
|
+
this.code = code;
|
|
137
|
+
this.suggestion = suggestion ?? VERIFICATION_ERRORS[code].suggestion;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Error thrown when webhook payload parsing fails (lightweight parser).
|
|
142
|
+
*
|
|
143
|
+
* Use the `code` property for programmatic handling and monitoring.
|
|
144
|
+
* The `suggestion` property contains actionable guidance for fixing the issue.
|
|
145
|
+
*/
|
|
146
|
+
export class WebhookPayloadError extends PrimitiveWebhookError {
|
|
147
|
+
code;
|
|
148
|
+
suggestion;
|
|
149
|
+
/** Original error if this wraps another error (e.g., JSON.parse failure) */
|
|
150
|
+
cause;
|
|
151
|
+
constructor(code, message, suggestion, cause) {
|
|
152
|
+
super(message ?? PAYLOAD_ERRORS[code].message);
|
|
153
|
+
this.name = "WebhookPayloadError";
|
|
154
|
+
this.code = code;
|
|
155
|
+
this.suggestion = suggestion ?? PAYLOAD_ERRORS[code].suggestion;
|
|
156
|
+
this.cause = cause;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Error thrown when schema validation fails.
|
|
161
|
+
*/
|
|
162
|
+
export class WebhookValidationError extends PrimitiveWebhookError {
|
|
163
|
+
code = "SCHEMA_VALIDATION_FAILED";
|
|
164
|
+
suggestion;
|
|
165
|
+
/** The specific field path that failed (e.g., "email.headers.from") */
|
|
166
|
+
field;
|
|
167
|
+
/** Original schema validation errors for advanced debugging */
|
|
168
|
+
validationErrors;
|
|
169
|
+
/** Number of additional validation errors beyond the first */
|
|
170
|
+
additionalErrorCount;
|
|
171
|
+
constructor(field, message, suggestion, validationErrors) {
|
|
172
|
+
super(message);
|
|
173
|
+
this.name = "WebhookValidationError";
|
|
174
|
+
this.field = field;
|
|
175
|
+
this.suggestion = suggestion;
|
|
176
|
+
this.validationErrors = validationErrors;
|
|
177
|
+
this.additionalErrorCount = Math.max(0, validationErrors.length - 1);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Formats the error for logging/display.
|
|
181
|
+
* Includes error count and suggestion.
|
|
182
|
+
*/
|
|
183
|
+
toString() {
|
|
184
|
+
let output = `${this.name} [${this.code}]: ${this.message}`;
|
|
185
|
+
if (this.additionalErrorCount > 0) {
|
|
186
|
+
output += ` (and ${this.additionalErrorCount} more validation error${this.additionalErrorCount > 1 ? "s" : ""})`;
|
|
187
|
+
}
|
|
188
|
+
output += `\n\nSuggestion: ${this.suggestion}`;
|
|
189
|
+
return output;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Serializes cleanly for structured logging (Datadog, CloudWatch, etc.)
|
|
193
|
+
*/
|
|
194
|
+
toJSON() {
|
|
195
|
+
return {
|
|
196
|
+
name: this.name,
|
|
197
|
+
code: this.code,
|
|
198
|
+
field: this.field,
|
|
199
|
+
message: this.message,
|
|
200
|
+
suggestion: this.suggestion,
|
|
201
|
+
additionalErrorCount: this.additionalErrorCount,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// -----------------------------------------------------------------------------
|
|
206
|
+
// Raw Email Decode Errors
|
|
207
|
+
// -----------------------------------------------------------------------------
|
|
208
|
+
/**
|
|
209
|
+
* Error thrown when raw email decoding or verification fails.
|
|
210
|
+
*
|
|
211
|
+
* Use the `code` property to determine the failure reason:
|
|
212
|
+
* - `NOT_INCLUDED`: Raw email not inline, must download from URL
|
|
213
|
+
* - `HASH_MISMATCH`: SHA-256 verification failed, content may be corrupted
|
|
214
|
+
*/
|
|
215
|
+
export class RawEmailDecodeError extends PrimitiveWebhookError {
|
|
216
|
+
code;
|
|
217
|
+
suggestion;
|
|
218
|
+
constructor(code, message) {
|
|
219
|
+
super(message ?? RAW_EMAIL_ERRORS[code].message);
|
|
220
|
+
this.name = "RawEmailDecodeError";
|
|
221
|
+
this.code = code;
|
|
222
|
+
this.suggestion = RAW_EMAIL_ERRORS[code].suggestion;
|
|
223
|
+
}
|
|
224
|
+
}
|
package/dist/webhook/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { A as UnknownEvent, C as ParsedDataFailed, D as RawContentDownloadOnly, E as RawContent, M as WebhookAttachment, N as WebhookEvent, O as RawContentInline, S as ParsedDataComplete, T as ParsedStatus, _ as ForwardResultInline, a as DmarcPolicy, b as KnownWebhookEvent, c as EmailAnalysis, d as EventType, f as ForwardAnalysis, g as ForwardResultAttachmentSkipped, h as ForwardResultAttachmentAnalyzed, i as DkimSignature, j as ValidateEmailAuthResult, k as SpfResult, l as EmailAuth, m as ForwardResult, n as AuthVerdict, o as DmarcResult, p as ForwardOriginalSender, r as DkimResult, s as EmailAddress, t as AuthConfidence, u as EmailReceivedEvent, v as ForwardVerdict, w as ParsedError, x as ParsedData, y as ForwardVerification } from "../types-9vXGZjPd.js";
|
|
2
|
-
import { a as
|
|
3
|
-
import { A as VerifyOptions,
|
|
2
|
+
import { _ as buildForwardSubject, a as RawEmailDecodeErrorCode, b as normalizeReceivedEmail, c as WebhookPayloadError, d as WebhookValidationErrorCode, f as WebhookVerificationError, g as ReceivedEmailThread, h as ReceivedEmailAddress, i as RawEmailDecodeError, l as WebhookPayloadErrorCode, m as ReceivedEmail, n as PrimitiveWebhookError, o as VERIFICATION_ERRORS, p as WebhookVerificationErrorCode, r as RAW_EMAIL_ERRORS, s as WebhookErrorCode, t as PAYLOAD_ERRORS, u as WebhookValidationError, v as buildReplySubject, x as parseHeaderAddress, y as formatAddress } from "../errors-C53fe686.js";
|
|
3
|
+
import { A as VerifyOptions, C as signStandardWebhooksPayload, D as PRIMITIVE_CONFIRMED_HEADER, E as LEGACY_SIGNATURE_HEADER, F as VerifyDownloadTokenResult, I as generateDownloadToken, L as verifyDownloadToken, M as verifyWebhookSignature, N as GenerateDownloadTokenOptions, O as PRIMITIVE_SIGNATURE_HEADER, P as VerifyDownloadTokenOptions, R as safeValidateEmailReceivedEvent, S as StandardWebhooksVerifyOptions, T as LEGACY_CONFIRMED_HEADER, _ as emailReceivedEventJsonSchema, a as confirmedHeaders, b as STANDARD_WEBHOOK_TIMESTAMP_HEADER, c as handleWebhook, d as isRawIncluded, f as parseWebhookEvent, g as validateEmailAuth, h as WEBHOOK_VERSION, i as WebhookHeaders, j as signWebhookPayload, k as SignResult, l as isDownloadExpired, m as verifyRawEmailDownload, n as HandleWebhookOptions, o as decodeRawEmail, p as receive, r as ReceiveRequestOptions, s as getDownloadTimeRemaining, t as DecodeRawEmailOptions, u as isEmailReceivedEvent, v as STANDARD_WEBHOOK_ID_HEADER, w as verifyStandardWebhooksSignature, x as StandardWebhooksSignResult, y as STANDARD_WEBHOOK_SIGNATURE_HEADER, z as validateEmailReceivedEvent } from "../index-Dbx9udpX.js";
|
|
4
4
|
export { AuthConfidence, AuthVerdict, DecodeRawEmailOptions, DkimResult, DkimSignature, DmarcPolicy, DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType, ForwardAnalysis, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict, ForwardVerification, GenerateDownloadTokenOptions, HandleWebhookOptions, KnownWebhookEvent, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawContent, RawContentDownloadOnly, RawContentInline, RawEmailDecodeError, RawEmailDecodeErrorCode, ReceiveRequestOptions, ReceivedEmail, ReceivedEmailAddress, ReceivedEmailThread, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, SignResult, SpfResult, StandardWebhooksSignResult, StandardWebhooksVerifyOptions, UnknownEvent, VERIFICATION_ERRORS, ValidateEmailAuthResult, VerifyDownloadTokenOptions, VerifyDownloadTokenResult, VerifyOptions, WEBHOOK_VERSION, WebhookAttachment, WebhookErrorCode, WebhookEvent, WebhookHeaders, WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError, WebhookVerificationErrorCode, buildForwardSubject, buildReplySubject, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, formatAddress, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, normalizeReceivedEmail, parseHeaderAddress, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
|
package/dist/webhook/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { A as PRIMITIVE_CONFIRMED_HEADER,
|
|
1
|
+
import { a as VERIFICATION_ERRORS, c as WebhookVerificationError, d as formatAddress, f as normalizeReceivedEmail, i as RawEmailDecodeError, l as buildForwardSubject, n as PrimitiveWebhookError, o as WebhookPayloadError, p as parseHeaderAddress, r as RAW_EMAIL_ERRORS, s as WebhookValidationError, t as PAYLOAD_ERRORS, u as buildReplySubject } from "../errors-x91I_yEt.js";
|
|
2
|
+
import { A as PRIMITIVE_CONFIRMED_HEADER, C as STANDARD_WEBHOOK_ID_HEADER, D as verifyStandardWebhooksSignature, E as signStandardWebhooksPayload, F as verifyDownloadToken, I as safeValidateEmailReceivedEvent, L as validateEmailReceivedEvent, M as signWebhookPayload, N as verifyWebhookSignature, O as LEGACY_CONFIRMED_HEADER, P as generateDownloadToken, S as emailReceivedEventJsonSchema, T as STANDARD_WEBHOOK_TIMESTAMP_HEADER, _ as DmarcResult, a as isDownloadExpired, b as ParsedStatus, c as parseWebhookEvent, d as WEBHOOK_VERSION, f as validateEmailAuth, g as DmarcPolicy, h as DkimResult, i as handleWebhook, j as PRIMITIVE_SIGNATURE_HEADER, k as LEGACY_SIGNATURE_HEADER, l as receive, m as AuthVerdict, n as decodeRawEmail, o as isEmailReceivedEvent, p as AuthConfidence, r as getDownloadTimeRemaining, s as isRawIncluded, t as confirmedHeaders, u as verifyRawEmailDownload, v as EventType, w as STANDARD_WEBHOOK_SIGNATURE_HEADER, x as SpfResult, y as ForwardVerdict } from "../webhook-DJkfUnFZ.js";
|
|
3
3
|
export { AuthConfidence, AuthVerdict, DkimResult, DmarcPolicy, DmarcResult, EventType, ForwardVerdict, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedStatus, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawEmailDecodeError, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, SpfResult, VERIFICATION_ERRORS, WEBHOOK_VERSION, WebhookPayloadError, WebhookValidationError, WebhookVerificationError, buildForwardSubject, buildReplySubject, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, formatAddress, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, normalizeReceivedEmail, parseHeaderAddress, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
|