@agent-cards/sdk 0.23.20 → 0.23.22
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.
- package/CHANGELOG.md +55 -2
- package/PREFLIGHT.md +6 -0
- package/README.md +169 -5
- package/dist/amadeus-checkout.generated.d.ts +6 -1
- package/dist/amadeus-checkout.generated.js +26 -2
- package/dist/card-fields.generated.js +2341 -127
- package/dist/cdp.js +199 -28
- package/dist/client.d.ts +177 -9
- package/dist/client.js +387 -37
- package/dist/comgate.d.ts +50 -0
- package/dist/comgate.js +80 -0
- package/dist/creditguard.generated.js +4 -2
- package/dist/cse-body.js +11 -0
- package/dist/cybersource-secure-acceptance.generated.d.ts +1 -1
- package/dist/ebanx.d.ts +1 -1
- package/dist/ebanx.js +1 -1
- package/dist/eprotect.generated.d.ts +1 -1
- package/dist/eximbay.d.ts +46 -0
- package/dist/eximbay.js +69 -0
- package/dist/gmo.generated.js +7 -3
- package/dist/hipay.generated.d.ts +5 -5
- package/dist/hipay.generated.js +5 -2
- package/dist/hold.d.ts +1 -1
- package/dist/hold.js +10 -4
- package/dist/hosted-entry.d.ts +4 -0
- package/dist/hosted-entry.js +32 -0
- package/dist/index.d.ts +1 -0
- package/dist/lifecycle.d.ts +9 -4
- package/dist/lifecycle.js +16 -4
- package/dist/paddle-tokenex.generated.js +7 -3
- package/dist/paygent.generated.d.ts +60 -0
- package/dist/paygent.generated.js +425 -0
- package/dist/payrails.generated.js +7 -3
- package/dist/payrexx.d.ts +91 -0
- package/dist/payrexx.generated.d.ts +91 -0
- package/dist/payrexx.generated.js +536 -0
- package/dist/payrexx.js +141 -0
- package/dist/pre-claim.d.ts +30 -1
- package/dist/pre-claim.js +257 -39
- package/dist/preflight-catalog.json +58 -0
- package/dist/preflight-schemas.json +4 -0
- package/dist/preflight.generated.js +26 -2
- package/dist/prepared-processor.d.ts +7 -2
- package/dist/prepared-processor.js +16 -2
- package/dist/primer.generated.js +2469 -255
- package/dist/przelewy24.d.ts +47 -0
- package/dist/przelewy24.js +88 -0
- package/dist/registry.d.ts +6 -5
- package/dist/registry.js +27 -7
- package/dist/shiji-sts.generated.js +7 -3
- package/dist/stripe-checkout.generated.js +896 -19
- package/dist/toast-seal.generated.d.ts +37 -0
- package/dist/toast-seal.generated.js +625 -0
- package/dist/toast.generated.d.ts +41 -0
- package/dist/toast.generated.js +113 -0
- package/dist/tokenex-iframe.d.ts +93 -0
- package/dist/tokenex-iframe.generated.d.ts +81 -0
- package/dist/tokenex-iframe.generated.js +403 -0
- package/dist/tokenex-iframe.js +195 -0
- package/dist/transbank.d.ts +45 -0
- package/dist/transbank.js +73 -0
- package/dist/twoc2p.generated.js +7 -3
- package/examples/preflight/kernel-native/inventory.json +1 -1
- package/package.json +3 -3
package/dist/payrexx.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payrexx Pay's card frame after its card request (payment-core payrexx.js holds the rules; this SDK vendors them as
|
|
3
|
+
* payrexx.generated.ts).
|
|
4
|
+
*
|
|
5
|
+
* The frame, https://checkout.payrexx.com/?pspId=44&lang=<xx>, posts the card to its own URL. When Payrexx answers that
|
|
6
|
+
* card request by starting 3-D Secure (no token, a threeDSServerTransID), the merchant's page runs 3-D Secure and the
|
|
7
|
+
* frame posts the whole card again to the same URL for each step, with the step's own keys after the card request's
|
|
8
|
+
* fifteen:
|
|
9
|
+
* - the authentication, after the ACS method: threeDSServerTransID, threeDSVersion when the first answer named one,
|
|
10
|
+
* and ten authData values the page reads from the agent's browser;
|
|
11
|
+
* - the post-authentication, after the bank's challenge: threeDSServerTransID and postAuth=true.
|
|
12
|
+
* On a page this SDK is attached to, that card is the agent's placeholder. One approval covers at most one of each, in
|
|
13
|
+
* that order, for the 3-D Secure run its own answer opened (payment-core payrexxFollowUpVerdict), so a run sends the
|
|
14
|
+
* card at most three times. What this module keeps of the approved card request (PayrexxFollowUps) is what the
|
|
15
|
+
* pre-claim gate reads to decide whether the cardholder's device sends a step, or the step fails in the browser.
|
|
16
|
+
* The card request itself, and a body with no card value at all (a wallet's own encryptedCard), are not 3-D Secure
|
|
17
|
+
* sends: the card-request arbiter pauses the one and continues the other (card-fields.js).
|
|
18
|
+
*/
|
|
19
|
+
import { PAYREXX_FOLLOW_UP_KINDS, isPayrexxFrameUrl, payrexxAnswerOutcome, payrexxBodyVerdict, payrexxFollowUpVerdict, payrexxGateVerdict, } from './payrexx.generated.js';
|
|
20
|
+
export const PAYREXX_PSP = 'payrexx';
|
|
21
|
+
/** The capability a build declares to be served Payrexx's recognizer (payment-core PAYREXX_CAPABILITY). */
|
|
22
|
+
export const PAYREXX_CAPABILITY = 'payrexx_card_frame';
|
|
23
|
+
/** The reason a checkout reads when a 3-D Secure send of the placeholder card fails in the browser. */
|
|
24
|
+
export const PAYREXX_RESEND_REASON = 'unsupported_payrexx_card_resend';
|
|
25
|
+
/**
|
|
26
|
+
* Whether a request is a POST to Payrexx's card frame URL whose body sends the card again for a 3-D Secure step
|
|
27
|
+
* (payment-core payrexxBodyVerdict: payrexx_three_ds_resend). `readBody` is called only for a POST to the frame URL,
|
|
28
|
+
* and a reader that throws, or a body nobody could read, reads as no 3-D Secure send.
|
|
29
|
+
*/
|
|
30
|
+
export function isPayrexxResend(url, method, readBody) {
|
|
31
|
+
if (String(method).toUpperCase() !== 'POST' || !isPayrexxFrameUrl(url))
|
|
32
|
+
return false;
|
|
33
|
+
let body;
|
|
34
|
+
try {
|
|
35
|
+
body = readBody();
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
body = null;
|
|
39
|
+
}
|
|
40
|
+
if (typeof body !== 'string')
|
|
41
|
+
return false;
|
|
42
|
+
const verdict = payrexxBodyVerdict(body);
|
|
43
|
+
return verdict.verdict === 'refuse' && verdict.code === 'payrexx_three_ds_resend';
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A 3-D Secure send the cardholder's device did not answer with Payrexx's own answer. `reason` is the API's word for
|
|
47
|
+
* it: `not_picked_up` (no device started it in time: the Vault page was closed or asleep), `not_sent` (the device
|
|
48
|
+
* refused it before the card left), `no_answer`, `answer_withheld` (Payrexx's answer carried the card),
|
|
49
|
+
* `answer_refused`, `answer_late`, `response_expired`, or the API's refusal code when it did not take the send at all
|
|
50
|
+
* (`follow_up_refused`, `follow_up_not_covered`, `follow_up_window_closed`). `cardSent` says whether the card may
|
|
51
|
+
* have reached Payrexx: false only when the API confirmed it never left the device. Nothing in it names the request,
|
|
52
|
+
* the card or Payrexx's answer.
|
|
53
|
+
*/
|
|
54
|
+
export class PayrexxFollowUpError extends Error {
|
|
55
|
+
reason;
|
|
56
|
+
cardSent;
|
|
57
|
+
authorizationId;
|
|
58
|
+
constructor(reason, cardSent, authorizationId) {
|
|
59
|
+
super(cardSent
|
|
60
|
+
? `This Payrexx 3-D Secure request under ${authorizationId} has no answer, and the cardholder's device may have sent it: ${reason}.`
|
|
61
|
+
: `The cardholder's device did not send this Payrexx 3-D Secure request under ${authorizationId}: ${reason}.`);
|
|
62
|
+
this.reason = reason;
|
|
63
|
+
this.cardSent = cardSent;
|
|
64
|
+
this.authorizationId = authorizationId;
|
|
65
|
+
this.name = 'PayrexxFollowUpError';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* What one attachment keeps of its approved Payrexx card request: the request and Payrexx's answer as the page received
|
|
70
|
+
* them, until when the API said the approval covers sends after it, and the sends it claimed since, in order. Only a
|
|
71
|
+
* card request whose answer started 3-D Secure (payment-core payrexxAnswerOutcome: pending three_ds) and whose read
|
|
72
|
+
* named that window (`followUpsUntil`) is kept. Any later Payrexx card request handed over replaces it, a send the
|
|
73
|
+
* window has passed is never claimed, and once a send is refused or fails the attachment stops (stop()): nothing after
|
|
74
|
+
* it is claimed, a later approval included.
|
|
75
|
+
*/
|
|
76
|
+
export class PayrexxFollowUps {
|
|
77
|
+
parent = null;
|
|
78
|
+
sent = [];
|
|
79
|
+
stopped = false;
|
|
80
|
+
/** After a refused or failed send: no later request on this attachment is claimed. */
|
|
81
|
+
stop() { this.stopped = true; }
|
|
82
|
+
/**
|
|
83
|
+
* The approval the remembered card request went under, or null when none is remembered. The gate sends nothing
|
|
84
|
+
* unless the checkout's own state names this same approval.
|
|
85
|
+
*/
|
|
86
|
+
get authorizationId() { return this.parent?.authorizationId ?? null; }
|
|
87
|
+
/**
|
|
88
|
+
* As the adapter hands an approved card request's answer to the page: before the answer lands, since the page may
|
|
89
|
+
* start 3-D Secure at once. Every Payrexx card request handed over clears what an earlier one left; only one whose
|
|
90
|
+
* answer started 3-D Secure, under a read that named the window, is kept.
|
|
91
|
+
*/
|
|
92
|
+
remember(request, replay) {
|
|
93
|
+
if (payrexxGateVerdict(request.url, request.body).verdict !== 'card')
|
|
94
|
+
return;
|
|
95
|
+
this.parent = null;
|
|
96
|
+
this.sent = [];
|
|
97
|
+
const until = typeof replay.followUpsUntil === 'string' ? Date.parse(replay.followUpsUntil) : NaN;
|
|
98
|
+
if ((replay.mode ?? 'token') !== 'token' || !Number.isFinite(until))
|
|
99
|
+
return;
|
|
100
|
+
// No card: this browser only ever held the placeholder.
|
|
101
|
+
const outcome = payrexxAnswerOutcome(replay.status, replay.body, null);
|
|
102
|
+
if (outcome.outcome !== 'approved' || outcome.pending !== 'three_ds')
|
|
103
|
+
return;
|
|
104
|
+
this.parent = { authorizationId: replay.authorizationId, url: request.url, body: request.body, answer: { status: replay.status, text: replay.body }, until };
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The claim for a paused 3-D Secure send the remembered approval covers, or null: no approval covers sends here, its
|
|
108
|
+
* window has passed, or payment-core's rule refuses the send against the sends already claimed. Synchronous, and it
|
|
109
|
+
* reserves the send, so two requests can never both be claimed as the next one.
|
|
110
|
+
*/
|
|
111
|
+
claim(request, now = Date.now()) {
|
|
112
|
+
const parent = this.parent;
|
|
113
|
+
if (this.stopped || !parent || now >= parent.until || typeof request.body !== 'string')
|
|
114
|
+
return null;
|
|
115
|
+
const verdict = payrexxFollowUpVerdict({
|
|
116
|
+
parent: { url: parent.url, body: parent.body, answer: parent.answer }, sent: this.sent,
|
|
117
|
+
request: { url: request.url, method: request.method, body: request.body },
|
|
118
|
+
});
|
|
119
|
+
if (!verdict.ok || !PAYREXX_FOLLOW_UP_KINDS.includes(verdict.kind))
|
|
120
|
+
return null;
|
|
121
|
+
const entry = { kind: verdict.kind, state: 'pending' };
|
|
122
|
+
this.sent.push(entry);
|
|
123
|
+
const contentType = Object.entries(request.headers ?? {}).find(([name]) => /^content-type$/i.test(name))?.[1];
|
|
124
|
+
return {
|
|
125
|
+
authorizationId: parent.authorizationId, kind: verdict.kind, until: parent.until,
|
|
126
|
+
request: { url: request.url, method: 'POST', headers: { 'content-type': typeof contentType === 'string' ? contentType : 'application/x-www-form-urlencoded; charset=UTF-8' },
|
|
127
|
+
body: request.body },
|
|
128
|
+
settle(answer) {
|
|
129
|
+
if (entry.state !== 'pending')
|
|
130
|
+
return;
|
|
131
|
+
// A copy of the answer as it was settled: a caller that changes its own object later changes no claim.
|
|
132
|
+
if (answer) {
|
|
133
|
+
entry.state = 'answered';
|
|
134
|
+
entry.answer = { status: answer.status, text: answer.text };
|
|
135
|
+
}
|
|
136
|
+
else
|
|
137
|
+
entry.state = 'failed';
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
}
|
package/dist/pre-claim.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { StripeCheckoutGate } from './stripe-checkout.js';
|
|
|
2
2
|
import { MercadoCheckoutGate } from './mercado-checkout.js';
|
|
3
3
|
import { type JuspayCheckoutGate } from './juspay-gate.js';
|
|
4
4
|
import { DatatransRepeats } from './datatrans.js';
|
|
5
|
+
import { TokenexIframeRepeats } from './tokenex-iframe.js';
|
|
5
6
|
import { type AciGate } from './aci.js';
|
|
6
7
|
import type { EprotectGate } from './eprotect.js';
|
|
7
8
|
import { type ShijiStsCompanions } from './shiji-sts.js';
|
|
@@ -15,6 +16,7 @@ import { type VerifoneProfile } from './verifone.js';
|
|
|
15
16
|
import { type WorldlineMyCheckoutProducts } from './worldline-mycheckout.js';
|
|
16
17
|
import { type PaddleVgsPayGate } from './paddle-vgs-pay.js';
|
|
17
18
|
import { type EbanxFollowUps } from './ebanx.js';
|
|
19
|
+
import { type PayrexxFollowUps } from './payrexx.js';
|
|
18
20
|
/** The native Stripe step the gate claimed, or null when none was: exactly what StripeCheckoutGate.claim returns. */
|
|
19
21
|
type StripeStep = ReturnType<StripeCheckoutGate['claim']>;
|
|
20
22
|
/** A synthetic response a gate fulfills locally. The effect applies CORS and encoding. */
|
|
@@ -99,7 +101,7 @@ export interface PreClaimContext {
|
|
|
99
101
|
verifoneProfileOf?(url: string): VerifoneProfile | null;
|
|
100
102
|
cardOnFilePolicy?(url: string, method?: string): string | null;
|
|
101
103
|
withoutCard?(url: string, body: string | null | undefined): 'continue' | 'refuse' | null;
|
|
102
|
-
/** VaultClient.recognizesProcessor: whether the synced registry serves this processor. */
|
|
104
|
+
/** VaultClient.recognizesProcessor: whether the synced registry serves this processor (ACI, EBANX, the TokenEx iframe). */
|
|
103
105
|
recognizesProcessor?(psp: string): boolean;
|
|
104
106
|
/** VaultClient.sendEbanxFollowUp: a send an approved EBANX token request covers, from the cardholder's device. */
|
|
105
107
|
sendEbanxFollowUp?(authorizationId: string, request: {
|
|
@@ -115,6 +117,20 @@ export interface PreClaimContext {
|
|
|
115
117
|
headers: Record<string, string>;
|
|
116
118
|
body: string;
|
|
117
119
|
}>;
|
|
120
|
+
/** VaultClient.sendPayrexxFollowUp: a 3-D Secure send an approved Payrexx card request covers, from the cardholder's device. */
|
|
121
|
+
sendPayrexxFollowUp?(authorizationId: string, request: {
|
|
122
|
+
url: string;
|
|
123
|
+
method: 'POST';
|
|
124
|
+
headers: Record<string, string>;
|
|
125
|
+
body: string;
|
|
126
|
+
}, options?: {
|
|
127
|
+
signal?: AbortSignal;
|
|
128
|
+
until?: number;
|
|
129
|
+
}): Promise<{
|
|
130
|
+
status: number;
|
|
131
|
+
headers: Record<string, string>;
|
|
132
|
+
body: string;
|
|
133
|
+
}>;
|
|
118
134
|
};
|
|
119
135
|
guards: {
|
|
120
136
|
matches(url: string, method?: string): boolean;
|
|
@@ -188,6 +204,8 @@ export interface PreClaimContext {
|
|
|
188
204
|
juspay?: JuspayCheckoutGate;
|
|
189
205
|
/** The attachment's approved Datatrans answers (the repeat rule, datatrans.ts). Absent: none are kept. */
|
|
190
206
|
datatrans?: DatatransRepeats;
|
|
207
|
+
/** The attachment's approved TokenEx iframe answers (the repeat rule, tokenex-iframe.ts). Absent: none are kept. */
|
|
208
|
+
tokenexIframe?: TokenexIframeRepeats;
|
|
191
209
|
/** The adapter's identity for the request's frame (CDP frameId, Playwright Frame); undefined when unknown. */
|
|
192
210
|
frame?: unknown;
|
|
193
211
|
/**
|
|
@@ -223,6 +241,12 @@ export interface PreClaimContext {
|
|
|
223
241
|
* is refused, as before the approval covered them.
|
|
224
242
|
*/
|
|
225
243
|
ebanx?: EbanxFollowUps;
|
|
244
|
+
/**
|
|
245
|
+
* The attachment's approved Payrexx card request and the 3-D Secure sends claimed under it (payrexx.ts
|
|
246
|
+
* PayrexxFollowUps). Absent, or holding no approval whose answer started 3-D Secure, and every 3-D Secure send of the
|
|
247
|
+
* card frame is refused.
|
|
248
|
+
*/
|
|
249
|
+
payrexx?: PayrexxFollowUps;
|
|
226
250
|
}
|
|
227
251
|
/**
|
|
228
252
|
* The URL an event may name for a request. For an armed merchant profile's
|
|
@@ -251,9 +275,13 @@ export declare const fiservPreClaim: PreClaimGate;
|
|
|
251
275
|
export declare function isArmedCreditguardCall(vault: {
|
|
252
276
|
recognizesProcessor?(psp: string): boolean;
|
|
253
277
|
} | undefined, url: string): boolean;
|
|
278
|
+
export declare const przelewy24PreClaim: PreClaimGate;
|
|
254
279
|
export declare const ekashuPreClaim: PreClaimGate;
|
|
280
|
+
export declare const transbankPreClaim: PreClaimGate;
|
|
255
281
|
export declare const redsysPreClaim: PreClaimGate;
|
|
256
282
|
export declare const quickpayPreClaim: PreClaimGate;
|
|
283
|
+
export declare const comgatePreClaim: PreClaimGate;
|
|
284
|
+
export declare const eximbayPreClaim: PreClaimGate;
|
|
257
285
|
export declare const paypalHostedFieldsPreClaim: PreClaimGate;
|
|
258
286
|
export declare const paypalCardFormsPreClaim: PreClaimGate;
|
|
259
287
|
export declare const cybersourceSecureAcceptancePreClaim: PreClaimGate;
|
|
@@ -271,6 +299,7 @@ export declare function routesHipayVault(vault: {
|
|
|
271
299
|
recognizesProcessor?: (psp: string) => boolean;
|
|
272
300
|
} | null | undefined, url: string): boolean;
|
|
273
301
|
export declare const ebanxPreClaim: PreClaimGate;
|
|
302
|
+
export declare const payrexxPreClaim: PreClaimGate;
|
|
274
303
|
/** The processor gates, in order. A new family adds one entry here; the terminal
|
|
275
304
|
* arbiter runs after all of them and is not part of this list. A gate appended
|
|
276
305
|
* after Stripe is never offered a step Stripe claimed: Stripe answers, aborts or
|