@agent-cards/sdk 0.21.0 → 0.23.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 (113) hide show
  1. package/CHANGELOG.md +87 -2
  2. package/PREFLIGHT.md +32 -0
  3. package/README.md +1177 -23
  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 +302 -56
  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-facts.d.ts +96 -0
  18. package/dist/card-endpoint-facts.js +275 -0
  19. package/dist/card-endpoint-page.d.ts +54 -0
  20. package/dist/card-endpoint-page.js +69 -0
  21. package/dist/card-endpoint.d.ts +298 -0
  22. package/dist/card-endpoint.js +438 -0
  23. package/dist/card-fields.generated.d.ts +5 -3
  24. package/dist/card-fields.generated.js +284 -7
  25. package/dist/cdp.d.ts +5 -1
  26. package/dist/cdp.js +1155 -141
  27. package/dist/client.d.ts +456 -20
  28. package/dist/client.js +1072 -104
  29. package/dist/creditguard.generated.d.ts +79 -0
  30. package/dist/creditguard.generated.js +662 -0
  31. package/dist/cse-body.js +11 -1
  32. package/dist/cybersource-flex.d.ts +30 -0
  33. package/dist/cybersource-flex.generated.d.ts +27 -1
  34. package/dist/cybersource-flex.generated.js +42 -2
  35. package/dist/cybersource-flex.js +46 -0
  36. package/dist/datatrans.d.ts +96 -0
  37. package/dist/datatrans.generated.d.ts +64 -0
  38. package/dist/datatrans.generated.js +426 -0
  39. package/dist/datatrans.js +178 -0
  40. package/dist/ekashu.d.ts +35 -0
  41. package/dist/ekashu.js +55 -0
  42. package/dist/elavon-converge.d.ts +37 -0
  43. package/dist/elavon-converge.generated.d.ts +49 -0
  44. package/dist/elavon-converge.generated.js +439 -0
  45. package/dist/elavon-converge.js +84 -0
  46. package/dist/eprotect.d.ts +152 -0
  47. package/dist/eprotect.generated.d.ts +77 -0
  48. package/dist/eprotect.generated.js +498 -0
  49. package/dist/eprotect.js +222 -0
  50. package/dist/hosted-form.d.ts +3 -2
  51. package/dist/hosted-form.js +3 -2
  52. package/dist/index.d.ts +17 -3
  53. package/dist/index.js +6 -1
  54. package/dist/juspay-gate.d.ts +82 -0
  55. package/dist/juspay-gate.js +126 -0
  56. package/dist/juspay.generated.d.ts +89 -0
  57. package/dist/juspay.generated.js +705 -0
  58. package/dist/lifecycle.d.ts +60 -6
  59. package/dist/lifecycle.js +122 -8
  60. package/dist/merchant-card-endpoints.generated.d.ts +122 -0
  61. package/dist/merchant-card-endpoints.generated.js +4261 -0
  62. package/dist/merchant-hosted.d.ts +4 -1
  63. package/dist/merchant-hosted.js +5 -2
  64. package/dist/merchant-session-probe.d.ts +48 -0
  65. package/dist/merchant-session-probe.js +53 -0
  66. package/dist/merchant-session.generated.d.ts +69 -0
  67. package/dist/merchant-session.generated.js +919 -0
  68. package/dist/payrails.d.ts +133 -0
  69. package/dist/payrails.generated.d.ts +73 -0
  70. package/dist/payrails.generated.js +596 -0
  71. package/dist/payrails.js +305 -0
  72. package/dist/pelecard.d.ts +32 -0
  73. package/dist/pelecard.generated.d.ts +32 -0
  74. package/dist/pelecard.generated.js +283 -0
  75. package/dist/pelecard.js +42 -0
  76. package/dist/pre-claim.d.ts +81 -2
  77. package/dist/pre-claim.js +1023 -5
  78. package/dist/preflight-catalog.json +2267 -288
  79. package/dist/preflight-schemas.json +183 -6
  80. package/dist/preflight.generated.d.ts +1 -1
  81. package/dist/preflight.generated.js +243 -4
  82. package/dist/preparation.d.ts +12 -3
  83. package/dist/preparation.js +63 -12
  84. package/dist/prepared-processor.d.ts +84 -5
  85. package/dist/prepared-processor.js +147 -6
  86. package/dist/primer.d.ts +53 -0
  87. package/dist/primer.generated.d.ts +38 -0
  88. package/dist/primer.generated.js +624 -0
  89. package/dist/primer.js +82 -0
  90. package/dist/registry.d.ts +100 -8
  91. package/dist/registry.js +85 -11
  92. package/dist/shiji-sts.d.ts +144 -0
  93. package/dist/shiji-sts.generated.d.ts +72 -0
  94. package/dist/shiji-sts.generated.js +913 -0
  95. package/dist/shiji-sts.js +222 -0
  96. package/dist/stripe-checkout.generated.d.ts +1 -1
  97. package/dist/stripe-checkout.generated.js +764 -9
  98. package/dist/stripe-setup.d.ts +16 -0
  99. package/dist/stripe-setup.js +61 -0
  100. package/dist/substitutions.generated.js +187 -29
  101. package/dist/verifone.d.ts +68 -0
  102. package/dist/verifone.generated.d.ts +51 -0
  103. package/dist/verifone.generated.js +1413 -0
  104. package/dist/verifone.js +119 -0
  105. package/dist/voice-types.d.ts +27 -0
  106. package/dist/voice.d.ts +6 -1
  107. package/dist/voice.js +6 -1
  108. package/dist/wspay.d.ts +41 -0
  109. package/dist/wspay.generated.d.ts +41 -0
  110. package/dist/wspay.generated.js +370 -0
  111. package/dist/wspay.js +65 -0
  112. package/examples/preflight/kernel-native/inventory.json +1 -1
  113. 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,15 @@ 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;
45
+ navigation?: 'top' | 'frame';
33
46
  };
34
47
  /** The adapter mechanics a gate performs. Each is awaited where the inline code
35
48
  * awaited it; none swallow their own transport failure (a gate adds a .catch
@@ -52,22 +65,52 @@ export interface PreClaimContext {
52
65
  /** The adapters expose headers and body as getters, read inside the gate that
53
66
  * needs them: Playwright's postData() can throw, and Mercado reads the body in
54
67
  * its own try, so that failure stops the native checkout instead of rejecting
55
- * the route handler with the request neither aborted nor reported. */
68
+ * the route handler with the request neither aborted nor reported. `body` is ''
69
+ * for a request with no body, and null when the adapter knows the request carries
70
+ * a body it could not read (CDP: hasPostData with no bytes, a blob or a file).
71
+ * Playwright cannot tell those two apart (its postData() is null for both), so
72
+ * attachToPlaywright hands a gate that null for either, and '' for either at an
73
+ * armed Verifone merchant's origin. */
56
74
  request: {
57
75
  url: string;
58
76
  method: string;
59
77
  headers: Record<string, string>;
60
78
  body: string | null;
79
+ /** The request is a frame's navigation (CDP resourceType Document, Playwright isNavigationRequest). Only the ACI gate reads it. */
80
+ navigation?: boolean;
61
81
  };
82
+ /**
83
+ * What the browser said the paused request is: a navigation of the page ('top'), of an
84
+ * iframe ('frame'), or neither (null: a fetch, an XHR, a subresource). Read only for a
85
+ * card endpoint whose page submits its form as a navigation; an adapter that cannot
86
+ * tell answers null, which refuses such a card post.
87
+ */
88
+ navigation?: () => Promise<'top' | 'frame' | null>;
89
+ /** cardOnFilePolicy: the policy the API served with the request's recognizer (VaultClient); absent reads as none.
90
+ * withoutCard is VaultClient's own (card-fields.js requestWithoutCard); optional so a test double may omit it. */
62
91
  vault: {
63
92
  isCardRequest(url: string, method?: string): boolean;
64
93
  merchantProfileOf?(url: string): MerchantProfile | null;
94
+ verifoneProfileOf?(url: string): VerifoneProfile | null;
95
+ cardOnFilePolicy?(url: string, method?: string): string | null;
96
+ withoutCard?(url: string, body: string | null | undefined): 'continue' | 'refuse' | null;
65
97
  };
66
98
  guards: {
67
99
  matches(url: string, method?: string): boolean;
68
100
  };
69
101
  mercado: MercadoCheckoutGate;
70
102
  stripe: StripeCheckoutGate;
103
+ /** ACI's split card; absent or inert until the registry serves ACI. */
104
+ aci?: AciGate;
105
+ /**
106
+ * Whether this browser sends the body the SDK replaced on a navigation, which removing the
107
+ * placeholder expiry from ACI's classic-mode /payment needs: true on the CDP adapter, which
108
+ * drives Chromium; the Playwright adapter asks the page's engine (aci.ts
109
+ * playwrightReplacesNavigationBody). Absent reads as no, so that /payment is refused.
110
+ */
111
+ replacesNavigationBody?: () => Promise<boolean>;
112
+ /** Worldpay eProtect's hosts; absent or inert until the registry serves eProtect. */
113
+ eprotect?: EprotectGate;
71
114
  readDocumentUrl: () => Promise<string>;
72
115
  lifecycle: CheckoutLifecycle;
73
116
  /** isEngaged and observeUnprepared are called only for an armed merchant profile's card request or a Fiserv card capture. */
@@ -93,6 +136,14 @@ export interface PreClaimContext {
93
136
  /** The paused request itself is gone (Playwright only); CDP returns false. */
94
137
  requestInactive: () => boolean;
95
138
  awaitingApproval: () => boolean;
139
+ /**
140
+ * The URLs of the frame that sent the request and of every frame above it, sender first, or
141
+ * undefined when the adapter cannot read them: Playwright walks the request's frame up through
142
+ * its parents, CDP reads the frame trees of the paused session and of each session above it.
143
+ * Read only for a Nuvei card request whose Origin or Referer does not already name PPS (see
144
+ * nuveiPreClaim), so no other request waits on it.
145
+ */
146
+ initiatorFrames?: () => readonly string[] | undefined | Promise<readonly string[] | undefined>;
96
147
  /** Set by the Stripe gate; read by the terminal arbiter and carried into a pause. */
97
148
  stripeStep: StripeStep;
98
149
  /** The merchant-hosted hand-off this attachment made, if any (merchant-handoff.ts). */
@@ -105,6 +156,31 @@ export interface PreClaimContext {
105
156
  cybersourceFlex?: {
106
157
  judge(request: FlexRequest): CybersourceFlexDecision | Promise<CybersourceFlexDecision>;
107
158
  };
159
+ /**
160
+ * The attachment's Juspay gate (juspay-gate.ts). Absent, or off because the registry does not
161
+ * serve the Juspay recognizer, and every request to a Juspay host is judged as it was before.
162
+ */
163
+ juspay?: JuspayCheckoutGate;
164
+ /** The attachment's approved Datatrans answers (the repeat rule, datatrans.ts). Absent: none are kept. */
165
+ datatrans?: DatatransRepeats;
166
+ /** The adapter's identity for the request's frame (CDP frameId, Playwright Frame); undefined when unknown. */
167
+ frame?: unknown;
168
+ /**
169
+ * The Payrails sessions the adapter captured, or null (or absent) when it captures none: the
170
+ * synced registry does not pause Payrails' save, so the Payrails gate defers every request.
171
+ */
172
+ payrails?: PayrailsSessionCapture | null;
173
+ /**
174
+ * The attachment's Shiji STS getCvvId companion and the adapter's opaque id
175
+ * for the page or frame this request came from (shiji-sts.ts), read when the
176
+ * request is judged (attachToPlaywright reads the frame's document, so it
177
+ * answers asynchronously). Absent, a getCvvId has nothing to bind to and is
178
+ * refused.
179
+ */
180
+ shijiSts?: {
181
+ companions: ShijiStsCompanions;
182
+ page: () => string | Promise<string>;
183
+ };
108
184
  }
109
185
  /**
110
186
  * The URL an event may name for a request. For an armed merchant profile's
@@ -115,12 +191,15 @@ export interface PreClaimContext {
115
191
  */
116
192
  export declare function eventUrl(vault: {
117
193
  merchantProfileOf?(url: string): MerchantProfile | null;
194
+ verifoneProfileOf?(url: string): VerifoneProfile | null;
118
195
  } | undefined, url: string): string;
119
196
  /** A gate returns a decision when it handles the request, undefined to defer to
120
197
  * the next gate, or a promise of either when it must do I/O first. */
121
198
  export type PreClaimGate = (ctx: PreClaimContext) => PreClaimDecision | undefined | Promise<PreClaimDecision | undefined>;
122
199
  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";
200
+ export declare const verifonePreClaim: PreClaimGate;
123
201
  export declare const fiservPreClaim: PreClaimGate;
202
+ export declare const ekashuPreClaim: PreClaimGate;
124
203
  /** The processor gates, in order. A new family adds one entry here; the terminal
125
204
  * arbiter runs after all of them and is not part of this list. A gate appended
126
205
  * after Stripe is never offered a step Stripe claimed: Stripe answers, aborts or