@primitivedotdev/sdk 1.3.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/api/index.d.ts +4 -4
- package/dist/api/index.js +3 -3
- package/dist/{api-DacG4JSU.js → api-DrrmrNDe.js} +257 -22
- package/dist/contract/index.d.ts +2 -2
- package/dist/contract/index.js +1 -1
- package/dist/{errors-7E9sW9eX.d.ts → errors-DyuAXctD.d.ts} +1 -1
- package/dist/{index-X7RsDaVi.d.ts → index--2RzTxVl.d.ts} +361 -7
- package/dist/{index-DR978rq5.d.ts → index-iZWfb98V.d.ts} +275 -4
- package/dist/index.d.ts +6 -184
- package/dist/index.js +4 -194
- package/dist/openapi/index.js +1 -1
- package/dist/{operations.generated-DSMTMcWh.js → operations.generated-CA3-eorF.js} +453 -3
- package/dist/parser/index.d.ts +1 -1
- package/dist/{types-yNU-Oiea.d.ts → types-QT2ss9ho.d.ts} +207 -3
- package/dist/webhook/index.d.ts +4 -4
- package/dist/webhook/index.js +1 -1
- package/dist/{webhook-BAwK8EOG.js → webhook-CwjCyFv-.js} +2559 -224
- package/dist/x402/index.d.ts +263 -0
- package/dist/x402/index.js +320 -0
- package/package.json +6 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { m as ReceivedEmail, u as WebhookValidationError } from "./errors-
|
|
1
|
+
import { I as WebhookEvent, P as ValidateEmailAuthResult, d as EmailAuth, f as EmailReceivedEvent } from "./types-QT2ss9ho.js";
|
|
2
|
+
import { m as ReceivedEmail, u as WebhookValidationError } from "./errors-DyuAXctD.js";
|
|
3
3
|
|
|
4
4
|
//#region src/validation.d.ts
|
|
5
5
|
interface ValidationSuccess<T> {
|
|
@@ -281,8 +281,8 @@ declare const emailReceivedEventJsonSchema: {
|
|
|
281
281
|
};
|
|
282
282
|
readonly event: {
|
|
283
283
|
readonly type: "string";
|
|
284
|
-
readonly
|
|
285
|
-
readonly description: "Event type identifier.
|
|
284
|
+
readonly enum: ["email.received", "email.bounced", "email.tls_report", "email.dmarc_report", "email.dmarc_failure"];
|
|
285
|
+
readonly description: "Event type identifier.\n\n- `email.received` - A normal inbound email.\n- `email.bounced` - A delivery status notification (DSN) reporting that a message delivery failed. Carries `email.analysis.bounce`.\n- `email.tls_report` - An SMTP TLS report (RFC 8460). Carries `email.analysis.tls_report`.\n- `email.dmarc_report` - A DMARC aggregate report (RFC 7489). Carries `email.analysis.dmarc_report`.\n- `email.dmarc_failure` - A DMARC failure (forensic) report.\n\nMachine-generated mail (bounces and the report types above) is delivered under its own event type rather than `email.received`, so an endpoint subscribed only to `email.received` receives just normal inbound mail. The payload shape is otherwise identical across event types; the type-specific details live under `email.analysis`.";
|
|
286
286
|
};
|
|
287
287
|
readonly version: {
|
|
288
288
|
readonly $ref: "#/definitions/WebhookVersion";
|
|
@@ -768,9 +768,280 @@ declare const emailReceivedEventJsonSchema: {
|
|
|
768
768
|
readonly $ref: "#/definitions/ForwardAnalysis";
|
|
769
769
|
readonly description: "Forward detection and analysis results.\n\nOptional. Present when the email was processed by a forward-detection pipeline (always present in Primitive's managed service). When absent, forward detection was not performed on this email.";
|
|
770
770
|
};
|
|
771
|
+
readonly bounce: {
|
|
772
|
+
readonly $ref: "#/definitions/BounceAnalysis";
|
|
773
|
+
readonly description: "Bounce (delivery status notification) analysis.\n\nPresent on `email.bounced` events: the parsed DSN reporting that a message you sent could not be delivered. Absent on all other event types.";
|
|
774
|
+
};
|
|
775
|
+
readonly tls_report: {
|
|
776
|
+
readonly $ref: "#/definitions/TlsReportAnalysis";
|
|
777
|
+
readonly description: "SMTP TLS report analysis (RFC 8460).\n\nPresent on `email.tls_report` events: a remote MTA's report of TLS negotiation results for mail sent to your domain. Absent on all other event types.";
|
|
778
|
+
};
|
|
779
|
+
readonly dmarc_report: {
|
|
780
|
+
readonly $ref: "#/definitions/DmarcReportAnalysis";
|
|
781
|
+
readonly description: "DMARC aggregate report analysis (RFC 7489).\n\nPresent on `email.dmarc_report` events: a receiver's periodic aggregate report of DMARC authentication results for your domain. Absent on all other event types.";
|
|
782
|
+
};
|
|
771
783
|
};
|
|
772
784
|
readonly description: "Email analysis and classification results.\n\nAll properties in this object are optional. Which fields are present depends on the analysis pipeline processing the email. Primitive's managed service populates all fields. Self-hosted or third-party deployments may include some, all, or none of these fields depending on their pipeline configuration.\n\nWhen a field is absent, it means that particular analysis was not performed, not that the analysis produced no results. For example, a missing `spamassassin` field means SpamAssassin was not run, not that the email scored 0.\n\nThese fields may be omitted from the payload entirely but must not be set to null.";
|
|
773
785
|
};
|
|
786
|
+
readonly BounceAnalysis: {
|
|
787
|
+
readonly type: "object";
|
|
788
|
+
readonly properties: {
|
|
789
|
+
readonly is_bounce: {
|
|
790
|
+
readonly type: "boolean";
|
|
791
|
+
readonly const: true;
|
|
792
|
+
readonly description: "Always `true` on a parsed bounce.";
|
|
793
|
+
};
|
|
794
|
+
readonly kind: {
|
|
795
|
+
readonly type: "string";
|
|
796
|
+
readonly const: "dsn";
|
|
797
|
+
readonly description: "The machine-mail kind. Always `dsn` for a bounce.";
|
|
798
|
+
};
|
|
799
|
+
readonly type: {
|
|
800
|
+
readonly type: "string";
|
|
801
|
+
readonly enum: ["permanent", "transient", "undetermined"];
|
|
802
|
+
readonly description: "Whether the failure is permanent (hard bounce), transient (soft bounce, may be retried), or undetermined.";
|
|
803
|
+
};
|
|
804
|
+
readonly category: {
|
|
805
|
+
readonly type: "string";
|
|
806
|
+
readonly enum: ["mailbox_does_not_exist", "domain_does_not_exist", "domain_not_accepting_mail", "mailbox_full", "mailbox_inactive", "message_too_large", "content_rejected", "policy_blocked", "auth_failure", "relay_denied", "rate_limited", "network_error", "recipient_moved", "expired", "undetermined"];
|
|
807
|
+
readonly description: "Best-effort reason category for the failure.";
|
|
808
|
+
};
|
|
809
|
+
readonly classified_by: {
|
|
810
|
+
readonly type: "string";
|
|
811
|
+
readonly enum: ["status_code", "smtp_code", "pattern", "provider", "none"];
|
|
812
|
+
readonly description: "Which signal produced `category` (for transparency and debugging).";
|
|
813
|
+
};
|
|
814
|
+
readonly failed_recipient: {
|
|
815
|
+
readonly type: ["string", "null"];
|
|
816
|
+
readonly description: "The recipient address that failed, if the report identifies one.";
|
|
817
|
+
};
|
|
818
|
+
readonly smtp_code: {
|
|
819
|
+
readonly type: ["integer", "null"];
|
|
820
|
+
readonly description: "SMTP reply code (e.g. `550`), if reported.";
|
|
821
|
+
};
|
|
822
|
+
readonly status_code: {
|
|
823
|
+
readonly type: ["string", "null"];
|
|
824
|
+
readonly description: "Enhanced mail system status code (RFC 3463, e.g. `5.1.1`), if reported.";
|
|
825
|
+
};
|
|
826
|
+
readonly diagnostic_code: {
|
|
827
|
+
readonly type: ["string", "null"];
|
|
828
|
+
readonly description: "Raw diagnostic text from the reporting MTA, if present.";
|
|
829
|
+
};
|
|
830
|
+
readonly reported_by_mta: {
|
|
831
|
+
readonly type: ["string", "null"];
|
|
832
|
+
readonly description: "The MTA that generated the report, if identifiable.";
|
|
833
|
+
};
|
|
834
|
+
readonly original_message_id: {
|
|
835
|
+
readonly type: ["string", "null"];
|
|
836
|
+
readonly description: "Message-ID of the original message that bounced, if recoverable. Match this against the `message_id` of a message you sent to correlate the bounce.";
|
|
837
|
+
};
|
|
838
|
+
readonly reasons: {
|
|
839
|
+
readonly type: "array";
|
|
840
|
+
readonly items: {
|
|
841
|
+
readonly type: "string";
|
|
842
|
+
};
|
|
843
|
+
readonly description: "Human-readable reason strings extracted from the report.";
|
|
844
|
+
};
|
|
845
|
+
};
|
|
846
|
+
readonly required: ["is_bounce", "kind", "type", "category", "classified_by", "failed_recipient", "smtp_code", "status_code", "diagnostic_code", "reported_by_mta", "original_message_id", "reasons"];
|
|
847
|
+
readonly description: "Parsed delivery status notification (bounce). Present as `email.analysis.bounce` on `email.bounced` events.";
|
|
848
|
+
};
|
|
849
|
+
readonly TlsReportFailure: {
|
|
850
|
+
readonly type: "object";
|
|
851
|
+
readonly properties: {
|
|
852
|
+
readonly result_type: {
|
|
853
|
+
readonly type: ["string", "null"];
|
|
854
|
+
readonly description: "Failure result type (e.g. `certificate-expired`, `starttls-not-supported`).";
|
|
855
|
+
};
|
|
856
|
+
readonly count: {
|
|
857
|
+
readonly type: "integer";
|
|
858
|
+
readonly description: "Number of sessions that hit this failure.";
|
|
859
|
+
};
|
|
860
|
+
readonly sending_mta_ip: {
|
|
861
|
+
readonly type: ["string", "null"];
|
|
862
|
+
};
|
|
863
|
+
readonly receiving_mx_hostname: {
|
|
864
|
+
readonly type: ["string", "null"];
|
|
865
|
+
};
|
|
866
|
+
};
|
|
867
|
+
readonly required: ["result_type", "count", "sending_mta_ip", "receiving_mx_hostname"];
|
|
868
|
+
};
|
|
869
|
+
readonly TlsReportPolicy: {
|
|
870
|
+
readonly type: "object";
|
|
871
|
+
readonly properties: {
|
|
872
|
+
readonly policy_domain: {
|
|
873
|
+
readonly type: ["string", "null"];
|
|
874
|
+
};
|
|
875
|
+
readonly policy_type: {
|
|
876
|
+
readonly type: ["string", "null"];
|
|
877
|
+
readonly description: "Policy type the sessions were evaluated against (e.g. `sts`, `tlsa`, `no-policy-found`).";
|
|
878
|
+
};
|
|
879
|
+
readonly successful_sessions: {
|
|
880
|
+
readonly type: "integer";
|
|
881
|
+
};
|
|
882
|
+
readonly failed_sessions: {
|
|
883
|
+
readonly type: "integer";
|
|
884
|
+
};
|
|
885
|
+
readonly failures: {
|
|
886
|
+
readonly type: "array";
|
|
887
|
+
readonly items: {
|
|
888
|
+
readonly $ref: "#/definitions/TlsReportFailure";
|
|
889
|
+
};
|
|
890
|
+
};
|
|
891
|
+
};
|
|
892
|
+
readonly required: ["policy_domain", "policy_type", "successful_sessions", "failed_sessions", "failures"];
|
|
893
|
+
};
|
|
894
|
+
readonly TlsReportAnalysis: {
|
|
895
|
+
readonly type: "object";
|
|
896
|
+
readonly properties: {
|
|
897
|
+
readonly kind: {
|
|
898
|
+
readonly type: "string";
|
|
899
|
+
readonly const: "tls_report";
|
|
900
|
+
};
|
|
901
|
+
readonly organization: {
|
|
902
|
+
readonly type: ["string", "null"];
|
|
903
|
+
readonly description: "Reporting organization name.";
|
|
904
|
+
};
|
|
905
|
+
readonly report_id: {
|
|
906
|
+
readonly type: ["string", "null"];
|
|
907
|
+
};
|
|
908
|
+
readonly contact: {
|
|
909
|
+
readonly type: ["string", "null"];
|
|
910
|
+
readonly description: "Reporter contact, if provided.";
|
|
911
|
+
};
|
|
912
|
+
readonly date_range: {
|
|
913
|
+
readonly type: "object";
|
|
914
|
+
readonly properties: {
|
|
915
|
+
readonly start: {
|
|
916
|
+
readonly type: ["string", "null"];
|
|
917
|
+
readonly description: "ISO 8601 start of the reporting window.";
|
|
918
|
+
};
|
|
919
|
+
readonly end: {
|
|
920
|
+
readonly type: ["string", "null"];
|
|
921
|
+
readonly description: "ISO 8601 end of the reporting window.";
|
|
922
|
+
};
|
|
923
|
+
};
|
|
924
|
+
readonly required: ["start", "end"];
|
|
925
|
+
};
|
|
926
|
+
readonly total_successful_sessions: {
|
|
927
|
+
readonly type: "integer";
|
|
928
|
+
};
|
|
929
|
+
readonly total_failed_sessions: {
|
|
930
|
+
readonly type: "integer";
|
|
931
|
+
};
|
|
932
|
+
readonly policies: {
|
|
933
|
+
readonly type: "array";
|
|
934
|
+
readonly items: {
|
|
935
|
+
readonly $ref: "#/definitions/TlsReportPolicy";
|
|
936
|
+
};
|
|
937
|
+
};
|
|
938
|
+
};
|
|
939
|
+
readonly required: ["kind", "organization", "report_id", "contact", "date_range", "total_successful_sessions", "total_failed_sessions", "policies"];
|
|
940
|
+
readonly description: "Parsed SMTP TLS report (RFC 8460). Present as `email.analysis.tls_report` on `email.tls_report` events.";
|
|
941
|
+
};
|
|
942
|
+
readonly DmarcRecord: {
|
|
943
|
+
readonly type: "object";
|
|
944
|
+
readonly properties: {
|
|
945
|
+
readonly source_ip: {
|
|
946
|
+
readonly type: ["string", "null"];
|
|
947
|
+
};
|
|
948
|
+
readonly count: {
|
|
949
|
+
readonly type: "integer";
|
|
950
|
+
};
|
|
951
|
+
readonly disposition: {
|
|
952
|
+
readonly type: ["string", "null"];
|
|
953
|
+
readonly description: "Disposition applied by the receiver: `none`, `quarantine`, or `reject`.";
|
|
954
|
+
};
|
|
955
|
+
readonly dkim: {
|
|
956
|
+
readonly type: ["string", "null"];
|
|
957
|
+
readonly description: "DKIM alignment result: `pass` or `fail`.";
|
|
958
|
+
};
|
|
959
|
+
readonly spf: {
|
|
960
|
+
readonly type: ["string", "null"];
|
|
961
|
+
readonly description: "SPF alignment result: `pass` or `fail`.";
|
|
962
|
+
};
|
|
963
|
+
readonly header_from: {
|
|
964
|
+
readonly type: ["string", "null"];
|
|
965
|
+
};
|
|
966
|
+
};
|
|
967
|
+
readonly required: ["source_ip", "count", "disposition", "dkim", "spf", "header_from"];
|
|
968
|
+
};
|
|
969
|
+
readonly DmarcReportAnalysis: {
|
|
970
|
+
readonly type: "object";
|
|
971
|
+
readonly properties: {
|
|
972
|
+
readonly kind: {
|
|
973
|
+
readonly type: "string";
|
|
974
|
+
readonly const: "dmarc_report";
|
|
975
|
+
};
|
|
976
|
+
readonly organization: {
|
|
977
|
+
readonly type: ["string", "null"];
|
|
978
|
+
};
|
|
979
|
+
readonly report_id: {
|
|
980
|
+
readonly type: ["string", "null"];
|
|
981
|
+
};
|
|
982
|
+
readonly date_range: {
|
|
983
|
+
readonly type: "object";
|
|
984
|
+
readonly properties: {
|
|
985
|
+
readonly start: {
|
|
986
|
+
readonly type: ["string", "null"];
|
|
987
|
+
readonly description: "ISO 8601 start of the reporting window.";
|
|
988
|
+
};
|
|
989
|
+
readonly end: {
|
|
990
|
+
readonly type: ["string", "null"];
|
|
991
|
+
readonly description: "ISO 8601 end of the reporting window.";
|
|
992
|
+
};
|
|
993
|
+
};
|
|
994
|
+
readonly required: ["start", "end"];
|
|
995
|
+
};
|
|
996
|
+
readonly policy_published: {
|
|
997
|
+
readonly type: "object";
|
|
998
|
+
readonly properties: {
|
|
999
|
+
readonly domain: {
|
|
1000
|
+
readonly type: ["string", "null"];
|
|
1001
|
+
};
|
|
1002
|
+
readonly p: {
|
|
1003
|
+
readonly type: ["string", "null"];
|
|
1004
|
+
readonly description: "Published domain policy: `none`, `quarantine`, or `reject`.";
|
|
1005
|
+
};
|
|
1006
|
+
readonly sp: {
|
|
1007
|
+
readonly type: ["string", "null"];
|
|
1008
|
+
readonly description: "Published subdomain policy.";
|
|
1009
|
+
};
|
|
1010
|
+
readonly pct: {
|
|
1011
|
+
readonly type: ["integer", "null"];
|
|
1012
|
+
readonly description: "Percentage of messages the policy is applied to.";
|
|
1013
|
+
};
|
|
1014
|
+
readonly adkim: {
|
|
1015
|
+
readonly type: ["string", "null"];
|
|
1016
|
+
readonly description: "DKIM alignment mode: `r` (relaxed) or `s` (strict).";
|
|
1017
|
+
};
|
|
1018
|
+
readonly aspf: {
|
|
1019
|
+
readonly type: ["string", "null"];
|
|
1020
|
+
readonly description: "SPF alignment mode: `r` (relaxed) or `s` (strict).";
|
|
1021
|
+
};
|
|
1022
|
+
};
|
|
1023
|
+
readonly required: ["domain", "p", "sp", "pct", "adkim", "aspf"];
|
|
1024
|
+
};
|
|
1025
|
+
readonly total_count: {
|
|
1026
|
+
readonly type: "integer";
|
|
1027
|
+
readonly description: "Total messages covered by the report.";
|
|
1028
|
+
};
|
|
1029
|
+
readonly dkim_pass_count: {
|
|
1030
|
+
readonly type: "integer";
|
|
1031
|
+
};
|
|
1032
|
+
readonly spf_pass_count: {
|
|
1033
|
+
readonly type: "integer";
|
|
1034
|
+
};
|
|
1035
|
+
readonly records: {
|
|
1036
|
+
readonly type: "array";
|
|
1037
|
+
readonly items: {
|
|
1038
|
+
readonly $ref: "#/definitions/DmarcRecord";
|
|
1039
|
+
};
|
|
1040
|
+
};
|
|
1041
|
+
};
|
|
1042
|
+
readonly required: ["kind", "organization", "report_id", "date_range", "policy_published", "total_count", "dkim_pass_count", "spf_pass_count", "records"];
|
|
1043
|
+
readonly description: "Parsed DMARC aggregate report (RFC 7489). Present as `email.analysis.dmarc_report` on `email.dmarc_report` events.";
|
|
1044
|
+
};
|
|
774
1045
|
readonly ForwardAnalysis: {
|
|
775
1046
|
readonly type: "object";
|
|
776
1047
|
readonly properties: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,187 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as
|
|
3
|
-
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-
|
|
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-
|
|
5
|
-
import {
|
|
1
|
+
import { Ds as PlanLimits, Ln as CreateAgentClaimLinkInput, Lu as VerifyAgentClaimInput, O as PrimitiveApiError, Zt as Account, _ as SendThreadInput, a as ForwardInput, an as AgentAccountResult, b as createAgent, c as InboxStreamOptions, cn as AgentClaimResult, d as ReplyInput, g as SendResult, h as SendInput, i as CreatedAgent, jn as CreateAgentAccountInput, l as PrimitiveClient, ln as AgentClaimStartResult, m as SendAttachment, ml as StartAgentClaimInput, o as InboundEmail, on as AgentAccountUpgradeHint, r as CreateAgentOptions, s as InboxResource, sn as AgentClaimLinkResult, t as AccountResource, u as PrimitiveClientOptions, v as WaitForNextOptions, x as createPrimitiveClient, y as client } from "./index--2RzTxVl.js";
|
|
2
|
+
import { A as RawContentInline, C as ParsedData, D as ParsedStatus, E as ParsedError, F as WebhookAttachment, I as WebhookEvent, M as TlsReportAnalysis, N as UnknownEvent, O as RawContent, P as ValidateEmailAuthResult, S as KnownWebhookEvent, T as ParsedDataFailed, _ as ForwardResultAttachmentAnalyzed, a as DkimSignature, b as ForwardVerdict, c as DmarcResult, d as EmailAuth, f as EmailReceivedEvent, g as ForwardResult, h as ForwardOriginalSender, i as DkimResult, j as SpfResult, k as RawContentDownloadOnly, l as EmailAddress, m as ForwardAnalysis, n as AuthVerdict, o as DmarcPolicy, p as EventType, r as BounceAnalysis, s as DmarcReportAnalysis, t as AuthConfidence, u as EmailAnalysis, v as ForwardResultAttachmentSkipped, w as ParsedDataComplete, x as ForwardVerification, y as ForwardResultInline } from "./types-QT2ss9ho.js";
|
|
3
|
+
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-DyuAXctD.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-iZWfb98V.js";
|
|
5
|
+
import { NonceBinding, PayoutRegistrationMessageInput, TokenDomain, TransferAuthorization, X402Challenge, X402ChargeInput, X402Client, X402ClientOptions, X402Error, X402PaymentPayload, X402PaymentRequirements, X402PayoutAddress, X402Receipt, X402Signer, X402SpendPolicy, buildPayoutRegistrationMessage, createX402Client, deriveEip3009Nonce } from "./x402/index.js";
|
|
6
6
|
|
|
7
|
-
//#region src/x402/sign.d.ts
|
|
8
|
-
interface NonceBinding {
|
|
9
|
-
/** The interaction id, including its `@domain`. Lowercased before hashing. */
|
|
10
|
-
interactionId: string;
|
|
11
|
-
/** The challenge step id (a UUID). Lowercased before hashing. */
|
|
12
|
-
challengeStepId: string;
|
|
13
|
-
/** The challenger's per-challenge random nonce: 64 lowercase hex chars. */
|
|
14
|
-
challengeNonce: string;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Derive the EIP-3009 nonce bound to a specific interaction step:
|
|
18
|
-
*
|
|
19
|
-
* keccak256( utf8(lower(interaction_id)) || 0x00
|
|
20
|
-
* || utf8(lower(challenge_step_id)) || 0x00
|
|
21
|
-
* || hexdecode(challenge_nonce) )
|
|
22
|
-
*
|
|
23
|
-
* The `0x00` separators pin the field boundaries (undelimited concatenation of
|
|
24
|
-
* variable-length strings is collision-ambiguous), and the challenge nonce is
|
|
25
|
-
* decoded to its 32 raw bytes before hashing. The platform recomputes this and
|
|
26
|
-
* rejects a mismatch.
|
|
27
|
-
*/
|
|
28
|
-
declare function deriveEip3009Nonce(input: NonceBinding): Hex;
|
|
29
|
-
/**
|
|
30
|
-
* The EIP-3009 `TransferWithAuthorization` EIP-712 type. The field order and
|
|
31
|
-
* types are part of the on-chain contract and MUST NOT change.
|
|
32
|
-
*/
|
|
33
|
-
declare const TRANSFER_WITH_AUTHORIZATION_TYPES: {
|
|
34
|
-
readonly TransferWithAuthorization: readonly [{
|
|
35
|
-
readonly name: "from";
|
|
36
|
-
readonly type: "address";
|
|
37
|
-
}, {
|
|
38
|
-
readonly name: "to";
|
|
39
|
-
readonly type: "address";
|
|
40
|
-
}, {
|
|
41
|
-
readonly name: "value";
|
|
42
|
-
readonly type: "uint256";
|
|
43
|
-
}, {
|
|
44
|
-
readonly name: "validAfter";
|
|
45
|
-
readonly type: "uint256";
|
|
46
|
-
}, {
|
|
47
|
-
readonly name: "validBefore";
|
|
48
|
-
readonly type: "uint256";
|
|
49
|
-
}, {
|
|
50
|
-
readonly name: "nonce";
|
|
51
|
-
readonly type: "bytes32";
|
|
52
|
-
}];
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* The token's EIP-712 domain. `name`/`version` MUST be the actual token's domain
|
|
56
|
-
* params (Base mainnet USDC reports `name: "USD Coin"`, Base Sepolia `"USDC"`;
|
|
57
|
-
* both `version: "2"`); they come from the challenge's payment requirements
|
|
58
|
-
* `extra`. A wrong name/version produces a signature the verifier rejects.
|
|
59
|
-
*/
|
|
60
|
-
interface TokenDomain {
|
|
61
|
-
name: string;
|
|
62
|
-
version: string;
|
|
63
|
-
chainId: number;
|
|
64
|
-
verifyingContract: Address;
|
|
65
|
-
}
|
|
66
|
-
interface TransferAuthorization {
|
|
67
|
-
from: Address;
|
|
68
|
-
to: Address;
|
|
69
|
-
/** Token base units (USDC has 6 decimals), as a bigint. */
|
|
70
|
-
value: bigint;
|
|
71
|
-
validAfter: bigint;
|
|
72
|
-
validBefore: bigint;
|
|
73
|
-
nonce: Hex;
|
|
74
|
-
}
|
|
75
|
-
interface TransferWithAuthorizationTypedData {
|
|
76
|
-
domain: {
|
|
77
|
-
name: string;
|
|
78
|
-
version: string;
|
|
79
|
-
chainId: number;
|
|
80
|
-
verifyingContract: Address;
|
|
81
|
-
};
|
|
82
|
-
types: typeof TRANSFER_WITH_AUTHORIZATION_TYPES;
|
|
83
|
-
primaryType: "TransferWithAuthorization";
|
|
84
|
-
message: TransferAuthorization;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* A customer-held signer. A viem `LocalAccount` satisfies this directly; any
|
|
88
|
-
* key source (hardware wallet, injected provider) can be adapted. The key never
|
|
89
|
-
* leaves the caller.
|
|
90
|
-
*/
|
|
91
|
-
interface X402Signer {
|
|
92
|
-
address: Address;
|
|
93
|
-
signTypedData(typedData: TransferWithAuthorizationTypedData): Promise<Hex>;
|
|
94
|
-
}
|
|
95
|
-
/** The x402 wire payload (validated server-side against the x402 schema). */
|
|
96
|
-
interface X402PaymentPayload {
|
|
97
|
-
x402Version: 1;
|
|
98
|
-
scheme: "exact";
|
|
99
|
-
network: string;
|
|
100
|
-
payload: {
|
|
101
|
-
signature: Hex;
|
|
102
|
-
authorization: {
|
|
103
|
-
from: Address;
|
|
104
|
-
to: Address;
|
|
105
|
-
value: string;
|
|
106
|
-
validAfter: string;
|
|
107
|
-
validBefore: string;
|
|
108
|
-
nonce: Hex;
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/x402/client.d.ts
|
|
114
|
-
interface X402PaymentRequirements {
|
|
115
|
-
scheme: string;
|
|
116
|
-
network: string;
|
|
117
|
-
maxAmountRequired: string;
|
|
118
|
-
payTo: string;
|
|
119
|
-
asset: string;
|
|
120
|
-
extra: {
|
|
121
|
-
name: string;
|
|
122
|
-
version: string;
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
/** A request for payment, as returned by `charge()` / the platform. */
|
|
126
|
-
interface X402Challenge {
|
|
127
|
-
id: string;
|
|
128
|
-
network: string;
|
|
129
|
-
amount: string;
|
|
130
|
-
pay_to: string;
|
|
131
|
-
nonce_binding: {
|
|
132
|
-
interaction_id: string;
|
|
133
|
-
challenge_step_id: string;
|
|
134
|
-
challenge_nonce: string;
|
|
135
|
-
};
|
|
136
|
-
payment_requirements: X402PaymentRequirements;
|
|
137
|
-
expires_at: string;
|
|
138
|
-
}
|
|
139
|
-
interface X402Receipt {
|
|
140
|
-
id: string;
|
|
141
|
-
status: string;
|
|
142
|
-
settle_tx: string | null;
|
|
143
|
-
}
|
|
144
|
-
interface X402ChargeInput {
|
|
145
|
-
/** Amount in token base units (USDC has 6 decimals, so "10000" = 0.01). */
|
|
146
|
-
amount: string;
|
|
147
|
-
/** Defaults to "base-sepolia". */
|
|
148
|
-
network?: string;
|
|
149
|
-
/** The org id allowed to pay this challenge (on-net binding). */
|
|
150
|
-
payerOrg?: string;
|
|
151
|
-
description?: string;
|
|
152
|
-
/** A URL identifying the thing being paid for. */
|
|
153
|
-
resource?: string;
|
|
154
|
-
/** Seconds until the challenge expires (default 1h). */
|
|
155
|
-
expiresIn?: number;
|
|
156
|
-
}
|
|
157
|
-
declare class X402Error extends Error {
|
|
158
|
-
readonly status: number;
|
|
159
|
-
readonly body: unknown;
|
|
160
|
-
constructor(message: string, status: number, body?: unknown);
|
|
161
|
-
}
|
|
162
|
-
interface X402ClientOptions {
|
|
163
|
-
/** API key. Defaults to `process.env.PRIMITIVE_API_KEY`. */
|
|
164
|
-
apiKey?: string;
|
|
165
|
-
/** API base URL. Defaults to the production host. */
|
|
166
|
-
baseUrl?: string;
|
|
167
|
-
/** Override the fetch implementation (e.g. for testing). */
|
|
168
|
-
fetch?: typeof fetch;
|
|
169
|
-
}
|
|
170
|
-
declare class X402Client {
|
|
171
|
-
#private;
|
|
172
|
-
constructor(options?: X402ClientOptions);
|
|
173
|
-
/** Request a payment (payee side). Returns the challenge to hand to the payer. */
|
|
174
|
-
charge(input: X402ChargeInput): Promise<X402Challenge>;
|
|
175
|
-
/**
|
|
176
|
-
* Pay a challenge (payer side). Derives the interaction-bound authorization,
|
|
177
|
-
* signs it locally with the caller's key, and submits it for settlement.
|
|
178
|
-
*/
|
|
179
|
-
pay(challenge: X402Challenge, options: {
|
|
180
|
-
signer: X402Signer;
|
|
181
|
-
}): Promise<X402Receipt>;
|
|
182
|
-
}
|
|
183
|
-
declare function createX402Client(options?: X402ClientOptions): X402Client;
|
|
184
|
-
//#endregion
|
|
185
7
|
//#region src/index.d.ts
|
|
186
8
|
declare const primitive: {
|
|
187
9
|
client: typeof client;
|
|
@@ -189,4 +11,4 @@ declare const primitive: {
|
|
|
189
11
|
x402: typeof createX402Client;
|
|
190
12
|
};
|
|
191
13
|
//#endregion
|
|
192
|
-
export { type AgentAccountResult, type AgentAccountUpgradeHint, type AgentClaimLinkResult, type AgentClaimResult, type AgentClaimStartResult, AuthConfidence, AuthVerdict, type CreateAgentAccountInput, type CreateAgentClaimLinkInput, DecodeRawEmailOptions, DkimResult, DkimSignature, DmarcPolicy, DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType, ForwardAnalysis, type ForwardInput, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict, ForwardVerification, GenerateDownloadTokenOptions, HandleWebhookOptions, KnownWebhookEvent, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, type NonceBinding, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus, type PlanLimits, PrimitiveApiError, PrimitiveClient, type PrimitiveClientOptions, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawContent, RawContentDownloadOnly, RawContentInline, RawEmailDecodeError, RawEmailDecodeErrorCode, ReceiveRequestOptions, ReceivedEmail, ReceivedEmailAddress, ReceivedEmailThread, type ReplyInput, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, type SendAttachment, type SendInput, type SendResult, type SendThreadInput, SignResult, SpfResult, StandardWebhooksSignResult, StandardWebhooksVerifyOptions, type StartAgentClaimInput, type TokenDomain, type TransferAuthorization, UnknownEvent, VERIFICATION_ERRORS, ValidateEmailAuthResult, type VerifyAgentClaimInput, VerifyDownloadTokenOptions, VerifyDownloadTokenResult, VerifyOptions, WEBHOOK_VERSION, WebhookAttachment, WebhookErrorCode, WebhookEvent, WebhookHeaders, WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError, WebhookVerificationErrorCode, type X402Challenge, type X402ChargeInput, X402Client, type X402ClientOptions, X402Error, type X402PaymentPayload, type X402PaymentRequirements, type X402Receipt, type X402Signer, buildForwardSubject, buildReplySubject, client, confirmedHeaders, createPrimitiveClient, createX402Client, decodeRawEmail, primitive as default, deriveEip3009Nonce, emailReceivedEventJsonSchema, formatAddress, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, normalizeReceivedEmail, parseHeaderAddress, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
|
|
14
|
+
export { type Account, AccountResource, type AgentAccountResult, type AgentAccountUpgradeHint, type AgentClaimLinkResult, type AgentClaimResult, type AgentClaimStartResult, AuthConfidence, AuthVerdict, BounceAnalysis, type CreateAgentAccountInput, type CreateAgentClaimLinkInput, type CreateAgentOptions, type CreatedAgent, DecodeRawEmailOptions, DkimResult, DkimSignature, DmarcPolicy, DmarcReportAnalysis, DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType, ForwardAnalysis, type ForwardInput, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict, ForwardVerification, GenerateDownloadTokenOptions, HandleWebhookOptions, type InboundEmail, InboxResource, type InboxStreamOptions, KnownWebhookEvent, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, type NonceBinding, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus, type PayoutRegistrationMessageInput, type PlanLimits, PrimitiveApiError, PrimitiveClient, type PrimitiveClientOptions, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawContent, RawContentDownloadOnly, RawContentInline, RawEmailDecodeError, RawEmailDecodeErrorCode, ReceiveRequestOptions, ReceivedEmail, ReceivedEmailAddress, ReceivedEmailThread, type ReplyInput, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, type SendAttachment, type SendInput, type SendResult, type SendThreadInput, SignResult, SpfResult, StandardWebhooksSignResult, StandardWebhooksVerifyOptions, type StartAgentClaimInput, TlsReportAnalysis, type TokenDomain, type TransferAuthorization, UnknownEvent, VERIFICATION_ERRORS, ValidateEmailAuthResult, type VerifyAgentClaimInput, VerifyDownloadTokenOptions, VerifyDownloadTokenResult, VerifyOptions, WEBHOOK_VERSION, type WaitForNextOptions, WebhookAttachment, WebhookErrorCode, WebhookEvent, WebhookHeaders, WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError, WebhookVerificationErrorCode, type X402Challenge, type X402ChargeInput, X402Client, type X402ClientOptions, X402Error, type X402PaymentPayload, type X402PaymentRequirements, type X402PayoutAddress, type X402Receipt, type X402Signer, type X402SpendPolicy, buildForwardSubject, buildPayoutRegistrationMessage, buildReplySubject, client, confirmedHeaders, createAgent, createPrimitiveClient, createX402Client, decodeRawEmail, primitive as default, deriveEip3009Nonce, emailReceivedEventJsonSchema, formatAddress, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, normalizeReceivedEmail, parseHeaderAddress, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
|