@agent-cards/checkout 0.19.0 → 0.22.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 +6 -753
- package/cdp.d.ts +1 -0
- package/cdp.js +2 -0
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +33 -33
- package/playwright.d.ts +1 -0
- package/playwright.js +2 -0
- package/preflight.d.ts +1 -0
- package/preflight.js +2 -0
- package/CHANGELOG.md +0 -132
- package/PREFLIGHT.md +0 -312
- package/dist/adyen-merchant-hosted.generated.d.ts +0 -277
- package/dist/adyen-merchant-hosted.generated.js +0 -1902
- package/dist/adyen.generated.d.ts +0 -24
- package/dist/adyen.generated.js +0 -64
- package/dist/attachment.d.ts +0 -11
- package/dist/attachment.js +0 -50
- package/dist/braintree.d.ts +0 -2
- package/dist/braintree.generated.d.ts +0 -10
- package/dist/braintree.generated.js +0 -302
- package/dist/braintree.js +0 -2
- package/dist/builtin-registry.generated.d.ts +0 -2
- package/dist/builtin-registry.generated.js +0 -1
- package/dist/card-fields.generated.d.ts +0 -3
- package/dist/card-fields.generated.js +0 -46
- package/dist/cdp.d.ts +0 -192
- package/dist/cdp.js +0 -2393
- package/dist/checkout-com.generated.d.ts +0 -4
- package/dist/checkout-com.generated.js +0 -183
- package/dist/client.d.ts +0 -849
- package/dist/client.js +0 -1754
- package/dist/cse-body.d.ts +0 -25
- package/dist/cse-body.js +0 -41
- package/dist/fiserv.d.ts +0 -65
- package/dist/fiserv.generated.d.ts +0 -73
- package/dist/fiserv.generated.js +0 -830
- package/dist/fiserv.js +0 -104
- package/dist/hosted-form.d.ts +0 -44
- package/dist/hosted-form.js +0 -78
- package/dist/index.d.ts +0 -18
- package/dist/index.js +0 -10
- package/dist/lifecycle.d.ts +0 -179
- package/dist/lifecycle.js +0 -395
- package/dist/mercado-checkout.d.ts +0 -20
- package/dist/mercado-checkout.generated.d.ts +0 -52
- package/dist/mercado-checkout.generated.js +0 -198
- package/dist/mercado-checkout.js +0 -108
- package/dist/merchant-handoff.d.ts +0 -54
- package/dist/merchant-handoff.js +0 -100
- package/dist/merchant-hosted.d.ts +0 -140
- package/dist/merchant-hosted.js +0 -170
- package/dist/merchant-total-watch.d.ts +0 -115
- package/dist/merchant-total-watch.js +0 -268
- package/dist/merchant-total.d.ts +0 -257
- package/dist/merchant-total.js +0 -383
- package/dist/owned-shop.generated.d.ts +0 -24
- package/dist/owned-shop.generated.js +0 -108
- package/dist/paysafe.generated.d.ts +0 -12
- package/dist/paysafe.generated.js +0 -87
- package/dist/playwright.d.ts +0 -3
- package/dist/playwright.js +0 -3
- package/dist/pre-claim.d.ts +0 -123
- package/dist/pre-claim.js +0 -386
- package/dist/preflight-capabilities.generated.d.ts +0 -1253
- package/dist/preflight-capabilities.generated.js +0 -1929
- package/dist/preflight-catalog.json +0 -4727
- package/dist/preflight-playwright.d.ts +0 -34
- package/dist/preflight-playwright.js +0 -355
- package/dist/preflight-schemas.json +0 -1122
- package/dist/preflight.d.ts +0 -1
- package/dist/preflight.generated.d.ts +0 -1965
- package/dist/preflight.generated.js +0 -570
- package/dist/preflight.js +0 -2
- package/dist/preparation.d.ts +0 -38
- package/dist/preparation.js +0 -191
- package/dist/prepared-processor.d.ts +0 -43
- package/dist/prepared-processor.js +0 -172
- package/dist/recurly.generated.d.ts +0 -1
- package/dist/recurly.generated.js +0 -87
- package/dist/registry.d.ts +0 -121
- package/dist/registry.js +0 -310
- package/dist/spreedly.generated.d.ts +0 -10
- package/dist/spreedly.generated.js +0 -332
- package/dist/stripe-checkout.d.ts +0 -81
- package/dist/stripe-checkout.generated.d.ts +0 -82
- package/dist/stripe-checkout.generated.js +0 -1093
- package/dist/stripe-checkout.js +0 -140
- package/dist/substitute.d.ts +0 -38
- package/dist/substitute.js +0 -23
- package/dist/substitutions.generated.d.ts +0 -11
- package/dist/substitutions.generated.js +0 -818
- package/examples/existing-browser.mjs +0 -63
- package/examples/preflight/classify-direct.mjs +0 -21
- package/examples/preflight/classify-kernel.mjs +0 -30
- package/examples/preflight/inspect-browser.mjs +0 -44
- package/examples/preflight/kernel-native/README.md +0 -112
- package/examples/preflight/kernel-native/documented-adapters.json +0 -113
- package/examples/preflight/kernel-native/inventory.json +0 -233
- package/examples/preflight/kernel-native/qualification.mjs +0 -182
- package/examples/preflight/kernel-profile.empty.json +0 -11
- package/examples/preflight/mollie-hosted.observations.json +0 -23
- package/examples/preflight/mollie-hosted.result.json +0 -103
- package/examples/preflight/stripe-script.direct.result.json +0 -92
- package/examples/preflight/stripe-script.observations.json +0 -16
- package/examples/preflight/stripe-script.result.json +0 -87
package/dist/cdp.d.ts
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { type VaultClient, type ExecutionMetadata } from './client.js';
|
|
2
|
-
import { type StripeCheckoutOptions } from './stripe-checkout.js';
|
|
3
|
-
import { type CheckoutController, type LifecycleOptions, type PaymentEndpointGuard } from './lifecycle.js';
|
|
4
|
-
/**
|
|
5
|
-
* The CORS headers a fulfilled CROSS-ORIGIN request needs, or null when the
|
|
6
|
-
* request is same-origin (or carries no Origin, so no CORS check applies).
|
|
7
|
-
*
|
|
8
|
-
* The browser checks a fulfilled response exactly as it checks a real one. A
|
|
9
|
-
* page that fetches a processor on another origin therefore needs
|
|
10
|
-
* `access-control-allow-origin` on the synthetic answer, or its fetch rejects
|
|
11
|
-
* with "Failed to fetch" and the page never sees the processor's reply, even
|
|
12
|
-
* though the cardholder approved and the processor answered the vault.
|
|
13
|
-
* Shopify never hit this on its current host: the checkout.pci.shopifyinc.com
|
|
14
|
-
* card iframe posts to its own origin (its older deposit.<region>.shopifycs.com
|
|
15
|
-
* host is called from the checkout.shopifycs.com frame, cross-origin, and gets
|
|
16
|
-
* the answer like everyone else). Stripe hits it on every surface (Checkout on
|
|
17
|
-
* checkout.stripe.com or a merchant domain, and Elements in the js.stripe.com
|
|
18
|
-
* frame, all call api.stripe.com), and so does every other processor whose
|
|
19
|
-
* card frame calls a separate API host. Observed live on
|
|
20
|
-
* 2026-09-03: the vault replayed a Stripe PaymentMethod into a raw-CDP
|
|
21
|
-
* runtime, the browser refused the answer for want of this header, and
|
|
22
|
-
* Stripe Checkout showed "We are experiencing connection issues".
|
|
23
|
-
*
|
|
24
|
-
* The exact Origin is echoed rather than `*`: a credentialed request refuses
|
|
25
|
-
* `*`, the echo satisfies both. The processor's own value can never reach
|
|
26
|
-
* this adapter (a browser does not expose that header to the page that
|
|
27
|
-
* replayed the call), so whatever the replay carries under these names is
|
|
28
|
-
* replaced by the one value that is right for THIS request. Playwright adds
|
|
29
|
-
* the same headers inside route.fulfill when a cross-origin fulfill carries
|
|
30
|
-
* none (microsoft/playwright#12929), which is why attachToPlaywright never
|
|
31
|
-
* needed this; it writes them itself anyway, replacing a stale value, so both
|
|
32
|
-
* adapters answer the vault's replays identically.
|
|
33
|
-
*
|
|
34
|
-
* This widens nothing. A tokenization endpoint is built for anonymous
|
|
35
|
-
* browsers and answers every origin (`access-control-allow-origin: *` on
|
|
36
|
-
* Stripe's and Shopify's own replies), so the page that made the request
|
|
37
|
-
* could always read the processor's answer to it; the replay is made exactly
|
|
38
|
-
* as visible, to exactly that page. Whether a card goes anywhere at all is
|
|
39
|
-
* decided by the cardholder on the approval screen, never by this header.
|
|
40
|
-
*
|
|
41
|
-
* Only what a browser serializes is ever echoed: one canonical http(s)
|
|
42
|
-
* origin (`new URL(origin).origin === origin`), or the opaque `null` a
|
|
43
|
-
* sandboxed or data: document sends, which Chrome matches against
|
|
44
|
-
* `access-control-allow-origin: null` and which Playwright echoes too. That
|
|
45
|
-
* refuses userinfo, a path, an explicit default port, several origins in one
|
|
46
|
-
* value, or a control character that would break the fulfill after the
|
|
47
|
-
* cardholder already approved. Anything refused simply gets no CORS answer,
|
|
48
|
-
* which is what every fulfill got before this existed.
|
|
49
|
-
*/
|
|
50
|
-
export declare function corsHeadersFor(url: string, requestHeaders: Record<string, string> | undefined): Record<string, string> | null;
|
|
51
|
-
/** How a fulfill was answered, reported on the `authorized` event so a silent CORS failure is diagnosable from events alone. */
|
|
52
|
-
export type CorsOutcome = 'echoed' | 'same_origin' | 'none';
|
|
53
|
-
/** The CORS answer and its reason: `none` when no usable Origin was sent (or the url is not http(s)), `same_origin` when no check applies. */
|
|
54
|
-
export declare function corsDecision(url: string, requestHeaders: Record<string, string> | undefined): {
|
|
55
|
-
headers: Record<string, string> | null;
|
|
56
|
-
outcome: CorsOutcome;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* `headers` with the CORS answer for this request written in; the object
|
|
60
|
-
* itself when none is needed. Any header the answer names is replaced
|
|
61
|
-
* whatever its case, so a name is never sent twice. The answer varies by
|
|
62
|
-
* Origin, and a `vary` the replay already carries is extended rather than
|
|
63
|
-
* replaced (or left alone when it already covers Origin or is `*`); a `vary`
|
|
64
|
-
* the answer itself names is taken as given.
|
|
65
|
-
*/
|
|
66
|
-
export declare function withCorsHeaders(headers: Record<string, string>, cors: Record<string, string> | null): Record<string, string>;
|
|
67
|
-
/**
|
|
68
|
-
* Browser-level, session-aware CDP connection. A page-scoped Playwright or
|
|
69
|
-
* Puppeteer CDPSession is NOT this interface; use attachToPlaywright for those.
|
|
70
|
-
*
|
|
71
|
-
* Forward commands and events over a browser WebSocket with flattened sessions.
|
|
72
|
-
* An omitted sessionId means the browser root, never a default page session.
|
|
73
|
-
* Attachment requires Target.getTargetInfo on the supplied page session, then
|
|
74
|
-
* Target.setDiscoverTargets and Target.getTargets at the browser root. Forward
|
|
75
|
-
* root Target.targetCreated/targetInfoChanged events with no sessionId, and
|
|
76
|
-
* preserve the sessionId on child attachment, Fetch, and Network events.
|
|
77
|
-
* Page/iframe sessions must support Page, Fetch, Network, and Target; dedicated
|
|
78
|
-
* workers require Network, Target, and Runtime.runIfWaitingForDebugger.
|
|
79
|
-
* Unsupported or incomplete discovery fails with CheckoutAttachmentError
|
|
80
|
-
* before fetch_armed. TypeScript describes forwarding; attachment verifies
|
|
81
|
-
* the browser's runtime capabilities and returned metadata.
|
|
82
|
-
*/
|
|
83
|
-
export interface CdpLike {
|
|
84
|
-
/** Read the merchant target on the page session; returns { targetInfo: CdpTargetInfo }. */
|
|
85
|
-
send(method: 'Target.getTargetInfo', params: Record<string, never>, sessionId: string): Promise<any>;
|
|
86
|
-
/** Enable root discovery events, including targets outside the page tree. */
|
|
87
|
-
send(method: 'Target.setDiscoverTargets', params: {
|
|
88
|
-
discover: boolean;
|
|
89
|
-
}, sessionId?: undefined): Promise<any>;
|
|
90
|
-
/** Read { targetInfos: CdpTargetInfo[] }; missing sessionId must remain browser-scoped. */
|
|
91
|
-
send(method: 'Target.getTargets', params?: Record<string, never>, sessionId?: undefined): Promise<any>;
|
|
92
|
-
/** Forward other CDP commands unchanged; unsupported commands must reject. */
|
|
93
|
-
send(method: string, params?: any, sessionId?: string): Promise<any>;
|
|
94
|
-
/** Deliver browser-root events as well as events from flattened child sessions. */
|
|
95
|
-
on(handler: (method: string, params: any, sessionId?: string) => void): void;
|
|
96
|
-
}
|
|
97
|
-
/** Browser Target metadata used to establish which checkout owns a worker. */
|
|
98
|
-
export interface CdpTargetInfo {
|
|
99
|
-
targetId: string;
|
|
100
|
-
type: string;
|
|
101
|
-
/** Absent for the default browser context. */
|
|
102
|
-
browserContextId?: string;
|
|
103
|
-
}
|
|
104
|
-
export interface AttachOptions extends LifecycleOptions, ExecutionMetadata {
|
|
105
|
-
/** Explicit native hosted Stripe Checkout TEST integration; requires an Autopilot grant. */
|
|
106
|
-
stripeCheckout?: StripeCheckoutOptions;
|
|
107
|
-
/** Fallback when the browser cannot expose its top-level origin. Never an amount/payee authority. */
|
|
108
|
-
merchantOrigin?: string;
|
|
109
|
-
vault: VaultClient;
|
|
110
|
-
user: string;
|
|
111
|
-
merchant: string;
|
|
112
|
-
/** Return the caller's `Date.now()` at the pay click; the SDK reads it when the card request pauses. */
|
|
113
|
-
payClickedAt?: () => number | null | undefined;
|
|
114
|
-
/**
|
|
115
|
-
* Your hint at the amount, an integer in the currency's smallest unit or a
|
|
116
|
-
* decimal string in normal units, with its ISO 4217 code. See
|
|
117
|
-
* AuthorizeInput.amount: the processor's own amount is the higher authority
|
|
118
|
-
* and is read right before the card is sent; a hint lets a bad purchase be
|
|
119
|
-
* refused the moment it opens, and one that disagrees with the processor is
|
|
120
|
-
* refused with nothing charged.
|
|
121
|
-
*/
|
|
122
|
-
amount?: number | string;
|
|
123
|
-
currency?: string;
|
|
124
|
-
/**
|
|
125
|
-
* The total the checkout page shows, the lowest authority: used only when
|
|
126
|
-
* neither the processor's request nor your `amount` names one. Pass a reader
|
|
127
|
-
* that returns an integer in the currency's smallest unit with its code
|
|
128
|
-
* (`{ amount: 4210, currency: 'usd' }`), read off the page however your
|
|
129
|
-
* page spells it; the adapters call it when a card request pauses, give it
|
|
130
|
-
* one second, and send nothing when it yields nothing. Absent: no page total.
|
|
131
|
-
*/
|
|
132
|
-
pageAmount?: () => Promise<{
|
|
133
|
-
amount: number;
|
|
134
|
-
currency: string;
|
|
135
|
-
} | undefined>;
|
|
136
|
-
cardId?: string;
|
|
137
|
-
timeoutMs?: number;
|
|
138
|
-
/** Interception setup and request ownership deadline, separate from approval. Defaults to 30000 ms; maximum 300000 ms. */
|
|
139
|
-
attachmentTimeoutMs?: number;
|
|
140
|
-
/** Explicit payment endpoints to block if the registry cannot handle their method/format. Unlisted traffic is untouched. */
|
|
141
|
-
paymentEndpoints?: readonly PaymentEndpointGuard[];
|
|
142
|
-
onApprovalUrl?: (url: string) => void;
|
|
143
|
-
onEvent?: (e: {
|
|
144
|
-
type: string;
|
|
145
|
-
detail?: unknown;
|
|
146
|
-
}) => void;
|
|
147
|
-
/** Silence after a decline or timeout. Defaults to APPROVAL_COOLDOWN_MS. */
|
|
148
|
-
approvalCooldownMs?: number;
|
|
149
|
-
/** How long a hosted form the device already submitted stays refused on a re-post. Defaults to HOSTED_FORM_REPEAT_QUIET_MS. */
|
|
150
|
-
hostedFormRepeatQuietMs?: number;
|
|
151
|
-
/**
|
|
152
|
-
* After the cardholder approves with no live page request to answer (the
|
|
153
|
-
* page's own script gave up on its request while they decided), how long
|
|
154
|
-
* the approval waits for the page to ask again before it is retired as
|
|
155
|
-
* `merchant_never_retried`. Capped by the approval window. Defaults to
|
|
156
|
-
* MERCHANT_RETRY_WAIT_MS.
|
|
157
|
-
*/
|
|
158
|
-
merchantRetryWaitMs?: number;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Take over card tokenization for a page.
|
|
162
|
-
*
|
|
163
|
-
* IMPORTANT: card fields render in cross-origin iframes, which are separate CDP
|
|
164
|
-
* targets. Enabling Fetch on the page session alone will never see the
|
|
165
|
-
* tokenization request. This attaches recursively so every nested target is
|
|
166
|
-
* armed, which is the whole reason this adapter exists.
|
|
167
|
-
*
|
|
168
|
-
* The patterns armed here come from the REGISTRY, not from a constant, so a PSP
|
|
169
|
-
* the API knows about is paused without an SDK release — call
|
|
170
|
-
* `vault.syncRegistry()` before attaching and every recognizer the server
|
|
171
|
-
* serves is covered. They are a coarse pre-filter and are deliberately wider
|
|
172
|
-
* than the recognizers (see cardUrlPatterns): each paused request is re-checked
|
|
173
|
-
* with `isCardRequest` below and continued untouched unless it is an exact
|
|
174
|
-
* match. Patterns are resolved once, at attach, so every nested target ends up
|
|
175
|
-
* armed identically. Merchant profiles are the exception to syncing first: the
|
|
176
|
-
* endpoint of every profile this build reviewed is armed whatever the sync said,
|
|
177
|
-
* and each paused request is judged against the profiles armed when it pauses,
|
|
178
|
-
* so a sync after attach arms a profile here as it does in attachToPlaywright.
|
|
179
|
-
*/
|
|
180
|
-
export declare function attachToCdp(cdp: CdpLike, pageSessionId: string, opts: AttachOptions): Promise<CheckoutController>;
|
|
181
|
-
/**
|
|
182
|
-
* Playwright convenience wrapper — the path for cloud browsers that hand you a
|
|
183
|
-
* CDP websocket (Kernel's `cdp_ws_url`, Browserbase, etc.):
|
|
184
|
-
*
|
|
185
|
-
* const browser = await chromium.connectOverCDP(kernelBrowser.cdp_ws_url);
|
|
186
|
-
* const page = await browser.contexts()[0].newPage();
|
|
187
|
-
* await attachToPlaywright(page, { vault, user, merchant, amount });
|
|
188
|
-
*
|
|
189
|
-
* Uses Playwright's own request routing, which already spans subframes — see
|
|
190
|
-
* the note in the body for why a hand-rolled CDPSession does not work here.
|
|
191
|
-
*/
|
|
192
|
-
export declare function attachToPlaywright(page: any, opts: AttachOptions): Promise<CheckoutController>;
|