@agent-cards/sdk 0.21.0 → 0.23.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.
Files changed (113) hide show
  1. package/CHANGELOG.md +87 -2
  2. package/PREFLIGHT.md +32 -0
  3. package/README.md +1177 -23
  4. package/dist/aci.d.ts +173 -0
  5. package/dist/aci.generated.d.ts +87 -0
  6. package/dist/aci.generated.js +306 -0
  7. package/dist/aci.js +371 -0
  8. package/dist/adyen-merchant-hosted.generated.d.ts +3 -3
  9. package/dist/adyen-merchant-hosted.generated.js +302 -56
  10. package/dist/agentcard.d.ts +9 -2
  11. package/dist/agentcard.js +4 -2
  12. package/dist/amadeus-checkout.generated.d.ts +57 -0
  13. package/dist/amadeus-checkout.generated.js +549 -0
  14. package/dist/amadeus.d.ts +41 -0
  15. package/dist/amadeus.js +81 -0
  16. package/dist/builtin-registry.generated.js +1 -1
  17. package/dist/card-endpoint-facts.d.ts +96 -0
  18. package/dist/card-endpoint-facts.js +275 -0
  19. package/dist/card-endpoint-page.d.ts +54 -0
  20. package/dist/card-endpoint-page.js +69 -0
  21. package/dist/card-endpoint.d.ts +298 -0
  22. package/dist/card-endpoint.js +438 -0
  23. package/dist/card-fields.generated.d.ts +5 -3
  24. package/dist/card-fields.generated.js +284 -7
  25. package/dist/cdp.d.ts +5 -1
  26. package/dist/cdp.js +1155 -141
  27. package/dist/client.d.ts +456 -20
  28. package/dist/client.js +1072 -104
  29. package/dist/creditguard.generated.d.ts +79 -0
  30. package/dist/creditguard.generated.js +662 -0
  31. package/dist/cse-body.js +11 -1
  32. package/dist/cybersource-flex.d.ts +30 -0
  33. package/dist/cybersource-flex.generated.d.ts +27 -1
  34. package/dist/cybersource-flex.generated.js +42 -2
  35. package/dist/cybersource-flex.js +46 -0
  36. package/dist/datatrans.d.ts +96 -0
  37. package/dist/datatrans.generated.d.ts +64 -0
  38. package/dist/datatrans.generated.js +426 -0
  39. package/dist/datatrans.js +178 -0
  40. package/dist/ekashu.d.ts +35 -0
  41. package/dist/ekashu.js +55 -0
  42. package/dist/elavon-converge.d.ts +37 -0
  43. package/dist/elavon-converge.generated.d.ts +49 -0
  44. package/dist/elavon-converge.generated.js +439 -0
  45. package/dist/elavon-converge.js +84 -0
  46. package/dist/eprotect.d.ts +152 -0
  47. package/dist/eprotect.generated.d.ts +77 -0
  48. package/dist/eprotect.generated.js +498 -0
  49. package/dist/eprotect.js +222 -0
  50. package/dist/hosted-form.d.ts +3 -2
  51. package/dist/hosted-form.js +3 -2
  52. package/dist/index.d.ts +17 -3
  53. package/dist/index.js +6 -1
  54. package/dist/juspay-gate.d.ts +82 -0
  55. package/dist/juspay-gate.js +126 -0
  56. package/dist/juspay.generated.d.ts +89 -0
  57. package/dist/juspay.generated.js +705 -0
  58. package/dist/lifecycle.d.ts +60 -6
  59. package/dist/lifecycle.js +122 -8
  60. package/dist/merchant-card-endpoints.generated.d.ts +122 -0
  61. package/dist/merchant-card-endpoints.generated.js +4261 -0
  62. package/dist/merchant-hosted.d.ts +4 -1
  63. package/dist/merchant-hosted.js +5 -2
  64. package/dist/merchant-session-probe.d.ts +48 -0
  65. package/dist/merchant-session-probe.js +53 -0
  66. package/dist/merchant-session.generated.d.ts +69 -0
  67. package/dist/merchant-session.generated.js +919 -0
  68. package/dist/payrails.d.ts +133 -0
  69. package/dist/payrails.generated.d.ts +73 -0
  70. package/dist/payrails.generated.js +596 -0
  71. package/dist/payrails.js +305 -0
  72. package/dist/pelecard.d.ts +32 -0
  73. package/dist/pelecard.generated.d.ts +32 -0
  74. package/dist/pelecard.generated.js +283 -0
  75. package/dist/pelecard.js +42 -0
  76. package/dist/pre-claim.d.ts +81 -2
  77. package/dist/pre-claim.js +1023 -5
  78. package/dist/preflight-catalog.json +2267 -288
  79. package/dist/preflight-schemas.json +183 -6
  80. package/dist/preflight.generated.d.ts +1 -1
  81. package/dist/preflight.generated.js +243 -4
  82. package/dist/preparation.d.ts +12 -3
  83. package/dist/preparation.js +63 -12
  84. package/dist/prepared-processor.d.ts +84 -5
  85. package/dist/prepared-processor.js +147 -6
  86. package/dist/primer.d.ts +53 -0
  87. package/dist/primer.generated.d.ts +38 -0
  88. package/dist/primer.generated.js +624 -0
  89. package/dist/primer.js +82 -0
  90. package/dist/registry.d.ts +100 -8
  91. package/dist/registry.js +85 -11
  92. package/dist/shiji-sts.d.ts +144 -0
  93. package/dist/shiji-sts.generated.d.ts +72 -0
  94. package/dist/shiji-sts.generated.js +913 -0
  95. package/dist/shiji-sts.js +222 -0
  96. package/dist/stripe-checkout.generated.d.ts +1 -1
  97. package/dist/stripe-checkout.generated.js +764 -9
  98. package/dist/stripe-setup.d.ts +16 -0
  99. package/dist/stripe-setup.js +61 -0
  100. package/dist/substitutions.generated.js +187 -29
  101. package/dist/verifone.d.ts +68 -0
  102. package/dist/verifone.generated.d.ts +51 -0
  103. package/dist/verifone.generated.js +1413 -0
  104. package/dist/verifone.js +119 -0
  105. package/dist/voice-types.d.ts +27 -0
  106. package/dist/voice.d.ts +6 -1
  107. package/dist/voice.js +6 -1
  108. package/dist/wspay.d.ts +41 -0
  109. package/dist/wspay.generated.d.ts +41 -0
  110. package/dist/wspay.generated.js +370 -0
  111. package/dist/wspay.js +65 -0
  112. package/examples/preflight/kernel-native/inventory.json +1 -1
  113. package/package.json +3 -3
@@ -0,0 +1,298 @@
1
+ /** The SDK's view of a reviewed card endpoint profile: where its card request goes and what may travel with it. */
2
+ export interface CardEndpointProfile {
3
+ readonly id: string;
4
+ readonly merchant: string;
5
+ readonly status: 'observe' | 'enabled';
6
+ /** The exact https origin of the top-level page the card is typed into. */
7
+ readonly checkout: string;
8
+ /**
9
+ * The exact https origin of the merchant's own card vault frame inside that page, when
10
+ * the card request is sent from it rather than from the page itself; else null.
11
+ */
12
+ readonly frame: string | null;
13
+ /** The exact https origin the card request goes to. */
14
+ readonly endpoint: string;
15
+ readonly method: 'POST';
16
+ readonly path: string;
17
+ readonly query: Readonly<Record<string, string>>;
18
+ /** json_api is a JSON object sent as application/vnd.api+json. */
19
+ readonly encoding: 'json' | 'json_api' | 'form' | 'multipart';
20
+ /** A fetch or XHR (null), or a form the page submits as a navigation of the page ('top') or of an iframe ('frame'). */
21
+ readonly navigation: 'top' | 'frame' | null;
22
+ readonly session: {
23
+ readonly cookies: boolean;
24
+ /** Null for every cookie of the endpoint's jar, or the only names that may travel ('X*' takes every name that starts with X). */
25
+ readonly cookie_names: readonly string[] | null;
26
+ readonly headers: readonly string[];
27
+ readonly required: readonly string[];
28
+ };
29
+ readonly response: {
30
+ readonly headers: readonly string[];
31
+ };
32
+ /** True when the card is typed into a frame the merchant's page embeds: the request pauses on that frame's document. */
33
+ readonly checkout_frame?: boolean;
34
+ /** Where a body names its payment method, and the values that mean a card: any other method continues untouched. */
35
+ readonly payment_method?: {
36
+ readonly at: unknown;
37
+ readonly card: readonly string[];
38
+ } | null;
39
+ /** Requests on the endpoint origin that send the typed card again outside the card request: aborted in every status. */
40
+ readonly resends?: readonly {
41
+ readonly method: string;
42
+ readonly path: string;
43
+ readonly query: Readonly<Record<string, string>>;
44
+ }[];
45
+ /**
46
+ * The merchant's own record of the order, read from these responses (card-endpoint-facts.ts), and the calls on the
47
+ * same checkout session that change nothing it holds (inert).
48
+ */
49
+ readonly facts?: {
50
+ readonly reader: string;
51
+ readonly responses: readonly {
52
+ readonly method: string;
53
+ readonly path: string;
54
+ readonly query: Readonly<Record<string, string>>;
55
+ readonly format: string;
56
+ }[];
57
+ readonly inert: readonly {
58
+ readonly method: string;
59
+ readonly path: string;
60
+ readonly query: Readonly<Record<string, string>>;
61
+ }[];
62
+ readonly bind: string;
63
+ } | null;
64
+ }
65
+ /** One cookie of the endpoint's jar, name and value only. */
66
+ export interface CardEndpointCookie {
67
+ name: string;
68
+ value: string;
69
+ }
70
+ /**
71
+ * What the adapters capture from a paused card request and hand to the create: the
72
+ * URL, the origin of the page it was paused on, the profile's session headers, the
73
+ * endpoint's cookies for a cookie profile, a Referer on the origin the request is sent
74
+ * from (the profile's card vault frame when it names one, else the checkout page), and
75
+ * the body, which holds only the placeholder card the agent typed. Never a real card,
76
+ * always cardholder data: it travels only in `merchant_card_endpoint.session`.
77
+ */
78
+ export interface CardEndpointSession {
79
+ url: string;
80
+ page_origin: string;
81
+ /** For a navigation profile: what the browser said the paused request was. */
82
+ navigation?: 'top' | 'frame';
83
+ headers: Record<string, string>;
84
+ cookies?: CardEndpointCookie[];
85
+ referer?: string;
86
+ body: string;
87
+ }
88
+ /** The psp and mode a card endpoint authorization carries; neither is a processor. */
89
+ export declare const CARD_ENDPOINT_PSP: string;
90
+ export declare const CARD_ENDPOINT_MODE: "card_endpoint";
91
+ /**
92
+ * Why a card endpoint payment was refused before anything was created or sent. Nothing
93
+ * was charged, and the message names no URL, body or session value.
94
+ *
95
+ * - `not_enabled`: this build's copy of the profile does not take payments yet.
96
+ * - `amount_required`: the attachment names no amount; the agent's amount is the only authority here.
97
+ * - `approval_required`: the attachment asks for Autopilot; every payment here needs the cardholder's approval.
98
+ * - `preparation_unsupported`: a prepared checkout cannot pay a merchant's own card endpoint.
99
+ * - `request_unsupported`: the paused request is not the card request Agentcard reviewed
100
+ * (`detail` says what, naming fields, never values).
101
+ * - `facts_unavailable`: the merchant keeps its own record of the order (profile.facts),
102
+ * and this runtime read none for this checkout, or one it cannot place.
103
+ * - `facts_refused`: the merchant's own record says the order renews on a schedule, or
104
+ * that its checkout is in test mode. A total or currency that differs from the agent's
105
+ * is an AmountMismatchError instead.
106
+ *
107
+ * `not_enabled`, `amount_required`, `approval_required` and `preparation_unsupported`
108
+ * answer the same way for every request on the attachment, so the adapters stop asking;
109
+ * the others refuse only the request they are about.
110
+ */
111
+ export type CardEndpointRefusal = 'not_enabled' | 'amount_required' | 'approval_required' | 'preparation_unsupported' | 'request_unsupported' | 'facts_unavailable' | 'facts_refused';
112
+ export declare class CardEndpointRefusedError extends Error {
113
+ readonly profile: string;
114
+ readonly reason: CardEndpointRefusal;
115
+ readonly detail: string | null;
116
+ constructor(profile: string, reason: CardEndpointRefusal, detail?: string | null);
117
+ /** True when every later request on the attachment would be refused the same way. */
118
+ get permanent(): boolean;
119
+ }
120
+ /** The reviewed profile (any status) whose card request `url` and `method` are exactly, or null. */
121
+ export declare function cardEndpointFor(url: string, method: string): CardEndpointProfile | null;
122
+ /** The reviewed profile with this id, or null. */
123
+ export declare function cardEndpointById(id: string): CardEndpointProfile | null;
124
+ /**
125
+ * Whether a request to the profile's card endpoint is a card-free payment (the profile's
126
+ * payment_method names another method in the body): it is never Agentcard's and
127
+ * continues untouched, in every status. False for anything the rule cannot read, which
128
+ * is then held to the card request's rules.
129
+ */
130
+ export declare function cardEndpointPasses(profile: CardEndpointProfile, body: string | null, contentType: string | undefined): boolean;
131
+ /** The reviewed profile (any status) one of whose resend requests `url` and `method` are, or null: the adapters abort it. */
132
+ export declare function cardEndpointResendFor(url: string, method: string): CardEndpointProfile | null;
133
+ /** The origins of the profiles whose merchant keeps its own record of the order: the only responses card-endpoint-facts.ts records. */
134
+ export declare function cardEndpointFactsOrigins(): readonly string[];
135
+ /**
136
+ * The checkout session a request on the endpoint of a profile with facts belongs to: the
137
+ * endpoint origin and the profile's card path up to its bind placeholder, written with the
138
+ * request's own segments, the session payment-core binds the record to
139
+ * ('https://rekordcloud.onfastspring.com/popup-lexicon/session/<id>'). Null for any other
140
+ * request. card-endpoint-facts.ts counts what it keeps, and what a checkout lost, by it.
141
+ * When the paths of two profiles on one origin both fit, the shorter session is the one:
142
+ * every request on a card request's session then gets the card request's own.
143
+ */
144
+ export declare function cardEndpointFactsSession(url: string): string | null;
145
+ /** Whether this build's copy of the profile takes payments (enabled, nothing pending, a reviewed HAR, not recurring). */
146
+ export declare function cardEndpointLive(profile: CardEndpointProfile | string): boolean;
147
+ /**
148
+ * Whether a paused request to the profile's card request URL carries a card, so the
149
+ * adapters hold it (payment-core merchantCardEndpointCarriesCard): anything at the
150
+ * profile's card number field, or a Luhn-valid number of 12 to 19 digits anywhere in
151
+ * the body, however it is written. A body the adapter could not read (null), an empty
152
+ * one, and any answer the rule cannot give count as carrying one. A post to a
153
+ * navigation profile carries none only when it also reads under the profile's
154
+ * encoding, its card fields are empty and it holds no card number anywhere: no run of
155
+ * 12 to 19 digits, spaces, dots and dashes dropped, that passes the card check digit.
156
+ * Its page posts such a body for a cancel, another payment method or a bank payment,
157
+ * and it continues untouched.
158
+ */
159
+ export declare function cardEndpointCarriesCard(profile: CardEndpointProfile, body: string | null | undefined, contentType: string | undefined): boolean;
160
+ /** Whether a paused body is the card request the profile reviewed (its body rules, never its status). */
161
+ export declare function cardEndpointReviewed(profile: CardEndpointProfile, body: string | null | undefined, contentType: string | undefined): boolean;
162
+ /** What an event may say about a card endpoint request: the profile and the endpoint origin, never the URL's path or query. */
163
+ export declare function cardEndpointDetail(profile: CardEndpointProfile): {
164
+ profile: string;
165
+ endpoint: string;
166
+ };
167
+ /**
168
+ * Fetch.enable patterns covering every profile's card request, in any status: its
169
+ * origin and path with each `:name` segment and the query as wildcards. A coarse
170
+ * pre-filter, like cardUrlPatterns for processors; cardEndpointFor is the exact check
171
+ * each paused request is held to, and anything it refuses continues untouched.
172
+ */
173
+ export declare function cardEndpointPatterns(): string[];
174
+ /** What an adapter reads off a paused card endpoint request. */
175
+ export interface CardEndpointCapture {
176
+ url: string;
177
+ /** The paused request's headers as the browser reports them; the jar's cookies are never among them. */
178
+ headers: Record<string, string> | undefined;
179
+ /** The paused body: the placeholder card the agent typed and the rest of the merchant's fields. */
180
+ body: string;
181
+ /**
182
+ * The origin of the page the request was paused on, when it could be read: the
183
+ * top-level page, or for a 'frame' profile the document of the iframe its form sits in.
184
+ */
185
+ pageOrigin: string | undefined;
186
+ /** For a document request: a navigation of the page ('top') or of an iframe ('frame'). Absent for a fetch or XHR. */
187
+ navigation?: 'top' | 'frame';
188
+ /** The endpoint's cookie jar for this URL (HttpOnly included). Read only for a cookie profile. */
189
+ cookies: () => Promise<CardEndpointCookie[]>;
190
+ }
191
+ /**
192
+ * The session the create carries for a paused card endpoint request: the profile's own
193
+ * header names and nothing else, the Referer only when it is a page on the origin the
194
+ * request is sent from (the profile's card vault frame when it names one, else the
195
+ * checkout page), the endpoint's cookies only for a cookie profile, and the body. Checked with
196
+ * the same rules the API and the device run (payment-core
197
+ * merchantCardEndpointSessionRefusal), so a request they would refuse never leaves this
198
+ * process: a CardEndpointRefusedError (`request_unsupported`) instead, naming no value.
199
+ */
200
+ export declare function captureCardEndpointSession(profile: CardEndpointProfile, capture: CardEndpointCapture): Promise<CardEndpointSession>;
201
+ /**
202
+ * The headers the paused request is answered with: the profile's answer headers the
203
+ * merchant sent, and never Set-Cookie (cookies reach the browser through
204
+ * cardEndpointCookies, on the endpoint host only).
205
+ */
206
+ export declare function cardEndpointAnswerHeaders(profile: CardEndpointProfile, headers: Record<string, string>): Record<string, string>;
207
+ /**
208
+ * The fixed answer a paused request gets when the cardholder's device withheld the
209
+ * merchant's answer (it carried the card, or a compressed stream the device cannot
210
+ * read): an error the merchant's page stops on. The card request was sent; whether
211
+ * the merchant took the payment is unknown until the order is checked.
212
+ */
213
+ export declare const CARD_ENDPOINT_WITHHELD_ANSWER: Readonly<{
214
+ status: number;
215
+ headers: Readonly<Record<string, string>>;
216
+ body: string;
217
+ }>;
218
+ /**
219
+ * The fixed answer for a merchant answer the device withheld because it asks the page
220
+ * for a step the review refuses (withheld `refused_step_in_response`: FastSpring's EBANX
221
+ * step, which reads the typed card back and sends it again). The card request was sent,
222
+ * so the outcome is unknown until the order is checked.
223
+ */
224
+ export declare const CARD_ENDPOINT_REFUSED_STEP_ANSWER: Readonly<{
225
+ status: number;
226
+ headers: Readonly<Record<string, string>>;
227
+ body: string;
228
+ }>;
229
+ /**
230
+ * A Set-Cookie value from the merchant's answer, as an adapter writes it into the
231
+ * agent's browser: host-only on the endpoint host, or on the parent domain its Domain
232
+ * attribute names when that is a rotation of a cookie the browser already holds there
233
+ * (`domain`), at the cookie's path, Secure whatever the merchant said (the endpoint is
234
+ * https-only, so no cookie the SDK writes ever travels over plain http), with its other
235
+ * flags and expiry. `expires` is seconds since the epoch, absent for a session cookie,
236
+ * and 1 for a cookie the merchant expired, which the browser then removes.
237
+ */
238
+ export interface CardEndpointSetCookie {
239
+ name: string;
240
+ value: string;
241
+ /** The endpoint's origin, which a host-only cookie is written for. */
242
+ origin: string;
243
+ /** The endpoint's host name. */
244
+ host: string;
245
+ /**
246
+ * The domain (no leading dot) the cookie is written on as a domain cookie: set only
247
+ * when the merchant's Domain attribute names the endpoint host or a parent of it and
248
+ * the browser already sends the endpoint a cookie of this name on that domain, so the
249
+ * write replaces that cookie. Absent for every other cookie, which is host-only.
250
+ */
251
+ domain?: string;
252
+ path: string;
253
+ /** True for every cookie the SDK writes: see above. */
254
+ secure: boolean;
255
+ httpOnly: boolean;
256
+ sameSite?: 'Strict' | 'Lax' | 'None';
257
+ expires?: number;
258
+ }
259
+ /**
260
+ * One cookie the browser sends to the endpoint, as the adapters read the jar
261
+ * (Network.getCookies or context.cookies()): its name and its domain, which a leading
262
+ * dot marks as a domain cookie.
263
+ */
264
+ export interface CardEndpointJarCookie {
265
+ name: string;
266
+ domain: string;
267
+ }
268
+ /**
269
+ * The merchant's Set-Cookie values as cookies to write (parseSetCookie), and how many
270
+ * could not be written as one (a malformed line, a prefix or a Domain the browser would
271
+ * refuse, a Domain with the jar unread). `jar` is the endpoint's cookies as the adapter
272
+ * read them, null when the read failed. Only a profile whose answer may carry cookies
273
+ * has any.
274
+ */
275
+ export declare function cardEndpointCookies(profile: CardEndpointProfile, requestUrl: string, setCookies: readonly string[], nowMs?: number, jar?: readonly CardEndpointJarCookie[] | null): {
276
+ cookies: CardEndpointSetCookie[];
277
+ skipped: number;
278
+ };
279
+ /**
280
+ * How a paused navigation is answered from the merchant's answer (payment-core
281
+ * merchantCardEndpointNavigationAnswer): the page, a 301, 302 or 303 to one https URL,
282
+ * or refused (a redirect that repeats the post, or a Location that is not one https URL).
283
+ */
284
+ export declare function cardEndpointNavigationAnswer(profile: CardEndpointProfile, answer: {
285
+ status: number;
286
+ headers: Record<string, string>;
287
+ }, requestUrl: string): {
288
+ kind: 'page';
289
+ } | {
290
+ kind: 'redirect';
291
+ status: number;
292
+ location: string;
293
+ } | {
294
+ kind: 'refused';
295
+ reason: 'redirect_repeats_post' | 'redirect_location_invalid';
296
+ };
297
+ /** Why a session is not one the profile lets travel (payment-core merchantCardEndpointSessionRefusal), or null. Names no value. */
298
+ export declare function cardEndpointSessionRefusal(profile: CardEndpointProfile, session: unknown): string | null;