@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.
- package/CHANGELOG.md +47 -0
- package/PREFLIGHT.md +30 -0
- package/README.md +1070 -21
- package/dist/aci.d.ts +173 -0
- package/dist/aci.generated.d.ts +87 -0
- package/dist/aci.generated.js +306 -0
- package/dist/aci.js +371 -0
- package/dist/adyen-merchant-hosted.generated.d.ts +3 -3
- package/dist/adyen-merchant-hosted.generated.js +283 -49
- package/dist/agentcard.d.ts +9 -2
- package/dist/agentcard.js +4 -2
- package/dist/amadeus-checkout.generated.d.ts +57 -0
- package/dist/amadeus-checkout.generated.js +549 -0
- package/dist/amadeus.d.ts +41 -0
- package/dist/amadeus.js +81 -0
- package/dist/builtin-registry.generated.js +1 -1
- package/dist/card-endpoint.d.ts +177 -0
- package/dist/card-endpoint.js +286 -0
- package/dist/card-fields.generated.d.ts +5 -3
- package/dist/card-fields.generated.js +284 -7
- package/dist/cdp.d.ts +5 -1
- package/dist/cdp.js +841 -135
- package/dist/client.d.ts +403 -19
- package/dist/client.js +949 -98
- package/dist/creditguard.generated.d.ts +79 -0
- package/dist/creditguard.generated.js +662 -0
- package/dist/cse-body.js +11 -1
- package/dist/datatrans.d.ts +96 -0
- package/dist/datatrans.generated.d.ts +64 -0
- package/dist/datatrans.generated.js +426 -0
- package/dist/datatrans.js +178 -0
- package/dist/elavon-converge.d.ts +37 -0
- package/dist/elavon-converge.generated.d.ts +49 -0
- package/dist/elavon-converge.generated.js +439 -0
- package/dist/elavon-converge.js +84 -0
- package/dist/eprotect.d.ts +152 -0
- package/dist/eprotect.generated.d.ts +77 -0
- package/dist/eprotect.generated.js +498 -0
- package/dist/eprotect.js +222 -0
- package/dist/hosted-form.d.ts +3 -2
- package/dist/hosted-form.js +3 -2
- package/dist/index.d.ts +17 -3
- package/dist/index.js +6 -1
- package/dist/juspay-gate.d.ts +82 -0
- package/dist/juspay-gate.js +126 -0
- package/dist/juspay.generated.d.ts +89 -0
- package/dist/juspay.generated.js +705 -0
- package/dist/lifecycle.d.ts +57 -6
- package/dist/lifecycle.js +119 -8
- package/dist/merchant-card-endpoints.generated.d.ts +63 -0
- package/dist/merchant-card-endpoints.generated.js +1103 -0
- package/dist/merchant-hosted.d.ts +4 -1
- package/dist/merchant-hosted.js +5 -2
- package/dist/merchant-session-probe.d.ts +48 -0
- package/dist/merchant-session-probe.js +53 -0
- package/dist/merchant-session.generated.d.ts +69 -0
- package/dist/merchant-session.generated.js +919 -0
- package/dist/payrails.d.ts +133 -0
- package/dist/payrails.generated.d.ts +73 -0
- package/dist/payrails.generated.js +596 -0
- package/dist/payrails.js +305 -0
- package/dist/pelecard.d.ts +32 -0
- package/dist/pelecard.generated.d.ts +32 -0
- package/dist/pelecard.generated.js +283 -0
- package/dist/pelecard.js +42 -0
- package/dist/pre-claim.d.ts +72 -2
- package/dist/pre-claim.js +857 -5
- package/dist/preflight-catalog.json +2218 -287
- package/dist/preflight-schemas.json +179 -6
- package/dist/preflight.generated.d.ts +1 -1
- package/dist/preflight.generated.js +233 -4
- package/dist/preparation.d.ts +5 -2
- package/dist/preparation.js +36 -10
- package/dist/prepared-processor.d.ts +84 -5
- package/dist/prepared-processor.js +147 -6
- package/dist/primer.d.ts +53 -0
- package/dist/primer.generated.d.ts +38 -0
- package/dist/primer.generated.js +624 -0
- package/dist/primer.js +82 -0
- package/dist/registry.d.ts +100 -8
- package/dist/registry.js +85 -11
- package/dist/shiji-sts.d.ts +144 -0
- package/dist/shiji-sts.generated.d.ts +72 -0
- package/dist/shiji-sts.generated.js +913 -0
- package/dist/shiji-sts.js +222 -0
- package/dist/stripe-checkout.generated.d.ts +1 -1
- package/dist/stripe-checkout.generated.js +699 -9
- package/dist/stripe-setup.d.ts +16 -0
- package/dist/stripe-setup.js +61 -0
- package/dist/substitutions.generated.js +187 -29
- package/dist/verifone.d.ts +68 -0
- package/dist/verifone.generated.d.ts +51 -0
- package/dist/verifone.generated.js +1401 -0
- package/dist/verifone.js +119 -0
- package/dist/voice-types.d.ts +27 -0
- package/dist/voice.d.ts +6 -1
- package/dist/voice.js +6 -1
- package/dist/wspay.d.ts +41 -0
- package/dist/wspay.generated.d.ts +41 -0
- package/dist/wspay.generated.js +370 -0
- package/dist/wspay.js +65 -0
- package/examples/preflight/kernel-native/inventory.json +1 -1
- package/package.json +3 -3
|
@@ -7,30 +7,81 @@ import { checkoutComPreparationUrl, isPreparedCheckoutComRequest } from './check
|
|
|
7
7
|
import { classifyDeclaredMerchantRequest, classifyMerchantRequest } from './merchant-hosted.js';
|
|
8
8
|
import { fiservCapturePinId, fiservPreparationUrl, isPreparedFiservRequest } from './fiserv.js';
|
|
9
9
|
import { cybersourceFlexPreparationUrl, isPreparedCybersourceFlexRequest } from './cybersource-flex.generated.js';
|
|
10
|
+
import { isPreparedAciRequest } from './aci.generated.js';
|
|
11
|
+
import { CREDITGUARD_SANDBOX_HOST, creditguardPageProcessUrl, creditguardPreparationEnvironment, creditguardProcessRefusal, creditguardProcessTxId, } from './creditguard.generated.js';
|
|
12
|
+
import { eprotectPreparationUrl, isPreparedEprotectRequest } from './eprotect.generated.js';
|
|
13
|
+
import { amadeusEnvironment, amadeusPreparationUrls, amadeusRequestRefusal, isPreparedAmadeusRequest } from './amadeus-checkout.generated.js';
|
|
14
|
+
import { isPreparedVerifoneRequest } from './verifone.js';
|
|
10
15
|
export function preparationMode(psp) {
|
|
11
|
-
return psp === 'adyen' || psp === 'fiserv' ? 'cse' : 'token';
|
|
16
|
+
return psp === 'adyen' || psp === 'fiserv' || psp === 'verifone' ? 'cse' : 'token';
|
|
17
|
+
}
|
|
18
|
+
/** The method of the native card request a preparation binds: the registration GET for Worldpay eProtect, a POST for every other processor. */
|
|
19
|
+
export function preparationRequestMethod(psp) {
|
|
20
|
+
return psp === 'worldpay_eprotect' ? 'GET' : 'POST';
|
|
12
21
|
}
|
|
13
22
|
/**
|
|
14
23
|
* Shared endpoint processors cannot attest test/live mode from their URL or key prefix.
|
|
15
24
|
* Adyen can: test and live are separate hosts and key prefixes. Fiserv's are separate
|
|
16
25
|
* hosts too: connect (production) and connect-cert (sandbox). So are CyberSource
|
|
17
26
|
* Flex's: flex.cybersource.com is live, testflex.cybersource.com is test, and each has
|
|
18
|
-
* its own signing keys.
|
|
27
|
+
* its own signing keys. A Verifone preparation pays in the environment of the key its reviewed
|
|
28
|
+
* profile pins.
|
|
19
29
|
*/
|
|
20
30
|
export function validPreparationEnvironment(psp, environment) {
|
|
21
31
|
if (psp === 'bambora' || psp === 'mercado_pago' || psp === 'recurly' || psp === 'spreedly')
|
|
22
32
|
return environment === 'shared';
|
|
23
|
-
return ['square', 'braintree', 'worldpay', 'adyen', 'checkout_com', 'paysafe', 'fiserv', 'cybersource_flex'].includes(psp) && ['production', 'sandbox'].includes(environment);
|
|
33
|
+
return ['square', 'braintree', 'worldpay', 'adyen', 'checkout_com', 'paysafe', 'fiserv', 'cybersource_flex', 'aci', 'creditguard', 'worldpay_eprotect', 'amadeus_checkout', 'verifone'].includes(psp) && ['production', 'sandbox'].includes(environment);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* ACI's prepared endpoint, the literal the API names (backend checkout-prepared-processor.ts): its
|
|
37
|
+
* environment's primary widget host and a checkout id that can never be real, since the merchant
|
|
38
|
+
* mints the checkout only at Pay time. The bind matches the card-number request by host
|
|
39
|
+
* environment and shape instead (matchesPreparedRequest).
|
|
40
|
+
*/
|
|
41
|
+
export function aciPreparationUrl(environment) {
|
|
42
|
+
return `https://${environment === 'production' ? 'eu-prod' : 'eu-test'}.oppwa.com/v1/checkouts/prepared`;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A processor whose card request names an id the merchant mints only at Pay time (ACI's checkout
|
|
46
|
+
* id), so no URL can be prepared in advance: whether the adapters can intercept it is asked of the
|
|
47
|
+
* registry (VaultClient.recognizesProcessor), not of the prepared endpoint.
|
|
48
|
+
*/
|
|
49
|
+
export function preparationBindsByShape(psp) {
|
|
50
|
+
return psp === 'aci';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The endpoint a CreditGuard preparation stands for, per environment, as the API advertises it: the
|
|
54
|
+
* PPS card submit on pps (production) or ppsuat (sandbox) under the nil transaction id. It only
|
|
55
|
+
* proves the synced registry recognizes CreditGuard. A real submit names the txId of the page the
|
|
56
|
+
* preparation framed and may be on pps2, so it is matched by shape (matchesPreparedRequest), never
|
|
57
|
+
* by equality with this URL.
|
|
58
|
+
*/
|
|
59
|
+
export function creditguardPreparationUrl(environment) {
|
|
60
|
+
const host = environment === 'sandbox' ? CREDITGUARD_SANDBOX_HOST : 'pps.creditguard.co.il';
|
|
61
|
+
return `https://${host}/services/v1/txn/00000000-0000-0000-0000-000000000000/process`;
|
|
24
62
|
}
|
|
25
63
|
export function preparationEndpoint(psp, environment) {
|
|
26
64
|
if (!validPreparationEnvironment(psp, environment))
|
|
27
65
|
throw new Error('unsupported_preparation_processor');
|
|
28
66
|
if (psp === 'cybersource_flex')
|
|
29
67
|
return cybersourceFlexPreparationUrl(environment);
|
|
68
|
+
if (psp === 'creditguard')
|
|
69
|
+
return creditguardPreparationUrl(environment);
|
|
70
|
+
if (psp === 'worldpay_eprotect')
|
|
71
|
+
return eprotectPreparationUrl(environment);
|
|
72
|
+
// A Verifone endpoint is its reviewed profile's leg, never one per environment (verifone.ts).
|
|
73
|
+
if (psp === 'verifone')
|
|
74
|
+
throw new Error('unsupported_preparation_processor');
|
|
30
75
|
if (psp === 'paysafe')
|
|
31
76
|
return paysafePreparationUrl(environment);
|
|
32
77
|
if (psp === 'fiserv')
|
|
33
78
|
return fiservPreparationUrl(environment);
|
|
79
|
+
if (psp === 'aci')
|
|
80
|
+
return aciPreparationUrl(environment);
|
|
81
|
+
// The SDK's pay URL on the environment's first path, as the API names it. It only tells prepare()
|
|
82
|
+
// the processor is armed; the claim takes every exact card URL of that environment.
|
|
83
|
+
if (psp === 'amadeus_checkout')
|
|
84
|
+
return amadeusPreparationUrls(environment)[0];
|
|
34
85
|
if (psp === 'checkout_com')
|
|
35
86
|
return checkoutComPreparationUrl(environment);
|
|
36
87
|
if (psp === 'adyen')
|
|
@@ -91,8 +142,57 @@ function freshCardBody(psp, body) {
|
|
|
91
142
|
return false;
|
|
92
143
|
return true;
|
|
93
144
|
}
|
|
94
|
-
/**
|
|
95
|
-
|
|
145
|
+
/**
|
|
146
|
+
* CreditGuard PPS: the host's environment (ppsuat sandbox, pps and pps2 production) is the
|
|
147
|
+
* preparation's, the submit is the /process URL of the page the preparation read, on that page's
|
|
148
|
+
* own host and for its txId, and the request is the page's own new-card submit exactly as the
|
|
149
|
+
* device will judge it, with ppDomain bound to the approved merchant page. A saved card, a wallet,
|
|
150
|
+
* a refused flag, another transaction or another PPS host never spends consent.
|
|
151
|
+
*/
|
|
152
|
+
function matchesPreparedCreditguard(environment, requestUrl, body, headers, binding) {
|
|
153
|
+
let hostname = '', merchantHost = '';
|
|
154
|
+
try {
|
|
155
|
+
hostname = new URL(requestUrl).hostname;
|
|
156
|
+
merchantHost = new URL(binding.merchantOrigin ?? '').hostname;
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
if (creditguardPreparationEnvironment(hostname) !== environment)
|
|
162
|
+
return false;
|
|
163
|
+
const page = typeof binding.paymentPageUrl === 'string' ? creditguardPageProcessUrl(binding.paymentPageUrl) : null;
|
|
164
|
+
const txId = creditguardProcessTxId(requestUrl);
|
|
165
|
+
if (page === null || txId === null || page !== requestUrl)
|
|
166
|
+
return false;
|
|
167
|
+
return creditguardProcessRefusal({ url: requestUrl, method: 'POST', headers, body: body ?? '' }, { merchantHost }) === null;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* The approved merchant page's host, with its port if it has one: what the Amadeus SDK sends in its
|
|
171
|
+
* Amadeus-Checkout-Sdk-Host header (location.host). Null for anything but an http(s) origin. The
|
|
172
|
+
* API's twin (checkout-prepared-processor.ts) reads the same value.
|
|
173
|
+
*/
|
|
174
|
+
export function merchantHostOf(merchantOrigin) {
|
|
175
|
+
try {
|
|
176
|
+
const url = new URL(merchantOrigin ?? '');
|
|
177
|
+
return (url.protocol === 'https:' || url.protocol === 'http:') && url.host ? url.host.toLowerCase() : null;
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Processor identity and environment are part of the device's prior consent. `binding` carries what
|
|
185
|
+
* the preparation fixed beyond them (PreparedRequestBinding); Amadeus binds its SDK's Host header to
|
|
186
|
+
* `binding.merchantOrigin`, the origin the cardholder approved, and fails without one.
|
|
187
|
+
*/
|
|
188
|
+
export function matchesPreparedRequest(psp, environment, requestUrl, method, body, headers, binding = {}) {
|
|
189
|
+
// The one prepared GET: the registration itself, bodyless, on the approved environment's host,
|
|
190
|
+
// naming the paypageId the preparation carries (payment-core isPreparedEprotectRequest, the rule
|
|
191
|
+
// the API and the Vault bind with too). A preparation that carries none never matches.
|
|
192
|
+
if (psp === 'worldpay_eprotect') {
|
|
193
|
+
return validPreparationEnvironment(psp, environment)
|
|
194
|
+
&& isPreparedEprotectRequest(requestUrl, method.toUpperCase(), body ?? '', environment, binding.paypageId ?? null);
|
|
195
|
+
}
|
|
96
196
|
if (method.toUpperCase() !== 'POST' || !validPreparationEnvironment(psp, environment))
|
|
97
197
|
return false;
|
|
98
198
|
// CyberSource Flex: this environment's exact tokens URL, application/jwt with only the headers a
|
|
@@ -100,6 +200,11 @@ export function matchesPreparedRequest(psp, environment, requestUrl, method, bod
|
|
|
100
200
|
// Flex gate verified the issuing field iframe's capture context against that JWE's key.
|
|
101
201
|
if (psp === 'cybersource_flex')
|
|
102
202
|
return isPreparedCybersourceFlexRequest(requestUrl, method.toUpperCase(), body ?? null, environment, headers);
|
|
203
|
+
if (psp === 'creditguard')
|
|
204
|
+
return matchesPreparedCreditguard(environment, requestUrl, body, headers, binding);
|
|
205
|
+
// A Verifone request is judged only through the profile its preparation names (matchesPreparation).
|
|
206
|
+
if (psp === 'verifone')
|
|
207
|
+
return false;
|
|
103
208
|
if (psp === 'paysafe')
|
|
104
209
|
return isPreparedPaysafeRequest(requestUrl, method, body ?? null, environment, headers);
|
|
105
210
|
// Fiserv: that environment's card-capture endpoint exactly, the capture rules on the whole
|
|
@@ -107,6 +212,14 @@ export function matchesPreparedRequest(psp, environment, requestUrl, method, bod
|
|
|
107
212
|
// and for the merchant the body names (payment-core isPreparedFiservRequest).
|
|
108
213
|
if (psp === 'fiserv')
|
|
109
214
|
return isPreparedFiservRequest(requestUrl, method.toUpperCase(), body ?? null, environment, headers);
|
|
215
|
+
// ACI binds the exact card-number request of a checkout on a host of the prepared environment
|
|
216
|
+
// (payment-core isPreparedAciRequest, the rule the API and the Vault bind with too).
|
|
217
|
+
if (psp === 'aci')
|
|
218
|
+
return isPreparedAciRequest({ url: requestUrl, method: method.toUpperCase(), body: body ?? null, headers }, environment);
|
|
219
|
+
if (psp === 'amadeus_checkout') {
|
|
220
|
+
const merchantHost = merchantHostOf(binding.merchantOrigin);
|
|
221
|
+
return merchantHost !== null && isPreparedAmadeusRequest(requestUrl, method, body ?? null, environment, headers, { merchantHost });
|
|
222
|
+
}
|
|
110
223
|
if (psp === 'checkout_com')
|
|
111
224
|
return isPreparedCheckoutComRequest(requestUrl, method, body ?? null, environment, headers);
|
|
112
225
|
if (psp === 'adyen')
|
|
@@ -167,8 +280,18 @@ export function matchesPreparedMerchantRequest(profileId, requestUrl, method, bo
|
|
|
167
280
|
* the one its envelope's key is pinned as for its endpoint and merchant, must be that
|
|
168
281
|
* pin, as the API's bind requires. Two pins in one environment (a merchant's old and new
|
|
169
282
|
* keys during a rotation) never spend each other's approval. No other processor names one.
|
|
283
|
+
* A CreditGuard preparation binds the merchant page it approved and the page it framed
|
|
284
|
+
* (merchantOrigin, paymentPageUrl), which matchesPreparedRequest holds the submit to.
|
|
285
|
+
* A Worldpay eProtect preparation names the paypageId its registration must carry.
|
|
286
|
+
* An Amadeus preparation binds its SDK's Host header to the page the cardholder approved
|
|
287
|
+
* (merchantOrigin), as the API does.
|
|
170
288
|
*/
|
|
171
289
|
export function matchesPreparation(preparation, requestUrl, method, body, headers) {
|
|
290
|
+
// A Verifone preparation pays only its profile's reviewed leg, as payment-core pauses it.
|
|
291
|
+
if (preparation.psp === 'verifone') {
|
|
292
|
+
return typeof preparation.merchantProfile === 'string' && method.toUpperCase() === 'POST'
|
|
293
|
+
&& isPreparedVerifoneRequest(requestUrl, 'POST', body ?? null, preparation.merchantProfile);
|
|
294
|
+
}
|
|
172
295
|
if (preparation.psp === 'fiserv') {
|
|
173
296
|
if (!matchesPreparedRequest(preparation.psp, preparation.environment, requestUrl, method, body, headers))
|
|
174
297
|
return false;
|
|
@@ -178,5 +301,23 @@ export function matchesPreparation(preparation, requestUrl, method, body, header
|
|
|
178
301
|
return preparation.psp === 'adyen'
|
|
179
302
|
&& matchesPreparedMerchantRequest(preparation.merchantProfile, requestUrl, method, body, preparation.sandboxDeclaration);
|
|
180
303
|
}
|
|
181
|
-
return matchesPreparedRequest(preparation.psp, preparation.environment, requestUrl, method, body, headers);
|
|
304
|
+
return matchesPreparedRequest(preparation.psp, preparation.environment, requestUrl, method, body, headers, { merchantOrigin: preparation.merchantOrigin, paymentPageUrl: preparation.paymentPageUrl, paypageId: preparation.paypageId });
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* The reason a claim reports for a request its preparation does not match. An Amadeus preparation
|
|
308
|
+
* names what payment-core's Amadeus check refused on its own environment's card URL, as
|
|
309
|
+
* `amadeus_<reason>`: Air France's and KLM's add, whose expiry their own form keeps, is
|
|
310
|
+
* `amadeus_merchant_held_expiry`, every Data Collection Page store is
|
|
311
|
+
* `amadeus_dcp_field_config_unreviewed` until a merchant's field config is reviewed, and a Host
|
|
312
|
+
* header that does not name the approved page is `amadeus_header_binding`. Everything else, another
|
|
313
|
+
* processor's request or the other environment's host included, is `checkout_changed`.
|
|
314
|
+
*/
|
|
315
|
+
export function preparedRequestRefusal(psp, environment, requestUrl, body, headers, merchantOrigin) {
|
|
316
|
+
if (psp !== 'amadeus_checkout' || amadeusEnvironment(requestUrl) !== environment)
|
|
317
|
+
return 'checkout_changed';
|
|
318
|
+
const merchantHost = merchantHostOf(merchantOrigin);
|
|
319
|
+
if (merchantHost === null)
|
|
320
|
+
return 'amadeus_header_binding';
|
|
321
|
+
const reason = amadeusRequestRefusal({ url: requestUrl, method: 'POST', body: body ?? null, headers }, null, { merchantHost });
|
|
322
|
+
return typeof reason === 'string' ? `amadeus_${reason}` : 'checkout_changed';
|
|
182
323
|
}
|
package/dist/primer.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const PRIMER_PSP = "primer";
|
|
2
|
+
/** The dark-launch capability a build declares when it judges every Primer request with classifyPrimerRequest. */
|
|
3
|
+
export declare const PRIMER_CAPABILITY = "primer_payment_instruments";
|
|
4
|
+
/**
|
|
5
|
+
* Why a Primer request was aborted as an unsupported checkout, reported as the `reason` of the
|
|
6
|
+
* `unsupported_checkout` event and of the attachment's `unsupported` state:
|
|
7
|
+
* unsupported_primer_sdk a card request from Primer Checkout (primer-js), whose request gives
|
|
8
|
+
* up after 30 seconds, or any SDK that is not the legacy v2 controller
|
|
9
|
+
* unsupported_primer_request a card request the legacy v2 controller would not send: another URL
|
|
10
|
+
* spelling on the pci host, another header or body shape
|
|
11
|
+
*/
|
|
12
|
+
export type PrimerUnsupportedReason = 'unsupported_primer_sdk' | 'unsupported_primer_request';
|
|
13
|
+
/**
|
|
14
|
+
* Why a single Primer request was aborted alone, reported as the detail of a `blocked` event; the
|
|
15
|
+
* attachment is not held, so the next request is judged again:
|
|
16
|
+
* primer_keep_on_file the body asks Primer to save the card for later charges
|
|
17
|
+
* unreadable_primer_request the adapter could not read the body
|
|
18
|
+
*/
|
|
19
|
+
export type PrimerBlockedReason = 'primer_keep_on_file' | 'unreadable_primer_request';
|
|
20
|
+
/** What the pre-claim gate does with a request on a Primer pci host. */
|
|
21
|
+
export type PrimerVerdict = {
|
|
22
|
+
kind: 'defer';
|
|
23
|
+
} | {
|
|
24
|
+
kind: 'block';
|
|
25
|
+
reason: PrimerBlockedReason;
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'unsupported';
|
|
28
|
+
reason: PrimerUnsupportedReason;
|
|
29
|
+
};
|
|
30
|
+
/** True for a URL on one of Primer's two pci hosts, whatever its path. */
|
|
31
|
+
export declare function isPrimerPciHost(rawUrl: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The gate's verdict for a POST the registry recognized on a Primer pci host: defer (a new card,
|
|
34
|
+
* which the arbiter pauses, or a body with no card, which the card-field rule continues), block it
|
|
35
|
+
* alone, or abort it as an unsupported checkout. A decision that throws refuses.
|
|
36
|
+
*/
|
|
37
|
+
export declare function primerRequestVerdict(request: {
|
|
38
|
+
url: string;
|
|
39
|
+
method: string;
|
|
40
|
+
headers?: Record<string, string>;
|
|
41
|
+
body: string | null;
|
|
42
|
+
}): PrimerVerdict;
|
|
43
|
+
/**
|
|
44
|
+
* The only answer the page may receive for an approved Primer request: status 200 or 201 and
|
|
45
|
+
* Primer's single-use card token rebuilt from payment-core's allow-list (sanitizePrimerResponse),
|
|
46
|
+
* under a JSON content type. Null for anything else: another status, a multi-use token or vaultData
|
|
47
|
+
* (the card was saved), a field out of bounds, a body that does not parse.
|
|
48
|
+
*/
|
|
49
|
+
export declare function primerTokenAnswer(status: number, body: string): {
|
|
50
|
+
status: number;
|
|
51
|
+
headers: Record<string, string>;
|
|
52
|
+
body: string;
|
|
53
|
+
} | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
declare var PRIMER_PCI_HOSTS: readonly string[];
|
|
2
|
+
declare var PRIMER_TOKENIZE_PATH: string;
|
|
3
|
+
declare var PRIMER_REFUSAL_REASONS: readonly string[];
|
|
4
|
+
declare var PRIMER_PROVABLE_NETWORKS: readonly string[];
|
|
5
|
+
declare function isPrimerTokenizeUrl(url: any, method?: string): boolean;
|
|
6
|
+
declare function primerBodyRefusal(body: any): "unsupported" | "keep_on_file" | null;
|
|
7
|
+
declare function isPrimerNewCardBody(body: any): boolean;
|
|
8
|
+
declare function primerKeepOnFileRequested(body: any): boolean | null;
|
|
9
|
+
declare function classifyPrimerRequest(url: any, method: any, body: any, headers: any): "card" | "unsupported" | "keep_on_file" | "unsupported_sdk" | null;
|
|
10
|
+
declare function primerTokenizeRefusal(request: any): "unsupported" | "keep_on_file" | "unsupported_sdk" | null;
|
|
11
|
+
declare function isPrimerTokenizeRequest(request: any): boolean;
|
|
12
|
+
declare function primerRefusalMessage(reason: any): string;
|
|
13
|
+
declare function primerCardNetwork(number: any): "VISA" | "AMEX" | "MASTERCARD" | null;
|
|
14
|
+
declare function primerNetworkRefusal(body: any, card: any): "unsupported" | "network_mismatch" | null;
|
|
15
|
+
declare function injectPrimerCard(body: any, card: any): {
|
|
16
|
+
body: string;
|
|
17
|
+
where: string[];
|
|
18
|
+
};
|
|
19
|
+
declare function primerErrorId(body: any): any;
|
|
20
|
+
declare function primerResponseOutcome(status: any, body: any, card: any): {
|
|
21
|
+
outcome: string;
|
|
22
|
+
code: any;
|
|
23
|
+
reason?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
outcome: string;
|
|
26
|
+
reason: string;
|
|
27
|
+
code?: undefined;
|
|
28
|
+
} | {
|
|
29
|
+
outcome: string;
|
|
30
|
+
code?: undefined;
|
|
31
|
+
reason?: undefined;
|
|
32
|
+
};
|
|
33
|
+
declare function sanitizePrimerResponse(body: any): string;
|
|
34
|
+
declare function primerFacts(status: any, body: any): {
|
|
35
|
+
outcome: string;
|
|
36
|
+
refusalCode: any;
|
|
37
|
+
};
|
|
38
|
+
export { PRIMER_PCI_HOSTS, PRIMER_PROVABLE_NETWORKS, PRIMER_REFUSAL_REASONS, PRIMER_TOKENIZE_PATH, classifyPrimerRequest, injectPrimerCard, isPrimerNewCardBody, isPrimerTokenizeRequest, isPrimerTokenizeUrl, primerBodyRefusal, primerCardNetwork, primerErrorId, primerFacts, primerKeepOnFileRequested, primerNetworkRefusal, primerRefusalMessage, primerResponseOutcome, primerTokenizeRefusal, sanitizePrimerResponse };
|