@agent-cards/sdk 0.21.0 → 0.22.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 +47 -0
  2. package/PREFLIGHT.md +30 -0
  3. package/README.md +1070 -21
  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 +283 -49
  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.d.ts +177 -0
  18. package/dist/card-endpoint.js +286 -0
  19. package/dist/card-fields.generated.d.ts +5 -3
  20. package/dist/card-fields.generated.js +284 -7
  21. package/dist/cdp.d.ts +5 -1
  22. package/dist/cdp.js +841 -135
  23. package/dist/client.d.ts +403 -19
  24. package/dist/client.js +949 -98
  25. package/dist/creditguard.generated.d.ts +79 -0
  26. package/dist/creditguard.generated.js +662 -0
  27. package/dist/cse-body.js +11 -1
  28. package/dist/datatrans.d.ts +96 -0
  29. package/dist/datatrans.generated.d.ts +64 -0
  30. package/dist/datatrans.generated.js +426 -0
  31. package/dist/datatrans.js +178 -0
  32. package/dist/elavon-converge.d.ts +37 -0
  33. package/dist/elavon-converge.generated.d.ts +49 -0
  34. package/dist/elavon-converge.generated.js +439 -0
  35. package/dist/elavon-converge.js +84 -0
  36. package/dist/eprotect.d.ts +152 -0
  37. package/dist/eprotect.generated.d.ts +77 -0
  38. package/dist/eprotect.generated.js +498 -0
  39. package/dist/eprotect.js +222 -0
  40. package/dist/hosted-form.d.ts +3 -2
  41. package/dist/hosted-form.js +3 -2
  42. package/dist/index.d.ts +17 -3
  43. package/dist/index.js +6 -1
  44. package/dist/juspay-gate.d.ts +82 -0
  45. package/dist/juspay-gate.js +126 -0
  46. package/dist/juspay.generated.d.ts +89 -0
  47. package/dist/juspay.generated.js +705 -0
  48. package/dist/lifecycle.d.ts +57 -6
  49. package/dist/lifecycle.js +119 -8
  50. package/dist/merchant-card-endpoints.generated.d.ts +63 -0
  51. package/dist/merchant-card-endpoints.generated.js +1103 -0
  52. package/dist/merchant-hosted.d.ts +4 -1
  53. package/dist/merchant-hosted.js +5 -2
  54. package/dist/merchant-session-probe.d.ts +48 -0
  55. package/dist/merchant-session-probe.js +53 -0
  56. package/dist/merchant-session.generated.d.ts +69 -0
  57. package/dist/merchant-session.generated.js +919 -0
  58. package/dist/payrails.d.ts +133 -0
  59. package/dist/payrails.generated.d.ts +73 -0
  60. package/dist/payrails.generated.js +596 -0
  61. package/dist/payrails.js +305 -0
  62. package/dist/pelecard.d.ts +32 -0
  63. package/dist/pelecard.generated.d.ts +32 -0
  64. package/dist/pelecard.generated.js +283 -0
  65. package/dist/pelecard.js +42 -0
  66. package/dist/pre-claim.d.ts +72 -2
  67. package/dist/pre-claim.js +857 -5
  68. package/dist/preflight-catalog.json +2218 -287
  69. package/dist/preflight-schemas.json +179 -6
  70. package/dist/preflight.generated.d.ts +1 -1
  71. package/dist/preflight.generated.js +233 -4
  72. package/dist/preparation.d.ts +5 -2
  73. package/dist/preparation.js +36 -10
  74. package/dist/prepared-processor.d.ts +84 -5
  75. package/dist/prepared-processor.js +147 -6
  76. package/dist/primer.d.ts +53 -0
  77. package/dist/primer.generated.d.ts +38 -0
  78. package/dist/primer.generated.js +624 -0
  79. package/dist/primer.js +82 -0
  80. package/dist/registry.d.ts +100 -8
  81. package/dist/registry.js +85 -11
  82. package/dist/shiji-sts.d.ts +144 -0
  83. package/dist/shiji-sts.generated.d.ts +72 -0
  84. package/dist/shiji-sts.generated.js +913 -0
  85. package/dist/shiji-sts.js +222 -0
  86. package/dist/stripe-checkout.generated.d.ts +1 -1
  87. package/dist/stripe-checkout.generated.js +699 -9
  88. package/dist/stripe-setup.d.ts +16 -0
  89. package/dist/stripe-setup.js +61 -0
  90. package/dist/substitutions.generated.js +187 -29
  91. package/dist/verifone.d.ts +68 -0
  92. package/dist/verifone.generated.d.ts +51 -0
  93. package/dist/verifone.generated.js +1401 -0
  94. package/dist/verifone.js +119 -0
  95. package/dist/voice-types.d.ts +27 -0
  96. package/dist/voice.d.ts +6 -1
  97. package/dist/voice.js +6 -1
  98. package/dist/wspay.d.ts +41 -0
  99. package/dist/wspay.generated.d.ts +41 -0
  100. package/dist/wspay.generated.js +370 -0
  101. package/dist/wspay.js +65 -0
  102. package/examples/preflight/kernel-native/inventory.json +1 -1
  103. package/package.json +3 -3
@@ -0,0 +1,42 @@
1
+ // Pelecard Iframe/Redirect 2.0 (psp `pelecard`): the hosted payment page Uman tourist tax
2
+ // (aumantax.com) loads in an iframe, served from gateway21.pelecard.biz (gateway20 on older
3
+ // terminals). The page sends the card in one same-origin jQuery XHR, POST /PaymentGW/Transaction,
4
+ // whose flat JSON body carries the card at CreditCardNumber, CreditCardDate (MMYY) and CvvNumber
5
+ // and names no amount: the merchant's server bound the total, the currency and the action type
6
+ // to the page's TransactionId when it created the payment. This module holds what the SDK
7
+ // decides about that request. The rules themselves are payment-core's (pelecard.generated.ts):
8
+ // the API applies the same ones at create, and the cardholder's device applies them again
9
+ // before it writes a card.
10
+ //
11
+ // The processor ships dark. The API serves the pelecard recognizer only to a build that declares
12
+ // the `pelecard_transaction` capability (client.ts SUPPORTED_CAPABILITIES), and only for an org
13
+ // Agentcard enabled for Pelecard, so an SDK that has not synced, or that runs for any other org,
14
+ // never recognizes a Pelecard host and leaves its requests alone.
15
+ import { PELECARD_TRANSACTION_HOSTS, pelecardTransactionRefusal } from './pelecard.generated.js';
16
+ export const PELECARD_PSP = 'pelecard';
17
+ /** The dark-launch capability the API serves the pelecard recognizer behind. */
18
+ export const PELECARD_CAPABILITY = 'pelecard_transaction';
19
+ /** True when the URL's host is one of Pelecard's two payment page hosts. */
20
+ export function isPelecardHost(url) {
21
+ try {
22
+ return PELECARD_TRANSACTION_HOSTS.includes(new URL(url).hostname);
23
+ }
24
+ catch {
25
+ return false;
26
+ }
27
+ }
28
+ /**
29
+ * The pause decision for a card-carrying POST the registry recognized on a Pelecard host. Null
30
+ * when it is the page's own one-time new-card submission, which pauses for approval; otherwise
31
+ * the reason it is refused. It judges the whole request (the exact URL, the page's JSON content
32
+ * type with Payment.js's own `charse0t` spelling, jQuery's X-Requested-With, and a body of the
33
+ * page's own keys) with payment-core's pelecardTransactionRefusal, the check the API runs at
34
+ * create and the device runs before it writes a card. It never passes keep-on-file consent:
35
+ * that waits for an approval that asks the cardholder.
36
+ */
37
+ export function pelecardRefusal(request) {
38
+ const refusal = pelecardTransactionRefusal({ url: request.url, method: 'POST', headers: request.headers ?? {}, body: request.body ?? '' });
39
+ if (refusal === null)
40
+ return null;
41
+ return refusal === 'keep_on_file' ? 'pelecard_keep_on_file_unsupported' : 'invalid_pelecard_request';
42
+ }
@@ -1,9 +1,17 @@
1
1
  import { StripeCheckoutGate } from './stripe-checkout.js';
2
2
  import { MercadoCheckoutGate } from './mercado-checkout.js';
3
+ import { type JuspayCheckoutGate } from './juspay-gate.js';
4
+ import { DatatransRepeats } from './datatrans.js';
5
+ import { type AciGate } from './aci.js';
6
+ import type { EprotectGate } from './eprotect.js';
7
+ import { type ShijiStsCompanions } from './shiji-sts.js';
3
8
  import type { CheckoutLifecycle } from './lifecycle.js';
4
9
  import { type MerchantProfile } from './merchant-hosted.js';
5
10
  import type { MerchantHandoffWatch } from './merchant-handoff.js';
6
11
  import { type CybersourceFlexDecision, type CybersourceFlexPause, type FlexRequest } from './cybersource-flex.js';
12
+ import { type CardEndpointProfile } from './card-endpoint.js';
13
+ import { type PayrailsSessionCapture, type PayrailsSidecar } from './payrails.js';
14
+ import { type VerifoneProfile } from './verifone.js';
7
15
  /** The native Stripe step the gate claimed, or null when none was: exactly what StripeCheckoutGate.claim returns. */
8
16
  type StripeStep = ReturnType<StripeCheckoutGate['claim']>;
9
17
  /** A synthetic response a gate fulfills locally. The effect applies CORS and encoding. */
@@ -26,10 +34,14 @@ export type PreClaimDecision = {
26
34
  kind: 'abort';
27
35
  } | {
28
36
  kind: 'answer';
29
- } | {
37
+ }
38
+ /** `payrails`: the session key a bound Payrails card save carries onto the create. */
39
+ | {
30
40
  kind: 'pause';
31
41
  stripeStep: StripeStep;
32
42
  cybersourceFlex?: CybersourceFlexPause;
43
+ cardEndpoint?: CardEndpointProfile;
44
+ payrails?: PayrailsSidecar;
33
45
  };
34
46
  /** The adapter mechanics a gate performs. Each is awaited where the inline code
35
47
  * awaited it; none swallow their own transport failure (a gate adds a .catch
@@ -52,22 +64,45 @@ export interface PreClaimContext {
52
64
  /** The adapters expose headers and body as getters, read inside the gate that
53
65
  * needs them: Playwright's postData() can throw, and Mercado reads the body in
54
66
  * its own try, so that failure stops the native checkout instead of rejecting
55
- * the route handler with the request neither aborted nor reported. */
67
+ * the route handler with the request neither aborted nor reported. `body` is ''
68
+ * for a request with no body, and null when the adapter knows the request carries
69
+ * a body it could not read (CDP: hasPostData with no bytes, a blob or a file).
70
+ * Playwright cannot tell those two apart (its postData() is null for both), so
71
+ * attachToPlaywright hands a gate that null for either, and '' for either at an
72
+ * armed Verifone merchant's origin. */
56
73
  request: {
57
74
  url: string;
58
75
  method: string;
59
76
  headers: Record<string, string>;
60
77
  body: string | null;
78
+ /** The request is a frame's navigation (CDP resourceType Document, Playwright isNavigationRequest). Only the ACI gate reads it. */
79
+ navigation?: boolean;
61
80
  };
81
+ /** cardOnFilePolicy: the policy the API served with the request's recognizer (VaultClient); absent reads as none.
82
+ * withoutCard is VaultClient's own (card-fields.js requestWithoutCard); optional so a test double may omit it. */
62
83
  vault: {
63
84
  isCardRequest(url: string, method?: string): boolean;
64
85
  merchantProfileOf?(url: string): MerchantProfile | null;
86
+ verifoneProfileOf?(url: string): VerifoneProfile | null;
87
+ cardOnFilePolicy?(url: string, method?: string): string | null;
88
+ withoutCard?(url: string, body: string | null | undefined): 'continue' | 'refuse' | null;
65
89
  };
66
90
  guards: {
67
91
  matches(url: string, method?: string): boolean;
68
92
  };
69
93
  mercado: MercadoCheckoutGate;
70
94
  stripe: StripeCheckoutGate;
95
+ /** ACI's split card; absent or inert until the registry serves ACI. */
96
+ aci?: AciGate;
97
+ /**
98
+ * Whether this browser sends the body the SDK replaced on a navigation, which removing the
99
+ * placeholder expiry from ACI's classic-mode /payment needs: true on the CDP adapter, which
100
+ * drives Chromium; the Playwright adapter asks the page's engine (aci.ts
101
+ * playwrightReplacesNavigationBody). Absent reads as no, so that /payment is refused.
102
+ */
103
+ replacesNavigationBody?: () => Promise<boolean>;
104
+ /** Worldpay eProtect's hosts; absent or inert until the registry serves eProtect. */
105
+ eprotect?: EprotectGate;
71
106
  readDocumentUrl: () => Promise<string>;
72
107
  lifecycle: CheckoutLifecycle;
73
108
  /** isEngaged and observeUnprepared are called only for an armed merchant profile's card request or a Fiserv card capture. */
@@ -93,6 +128,14 @@ export interface PreClaimContext {
93
128
  /** The paused request itself is gone (Playwright only); CDP returns false. */
94
129
  requestInactive: () => boolean;
95
130
  awaitingApproval: () => boolean;
131
+ /**
132
+ * The URLs of the frame that sent the request and of every frame above it, sender first, or
133
+ * undefined when the adapter cannot read them: Playwright walks the request's frame up through
134
+ * its parents, CDP reads the frame trees of the paused session and of each session above it.
135
+ * Read only for a Nuvei card request whose Origin or Referer does not already name PPS (see
136
+ * nuveiPreClaim), so no other request waits on it.
137
+ */
138
+ initiatorFrames?: () => readonly string[] | undefined | Promise<readonly string[] | undefined>;
96
139
  /** Set by the Stripe gate; read by the terminal arbiter and carried into a pause. */
97
140
  stripeStep: StripeStep;
98
141
  /** The merchant-hosted hand-off this attachment made, if any (merchant-handoff.ts). */
@@ -105,6 +148,31 @@ export interface PreClaimContext {
105
148
  cybersourceFlex?: {
106
149
  judge(request: FlexRequest): CybersourceFlexDecision | Promise<CybersourceFlexDecision>;
107
150
  };
151
+ /**
152
+ * The attachment's Juspay gate (juspay-gate.ts). Absent, or off because the registry does not
153
+ * serve the Juspay recognizer, and every request to a Juspay host is judged as it was before.
154
+ */
155
+ juspay?: JuspayCheckoutGate;
156
+ /** The attachment's approved Datatrans answers (the repeat rule, datatrans.ts). Absent: none are kept. */
157
+ datatrans?: DatatransRepeats;
158
+ /** The adapter's identity for the request's frame (CDP frameId, Playwright Frame); undefined when unknown. */
159
+ frame?: unknown;
160
+ /**
161
+ * The Payrails sessions the adapter captured, or null (or absent) when it captures none: the
162
+ * synced registry does not pause Payrails' save, so the Payrails gate defers every request.
163
+ */
164
+ payrails?: PayrailsSessionCapture | null;
165
+ /**
166
+ * The attachment's Shiji STS getCvvId companion and the adapter's opaque id
167
+ * for the page or frame this request came from (shiji-sts.ts), read when the
168
+ * request is judged (attachToPlaywright reads the frame's document, so it
169
+ * answers asynchronously). Absent, a getCvvId has nothing to bind to and is
170
+ * refused.
171
+ */
172
+ shijiSts?: {
173
+ companions: ShijiStsCompanions;
174
+ page: () => string | Promise<string>;
175
+ };
108
176
  }
109
177
  /**
110
178
  * The URL an event may name for a request. For an armed merchant profile's
@@ -115,11 +183,13 @@ export interface PreClaimContext {
115
183
  */
116
184
  export declare function eventUrl(vault: {
117
185
  merchantProfileOf?(url: string): MerchantProfile | null;
186
+ verifoneProfileOf?(url: string): VerifoneProfile | null;
118
187
  } | undefined, url: string): string;
119
188
  /** A gate returns a decision when it handles the request, undefined to defer to
120
189
  * the next gate, or a promise of either when it must do I/O first. */
121
190
  export type PreClaimGate = (ctx: PreClaimContext) => PreClaimDecision | undefined | Promise<PreClaimDecision | undefined>;
122
191
  export declare const MERCHANT_BODY_UNREADABLE = "the paused request carries no body the SDK could read, so Agentcard cannot tell whether it carries a card";
192
+ export declare const verifonePreClaim: PreClaimGate;
123
193
  export declare const fiservPreClaim: PreClaimGate;
124
194
  /** The processor gates, in order. A new family adds one entry here; the terminal
125
195
  * arbiter runs after all of them and is not part of this list. A gate appended