@agent-cards/sdk 0.23.28 → 0.24.1

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 (110) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/PREFLIGHT.md +7 -1
  3. package/README.md +197 -102
  4. package/dist/aci.d.ts +52 -22
  5. package/dist/aci.js +79 -15
  6. package/dist/adyen-merchant-hosted.generated.d.ts +2 -2
  7. package/dist/adyen-merchant-hosted.generated.js +586 -55
  8. package/dist/agent-amount.generated.js +1 -1
  9. package/dist/agentcard.d.ts +4 -5
  10. package/dist/agentcard.js +4 -5
  11. package/dist/amadeus.d.ts +9 -3
  12. package/dist/amadeus.js +33 -4
  13. package/dist/api-module.d.ts +1 -7
  14. package/dist/api-module.js +3 -5
  15. package/dist/{voice-retry.js → api-retry.js} +1 -1
  16. package/dist/api-types.d.ts +53 -0
  17. package/dist/{voice-types.js → api-types.js} +7 -2
  18. package/dist/approvals.d.ts +166 -0
  19. package/dist/approvals.js +213 -0
  20. package/dist/aurus.d.ts +33 -0
  21. package/dist/aurus.js +75 -0
  22. package/dist/builtin-registry.generated.js +1 -1
  23. package/dist/buy.d.ts +20 -101
  24. package/dist/buy.js +19 -74
  25. package/dist/capabilities.generated.js +1 -1
  26. package/dist/card-fields.generated.js +2864 -249
  27. package/dist/cardlink-vpos.d.ts +43 -0
  28. package/dist/cardlink-vpos.js +90 -0
  29. package/dist/cdp.d.ts +3 -13
  30. package/dist/cdp.js +244 -175
  31. package/dist/checkout-com.generated.js +5 -1
  32. package/dist/client.d.ts +170 -22
  33. package/dist/client.js +281 -40
  34. package/dist/creditguard.generated.d.ts +4 -4
  35. package/dist/cybersource-flex.generated.d.ts +39 -1
  36. package/dist/cybersource-flex.generated.js +100 -11
  37. package/dist/datatrans.generated.js +22 -1
  38. package/dist/eghl.d.ts +40 -0
  39. package/dist/eghl.js +72 -0
  40. package/dist/elavon-converge.generated.js +5 -3
  41. package/dist/gmo.generated.js +7 -2
  42. package/dist/hold.d.ts +8 -0
  43. package/dist/hold.js +43 -2
  44. package/dist/hosted-entry.js +4 -0
  45. package/dist/index.d.ts +9 -15
  46. package/dist/index.js +6 -10
  47. package/dist/lifecycle.d.ts +9 -61
  48. package/dist/lifecycle.js +24 -10
  49. package/dist/merchant-card-endpoints.generated.d.ts +6 -1
  50. package/dist/merchant-card-endpoints.generated.js +344 -19
  51. package/dist/merchant-hosted.d.ts +8 -1
  52. package/dist/nike-order.d.ts +51 -0
  53. package/dist/nike-order.js +81 -0
  54. package/dist/oceanpayment.d.ts +38 -0
  55. package/dist/oceanpayment.js +70 -0
  56. package/dist/paddle-tokenex.generated.js +111 -11
  57. package/dist/payplug.d.ts +41 -0
  58. package/dist/payplug.js +71 -0
  59. package/dist/payrails.generated.js +33 -8
  60. package/dist/pre-claim.d.ts +11 -0
  61. package/dist/pre-claim.js +130 -7
  62. package/dist/preflight-capabilities.generated.d.ts +0 -4
  63. package/dist/preflight-capabilities.generated.js +0 -5
  64. package/dist/preflight-catalog.json +200 -6
  65. package/dist/preflight-playwright.d.ts +2 -2
  66. package/dist/preflight-playwright.js +63 -14
  67. package/dist/preflight-schemas.json +18 -0
  68. package/dist/preflight.generated.d.ts +5 -4
  69. package/dist/preflight.generated.js +63 -3
  70. package/dist/preparation.d.ts +7 -0
  71. package/dist/preparation.js +21 -0
  72. package/dist/prepared-processor.d.ts +18 -5
  73. package/dist/prepared-processor.js +48 -8
  74. package/dist/primer.generated.js +2889 -268
  75. package/dist/processout.generated.d.ts +61 -0
  76. package/dist/processout.generated.js +577 -0
  77. package/dist/requests.js +1 -1
  78. package/dist/shiji-sts.generated.js +111 -11
  79. package/dist/stripe-checkout.generated.js +2761 -319
  80. package/dist/substitutions.generated.js +553 -26
  81. package/dist/tap-payments.generated.js +111 -11
  82. package/dist/twoc2p.generated.js +111 -11
  83. package/dist/url-masks/bluesnap.d.ts +2 -0
  84. package/dist/url-masks/bluesnap.js +15 -0
  85. package/dist/url-masks/oceanpayment.d.ts +2 -0
  86. package/dist/url-masks/oceanpayment.js +13 -0
  87. package/dist/url-masks/payplug.d.ts +2 -0
  88. package/dist/url-masks/payplug.js +13 -0
  89. package/dist/url-masks/vtex_payments.d.ts +2 -0
  90. package/dist/url-masks/vtex_payments.js +12 -0
  91. package/dist/url-masks.generated.d.ts +1 -1
  92. package/dist/url-masks.generated.js +6 -2
  93. package/dist/verifone.generated.js +42 -2
  94. package/dist/vtex-payments.generated.d.ts +127 -0
  95. package/dist/vtex-payments.generated.js +544 -0
  96. package/dist/webhooks.d.ts +2 -2
  97. package/dist/webhooks.js +2 -2
  98. package/examples/preflight/kernel-native/inventory.json +1 -1
  99. package/package.json +6 -8
  100. package/dist/languages.d.ts +0 -23
  101. package/dist/languages.js +0 -76
  102. package/dist/voice-pkce.d.ts +0 -49
  103. package/dist/voice-pkce.js +0 -147
  104. package/dist/voice-stream.generated.d.ts +0 -118
  105. package/dist/voice-stream.generated.js +0 -170
  106. package/dist/voice-types.d.ts +0 -735
  107. package/dist/voice.d.ts +0 -373
  108. package/dist/voice.js +0 -815
  109. package/readme.test.mjs +0 -53
  110. /package/dist/{voice-retry.d.ts → api-retry.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  // @ts-nocheck
2
2
  // Generated from @agent-cards/payment-core. Do not edit.
3
- // artifact-sha256: 9e15c873e3e3002651f0d5bcde91507c344bf33bfacec748aabfd56c6e7529f1
3
+ // artifact-sha256: a8df2fb26245ce80114ca67b02b7b6b0319e93217035e4fb52ea77c640e42189
4
4
  // src/sha256.js
5
5
  var K = /* @__PURE__ */ new Uint32Array([
6
6
  1116352408,
@@ -146,6 +146,7 @@ var BASE64 = /^[A-Za-z0-9+/]+={0,2}$/;
146
146
  var SHA256_HEX = /^[0-9a-f]{64}$/;
147
147
  var RSA_ALGORITHM = [48, 13, 6, 9, 42, 134, 72, 134, 247, 13, 1, 1, 1, 5, 0];
148
148
  var MODULUS_BYTES = [128, 256, 384, 512];
149
+ var SMALL_MODULUS_BYTES = 64;
149
150
  var MIN_PADDING = 8;
150
151
  var MAX_DRAWS = 16;
151
152
  var TYPED_ARRAY = Object.getPrototypeOf(Uint8Array.prototype);
@@ -156,6 +157,9 @@ function parseRsaPublicKey(key) {
156
157
  const named = key && typeof key === "object" && Object.prototype.hasOwnProperty.call(key, "exponent") ? key.exponent : void 0;
157
158
  if (named !== void 0 && named !== 17)
158
159
  throw refuse("key");
160
+ const sized = key && typeof key === "object" && Object.prototype.hasOwnProperty.call(key, "bits") ? key.bits : void 0;
161
+ if (sized !== void 0 && sized !== 512)
162
+ throw refuse("key");
159
163
  if (typeof spki !== "string" || spki.length > 1024 || spki.length % 4 !== 0 || !BASE64.test(spki))
160
164
  throw refuse("key");
161
165
  if (typeof pin !== "string" || !SHA256_HEX.test(pin))
@@ -188,7 +192,8 @@ function parseRsaPublicKey(key) {
188
192
  if (exponent.end !== rsa.end)
189
193
  throw refuse("key");
190
194
  const n = modulus.bytes;
191
- if (!MODULUS_BYTES.includes(n.length) || !(n[0] & 128) || !(n[n.length - 1] & 1))
195
+ const sizes = sized === 512 ? [SMALL_MODULUS_BYTES] : MODULUS_BYTES;
196
+ if (!sizes.includes(n.length) || !(n[0] & 128) || !(n[n.length - 1] & 1))
192
197
  throw refuse("key");
193
198
  const e = exponent.bytes;
194
199
  const expected = named === 17 ? [17] : [1, 0, 1];
@@ -335,9 +340,64 @@ function isPlainObject(v) {
335
340
  return !!v && typeof v === "object" && !Array.isArray(v);
336
341
  }
337
342
  var MAX_PATH_STEPS = 16;
343
+ var MAX_TEXT_STEPS = 2;
344
+ function isTextStep(step) {
345
+ return isPlainObject(step) && Object.keys(step).length === 1 && step.text === "json";
346
+ }
347
+ function sameStep(a, b) {
348
+ return a === b || isTextStep(a) && isTextStep(b);
349
+ }
350
+ function spellJson(parsed, form) {
351
+ const text = JSON.stringify(parsed);
352
+ if (form !== "php")
353
+ return text;
354
+ return text.replace(/\//g, "\\/").replace(/[\u0080-\uffff]/g, (unit) => `\\u${unit.charCodeAt(0).toString(16).padStart(4, "0")}`);
355
+ }
356
+ function jsonTextForm(value) {
357
+ if (typeof value !== "string" || !/^[[{]/.test(value))
358
+ return void 0;
359
+ let parsed;
360
+ try {
361
+ parsed = JSON.parse(value);
362
+ }
363
+ catch {
364
+ return void 0;
365
+ }
366
+ if (parsed === null || typeof parsed !== "object")
367
+ return void 0;
368
+ for (const form of ["js", "php"]) {
369
+ try {
370
+ if (spellJson(parsed, form) === value)
371
+ return { parsed, form };
372
+ }
373
+ catch {
374
+ return void 0;
375
+ }
376
+ }
377
+ return void 0;
378
+ }
379
+ function jsonText(value) {
380
+ return jsonTextForm(value)?.parsed;
381
+ }
338
382
  function isJsonPath(path) {
339
383
  return Array.isArray(path) && path.length <= MAX_PATH_STEPS && path.every((step) => typeof step === "string" ? step.length > 0 && !FORBIDDEN_KEYS.has(step) : Number.isSafeInteger(step) && step >= 0);
340
384
  }
385
+ function isProfilePath(path) {
386
+ if (!Array.isArray(path) || path.length > MAX_PATH_STEPS)
387
+ return false;
388
+ let texts = 0;
389
+ for (const [i, step] of path.entries()) {
390
+ if (isTextStep(step)) {
391
+ texts += 1;
392
+ if (i === 0 || i === path.length - 1 || isTextStep(path[i - 1]) || texts > MAX_TEXT_STEPS)
393
+ return false;
394
+ }
395
+ else if (!isJsonPath([step])) {
396
+ return false;
397
+ }
398
+ }
399
+ return true;
400
+ }
341
401
  function jsonAt(root, path) {
342
402
  let node = root;
343
403
  for (const step of path) {
@@ -352,6 +412,42 @@ function jsonAt(root, path) {
352
412
  }
353
413
  return { found: true, value: node };
354
414
  }
415
+ function profileAt(root, path) {
416
+ if (!isProfilePath(path))
417
+ return { found: false };
418
+ let node = root;
419
+ for (const step of path) {
420
+ if (isTextStep(step)) {
421
+ const inner = jsonText(node);
422
+ if (inner === void 0)
423
+ return { found: false };
424
+ node = inner;
425
+ continue;
426
+ }
427
+ const at = jsonAt(node, [step]);
428
+ if (!at.found)
429
+ return { found: false };
430
+ node = at.value;
431
+ }
432
+ return { found: true, value: node };
433
+ }
434
+ function editAtProfilePath(root, path, edit) {
435
+ const at = profileAt(root, path);
436
+ if (!at.found || !isPlainObject(at.value))
437
+ return false;
438
+ const k = path.findIndex(isTextStep);
439
+ if (k === -1) {
440
+ edit(at.value);
441
+ return true;
442
+ }
443
+ const holder = jsonAt(root, path.slice(0, k - 1)).value;
444
+ const key = path[k - 1];
445
+ const text = jsonTextForm(holder[key]);
446
+ if (!text || !editAtProfilePath(text.parsed, path.slice(k + 1), edit))
447
+ return false;
448
+ holder[key] = spellJson(text.parsed, text.form);
449
+ return true;
450
+ }
355
451
  function roundTrips(parsed, body) {
356
452
  try {
357
453
  return JSON.stringify(parsed) === body;
@@ -361,17 +457,17 @@ function roundTrips(parsed, body) {
361
457
  }
362
458
  }
363
459
  function sameSteps(a, b) {
364
- return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((step, i) => step === b[i]);
460
+ return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((step, i) => sameStep(step, b[i]));
365
461
  }
366
462
  function pathsOverlap(a, b) {
367
463
  const n = Math.min(a.length, b.length);
368
464
  for (let i = 0; i < n; i += 1)
369
- if (a[i] !== b[i])
465
+ if (!sameStep(a[i], b[i]))
370
466
  return false;
371
467
  return true;
372
468
  }
373
469
  function describePath(path) {
374
- return path.length ? path.map((step) => typeof step === "number" ? `[${step}]` : `.${step}`).join("").replace(/^\./, "") : "(root)";
470
+ return path.length ? path.map((step) => typeof step === "number" ? `[${step}]` : isTextStep(step) ? "<json>" : `.${step}`).join("").replace(/^\./, "") : "(root)";
375
471
  }
376
472
  // src/substitution-primitives.js
377
473
  var SubstitutionError = class extends Error {
@@ -420,7 +516,7 @@ function swapMerchantHostedFields(body, spec, ciphertext = ADYEN_JWE) {
420
516
  const path = Array.isArray(spec.path) ? [...spec.path] : spec.path;
421
517
  const fields = isPlainObject(spec.fields) ? Object.fromEntries(Object.entries(spec.fields)) : null;
422
518
  const remove = Array.isArray(spec.remove) ? [...spec.remove] : spec.remove ?? [];
423
- if (!isJsonPath(path))
519
+ if (!isProfilePath(path))
424
520
  throw new SubstitutionError("refusing substitution path");
425
521
  if (!fields || Object.keys(fields).length === 0)
426
522
  throw new SubstitutionError("substitutions carry no fields");
@@ -454,7 +550,7 @@ function swapMerchantHostedFields(body, spec, ciphertext = ADYEN_JWE) {
454
550
  }
455
551
  if (!isPlainObject(parsed))
456
552
  throw new SubstitutionError("the paused body is not a JSON object");
457
- const holder = jsonAt(parsed, path);
553
+ const holder = profileAt(parsed, path);
458
554
  if (!holder.found || !isPlainObject(holder.value))
459
555
  throw new SubstitutionError(`the paused body has no object at ${describePath(path)}`);
460
556
  const swaps = /* @__PURE__ */ new Map();
@@ -506,15 +602,19 @@ function swapMerchantHostedFields(body, spec, ciphertext = ADYEN_JWE) {
506
602
  catch {
507
603
  throw new SubstitutionError("the substituted body is not JSON");
508
604
  }
509
- const written = jsonAt(out, path);
605
+ const written = profileAt(out, path);
510
606
  if (!written.found || !isPlainObject(written.value) || names.some((name) => written.value[name] !== fields[name]) || dummies.some((dummy) => swapped.includes(dummy))) {
511
607
  throw new SubstitutionError(`the substitution did not land at ${describePath(path)}`);
512
608
  }
513
609
  if (remove.length === 0 && set.length === 0)
514
610
  return swapped;
515
- for (const key of remove)
516
- if (Object.prototype.hasOwnProperty.call(written.value, key))
517
- delete written.value[key];
611
+ if (remove.length > 0 && !editAtProfilePath(out, path, (object) => {
612
+ for (const key of remove)
613
+ if (Object.prototype.hasOwnProperty.call(object, key))
614
+ delete object[key];
615
+ })) {
616
+ throw new SubstitutionError(`the substitution did not land at ${describePath(path)}`);
617
+ }
518
618
  for (const entry of set) {
519
619
  const parent = jsonAt(out, entry.path.slice(0, -1));
520
620
  if (!parent.found || !isPlainObject(parent.value))