@agent-cards/sdk 0.23.27 → 0.24.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 (103) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/PREFLIGHT.md +7 -1
  3. package/README.md +137 -99
  4. package/dist/aci.d.ts +52 -22
  5. package/dist/aci.js +79 -15
  6. package/dist/adyen-merchant-hosted.generated.d.ts +1 -1
  7. package/dist/adyen-merchant-hosted.generated.js +459 -21
  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/buy.d.ts +20 -101
  21. package/dist/buy.js +19 -74
  22. package/dist/capabilities.generated.js +1 -1
  23. package/dist/card-fields.generated.js +1398 -106
  24. package/dist/cdp.d.ts +3 -13
  25. package/dist/cdp.js +231 -175
  26. package/dist/client.d.ts +104 -22
  27. package/dist/client.js +215 -40
  28. package/dist/creditguard.generated.d.ts +4 -4
  29. package/dist/datatrans.generated.js +22 -1
  30. package/dist/elavon-converge.generated.js +5 -3
  31. package/dist/hold.d.ts +8 -0
  32. package/dist/hold.js +43 -2
  33. package/dist/hosted-entry.js +2 -0
  34. package/dist/index.d.ts +9 -15
  35. package/dist/index.js +6 -10
  36. package/dist/juspay-gate.js +2 -2
  37. package/dist/juspay.generated.d.ts +2 -2
  38. package/dist/juspay.generated.js +174 -4
  39. package/dist/lifecycle.d.ts +9 -61
  40. package/dist/lifecycle.js +24 -10
  41. package/dist/merchant-card-endpoints.generated.d.ts +6 -1
  42. package/dist/merchant-card-endpoints.generated.js +344 -19
  43. package/dist/merchant-hosted.d.ts +8 -1
  44. package/dist/nike-order.d.ts +51 -0
  45. package/dist/nike-order.js +81 -0
  46. package/dist/oceanpayment.d.ts +38 -0
  47. package/dist/oceanpayment.js +70 -0
  48. package/dist/paddle-tokenex.generated.js +105 -10
  49. package/dist/payplug.d.ts +41 -0
  50. package/dist/payplug.js +71 -0
  51. package/dist/payrails.generated.js +27 -7
  52. package/dist/payrexx.generated.js +176 -2
  53. package/dist/pre-claim.d.ts +9 -0
  54. package/dist/pre-claim.js +86 -7
  55. package/dist/preflight-capabilities.generated.d.ts +0 -4
  56. package/dist/preflight-capabilities.generated.js +0 -5
  57. package/dist/preflight-catalog.json +46 -5
  58. package/dist/preflight-playwright.d.ts +2 -2
  59. package/dist/preflight-playwright.js +63 -14
  60. package/dist/preflight-schemas.json +4 -0
  61. package/dist/preflight.generated.d.ts +0 -4
  62. package/dist/preflight.generated.js +24 -1
  63. package/dist/prepared-processor.d.ts +18 -5
  64. package/dist/prepared-processor.js +48 -8
  65. package/dist/primer.generated.js +1418 -120
  66. package/dist/processout.generated.d.ts +61 -0
  67. package/dist/processout.generated.js +577 -0
  68. package/dist/requests.js +1 -1
  69. package/dist/shiji-sts.generated.js +105 -10
  70. package/dist/stripe-checkout.generated.js +1405 -234
  71. package/dist/substitutions.generated.js +460 -26
  72. package/dist/tap-payments.generated.js +105 -10
  73. package/dist/twoc2p.generated.js +105 -10
  74. package/dist/url-masks/bluesnap.d.ts +2 -0
  75. package/dist/url-masks/bluesnap.js +15 -0
  76. package/dist/url-masks/oceanpayment.d.ts +2 -0
  77. package/dist/url-masks/oceanpayment.js +13 -0
  78. package/dist/url-masks/payplug.d.ts +2 -0
  79. package/dist/url-masks/payplug.js +13 -0
  80. package/dist/url-masks/vtex_payments.d.ts +2 -0
  81. package/dist/url-masks/vtex_payments.js +12 -0
  82. package/dist/url-masks.generated.d.ts +1 -1
  83. package/dist/url-masks.generated.js +6 -2
  84. package/dist/verifone.generated.js +42 -2
  85. package/dist/vtex-payments.generated.d.ts +127 -0
  86. package/dist/vtex-payments.generated.js +544 -0
  87. package/dist/webhooks.d.ts +2 -2
  88. package/dist/webhooks.js +2 -2
  89. package/dist/wspay.generated.d.ts +1 -1
  90. package/dist/wspay.generated.js +175 -3
  91. package/examples/preflight/kernel-native/inventory.json +1 -1
  92. package/package.json +6 -8
  93. package/dist/languages.d.ts +0 -23
  94. package/dist/languages.js +0 -76
  95. package/dist/voice-pkce.d.ts +0 -49
  96. package/dist/voice-pkce.js +0 -147
  97. package/dist/voice-stream.generated.d.ts +0 -118
  98. package/dist/voice-stream.generated.js +0 -170
  99. package/dist/voice-types.d.ts +0 -735
  100. package/dist/voice.d.ts +0 -373
  101. package/dist/voice.js +0 -815
  102. package/readme.test.mjs +0 -53
  103. /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: e9f7e427a2cae183ce249c0adeabab974d75c413b81cf9f1a7d013fb1d962e31
4
4
  // src/sha256.js
5
5
  var K = /* @__PURE__ */ new Uint32Array([
6
6
  1116352408,
@@ -335,9 +335,64 @@ function isPlainObject(v) {
335
335
  return !!v && typeof v === "object" && !Array.isArray(v);
336
336
  }
337
337
  var MAX_PATH_STEPS = 16;
338
+ var MAX_TEXT_STEPS = 2;
339
+ function isTextStep(step) {
340
+ return isPlainObject(step) && Object.keys(step).length === 1 && step.text === "json";
341
+ }
342
+ function sameStep(a, b) {
343
+ return a === b || isTextStep(a) && isTextStep(b);
344
+ }
345
+ function spellJson(parsed, form) {
346
+ const text = JSON.stringify(parsed);
347
+ if (form !== "php")
348
+ return text;
349
+ return text.replace(/\//g, "\\/").replace(/[\u0080-\uffff]/g, (unit) => `\\u${unit.charCodeAt(0).toString(16).padStart(4, "0")}`);
350
+ }
351
+ function jsonTextForm(value) {
352
+ if (typeof value !== "string" || !/^[[{]/.test(value))
353
+ return void 0;
354
+ let parsed;
355
+ try {
356
+ parsed = JSON.parse(value);
357
+ }
358
+ catch {
359
+ return void 0;
360
+ }
361
+ if (parsed === null || typeof parsed !== "object")
362
+ return void 0;
363
+ for (const form of ["js", "php"]) {
364
+ try {
365
+ if (spellJson(parsed, form) === value)
366
+ return { parsed, form };
367
+ }
368
+ catch {
369
+ return void 0;
370
+ }
371
+ }
372
+ return void 0;
373
+ }
374
+ function jsonText(value) {
375
+ return jsonTextForm(value)?.parsed;
376
+ }
338
377
  function isJsonPath(path) {
339
378
  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
379
  }
380
+ function isProfilePath(path) {
381
+ if (!Array.isArray(path) || path.length > MAX_PATH_STEPS)
382
+ return false;
383
+ let texts = 0;
384
+ for (const [i, step] of path.entries()) {
385
+ if (isTextStep(step)) {
386
+ texts += 1;
387
+ if (i === 0 || i === path.length - 1 || isTextStep(path[i - 1]) || texts > MAX_TEXT_STEPS)
388
+ return false;
389
+ }
390
+ else if (!isJsonPath([step])) {
391
+ return false;
392
+ }
393
+ }
394
+ return true;
395
+ }
341
396
  function jsonAt(root, path) {
342
397
  let node = root;
343
398
  for (const step of path) {
@@ -352,6 +407,42 @@ function jsonAt(root, path) {
352
407
  }
353
408
  return { found: true, value: node };
354
409
  }
410
+ function profileAt(root, path) {
411
+ if (!isProfilePath(path))
412
+ return { found: false };
413
+ let node = root;
414
+ for (const step of path) {
415
+ if (isTextStep(step)) {
416
+ const inner = jsonText(node);
417
+ if (inner === void 0)
418
+ return { found: false };
419
+ node = inner;
420
+ continue;
421
+ }
422
+ const at = jsonAt(node, [step]);
423
+ if (!at.found)
424
+ return { found: false };
425
+ node = at.value;
426
+ }
427
+ return { found: true, value: node };
428
+ }
429
+ function editAtProfilePath(root, path, edit) {
430
+ const at = profileAt(root, path);
431
+ if (!at.found || !isPlainObject(at.value))
432
+ return false;
433
+ const k = path.findIndex(isTextStep);
434
+ if (k === -1) {
435
+ edit(at.value);
436
+ return true;
437
+ }
438
+ const holder = jsonAt(root, path.slice(0, k - 1)).value;
439
+ const key = path[k - 1];
440
+ const text = jsonTextForm(holder[key]);
441
+ if (!text || !editAtProfilePath(text.parsed, path.slice(k + 1), edit))
442
+ return false;
443
+ holder[key] = spellJson(text.parsed, text.form);
444
+ return true;
445
+ }
355
446
  function roundTrips(parsed, body) {
356
447
  try {
357
448
  return JSON.stringify(parsed) === body;
@@ -361,17 +452,17 @@ function roundTrips(parsed, body) {
361
452
  }
362
453
  }
363
454
  function sameSteps(a, b) {
364
- return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((step, i) => step === b[i]);
455
+ return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((step, i) => sameStep(step, b[i]));
365
456
  }
366
457
  function pathsOverlap(a, b) {
367
458
  const n = Math.min(a.length, b.length);
368
459
  for (let i = 0; i < n; i += 1)
369
- if (a[i] !== b[i])
460
+ if (!sameStep(a[i], b[i]))
370
461
  return false;
371
462
  return true;
372
463
  }
373
464
  function describePath(path) {
374
- return path.length ? path.map((step) => typeof step === "number" ? `[${step}]` : `.${step}`).join("").replace(/^\./, "") : "(root)";
465
+ return path.length ? path.map((step) => typeof step === "number" ? `[${step}]` : isTextStep(step) ? "<json>" : `.${step}`).join("").replace(/^\./, "") : "(root)";
375
466
  }
376
467
  // src/substitution-primitives.js
377
468
  var SubstitutionError = class extends Error {
@@ -420,7 +511,7 @@ function swapMerchantHostedFields(body, spec, ciphertext = ADYEN_JWE) {
420
511
  const path = Array.isArray(spec.path) ? [...spec.path] : spec.path;
421
512
  const fields = isPlainObject(spec.fields) ? Object.fromEntries(Object.entries(spec.fields)) : null;
422
513
  const remove = Array.isArray(spec.remove) ? [...spec.remove] : spec.remove ?? [];
423
- if (!isJsonPath(path))
514
+ if (!isProfilePath(path))
424
515
  throw new SubstitutionError("refusing substitution path");
425
516
  if (!fields || Object.keys(fields).length === 0)
426
517
  throw new SubstitutionError("substitutions carry no fields");
@@ -454,7 +545,7 @@ function swapMerchantHostedFields(body, spec, ciphertext = ADYEN_JWE) {
454
545
  }
455
546
  if (!isPlainObject(parsed))
456
547
  throw new SubstitutionError("the paused body is not a JSON object");
457
- const holder = jsonAt(parsed, path);
548
+ const holder = profileAt(parsed, path);
458
549
  if (!holder.found || !isPlainObject(holder.value))
459
550
  throw new SubstitutionError(`the paused body has no object at ${describePath(path)}`);
460
551
  const swaps = /* @__PURE__ */ new Map();
@@ -506,15 +597,19 @@ function swapMerchantHostedFields(body, spec, ciphertext = ADYEN_JWE) {
506
597
  catch {
507
598
  throw new SubstitutionError("the substituted body is not JSON");
508
599
  }
509
- const written = jsonAt(out, path);
600
+ const written = profileAt(out, path);
510
601
  if (!written.found || !isPlainObject(written.value) || names.some((name) => written.value[name] !== fields[name]) || dummies.some((dummy) => swapped.includes(dummy))) {
511
602
  throw new SubstitutionError(`the substitution did not land at ${describePath(path)}`);
512
603
  }
513
604
  if (remove.length === 0 && set.length === 0)
514
605
  return swapped;
515
- for (const key of remove)
516
- if (Object.prototype.hasOwnProperty.call(written.value, key))
517
- delete written.value[key];
606
+ if (remove.length > 0 && !editAtProfilePath(out, path, (object) => {
607
+ for (const key of remove)
608
+ if (Object.prototype.hasOwnProperty.call(object, key))
609
+ delete object[key];
610
+ })) {
611
+ throw new SubstitutionError(`the substitution did not land at ${describePath(path)}`);
612
+ }
518
613
  for (const entry of set) {
519
614
  const parent = jsonAt(out, entry.path.slice(0, -1));
520
615
  if (!parent.found || !isPlainObject(parent.value))