@agent-cards/sdk 0.23.20 → 0.23.22

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 (64) hide show
  1. package/CHANGELOG.md +55 -2
  2. package/PREFLIGHT.md +6 -0
  3. package/README.md +169 -5
  4. package/dist/amadeus-checkout.generated.d.ts +6 -1
  5. package/dist/amadeus-checkout.generated.js +26 -2
  6. package/dist/card-fields.generated.js +2341 -127
  7. package/dist/cdp.js +199 -28
  8. package/dist/client.d.ts +177 -9
  9. package/dist/client.js +387 -37
  10. package/dist/comgate.d.ts +50 -0
  11. package/dist/comgate.js +80 -0
  12. package/dist/creditguard.generated.js +4 -2
  13. package/dist/cse-body.js +11 -0
  14. package/dist/cybersource-secure-acceptance.generated.d.ts +1 -1
  15. package/dist/ebanx.d.ts +1 -1
  16. package/dist/ebanx.js +1 -1
  17. package/dist/eprotect.generated.d.ts +1 -1
  18. package/dist/eximbay.d.ts +46 -0
  19. package/dist/eximbay.js +69 -0
  20. package/dist/gmo.generated.js +7 -3
  21. package/dist/hipay.generated.d.ts +5 -5
  22. package/dist/hipay.generated.js +5 -2
  23. package/dist/hold.d.ts +1 -1
  24. package/dist/hold.js +10 -4
  25. package/dist/hosted-entry.d.ts +4 -0
  26. package/dist/hosted-entry.js +32 -0
  27. package/dist/index.d.ts +1 -0
  28. package/dist/lifecycle.d.ts +9 -4
  29. package/dist/lifecycle.js +16 -4
  30. package/dist/paddle-tokenex.generated.js +7 -3
  31. package/dist/paygent.generated.d.ts +60 -0
  32. package/dist/paygent.generated.js +425 -0
  33. package/dist/payrails.generated.js +7 -3
  34. package/dist/payrexx.d.ts +91 -0
  35. package/dist/payrexx.generated.d.ts +91 -0
  36. package/dist/payrexx.generated.js +536 -0
  37. package/dist/payrexx.js +141 -0
  38. package/dist/pre-claim.d.ts +30 -1
  39. package/dist/pre-claim.js +257 -39
  40. package/dist/preflight-catalog.json +58 -0
  41. package/dist/preflight-schemas.json +4 -0
  42. package/dist/preflight.generated.js +26 -2
  43. package/dist/prepared-processor.d.ts +7 -2
  44. package/dist/prepared-processor.js +16 -2
  45. package/dist/primer.generated.js +2469 -255
  46. package/dist/przelewy24.d.ts +47 -0
  47. package/dist/przelewy24.js +88 -0
  48. package/dist/registry.d.ts +6 -5
  49. package/dist/registry.js +27 -7
  50. package/dist/shiji-sts.generated.js +7 -3
  51. package/dist/stripe-checkout.generated.js +896 -19
  52. package/dist/toast-seal.generated.d.ts +37 -0
  53. package/dist/toast-seal.generated.js +625 -0
  54. package/dist/toast.generated.d.ts +41 -0
  55. package/dist/toast.generated.js +113 -0
  56. package/dist/tokenex-iframe.d.ts +93 -0
  57. package/dist/tokenex-iframe.generated.d.ts +81 -0
  58. package/dist/tokenex-iframe.generated.js +403 -0
  59. package/dist/tokenex-iframe.js +195 -0
  60. package/dist/transbank.d.ts +45 -0
  61. package/dist/transbank.js +73 -0
  62. package/dist/twoc2p.generated.js +7 -3
  63. package/examples/preflight/kernel-native/inventory.json +1 -1
  64. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
  // Generated from @agent-cards/payment-core. Do not edit.
3
- // artifact-sha256: c9116965f8802329701f18adf6519c9111857dfc4329e4f59d7666de150fb5a4
3
+ // artifact-sha256: 4289a22922e08251b579e9aadc396c8cff5d1a95b99ce35dd9a4618b43a33db5
4
4
  // src/sha256.js
5
5
  var K = /* @__PURE__ */ new Uint32Array([
6
6
  1116352408,
@@ -153,6 +153,9 @@ var typedArrayName = Object.getOwnPropertyDescriptor(TYPED_ARRAY, Symbol.toStrin
153
153
  function parseRsaPublicKey(key) {
154
154
  const spki = key && typeof key === "object" ? key.spki : void 0;
155
155
  const pin2 = key && typeof key === "object" ? key.sha256 : void 0;
156
+ const named = key && typeof key === "object" && Object.prototype.hasOwnProperty.call(key, "exponent") ? key.exponent : void 0;
157
+ if (named !== void 0 && named !== 17)
158
+ throw refuse("key");
156
159
  if (typeof spki !== "string" || spki.length > 1024 || spki.length % 4 !== 0 || !BASE64.test(spki))
157
160
  throw refuse("key");
158
161
  if (typeof pin2 !== "string" || !SHA256_HEX.test(pin2))
@@ -188,9 +191,10 @@ function parseRsaPublicKey(key) {
188
191
  if (!MODULUS_BYTES.includes(n.length) || !(n[0] & 128) || !(n[n.length - 1] & 1))
189
192
  throw refuse("key");
190
193
  const e = exponent.bytes;
191
- if (e.length !== 3 || e[0] !== 1 || e[1] !== 0 || e[2] !== 1)
194
+ const expected = named === 17 ? [17] : [1, 0, 1];
195
+ if (e.length !== expected.length || !expected.every((byte, i) => e[i] === byte))
192
196
  throw refuse("key");
193
- return Object.freeze({ n: toBigInt(n), e: 65537n, size: n.length });
197
+ return Object.freeze({ n: toBigInt(n), e: named === 17 ? 17n : 65537n, size: n.length });
194
198
  }
195
199
  function rsaesPkcs1v15Encrypt(key, message, random) {
196
200
  const { n, e, size } = parseRsaPublicKey(key);
@@ -0,0 +1,60 @@
1
+ declare var PAYGENT_PSP: string;
2
+ declare var PAYGENT_CAPABILITY: string;
3
+ declare var PAYGENT_OPERATION: string;
4
+ declare var PAYGENT_TOKEN_HOSTS: Readonly<{
5
+ production: readonly string[];
6
+ sandbox: readonly string[];
7
+ }>;
8
+ declare var PAYGENT_TOKEN_PATH: string;
9
+ declare var PAYGENT_CONTENT_TYPE: string;
10
+ declare var PAYGENT_BODY_KEYS: readonly string[];
11
+ declare var PAYGENT_REFUSAL_CODES: readonly string[];
12
+ declare function paygentEnvironment(url: any): "production" | "sandbox" | null;
13
+ declare function isPaygentTokenUrl(url: any): boolean;
14
+ declare function paygentBodyVerdict(body: any): Readonly<{
15
+ verdict: "refuse";
16
+ code: any;
17
+ }> | Readonly<{
18
+ verdict: "card";
19
+ }>;
20
+ declare function paygentRequestVerdict(url: any, body: any): Readonly<{
21
+ verdict: "refuse";
22
+ code: any;
23
+ }> | Readonly<{
24
+ verdict: "card";
25
+ }>;
26
+ declare function paygentRequestRefusal(request: any): any;
27
+ declare function paygentMerchantId(body: any): string | null;
28
+ declare function paygentBodyMerchant(body: any): {
29
+ merchantId: string;
30
+ tokenKey: string;
31
+ } | null;
32
+ declare function paygentPreparationUrl(environment: any): string;
33
+ declare var PAYGENT_MERCHANT_PINS: readonly any[];
34
+ declare function paygentMerchantPin(merchantOrigin: any, merchant: any, pins?: readonly any[]): any;
35
+ declare function paygentMerchantRefusal(environment: any, merchantOrigin: any, merchant: any, facts?: {}, pins?: readonly any[]): "unsupported_environment" | "paygent_merchant_unreviewed" | "paygent_currency_mismatch" | "paygent_merchant_mismatch" | null;
36
+ declare function isPreparedPaygentRequest(url: any, method: any, body: any, environment: any, headers: any, binding?: {}, pins?: readonly any[]): boolean;
37
+ declare function injectPaygentCard(body: any, card: any): {
38
+ body: string;
39
+ where: any[];
40
+ };
41
+ declare var PAYGENT_ANSWER_REFUSAL_CODES: readonly string[];
42
+ declare function paygentAnswerOutcome(status: any, text: any, card: any): {
43
+ outcome: string;
44
+ code: any;
45
+ reason?: undefined;
46
+ body?: undefined;
47
+ } | {
48
+ outcome: string;
49
+ reason: string | undefined;
50
+ code?: undefined;
51
+ body?: undefined;
52
+ } | {
53
+ outcome: string;
54
+ body: string;
55
+ code?: undefined;
56
+ reason?: undefined;
57
+ };
58
+ declare function paygentRefusalCode(text: any): any;
59
+ declare function paygentRefusalMessage(code: any): any;
60
+ export { PAYGENT_ANSWER_REFUSAL_CODES, PAYGENT_BODY_KEYS, PAYGENT_CAPABILITY, PAYGENT_CONTENT_TYPE, PAYGENT_MERCHANT_PINS, PAYGENT_OPERATION, PAYGENT_PSP, PAYGENT_REFUSAL_CODES, PAYGENT_TOKEN_HOSTS, PAYGENT_TOKEN_PATH, injectPaygentCard, isPaygentTokenUrl, isPreparedPaygentRequest, paygentAnswerOutcome, paygentBodyMerchant, paygentBodyVerdict, paygentEnvironment, paygentMerchantId, paygentMerchantPin, paygentMerchantRefusal, paygentPreparationUrl, paygentRefusalCode, paygentRefusalMessage, paygentRequestRefusal, paygentRequestVerdict };
@@ -0,0 +1,425 @@
1
+ // @ts-nocheck
2
+ // Generated from @agent-cards/payment-core. Do not edit.
3
+ // artifact-sha256: 32d9a3f112e2704eacabb2954570a746bef5547c8fd865a4db14b2bd0cd1d936
4
+ // src/sha256.js
5
+ var K = /* @__PURE__ */ new Uint32Array([
6
+ 1116352408,
7
+ 1899447441,
8
+ 3049323471,
9
+ 3921009573,
10
+ 961987163,
11
+ 1508970993,
12
+ 2453635748,
13
+ 2870763221,
14
+ 3624381080,
15
+ 310598401,
16
+ 607225278,
17
+ 1426881987,
18
+ 1925078388,
19
+ 2162078206,
20
+ 2614888103,
21
+ 3248222580,
22
+ 3835390401,
23
+ 4022224774,
24
+ 264347078,
25
+ 604807628,
26
+ 770255983,
27
+ 1249150122,
28
+ 1555081692,
29
+ 1996064986,
30
+ 2554220882,
31
+ 2821834349,
32
+ 2952996808,
33
+ 3210313671,
34
+ 3336571891,
35
+ 3584528711,
36
+ 113926993,
37
+ 338241895,
38
+ 666307205,
39
+ 773529912,
40
+ 1294757372,
41
+ 1396182291,
42
+ 1695183700,
43
+ 1986661051,
44
+ 2177026350,
45
+ 2456956037,
46
+ 2730485921,
47
+ 2820302411,
48
+ 3259730800,
49
+ 3345764771,
50
+ 3516065817,
51
+ 3600352804,
52
+ 4094571909,
53
+ 275423344,
54
+ 430227734,
55
+ 506948616,
56
+ 659060556,
57
+ 883997877,
58
+ 958139571,
59
+ 1322822218,
60
+ 1537002063,
61
+ 1747873779,
62
+ 1955562222,
63
+ 2024104815,
64
+ 2227730452,
65
+ 2361852424,
66
+ 2428436474,
67
+ 2756734187,
68
+ 3204031479,
69
+ 3329325298
70
+ ]);
71
+ var rotr = (x, n) => x >>> n | x << 32 - n;
72
+ function utf8(text) {
73
+ const out = [];
74
+ for (const char of text) {
75
+ let cp = char.codePointAt(0);
76
+ if (cp >= 55296 && cp <= 57343)
77
+ cp = 65533;
78
+ if (cp < 128)
79
+ out.push(cp);
80
+ else if (cp < 2048)
81
+ out.push(192 | cp >> 6, 128 | cp & 63);
82
+ else if (cp < 65536)
83
+ out.push(224 | cp >> 12, 128 | cp >> 6 & 63, 128 | cp & 63);
84
+ else
85
+ out.push(240 | cp >> 18, 128 | cp >> 12 & 63, 128 | cp >> 6 & 63, 128 | cp & 63);
86
+ }
87
+ return Uint8Array.from(out);
88
+ }
89
+ function sha256Hex(input) {
90
+ const isBytes = Object.prototype.toString.call(input) === "[object Uint8Array]";
91
+ if (typeof input !== "string" && !isBytes)
92
+ throw new TypeError("sha256Hex takes a string or a Uint8Array.");
93
+ const bytes = typeof input === "string" ? utf8(input) : input;
94
+ const length = bytes.length;
95
+ const padded = new Uint8Array((length + 8 >> 6) + 1 << 6);
96
+ padded.set(bytes);
97
+ padded[length] = 128;
98
+ const view = new DataView(padded.buffer);
99
+ view.setUint32(padded.length - 8, Math.floor(length / 536870912));
100
+ view.setUint32(padded.length - 4, length << 3 >>> 0);
101
+ const H = new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]);
102
+ const W = new Uint32Array(64);
103
+ for (let offset = 0; offset < padded.length; offset += 64) {
104
+ for (let t = 0; t < 16; t++)
105
+ W[t] = view.getUint32(offset + t * 4);
106
+ for (let t = 16; t < 64; t++) {
107
+ const s0 = rotr(W[t - 15], 7) ^ rotr(W[t - 15], 18) ^ W[t - 15] >>> 3;
108
+ const s1 = rotr(W[t - 2], 17) ^ rotr(W[t - 2], 19) ^ W[t - 2] >>> 10;
109
+ W[t] = W[t - 16] + s0 + W[t - 7] + s1 >>> 0;
110
+ }
111
+ let a = H[0], b = H[1], c = H[2], d = H[3], e = H[4], f = H[5], g = H[6], h = H[7];
112
+ for (let t = 0; t < 64; t++) {
113
+ const t1 = h + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + (e & f ^ ~e & g) + K[t] + W[t] >>> 0;
114
+ const t2 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
115
+ h = g;
116
+ g = f;
117
+ f = e;
118
+ e = d + t1 >>> 0;
119
+ d = c;
120
+ c = b;
121
+ b = a;
122
+ a = t1 + t2 >>> 0;
123
+ }
124
+ H[0] += a;
125
+ H[1] += b;
126
+ H[2] += c;
127
+ H[3] += d;
128
+ H[4] += e;
129
+ H[5] += f;
130
+ H[6] += g;
131
+ H[7] += h;
132
+ }
133
+ return Array.from(H, (word) => word.toString(16).padStart(8, "0")).join("");
134
+ }
135
+ // src/paygent.js
136
+ var PAYGENT_PSP = "paygent";
137
+ var PAYGENT_CAPABILITY = "paygent_token";
138
+ var PAYGENT_OPERATION = "paygent.card_request";
139
+ var PAYGENT_TOKEN_HOSTS = /* @__PURE__ */ Object.freeze({
140
+ production: Object.freeze(["token.paygent.co.jp"]),
141
+ sandbox: Object.freeze(["sandbox.paygent.co.jp"])
142
+ });
143
+ var PAYGENT_TOKEN_PATH = "/n/token/request";
144
+ var PAYGENT_CONTENT_TYPE = "text/plain;charset=UTF-8";
145
+ var PAYGENT_BODY_KEYS = /* @__PURE__ */ Object.freeze([
146
+ "merchant_id",
147
+ "token_generate_key",
148
+ "card_number",
149
+ "card_expire_year",
150
+ "card_expire_month",
151
+ "card_cvc",
152
+ "card_name"
153
+ ]);
154
+ var PAYGENT_REFUSAL_CODES = /* @__PURE__ */ Object.freeze([
155
+ "paygent_url_refused",
156
+ "paygent_headers_refused",
157
+ "paygent_cvc_only",
158
+ "paygent_key_environment",
159
+ "paygent_body_unsupported"
160
+ ]);
161
+ var BODY_LIMIT = 2048;
162
+ var URL_LIMIT = 128;
163
+ var MERCHANT_ID = /^[0-9]{5,6}$/;
164
+ var LIVE_KEY = /^live_[A-Za-z0-9]{24}$/;
165
+ var SANDBOX_KEY = /^(?!live_)[a-z]{1,8}_[A-Za-z0-9]{24}$/;
166
+ var NUMBER = /^[0-9]{12,19}$/;
167
+ var YEAR = /^[0-9]{2}$/;
168
+ var MONTH = /^(?:0?[1-9]|1[0-2])$/;
169
+ var SECURITY_CODE = /^[0-9]{3,4}$/;
170
+ var HOLDER = /^[A-Za-z][A-Za-z .'-]{0,44}$/;
171
+ var PAGE_HOLDER = /^(?:[A-Za-z][A-Za-z .'-]{0,44})?$/;
172
+ var CONTENT_TYPE = /^text\/plain; ?charset=utf-8$/i;
173
+ var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
174
+ var refuse = (code) => Object.freeze({ verdict: "refuse", code });
175
+ var CARD = /* @__PURE__ */ Object.freeze({ verdict: "card" });
176
+ function paygentEnvironment(url) {
177
+ if (typeof url !== "string" || url.length > URL_LIMIT || url.includes("?") || url.includes("#"))
178
+ return null;
179
+ let parsed;
180
+ try {
181
+ parsed = new URL(url);
182
+ }
183
+ catch {
184
+ return null;
185
+ }
186
+ if (parsed.href !== url || parsed.protocol !== "https:" || parsed.port || parsed.username || parsed.password || parsed.pathname !== PAYGENT_TOKEN_PATH)
187
+ return null;
188
+ if (PAYGENT_TOKEN_HOSTS.production.includes(parsed.hostname))
189
+ return "production";
190
+ if (PAYGENT_TOKEN_HOSTS.sandbox.includes(parsed.hostname))
191
+ return "sandbox";
192
+ return null;
193
+ }
194
+ function isPaygentTokenUrl(url) {
195
+ return paygentEnvironment(url) !== null;
196
+ }
197
+ function readBody(body) {
198
+ if (typeof body !== "string" || body === "" || body.length > BODY_LIMIT)
199
+ return null;
200
+ try {
201
+ const pairs = body.split("&").map((chunk) => {
202
+ const eq = chunk.indexOf("=");
203
+ if (eq <= 0)
204
+ throw new URIError("not a pair");
205
+ return [chunk.slice(0, eq), decodeURIComponent(chunk.slice(eq + 1))];
206
+ });
207
+ return pairs.map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join("&") === body ? pairs : null;
208
+ }
209
+ catch {
210
+ return null;
211
+ }
212
+ }
213
+ var CVC_ONLY_KEYS = /* @__PURE__ */ Object.freeze(["merchant_id", "token_generate_key", "card_cvc", "cvc_only_flg"]);
214
+ var sameKeys = (pairs, keys) => pairs.length === keys.length && pairs.every(([key], at) => key === keys[at]);
215
+ function judgeBody(body) {
216
+ const pairs = readBody(body);
217
+ if (pairs === null)
218
+ return { code: "paygent_body_unsupported", pairs: null };
219
+ if (sameKeys(pairs, CVC_ONLY_KEYS))
220
+ return { code: "paygent_cvc_only", pairs: null };
221
+ if (!sameKeys(pairs, PAYGENT_BODY_KEYS))
222
+ return { code: "paygent_body_unsupported", pairs: null };
223
+ const value = Object.fromEntries(pairs);
224
+ if (!MERCHANT_ID.test(value.merchant_id) || !(LIVE_KEY.test(value.token_generate_key) || SANDBOX_KEY.test(value.token_generate_key)) || !NUMBER.test(value.card_number) || !YEAR.test(value.card_expire_year) || !MONTH.test(value.card_expire_month) || !SECURITY_CODE.test(value.card_cvc) || !PAGE_HOLDER.test(value.card_name)) {
225
+ return { code: "paygent_body_unsupported", pairs: null };
226
+ }
227
+ return { code: null, pairs };
228
+ }
229
+ function paygentBodyVerdict(body) {
230
+ const { code } = judgeBody(body);
231
+ return code === null ? CARD : refuse(code);
232
+ }
233
+ function paygentRequestVerdict(url, body) {
234
+ const environment = paygentEnvironment(url);
235
+ if (environment === null)
236
+ return refuse("paygent_url_refused");
237
+ const { code, pairs } = judgeBody(body);
238
+ if (code !== null)
239
+ return refuse(code);
240
+ const key = pairs[1][1];
241
+ return (environment === "production" ? LIVE_KEY : SANDBOX_KEY).test(key) ? CARD : refuse("paygent_key_environment");
242
+ }
243
+ function paygentRequestRefusal(request) {
244
+ if (!record(request) || request.method !== "POST" || !isPaygentTokenUrl(request.url))
245
+ return "paygent_url_refused";
246
+ const headers = /* @__PURE__ */ new Map();
247
+ for (const [name, value] of Object.entries(record(request.headers) ? request.headers : {})) {
248
+ const lower = name.toLowerCase();
249
+ if (headers.has(lower) || typeof value !== "string")
250
+ return "paygent_headers_refused";
251
+ headers.set(lower, value);
252
+ }
253
+ const contentType = headers.get("content-type");
254
+ if (contentType === void 0 || !CONTENT_TYPE.test(contentType))
255
+ return "paygent_headers_refused";
256
+ const verdict = paygentRequestVerdict(request.url, request.body);
257
+ return verdict.verdict === "card" ? null : verdict.code;
258
+ }
259
+ function paygentMerchantId(body) {
260
+ const { code, pairs } = judgeBody(body);
261
+ return code === null ? pairs[0][1] : null;
262
+ }
263
+ function paygentBodyMerchant(body) {
264
+ const { code, pairs } = judgeBody(body);
265
+ return code === null ? { merchantId: pairs[0][1], tokenKey: pairs[1][1] } : null;
266
+ }
267
+ function paygentPreparationUrl(environment) {
268
+ if (environment !== "production" && environment !== "sandbox")
269
+ throw new Error("unsupported_preparation_environment");
270
+ return `https://${PAYGENT_TOKEN_HOSTS[environment][0]}${PAYGENT_TOKEN_PATH}`;
271
+ }
272
+ var pin = (fields) => Object.freeze({ ...fields, origins: Object.freeze([...fields.origins]) });
273
+ var PAYGENT_MERCHANT_PINS = /* @__PURE__ */ Object.freeze([
274
+ pin({
275
+ id: "fundex_tcs_eng",
276
+ merchant: "Tokyo Chinese School",
277
+ merchantId: "60362",
278
+ keySha256: "6073dee112b1e4089025d1c1f3c4cfad818c314a81943ffa55b839cb2df51018",
279
+ origins: ["https://fundexapp.jp"],
280
+ currency: "jpy"
281
+ })
282
+ ]);
283
+ function paygentMerchantPin(merchantOrigin, merchant, pins = PAYGENT_MERCHANT_PINS) {
284
+ if (typeof merchantOrigin !== "string" || typeof merchant !== "string" || !Array.isArray(pins))
285
+ return null;
286
+ return pins.find((entry) => !!entry && Array.isArray(entry.origins) && entry.origins.includes(merchantOrigin) && entry.merchant === merchant) ?? null;
287
+ }
288
+ function paygentMerchantRefusal(environment, merchantOrigin, merchant, facts = {}, pins = PAYGENT_MERCHANT_PINS) {
289
+ if (environment === "sandbox")
290
+ return null;
291
+ if (environment !== "production")
292
+ return "unsupported_environment";
293
+ const found = paygentMerchantPin(merchantOrigin, merchant, pins);
294
+ if (!found)
295
+ return "paygent_merchant_unreviewed";
296
+ const given = record(facts) ? facts : {};
297
+ if (given.currency !== void 0 && given.currency !== found.currency)
298
+ return "paygent_currency_mismatch";
299
+ if (given.merchantId !== void 0 && given.merchantId !== found.merchantId)
300
+ return "paygent_merchant_mismatch";
301
+ if (given.tokenKey !== void 0 && (typeof given.tokenKey !== "string" || typeof found.keySha256 !== "string" || sha256Hex(given.tokenKey) !== found.keySha256))
302
+ return "paygent_merchant_mismatch";
303
+ return null;
304
+ }
305
+ function isPreparedPaygentRequest(url, method, body, environment, headers, binding = {}, pins = PAYGENT_MERCHANT_PINS) {
306
+ if (environment !== "production" && environment !== "sandbox" || paygentEnvironment(url) !== environment || paygentRequestRefusal({ url, method, headers, body }) !== null)
307
+ return false;
308
+ const given = record(binding) ? binding : {};
309
+ const facts = paygentBodyMerchant(body);
310
+ return facts !== null && paygentMerchantRefusal(environment, given.merchantOrigin, given.merchant, facts, pins) === null;
311
+ }
312
+ var digits = (value, min, max) => typeof value === "string" && value.length >= min && value.length <= max && !/[^0-9]/.test(value);
313
+ var whole = (value, min, max) => {
314
+ if (Number.isSafeInteger(value) && value >= 0)
315
+ return value;
316
+ return digits(value, min, max) ? Number(value) : NaN;
317
+ };
318
+ var cardYear = (year) => year >= 0 && year <= 99 || year >= 2e3 && year <= 2099;
319
+ var AMEX = /^3[47]/;
320
+ var FILL_REFUSAL = "Could not fill the card fields for Paygent. Nothing was sent.";
321
+ function injectPaygentCard(body, card) {
322
+ const { code, pairs } = judgeBody(body);
323
+ if (code !== null)
324
+ throw new Error(paygentRefusalMessage(code));
325
+ const month = card ? whole(card.month, 1, 2) : NaN;
326
+ const year = card ? whole(card.year, 2, 4) : NaN;
327
+ if (!card || !digits(card.number, 12, 19) || !(month >= 1 && month <= 12) || !cardYear(year) || !digits(card.cvc, AMEX.test(card.number) ? 4 : 3, AMEX.test(card.number) ? 4 : 3)) {
328
+ throw new Error(FILL_REFUSAL);
329
+ }
330
+ const written = {
331
+ card_number: card.number,
332
+ card_expire_year: String(year % 100).padStart(2, "0"),
333
+ card_expire_month: String(month).padStart(2, "0"),
334
+ card_cvc: card.cvc
335
+ };
336
+ if (pairs[6][1] !== "" && typeof card.name === "string" && HOLDER.test(card.name))
337
+ written.card_name = card.name;
338
+ const where = [];
339
+ const filled = pairs.map(([key, value]) => {
340
+ if (!Object.prototype.hasOwnProperty.call(written, key))
341
+ return `${key}=${encodeURIComponent(value)}`;
342
+ where.push(key);
343
+ return `${key}=${encodeURIComponent(written[key])}`;
344
+ });
345
+ return { body: filled.join("&"), where };
346
+ }
347
+ var PAYGENT_ANSWER_REFUSAL_CODES = /* @__PURE__ */ Object.freeze([
348
+ "1100",
349
+ "1200",
350
+ "1300",
351
+ "1301",
352
+ "1400",
353
+ "1401",
354
+ "1500",
355
+ "1501",
356
+ "1502",
357
+ "1600",
358
+ "1601",
359
+ "1700"
360
+ ]);
361
+ var ANSWER_LIMIT = 4096;
362
+ var TOKEN = /^[A-Za-z0-9+/=_.-]{8,256}$/;
363
+ var MASKED = /^(?=.{12,19}$)[0-9]{0,6}[*Xx]{2,}[0-9]{4}$/;
364
+ var VALID_UNTIL = /^[0-9][0-9 :/.T-]{7,31}$/;
365
+ var FINGERPRINT = /^[A-Za-z0-9+/=_.-]{1,256}$/;
366
+ var TOKEN_KEYS = /* @__PURE__ */ Object.freeze(["token", "masked_card_number", "valid_until", "fingerprint"]);
367
+ var HC = /^[A-Za-z0-9+/=_.-]{1,256}$/;
368
+ function readAnswer(status, text) {
369
+ if (status !== 200)
370
+ return { kind: "unknown", reason: status >= 500 ? "server_error" : "paygent_answer_status" };
371
+ if (typeof text !== "string" || text.length > ANSWER_LIMIT)
372
+ return { kind: "unknown", reason: "paygent_answer_unreadable" };
373
+ let answer;
374
+ try {
375
+ answer = JSON.parse(text);
376
+ }
377
+ catch {
378
+ return { kind: "unknown", reason: "paygent_answer_unreadable" };
379
+ }
380
+ if (!record(answer) || typeof answer.result !== "string")
381
+ return { kind: "unknown", reason: "paygent_answer_unreadable" };
382
+ if (answer.result !== "0000") {
383
+ return PAYGENT_ANSWER_REFUSAL_CODES.includes(answer.result) ? { kind: "refused", code: answer.result } : { kind: "unknown", reason: "paygent_answer_unknown_result" };
384
+ }
385
+ const card = answer.tokenizedCardObject;
386
+ if (!record(card) || typeof card.token !== "string" || !TOKEN.test(card.token) || typeof card.masked_card_number !== "string" || !MASKED.test(card.masked_card_number) || typeof card.valid_until !== "string" || !VALID_UNTIL.test(card.valid_until) || card.fingerprint !== void 0 && (typeof card.fingerprint !== "string" || !FINGERPRINT.test(card.fingerprint))) {
387
+ return { kind: "unknown", reason: "paygent_token_unconfirmed" };
388
+ }
389
+ if (answer.hc !== void 0 && (typeof answer.hc !== "string" || !HC.test(answer.hc))) {
390
+ return { kind: "unknown", reason: "paygent_token_unconfirmed" };
391
+ }
392
+ return { kind: "token", answer: card, hc: answer.hc };
393
+ }
394
+ var rebuild = (card, hc) => JSON.stringify({ result: "0000", tokenizedCardObject: Object.fromEntries(TOKEN_KEYS.filter((key) => card[key] !== void 0).map((key) => [key, card[key]])), ...hc !== void 0 ? { hc } : {} });
395
+ function paygentAnswerOutcome(status, text, card) {
396
+ const read = readAnswer(status, text);
397
+ if (read.kind === "refused")
398
+ return { outcome: "refused", code: read.code };
399
+ if (read.kind !== "token")
400
+ return { outcome: "unknown", reason: read.reason };
401
+ if (card) {
402
+ const number = String(card.number);
403
+ const masked = read.answer.masked_card_number;
404
+ const inPlace = masked.length === number.length && [...masked].every((ch, at) => !/[0-9]/.test(ch) || ch === number[at]);
405
+ if (!inPlace || [...TOKEN_KEYS.map((key) => read.answer[key]), read.hc].some((value) => typeof value === "string" && value.includes(number))) {
406
+ return { outcome: "unknown", reason: "paygent_token_mismatch" };
407
+ }
408
+ }
409
+ return { outcome: "approved", body: rebuild(read.answer, read.hc) };
410
+ }
411
+ function paygentRefusalCode(text) {
412
+ const read = readAnswer(200, text);
413
+ return read.kind === "refused" ? read.code : null;
414
+ }
415
+ var REFUSAL_MESSAGES = /* @__PURE__ */ Object.freeze({
416
+ paygent_url_refused: "Refusing to pay: this Paygent card request does not go to Paygent's token address exactly as Paygent's script sends it. Nothing was sent.",
417
+ paygent_headers_refused: "Refusing to pay: this Paygent card request does not carry Paygent's own content type. Nothing was sent.",
418
+ paygent_cvc_only: "Refusing to pay: this Paygent request is for a card the merchant keeps on file, not a card from your Vault. Nothing was sent.",
419
+ paygent_key_environment: "Refusing to pay: this Paygent card request uses a test key on Paygent's live address, or a live key on its test address. Nothing was sent.",
420
+ paygent_body_unsupported: "Refusing to pay: this is not the card request of Paygent's token script. Nothing was sent."
421
+ });
422
+ function paygentRefusalMessage(code) {
423
+ return Object.prototype.hasOwnProperty.call(REFUSAL_MESSAGES, code) ? REFUSAL_MESSAGES[code] : REFUSAL_MESSAGES.paygent_body_unsupported;
424
+ }
425
+ export { PAYGENT_ANSWER_REFUSAL_CODES, PAYGENT_BODY_KEYS, PAYGENT_CAPABILITY, PAYGENT_CONTENT_TYPE, PAYGENT_MERCHANT_PINS, PAYGENT_OPERATION, PAYGENT_PSP, PAYGENT_REFUSAL_CODES, PAYGENT_TOKEN_HOSTS, PAYGENT_TOKEN_PATH, injectPaygentCard, isPaygentTokenUrl, isPreparedPaygentRequest, paygentAnswerOutcome, paygentBodyMerchant, paygentBodyVerdict, paygentEnvironment, paygentMerchantId, paygentMerchantPin, paygentMerchantRefusal, paygentPreparationUrl, paygentRefusalCode, paygentRefusalMessage, paygentRequestRefusal, paygentRequestVerdict };
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
  // Generated from @agent-cards/payment-core. Do not edit.
3
- // artifact-sha256: 38065a5bd834d5233979a0528fde4345378914e8e8b1a63e329bff0994572da5
3
+ // artifact-sha256: 056fa54de953be9af775505906b2fba30def2787a217a12fe2ca2a50b8614649
4
4
  // src/json-path.js
5
5
  function roundTrips(parsed, body) {
6
6
  try {
@@ -160,6 +160,9 @@ var typedArrayName = Object.getOwnPropertyDescriptor(TYPED_ARRAY, Symbol.toStrin
160
160
  function parseRsaPublicKey(key) {
161
161
  const spki = key && typeof key === "object" ? key.spki : void 0;
162
162
  const pin = key && typeof key === "object" ? key.sha256 : void 0;
163
+ const named = key && typeof key === "object" && Object.prototype.hasOwnProperty.call(key, "exponent") ? key.exponent : void 0;
164
+ if (named !== void 0 && named !== 17)
165
+ throw refuse("key");
163
166
  if (typeof spki !== "string" || spki.length > 1024 || spki.length % 4 !== 0 || !BASE64.test(spki))
164
167
  throw refuse("key");
165
168
  if (typeof pin !== "string" || !SHA256_HEX.test(pin))
@@ -195,9 +198,10 @@ function parseRsaPublicKey(key) {
195
198
  if (!MODULUS_BYTES.includes(n.length) || !(n[0] & 128) || !(n[n.length - 1] & 1))
196
199
  throw refuse("key");
197
200
  const e = exponent.bytes;
198
- if (e.length !== 3 || e[0] !== 1 || e[1] !== 0 || e[2] !== 1)
201
+ const expected = named === 17 ? [17] : [1, 0, 1];
202
+ if (e.length !== expected.length || !expected.every((byte, i) => e[i] === byte))
199
203
  throw refuse("key");
200
- return Object.freeze({ n: toBigInt(n), e: 65537n, size: n.length });
204
+ return Object.freeze({ n: toBigInt(n), e: named === 17 ? 17n : 65537n, size: n.length });
201
205
  }
202
206
  function readElement(der, at, tag) {
203
207
  if (at + 2 > der.length || der[at] !== tag)
@@ -0,0 +1,91 @@
1
+ export declare const PAYREXX_PSP: "payrexx";
2
+ /** The capability a build declares to be served Payrexx's recognizer (payment-core PAYREXX_CAPABILITY). */
3
+ export declare const PAYREXX_CAPABILITY: "payrexx_card_frame";
4
+ /** The reason a checkout reads when a 3-D Secure send of the placeholder card fails in the browser. */
5
+ export declare const PAYREXX_RESEND_REASON: "unsupported_payrexx_card_resend";
6
+ /** The 3-D Secure sends one approval covers, in the page's order (payment-core PAYREXX_FOLLOW_UP_KINDS). */
7
+ export type PayrexxFollowUpKind = 'authentication' | 'post_authentication';
8
+ /**
9
+ * Whether a request is a POST to Payrexx's card frame URL whose body sends the card again for a 3-D Secure step
10
+ * (payment-core payrexxBodyVerdict: payrexx_three_ds_resend). `readBody` is called only for a POST to the frame URL,
11
+ * and a reader that throws, or a body nobody could read, reads as no 3-D Secure send.
12
+ */
13
+ export declare function isPayrexxResend(url: string, method: string, readBody: () => string | null): boolean;
14
+ /**
15
+ * A 3-D Secure send the cardholder's device did not answer with Payrexx's own answer. `reason` is the API's word for
16
+ * it: `not_picked_up` (no device started it in time: the Vault page was closed or asleep), `not_sent` (the device
17
+ * refused it before the card left), `no_answer`, `answer_withheld` (Payrexx's answer carried the card),
18
+ * `answer_refused`, `answer_late`, `response_expired`, or the API's refusal code when it did not take the send at all
19
+ * (`follow_up_refused`, `follow_up_not_covered`, `follow_up_window_closed`). `cardSent` says whether the card may
20
+ * have reached Payrexx: false only when the API confirmed it never left the device. Nothing in it names the request,
21
+ * the card or Payrexx's answer.
22
+ */
23
+ export declare class PayrexxFollowUpError extends Error {
24
+ readonly reason: string;
25
+ readonly cardSent: boolean;
26
+ readonly authorizationId: string;
27
+ constructor(reason: string, cardSent: boolean, authorizationId: string);
28
+ }
29
+ /** A send this attachment claimed: the approval it goes under, its kind, the request to send, and how it ended. */
30
+ export interface PayrexxFollowUpClaim {
31
+ readonly authorizationId: string;
32
+ readonly kind: PayrexxFollowUpKind;
33
+ readonly until: number;
34
+ readonly request: {
35
+ url: string;
36
+ method: 'POST';
37
+ headers: Record<string, string>;
38
+ body: string;
39
+ };
40
+ /** Record the answer the page received, or null when the send failed. */
41
+ settle(answer: {
42
+ status: number;
43
+ text: string;
44
+ } | null): void;
45
+ }
46
+ /**
47
+ * What one attachment keeps of its approved Payrexx card request: the request and Payrexx's answer as the page received
48
+ * them, until when the API said the approval covers sends after it, and the sends it claimed since, in order. Only a
49
+ * card request whose answer started 3-D Secure (payment-core payrexxAnswerOutcome: pending three_ds) and whose read
50
+ * named that window (`followUpsUntil`) is kept. Any later Payrexx card request handed over replaces it, a send the
51
+ * window has passed is never claimed, and once a send is refused or fails the attachment stops (stop()): nothing after
52
+ * it is claimed, a later approval included.
53
+ */
54
+ export declare class PayrexxFollowUps {
55
+ private parent;
56
+ private sent;
57
+ private stopped;
58
+ /** After a refused or failed send: no later request on this attachment is claimed. */
59
+ stop(): void;
60
+ /**
61
+ * The approval the remembered card request went under, or null when none is remembered. The gate sends nothing
62
+ * unless the checkout's own state names this same approval.
63
+ */
64
+ get authorizationId(): string | null;
65
+ /**
66
+ * As the adapter hands an approved card request's answer to the page: before the answer lands, since the page may
67
+ * start 3-D Secure at once. Every Payrexx card request handed over clears what an earlier one left; only one whose
68
+ * answer started 3-D Secure, under a read that named the window, is kept.
69
+ */
70
+ remember(request: {
71
+ url: string;
72
+ body: string;
73
+ }, replay: {
74
+ mode?: string;
75
+ authorizationId: string;
76
+ status: number;
77
+ body: string;
78
+ followUpsUntil?: string;
79
+ }): void;
80
+ /**
81
+ * The claim for a paused 3-D Secure send the remembered approval covers, or null: no approval covers sends here, its
82
+ * window has passed, or payment-core's rule refuses the send against the sends already claimed. Synchronous, and it
83
+ * reserves the send, so two requests can never both be claimed as the next one.
84
+ */
85
+ claim(request: {
86
+ url: string;
87
+ method: string;
88
+ headers: Record<string, string>;
89
+ body: string | null;
90
+ }, now?: number): PayrexxFollowUpClaim | null;
91
+ }