@agent-cards/sdk 0.21.0 → 0.23.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 (113) hide show
  1. package/CHANGELOG.md +87 -2
  2. package/PREFLIGHT.md +32 -0
  3. package/README.md +1177 -23
  4. package/dist/aci.d.ts +173 -0
  5. package/dist/aci.generated.d.ts +87 -0
  6. package/dist/aci.generated.js +306 -0
  7. package/dist/aci.js +371 -0
  8. package/dist/adyen-merchant-hosted.generated.d.ts +3 -3
  9. package/dist/adyen-merchant-hosted.generated.js +302 -56
  10. package/dist/agentcard.d.ts +9 -2
  11. package/dist/agentcard.js +4 -2
  12. package/dist/amadeus-checkout.generated.d.ts +57 -0
  13. package/dist/amadeus-checkout.generated.js +549 -0
  14. package/dist/amadeus.d.ts +41 -0
  15. package/dist/amadeus.js +81 -0
  16. package/dist/builtin-registry.generated.js +1 -1
  17. package/dist/card-endpoint-facts.d.ts +96 -0
  18. package/dist/card-endpoint-facts.js +275 -0
  19. package/dist/card-endpoint-page.d.ts +54 -0
  20. package/dist/card-endpoint-page.js +69 -0
  21. package/dist/card-endpoint.d.ts +298 -0
  22. package/dist/card-endpoint.js +438 -0
  23. package/dist/card-fields.generated.d.ts +5 -3
  24. package/dist/card-fields.generated.js +284 -7
  25. package/dist/cdp.d.ts +5 -1
  26. package/dist/cdp.js +1155 -141
  27. package/dist/client.d.ts +456 -20
  28. package/dist/client.js +1072 -104
  29. package/dist/creditguard.generated.d.ts +79 -0
  30. package/dist/creditguard.generated.js +662 -0
  31. package/dist/cse-body.js +11 -1
  32. package/dist/cybersource-flex.d.ts +30 -0
  33. package/dist/cybersource-flex.generated.d.ts +27 -1
  34. package/dist/cybersource-flex.generated.js +42 -2
  35. package/dist/cybersource-flex.js +46 -0
  36. package/dist/datatrans.d.ts +96 -0
  37. package/dist/datatrans.generated.d.ts +64 -0
  38. package/dist/datatrans.generated.js +426 -0
  39. package/dist/datatrans.js +178 -0
  40. package/dist/ekashu.d.ts +35 -0
  41. package/dist/ekashu.js +55 -0
  42. package/dist/elavon-converge.d.ts +37 -0
  43. package/dist/elavon-converge.generated.d.ts +49 -0
  44. package/dist/elavon-converge.generated.js +439 -0
  45. package/dist/elavon-converge.js +84 -0
  46. package/dist/eprotect.d.ts +152 -0
  47. package/dist/eprotect.generated.d.ts +77 -0
  48. package/dist/eprotect.generated.js +498 -0
  49. package/dist/eprotect.js +222 -0
  50. package/dist/hosted-form.d.ts +3 -2
  51. package/dist/hosted-form.js +3 -2
  52. package/dist/index.d.ts +17 -3
  53. package/dist/index.js +6 -1
  54. package/dist/juspay-gate.d.ts +82 -0
  55. package/dist/juspay-gate.js +126 -0
  56. package/dist/juspay.generated.d.ts +89 -0
  57. package/dist/juspay.generated.js +705 -0
  58. package/dist/lifecycle.d.ts +60 -6
  59. package/dist/lifecycle.js +122 -8
  60. package/dist/merchant-card-endpoints.generated.d.ts +122 -0
  61. package/dist/merchant-card-endpoints.generated.js +4261 -0
  62. package/dist/merchant-hosted.d.ts +4 -1
  63. package/dist/merchant-hosted.js +5 -2
  64. package/dist/merchant-session-probe.d.ts +48 -0
  65. package/dist/merchant-session-probe.js +53 -0
  66. package/dist/merchant-session.generated.d.ts +69 -0
  67. package/dist/merchant-session.generated.js +919 -0
  68. package/dist/payrails.d.ts +133 -0
  69. package/dist/payrails.generated.d.ts +73 -0
  70. package/dist/payrails.generated.js +596 -0
  71. package/dist/payrails.js +305 -0
  72. package/dist/pelecard.d.ts +32 -0
  73. package/dist/pelecard.generated.d.ts +32 -0
  74. package/dist/pelecard.generated.js +283 -0
  75. package/dist/pelecard.js +42 -0
  76. package/dist/pre-claim.d.ts +81 -2
  77. package/dist/pre-claim.js +1023 -5
  78. package/dist/preflight-catalog.json +2267 -288
  79. package/dist/preflight-schemas.json +183 -6
  80. package/dist/preflight.generated.d.ts +1 -1
  81. package/dist/preflight.generated.js +243 -4
  82. package/dist/preparation.d.ts +12 -3
  83. package/dist/preparation.js +63 -12
  84. package/dist/prepared-processor.d.ts +84 -5
  85. package/dist/prepared-processor.js +147 -6
  86. package/dist/primer.d.ts +53 -0
  87. package/dist/primer.generated.d.ts +38 -0
  88. package/dist/primer.generated.js +624 -0
  89. package/dist/primer.js +82 -0
  90. package/dist/registry.d.ts +100 -8
  91. package/dist/registry.js +85 -11
  92. package/dist/shiji-sts.d.ts +144 -0
  93. package/dist/shiji-sts.generated.d.ts +72 -0
  94. package/dist/shiji-sts.generated.js +913 -0
  95. package/dist/shiji-sts.js +222 -0
  96. package/dist/stripe-checkout.generated.d.ts +1 -1
  97. package/dist/stripe-checkout.generated.js +764 -9
  98. package/dist/stripe-setup.d.ts +16 -0
  99. package/dist/stripe-setup.js +61 -0
  100. package/dist/substitutions.generated.js +187 -29
  101. package/dist/verifone.d.ts +68 -0
  102. package/dist/verifone.generated.d.ts +51 -0
  103. package/dist/verifone.generated.js +1413 -0
  104. package/dist/verifone.js +119 -0
  105. package/dist/voice-types.d.ts +27 -0
  106. package/dist/voice.d.ts +6 -1
  107. package/dist/voice.js +6 -1
  108. package/dist/wspay.d.ts +41 -0
  109. package/dist/wspay.generated.d.ts +41 -0
  110. package/dist/wspay.generated.js +370 -0
  111. package/dist/wspay.js +65 -0
  112. package/examples/preflight/kernel-native/inventory.json +1 -1
  113. package/package.json +3 -3
@@ -0,0 +1,222 @@
1
+ // Shiji Payment Solutions STS, the card leg of the MyCheck Wallet V3 (Shiji Group), as the SDK sees it.
2
+ //
3
+ // La Quinta by Wyndham's booking page loads MyCheck's wallet, whose Shiji proxy (sts.proxy.v2.1.js)
4
+ // encrypts the typed card with RSAES-PKCS1-v1_5 under the RSA-1024 key it hardcodes and sends one
5
+ // fetch from the page:
6
+ // POST https://iframe.vault.eu.prod.shijipayment.com/v1/token/getTokenId (UAT: iframe.vault.eu.uat...)
7
+ // {"accessToken":"<STS token>","pan":"<b64>","expires":"<b64>","keySequence":"<clientKey>"}
8
+ // and, after MyCheck's payment-methods call, the CVV the same way to /v1/token/getCvvId. The agent's
9
+ // page encrypts the placeholder card. The cardholder's device encrypts the real one under the key
10
+ // payment-core pins (never a key from a row, a request or a page), and the runtime swaps those
11
+ // ciphertexts over the page's own, byte for byte, at the body root, so the accessToken, the
12
+ // keySequence and the origin stay the page's (mode cse).
13
+ //
14
+ // The registry entry ships dark (capability shiji_sts_pinned_key). This build declares the
15
+ // capability on syncRegistry, and the API serves the entry only to an org Agentcard enabled for
16
+ // shiji_sts, so for every other org nothing here fires: isCardRequest never recognizes an STS URL
17
+ // and Shiji's requests go through untouched, exactly as before.
18
+ //
19
+ // For an org in the dark launch, a POST the registry recognizes on an STS host is judged by
20
+ // payment-core's classifier (shiji-sts.generated.ts classifyShijiStsRequest), the same rules the API
21
+ // runs at create and the device runs before it encrypts:
22
+ // - a getTokenId in the proxy's shape is the one prompt, but only once the card-on-file decision is
23
+ // made: the token Shiji mints guarantees a hotel stay, so while SHIJI_STS_KEEP_ON_FILE is
24
+ // 'refuse' every one is refused in the browser (shiji_sts_keep_on_file) before any create or
25
+ // prompt, and the page's card never reaches Shiji. Once asked, the device's ciphertext goes only
26
+ // into that paused request, byte for byte: if the page abandons it, the approval is cancelled
27
+ // (merchant_request_aborted) and no later getTokenId is answered from it, because one of the
28
+ // same shape can name another Shiji merchant's accessToken and keySequence;
29
+ // - a getCvvId never prompts. It continues with the device's CVV ciphertext only when it is the
30
+ // companion of the getTokenId this attachment continued with the Vault's ciphertexts (same host,
31
+ // same page, same accessToken, a keySequence the API reviewed as that page's getCvvId key and
32
+ // served with the approval, within 120 s, once), and is refused otherwise, so the agent's
33
+ // placeholder CVV never rides beside a real card and the real one goes to no unreviewed key. The
34
+ // binding, and the CVV ciphertext it holds, is dropped as soon as the attachment can no longer
35
+ // use it: a cancel, the page, frame or target that sent the getTokenId going away, or that frame
36
+ // committing a new document, which never obtained the approval;
37
+ // - anything else on those two URLs is refused as an unsupported checkout.
38
+ // Autopilot never pays this processor: the API, the authority and the enclave refuse it.
39
+ import { SHIJI_STS_COMPANION_WINDOW_MS, SHIJI_STS_PSP, ShijiStsError, classifyShijiStsRequest, createShijiStsCompanion, isShijiStsCiphertext, isShijiStsHost, shijiStsEndpoint, substituteShijiSts, } from './shiji-sts.generated.js';
40
+ export { SHIJI_STS_COMPANION_WINDOW_MS, SHIJI_STS_PSP, ShijiStsError, isShijiStsHost };
41
+ /** The dark-launch capability a build declares when it swaps Shiji's ciphertexts and binds its getCvvId companion. */
42
+ export const SHIJI_STS_CAPABILITY = 'shiji_sts_pinned_key';
43
+ const REFUSED = Object.freeze({
44
+ keep_on_file: 'shiji_sts_keep_on_file',
45
+ foreign_key: 'shiji_sts_foreign_key',
46
+ unsupported: 'unsupported_shiji_sts_request',
47
+ companion_unbound: 'shiji_sts_companion_unbound',
48
+ companion_expired: 'shiji_sts_companion_expired',
49
+ companion_used: 'shiji_sts_companion_used',
50
+ });
51
+ /**
52
+ * The verdict on a request to an STS host that the registry recognized: 'pause' for the one prompt
53
+ * (a getTokenId in the proxy's shape once the card-on-file decision allows it), 'companion' for a
54
+ * getCvvId in the proxy's shape, and 'refuse' with a reason for everything else. A classifier that
55
+ * throws refuses.
56
+ */
57
+ export function shijiStsVerdict(request) {
58
+ let verdict;
59
+ try {
60
+ verdict = classifyShijiStsRequest(request.url, request.method.toUpperCase(), request.body);
61
+ }
62
+ catch {
63
+ verdict = null;
64
+ }
65
+ if (verdict === 'card')
66
+ return { kind: 'pause' };
67
+ if (verdict === 'companion')
68
+ return { kind: 'companion' };
69
+ return { kind: 'refuse', reason: (verdict && REFUSED[verdict]) || 'unsupported_shiji_sts_request' };
70
+ }
71
+ const SERVED_FIELDS = ['pan', 'expires', 'cvv'];
72
+ /**
73
+ * Whether an approved Shiji STS authorization's served substitution is one this SDK can continue:
74
+ * JSON at the body root (`at` is ''), no sibling to remove, and exactly pan, expires and cvv, each a
75
+ * 128-byte ciphertext as JSEncrypt writes one. Anything else is not acted on.
76
+ */
77
+ export function isShijiStsServedSubstitution(sub) {
78
+ if (!sub || typeof sub !== 'object' || Array.isArray(sub))
79
+ return false;
80
+ const { encoding, at, fields, remove } = sub;
81
+ if (encoding !== 'json' || at !== '' || !fields || typeof fields !== 'object' || Array.isArray(fields))
82
+ return false;
83
+ if (remove !== undefined && !(Array.isArray(remove) && remove.length === 0))
84
+ return false;
85
+ const names = Object.keys(fields);
86
+ return names.length === SERVED_FIELDS.length
87
+ && SERVED_FIELDS.every((name) => isShijiStsCiphertext(fields[name]));
88
+ }
89
+ const SERVED_KEY_SEQUENCE = /^[\x21-\x7e]{1,256}$/;
90
+ const SERVED_KEY_SEQUENCES_LIMIT = 16;
91
+ /**
92
+ * Whether the API's `shiji_sts_companion` beside an approved Shiji STS set is one this SDK can bind
93
+ * the companion getCvvId to: exactly `{ key_sequences }`, 1 to 16 non-empty keySequences of printable
94
+ * ASCII. Anything else, an API that serves none included, is not acted on: the approval reads as
95
+ * malformed and the getTokenId is not continued, so no card reaches Shiji while its CVV has no
96
+ * reviewed key to go to.
97
+ */
98
+ export function isShijiStsServedCompanion(value) {
99
+ if (!value || typeof value !== 'object' || Array.isArray(value))
100
+ return false;
101
+ const names = Object.keys(value);
102
+ if (names.length !== 1 || names[0] !== 'key_sequences')
103
+ return false;
104
+ const keys = value.key_sequences;
105
+ return Array.isArray(keys) && keys.length > 0 && keys.length <= SERVED_KEY_SEQUENCES_LIMIT
106
+ && keys.every((key) => typeof key === 'string' && SERVED_KEY_SEQUENCE.test(key));
107
+ }
108
+ /**
109
+ * The continuation of an approved getTokenId: the paused body with the device's pan and expires
110
+ * written over the page's own at the body root (payment-core substituteShijiSts, which refuses a
111
+ * value that is not a ciphertext under the pinned key), the device's cvv, which this body does not
112
+ * carry and the runtime keeps in memory for the one companion getCvvId, and the reviewed getCvvId
113
+ * keys that companion may carry it under (`companion`, the replay's shijiStsCompanion, which the
114
+ * client read from the API's shiji_sts_companion).
115
+ *
116
+ * Only into `approved`, the paused getTokenId the approval was created from: `url` and `body` must
117
+ * equal it byte for byte, so the accessToken and keySequence are the ones the API reviewed at create
118
+ * (its merchant binding). Every Shiji merchant's card is encrypted under the one pinned key, so the
119
+ * device's ciphertext would tokenize the card in any STS session a later request of the same shape
120
+ * names. The adapters never hand a Shiji approval to a retry either (cdp.ts survivesAbandonment).
121
+ *
122
+ * Null when neither URL is on an STS host, so every other processor keeps the generic swap. Throws
123
+ * for any other body or URL, an STS URL that is not getTokenId, a substitution
124
+ * isShijiStsServedSubstitution refuses (`sub` is whatever the approval served, of any processor's
125
+ * shape), no reviewed getCvvId key to bind the companion to, and while the card-on-file decision is
126
+ * open: in each case before anything continues.
127
+ */
128
+ export function shijiStsTokenContinuation(url, body, sub, approved, companion) {
129
+ if (!isShijiStsHost(url) && !isShijiStsHost(approved.url))
130
+ return null;
131
+ if (url !== approved.url || body !== approved.body)
132
+ throw new ShijiStsError('unsupported');
133
+ if (shijiStsEndpoint(url, 'POST') !== 'token' || !isShijiStsServedSubstitution(sub))
134
+ throw new ShijiStsError('unsupported');
135
+ const keys = companion && Array.isArray(companion.keySequences) ? [...companion.keySequences] : null;
136
+ if (!keys || !isShijiStsServedCompanion({ key_sequences: keys }))
137
+ throw new ShijiStsError('unsupported');
138
+ return { body: substituteShijiSts(url, body, { pan: sub.fields.pan, expires: sub.fields.expires }), cvv: sub.fields.cvv, cvvKeySequences: keys };
139
+ }
140
+ /**
141
+ * One attachment's getCvvId companion: at most one binding, to the getTokenId it last continued with
142
+ * the Vault's ciphertexts. `bind` runs right before that continue, `release` when the continue
143
+ * fails or the attachment is cancelled or its page goes away, `releasePage` when the frame or target
144
+ * the getTokenId came from goes away or commits a new document, and `claim` for every getCvvId in the
145
+ * proxy's shape. The binding is payment-core's (createShijiStsCompanion: same host, same page, same
146
+ * accessToken, a reviewed getCvvId key, within 120 s, once). The CVV ciphertext leaves memory with the
147
+ * one body it goes into or with the teardown that releases it, and the binding itself is dropped a
148
+ * little after its window, so a later getCvvId reads as unbound.
149
+ */
150
+ export class ShijiStsCompanions {
151
+ bound = null;
152
+ /**
153
+ * Bind the companion of `tokenRequest` (the paused getTokenId: its URL, method and body) for the
154
+ * page `page` (the adapter's opaque id for the frame that sent it) and keep `cvv`, the device's
155
+ * CVV ciphertext, for it, to go only into a getCvvId whose keySequence is one of `cvvKeySequences`
156
+ * (the reviewed getCvvId keys the approval served). Replaces any earlier binding. Throws
157
+ * ShijiStsError for a request that is not a getTokenId in the proxy's shape, a key list
158
+ * payment-core refuses (none, empty or malformed), and while the card-on-file decision is open.
159
+ */
160
+ bind(tokenRequest, page, cvv, cvvKeySequences, now = Date.now()) {
161
+ this.release();
162
+ if (!isShijiStsCiphertext(cvv))
163
+ throw new ShijiStsError('unsupported');
164
+ const companion = createShijiStsCompanion({ url: tokenRequest.url, method: tokenRequest.method.toUpperCase(), body: tokenRequest.body }, { page, now, cvvKeySequences: Array.isArray(cvvKeySequences) ? [...cvvKeySequences] : cvvKeySequences });
165
+ const timer = setTimeout(() => { if (this.bound?.timer === timer)
166
+ this.bound = null; }, SHIJI_STS_COMPANION_WINDOW_MS + 1000);
167
+ timer.unref?.();
168
+ this.bound = { companion, cvv, page, timer };
169
+ }
170
+ /** Drop the binding and the CVV ciphertext it holds. */
171
+ release() {
172
+ if (this.bound)
173
+ clearTimeout(this.bound.timer);
174
+ this.bound = null;
175
+ }
176
+ /**
177
+ * Drop the binding only when its page is one `gone` names: the adapter calls it with a test for the
178
+ * page ids of a frame or target that went away, so the CVV ciphertext never outlives the frame its
179
+ * getCvvId would have to come from, and a binding on another frame stays.
180
+ */
181
+ releasePage(gone) {
182
+ if (this.bound && gone(this.bound.page))
183
+ this.release();
184
+ }
185
+ /** Whether a binding is held (its window may have closed; claim decides). */
186
+ isBound() {
187
+ return this.bound !== null;
188
+ }
189
+ /** The page id the binding is held for, or null with none: an adapter compares its own ids to it. */
190
+ boundPage() {
191
+ return this.bound?.page ?? null;
192
+ }
193
+ /**
194
+ * The body to continue a getCvvId with, the device's CVV written over the page's own at the body
195
+ * root, or why the request is refused. Only the first getCvvId the binding answers 'swap' for gets
196
+ * a body; the CVV ciphertext is dropped as it is written, so a second one reads as used.
197
+ */
198
+ claim(request, page, now = Date.now()) {
199
+ const bound = this.bound;
200
+ if (!bound)
201
+ return { reason: 'shiji_sts_companion_unbound' };
202
+ let answer;
203
+ try {
204
+ answer = bound.companion.claim({ url: request.url, method: request.method.toUpperCase(), body: request.body }, { page, now });
205
+ }
206
+ catch {
207
+ answer = 'unsupported';
208
+ }
209
+ if (answer !== 'swap')
210
+ return { reason: REFUSED[answer] ?? 'unsupported_shiji_sts_request' };
211
+ const cvv = bound.cvv;
212
+ bound.cvv = null;
213
+ if (cvv === null)
214
+ return { reason: 'shiji_sts_companion_used' };
215
+ try {
216
+ return { body: substituteShijiSts(request.url, request.body, { cvv }) };
217
+ }
218
+ catch {
219
+ return { reason: 'unsupported_shiji_sts_request' };
220
+ }
221
+ }
222
+ }
@@ -23,7 +23,7 @@ declare var STRIPE_CHECKOUT_VALIDATION_CODES: Readonly<{
23
23
  synthetic_payment_method: "synthetic_payment_method";
24
24
  required_final_fields: "required_final_fields";
25
25
  }>;
26
- declare function stripeCheckoutValidationCode(error: any): "unclassified" | "request_shape" | "request_body_bounds" | "request_headers" | "form_encoding" | "form_field_unknown" | "form_field_duplicate" | "form_value_bounds" | "context_invalid" | "session_binding" | "publishable_key" | "mode_binding" | "attribution_session" | "tokenization_fields" | "billing_email" | "billing_binding" | "billing_conflict" | "expected_amount" | "payment_method_type" | "synthetic_payment_method" | "required_final_fields";
26
+ declare function stripeCheckoutValidationCode(error: any): "payment_method_type" | "unclassified" | "request_shape" | "request_body_bounds" | "request_headers" | "form_encoding" | "form_field_unknown" | "form_field_duplicate" | "form_value_bounds" | "context_invalid" | "session_binding" | "publishable_key" | "mode_binding" | "attribution_session" | "tokenization_fields" | "billing_email" | "billing_binding" | "billing_conflict" | "expected_amount" | "synthetic_payment_method" | "required_final_fields";
27
27
  declare function validateStripeCheckoutIdentity(value: any): Readonly<{
28
28
  environment: any;
29
29
  livemode: boolean;