@agent-cards/sdk 0.23.9 → 0.23.10
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 +40 -0
- package/PREFLIGHT.md +7 -5
- package/README.md +181 -92
- package/dist/aci.d.ts +7 -5
- package/dist/aci.generated.d.ts +2 -1
- package/dist/aci.generated.js +14 -4
- package/dist/aci.js +28 -7
- package/dist/amadeus-checkout.generated.js +2 -2
- package/dist/builtin-registry.generated.js +1 -1
- package/dist/card-fields.generated.js +163 -9
- package/dist/cdp.js +79 -34
- package/dist/client.d.ts +61 -31
- package/dist/client.js +99 -42
- package/dist/creditguard.generated.d.ts +1 -1
- package/dist/creditguard.generated.js +1 -3
- package/dist/cse-body.d.ts +7 -6
- package/dist/cse-body.js +8 -7
- package/dist/datatrans.generated.js +8 -5
- package/dist/elavon-converge.d.ts +1 -1
- package/dist/elavon-converge.generated.js +7 -4
- package/dist/elavon-converge.js +4 -3
- package/dist/fiserv.d.ts +9 -5
- package/dist/fiserv.generated.d.ts +3 -3
- package/dist/fiserv.generated.js +50 -20
- package/dist/fiserv.js +10 -6
- package/dist/payrails.d.ts +78 -18
- package/dist/payrails.generated.d.ts +12 -2
- package/dist/payrails.generated.js +213 -18
- package/dist/payrails.js +165 -44
- package/dist/pre-claim.js +51 -29
- package/dist/preflight-capabilities.generated.d.ts +0 -106
- package/dist/preflight-capabilities.generated.js +0 -153
- package/dist/preflight-catalog.json +61 -181
- package/dist/preflight-schemas.json +6 -6
- package/dist/preflight.generated.d.ts +0 -106
- package/dist/preflight.generated.js +27 -15
- package/dist/preparation.d.ts +2 -0
- package/dist/preparation.js +4 -2
- package/dist/prepared-processor.d.ts +19 -5
- package/dist/prepared-processor.js +21 -5
- package/dist/primer.generated.d.ts +5 -1
- package/dist/primer.generated.js +200 -33
- package/dist/registry.d.ts +18 -12
- package/dist/registry.js +11 -8
- package/dist/shiji-sts.d.ts +24 -22
- package/dist/shiji-sts.generated.d.ts +1 -1
- package/dist/shiji-sts.generated.js +12 -8
- package/dist/shiji-sts.js +49 -46
- package/dist/stripe-checkout.generated.js +146 -49
- package/dist/verifone.generated.js +192 -17
- package/dist/verifone.js +1 -1
- package/dist/wspay.d.ts +17 -16
- package/dist/wspay.generated.d.ts +6 -1
- package/dist/wspay.generated.js +13 -3
- package/dist/wspay.js +9 -11
- package/examples/preflight/kernel-native/README.md +1 -1
- package/examples/preflight/kernel-native/inventory.json +1 -19
- package/package.json +3 -3
package/dist/fiserv.generated.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// Generated from @agent-cards/payment-core. Do not edit.
|
|
3
|
-
// artifact-sha256:
|
|
3
|
+
// artifact-sha256: 0e3d991aa970b75f82e71cdec7a1c8dd9211626cd1821485492de7dfc37aad96
|
|
4
4
|
// src/fiserv-environment.js
|
|
5
5
|
var FISERV_CARD_CAPTURE_ENDPOINTS = /* @__PURE__ */ Object.freeze({
|
|
6
6
|
production: "https://connect.fiservapis.com/ch/payments-vas/v1/card-capture",
|
|
@@ -320,12 +320,16 @@ var FISERV_KEY_PINS = /* @__PURE__ */ deepFreeze([
|
|
|
320
320
|
id: "homedepot_orangepay",
|
|
321
321
|
merchant: "Home Depot",
|
|
322
322
|
environment: "production",
|
|
323
|
-
//
|
|
324
|
-
//
|
|
325
|
-
//
|
|
326
|
-
//
|
|
327
|
-
//
|
|
328
|
-
merchantIds: [],
|
|
323
|
+
// The Commerce Hub merchant OrangePay's capture names on Blinds.com, Home
|
|
324
|
+
// Depot's blinds store, and on homedepot.com: merchantDetails.merchantId
|
|
325
|
+
// TZOPBKED with terminal 12, which OrangePay's frame hands the Secure Data
|
|
326
|
+
// Capture submit, read card-free from Blinds.com's payment step on 2026-09-30,
|
|
327
|
+
// 2026-10-06 and 2026-10-11, and the id env.js names for both stores.
|
|
328
|
+
merchantIds: ["TZOPBKED"],
|
|
329
|
+
// Blinds.com's checkout, where those three captures were read. homedepot.com
|
|
330
|
+
// runs the same OrangePay page and its env.js names the same merchant, but no
|
|
331
|
+
// capture was read there, so it is not listed and its approval names no host.
|
|
332
|
+
checkoutOrigins: ["https://www.blinds.com"],
|
|
329
333
|
keyId: "d51d5faeb0261f664c99aac27cd131db",
|
|
330
334
|
spki: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArobUom7fqw1aWE03z0OFQhnwzXPmh/rw0GxxEEdDsV07ysH/xtEAggNO46sWeWh8UEBat/mleL6wart8XEDkP1z67mSBhvu9Y3MqrbTMilxkb7NxdsMW26ukYx7Q9QGq+llTuapwBhLeU3uVsu0keUcs1kqc32fisCMv6hd7Nvh9niVp6dxPpqWnlmrB3PqQI/Y9wIOKlLtQ8n/1b5V3UJUjEXgJlDBzBn13ATj3vrl2aJxey6A99DL75md8RBF/rd2x/OxPKHkqWQWbRIgd++dtjxLVUYe5vRnq8OtqvrWdY0SCRoG61PgHqIPvoaokovJNi8utp95WuCww5jX8MQIDAQAB",
|
|
331
335
|
spkiSha256: "49c3ac40078bfb4d5a08ebf1f6009d0b4b25b9cac58a4046fe64f1fa917a0e84",
|
|
@@ -341,6 +345,8 @@ var FISERV_KEY_PINS = /* @__PURE__ */ deepFreeze([
|
|
|
341
345
|
// The sandbox merchant the key was generated under, which every Wave 0
|
|
342
346
|
// capture named.
|
|
343
347
|
merchantIds: ["100008000003683"],
|
|
348
|
+
// No merchant's checkout: the sandbox proof pays on Agentcard's own fixture page.
|
|
349
|
+
checkoutOrigins: [],
|
|
344
350
|
keyId: "77eba5e58f007456ce2c35527bec2877",
|
|
345
351
|
spki: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqbsaa0wpsHUuNIAr5LVYAbID77PB4d0qYnaIsTFGa0JZMIj/egbfdkl4DCaEhV3dzRDMivr+EB5643Xut00lT+SoPonc0Hps+Z5ejcVIZrtIvx/kSxJEqYK70HZHxJewh6P5qFUb+2ZPLSWQQpMqNMpDQhlISt3XtnO1JWmTvCUrjs4PKyVbexIq7+Di36HzwAnatSRP+mfgBnRsXnFmF/oOZKijsCYswqfomIom8eb9kpU1mVuSCPXmxivPOXPdFARFGd23PhdHpLhx0E7OIXpm2xEDmizeit56KVrP4PUHT08tZ4x26cSj7Po1oFpJ4XtsjSrXxmJCdE/LQFIZUwIDAQAB",
|
|
346
352
|
spkiSha256: "7a62942573e251eeffa856ce6f307d8684aad39eec43e9eb48badb450619296a",
|
|
@@ -371,6 +377,15 @@ function fiservKeyRefusal(keyId, environment, nowMs) {
|
|
|
371
377
|
function fiservPinServesMerchant(entry, merchantId) {
|
|
372
378
|
return !!entry && Array.isArray(entry.merchantIds) && typeof merchantId === "string" && entry.merchantIds.includes(merchantId);
|
|
373
379
|
}
|
|
380
|
+
function fiservMerchantPins(merchantId, environment) {
|
|
381
|
+
return FISERV_KEY_PINS.filter((entry) => (environment === null || entry.environment === environment) && fiservPinServesMerchant(entry, merchantId));
|
|
382
|
+
}
|
|
383
|
+
function fiservCheckoutHost(pinId, origin) {
|
|
384
|
+
const entry = typeof pinId === "string" ? FISERV_KEY_PINS.find((pin2) => pin2.id === pinId) : null;
|
|
385
|
+
if (!entry || typeof origin !== "string" || !entry.checkoutOrigins.includes(origin))
|
|
386
|
+
return null;
|
|
387
|
+
return new URL(origin).host;
|
|
388
|
+
}
|
|
374
389
|
function pinnedSpki(entry) {
|
|
375
390
|
const der = entry && typeof entry.spki === "string" ? decodeBase64(entry.spki) : null;
|
|
376
391
|
return der && sha256Hex(der) === entry.spkiSha256 ? der : null;
|
|
@@ -512,6 +527,7 @@ var decodedLength = (value, min, max) => {
|
|
|
512
527
|
};
|
|
513
528
|
var IDENTIFIER = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
514
529
|
var KEY_ID = /^[A-Za-z0-9][A-Za-z0-9-]{7,63}$/;
|
|
530
|
+
var SESSION_KEY_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
515
531
|
var BODY_LIMIT = 65536;
|
|
516
532
|
var TOP_LEVEL = ["source", "merchantDetails", "transactionDetails", "billingAddress"];
|
|
517
533
|
var ENVELOPE = ["keyId", "encryptedKey", "encryptionBlock", "aesIv", "aesTagLength", "encryptionType", "encryptionTarget"];
|
|
@@ -696,10 +712,6 @@ function isNonCardCapture(body) {
|
|
|
696
712
|
function isFiservPausableBody(body) {
|
|
697
713
|
return !isNonCardCapture(body);
|
|
698
714
|
}
|
|
699
|
-
function fiservTemplateKeyId(body) {
|
|
700
|
-
const parsed = readCaptureBody(body);
|
|
701
|
-
return parsed && captureBodyRefusal(parsed) === null ? parsed.source.encryptionData.keyId : null;
|
|
702
|
-
}
|
|
703
715
|
function fiservCaptureMerchant(body) {
|
|
704
716
|
const parsed = readCaptureBody(body);
|
|
705
717
|
if (!parsed || captureBodyRefusal(parsed) !== null)
|
|
@@ -719,12 +731,24 @@ function capturePin(capture) {
|
|
|
719
731
|
const refusal = captureBodyRefusal(body);
|
|
720
732
|
if (refusal)
|
|
721
733
|
return { refusal };
|
|
722
|
-
const
|
|
723
|
-
|
|
734
|
+
const { keyId } = body.source.encryptionData;
|
|
735
|
+
const { merchantId } = body.merchantDetails;
|
|
736
|
+
const pinned = fiservKeyPin(keyId, environment);
|
|
737
|
+
if (pinned)
|
|
738
|
+
return fiservPinServesMerchant(pinned, merchantId) ? { pin: pinned, environment } : { refusal: "fiserv_key_merchant_unlisted" };
|
|
739
|
+
if (!SESSION_KEY_ID.test(keyId))
|
|
724
740
|
return { refusal: "fiserv_key_unpinned" };
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
741
|
+
const pins = fiservMerchantPins(merchantId, environment);
|
|
742
|
+
return pins.length === 1 ? { pin: pins[0], environment } : { refusal: "fiserv_key_merchant_unlisted" };
|
|
743
|
+
}
|
|
744
|
+
function sealingKeyId(body, environment) {
|
|
745
|
+
const { keyId } = body.source.encryptionData;
|
|
746
|
+
if (isFiservPinnedKeyId(keyId) || !SESSION_KEY_ID.test(keyId))
|
|
747
|
+
return keyId;
|
|
748
|
+
if (!environment)
|
|
749
|
+
return null;
|
|
750
|
+
const pins = fiservMerchantPins(body.merchantDetails.merchantId, environment);
|
|
751
|
+
return pins.length === 1 ? pins[0].keyId : null;
|
|
728
752
|
}
|
|
729
753
|
function fiservCapturePin(capture) {
|
|
730
754
|
return capturePin(capture).pin ?? null;
|
|
@@ -808,7 +832,7 @@ function fiservSubstitutions(envelope) {
|
|
|
808
832
|
return { encoding: "json", at: FISERV_SUBSTITUTION.at, fields };
|
|
809
833
|
}
|
|
810
834
|
var SUBSTITUTION_MEMBERS = ["encoding", "at", "fields", "remove"];
|
|
811
|
-
function substituteFiservEnvelope(body, sub) {
|
|
835
|
+
function substituteFiservEnvelope(body, sub, url = null) {
|
|
812
836
|
if (!isPlainObject(sub) || !onlyKeys(sub, SUBSTITUTION_MEMBERS) || sub.encoding !== "json" || sub.at !== FISERV_SUBSTITUTION.at || own3(sub, "remove") && !(Array.isArray(sub.remove) && sub.remove.length === 0)) {
|
|
813
837
|
throw new Error("Refusing to substitute: not a Fiserv envelope substitution.");
|
|
814
838
|
}
|
|
@@ -820,11 +844,17 @@ function substituteFiservEnvelope(body, sub) {
|
|
|
820
844
|
const bodyRefusal = parsed ? captureBodyRefusal(parsed) : "fiserv_body_invalid";
|
|
821
845
|
if (bodyRefusal)
|
|
822
846
|
throw new Error(`Refusing to substitute: ${bodyRefusal}.`);
|
|
823
|
-
const
|
|
824
|
-
if (
|
|
847
|
+
const environment = url === null ? null : fiservEnvironment(url) ?? null;
|
|
848
|
+
if (url !== null && !environment)
|
|
849
|
+
throw new Error("Refusing to substitute: the paused capture is not on a Fiserv card-capture endpoint.");
|
|
850
|
+
if (!environment && SESSION_KEY_ID.test(parsed.source.encryptionData.keyId)) {
|
|
851
|
+
throw new Error("Refusing to substitute: a credentials session's key is written over only with the capture's own URL.");
|
|
852
|
+
}
|
|
853
|
+
if (sealingKeyId(parsed, environment) !== fields.keyId)
|
|
825
854
|
throw new Error("Refusing to substitute: the envelope names another key than the paused capture.");
|
|
855
|
+
const envelope = parsed.source.encryptionData;
|
|
826
856
|
for (const name of FISERV_SUBSTITUTION.fields)
|
|
827
857
|
envelope[name] = fields[name];
|
|
828
858
|
return JSON.stringify(parsed);
|
|
829
859
|
}
|
|
830
|
-
export { FISERV_CARD_CAPTURE_ENDPOINTS, FISERV_ENVELOPE_CONSTANTS, FISERV_KEY_PINS, FISERV_SIMULATOR_PANS, FISERV_SUBSTITUTION, encryptFiservCard, fiservApprovedEnvelopeRefusal, fiservCaptureCardMismatch, fiservCaptureKeyRefusal, fiservCaptureMerchant, fiservCapturePin, fiservCardCaptureRefusal, fiservEnvironment, fiservErrorIdentifiers, fiservKeyPin, fiservKeyRefusal, fiservPreparationUrl, fiservPublishedKeyRefusal, fiservSubstitutionFieldsRefusal, fiservSubstitutions,
|
|
860
|
+
export { FISERV_CARD_CAPTURE_ENDPOINTS, FISERV_ENVELOPE_CONSTANTS, FISERV_KEY_PINS, FISERV_SIMULATOR_PANS, FISERV_SUBSTITUTION, encryptFiservCard, fiservApprovedEnvelopeRefusal, fiservCaptureCardMismatch, fiservCaptureKeyRefusal, fiservCaptureMerchant, fiservCapturePin, fiservCardCaptureRefusal, fiservCheckoutHost, fiservEnvironment, fiservErrorIdentifiers, fiservKeyPin, fiservKeyRefusal, fiservPreparationUrl, fiservPublishedKeyRefusal, fiservSubstitutionFieldsRefusal, fiservSubstitutions, fiservTimestampMs, isFiservCardCaptureRequest, isFiservCardCaptureUrl, isFiservPausableBody, isFiservPinnedKeyId, isPreparedFiservRequest, parseFiservPublishedKey, sanitizeFiservCaptureResponse, substituteFiservEnvelope };
|
package/dist/fiserv.js
CHANGED
|
@@ -36,8 +36,9 @@ export function fiservKeyPinById(id) {
|
|
|
36
36
|
return typeof id === 'string' ? core.FISERV_KEY_PINS.find((pin) => pin.id === id) ?? null : null;
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
39
|
-
* The id of the pin a paused capture's card may be sealed under (its envelope's key,
|
|
40
|
-
*
|
|
39
|
+
* The id of the pin a paused capture's card may be sealed under (its envelope's key or,
|
|
40
|
+
* for a credentials session's key, the key pinned for the merchant its body names; for its
|
|
41
|
+
* endpoint's environment and that merchant), or null.
|
|
41
42
|
*/
|
|
42
43
|
export function fiservCapturePinId(url, body) {
|
|
43
44
|
return core.fiservCapturePin({ url, body })?.id ?? null;
|
|
@@ -96,9 +97,12 @@ export function isFiservSubstitution(sub) {
|
|
|
96
97
|
* The paused Fiserv capture with the approval's envelope written over the four members
|
|
97
98
|
* its source.encryptionData already carries, and every other byte the frame's own. It
|
|
98
99
|
* throws, writing nothing, for a body that is not the capture Agentcard covers, for any
|
|
99
|
-
* substitution but Fiserv's envelope, and for an envelope under another key than the
|
|
100
|
-
*
|
|
100
|
+
* substitution but Fiserv's envelope, and for an envelope under another key than the
|
|
101
|
+
* paused capture's card goes under: the key it names or, when it names a credentials
|
|
102
|
+
* session's key, the key pinned for its merchant on the endpoint `url` names (the paused
|
|
103
|
+
* capture's own URL, which a session's key requires), whose id then replaces the session's.
|
|
104
|
+
* Run this on a Fiserv approval, never substituteEncryptedFields.
|
|
101
105
|
*/
|
|
102
|
-
export function substituteFiservEnvelope(body, sub) {
|
|
103
|
-
return core.substituteFiservEnvelope(body, sub);
|
|
106
|
+
export function substituteFiservEnvelope(body, sub, url) {
|
|
107
|
+
return core.substituteFiservEnvelope(body, sub, url ?? null);
|
|
104
108
|
}
|
package/dist/payrails.d.ts
CHANGED
|
@@ -3,24 +3,30 @@ export { PAYRAILS_CAPABILITY, PAYRAILS_PSP };
|
|
|
3
3
|
/**
|
|
4
4
|
* How the pre-claim gate reads a POST to a Payrails host: `card` for a card save on a save URL
|
|
5
5
|
* (data.encryptedData present, payment-core's pause predicate), `card_payment` for a payment that
|
|
6
|
-
* carries an encrypted card inside paymentComposition,
|
|
6
|
+
* carries an encrypted card inside paymentComposition, the card form's included, and null for
|
|
7
|
+
* anything else, which continues.
|
|
7
8
|
*/
|
|
8
9
|
export declare function payrailsRequestKind(url: string, method: string, body: string): 'card' | 'card_payment' | null;
|
|
10
|
+
/** Whether `url` is exactly a payment-acceptance execution's authorize link on a Payrails API host, where a card-form payment may pause. */
|
|
11
|
+
export declare function isPayrailsPaymentUrl(url: string): boolean;
|
|
9
12
|
/**
|
|
10
13
|
* Why a Payrails request was aborted, reported as the `reason` of the `unsupported_checkout` event:
|
|
11
14
|
* unsupported_payrails_card_payment a payment that sends an encrypted card inside
|
|
12
|
-
* paymentComposition
|
|
15
|
+
* paymentComposition in a shape this build does not take
|
|
16
|
+
* over; the attachment holds
|
|
13
17
|
* payrails_request_malformed, payrails_not_card_save, payrails_jwe_malformed,
|
|
14
18
|
* payrails_future_usage_refused, payrails_card_on_file_consent_required
|
|
15
|
-
* a card save payment-core's guard
|
|
16
|
-
*
|
|
19
|
+
* a card save or card-form payment payment-core's guard
|
|
20
|
+
* refuses; the attachment holds
|
|
21
|
+
* payrails_session_unavailable no captured session matches the save or payment; that
|
|
22
|
+
* request only
|
|
17
23
|
* payrails_key_invalid, payrails_key_mismatch
|
|
18
24
|
* the captured key cannot be the frame's; that request only
|
|
19
25
|
*/
|
|
20
26
|
export type PayrailsUnsupportedReason = 'unsupported_payrails_card_payment' | 'payrails_request_malformed' | 'payrails_not_card_save' | 'payrails_jwe_malformed' | 'payrails_future_usage_refused' | 'payrails_card_on_file_consent_required' | 'payrails_session_unavailable' | 'payrails_key_invalid' | 'payrails_key_mismatch';
|
|
21
|
-
/** Refusals of the
|
|
27
|
+
/** Refusals of the request's own shape: the page's next one would be the same, so the attachment holds. */
|
|
22
28
|
export declare const PAYRAILS_HOLDING_REASONS: readonly PayrailsUnsupportedReason[];
|
|
23
|
-
/** What the agent reads when a
|
|
29
|
+
/** What the agent reads when a card request's session cannot be bound. Not shown to the cardholder. */
|
|
24
30
|
export declare const PAYRAILS_SESSION_MESSAGE = "Payrails session expired, reload the checkout";
|
|
25
31
|
/** Captured sessions kept per attachment; the oldest is dropped first. */
|
|
26
32
|
export declare const PAYRAILS_CAPTURE_LIMIT = 8;
|
|
@@ -34,29 +40,50 @@ export declare const PAYRAILS_INIT_BODY_LIMIT: number;
|
|
|
34
40
|
export declare const PAYRAILS_PENDING_READ_MS = 1000;
|
|
35
41
|
/** Fetch interception patterns for every Payrails host, armed only for an org the API served Payrails to. */
|
|
36
42
|
export declare const PAYRAILS_GUARD_PATTERNS: readonly string[];
|
|
37
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* One captured Payrails session: the init payload's binding fields and its key. Never logged.
|
|
45
|
+
* `executionId` is the payment-acceptance execution the payload carries (data.execution.id), or null
|
|
46
|
+
* when it carries none, and then no card-form payment binds to the session.
|
|
47
|
+
*/
|
|
38
48
|
export interface PayrailsSession {
|
|
39
49
|
readonly token: string;
|
|
40
50
|
readonly holderReference: string;
|
|
41
51
|
readonly providerConfigId: string;
|
|
42
52
|
readonly saveInstrumentHref: string;
|
|
53
|
+
readonly executionId: string | null;
|
|
43
54
|
readonly encryptionPublicKey: string;
|
|
44
55
|
readonly seenAt: number;
|
|
45
56
|
}
|
|
46
57
|
type SessionFields = Omit<PayrailsSession, 'seenAt'>;
|
|
47
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* What the create carries beside a Payrails card request: the session key its page encrypted under,
|
|
60
|
+
* and for a card-form payment the session's holderReference, which the payment's JWE carries.
|
|
61
|
+
*/
|
|
48
62
|
export interface PayrailsSidecar {
|
|
49
63
|
readonly encryption_public_key: string;
|
|
64
|
+
readonly holder_reference?: string;
|
|
50
65
|
}
|
|
66
|
+
/** How deep inside an answer an init payload is looked for, and how many of its objects at most. */
|
|
67
|
+
export declare const PAYRAILS_INIT_SEARCH_DEPTH = 8;
|
|
68
|
+
export declare const PAYRAILS_INIT_SEARCH_NODES = 4096;
|
|
51
69
|
/**
|
|
52
|
-
* Every Payrails init payload one JSON answer body carries: the body itself, or
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
70
|
+
* Every Payrails init payload one JSON answer body carries: the body itself, or any object or array
|
|
71
|
+
* item inside it at most PAYRAILS_INIT_SEARCH_DEPTH levels down, read breadth first over at most
|
|
72
|
+
* PAYRAILS_INIT_SEARCH_NODES of them. Blacklane's session answer is the payload itself; FlixBus's
|
|
73
|
+
* /payment/configuration/list carries it six levels down
|
|
74
|
+
* (options.initialState.selection.paymentMethods[i].paymentToken). An init payload is
|
|
75
|
+
* `{version, data}` whose `data` decodes to JSON with a token, a holderReference and a
|
|
76
|
+
* vaultConfiguration naming its providerConfigId, its encryptionPublicKey and a saveInstrument href
|
|
77
|
+
* on a Payrails save URL; nothing inside one is read further.
|
|
56
78
|
*/
|
|
57
79
|
export declare function payrailsInitSessions(body: unknown): SessionFields[];
|
|
58
80
|
/** Whether an answer may carry an init payload worth reading: a 2xx XHR or fetch with a JSON type. */
|
|
59
81
|
export declare function payrailsInitCandidate(resourceType: unknown, status: unknown, contentType: unknown): boolean;
|
|
82
|
+
/** The key and holderReference a paused Payrails card request binds to. */
|
|
83
|
+
export interface PayrailsBinding {
|
|
84
|
+
readonly key: string;
|
|
85
|
+
readonly holderReference: string;
|
|
86
|
+
}
|
|
60
87
|
/**
|
|
61
88
|
* The Payrails sessions one attachment has seen, in memory only: at most PAYRAILS_CAPTURE_LIMIT,
|
|
62
89
|
* each dropped PAYRAILS_CAPTURE_TTL_MS after it was first seen. Nothing here is ever logged or
|
|
@@ -83,13 +110,27 @@ export declare class PayrailsSessionCapture {
|
|
|
83
110
|
* The session key for a paused card save: the key of the captured session whose token is the
|
|
84
111
|
* save's bearer token, whose saveInstrument href is the save's URL, and whose holderReference and
|
|
85
112
|
* providerConfigId are the body's, first seen at most PAYRAILS_SESSION_MAX_AGE_MS before `now`.
|
|
86
|
-
* Null when none matches, or when matching sessions disagree on the key.
|
|
113
|
+
* Null when none matches, or when matching sessions disagree on the key. bind() reads a card-form
|
|
114
|
+
* payment too.
|
|
87
115
|
*/
|
|
88
116
|
keyFor(request: {
|
|
89
117
|
url: string;
|
|
90
118
|
headers?: Record<string, string>;
|
|
91
119
|
body: string | null;
|
|
92
120
|
}, now?: number): string | null;
|
|
121
|
+
/**
|
|
122
|
+
* The session a paused card request binds to: its key and holderReference. A save binds as keyFor
|
|
123
|
+
* says. A card-form payment binds to the captured session whose token is the payment's bearer
|
|
124
|
+
* token, whose execution is the one the authorize link names, whose saveInstrument href is on the
|
|
125
|
+
* link's host, and whose providerConfigId is the payment's vaultProviderConfigId, first seen at most
|
|
126
|
+
* PAYRAILS_SESSION_MAX_AGE_MS before `now`. Null when none matches, or when matching sessions
|
|
127
|
+
* disagree on the key or the holderReference.
|
|
128
|
+
*/
|
|
129
|
+
bind(request: {
|
|
130
|
+
url: string;
|
|
131
|
+
headers?: Record<string, string>;
|
|
132
|
+
body: string | null;
|
|
133
|
+
}, now?: number): PayrailsBinding | null;
|
|
93
134
|
/** How many sessions are held; for tests. */
|
|
94
135
|
get size(): number;
|
|
95
136
|
private prune;
|
|
@@ -116,18 +157,37 @@ export declare function isPayrailsStaticHost(rawUrl: string): boolean;
|
|
|
116
157
|
* to, else the refusal code. A guard that throws refuses.
|
|
117
158
|
*/
|
|
118
159
|
export declare function payrailsSaveRefusal(body: string): PayrailsUnsupportedReason | null;
|
|
160
|
+
/**
|
|
161
|
+
* payment-core's judgement of a card-form payment's own shape, before any session is looked up:
|
|
162
|
+
* null when it is the SDK's own payment that pays once, else the reason. A payment that stores the
|
|
163
|
+
* card at the merchant reads as payrails_card_on_file_consent_required, one that sets up a
|
|
164
|
+
* subscription as payrails_future_usage_refused, and a ciphertext of another shape as
|
|
165
|
+
* payrails_jwe_malformed; every other shape (a stored card's CVC, a split or installment payment, a
|
|
166
|
+
* preferred scheme) is one this build does not take over, unsupported_payrails_card_payment. A guard
|
|
167
|
+
* that throws refuses.
|
|
168
|
+
*/
|
|
169
|
+
export declare function payrailsPaymentRefusal(body: string): PayrailsUnsupportedReason | null;
|
|
119
170
|
/**
|
|
120
171
|
* The key check for a bound session: null when the captured key is an RSA-2048, 3072 or 4096 key as
|
|
121
|
-
* long as the key the page's frame wrapped for this save, else the refusal code.
|
|
172
|
+
* long as the key the page's frame wrapped for this save or payment, else the refusal code.
|
|
122
173
|
*/
|
|
123
174
|
export declare function payrailsKeyRefusal(key: string, body: string): PayrailsUnsupportedReason | null;
|
|
124
175
|
/**
|
|
125
|
-
* The only answer the page may receive for an approved Payrails
|
|
126
|
-
* instrument, rebuilt from payment-core's allow-list (the BIN cut to
|
|
127
|
-
*
|
|
176
|
+
* The only answer the page may receive for an approved Payrails card request, by the paused `url`: for
|
|
177
|
+
* a save, Payrails' 201 for a card instrument, rebuilt from payment-core's allow-list (the BIN cut to
|
|
178
|
+
* six digits); for a card-form payment, Payrails' 2xx for the authorize action it accepted, rebuilt to
|
|
179
|
+
* its name, id, time and execution link, which the page's SDK polls for the issuer's answer. That link
|
|
180
|
+
* must be the paused payment's own execution on its own host, or the page would poll another payment's
|
|
181
|
+
* result. Under a JSON content type; null for anything else.
|
|
128
182
|
*/
|
|
183
|
+
export declare function payrailsAnswer(status: number, body: string, url: string): {
|
|
184
|
+
status: number;
|
|
185
|
+
headers: Record<string, string>;
|
|
186
|
+
body: string;
|
|
187
|
+
} | null;
|
|
188
|
+
/** payrailsAnswer for a save. */
|
|
129
189
|
export declare function payrailsSaveAnswer(status: number, body: string): {
|
|
130
|
-
status:
|
|
190
|
+
status: number;
|
|
131
191
|
headers: Record<string, string>;
|
|
132
192
|
body: string;
|
|
133
193
|
} | null;
|
|
@@ -3,6 +3,8 @@ declare var PAYRAILS_CAPABILITY: string;
|
|
|
3
3
|
declare var PAYRAILS_OPERATION: string;
|
|
4
4
|
declare var PAYRAILS_SAVE_PATH: string;
|
|
5
5
|
declare var PAYRAILS_SAVE_HOSTS: readonly string[];
|
|
6
|
+
declare var PAYRAILS_MERCHANT_API_HOST: RegExp;
|
|
7
|
+
declare var PAYRAILS_AUTHORIZE_WORKFLOW: string;
|
|
6
8
|
declare var PAYRAILS_JWE_HEADER: string;
|
|
7
9
|
declare var PAYRAILS_JWE_HEADER_B64: string;
|
|
8
10
|
declare var PAYRAILS_KEY_BITS: readonly number[];
|
|
@@ -25,9 +27,14 @@ declare var PAYRAILS_REFUSALS: Readonly<{
|
|
|
25
27
|
declare function payrailsRefusalMessage(code: any): any;
|
|
26
28
|
declare function base64UrlEncode(bytes: any): string;
|
|
27
29
|
declare function base64UrlDecode(text: any, max: any): Uint8Array<ArrayBuffer> | null;
|
|
30
|
+
declare function isPayrailsApiHost(hostname: any): boolean;
|
|
28
31
|
declare function isPayrailsSaveUrl(url: any, { exact: exact2 }?: {
|
|
29
32
|
exact?: boolean | undefined;
|
|
30
33
|
}): boolean;
|
|
34
|
+
declare function isPayrailsAuthorizeUrl(url: any, { exact: exact2 }?: {
|
|
35
|
+
exact?: boolean | undefined;
|
|
36
|
+
}): boolean;
|
|
37
|
+
declare function payrailsExecutionId(url: any): string | null;
|
|
31
38
|
declare function payrailsJweParts(jwe: any): {
|
|
32
39
|
wrappedKey: Uint8Array<ArrayBuffer>;
|
|
33
40
|
iv: Uint8Array<ArrayBuffer>;
|
|
@@ -38,6 +45,8 @@ declare function payrailsTemplateRefusal(body: any): any;
|
|
|
38
45
|
declare function parsePayrailsSave(body: any): any;
|
|
39
46
|
declare function payrailsKeepsCardFor(save: any): any;
|
|
40
47
|
declare function payrailsCardOnFileRefusal(body: any): any;
|
|
48
|
+
declare function payrailsAuthorizeRefusal(body: any): any;
|
|
49
|
+
declare function parsePayrailsAuthorize(body: any): any;
|
|
41
50
|
declare function classifyPayrailsRequest(url: any, method: any, body: any): "card" | "continue" | null;
|
|
42
51
|
declare function payrailsAuthorizeCarriesCard(url: any, method: any, body: any): boolean;
|
|
43
52
|
declare function payrailsSessionKeyBytes(spki: any): any;
|
|
@@ -54,7 +63,8 @@ declare function payrailsFacts(text: any): {
|
|
|
54
63
|
refusalCode: any;
|
|
55
64
|
};
|
|
56
65
|
declare function sanitizePayrailsResponse(text: any): string;
|
|
57
|
-
declare function
|
|
66
|
+
declare function sanitizePayrailsAuthorizeResponse(text: any, url: any): string;
|
|
67
|
+
declare function payrailsResponseOutcome(status: any, text: any, { card, url }?: {}): {
|
|
58
68
|
outcome: string;
|
|
59
69
|
reason: string;
|
|
60
70
|
code?: undefined;
|
|
@@ -70,4 +80,4 @@ declare function payrailsResponseOutcome(status: any, text: any, { card }?: {}):
|
|
|
70
80
|
reason?: undefined;
|
|
71
81
|
code?: undefined;
|
|
72
82
|
};
|
|
73
|
-
export { PAYRAILS_CAPABILITY, PAYRAILS_CARD_ON_FILE_CONSENTED, PAYRAILS_FUTURE_USAGES, PAYRAILS_JWE_HEADER, PAYRAILS_JWE_HEADER_B64, PAYRAILS_KEY_BITS, PAYRAILS_OPERATION, PAYRAILS_PSP, PAYRAILS_REFUSALS, PAYRAILS_SAVE_HOSTS, PAYRAILS_SAVE_PATH, PAYRAILS_SERVED_CARD_FACTS, PAYRAILS_SESSION_MIN_SECONDS, PAYRAILS_UNUSABLE_STATUSES, PAYRAILS_USABLE_STATUSES, base64UrlDecode, base64UrlEncode, classifyPayrailsRequest, isPayrailsSaveUrl, parsePayrailsSave, payrailsAuthorizeCarriesCard, payrailsCardOnFileRefusal, payrailsFacts, payrailsJweParts, payrailsKeepsCardFor, payrailsRefusalMessage, payrailsResponseOutcome, payrailsSessionKeyBytes, payrailsSessionKeyRefusal, payrailsTemplateRefusal, payrailsTokenClaims, payrailsWorkspacePinRefusal, sanitizePayrailsResponse };
|
|
83
|
+
export { PAYRAILS_AUTHORIZE_WORKFLOW, PAYRAILS_CAPABILITY, PAYRAILS_CARD_ON_FILE_CONSENTED, PAYRAILS_FUTURE_USAGES, PAYRAILS_JWE_HEADER, PAYRAILS_JWE_HEADER_B64, PAYRAILS_KEY_BITS, PAYRAILS_MERCHANT_API_HOST, PAYRAILS_OPERATION, PAYRAILS_PSP, PAYRAILS_REFUSALS, PAYRAILS_SAVE_HOSTS, PAYRAILS_SAVE_PATH, PAYRAILS_SERVED_CARD_FACTS, PAYRAILS_SESSION_MIN_SECONDS, PAYRAILS_UNUSABLE_STATUSES, PAYRAILS_USABLE_STATUSES, base64UrlDecode, base64UrlEncode, classifyPayrailsRequest, isPayrailsApiHost, isPayrailsAuthorizeUrl, isPayrailsSaveUrl, parsePayrailsAuthorize, parsePayrailsSave, payrailsAuthorizeCarriesCard, payrailsAuthorizeRefusal, payrailsCardOnFileRefusal, payrailsExecutionId, payrailsFacts, payrailsJweParts, payrailsKeepsCardFor, payrailsRefusalMessage, payrailsResponseOutcome, payrailsSessionKeyBytes, payrailsSessionKeyRefusal, payrailsTemplateRefusal, payrailsTokenClaims, payrailsWorkspacePinRefusal, sanitizePayrailsAuthorizeResponse, sanitizePayrailsResponse };
|