@agent-cards/sdk 0.23.21 → 0.23.23

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 (56) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/PREFLIGHT.md +4 -0
  3. package/README.md +53 -4
  4. package/dist/aci.generated.js +3 -3
  5. package/dist/agent-amount.generated.d.ts +7 -0
  6. package/dist/agent-amount.generated.js +3 -0
  7. package/dist/amadeus-checkout.generated.d.ts +6 -1
  8. package/dist/amadeus-checkout.generated.js +26 -2
  9. package/dist/capabilities.generated.d.ts +2 -0
  10. package/dist/capabilities.generated.js +3 -0
  11. package/dist/card-fields.generated.js +2574 -186
  12. package/dist/cdp.js +103 -29
  13. package/dist/client.d.ts +130 -9
  14. package/dist/client.js +304 -115
  15. package/dist/creditguard.generated.js +4 -2
  16. package/dist/cse-body.js +11 -0
  17. package/dist/ebanx.d.ts +1 -1
  18. package/dist/ebanx.js +1 -1
  19. package/dist/eximbay.d.ts +46 -0
  20. package/dist/eximbay.js +69 -0
  21. package/dist/hosted-entry.js +2 -1
  22. package/dist/hosted-form.d.ts +5 -0
  23. package/dist/hosted-form.js +5 -0
  24. package/dist/lifecycle.d.ts +9 -4
  25. package/dist/lifecycle.js +16 -4
  26. package/dist/paygent.generated.d.ts +60 -0
  27. package/dist/paygent.generated.js +425 -0
  28. package/dist/payrexx.d.ts +91 -0
  29. package/dist/payrexx.generated.d.ts +91 -0
  30. package/dist/payrexx.generated.js +536 -0
  31. package/dist/payrexx.js +141 -0
  32. package/dist/paytrail.d.ts +58 -0
  33. package/dist/paytrail.js +98 -0
  34. package/dist/pre-claim.d.ts +27 -0
  35. package/dist/pre-claim.js +175 -20
  36. package/dist/prepared-processor.d.ts +7 -2
  37. package/dist/prepared-processor.js +16 -2
  38. package/dist/primer.generated.js +2709 -321
  39. package/dist/registry.d.ts +4 -3
  40. package/dist/registry.js +12 -4
  41. package/dist/sbps.d.ts +57 -0
  42. package/dist/sbps.generated.d.ts +96 -0
  43. package/dist/sbps.generated.js +427 -0
  44. package/dist/sbps.js +90 -0
  45. package/dist/stripe-checkout.generated.js +744 -27
  46. package/dist/toast-seal.generated.d.ts +37 -0
  47. package/dist/toast-seal.generated.js +625 -0
  48. package/dist/toast.generated.d.ts +41 -0
  49. package/dist/toast.generated.js +113 -0
  50. package/dist/transbank.d.ts +33 -0
  51. package/dist/transbank.js +62 -0
  52. package/dist/url-mask-parts.d.ts +24 -0
  53. package/dist/url-mask-parts.js +22 -0
  54. package/dist/url-masks.generated.d.ts +3 -0
  55. package/dist/url-masks.generated.js +2 -0
  56. package/package.json +4 -4
package/dist/sbps.js ADDED
@@ -0,0 +1,90 @@
1
+ // SB Payment Service (SBPS): the adapters' side of its one-time token request.
2
+ //
3
+ // SBPS's token script (com_sbps_system_token.js) encrypts the card in the merchant's page and sends it
4
+ // as ONE JSONP <script> GET to /token/generateToken on token.sps-system.com (stbtoken.sps-system.com
5
+ // for SBPS's test environment); the answer is JavaScript that calls the request's own callback with
6
+ // {"tokenRes": {...}}. The rules that judge that request (the exact URL the browser writes for the
7
+ // script's <script>, the merchant pins, the answer judge) live in payment-core and reach this SDK as
8
+ // sbps.generated.ts. This module holds only what an attachment decides from them:
9
+ // - which request on SBPS's token hosts is the card token request to pause for the vault;
10
+ // - which is a variant of it this SDK does not complete (aborted, so the placeholder's ciphertext
11
+ // never reaches SBPS);
12
+ // - the script answer the paused request gets once the cardholder's device sent the real card: the
13
+ // token Agentcard stored, wrapped in the callback the paused URL named.
14
+ // The 3-D Secure info request on the same host (/token/generateTds2Token: the buyer's name, phone and
15
+ // email, no card) and the scripts continue untouched.
16
+ import { SBPS_ANSWER_CONTENT_TYPE, SBPS_TOKEN_HOSTS, SBPS_TOKEN_PATH, isSbpsRequest, isSbpsTokenRequest, sbpsJsonp, sbpsOutcome, sbpsRequestFacts } from './sbps.generated.js';
17
+ /** The processor id, as the registry and the API name it. */
18
+ export const SBPS_PSP = 'sb_payment_service';
19
+ /** The dark-launch capability the API serves the SBPS recognizer behind (payment-core definitions.js). */
20
+ export const SBPS_CAPABILITY = 'sbps_token_jsonp';
21
+ /** What the paused <script> is answered with. */
22
+ export { SBPS_ANSWER_CONTENT_TYPE };
23
+ const SBPS_HOSTNAMES = [SBPS_TOKEN_HOSTS.production, SBPS_TOKEN_HOSTS.sandbox];
24
+ /** Which SBPS request this is, or null for a URL that is not on one of SBPS's token hosts. */
25
+ export function classifySbpsRequest(url, method) {
26
+ let parsed;
27
+ try {
28
+ parsed = new URL(url);
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ if (parsed.protocol !== 'https:' || parsed.port || parsed.username || parsed.password
34
+ || !SBPS_HOSTNAMES.includes(parsed.hostname.toLowerCase().replace(/\.$/, '')))
35
+ return null;
36
+ // Every spelling of the token path belongs to the token request family: the exact request carries the
37
+ // card, and any neighbour of it is nothing this SDK completes. generateTds2Token is not a neighbour.
38
+ if (parsed.pathname.toLowerCase().startsWith(SBPS_TOKEN_PATH.toLowerCase())) {
39
+ return typeof method === 'string' && isSbpsTokenRequest(url, method.toUpperCase()) ? { kind: 'token_request' } : { kind: 'unsupported' };
40
+ }
41
+ return { kind: 'sibling' };
42
+ }
43
+ /** The token request GET exactly as payment-core admits it: its URL alone, with no body. */
44
+ export function isSbpsTokenGet(request) {
45
+ return (request.method ?? 'POST').toUpperCase() === 'GET' && isSbpsRequest({ url: request.url, method: 'GET', body: request.body ?? '' });
46
+ }
47
+ /**
48
+ * The answer a paused token request gets, or null when the stored answer is not one to hand the page:
49
+ * SBPS's own shape, `<callback>(<tokenRes>)` under a script type, with the callback the paused URL
50
+ * named. The answer must be one payment-core's judge accepts for that exact URL (result OK and the
51
+ * five token fields), byte for byte what the API stored after running the same judge.
52
+ */
53
+ export function sbpsScriptAnswer(templateUrl, response) {
54
+ const facts = sbpsRequestFacts(templateUrl);
55
+ if (!facts || response.status !== 200 || typeof response.body !== 'string')
56
+ return null;
57
+ let body;
58
+ try {
59
+ body = sbpsJsonp(facts.callback, response.body);
60
+ }
61
+ catch {
62
+ return null;
63
+ }
64
+ const verdict = sbpsOutcome(200, body, templateUrl, undefined);
65
+ if (verdict.outcome !== 'token' || verdict.sanitizedJson !== response.body)
66
+ return null;
67
+ return { status: 200, headers: { 'content-type': SBPS_ANSWER_CONTENT_TYPE }, body };
68
+ }
69
+ /**
70
+ * One attachment's view of SBPS's token hosts. Inert (classify returns null) until the registry serves
71
+ * SBPS, which a client reaches only by syncing with the capability for an org the API enabled, so a
72
+ * build, an org or an API that never served it leaves every SBPS request exactly as before.
73
+ */
74
+ export class SbpsGate {
75
+ vault;
76
+ constructor(vault) {
77
+ this.vault = vault;
78
+ }
79
+ /** What this request is, when the registry serves SBPS and the URL is on its token hosts; null leaves it to the other gates. */
80
+ classify(url, method) {
81
+ if (typeof this.vault?.recognizesProcessor !== 'function' || !this.vault.recognizesProcessor(SBPS_PSP))
82
+ return null;
83
+ return classifySbpsRequest(url, method);
84
+ }
85
+ /** Playwright's route predicate sees only the URL: route the token request family, never the scripts or the 3-D Secure info request. */
86
+ matches(url) {
87
+ const request = this.classify(url, 'GET');
88
+ return request !== null && request.kind !== 'sibling';
89
+ }
90
+ }