@agent-cards/sdk 0.23.23 → 0.23.25

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 (39) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/PREFLIGHT.md +2 -0
  3. package/README.md +13 -1
  4. package/dist/agent-amount.generated.js +1 -1
  5. package/dist/amadeus.d.ts +5 -2
  6. package/dist/amadeus.js +18 -3
  7. package/dist/amazon-payment-services.d.ts +25 -0
  8. package/dist/amazon-payment-services.generated.d.ts +76 -0
  9. package/dist/amazon-payment-services.generated.js +883 -0
  10. package/dist/amazon-payment-services.js +53 -0
  11. package/dist/barion.d.ts +44 -0
  12. package/dist/barion.js +84 -0
  13. package/dist/capabilities.generated.js +1 -1
  14. package/dist/card-fields.generated.js +5 -4
  15. package/dist/cdp.js +70 -4
  16. package/dist/client.d.ts +55 -3
  17. package/dist/client.js +119 -12
  18. package/dist/hosted-entry.js +2 -0
  19. package/dist/index.d.ts +1 -0
  20. package/dist/index.js +1 -0
  21. package/dist/openpay.generated.d.ts +67 -0
  22. package/dist/openpay.generated.js +446 -0
  23. package/dist/paddle-checkout-watch.d.ts +70 -0
  24. package/dist/paddle-checkout-watch.js +239 -0
  25. package/dist/paddle-tokenex.generated.d.ts +29 -1
  26. package/dist/paddle-tokenex.generated.js +175 -26
  27. package/dist/pre-claim.d.ts +1 -0
  28. package/dist/pre-claim.js +18 -1
  29. package/dist/prepared-processor.d.ts +12 -4
  30. package/dist/prepared-processor.js +31 -5
  31. package/dist/primer.generated.js +5 -4
  32. package/dist/stripe-checkout.generated.js +5 -4
  33. package/dist/tap-payments.d.ts +43 -0
  34. package/dist/tap-payments.generated.d.ts +59 -0
  35. package/dist/tap-payments.generated.js +990 -0
  36. package/dist/tap-payments.js +72 -0
  37. package/dist/tokenex-iframe.generated.d.ts +18 -6
  38. package/dist/tokenex-iframe.generated.js +3 -3
  39. package/package.json +2 -2
@@ -0,0 +1,72 @@
1
+ // Tap Payments' card frame, the token request as the SDK sees it (payment-core tap-payments.js has the request's shape,
2
+ // the merchant pins, the device's encryption and the substitution). Tap's frame encrypts the card itself, under the
3
+ // merchant's own RSA key, and sends it in one request:
4
+ // POST https://sdk.tap.company/v2/card/token
5
+ // Content-Type: application/json, Authorization: <the merchant's publishable key>
6
+ // {"encryptedData":"<base64>","purpose":"CHARGE",...,"order":{...},"device":{...},"browser":{...},"app":{...}}
7
+ // The agent's page encrypts a placeholder card, so encryptedData carries the placeholder. This build holds that request
8
+ // and writes over it the approved card's own ciphertext: the one the cardholder's device made under the key payment-core
9
+ // pins for the request's publishable key (never a key from a row, a request or a page). Every other byte goes as the
10
+ // frame wrote it (mode cse), so the full card number never reaches the agent's runtime. Tap answers a token; 3-D
11
+ // Secure and the merchant's charge then run in the agent's browser, card free.
12
+ //
13
+ // The generic Adyen swap takes only JWEs at a named holder, and Tap's ciphertext is RSA base64 at the body root, so
14
+ // this lane is dispatched by the token URL to substituteTapPayments, as 2C2P is to its own swap. The ciphertext names no
15
+ // session and no time: it would ask Tap for a token at the same merchant again, so the continuation writes it only into
16
+ // the one request the approval was created from, byte for byte.
17
+ //
18
+ // The registry entry ships dark (capability tap_card_sdk_token). Until this build declares the capability, the API
19
+ // serves the recognizer to no client of it, so nothing here fires. Autopilot never pays this processor: the API, the
20
+ // authority and the enclave refuse it.
21
+ import { TAP_PAYMENTS_FIELD, isTapPaymentsTokenUrl, substituteTapPayments, tapPaymentsRequestKey } from './tap-payments.generated.js';
22
+ /** The PSP id the API and the recognizer name this lane, re-exported so the client dispatches by it. */
23
+ export { TAP_PAYMENTS_PSP } from './tap-payments.generated.js';
24
+ /** The dark-launch capability a build declares when it fills a Tap token request with the device's ciphertext. */
25
+ export const TAP_PAYMENTS_CAPABILITY = 'tap_card_sdk_token';
26
+ /**
27
+ * Whether an approved Tap authorization's served substitution is one this SDK can continue: JSON at the body root (`at`
28
+ * is ''), no sibling to remove, and exactly the one ciphertext, a non-empty string. substituteTapPayments checks its
29
+ * size and range against the pin for the request's publishable key; this is the shape gate the client runs first.
30
+ */
31
+ export function isTapPaymentsServedSubstitution(sub) {
32
+ if (!sub || typeof sub !== 'object' || Array.isArray(sub))
33
+ return false;
34
+ const { encoding, at, fields, remove } = sub;
35
+ if (encoding !== 'json' || at !== '' || !fields || typeof fields !== 'object' || Array.isArray(fields))
36
+ return false;
37
+ if (remove !== undefined && !(Array.isArray(remove) && remove.length === 0))
38
+ return false;
39
+ const named = fields;
40
+ return Object.keys(named).length === 1 && typeof named[TAP_PAYMENTS_FIELD] === 'string' && named[TAP_PAYMENTS_FIELD].length > 0;
41
+ }
42
+ /**
43
+ * The continuation of an approved Tap token request: the paused body with the device's ciphertext written over the
44
+ * placeholder's at encryptedData (payment-core substituteTapPayments, which runs the frame's request rule again on the
45
+ * headers of the request that continues, and refuses a ciphertext that does not have the size and range of one under
46
+ * the pin for its publishable key, or one already in the paused body).
47
+ *
48
+ * Only into `approved`, the paused request the approval was created from: `url` and `body` must equal it byte for byte.
49
+ * A ciphertext under the merchant's key would ask Tap for a token in any later request of the same shape; binding it
50
+ * to the one request keeps this lane from ever writing one checkout's card into another. `headers` are those of the
51
+ * request that continues, the paused one or the page's retry of it, and the browser sends them as they are: they
52
+ * must name the publishable key the approved request named, so a retry under another merchant's key never carries the
53
+ * card.
54
+ *
55
+ * Null when neither URL is Tap's token URL, so every other processor keeps its own swap. Throws for any other body,
56
+ * URL or key, and for a substitution the shape gate or the swap refuses, in each case before anything continues. The
57
+ * approval is not retired on a refusal: the runtime already read the ciphertext, so the API keeps the row and its hold.
58
+ */
59
+ export function tapPaymentsContinuation(url, body, headers, sub, approved) {
60
+ if (!isTapPaymentsTokenUrl(url) && !isTapPaymentsTokenUrl(approved.url))
61
+ return null;
62
+ if (url !== approved.url || body !== approved.body)
63
+ throw new Error('Refusing to substitute: the paused request is not the Tap card request the cardholder approved.');
64
+ const key = tapPaymentsRequestKey({ headers: headers ?? {} });
65
+ if (key === null || key !== tapPaymentsRequestKey({ headers: approved.headers ?? {} })) {
66
+ throw new Error('Refusing to substitute: the Tap card request does not name the merchant key the cardholder approved.');
67
+ }
68
+ if (!isTapPaymentsServedSubstitution(sub))
69
+ throw new Error('Refusing to substitute: the Tap approval is not one encrypted card.');
70
+ const request = { url, method: 'POST', headers: headers ?? {}, body };
71
+ return { body: substituteTapPayments(request, { [TAP_PAYMENTS_FIELD]: sub.fields[TAP_PAYMENTS_FIELD] }) };
72
+ }
@@ -7,11 +7,15 @@ declare var TOKENEX_IFRAME_REFUSAL_REASONS: readonly string[];
7
7
  declare var TOKENEX_IFRAME_BODY_KEYS: readonly string[];
8
8
  declare var TOKENEX_IFRAME_TOKEN_SCHEMES: readonly string[];
9
9
  declare var TOKENEX_IFRAME_REVIEWED_ACCOUNTS: Readonly<{
10
- "htp.tokenex.com": Readonly<{}>;
10
+ "htp.tokenex.com": Readonly<{
11
+ "9014311640612780": "https://www.jetblue.com";
12
+ }>;
11
13
  "test-htp.tokenex.com": Readonly<{}>;
12
14
  }>;
13
15
  declare var TOKENEX_IFRAME_ACCOUNT_NAMES: Readonly<{
14
- "htp.tokenex.com": Readonly<{}>;
16
+ "htp.tokenex.com": Readonly<{
17
+ "9014311640612780": "JetBlue";
18
+ }>;
15
19
  "test-htp.tokenex.com": Readonly<{}>;
16
20
  }>;
17
21
  declare function tokenexIframeTarget(url: any): {
@@ -37,20 +41,28 @@ declare function tokenexIframeAccount(request: any): {
37
41
  origin: any;
38
42
  } | null;
39
43
  declare function tokenexIframeAccountRefusal(request: any, accounts?: Readonly<{
40
- "htp.tokenex.com": Readonly<{}>;
44
+ "htp.tokenex.com": Readonly<{
45
+ "9014311640612780": "https://www.jetblue.com";
46
+ }>;
41
47
  "test-htp.tokenex.com": Readonly<{}>;
42
48
  }>): "unreviewed_account" | null;
43
49
  declare function tokenexIframeAccountName(request: any, accounts?: Readonly<{
44
- "htp.tokenex.com": Readonly<{}>;
50
+ "htp.tokenex.com": Readonly<{
51
+ "9014311640612780": "https://www.jetblue.com";
52
+ }>;
45
53
  "test-htp.tokenex.com": Readonly<{}>;
46
54
  }>, names?: Readonly<{
47
- "htp.tokenex.com": Readonly<{}>;
55
+ "htp.tokenex.com": Readonly<{
56
+ "9014311640612780": "JetBlue";
57
+ }>;
48
58
  "test-htp.tokenex.com": Readonly<{}>;
49
59
  }>): string | null;
50
60
  declare function tokenexIframeCardType(number: any): string | RegExp | null;
51
61
  declare function tokenexIframeBrandRefusal(body: any, card: any): "unsupported" | "brand_mismatch" | null;
52
62
  declare function tokenexIframeDeviceRefusal(request: any, card: any, accounts?: Readonly<{
53
- "htp.tokenex.com": Readonly<{}>;
63
+ "htp.tokenex.com": Readonly<{
64
+ "9014311640612780": "https://www.jetblue.com";
65
+ }>;
54
66
  "test-htp.tokenex.com": Readonly<{}>;
55
67
  }>): "unsupported" | "brand_mismatch" | "unreviewed_account" | null;
56
68
  declare function tokenexIframeRefusalMessage(reason: any): string;
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
  // Generated from @agent-cards/payment-core. Do not edit.
3
- // artifact-sha256: 79eec39d9ea40ae7687f24e640623f854bc1c0754a2553663c0662bd6cb86218
3
+ // artifact-sha256: 01596d96a2321c72cafdda7f9e60136ce5b46747178151f0878190aff8159ea2
4
4
  // src/tokenex-iframe.js
5
5
  var TOKENEX_IFRAME_PSP = "tokenex_iframe";
6
6
  var TOKENEX_IFRAME_CAPABILITY = "tokenex_iframe_tokenize";
@@ -32,11 +32,11 @@ var TOKENEX_IFRAME_BODY_KEYS = Object.freeze([
32
32
  ]);
33
33
  var TOKENEX_IFRAME_TOKEN_SCHEMES = Object.freeze(["sixTOKENfour"]);
34
34
  var TOKENEX_IFRAME_REVIEWED_ACCOUNTS = Object.freeze({
35
- "htp.tokenex.com": Object.freeze({}),
35
+ "htp.tokenex.com": Object.freeze({ "9014311640612780": "https://www.jetblue.com" }),
36
36
  "test-htp.tokenex.com": Object.freeze({})
37
37
  });
38
38
  var TOKENEX_IFRAME_ACCOUNT_NAMES = Object.freeze({
39
- "htp.tokenex.com": Object.freeze({}),
39
+ "htp.tokenex.com": Object.freeze({ "9014311640612780": "JetBlue" }),
40
40
  "test-htp.tokenex.com": Object.freeze({})
41
41
  });
42
42
  var UNSUPPORTED_REFUSAL = "Refusing to pay: unsupported TokenEx card request.";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-cards/sdk",
3
- "version": "0.23.23",
3
+ "version": "0.23.25",
4
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
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "_comment_test": "check:built runs first and names the command when a file the build generates (the copies in src/, the preflight contracts in dist/, the Kernel inventory) is missing or stale; verify:pack runs last, on the same dist.",
31
31
  "check:built": "node scripts/generate-payment-core.mjs --check && node scripts/generate-voice-stream.mjs --check && node scripts/generate-url-masks.mjs --check && node scripts/generate-capabilities.mjs --check && node scripts/generate-agent-amount.mjs --check && node scripts/generate-preflight-contract.mjs --check && node scripts/generate-kernel-native-inventory.mjs --check",
32
32
  "verify:pack": "node scripts/verify-pack.mjs",
33
- "test": "npm run check:built && node test.mjs && node --test lifecycle.test.mjs merchant-abort.test.mjs preparation.test.mjs braintree.test.mjs pre-claim.test.mjs ekashu.test.mjs redsys.test.mjs quickpay.test.mjs paytrail.test.mjs paypal-hosted-fields.test.mjs paypal-card-forms.test.mjs cybersource-secure-acceptance.test.mjs ebanx.test.mjs payrexx.test.mjs payrexx-follow-ups.test.mjs payrexx-adapters.test.mjs autopilot.test.mjs stripe-checkout.test.mjs stripe-setup.test.mjs stripe-legacy-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 wix-payments.test.mjs hipay.test.mjs payu.test.mjs attachment.test.mjs worker-targets.test.mjs mercado-checkout.test.mjs mercado-polling.test.mjs amadeus.test.mjs pelecard.test.mjs aci.test.mjs primer.test.mjs payrails.test.mjs elavon-converge.test.mjs voice.test.mjs agentcard.test.mjs buy.test.mjs readme.test.mjs gmo.test.mjs cybersource-flex.test.mjs juspay-gate.test.mjs card-endpoint.test.mjs card-endpoint-fastspring.test.mjs card-endpoint-navigation.test.mjs merchant-session-probe.test.mjs datatrans.test.mjs authorize-net-dpm.test.mjs creditguard.test.mjs eprotect.test.mjs wspay.test.mjs shiji-sts.test.mjs worldline-mycheckout.test.mjs verifone.test.mjs gravy.test.mjs paddle-vgs.test.mjs sbps.test.mjs hold.test.mjs paddle-tokenex.test.mjs lyra.test.mjs gopay.test.mjs paygent.test.mjs twoc2p.test.mjs pay-nl.test.mjs toast.test.mjs redact-url.test.mjs hosted-entry.test.mjs comgate.test.mjs przelewy24.test.mjs tokenex-iframe.test.mjs transbank.test.mjs sumup.test.mjs clover.test.mjs eximbay.test.mjs xendit.test.mjs omise.test.mjs && node --test preflight-package.test.mjs preflight-collector.test.mjs browser-tests.test.mjs && node --test kernel-native-qualification.test.mjs && node --test ../vault/scripts/recurly-validation/watch-duty-sdk-result.test.mjs && node scripts/verify-pack.mjs",
33
+ "test": "npm run check:built && node test.mjs && node --test lifecycle.test.mjs merchant-abort.test.mjs preparation.test.mjs braintree.test.mjs pre-claim.test.mjs ekashu.test.mjs redsys.test.mjs quickpay.test.mjs paytrail.test.mjs paypal-hosted-fields.test.mjs paypal-card-forms.test.mjs cybersource-secure-acceptance.test.mjs ebanx.test.mjs payrexx.test.mjs payrexx-follow-ups.test.mjs payrexx-adapters.test.mjs autopilot.test.mjs stripe-checkout.test.mjs stripe-setup.test.mjs stripe-legacy-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 wix-payments.test.mjs hipay.test.mjs openpay.test.mjs payu.test.mjs attachment.test.mjs worker-targets.test.mjs mercado-checkout.test.mjs mercado-polling.test.mjs amadeus.test.mjs pelecard.test.mjs aci.test.mjs primer.test.mjs payrails.test.mjs elavon-converge.test.mjs voice.test.mjs agentcard.test.mjs buy.test.mjs readme.test.mjs gmo.test.mjs cybersource-flex.test.mjs juspay-gate.test.mjs card-endpoint.test.mjs card-endpoint-fastspring.test.mjs card-endpoint-navigation.test.mjs merchant-session-probe.test.mjs datatrans.test.mjs authorize-net-dpm.test.mjs creditguard.test.mjs eprotect.test.mjs wspay.test.mjs shiji-sts.test.mjs worldline-mycheckout.test.mjs verifone.test.mjs gravy.test.mjs paddle-vgs.test.mjs sbps.test.mjs hold.test.mjs paddle-tokenex.test.mjs lyra.test.mjs gopay.test.mjs paygent.test.mjs twoc2p.test.mjs tap-payments.test.mjs pay-nl.test.mjs toast.test.mjs redact-url.test.mjs hosted-entry.test.mjs comgate.test.mjs przelewy24.test.mjs tokenex-iframe.test.mjs transbank.test.mjs sumup.test.mjs clover.test.mjs eximbay.test.mjs xendit.test.mjs omise.test.mjs fastspring.test.mjs amazon-payment-services.test.mjs barion.test.mjs && node --test preflight-package.test.mjs preflight-collector.test.mjs browser-tests.test.mjs && node --test kernel-native-qualification.test.mjs && node --test ../vault/scripts/recurly-validation/watch-duty-sdk-result.test.mjs && node scripts/verify-pack.mjs",
34
34
  "test:browser": "node browser-tests.mjs",
35
35
  "check:payment-core": "node scripts/generate-payment-core.mjs --check",
36
36
  "check:voice-stream": "node scripts/generate-voice-stream.mjs --check",