@primitivedotdev/sdk 0.8.0 → 0.9.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.
@@ -1,4 +1,4 @@
1
- import { AuthConfidence$1 as AuthConfidence, AuthVerdict$1 as AuthVerdict, DkimResult$1 as DkimResult, DkimSignature, DmarcPolicy$1 as DmarcPolicy, DmarcResult$1 as DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType$1 as EventType, ForwardAnalysis, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict$1 as ForwardVerdict, ForwardVerification, KnownWebhookEvent, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus$1 as ParsedStatus, RawContent, RawContentDownloadOnly, RawContentInline, SpfResult$1 as SpfResult, UnknownEvent, ValidateEmailAuthResult, WebhookAttachment, WebhookEvent } from "../types-CIOzt1FY.js";
2
- import { ReceivedEmail, ReceivedEmailAddress, ReceivedEmailThread, buildForwardSubject$1 as buildForwardSubject, buildReplySubject$1 as buildReplySubject, formatAddress$1 as formatAddress, normalizeReceivedEmail$1 as normalizeReceivedEmail, parseHeaderAddress$1 as parseHeaderAddress } from "../received-email-C67Z7Dha.js";
3
- import { DecodeRawEmailOptions, GenerateDownloadTokenOptions, HandleWebhookOptions, LEGACY_CONFIRMED_HEADER$1 as LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER$1 as LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS$1 as PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER$1 as PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER$1 as PRIMITIVE_SIGNATURE_HEADER, PrimitiveWebhookError$1 as PrimitiveWebhookError, RAW_EMAIL_ERRORS$1 as RAW_EMAIL_ERRORS, RawEmailDecodeError$1 as RawEmailDecodeError, RawEmailDecodeErrorCode, ReceiveRequestOptions, STANDARD_WEBHOOK_ID_HEADER$1 as STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER$1 as STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER$1 as STANDARD_WEBHOOK_TIMESTAMP_HEADER, SignResult, StandardWebhooksSignResult, StandardWebhooksVerifyOptions, VERIFICATION_ERRORS$1 as VERIFICATION_ERRORS, VerifyDownloadTokenOptions, VerifyDownloadTokenResult, VerifyOptions, WEBHOOK_VERSION$1 as WEBHOOK_VERSION, WebhookErrorCode, WebhookHeaders, WebhookPayloadError$1 as WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError$1 as WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError$1 as WebhookVerificationError, WebhookVerificationErrorCode, confirmedHeaders$1 as confirmedHeaders, decodeRawEmail$1 as decodeRawEmail, emailReceivedEventJsonSchema$1 as emailReceivedEventJsonSchema, generateDownloadToken$1 as generateDownloadToken, getDownloadTimeRemaining$1 as getDownloadTimeRemaining, handleWebhook$1 as handleWebhook, isDownloadExpired$1 as isDownloadExpired, isEmailReceivedEvent$1 as isEmailReceivedEvent, isRawIncluded$1 as isRawIncluded, parseWebhookEvent$1 as parseWebhookEvent, receive$1 as receive, safeValidateEmailReceivedEvent$1 as safeValidateEmailReceivedEvent, signStandardWebhooksPayload$1 as signStandardWebhooksPayload, signWebhookPayload$1 as signWebhookPayload, validateEmailAuth$1 as validateEmailAuth, validateEmailReceivedEvent$1 as validateEmailReceivedEvent, verifyDownloadToken$1 as verifyDownloadToken, verifyRawEmailDownload$1 as verifyRawEmailDownload, verifyStandardWebhooksSignature$1 as verifyStandardWebhooksSignature, verifyWebhookSignature$1 as verifyWebhookSignature } from "../index-CuuP1JkG.js";
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 buildReplySubject, c as parseHeaderAddress, i as buildForwardSubject, n as ReceivedEmailAddress, o as formatAddress, r as ReceivedEmailThread, s as normalizeReceivedEmail, t as ReceivedEmail } from "../received-email-DNjpq_Wt.js";
3
+ import { A as VerifyOptions, B as PAYLOAD_ERRORS, C as signStandardWebhooksPayload, D as PRIMITIVE_CONFIRMED_HEADER, E as LEGACY_SIGNATURE_HEADER, F as VerifyDownloadTokenResult, G as VERIFICATION_ERRORS, H as RAW_EMAIL_ERRORS, I as generateDownloadToken, J as WebhookPayloadErrorCode, K as WebhookErrorCode, L as verifyDownloadToken, M as verifyWebhookSignature, N as GenerateDownloadTokenOptions, O as PRIMITIVE_SIGNATURE_HEADER, P as VerifyDownloadTokenOptions, Q as WebhookVerificationErrorCode, R as safeValidateEmailReceivedEvent, S as StandardWebhooksVerifyOptions, T as LEGACY_CONFIRMED_HEADER, U as RawEmailDecodeError, V as PrimitiveWebhookError, W as RawEmailDecodeErrorCode, X as WebhookValidationErrorCode, Y as WebhookValidationError, Z as WebhookVerificationError, _ 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, q as WebhookPayloadError, 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-CbEivn3S.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 };
@@ -1,5 +1,3 @@
1
- import "../address-parser-CfPHs3mE.js";
2
- import { buildForwardSubject, buildReplySubject, formatAddress, normalizeReceivedEmail, parseHeaderAddress } from "../received-email-Q6Cha3wc.js";
3
- import { 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, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature } from "../webhook-2TALcBQz.js";
4
-
5
- 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 };
1
+ import { a as parseHeaderAddress, i as normalizeReceivedEmail, n as buildReplySubject, r as formatAddress, t as buildForwardSubject } from "../received-email-D6tKtWwW.js";
2
+ import { A as PRIMITIVE_CONFIRMED_HEADER, B as RAW_EMAIL_ERRORS, C as STANDARD_WEBHOOK_ID_HEADER, D as verifyStandardWebhooksSignature, E as signStandardWebhooksPayload, F as verifyDownloadToken, G as WebhookVerificationError, H as VERIFICATION_ERRORS, I as safeValidateEmailReceivedEvent, L as validateEmailReceivedEvent, M as signWebhookPayload, N as verifyWebhookSignature, O as LEGACY_CONFIRMED_HEADER, P as generateDownloadToken, R as PAYLOAD_ERRORS, S as emailReceivedEventJsonSchema, T as STANDARD_WEBHOOK_TIMESTAMP_HEADER, U as WebhookPayloadError, V as RawEmailDecodeError, W as WebhookValidationError, _ 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, z as PrimitiveWebhookError } from "../webhook-zkN4wUTs.js";
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 };
@@ -1,7 +1,10 @@
1
- import { normalizeReceivedEmail } from "./received-email-Q6Cha3wc.js";
1
+ import { i as normalizeReceivedEmail } from "./received-email-D6tKtWwW.js";
2
2
  import { createHash, createHmac, timingSafeEqual } from "node:crypto";
3
-
4
3
  //#region src/generated/email-received-event.validator.generated.ts
4
+ /**
5
+ * AUTO-GENERATED - DO NOT EDIT
6
+ * Run `pnpm generate:validator` to regenerate.
7
+ */
5
8
  var email_received_event_validator_generated_default = validate10;
6
9
  const schema12 = {
7
10
  "type": "object",
@@ -183,12 +186,12 @@ const schema12 = {
183
186
  ],
184
187
  "description": "Webhook payload for the `email.received` event.\n\nThis is delivered to your webhook endpoint when Primitive receives an email matching your domain configuration."
185
188
  };
186
- const pattern0 = new RegExp("^evt_[a-f0-9]{64}$", "u");
187
- const pattern1 = new RegExp("^(?:(?:\\d{4}-(?:(?:01|03|05|07|08|10|12)-(?:0[1-9]|[12]\\d|3[01])|(?:04|06|09|11)-(?:0[1-9]|[12]\\d|30)|02-(?:0[1-9]|1\\d|2[0-8])))|(?:(?:[02468][048]00|[13579][26]00|\\d{2}(?:0[48]|[2468][048]|[13579][26]))-02-29))$", "u");
188
- const pattern4 = new RegExp("^https?://", "u");
189
+ const pattern0 = /* @__PURE__ */ new RegExp("^evt_[a-f0-9]{64}$", "u");
190
+ const pattern1 = /* @__PURE__ */ new RegExp("^(?:(?:\\d{4}-(?:(?:01|03|05|07|08|10|12)-(?:0[1-9]|[12]\\d|3[01])|(?:04|06|09|11)-(?:0[1-9]|[12]\\d|30)|02-(?:0[1-9]|1\\d|2[0-8])))|(?:(?:[02468][048]00|[13579][26]00|\\d{2}(?:0[48]|[2468][048]|[13579][26]))-02-29))$", "u");
191
+ const pattern4 = /* @__PURE__ */ new RegExp("^https?://", "u");
189
192
  const formats0 = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])[T\t ](?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:[Zz]|[+-](?:[01]\d|2[0-3]):?[0-5]\d)$/;
190
193
  const formats4 = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
191
- const pattern2 = new RegExp("^[a-fA-F0-9]{64}$", "u");
194
+ const pattern2 = /* @__PURE__ */ new RegExp("^[a-fA-F0-9]{64}$", "u");
192
195
  function validate12(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
193
196
  let vErrors = null;
194
197
  let errors = 0;
@@ -5628,7 +5631,6 @@ function validate10(data, { instancePath = "", parentData, parentDataProperty, r
5628
5631
  validate10.errors = vErrors;
5629
5632
  return errors === 0;
5630
5633
  }
5631
-
5632
5634
  //#endregion
5633
5635
  //#region src/webhook/errors.ts
5634
5636
  /**
@@ -5847,7 +5849,6 @@ var RawEmailDecodeError = class extends PrimitiveWebhookError {
5847
5849
  this.suggestion = RAW_EMAIL_ERRORS[code].suggestion;
5848
5850
  }
5849
5851
  };
5850
-
5851
5852
  //#endregion
5852
5853
  //#region src/validation.ts
5853
5854
  const validateSchema = email_received_event_validator_generated_default;
@@ -5871,7 +5872,7 @@ function resolveValueAtPath(input, instancePath) {
5871
5872
  current = current[key];
5872
5873
  continue;
5873
5874
  }
5874
- return void 0;
5875
+ return;
5875
5876
  }
5876
5877
  return current;
5877
5878
  }
@@ -5942,10 +5943,9 @@ function formatValidationIssue(error, input) {
5942
5943
  }
5943
5944
  case "format": {
5944
5945
  const format = String(error.params.format ?? "unknown format");
5945
- const humanFormat = format === "uri" ? "valid URI" : `valid ${format}`;
5946
5946
  return {
5947
5947
  field,
5948
- message: `Invalid value for ${field}: must be a ${humanFormat}`,
5948
+ message: `Invalid value for ${field}: must be a ${format === "uri" ? "valid URI" : `valid ${format}`}`,
5949
5949
  suggestion: field.endsWith("url") ? `Check that ${fromFieldLabel(field)} is a complete URL including the scheme.` : `Check the format of ${fromFieldLabel(field)} in the webhook payload.`
5950
5950
  };
5951
5951
  }
@@ -5980,10 +5980,9 @@ function formatValidationIssue(error, input) {
5980
5980
  }
5981
5981
  case "minItems": {
5982
5982
  const limit = Number(error.params.limit ?? 0);
5983
- const itemLabel = limit === 1 ? "item" : "items";
5984
5983
  return {
5985
5984
  field,
5986
- message: `Invalid value for ${field}: must have at least ${limit} ${itemLabel}`,
5985
+ message: `Invalid value for ${field}: must have at least ${limit} ${limit === 1 ? "item" : "items"}`,
5987
5986
  suggestion: `Add more entries to ${fromFieldLabel(field)} in the webhook payload.`
5988
5987
  };
5989
5988
  }
@@ -6000,22 +5999,16 @@ function formatValidationIssue(error, input) {
6000
5999
  suggestion: `Check that ${fromFieldLabel(field)} meets the minimum length requirement.`
6001
6000
  };
6002
6001
  }
6003
- case "minimum": {
6004
- const limit = Number(error.params.limit ?? 0);
6005
- return {
6006
- field,
6007
- message: `Invalid value for ${field}: must be >= ${limit}`,
6008
- suggestion: `Check that ${fromFieldLabel(field)} meets the minimum allowed value.`
6009
- };
6010
- }
6011
- case "maximum": {
6012
- const limit = Number(error.params.limit ?? 0);
6013
- return {
6014
- field,
6015
- message: `Invalid value for ${field}: must be <= ${limit}`,
6016
- suggestion: `Check that ${fromFieldLabel(field)} stays within the maximum allowed value.`
6017
- };
6018
- }
6002
+ case "minimum": return {
6003
+ field,
6004
+ message: `Invalid value for ${field}: must be >= ${Number(error.params.limit ?? 0)}`,
6005
+ suggestion: `Check that ${fromFieldLabel(field)} meets the minimum allowed value.`
6006
+ };
6007
+ case "maximum": return {
6008
+ field,
6009
+ message: `Invalid value for ${field}: must be <= ${Number(error.params.limit ?? 0)}`,
6010
+ suggestion: `Check that ${fromFieldLabel(field)} stays within the maximum allowed value.`
6011
+ };
6019
6012
  default: return {
6020
6013
  field,
6021
6014
  message: `Validation failed for ${field}: ${error.message ?? error.keyword}`,
@@ -6043,9 +6036,31 @@ function safeValidateEmailReceivedEvent(input) {
6043
6036
  data: input
6044
6037
  };
6045
6038
  }
6046
-
6047
6039
  //#endregion
6048
6040
  //#region src/webhook/download-tokens.ts
6041
+ /**
6042
+ * Signed download tokens.
6043
+ *
6044
+ * A download token is a self-describing bearer credential for fetching a
6045
+ * specific email's raw bytes or attachment bundle from a per-deployment
6046
+ * download endpoint. It binds:
6047
+ *
6048
+ * - `email_id` — the specific email the token authorizes.
6049
+ * - `aud` — a caller-chosen audience label (e.g. the resource kind being
6050
+ * downloaded). Tokens minted for one audience will not verify under another.
6051
+ * - `exp` — an absolute expiration time (unix seconds).
6052
+ *
6053
+ * Format: `<base64url(payload)>.<base64url(signature)>` where `signature`
6054
+ * is HMAC-SHA256 over the base64url-encoded payload using the shared secret.
6055
+ *
6056
+ * The audience is an opaque caller-chosen string. Both the issuer and the
6057
+ * verifier must agree on the exact bytes; the SDK does not prescribe a
6058
+ * convention. New integrations are encouraged to namespace audiences
6059
+ * (e.g. `primitive:raw-download`).
6060
+ *
6061
+ * Tokens are stateless: verification needs only the shared secret. Keep
6062
+ * expirations as short as operationally tolerable.
6063
+ */
6049
6064
  const BASE64URL_PATTERN = /^[A-Za-z0-9_-]+$/;
6050
6065
  /**
6051
6066
  * Issue a signed download token.
@@ -6060,15 +6075,13 @@ const BASE64URL_PATTERN = /^[A-Za-z0-9_-]+$/;
6060
6075
  */
6061
6076
  function generateDownloadToken(params) {
6062
6077
  const { emailId, expiresAt, audience, secret } = params;
6063
- const payload = {
6078
+ const payloadJson = JSON.stringify({
6064
6079
  email_id: emailId,
6065
6080
  exp: expiresAt,
6066
6081
  aud: audience
6067
- };
6068
- const payloadJson = JSON.stringify(payload);
6082
+ });
6069
6083
  const payloadStr = Buffer.from(payloadJson, "utf8").toString("base64url");
6070
- const signature = createHmac("sha256", secret).update(payloadStr).digest("base64url");
6071
- return `${payloadStr}.${signature}`;
6084
+ return `${payloadStr}.${createHmac("sha256", secret).update(payloadStr).digest("base64url")}`;
6072
6085
  }
6073
6086
  /**
6074
6087
  * Verify a signed download token.
@@ -6132,16 +6145,17 @@ function verifyDownloadToken(params) {
6132
6145
  valid: false,
6133
6146
  error: "Email ID mismatch"
6134
6147
  };
6135
- const now = nowSeconds ?? Math.floor(Date.now() / 1e3);
6136
- if (exp <= now) return {
6148
+ if (exp <= (nowSeconds ?? Math.floor(Date.now() / 1e3))) return {
6137
6149
  valid: false,
6138
6150
  error: "Token is expired"
6139
6151
  };
6140
6152
  return { valid: true };
6141
6153
  }
6142
-
6143
6154
  //#endregion
6144
6155
  //#region src/webhook/encoding.ts
6156
+ /**
6157
+ * Buffer encoding utilities
6158
+ */
6145
6159
  const utf8Decoder = new TextDecoder("utf-8", { fatal: true });
6146
6160
  /**
6147
6161
  * Convert a Buffer to string with strict UTF-8 validation.
@@ -6162,15 +6176,28 @@ function bufferToString(buffer, label) {
6162
6176
  throw new WebhookPayloadError("INVALID_ENCODING", `${label} contains invalid UTF-8 bytes`, `Ensure the ${label} is valid UTF-8 encoded text. If the data is binary, it should be base64 encoded first.`, err instanceof Error ? err : void 0);
6163
6177
  }
6164
6178
  }
6165
-
6166
6179
  //#endregion
6167
6180
  //#region src/webhook/signing.ts
6168
6181
  /**
6182
+ * Webhook HMAC Signing (Stripe-style format)
6183
+ *
6184
+ * Implements HMAC-SHA256 signature for webhook security with timestamp validation.
6185
+ * Prevents replay attacks by including timestamp in signature.
6186
+ *
6187
+ * Header format:
6188
+ * Primitive-Signature: t=<unix_seconds>,v1=<hex_hmac_sha256>
6189
+ *
6190
+ * Signed payload format: "{timestamp}.{raw_body}"
6191
+ *
6192
+ * This format matches Stripe's webhook signature scheme, which is widely understood
6193
+ * and easy to implement in any language with ~15 lines of code.
6194
+ */
6195
+ /**
6169
6196
  * WeakMap cache for computed signatures.
6170
6197
  * Only works for Buffer bodies (strings cannot be WeakMap keys).
6171
6198
  * Automatically garbage collected when Buffer is no longer referenced.
6172
6199
  */
6173
- const signatureCache = new WeakMap();
6200
+ const signatureCache = /* @__PURE__ */ new WeakMap();
6174
6201
  /**
6175
6202
  * Hash a secret for cache key comparison.
6176
6203
  * @internal
@@ -6187,7 +6214,7 @@ const PRIMITIVE_CONFIRMED_HEADER = "X-Primitive-Confirmed";
6187
6214
  /** Legacy confirmed header name kept for backward compatibility */
6188
6215
  const LEGACY_CONFIRMED_HEADER = "X-MyMX-Confirmed";
6189
6216
  /** Default max age for webhook requests (5 minutes) */
6190
- const DEFAULT_TOLERANCE_SECONDS$1 = 5 * 60;
6217
+ const DEFAULT_TOLERANCE_SECONDS$1 = 300;
6191
6218
  /** Future clock skew tolerance (1 minute) */
6192
6219
  const FUTURE_TOLERANCE_SECONDS$1 = 60;
6193
6220
  /** Valid hex pattern for signature verification */
@@ -6208,8 +6235,7 @@ const UNIX_SECONDS_PATTERN = /^\d+$/;
6208
6235
  */
6209
6236
  function signWebhookPayload(rawBody, secret, timestamp) {
6210
6237
  const ts = timestamp ?? Math.floor(Date.now() / 1e3);
6211
- const body = typeof rawBody === "string" ? rawBody : bufferToString(rawBody, "rawBody");
6212
- const signedPayloadString = `${ts}.${body}`;
6238
+ const signedPayloadString = `${ts}.${typeof rawBody === "string" ? rawBody : bufferToString(rawBody, "rawBody")}`;
6213
6239
  const hmac = createHmac("sha256", secret);
6214
6240
  hmac.update(signedPayloadString);
6215
6241
  const v1 = hmac.digest("hex");
@@ -6288,8 +6314,7 @@ function verifyWebhookSignature(opts) {
6288
6314
  const parsed = parseSignatureHeader(signatureHeader);
6289
6315
  if (!parsed) throw new WebhookVerificationError("INVALID_SIGNATURE_HEADER", "Invalid Primitive-Signature header format. Expected: t={timestamp},v1={signature}");
6290
6316
  const { timestamp, signatures } = parsed;
6291
- const now = nowSeconds ?? Math.floor(Date.now() / 1e3);
6292
- const age = now - timestamp;
6317
+ const age = (nowSeconds ?? Math.floor(Date.now() / 1e3)) - timestamp;
6293
6318
  if (age > toleranceSeconds) throw new WebhookVerificationError("TIMESTAMP_OUT_OF_RANGE", `Webhook timestamp too old (${age}s). Max age is ${toleranceSeconds}s.`);
6294
6319
  if (age < -FUTURE_TOLERANCE_SECONDS$1) throw new WebhookVerificationError("TIMESTAMP_OUT_OF_RANGE", "Webhook timestamp is too far in the future. Check server clock sync.");
6295
6320
  const body = typeof rawBody === "string" ? rawBody : bufferToString(rawBody, "request body");
@@ -6318,13 +6343,10 @@ function verifyWebhookSignature(opts) {
6318
6343
  }
6319
6344
  for (const receivedHex of signatures) {
6320
6345
  if (!isValidHex(receivedHex, 64)) continue;
6321
- const receivedBytes = Buffer.from(receivedHex, "hex");
6322
- const expectedBytes = Buffer.from(expectedHex, "hex");
6323
- if (timingSafeEqual(receivedBytes, expectedBytes)) return true;
6346
+ if (timingSafeEqual(Buffer.from(receivedHex, "hex"), Buffer.from(expectedHex, "hex"))) return true;
6324
6347
  }
6325
6348
  const reserializationHint = detectReserializedBody(body);
6326
- const message = reserializationHint ? `No valid signature found. ${reserializationHint}` : "No valid signature found. Verify the webhook secret matches and you're using the raw request body (not re-serialized JSON).";
6327
- throw new WebhookVerificationError("SIGNATURE_MISMATCH", message);
6349
+ throw new WebhookVerificationError("SIGNATURE_MISMATCH", reserializationHint ? `No valid signature found. ${reserializationHint}` : "No valid signature found. Verify the webhook secret matches and you're using the raw request body (not re-serialized JSON).");
6328
6350
  }
6329
6351
  /**
6330
6352
  * Detect if a body looks like it was re-serialized by a framework.
@@ -6335,13 +6357,27 @@ function detectReserializedBody(body) {
6335
6357
  if (/^\s*\{[\s\S]*\n\s{2,}/.test(body)) return "Request body appears re-serialized (pretty-printed). Use the raw request body before any JSON.parse() or JSON.stringify() calls.";
6336
6358
  return null;
6337
6359
  }
6338
-
6339
6360
  //#endregion
6340
6361
  //#region src/webhook/standard-webhooks.ts
6362
+ /**
6363
+ * Standard Webhooks Verification & Signing
6364
+ *
6365
+ * Implements the Standard Webhooks spec (standardwebhooks.com) for webhook
6366
+ * signature verification and payload signing.
6367
+ *
6368
+ * Header format:
6369
+ * webhook-id: <msg_id>
6370
+ * webhook-timestamp: <unix_seconds>
6371
+ * webhook-signature: v1,<base64_hmac_sha256> [v1,<base64_2> ...]
6372
+ *
6373
+ * Signed payload format: "{msg_id}.{timestamp}.{raw_body}"
6374
+ *
6375
+ * Secrets are base64-encoded, optionally prefixed with "whsec_".
6376
+ */
6341
6377
  const WHSEC_PREFIX = "whsec_";
6342
6378
  const BASE64_PATTERN$1 = /^[A-Za-z0-9+/]*={0,2}$/;
6343
6379
  /** Default max age for webhook requests (5 minutes) */
6344
- const DEFAULT_TOLERANCE_SECONDS = 5 * 60;
6380
+ const DEFAULT_TOLERANCE_SECONDS = 300;
6345
6381
  /** Future clock skew tolerance (1 minute) */
6346
6382
  const FUTURE_TOLERANCE_SECONDS = 60;
6347
6383
  /** Standard Webhooks header names */
@@ -6362,7 +6398,7 @@ function prepareStandardWebhooksSecret(secret) {
6362
6398
  return secret;
6363
6399
  }
6364
6400
  let keyStr = secret;
6365
- if (keyStr.startsWith(WHSEC_PREFIX)) keyStr = keyStr.slice(WHSEC_PREFIX.length);
6401
+ if (keyStr.startsWith(WHSEC_PREFIX)) keyStr = keyStr.slice(6);
6366
6402
  if (!keyStr || !BASE64_PATTERN$1.test(keyStr)) throw new WebhookVerificationError("MISSING_SECRET", "Standard Webhooks secret must be base64-encoded (optionally with whsec_ prefix)");
6367
6403
  const decoded = Buffer.from(keyStr, "base64");
6368
6404
  if (decoded.length === 0) throw new WebhookVerificationError("MISSING_SECRET", "Webhook secret is required but was empty or not provided");
@@ -6404,9 +6440,8 @@ function signStandardWebhooksPayload(rawBody, secret, msgId, timestamp) {
6404
6440
  const key = prepareStandardWebhooksSecret(secret);
6405
6441
  if (key.length === 0) throw new WebhookVerificationError("MISSING_SECRET", "Webhook secret is required but was empty or not provided");
6406
6442
  const signedPayload = `${msgId}.${ts}.${body}`;
6407
- const sig = createHmac("sha256", key).update(signedPayload).digest("base64");
6408
6443
  return {
6409
- signature: `v1,${sig}`,
6444
+ signature: `v1,${createHmac("sha256", key).update(signedPayload).digest("base64")}`,
6410
6445
  msgId,
6411
6446
  timestamp: ts
6412
6447
  };
@@ -6423,12 +6458,10 @@ function verifyStandardWebhooksSignature(opts) {
6423
6458
  if (!timestampStr || !/^\d+$/.test(timestampStr)) throw new WebhookVerificationError("INVALID_SIGNATURE_HEADER", `Invalid webhook-timestamp header: "${timestampStr}". Expected a unix timestamp in seconds`);
6424
6459
  const timestamp = Number(timestampStr);
6425
6460
  if (!Number.isInteger(timestamp) || timestamp < 0) throw new WebhookVerificationError("INVALID_SIGNATURE_HEADER", `Invalid webhook-timestamp header: "${timestampStr}". Expected a unix timestamp in seconds`);
6426
- const now = nowSeconds ?? Math.floor(Date.now() / 1e3);
6427
- const age = now - timestamp;
6461
+ const age = (nowSeconds ?? Math.floor(Date.now() / 1e3)) - timestamp;
6428
6462
  if (age > toleranceSeconds) throw new WebhookVerificationError("TIMESTAMP_OUT_OF_RANGE", `Webhook timestamp too old (${age}s). Max age is ${toleranceSeconds}s.`);
6429
6463
  if (age < -FUTURE_TOLERANCE_SECONDS) throw new WebhookVerificationError("TIMESTAMP_OUT_OF_RANGE", "Webhook timestamp is too far in the future. Check server clock sync.");
6430
- const body = typeof rawBody === "string" ? rawBody : bufferToString(rawBody, "request body");
6431
- const signedPayload = `${msgId}.${timestamp}.${body}`;
6464
+ const signedPayload = `${msgId}.${timestamp}.${typeof rawBody === "string" ? rawBody : bufferToString(rawBody, "request body")}`;
6432
6465
  const expectedSig = createHmac("sha256", key).update(signedPayload).digest("base64");
6433
6466
  const signatures = parseStandardWebhooksSignatures(signatureHeader);
6434
6467
  if (signatures.length === 0) throw new WebhookVerificationError("INVALID_SIGNATURE_HEADER", "Invalid webhook-signature header format. Expected: \"v1,<base64>\"");
@@ -6440,7 +6473,6 @@ function verifyStandardWebhooksSignature(opts) {
6440
6473
  }
6441
6474
  throw new WebhookVerificationError("SIGNATURE_MISMATCH", "No valid signature found. Verify the webhook secret matches and you're using the raw request body (not re-serialized JSON).");
6442
6475
  }
6443
-
6444
6476
  //#endregion
6445
6477
  //#region src/schema.generated.ts
6446
6478
  const emailReceivedEventJsonSchema = {
@@ -7332,7 +7364,6 @@ const emailReceivedEventJsonSchema = {
7332
7364
  }
7333
7365
  }
7334
7366
  };
7335
-
7336
7367
  //#endregion
7337
7368
  //#region src/types.ts
7338
7369
  const EventType = { EmailReceived: "email.received" };
@@ -7381,7 +7412,6 @@ const AuthVerdict = {
7381
7412
  Suspicious: "suspicious",
7382
7413
  Unknown: "unknown"
7383
7414
  };
7384
-
7385
7415
  //#endregion
7386
7416
  //#region src/webhook/auth.ts
7387
7417
  /**
@@ -7578,7 +7608,6 @@ function validateEmailAuth(auth) {
7578
7608
  reasons: ["Unable to determine email authenticity"]
7579
7609
  };
7580
7610
  }
7581
-
7582
7611
  //#endregion
7583
7612
  //#region src/webhook/version.ts
7584
7613
  /**
@@ -7594,10 +7623,13 @@ function validateEmailAuth(auth) {
7594
7623
  * need to handle version-specific behavior.
7595
7624
  */
7596
7625
  const WEBHOOK_VERSION = "2025-12-14";
7597
-
7598
7626
  //#endregion
7599
7627
  //#region src/webhook/parsing.ts
7600
7628
  /**
7629
+ * JSON parsing utilities with helpful error messages.
7630
+ * @internal
7631
+ */
7632
+ /**
7601
7633
  * Parse a raw body string/Buffer into JSON with helpful error messages.
7602
7634
  *
7603
7635
  * Handles:
@@ -7618,12 +7650,10 @@ function parseJsonBody(rawBody) {
7618
7650
  return JSON.parse(cleanBody);
7619
7651
  } catch (e) {
7620
7652
  const jsonError = e;
7621
- const positionMatch = jsonError.message.match(/position\s*(\d+)/i);
7622
- const position = positionMatch?.[1];
7653
+ const position = jsonError.message.match(/position\s*(\d+)/i)?.[1];
7623
7654
  throw new WebhookPayloadError("JSON_PARSE_FAILED", "Failed to parse webhook body as JSON", position ? `Invalid JSON at position ${position}. Check your web framework isn't truncating the request body.` : `Invalid JSON: ${jsonError.message}. Check the raw request body is valid JSON.`, jsonError);
7624
7655
  }
7625
7656
  }
7626
-
7627
7657
  //#endregion
7628
7658
  //#region src/webhook/index.ts
7629
7659
  const BASE64_PATTERN = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
@@ -7818,17 +7848,13 @@ function handleWebhook(options) {
7818
7848
  secret,
7819
7849
  toleranceSeconds
7820
7850
  });
7821
- else {
7822
- const signature = getSignatureHeader(headers);
7823
- verifyWebhookSignature({
7824
- rawBody: body,
7825
- signatureHeader: signature,
7826
- secret,
7827
- toleranceSeconds
7828
- });
7829
- }
7830
- const parsed = parseJsonBody(body);
7831
- return validateEmailReceivedEvent(parsed);
7851
+ else verifyWebhookSignature({
7852
+ rawBody: body,
7853
+ signatureHeader: getSignatureHeader(headers),
7854
+ secret,
7855
+ toleranceSeconds
7856
+ });
7857
+ return validateEmailReceivedEvent(parseJsonBody(body));
7832
7858
  }
7833
7859
  function receive(input, options) {
7834
7860
  if (input instanceof Request) return receiveFromRequest(input, options);
@@ -7836,9 +7862,8 @@ function receive(input, options) {
7836
7862
  }
7837
7863
  async function receiveFromRequest(request, options) {
7838
7864
  if (!options?.secret) throw new WebhookVerificationError("MISSING_SECRET", "Webhook secret is required but was empty or not provided");
7839
- const body = Buffer.from(await request.arrayBuffer());
7840
7865
  return normalizeReceivedEmail(handleWebhook({
7841
- body,
7866
+ body: Buffer.from(await request.arrayBuffer()),
7842
7867
  headers: request.headers,
7843
7868
  secret: options.secret,
7844
7869
  toleranceSeconds: options.toleranceSeconds
@@ -7900,8 +7925,7 @@ function confirmedHeaders() {
7900
7925
  * ```
7901
7926
  */
7902
7927
  function isDownloadExpired(event, now = Date.now()) {
7903
- const expiresAt = new Date(event.email.content.download.expires_at).getTime();
7904
- return now >= expiresAt;
7928
+ return now >= new Date(event.email.content.download.expires_at).getTime();
7905
7929
  }
7906
7930
  /**
7907
7931
  * Get the time remaining (in milliseconds) before the download URL expires.
@@ -8016,6 +8040,5 @@ function verifyRawEmailDownload(downloaded, event) {
8016
8040
  if (hash !== expected.toLowerCase()) throw new RawEmailDecodeError("HASH_MISMATCH", `SHA-256 hash mismatch. Expected: ${expected}, got: ${hash}. The downloaded content may be corrupted.`);
8017
8041
  return buffer;
8018
8042
  }
8019
-
8020
8043
  //#endregion
8021
- 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, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
8044
+ export { PRIMITIVE_CONFIRMED_HEADER as A, RAW_EMAIL_ERRORS as B, STANDARD_WEBHOOK_ID_HEADER as C, verifyStandardWebhooksSignature as D, signStandardWebhooksPayload as E, verifyDownloadToken as F, WebhookVerificationError as G, VERIFICATION_ERRORS as H, safeValidateEmailReceivedEvent as I, validateEmailReceivedEvent as L, signWebhookPayload as M, verifyWebhookSignature as N, LEGACY_CONFIRMED_HEADER as O, generateDownloadToken as P, PAYLOAD_ERRORS as R, emailReceivedEventJsonSchema as S, STANDARD_WEBHOOK_TIMESTAMP_HEADER as T, WebhookPayloadError as U, RawEmailDecodeError as V, WebhookValidationError as W, DmarcResult as _, isDownloadExpired as a, ParsedStatus as b, parseWebhookEvent as c, WEBHOOK_VERSION as d, validateEmailAuth as f, DmarcPolicy as g, DkimResult as h, handleWebhook as i, PRIMITIVE_SIGNATURE_HEADER as j, LEGACY_SIGNATURE_HEADER as k, receive as l, AuthVerdict as m, decodeRawEmail as n, isEmailReceivedEvent as o, AuthConfidence as p, getDownloadTimeRemaining as r, isRawIncluded as s, confirmedHeaders as t, verifyRawEmailDownload as u, EventType as v, STANDARD_WEBHOOK_SIGNATURE_HEADER as w, SpfResult as x, ForwardVerdict as y, PrimitiveWebhookError as z };
@@ -173,7 +173,7 @@
173
173
  "account:update-account": {
174
174
  "aliases": [],
175
175
  "args": {},
176
- "description": "PATCH /account",
176
+ "description": "PATCH /account\n\nBody fields (JSON --body):\n discard_content_on_webhook_confirmed boolean Whether to discard email content after the webhook endpoint confirms receipt.\n spam_threshold number? Global spam score threshold (0-15). Emails scoring above this are rejected....\n(* = required)",
177
177
  "flags": {
178
178
  "api-key": {
179
179
  "description": "Primitive API key (defaults to PRIMITIVE_API_KEY)",
@@ -219,7 +219,7 @@
219
219
  "domains:add-domain": {
220
220
  "aliases": [],
221
221
  "args": {},
222
- "description": "Creates an unverified domain claim. You will receive a\n`verification_token` to add as a DNS TXT record before\ncalling the verify endpoint.\n",
222
+ "description": "Creates an unverified domain claim. You will receive a\n`verification_token` to add as a DNS TXT record before\ncalling the verify endpoint.\n\n\nBody fields (JSON --body):\n * domain string The domain name to claim (e.g. \"example.com\")\n(* = required)",
223
223
  "flags": {
224
224
  "api-key": {
225
225
  "description": "Primitive API key (defaults to PRIMITIVE_API_KEY)",
@@ -337,7 +337,7 @@
337
337
  "domains:update-domain": {
338
338
  "aliases": [],
339
339
  "args": {},
340
- "description": "Update a verified domain's settings. Only verified domains can be\nupdated. Per-domain spam thresholds require a Pro plan.\n",
340
+ "description": "Update a verified domain's settings. Only verified domains can be\nupdated. Per-domain spam thresholds require a Pro plan.\n\n\nBody fields (JSON --body):\n is_active boolean Whether the domain accepts incoming emails\n spam_threshold number? Per-domain spam threshold override (Pro plan required)\n(* = required)",
341
341
  "flags": {
342
342
  "api-key": {
343
343
  "description": "Primitive API key (defaults to PRIMITIVE_API_KEY)",
@@ -755,7 +755,7 @@
755
755
  "endpoints:create-endpoint": {
756
756
  "aliases": [],
757
757
  "args": {},
758
- "description": "Creates a new webhook endpoint. If a deactivated endpoint with the\nsame URL and domain exists, it is reactivated instead.\nSubject to plan limits on the number of active endpoints.\n",
758
+ "description": "Creates a new webhook endpoint. If a deactivated endpoint with the\nsame URL and domain exists, it is reactivated instead.\nSubject to plan limits on the number of active endpoints.\n\n\nBody fields (JSON --body):\n * url string The webhook URL to deliver events to\n domain_id string? Restrict to emails from a specific domain\n enabled boolean Whether the endpoint is active\n rules object Endpoint-specific filtering rules\n(* = required)",
759
759
  "flags": {
760
760
  "api-key": {
761
761
  "description": "Primitive API key (defaults to PRIMITIVE_API_KEY)",
@@ -913,7 +913,7 @@
913
913
  "endpoints:update-endpoint": {
914
914
  "aliases": [],
915
915
  "args": {},
916
- "description": "Updates an active webhook endpoint. If the URL is changed, the old\nendpoint is deactivated and a new one is created (or an existing\ndeactivated endpoint with the new URL is reactivated).\n",
916
+ "description": "Updates an active webhook endpoint. If the URL is changed, the old\nendpoint is deactivated and a new one is created (or an existing\ndeactivated endpoint with the new URL is reactivated).\n\n\nBody fields (JSON --body):\n domain_id string?\n enabled boolean\n rules object\n url string New webhook URL (triggers endpoint rotation)\n(* = required)",
917
917
  "flags": {
918
918
  "api-key": {
919
919
  "description": "Primitive API key (defaults to PRIMITIVE_API_KEY)",
@@ -967,7 +967,7 @@
967
967
  "filters:create-filter": {
968
968
  "aliases": [],
969
969
  "args": {},
970
- "description": "Creates a new whitelist or blocklist filter. Per-domain filters\nrequire a Pro plan. Patterns are stored as lowercase.\n",
970
+ "description": "Creates a new whitelist or blocklist filter. Per-domain filters\nrequire a Pro plan. Patterns are stored as lowercase.\n\n\nBody fields (JSON --body):\n * pattern string Email address or pattern to filter\n * type string\n domain_id string? Restrict filter to a specific domain (Pro plan required)\n(* = required)",
971
971
  "flags": {
972
972
  "api-key": {
973
973
  "description": "Primitive API key (defaults to PRIMITIVE_API_KEY)",
@@ -1085,7 +1085,7 @@
1085
1085
  "filters:update-filter": {
1086
1086
  "aliases": [],
1087
1087
  "args": {},
1088
- "description": "Toggle a filter's enabled state.",
1088
+ "description": "Toggle a filter's enabled state.\n\nBody fields (JSON --body):\n * enabled boolean\n(* = required)",
1089
1089
  "flags": {
1090
1090
  "api-key": {
1091
1091
  "description": "Primitive API key (defaults to PRIMITIVE_API_KEY)",
@@ -1139,7 +1139,7 @@
1139
1139
  "sending:send-email": {
1140
1140
  "aliases": [],
1141
1141
  "args": {},
1142
- "description": "Sends an outbound email through Primitive's outbound relay. By default\nthe request returns once the relay accepts the message for delivery.\nSet `wait: true` to wait for the first downstream SMTP delivery outcome.\n",
1142
+ "description": "Sends an outbound email through Primitive's outbound relay. By default\nthe request returns once the relay accepts the message for delivery.\nSet `wait: true` to wait for the first downstream SMTP delivery outcome.\n\n\nBody fields (JSON --body):\n * from string RFC 5322 From header. The sender domain must be a verified outbound domain ...\n * subject string Subject line for the outbound message\n * to string Recipient address. Recipient eligibility depends on your account's outbound...\n body_html string HTML message body. At least one of body_text or body_html is required. The ...\n body_text string Plain-text message body. At least one of body_text or body_html is required...\n in_reply_to string Message-ID of the direct parent email when sending a threaded reply.\n references array<string> Full ordered message-id chain for the thread.\n wait boolean When true, wait for the first downstream SMTP delivery outcome before retur...\n wait_timeout_ms integer Maximum time to wait for a delivery outcome when wait is true. Defaults to ...\n(* = required)",
1143
1143
  "flags": {
1144
1144
  "api-key": {
1145
1145
  "description": "Primitive API key (defaults to PRIMITIVE_API_KEY)",
@@ -1309,5 +1309,5 @@
1309
1309
  "enableJsonFlag": false
1310
1310
  }
1311
1311
  },
1312
- "version": "0.8.0"
1312
+ "version": "0.9.0"
1313
1313
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primitivedotdev/sdk",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Official Primitive Node.js SDK — webhook, api, openapi, contract, and parser modules",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",
@@ -152,7 +152,7 @@
152
152
  "json-schema-to-typescript": "^15.0.4",
153
153
  "oclif": "^4.23.0",
154
154
  "shx": "^0.3.4",
155
- "tsdown": "^0.9.1",
155
+ "tsdown": "^0.21.10",
156
156
  "tsx": "^4.21.0",
157
157
  "typescript": "^5.7.2",
158
158
  "vite": "^8.0.8",
@@ -1,11 +0,0 @@
1
- //#region rolldown:runtime
2
- var __defProp = Object.defineProperty;
3
- var __export = (target, all) => {
4
- for (var name in all) __defProp(target, name, {
5
- get: all[name],
6
- enumerable: true
7
- });
8
- };
9
-
10
- //#endregion
11
- export { __export };