@agent-cards/checkout 0.18.0 → 0.21.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 (88) hide show
  1. package/README.md +6 -669
  2. package/cdp.d.ts +1 -0
  3. package/cdp.js +2 -0
  4. package/index.d.ts +1 -0
  5. package/index.js +2 -0
  6. package/package.json +33 -33
  7. package/playwright.d.ts +1 -0
  8. package/playwright.js +2 -0
  9. package/preflight.d.ts +1 -0
  10. package/preflight.js +2 -0
  11. package/CHANGELOG.md +0 -124
  12. package/PREFLIGHT.md +0 -308
  13. package/dist/adyen.generated.d.ts +0 -24
  14. package/dist/adyen.generated.js +0 -64
  15. package/dist/attachment.d.ts +0 -11
  16. package/dist/attachment.js +0 -50
  17. package/dist/braintree.d.ts +0 -2
  18. package/dist/braintree.generated.d.ts +0 -10
  19. package/dist/braintree.generated.js +0 -302
  20. package/dist/braintree.js +0 -2
  21. package/dist/builtin-registry.generated.d.ts +0 -2
  22. package/dist/builtin-registry.generated.js +0 -1
  23. package/dist/card-fields.generated.d.ts +0 -3
  24. package/dist/card-fields.generated.js +0 -46
  25. package/dist/cdp.d.ts +0 -189
  26. package/dist/cdp.js +0 -2194
  27. package/dist/checkout-com.generated.d.ts +0 -4
  28. package/dist/checkout-com.generated.js +0 -183
  29. package/dist/client.d.ts +0 -618
  30. package/dist/client.js +0 -1251
  31. package/dist/hosted-form.d.ts +0 -44
  32. package/dist/hosted-form.js +0 -78
  33. package/dist/index.d.ts +0 -13
  34. package/dist/index.js +0 -6
  35. package/dist/lifecycle.d.ts +0 -165
  36. package/dist/lifecycle.js +0 -370
  37. package/dist/mercado-checkout.d.ts +0 -20
  38. package/dist/mercado-checkout.generated.d.ts +0 -52
  39. package/dist/mercado-checkout.generated.js +0 -198
  40. package/dist/mercado-checkout.js +0 -108
  41. package/dist/owned-shop.generated.d.ts +0 -24
  42. package/dist/owned-shop.generated.js +0 -108
  43. package/dist/paysafe.generated.d.ts +0 -12
  44. package/dist/paysafe.generated.js +0 -87
  45. package/dist/playwright.d.ts +0 -3
  46. package/dist/playwright.js +0 -3
  47. package/dist/preflight-capabilities.generated.d.ts +0 -1253
  48. package/dist/preflight-capabilities.generated.js +0 -1929
  49. package/dist/preflight-catalog.json +0 -4595
  50. package/dist/preflight-playwright.d.ts +0 -34
  51. package/dist/preflight-playwright.js +0 -355
  52. package/dist/preflight-schemas.json +0 -1110
  53. package/dist/preflight.d.ts +0 -1
  54. package/dist/preflight.generated.d.ts +0 -1965
  55. package/dist/preflight.generated.js +0 -556
  56. package/dist/preflight.js +0 -2
  57. package/dist/preparation.d.ts +0 -31
  58. package/dist/preparation.js +0 -164
  59. package/dist/prepared-processor.d.ts +0 -10
  60. package/dist/prepared-processor.js +0 -122
  61. package/dist/recurly.generated.d.ts +0 -1
  62. package/dist/recurly.generated.js +0 -87
  63. package/dist/registry.d.ts +0 -76
  64. package/dist/registry.js +0 -296
  65. package/dist/spreedly.generated.d.ts +0 -10
  66. package/dist/spreedly.generated.js +0 -332
  67. package/dist/stripe-checkout.d.ts +0 -81
  68. package/dist/stripe-checkout.generated.d.ts +0 -82
  69. package/dist/stripe-checkout.generated.js +0 -1004
  70. package/dist/stripe-checkout.js +0 -140
  71. package/dist/substitute.d.ts +0 -38
  72. package/dist/substitute.js +0 -23
  73. package/dist/substitutions.generated.d.ts +0 -10
  74. package/dist/substitutions.generated.js +0 -66
  75. package/examples/existing-browser.mjs +0 -63
  76. package/examples/preflight/classify-direct.mjs +0 -21
  77. package/examples/preflight/classify-kernel.mjs +0 -30
  78. package/examples/preflight/inspect-browser.mjs +0 -44
  79. package/examples/preflight/kernel-native/README.md +0 -112
  80. package/examples/preflight/kernel-native/documented-adapters.json +0 -113
  81. package/examples/preflight/kernel-native/inventory.json +0 -233
  82. package/examples/preflight/kernel-native/qualification.mjs +0 -182
  83. package/examples/preflight/kernel-profile.empty.json +0 -11
  84. package/examples/preflight/mollie-hosted.observations.json +0 -23
  85. package/examples/preflight/mollie-hosted.result.json +0 -103
  86. package/examples/preflight/stripe-script.direct.result.json +0 -92
  87. package/examples/preflight/stripe-script.observations.json +0 -16
  88. package/examples/preflight/stripe-script.result.json +0 -87
@@ -1,44 +0,0 @@
1
- /**
2
- * The hosted_form half of a replay: what the paused navigation is resolved
3
- * with once the cardholder's device has submitted the processor's own form.
4
- *
5
- * On a hosted-form processor (Tranzila) the paused request is a top-level
6
- * form navigation inside the processor's iframe, not an XHR. The cardholder's
7
- * device rebuilds that form with the real card and submits it itself, so the
8
- * processor's answer (approved, declined) is shown on the device and reaches
9
- * the merchant from the processor. The agent's browser never gets it.
10
- *
11
- * The paused navigation still has to resolve to SOMETHING. Aborting it is the
12
- * wrong something: an aborted navigation renders no error page, the iframe
13
- * silently stays on the dummy-card form, and the agent's natural next move is
14
- * to click Pay again. A fake copy of the processor's result page is wrong too:
15
- * this SDK does not know the outcome or the merchant's contract, so it must
16
- * not claim one. What it CAN say is exactly what happened: the cardholder
17
- * completed this payment on their own device, do not resubmit, confirm the
18
- * order with the merchant. This page says that, for a person and for an
19
- * agent, and nothing else.
20
- */
21
- export interface HostedFormSubmittedPageInput {
22
- /** The approved authorization (`cauth_…`). */
23
- authorizationId: string;
24
- /** The merchant name the authorization was created with. */
25
- merchant: string;
26
- /** When the device reported the form left it (ISO 8601). */
27
- submittedAt: string;
28
- }
29
- export interface SyntheticPage {
30
- status: 200;
31
- headers: Record<string, string>;
32
- body: string;
33
- }
34
- /** The outcome word on the page, the header and the JSON: one spelling everywhere. */
35
- export declare const HOSTED_FORM_SUBMITTED_OUTCOME = "submitted_on_device";
36
- /**
37
- * A self-contained HTML document: no external resources, no script that runs
38
- * (the one `<script>` is `application/json`, inert by type), machine-readable
39
- * through the meta tag, the header and the JSON block, and human-readable in
40
- * one paragraph. `merchant` is integrator text and lands escaped; inside the
41
- * JSON every `<`, `>` and `&` is a \u escape (still valid JSON), so a merchant
42
- * name can never close the script block early or open a comment inside it.
43
- */
44
- export declare function hostedFormSubmittedPage(input: HostedFormSubmittedPageInput): SyntheticPage;
@@ -1,78 +0,0 @@
1
- /**
2
- * The hosted_form half of a replay: what the paused navigation is resolved
3
- * with once the cardholder's device has submitted the processor's own form.
4
- *
5
- * On a hosted-form processor (Tranzila) the paused request is a top-level
6
- * form navigation inside the processor's iframe, not an XHR. The cardholder's
7
- * device rebuilds that form with the real card and submits it itself, so the
8
- * processor's answer (approved, declined) is shown on the device and reaches
9
- * the merchant from the processor. The agent's browser never gets it.
10
- *
11
- * The paused navigation still has to resolve to SOMETHING. Aborting it is the
12
- * wrong something: an aborted navigation renders no error page, the iframe
13
- * silently stays on the dummy-card form, and the agent's natural next move is
14
- * to click Pay again. A fake copy of the processor's result page is wrong too:
15
- * this SDK does not know the outcome or the merchant's contract, so it must
16
- * not claim one. What it CAN say is exactly what happened: the cardholder
17
- * completed this payment on their own device, do not resubmit, confirm the
18
- * order with the merchant. This page says that, for a person and for an
19
- * agent, and nothing else.
20
- */
21
- /** The outcome word on the page, the header and the JSON: one spelling everywhere. */
22
- export const HOSTED_FORM_SUBMITTED_OUTCOME = 'submitted_on_device';
23
- function escapeHtml(s) {
24
- return String(s)
25
- .replace(/&/g, '&amp;')
26
- .replace(/</g, '&lt;')
27
- .replace(/>/g, '&gt;')
28
- .replace(/"/g, '&quot;')
29
- .replace(/'/g, '&#39;');
30
- }
31
- /**
32
- * A self-contained HTML document: no external resources, no script that runs
33
- * (the one `<script>` is `application/json`, inert by type), machine-readable
34
- * through the meta tag, the header and the JSON block, and human-readable in
35
- * one paragraph. `merchant` is integrator text and lands escaped; inside the
36
- * JSON every `<`, `>` and `&` is a \u escape (still valid JSON), so a merchant
37
- * name can never close the script block early or open a comment inside it.
38
- */
39
- export function hostedFormSubmittedPage(input) {
40
- const merchant = String(input.merchant ?? '');
41
- const record = {
42
- outcome: HOSTED_FORM_SUBMITTED_OUTCOME,
43
- // In words, so an agent reading this block cannot take it for a receipt:
44
- // the cardholder's device attested the form left it, nothing more.
45
- payment: 'unverified',
46
- attested_by: 'cardholder_device',
47
- authorization_id: String(input.authorizationId),
48
- merchant,
49
- submitted_at: String(input.submittedAt),
50
- next: "poll the merchant's order state; never resubmit",
51
- };
52
- const json = JSON.stringify(record).replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026');
53
- const body = [
54
- '<!doctype html>',
55
- '<html lang="en">',
56
- '<head>',
57
- '<meta charset="utf-8">',
58
- `<meta name="agentcard-checkout" content="${HOSTED_FORM_SUBMITTED_OUTCOME}">`,
59
- '<meta name="robots" content="noindex">',
60
- '<title>Submitted on the cardholder\'s device</title>',
61
- '</head>',
62
- '<body>',
63
- `<p>The cardholder submitted this payment from their own device. Agentcard holds no evidence of the processor's answer: this is not a receipt. Do not resubmit this form. Confirm the order with the merchant${merchant ? ` (${escapeHtml(merchant)})` : ''}.</p>`,
64
- `<script type="application/json" id="agentcard-checkout">${json}</script>`,
65
- '</body>',
66
- '</html>',
67
- '',
68
- ].join('\n');
69
- return {
70
- status: 200,
71
- headers: {
72
- 'content-type': 'text/html; charset=utf-8',
73
- 'cache-control': 'no-store',
74
- 'x-agentcard-checkout': HOSTED_FORM_SUBMITTED_OUTCOME,
75
- },
76
- body,
77
- };
78
- }
package/dist/index.d.ts DELETED
@@ -1,13 +0,0 @@
1
- export { VaultClient, CardEncryptedError, UnsupportedModeError, ApprovalTimeoutError, ApprovalDeclinedError, AmountMismatchError, PresetRefusedError, PRESET_REFUSAL_REASONS, IntentNotConfirmableError, ProcessorRefusedError, CheckoutApiError, redactUrl, SUPPORTED_MODES, PaymentOutcomeUnknownError, CheckoutCancelledError, CheckoutPreparationError, } from './client.js';
2
- export type { PausedRequest, ReplayResponse, TokenReplay, CseReplay, HostedFormReplay, AmountAuthority, AuthorizeInput, VaultClientOptions, PrepareCheckoutOptions, PrepareCheckoutInput, PreparedCheckout, RazorpayProcessorError, RuntimeCancelReason, ExecutionMetadata, } from './client.js';
3
- export { attachToCdp, attachToPlaywright, corsHeadersFor, corsDecision, withCorsHeaders } from './cdp.js';
4
- export { CheckoutAttachmentError } from './attachment.js';
5
- export type { CdpLike, AttachOptions, CorsOutcome } from './cdp.js';
6
- export type { StripeCheckoutOptions, StripeCheckoutBlockedDetail, StripeCheckoutBlockStage, StripeCheckoutBlockReason } from './stripe-checkout.js';
7
- export { substituteEncryptedFields, SubstitutionError } from './substitute.js';
8
- export type { Substitutions } from './substitute.js';
9
- export { hostedFormSubmittedPage, HOSTED_FORM_SUBMITTED_OUTCOME } from './hosted-form.js';
10
- export type { HostedFormSubmittedPageInput, SyntheticPage } from './hosted-form.js';
11
- export { BUILTIN_REGISTRY, cardUrlPatterns, findRecognizer } from './registry.js';
12
- export type { Recognizer, CheckoutMode } from './registry.js';
13
- export type { CheckoutController, CheckoutState, MerchantResult, MerchantPaymentConfirmation, UserAction, LifecycleOptions, PaymentEndpointGuard } from './lifecycle.js';
package/dist/index.js DELETED
@@ -1,6 +0,0 @@
1
- export { VaultClient, CardEncryptedError, UnsupportedModeError, ApprovalTimeoutError, ApprovalDeclinedError, AmountMismatchError, PresetRefusedError, PRESET_REFUSAL_REASONS, IntentNotConfirmableError, ProcessorRefusedError, CheckoutApiError, redactUrl, SUPPORTED_MODES, PaymentOutcomeUnknownError, CheckoutCancelledError, CheckoutPreparationError, } from './client.js';
2
- export { attachToCdp, attachToPlaywright, corsHeadersFor, corsDecision, withCorsHeaders } from './cdp.js';
3
- export { CheckoutAttachmentError } from './attachment.js';
4
- export { substituteEncryptedFields, SubstitutionError } from './substitute.js';
5
- export { hostedFormSubmittedPage, HOSTED_FORM_SUBMITTED_OUTCOME } from './hosted-form.js';
6
- export { BUILTIN_REGISTRY, cardUrlPatterns, findRecognizer } from './registry.js';
@@ -1,165 +0,0 @@
1
- import { CheckoutPreparationError, type PrepareCheckoutOptions, type PreparedCheckout, type ReplayResponse } from './client.js';
2
- import type { CheckoutMode } from './registry.js';
3
- /** The application's resolver confirmed the payment for this checkout authorization. */
4
- export interface MerchantPaymentConfirmation {
5
- kind: 'merchant_payment';
6
- authorizationId: string;
7
- }
8
- /** Only authoritative merchant evidence can confirm completion; a processor token is insufficient. */
9
- export type MerchantResult = {
10
- status: 'completed';
11
- orderId: string;
12
- confirmation?: never;
13
- } | {
14
- status: 'completed';
15
- confirmation: MerchantPaymentConfirmation;
16
- orderId?: never;
17
- } | {
18
- status: 'failed';
19
- } | {
20
- status: 'pending' | 'unknown';
21
- } | {
22
- status: 'requires_user_action';
23
- reason: '3ds' | 'redirect' | 'other';
24
- };
25
- export interface CheckoutState {
26
- status: 'idle' | 'awaiting_approval' | 'ready_to_submit' | 'awaiting_merchant' | 'requires_user_action' | 'completed' | 'declined' | 'timed_out' | 'cancelled' | 'unsupported' | 'outcome_unknown' | 'failed';
27
- authorizationId: string | null;
28
- preparationId?: string;
29
- mode?: CheckoutMode;
30
- orderId?: string;
31
- confirmation?: MerchantPaymentConfirmation;
32
- /** Stable SDK category; never includes a request body, processor response, or approval link. */
33
- reason?: string;
34
- }
35
- export interface UserAction {
36
- reason: 'approval' | '3ds' | 'redirect' | 'other';
37
- authorizationId: string | null;
38
- /** Sensitive approval capability. Deliver privately; do not put this in ordinary telemetry. */
39
- approvalUrl?: string;
40
- }
41
- export interface LifecycleOptions {
42
- onStateChange?: (state: Readonly<CheckoutState>) => void;
43
- onUserAction?: (action: UserAction) => void | Promise<void>;
44
- /** Read authoritative merchant payment or order state; do not click Pay or initiate a new charge here. */
45
- resolveMerchantResult?: (state: Readonly<CheckoutState>) => Promise<MerchantResult>;
46
- /** Hold further card requests after handoff until the merchant result is reconciled. Default false for compatibility. */
47
- requireMerchantResult?: boolean;
48
- }
49
- export interface CheckoutController {
50
- getState(): Readonly<CheckoutState>;
51
- /** Await device consent before the caller starts the first native Pay action. One use per attachment. */
52
- prepare(options: PrepareCheckoutOptions): Promise<PreparedCheckout>;
53
- /** Stop locally and best-effort retire an unbound preparation. Does not cancel a processor payment. */
54
- cancel(): void;
55
- /** Ask the application's merchant resolver. A rejection records unknown; never automatically retries payment. */
56
- reconcile(): Promise<Readonly<CheckoutState>>;
57
- /** Signal an observed challenge; the SDK cannot detect every processor's 3DS UI. */
58
- requestUserAction(reason: '3ds' | 'redirect' | 'other'): Promise<void>;
59
- /** Start a new attempt after merchant-confirmed failure. Cancelled, completed and unbound Stripe-token attachments cannot reset. */
60
- retryAfterMerchantFailure(result: {
61
- status: 'failed';
62
- }): void;
63
- }
64
- /** How many times one approval's card-free Stripe confirmation may be checked before it is simply held. */
65
- export declare const MAX_STRIPE_CONTINUATION_CHECKS = 3;
66
- /** Shared by the raw CDP and Playwright transports. No browser ownership or payment execution lives here. */
67
- export declare class CheckoutLifecycle implements CheckoutController {
68
- private readonly options;
69
- private state;
70
- private held;
71
- private active;
72
- private cancelled;
73
- private merchantAborted;
74
- private unboundStripeToken;
75
- private stripeTokenPrepared;
76
- private stripeContinuation;
77
- private stripeContinuationChecks;
78
- private ownedShopOrderId;
79
- private reconciliation;
80
- private preparationHandler?;
81
- private preparationUsed;
82
- readonly abort: AbortController;
83
- constructor(options: LifecycleOptions);
84
- getState(): Readonly<CheckoutState>;
85
- setPreparationHandler(handler: (options: PrepareCheckoutOptions) => Promise<PreparedCheckout>): void;
86
- prepare(options: PrepareCheckoutOptions): Promise<PreparedCheckout>;
87
- preparing(): void;
88
- preparationCreated(preparationId: string): void;
89
- prepared(preparation: PreparedCheckout): void;
90
- preparationFailed(error: CheckoutPreparationError): void;
91
- isBlocked(): boolean;
92
- isCancelled(): boolean;
93
- begin(): void;
94
- end(): void;
95
- private set;
96
- approvalCreated(authorizationId: string): void;
97
- approvalUrl(approvalUrl: string): void;
98
- private notify;
99
- cancel(): void;
100
- /** The exact browser request is gone; a late approval cannot reopen it. */
101
- merchantRequestAborted(): void;
102
- /**
103
- * The page abandoned its card request (its own script timed out) while
104
- * the cardholder is still deciding. The approval stays pending and the
105
- * page's next matching request will be answered from it, so the status
106
- * stays `awaiting_approval`; the reason says the page has to ask again.
107
- * Not a hold: nothing is refused, and no card or token has moved.
108
- */
109
- merchantRequestLost(): void;
110
- /**
111
- * The cardholder approved, and there is no live page request to hand the
112
- * answer to: the page gave up on its own request while they decided.
113
- * `ready_to_submit` is the state a prepared checkout uses for "consent in
114
- * hand, click Pay": the application's next Pay action produces the request
115
- * this approval answers, with no second prompt on the phone.
116
- */
117
- awaitingMerchantRetry(authorizationId: string): void;
118
- /**
119
- * The page never asked again inside the retry wait and the API confirmed
120
- * the approval is retired: `declined`, like any other approval that ended
121
- * with nothing charged, and not held, because the next card request is a
122
- * new question (the cardholder is told to ask their agent to try again).
123
- * A retirement the API refused or did not confirm is an unknown outcome and
124
- * is reported through failed() instead, which holds.
125
- */
126
- merchantNeverRetried(authorizationId: string | null): void;
127
- unsupported(): void;
128
- prepareHandoff(replay: ReplayResponse, requestUrl: string): void;
129
- /**
130
- * The approval a page's card-free Stripe confirmation may continue, or null.
131
- * Only once a Stripe tokenization is being handed to the page, and while
132
- * the checkout still awaits it (the page can send its confirmation before
133
- * the browser acknowledges the delivery) or the merchant; for one check at
134
- * a time and at most MAX_STRIPE_CONTINUATION_CHECKS checks. Reserves the check synchronously,
135
- * so two confirmations can never both continue: the caller settles it with
136
- * stripeContinuationChecked(). The hold stays on throughout.
137
- */
138
- claimStripeContinuation(): string | null;
139
- /**
140
- * Settle a claimed check. True only when the API allowed it and the checkout
141
- * still awaits the merchant (nothing cancelled, aborted or reconciled it
142
- * while the API answered): the page's confirmation continues, and no later
143
- * one will.
144
- */
145
- stripeContinuationChecked(allowed: boolean): boolean;
146
- private stripeContinuationOpen;
147
- handedOff(replay: ReplayResponse): void;
148
- failed(error: unknown, handoffStarted?: boolean): void;
149
- requestUserAction(reason: '3ds' | 'redirect' | 'other'): Promise<void>;
150
- reconcile(): Promise<Readonly<CheckoutState>>;
151
- private resolve;
152
- retryAfterMerchantFailure(result: {
153
- status: 'failed';
154
- }): void;
155
- }
156
- /** Exact origin and path, supplied by the integrator after observing a payment endpoint. No query/body matching. */
157
- export interface PaymentEndpointGuard {
158
- origin: string;
159
- pathname: string;
160
- methods?: readonly string[];
161
- }
162
- export declare function paymentEndpointGuards(input?: readonly PaymentEndpointGuard[]): {
163
- patterns: string[];
164
- matches(url: string, method?: string): boolean;
165
- };