@agent-cards/sdk 0.20.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/CHANGELOG.md +198 -0
- package/PREFLIGHT.md +314 -0
- package/README.md +864 -0
- package/dist/adyen-merchant-hosted.generated.d.ts +277 -0
- package/dist/adyen-merchant-hosted.generated.js +1902 -0
- package/dist/adyen.generated.d.ts +24 -0
- package/dist/adyen.generated.js +64 -0
- package/dist/agentcard.d.ts +72 -0
- package/dist/agentcard.js +71 -0
- package/dist/api-module.d.ts +54 -0
- package/dist/api-module.js +85 -0
- package/dist/attachment.d.ts +11 -0
- package/dist/attachment.js +50 -0
- package/dist/braintree.d.ts +2 -0
- package/dist/braintree.generated.d.ts +10 -0
- package/dist/braintree.generated.js +302 -0
- package/dist/braintree.js +2 -0
- package/dist/builtin-registry.generated.d.ts +2 -0
- package/dist/builtin-registry.generated.js +1 -0
- package/dist/buy.d.ts +374 -0
- package/dist/buy.js +314 -0
- package/dist/card-fields.generated.d.ts +3 -0
- package/dist/card-fields.generated.js +88 -0
- package/dist/cdp.d.ts +202 -0
- package/dist/cdp.js +2540 -0
- package/dist/checkout-com.generated.d.ts +4 -0
- package/dist/checkout-com.generated.js +183 -0
- package/dist/client.d.ts +929 -0
- package/dist/client.js +1896 -0
- package/dist/cse-body.d.ts +25 -0
- package/dist/cse-body.js +41 -0
- package/dist/fiserv.d.ts +65 -0
- package/dist/fiserv.generated.d.ts +73 -0
- package/dist/fiserv.generated.js +830 -0
- package/dist/fiserv.js +104 -0
- package/dist/hosted-form.d.ts +44 -0
- package/dist/hosted-form.js +78 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +26 -0
- package/dist/languages.d.ts +23 -0
- package/dist/languages.js +76 -0
- package/dist/lifecycle.d.ts +235 -0
- package/dist/lifecycle.js +405 -0
- package/dist/mercado-checkout.d.ts +20 -0
- package/dist/mercado-checkout.generated.d.ts +52 -0
- package/dist/mercado-checkout.generated.js +198 -0
- package/dist/mercado-checkout.js +108 -0
- package/dist/merchant-handoff.d.ts +54 -0
- package/dist/merchant-handoff.js +100 -0
- package/dist/merchant-hosted.d.ts +140 -0
- package/dist/merchant-hosted.js +170 -0
- package/dist/merchant-total-watch.d.ts +115 -0
- package/dist/merchant-total-watch.js +268 -0
- package/dist/merchant-total.d.ts +257 -0
- package/dist/merchant-total.js +383 -0
- package/dist/owned-shop.generated.d.ts +24 -0
- package/dist/owned-shop.generated.js +108 -0
- package/dist/paysafe.generated.d.ts +12 -0
- package/dist/paysafe.generated.js +87 -0
- package/dist/playwright.d.ts +3 -0
- package/dist/playwright.js +3 -0
- package/dist/pre-claim.d.ts +123 -0
- package/dist/pre-claim.js +386 -0
- package/dist/preflight-capabilities.generated.d.ts +1311 -0
- package/dist/preflight-capabilities.generated.js +2007 -0
- package/dist/preflight-catalog.json +5031 -0
- package/dist/preflight-playwright.d.ts +34 -0
- package/dist/preflight-playwright.js +355 -0
- package/dist/preflight-schemas.json +1144 -0
- package/dist/preflight.d.ts +1 -0
- package/dist/preflight.generated.d.ts +2023 -0
- package/dist/preflight.generated.js +604 -0
- package/dist/preflight.js +2 -0
- package/dist/preparation.d.ts +38 -0
- package/dist/preparation.js +191 -0
- package/dist/prepared-processor.d.ts +43 -0
- package/dist/prepared-processor.js +172 -0
- package/dist/recurly.generated.d.ts +1 -0
- package/dist/recurly.generated.js +87 -0
- package/dist/registry.d.ts +145 -0
- package/dist/registry.js +338 -0
- package/dist/requests.d.ts +66 -0
- package/dist/requests.js +76 -0
- package/dist/spreedly.generated.d.ts +10 -0
- package/dist/spreedly.generated.js +332 -0
- package/dist/stripe-checkout.d.ts +81 -0
- package/dist/stripe-checkout.generated.d.ts +82 -0
- package/dist/stripe-checkout.generated.js +1153 -0
- package/dist/stripe-checkout.js +140 -0
- package/dist/substitute.d.ts +38 -0
- package/dist/substitute.js +23 -0
- package/dist/substitutions.generated.d.ts +11 -0
- package/dist/substitutions.generated.js +818 -0
- package/dist/voice-pkce.d.ts +49 -0
- package/dist/voice-pkce.js +147 -0
- package/dist/voice-retry.d.ts +6 -0
- package/dist/voice-retry.js +27 -0
- package/dist/voice-stream.generated.d.ts +118 -0
- package/dist/voice-stream.generated.js +170 -0
- package/dist/voice-types.d.ts +708 -0
- package/dist/voice-types.js +16 -0
- package/dist/voice.d.ts +365 -0
- package/dist/voice.js +807 -0
- package/dist/webhooks.d.ts +87 -0
- package/dist/webhooks.js +136 -0
- package/examples/existing-browser.mjs +62 -0
- package/examples/preflight/classify-direct.mjs +21 -0
- package/examples/preflight/classify-kernel.mjs +30 -0
- package/examples/preflight/inspect-browser.mjs +44 -0
- package/examples/preflight/kernel-native/README.md +112 -0
- package/examples/preflight/kernel-native/documented-adapters.json +113 -0
- package/examples/preflight/kernel-native/inventory.json +242 -0
- package/examples/preflight/kernel-native/qualification.mjs +182 -0
- package/examples/preflight/kernel-profile.empty.json +11 -0
- package/examples/preflight/mollie-hosted.observations.json +23 -0
- package/examples/preflight/mollie-hosted.result.json +103 -0
- package/examples/preflight/stripe-script.direct.result.json +92 -0
- package/examples/preflight/stripe-script.observations.json +16 -0
- package/examples/preflight/stripe-script.result.json +87 -0
- package/package.json +53 -0
- package/readme.test.mjs +53 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
{
|
|
2
|
+
"snapshot": {
|
|
3
|
+
"schema_version": 1,
|
|
4
|
+
"catalog_version": "2026-09-15.1",
|
|
5
|
+
"signals": [
|
|
6
|
+
{
|
|
7
|
+
"rule_id": "stripe-js-v3",
|
|
8
|
+
"kind": "script",
|
|
9
|
+
"frame_id": 0,
|
|
10
|
+
"parent_frame_id": null,
|
|
11
|
+
"visible": null
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"rule_id": "stripe-js-script",
|
|
15
|
+
"kind": "script",
|
|
16
|
+
"frame_id": 0,
|
|
17
|
+
"parent_frame_id": null,
|
|
18
|
+
"visible": null
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"observation": {
|
|
22
|
+
"complete": true,
|
|
23
|
+
"truncated": false,
|
|
24
|
+
"reasons": []
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"result": {
|
|
28
|
+
"schema_version": 1,
|
|
29
|
+
"catalog_version": "2026-09-15.1",
|
|
30
|
+
"integration": {
|
|
31
|
+
"id": "kernel_native",
|
|
32
|
+
"version": "example-native-adapter"
|
|
33
|
+
},
|
|
34
|
+
"scenario": "one_time",
|
|
35
|
+
"scenario_defaulted": false,
|
|
36
|
+
"psp": "stripe",
|
|
37
|
+
"flow": null,
|
|
38
|
+
"mode": "token",
|
|
39
|
+
"status": "unknown",
|
|
40
|
+
"support_scope": null,
|
|
41
|
+
"checkout_flow_status": "unknown",
|
|
42
|
+
"candidates": [
|
|
43
|
+
{
|
|
44
|
+
"psp": "stripe",
|
|
45
|
+
"relevance": "undetermined",
|
|
46
|
+
"evidence": [
|
|
47
|
+
{
|
|
48
|
+
"rule_id": "stripe-js-v3",
|
|
49
|
+
"kind": "script",
|
|
50
|
+
"frame_id": 0,
|
|
51
|
+
"parent_frame_id": null,
|
|
52
|
+
"visible": null,
|
|
53
|
+
"origin": "https://js.stripe.com",
|
|
54
|
+
"path_pattern": "/v3/*"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"rule_id": "stripe-js-script",
|
|
58
|
+
"kind": "script",
|
|
59
|
+
"frame_id": 0,
|
|
60
|
+
"parent_frame_id": null,
|
|
61
|
+
"visible": null,
|
|
62
|
+
"origin": "https://js.stripe.com",
|
|
63
|
+
"path_pattern": "^/v3/?$"
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"reason_codes": [
|
|
69
|
+
"checkout_flow_unidentified",
|
|
70
|
+
"integration_processor_undeclared"
|
|
71
|
+
],
|
|
72
|
+
"limitations": [
|
|
73
|
+
"Processor assets alone do not establish the active card payment flow."
|
|
74
|
+
],
|
|
75
|
+
"missing_evidence": [
|
|
76
|
+
"active_checkout_flow",
|
|
77
|
+
"integration_processor_capability"
|
|
78
|
+
],
|
|
79
|
+
"observation": {
|
|
80
|
+
"complete": true,
|
|
81
|
+
"truncated": false,
|
|
82
|
+
"reasons": []
|
|
83
|
+
},
|
|
84
|
+
"scope": "preflight_hint",
|
|
85
|
+
"merchant_confirmation_required": true
|
|
86
|
+
}
|
|
87
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agent-cards/sdk",
|
|
3
|
+
"version": "0.20.0",
|
|
4
|
+
"description": "Agentcard's SDK: one client, Agentcard, with two modules. checkout pauses a browser purchase and pays it with the person's own card; voice connects a person to your product once and approves a purchase by voice inside it. Card data never enters your process.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./dist/index.js",
|
|
10
|
+
"./cdp": "./dist/cdp.js",
|
|
11
|
+
"./playwright": "./dist/playwright.js",
|
|
12
|
+
"./preflight": "./dist/preflight.js",
|
|
13
|
+
"./preflight/catalog.json": "./dist/preflight-catalog.json",
|
|
14
|
+
"./preflight/schemas.json": "./dist/preflight-schemas.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md",
|
|
19
|
+
"CHANGELOG.md",
|
|
20
|
+
"examples",
|
|
21
|
+
"PREFLIGHT.md"
|
|
22
|
+
],
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"_comment_build": "The public SDK keeps zero runtime dependencies. Its build vendors deterministic metadata and substitution artifacts from the internal payment core, and the voice streaming door from packages/voice/src/core (the phone package, @agent-cards/voice, ships it to phones); TypeScript remains pinned.",
|
|
28
|
+
"build": "node ../payment-core/scripts/build.mjs && node scripts/generate-payment-core.mjs && node scripts/generate-voice-stream.mjs && npx -y -p typescript@5.9.3 tsc && node scripts/generate-preflight-contract.mjs",
|
|
29
|
+
"prepublishOnly": "pnpm build",
|
|
30
|
+
"test": "node test.mjs && node --test lifecycle.test.mjs merchant-abort.test.mjs preparation.test.mjs braintree.test.mjs pre-claim.test.mjs autopilot.test.mjs stripe-checkout.test.mjs payment-core.test.mjs prepared-processor.test.mjs merchant-hosted.test.mjs merchant-total.test.mjs sandbox-declaration.test.mjs minimum-delay.test.mjs paysafe.test.mjs payu.test.mjs attachment.test.mjs worker-targets.test.mjs mercado-checkout.test.mjs mercado-polling.test.mjs voice.test.mjs agentcard.test.mjs buy.test.mjs readme.test.mjs && node --test preflight-package.test.mjs preflight-collector.test.mjs && node --test kernel-native-qualification.test.mjs && node --test ../vault/scripts/recurly-validation/watch-duty-sdk-result.test.mjs",
|
|
31
|
+
"test:browser": "node browser.test.mjs && node stripe-browser.test.mjs && node preparation-browser.test.mjs && node checkout-com-browser.test.mjs && node paysafe-preparation-browser.test.mjs && node owned-shop-browser.test.mjs && node spreedly-browser.test.mjs && node worker-browser.test.mjs && node adyen-merchant-hosted-browser.test.mjs && node fiserv-browser.test.mjs",
|
|
32
|
+
"check:payment-core": "node scripts/generate-payment-core.mjs --check",
|
|
33
|
+
"check:voice-stream": "node scripts/generate-voice-stream.mjs --check",
|
|
34
|
+
"test:preflight": "node --test preflight-package.test.mjs preflight-collector.test.mjs kernel-native-qualification.test.mjs",
|
|
35
|
+
"test:preflight:browser": "node preflight-browser.test.mjs",
|
|
36
|
+
"pack:preview": "node scripts/pack-preflight-preview.mjs",
|
|
37
|
+
"test:preflight:schemas": "node --test preflight-schemas.test.mjs",
|
|
38
|
+
"check:kernel-native": "node examples/preflight/kernel-native/qualification.mjs inventory --check"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"payments",
|
|
42
|
+
"agents",
|
|
43
|
+
"browser-automation",
|
|
44
|
+
"pci",
|
|
45
|
+
"checkout",
|
|
46
|
+
"voice",
|
|
47
|
+
"agentcard"
|
|
48
|
+
],
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=22"
|
|
51
|
+
},
|
|
52
|
+
"license": "UNLICENSED"
|
|
53
|
+
}
|
package/readme.test.mjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// The README's hello world, run as written against the stub. The block is read
|
|
2
|
+
// off README.md, its import is pointed at dist, `returnLink` (the link the
|
|
3
|
+
// app's sheet came back with) is taken from the stub, and the client is aimed
|
|
4
|
+
// at the stub; nothing else changes, so a line that stops running here stops
|
|
5
|
+
// the test.
|
|
6
|
+
import assert from 'node:assert/strict';
|
|
7
|
+
import fs from 'node:fs';
|
|
8
|
+
import { test } from 'node:test';
|
|
9
|
+
import { startStub } from './voice-stub.mjs';
|
|
10
|
+
|
|
11
|
+
const AsyncFunction = Object.getPrototypeOf(async function () {}).constructor;
|
|
12
|
+
|
|
13
|
+
/** The first fenced block after the heading, as text. */
|
|
14
|
+
export function readmeBlock(file, heading) {
|
|
15
|
+
const md = fs.readFileSync(file, 'utf8');
|
|
16
|
+
const at = md.indexOf(`\n${heading}\n`);
|
|
17
|
+
assert.ok(at >= 0, `${heading} is in ${file}`);
|
|
18
|
+
const m = /```[a-z]*\n([\s\S]*?)```/.exec(md.slice(at));
|
|
19
|
+
assert.ok(m, `a code block follows ${heading}`);
|
|
20
|
+
return m[1];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
test("the hello world runs as written: connect, the sheet's return link, a sandbox purchase, the result", async () => {
|
|
24
|
+
// The API names the client's mode on the token exchange; the hello world names none itself.
|
|
25
|
+
const stub = await startStub({ tokenSandbox: true });
|
|
26
|
+
try {
|
|
27
|
+
let code = readmeBlock(new URL('./README.md', import.meta.url), '## Hello world');
|
|
28
|
+
assert.equal(code.trim().split('\n').filter((l) => l.trim()).length, 7, 'seven lines');
|
|
29
|
+
assert.match(code, /request: 'sandbox'/); assert.match(code, /user_id: person\.user_id/);
|
|
30
|
+
assert.doesNotMatch(code, /sandbox: true/, 'sandbox and live are decided by the credentials, never named in code');
|
|
31
|
+
// The import becomes a dynamic one on dist; the client is aimed at the stub; the return link is the stub's.
|
|
32
|
+
code = code.replace(/^import \{([^}]+)\} from '@agent-cards\/sdk';/m, "const {$1} = await import('./dist/index.js');");
|
|
33
|
+
code = code.replace('new Agentcard({', 'new Agentcard({ baseUrl: stub.baseUrl, pollIntervalMs: 10,');
|
|
34
|
+
code = code.replace('completeConnect(returnLink)', 'completeConnect(stub.state.returnLinkFor(link.session_id))');
|
|
35
|
+
process.env.AGENTCARD_CLIENT_ID = 'cid'; process.env.AGENTCARD_CLIENT_SECRET = 'acs_good';
|
|
36
|
+
// The person approves while the server waits.
|
|
37
|
+
const approve = setInterval(() => { for (const row of stub.state.authorizations.values()) { row.status = 'approved'; row.approved_with = 'voice'; } }, 20);
|
|
38
|
+
try {
|
|
39
|
+
const run = new AsyncFunction('stub', code + '\nreturn { agentcard, link, person, purchase, card, cards, result };');
|
|
40
|
+
const out = await run(stub);
|
|
41
|
+
assert.equal(out.agentcard.sandbox, true, 'the client learned its mode from the token exchange');
|
|
42
|
+
assert.equal(out.link.grant, 'exchange');
|
|
43
|
+
assert.equal(out.person.user_id, 'usr_1');
|
|
44
|
+
assert.equal(out.purchase.status, 'awaiting_approval');
|
|
45
|
+
assert.match(out.purchase.approval_url, /^http:\/\/vault\.test\/authorize\?id=cauth_/);
|
|
46
|
+
assert.equal(out.result.status, 'approved'); assert.equal(out.result.approved_with, 'voice');
|
|
47
|
+
// The card that pays rides the create (decision 213): named, with the recommendation's reason, and the others beside it.
|
|
48
|
+
assert.equal(out.card.id, 'vc_sapphire'); assert.match(out.card.reason, /3x on shopping/); assert.equal(out.cards.length, 2);
|
|
49
|
+
const create = stub.state.requests.find((r) => r.path === '/v2/checkout/authorizations').body;
|
|
50
|
+
assert.equal(create.user, 'usr_1'); assert.match(create.request.url, /pi_sandbox/);
|
|
51
|
+
} finally { clearInterval(approve); }
|
|
52
|
+
} finally { await stub.close(); }
|
|
53
|
+
});
|