@agent-cards/checkout 0.7.0 → 0.8.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/dist/registry.js CHANGED
@@ -6,194 +6,9 @@
6
6
  * site shares another. The list is served from the Agentcard API at runtime so
7
7
  * integrators pick up new processors without shipping a release.
8
8
  */
9
- /**
10
- * Every PSP the service recognizes, shipped with the package.
11
- *
12
- * This list is the FALLBACK that decides interception whenever
13
- * `syncRegistry()` is skipped or its fetch fails — and that failure is silent
14
- * by design ("never break checkout over a registry fetch"). A PSP missing here
15
- * is not an error: its tokenization request is simply never paused, the vault
16
- * is never consulted, and the shopper pays with their OWN card.
17
- *
18
- * It shipped with only 5 of the service's 22 recognizers, which meant 17
19
- * processors degraded to a silent wrong-card charge for any integrator whose
20
- * sync had not landed. Generated from the backend registry
21
- * (packages/backend/src/services/checkout-recognizers.ts) so the two cannot
22
- * drift by transcription; `sdk-registry-drift.test.ts` fails CI if they do.
23
- *
24
- * Syncing still matters — it is how a NEW processor arrives without an npm
25
- * release. This list is the floor, not the ceiling.
26
- */
27
- export const BUILTIN_REGISTRY = [
28
- {
29
- psp: 'shopify',
30
- match: /(checkout\.pci\.shopifyinc\.com|deposit\.[a-z0-9-]+\.shopifycs\.com)\/sessions/i,
31
- hosts: ["^checkout\\.pci\\.shopifyinc\\.com$", "^deposit\\.[a-z0-9-]+\\.shopifycs\\.com$"],
32
- encoding: 'json',
33
- passthroughHeaders: [/^shopify-identification-signature$/i],
34
- },
35
- {
36
- psp: 'stripe',
37
- match: /api\.stripe\.com\/v1\/(payment_methods|tokens|setup_intents\/seti_\w+\/confirm|payment_intents\/pi_\w+\/confirm)/i,
38
- hosts: ["^api\\.stripe\\.com$"],
39
- encoding: 'form',
40
- passthroughHeaders: [/^authorization$/i, /^stripe-version$/i, /^x-stripe-client-user-agent$/i],
41
- },
42
- {
43
- psp: 'braintree',
44
- match: /payments(\.sandbox)?\.braintree-api\.com\/graphql/i,
45
- hosts: ["^payments\\.braintree-api\\.com$", "^payments\\.sandbox\\.braintree-api\\.com$"],
46
- encoding: 'json',
47
- passthroughHeaders: [/^authorization$/i, /^braintree-version$/i],
48
- },
49
- {
50
- psp: 'checkout_com',
51
- // Flow's native card controller can use either tokenization host.
52
- match: /(api|card-acquisition-gateway)(\.sandbox)?\.checkout\.com\/tokens/i,
53
- hosts: [
54
- "^api\\.checkout\\.com$", "^api\\.sandbox\\.checkout\\.com$",
55
- "^card-acquisition-gateway\\.checkout\\.com$", "^card-acquisition-gateway\\.sandbox\\.checkout\\.com$",
56
- ],
57
- encoding: 'json',
58
- passthroughHeaders: [/^authorization$/i],
59
- },
60
- {
61
- psp: 'adyen',
62
- match: /(checkoutshopper-(test|live(-[a-z]+)?)\.adyen\.com|([a-z0-9-]+\.)*adyenpayments\.com)\/checkoutshopper\/v1\/sessions\/[A-Za-z0-9_-]+\/payments/i,
63
- hosts: ["^checkoutshopper-(test|live(-[a-z]+)?)\\.adyen\\.com$", "^([a-z0-9-]+\\.)*adyenpayments\\.com$"],
64
- encoding: 'json',
65
- passthroughHeaders: [],
66
- clientSideEncrypted: true,
67
- mode: 'cse',
68
- },
69
- {
70
- psp: 'tranzila',
71
- match: /(direct\.tranzila\.com\/process\/n\/|directng\.tranzila\.com\/process\/?)/i,
72
- hosts: ["^direct\\.tranzila\\.com$", "^directng\\.tranzila\\.com$"],
73
- encoding: 'form',
74
- passthroughHeaders: [],
75
- mode: 'hosted_form',
76
- },
77
- {
78
- psp: 'square',
79
- match: /pci-connect\.squareup(?:sandbox)?\.com\/v2\/card-nonce/i,
80
- hosts: ["^pci-connect\\.squareup\\.com$", "^pci-connect\\.squareupsandbox\\.com$"],
81
- encoding: 'json',
82
- passthroughHeaders: [],
83
- },
84
- {
85
- psp: 'authorize_net',
86
- match: /(api2|apitest)\.authorize\.net\/xml\/v1\/request\.api/i,
87
- hosts: ["^api2\\.authorize\\.net$", "^apitest\\.authorize\\.net$"],
88
- encoding: 'json',
89
- passthroughHeaders: [],
90
- },
91
- {
92
- psp: 'worldpay',
93
- match: /(try\.)?access\.worldpay\.com\/(sessions\/card|verifiedTokens\/sessions)/i,
94
- hosts: ["^access\\.worldpay\\.com$", "^try\\.access\\.worldpay\\.com$"],
95
- encoding: 'json',
96
- passthroughHeaders: [/^accept$/i],
97
- },
98
- {
99
- psp: 'nuvei',
100
- match: /(secure|ppp-test)\.safecharge\.com\/ppp\/api\/v1\/(?:cardTokenization|clientPayment|websdk\/initPaymentWithCardTokenization)\.do/i,
101
- hosts: ["^secure\\.safecharge\\.com$", "^ppp-test\\.safecharge\\.com$"],
102
- encoding: 'json',
103
- passthroughHeaders: [],
104
- },
105
- {
106
- psp: 'airwallex',
107
- match: /(checkout(\.sandbox)?\.airwallex\.com|pci-api(\.sandbox)?\.airwallex\.com)\/api\/v1\/pa\/(payment_intents\/[^\/?#]+\/confirm|payment_consents\/[^\/?#]+\/verify|payment_methods\/create)(\?|$)/i,
108
- hosts: ["^checkout\\.airwallex\\.com$", "^checkout\\.sandbox\\.airwallex\\.com$", "^pci-api\\.airwallex\\.com$", "^pci-api\\.sandbox\\.airwallex\\.com$"],
109
- encoding: 'json',
110
- passthroughHeaders: [/^client-secret$/i, /^authorization$/i, /^x-auth-token$/i, /^x-on-behalf-of$/i, /^x-api-version$/i],
111
- },
112
- {
113
- psp: 'rapyd',
114
- match: /(api|sandboxapi)\.rapyd\.net\/v1\/(?:hosted\/collect\/card\/[^\/?#]+\/payment_method|checkout\/checkout_[A-Za-z0-9]+)(?:[?#]|$)/i,
115
- hosts: ["^api\\.rapyd\\.net$", "^sandboxapi\\.rapyd\\.net$"],
116
- encoding: 'json',
117
- passthroughHeaders: [],
118
- },
119
- {
120
- psp: 'dlocal',
121
- match: /ppmcc(-sandbox)?\.dlocal\.com\/cvault\/credit-card\/temporal/i,
122
- hosts: ["^ppmcc\\.dlocal\\.com$", "^ppmcc-sandbox\\.dlocal\\.com$"],
123
- encoding: 'json',
124
- passthroughHeaders: [/^x-fields-api-key$/i, /^x-uow$/i, /^x-dlocal-infrav2$/i],
125
- },
126
- {
127
- psp: 'ebanx',
128
- match: /(?:(?:customer-frontier|customer|api-local-latam|api|sandbox-local-latam|sandbox)\.ebanx\.com|(?:api-diamond|api|sandbox)\.ebanxpay\.com)\/ws\/token/i,
129
- hosts: ["^customer\\.ebanx\\.com$", "^customer-frontier\\.ebanx\\.com$", "^api\\.ebanx\\.com$", "^sandbox\\.ebanx\\.com$", "^api-local-latam\\.ebanx\\.com$", "^sandbox-local-latam\\.ebanx\\.com$", "^api-diamond\\.ebanxpay\\.com$", "^api\\.ebanxpay\\.com$", "^sandbox\\.ebanxpay\\.com$"],
130
- encoding: 'json',
131
- passthroughHeaders: [],
132
- },
133
- {
134
- psp: 'mercado_pago',
135
- match: /api\.mercadopago\.com\/v1\/card_tokens(?![\w\/-])/i,
136
- hosts: ["^api\\.mercadopago\\.com$"],
137
- encoding: 'json',
138
- passthroughHeaders: [/^x-product-id$/i],
139
- },
140
- {
141
- psp: 'payu',
142
- match: /(secure\.payu\.com|(merch-prod|secure)\.snd\.payu\.com)\/api\/front\/tokens/i,
143
- hosts: ["^secure\\.payu\\.com$", "^(merch-prod|secure)\\.snd\\.payu\\.com$"],
144
- encoding: 'json',
145
- passthroughHeaders: [],
146
- },
147
- {
148
- psp: 'razorpay',
149
- match: /api\.razorpay\.com\/v1\/(?:standard_checkout\/)?payments\/create\/(?:ajax|checkout|fees)/i,
150
- hosts: ["^api\\.razorpay\\.com$"],
151
- encoding: 'form',
152
- passthroughHeaders: [/^x-razorpay-sessionid$/i, /^x-customer-access-token$/i],
153
- },
154
- {
155
- psp: 'mollie',
156
- match: /api\.cc\.mollie\.com\/v1\/card-tokens/i,
157
- hosts: ["^api\\.cc\\.mollie\\.com$"],
158
- encoding: 'json',
159
- passthroughHeaders: [],
160
- },
161
- {
162
- psp: 'paysafe',
163
- match: /(?:api(\.test)?\.paysafe\.com\/(?:paymenthub\/v1\/singleusepaymenthandles|js\/api\/v1\/tokenize)|hosted(\.test)?\.paysafe\.com\/checkout\/api\/v1\/tokenize)(?![\w\/-])/i,
164
- hosts: ["^api\\.paysafe\\.com$", "^api\\.test\\.paysafe\\.com$", "^hosted\\.paysafe\\.com$", "^hosted\\.test\\.paysafe\\.com$"],
165
- encoding: 'json',
166
- passthroughHeaders: [/^authorization$/i, /^x-paysafe-credentials$/i, /^correlationid$/i],
167
- },
168
- {
169
- psp: 'recurly',
170
- match: /api(\.eu)?\.recurly\.com\/js\/v1\/token(?![\w-])/i,
171
- hosts: ["^api\\.recurly\\.com$", "^api\\.eu\\.recurly\\.com$"],
172
- encoding: 'form',
173
- passthroughHeaders: [/^recurly-credential-checkout-hostname$/i],
174
- },
175
- {
176
- psp: 'moneris',
177
- match: /(www3|esqa|gateway|gatewayqa|gatewayt|gatewaydev)\.moneris\.com\/HPPtoken\/request\.php/i,
178
- hosts: ["^www3\\.moneris\\.com$", "^esqa\\.moneris\\.com$", "^gateway\\.moneris\\.com$", "^gatewayqa\\.moneris\\.com$", "^gatewayt\\.moneris\\.com$", "^gatewaydev\\.moneris\\.com$"],
179
- encoding: 'form',
180
- passthroughHeaders: [],
181
- },
182
- {
183
- psp: 'bambora',
184
- match: /(api\.na\.bambora\.com|api\.bam\.shift4api\.net)\/scripts\/tokenization\/tokens/i,
185
- hosts: ["^api\\.na\\.bambora\\.com$", "^api\\.bam\\.shift4api\\.net$"],
186
- encoding: 'json',
187
- passthroughHeaders: [],
188
- },
189
- {
190
- psp: 'global_payments',
191
- match: /(?:api\.heartlandportico\.com\/SecureSubmit\.v1\/api\/token|cert\.api2\.heartlandportico\.com\/Hps\.Exchange\.PosGateway\.Hpf\.v1\/api\/token|apis(?:\.sandbox)?(?:\.eu)?\.globalpay\.com\/ucp\/(?:merchants\/[^\/]+\/)?payment-methods)/i,
192
- hosts: ["^api\\.heartlandportico\\.com$", "^cert\\.api2\\.heartlandportico\\.com$", "^apis\\.globalpay\\.com$", "^apis\\.sandbox\\.globalpay\\.com$", "^apis\\.eu\\.globalpay\\.com$", "^apis\\.sandbox\\.eu\\.globalpay\\.com$"],
193
- encoding: 'json',
194
- passthroughHeaders: [/^authorization$/i, /^x-gp-version$/i],
195
- },
196
- ];
9
+ // Pinned fallback generated from the single shared processor catalog.
10
+ import { BUILTIN_REGISTRY } from './builtin-registry.generated.js';
11
+ export { BUILTIN_REGISTRY };
197
12
  export function findRecognizer(url, registry = BUILTIN_REGISTRY) {
198
13
  // Match the way the SERVER does, on the PARSED url — never as a substring of
199
14
  // the raw string. `match` is unanchored, so a raw-string test classifies any
@@ -29,14 +29,10 @@ export interface Substitutions {
29
29
  */
30
30
  remove?: string[];
31
31
  }
32
- /** The paused body could not take the substitutions. Not terminal: the next request may differ. */
33
- export declare class SubstitutionError extends Error {
32
+ declare class SubstitutionErrorShape extends Error {
34
33
  constructor(message: string);
35
34
  }
36
- /**
37
- * Return the paused JSON body with `sub.fields` written over the same-named
38
- * string members of the object at `sub.at`. Throws SubstitutionError when the
39
- * body is not JSON, the path does not lead to an object, or any field is not
40
- * already a string there.
41
- */
42
- export declare function substituteEncryptedFields(body: string, sub: Substitutions): string;
35
+ export type SubstitutionError = SubstitutionErrorShape;
36
+ export declare const SubstitutionError: typeof SubstitutionErrorShape;
37
+ export declare const substituteEncryptedFields: (body: string, sub: Substitutions) => string;
38
+ export {};
@@ -16,72 +16,8 @@
16
16
  * and Adyen refuses the mismatch), and a body that does not carry the fields
17
17
  * is refused rather than guessed at.
18
18
  */
19
- /** The paused body could not take the substitutions. Not terminal: the next request may differ. */
20
- export class SubstitutionError extends Error {
21
- constructor(message) {
22
- super(message);
23
- this.name = 'SubstitutionError';
24
- }
25
- }
26
- const FORBIDDEN_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
27
- function isPlainObject(v) {
28
- return !!v && typeof v === 'object' && !Array.isArray(v);
29
- }
30
- /**
31
- * Return the paused JSON body with `sub.fields` written over the same-named
32
- * string members of the object at `sub.at`. Throws SubstitutionError when the
33
- * body is not JSON, the path does not lead to an object, or any field is not
34
- * already a string there.
35
- */
36
- export function substituteEncryptedFields(body, sub) {
37
- if (!sub || sub.encoding !== 'json') {
38
- throw new SubstitutionError(`unsupported substitution encoding: ${String(sub?.encoding)}`);
39
- }
40
- if (typeof sub.at !== 'string' || !sub.at)
41
- throw new SubstitutionError('substitutions name no path');
42
- if (!isPlainObject(sub.fields) || Object.keys(sub.fields).length === 0) {
43
- throw new SubstitutionError('substitutions carry no fields');
44
- }
45
- let parsed;
46
- try {
47
- parsed = JSON.parse(body);
48
- }
49
- catch {
50
- throw new SubstitutionError('the paused body is not JSON');
51
- }
52
- if (!isPlainObject(parsed))
53
- throw new SubstitutionError('the paused body is not a JSON object');
54
- let node = parsed;
55
- for (const step of sub.at.split('.')) {
56
- if (!step || FORBIDDEN_KEYS.has(step))
57
- throw new SubstitutionError(`refusing substitution path ${sub.at}`);
58
- const next = node[step];
59
- if (!isPlainObject(next))
60
- throw new SubstitutionError(`the paused body has no object at ${sub.at}`);
61
- node = next;
62
- }
63
- for (const [key, value] of Object.entries(sub.fields)) {
64
- if (FORBIDDEN_KEYS.has(key))
65
- throw new SubstitutionError(`refusing substitution field ${key}`);
66
- if (typeof value !== 'string' || value.length === 0)
67
- throw new SubstitutionError(`substitution for ${key} is not a string`);
68
- if (typeof node[key] !== 'string')
69
- throw new SubstitutionError(`the paused body has no string field ${sub.at}.${key}`);
70
- }
71
- const remove = sub.remove ?? [];
72
- if (!Array.isArray(remove))
73
- throw new SubstitutionError('substitutions.remove is not a list');
74
- for (const key of remove) {
75
- if (typeof key !== 'string' || !key || FORBIDDEN_KEYS.has(key))
76
- throw new SubstitutionError(`refusing removal of ${String(key)}`);
77
- if (key in sub.fields)
78
- throw new SubstitutionError(`substitution field ${key} is also listed for removal`);
79
- }
80
- // Only past every check, so a refused body is never half-written.
81
- for (const [key, value] of Object.entries(sub.fields))
82
- node[key] = value;
83
- for (const key of remove)
84
- if (Object.prototype.hasOwnProperty.call(node, key))
85
- delete node[key];
86
- return JSON.stringify(parsed);
87
- }
19
+ // The implementation is bundled from the internal core; the published SDK
20
+ // keeps its existing public types and does not require another package at runtime.
21
+ import { substituteEncryptedFields as sharedSubstitute, SubstitutionError as SharedSubstitutionError, } from './substitutions.generated.js';
22
+ export const SubstitutionError = SharedSubstitutionError;
23
+ export const substituteEncryptedFields = sharedSubstitute;
@@ -0,0 +1,10 @@
1
+ declare var SubstitutionError: {
2
+ new (message: any): {
3
+ name: string;
4
+ message: string;
5
+ stack?: string;
6
+ cause?: unknown;
7
+ };
8
+ };
9
+ declare function substituteEncryptedFields(body: any, sub: any): string;
10
+ export { SubstitutionError, substituteEncryptedFields };
@@ -0,0 +1,66 @@
1
+ // @ts-nocheck
2
+ // Generated from @agent-cards/payment-core. Do not edit.
3
+ // artifact-sha256: a74db713f1742d9bc5dc8efc78b364d2a69b255ee8da7f98345242f02114e6ce
4
+ // src/substitutions.js
5
+ var SubstitutionError = class extends Error {
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = "SubstitutionError";
9
+ }
10
+ };
11
+ var FORBIDDEN_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
12
+ function isPlainObject(v) {
13
+ return !!v && typeof v === "object" && !Array.isArray(v);
14
+ }
15
+ function substituteEncryptedFields(body, sub) {
16
+ if (!sub || sub.encoding !== "json") {
17
+ throw new SubstitutionError(`unsupported substitution encoding: ${String(sub?.encoding)}`);
18
+ }
19
+ if (typeof sub.at !== "string" || !sub.at)
20
+ throw new SubstitutionError("substitutions name no path");
21
+ if (!isPlainObject(sub.fields) || Object.keys(sub.fields).length === 0) {
22
+ throw new SubstitutionError("substitutions carry no fields");
23
+ }
24
+ let parsed;
25
+ try {
26
+ parsed = JSON.parse(body);
27
+ }
28
+ catch {
29
+ throw new SubstitutionError("the paused body is not JSON");
30
+ }
31
+ if (!isPlainObject(parsed))
32
+ throw new SubstitutionError("the paused body is not a JSON object");
33
+ let node = parsed;
34
+ for (const step of sub.at.split(".")) {
35
+ if (!step || FORBIDDEN_KEYS.has(step))
36
+ throw new SubstitutionError(`refusing substitution path ${sub.at}`);
37
+ const next = node[step];
38
+ if (!isPlainObject(next))
39
+ throw new SubstitutionError(`the paused body has no object at ${sub.at}`);
40
+ node = next;
41
+ }
42
+ for (const [key, value] of Object.entries(sub.fields)) {
43
+ if (FORBIDDEN_KEYS.has(key))
44
+ throw new SubstitutionError(`refusing substitution field ${key}`);
45
+ if (typeof value !== "string" || value.length === 0)
46
+ throw new SubstitutionError(`substitution for ${key} is not a string`);
47
+ if (typeof node[key] !== "string")
48
+ throw new SubstitutionError(`the paused body has no string field ${sub.at}.${key}`);
49
+ }
50
+ const remove = sub.remove ?? [];
51
+ if (!Array.isArray(remove))
52
+ throw new SubstitutionError("substitutions.remove is not a list");
53
+ for (const key of remove) {
54
+ if (typeof key !== "string" || !key || FORBIDDEN_KEYS.has(key))
55
+ throw new SubstitutionError(`refusing removal of ${String(key)}`);
56
+ if (key in sub.fields)
57
+ throw new SubstitutionError(`substitution field ${key} is also listed for removal`);
58
+ }
59
+ for (const [key, value] of Object.entries(sub.fields))
60
+ node[key] = value;
61
+ for (const key of remove)
62
+ if (Object.prototype.hasOwnProperty.call(node, key))
63
+ delete node[key];
64
+ return JSON.stringify(parsed);
65
+ }
66
+ export { SubstitutionError, substituteEncryptedFields };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-cards/checkout",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Let browser agents pay with the user's own card, without your infrastructure ever touching card data.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -20,11 +20,12 @@
20
20
  "access": "public"
21
21
  },
22
22
  "scripts": {
23
- "_comment_build": "TypeScript is fetched rather than declared as a devDependency ON PURPOSE. This package ships zero dependencies, which is why pnpm writes no importer for it in the workspace lockfile; adding any dep here creates one, and an importer the lockfile has not been regenerated for fails every Vercel build with ERR_PNPM_OUTDATED_LOCKFILE. Pinned so the published output is reproducible.",
24
- "build": "npx -y -p typescript@5.9.3 tsc",
23
+ "_comment_build": "The public SDK keeps zero runtime dependencies. Its build vendors deterministic metadata and substitution artifacts from the internal payment core; TypeScript remains pinned.",
24
+ "build": "node ../payment-core/scripts/build.mjs && node scripts/generate-payment-core.mjs && npx -y -p typescript@5.9.3 tsc",
25
25
  "prepublishOnly": "pnpm build",
26
- "test": "node test.mjs && node --test lifecycle.test.mjs merchant-abort.test.mjs preparation.test.mjs braintree.test.mjs prepared-processor.test.mjs minimum-delay.test.mjs paysafe.test.mjs attachment.test.mjs",
27
- "test:browser": "node browser.test.mjs && node stripe-browser.test.mjs && node preparation-browser.test.mjs"
26
+ "test": "node test.mjs && node --test lifecycle.test.mjs merchant-abort.test.mjs preparation.test.mjs braintree.test.mjs autopilot.test.mjs payment-core.test.mjs prepared-processor.test.mjs minimum-delay.test.mjs paysafe.test.mjs attachment.test.mjs",
27
+ "test:browser": "node browser.test.mjs && node stripe-browser.test.mjs && node preparation-browser.test.mjs && node owned-shop-browser.test.mjs",
28
+ "check:payment-core": "node scripts/generate-payment-core.mjs --check"
28
29
  },
29
30
  "keywords": [
30
31
  "payments",