@agent-cards/sdk 0.22.0 → 0.23.1

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.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * NMI's Hosted Payment Page (formerly eKashu), as this SDK reads it.
3
+ *
4
+ * The merchant's page posts an entry form, top-level, to https://live.ekashu.com/ (test:
5
+ * test.ekashu.com), and NMI answers with its own card page. That entry carries no card, and it
6
+ * is the one request this SDK pauses: the cardholder's device repeats it over the end-to-end TLS
7
+ * relay and fills the card into the page NMI returns to it (payment-core processors/ekashu.js).
8
+ * Everything else the agent's browser posts to NMI carries a card the agent typed: the card page's
9
+ * own post (/index.php) and its 3-D Secure calls (ajax_3d_secure_v2_*.php). This SDK aborts every
10
+ * one of them, so a placeholder card never reaches NMI.
11
+ *
12
+ * The hosts are payment-core's EKASHU_HOSTS; payment-core.test.mjs pins the two lists together.
13
+ */
14
+ export declare const EKASHU_PSP = "ekashu";
15
+ export declare const EKASHU_HOSTS: readonly string[];
16
+ /** Whether this URL is on one of NMI's hosted payment page hosts (https, standard port, no credentials). */
17
+ export declare function isEkashuHost(url: string): boolean;
18
+ /**
19
+ * The only request on NMI's hosts that is the merchant's entry: a POST to the host's root, with no
20
+ * query. The entry the SDK pauses; every other POST there carries a card and is aborted.
21
+ */
22
+ export declare function isEkashuEntry(url: string, method: string): boolean;
23
+ /** The entry URL on the same NMI host as this URL, the one the registry recognizes when this build is armed for NMI. */
24
+ export declare function ekashuEntryUrl(url: string): string | null;
25
+ /**
26
+ * Whether an adapter must hand this request to the pre-claim gates: it is on one of NMI's hosts
27
+ * and this build's registry serves that host's entry. The card page's own post and its 3-D Secure
28
+ * calls are not the entry, so the registry's card-request test (anchored to the entry) does not
29
+ * name them; the CDP adapter still pauses them through the recognizer's host-wide URL patterns,
30
+ * and attachToPlaywright's route predicate asks this, so both adapters show the gates every
31
+ * request to an armed NMI host.
32
+ */
33
+ export declare function isArmedEkashuUrl(vault: {
34
+ isCardRequest(url: string, method?: string): boolean;
35
+ }, url: string): boolean;
package/dist/ekashu.js ADDED
@@ -0,0 +1,55 @@
1
+ /**
2
+ * NMI's Hosted Payment Page (formerly eKashu), as this SDK reads it.
3
+ *
4
+ * The merchant's page posts an entry form, top-level, to https://live.ekashu.com/ (test:
5
+ * test.ekashu.com), and NMI answers with its own card page. That entry carries no card, and it
6
+ * is the one request this SDK pauses: the cardholder's device repeats it over the end-to-end TLS
7
+ * relay and fills the card into the page NMI returns to it (payment-core processors/ekashu.js).
8
+ * Everything else the agent's browser posts to NMI carries a card the agent typed: the card page's
9
+ * own post (/index.php) and its 3-D Secure calls (ajax_3d_secure_v2_*.php). This SDK aborts every
10
+ * one of them, so a placeholder card never reaches NMI.
11
+ *
12
+ * The hosts are payment-core's EKASHU_HOSTS; payment-core.test.mjs pins the two lists together.
13
+ */
14
+ export const EKASHU_PSP = 'ekashu';
15
+ export const EKASHU_HOSTS = Object.freeze(['live.ekashu.com', 'test.ekashu.com']);
16
+ /** Whether this URL is on one of NMI's hosted payment page hosts (https, standard port, no credentials). */
17
+ export function isEkashuHost(url) {
18
+ let parsed;
19
+ try {
20
+ parsed = new URL(url);
21
+ }
22
+ catch {
23
+ return false;
24
+ }
25
+ return parsed.protocol === 'https:' && !parsed.port && !parsed.username && !parsed.password
26
+ && EKASHU_HOSTS.includes(parsed.hostname.toLowerCase());
27
+ }
28
+ /**
29
+ * The only request on NMI's hosts that is the merchant's entry: a POST to the host's root, with no
30
+ * query. The entry the SDK pauses; every other POST there carries a card and is aborted.
31
+ */
32
+ export function isEkashuEntry(url, method) {
33
+ if (String(method).toUpperCase() !== 'POST' || !isEkashuHost(url))
34
+ return false;
35
+ const parsed = new URL(url);
36
+ return parsed.pathname === '/' && !parsed.search && !parsed.hash;
37
+ }
38
+ /** The entry URL on the same NMI host as this URL, the one the registry recognizes when this build is armed for NMI. */
39
+ export function ekashuEntryUrl(url) {
40
+ if (!isEkashuHost(url))
41
+ return null;
42
+ return `https://${new URL(url).hostname.toLowerCase()}/`;
43
+ }
44
+ /**
45
+ * Whether an adapter must hand this request to the pre-claim gates: it is on one of NMI's hosts
46
+ * and this build's registry serves that host's entry. The card page's own post and its 3-D Secure
47
+ * calls are not the entry, so the registry's card-request test (anchored to the entry) does not
48
+ * name them; the CDP adapter still pauses them through the recognizer's host-wide URL patterns,
49
+ * and attachToPlaywright's route predicate asks this, so both adapters show the gates every
50
+ * request to an armed NMI host.
51
+ */
52
+ export function isArmedEkashuUrl(vault, url) {
53
+ const entry = ekashuEntryUrl(url);
54
+ return entry !== null && vault.isCardRequest(entry, 'POST');
55
+ }
@@ -217,15 +217,18 @@ export declare class CheckoutLifecycle implements CheckoutController {
217
217
  * cybersource-flex.ts), a Juspay card request that is not the reviewed
218
218
  * payment (juspay_request_unsupported, juspay-gate.ts), such as save card,
219
219
  * EMI, a direct card or a sibling host, a reviewed merchant card endpoint
220
- * this build does not pay (merchant_card_endpoint_not_enabled), a CreditGuard
220
+ * this build does not pay (merchant_card_endpoint_not_enabled), a request that
221
+ * sends the typed card to such a merchant again outside its card request
222
+ * (merchant_card_endpoint_resend_refused), a CreditGuard
221
223
  * page that runs its own 3-D Secure (creditguard_three_d_secure), a
222
224
  * recognized Primer request in a form its gate refuses (unsupported_primer_sdk,
223
225
  * unsupported_primer_request), a Payrails request its gate refuses
224
- * (`unsupported_payrails_card_payment` and the card-save refusal codes), or a
226
+ * (`unsupported_payrails_card_payment` and the card-save refusal codes), a
225
227
  * Shiji STS request its gate refuses (shiji_sts_keep_on_file and the other
226
- * shiji-sts.ts reasons).
228
+ * shiji-sts.ts reasons), or a post to a processor's own card page that only
229
+ * the cardholder's device can fill (processor_card_page: NMI's).
227
230
  */
228
- unsupported(reason?: 'unrecognized_payment_endpoint' | 'merchant_profile_observe' | 'merchant_request_unsupported' | GmoUnsupportedReason | 'microform_unsupported' | 'juspay_request_unsupported' | 'merchant_card_endpoint_not_enabled' | 'creditguard_three_d_secure' | 'unsupported_primer_sdk' | 'unsupported_primer_request' | PayrailsUnsupportedReason | ShijiStsUnsupportedReason): void;
231
+ unsupported(reason?: 'unrecognized_payment_endpoint' | 'merchant_profile_observe' | 'merchant_request_unsupported' | GmoUnsupportedReason | 'microform_unsupported' | 'juspay_request_unsupported' | 'merchant_card_endpoint_not_enabled' | 'merchant_card_endpoint_resend_refused' | 'creditguard_three_d_secure' | 'unsupported_primer_sdk' | 'unsupported_primer_request' | PayrailsUnsupportedReason | ShijiStsUnsupportedReason | 'processor_card_page'): void;
229
232
  /**
230
233
  * A card request that only a prepared checkout pays (an Adyen merchant
231
234
  * profile's, or a Fiserv card capture) arrived with no preparation on this
package/dist/lifecycle.js CHANGED
@@ -193,13 +193,16 @@ export class CheckoutLifecycle {
193
193
  * cybersource-flex.ts), a Juspay card request that is not the reviewed
194
194
  * payment (juspay_request_unsupported, juspay-gate.ts), such as save card,
195
195
  * EMI, a direct card or a sibling host, a reviewed merchant card endpoint
196
- * this build does not pay (merchant_card_endpoint_not_enabled), a CreditGuard
196
+ * this build does not pay (merchant_card_endpoint_not_enabled), a request that
197
+ * sends the typed card to such a merchant again outside its card request
198
+ * (merchant_card_endpoint_resend_refused), a CreditGuard
197
199
  * page that runs its own 3-D Secure (creditguard_three_d_secure), a
198
200
  * recognized Primer request in a form its gate refuses (unsupported_primer_sdk,
199
201
  * unsupported_primer_request), a Payrails request its gate refuses
200
- * (`unsupported_payrails_card_payment` and the card-save refusal codes), or a
202
+ * (`unsupported_payrails_card_payment` and the card-save refusal codes), a
201
203
  * Shiji STS request its gate refuses (shiji_sts_keep_on_file and the other
202
- * shiji-sts.ts reasons).
204
+ * shiji-sts.ts reasons), or a post to a processor's own card page that only
205
+ * the cardholder's device can fill (processor_card_page: NMI's).
203
206
  */
204
207
  unsupported(reason = 'unrecognized_payment_endpoint') {
205
208
  this.held = true;
@@ -6,6 +6,7 @@ declare var SubstitutionError: {
6
6
  cause?: unknown;
7
7
  };
8
8
  };
9
+ declare var HILTON_CREATE_RESERVATION_DOCUMENTS: readonly string[];
9
10
  declare var MERCHANT_CARD_ENDPOINT_PSP: string;
10
11
  declare var MERCHANT_CARD_ENDPOINT_MODE: string;
11
12
  declare var MERCHANT_CARD_ENDPOINT_PROFILES: any;
@@ -15,6 +16,31 @@ declare function merchantCardEndpointById(id: any): any;
15
16
  declare function trustedMerchantCardEndpoint(idOrEntry: any): any;
16
17
  declare function merchantCardEndpointRecognizerById(id: any): any;
17
18
  declare function merchantCardEndpointLive(idOrEntry: any): boolean;
19
+ declare var MERCHANT_CARD_ENDPOINT_FACTS_TEXT_MAX: number;
20
+ declare var MERCHANT_CARD_ENDPOINT_FACT_READERS: readonly string[];
21
+ declare function merchantCardEndpointFactsRole(profile: any, cardUrl: any, exchange: any): "card" | "record" | "unread" | "inert" | null;
22
+ declare function projectMerchantCardEndpointFacts(profile: any, cardUrl: any, exchange: any): {
23
+ none: boolean;
24
+ refusal?: undefined;
25
+ record?: undefined;
26
+ } | {
27
+ refusal: any;
28
+ none?: undefined;
29
+ record?: undefined;
30
+ } | {
31
+ record: {
32
+ method: any;
33
+ url: any;
34
+ state: any;
35
+ };
36
+ none?: undefined;
37
+ refusal?: undefined;
38
+ };
39
+ declare function readMerchantCardEndpointFacts(profile: any, cardUrl: any, record: any): any;
40
+ declare function merchantCardEndpointFactsRefusal(profile: any, facts: any, agent: any): {
41
+ code: any;
42
+ reason: any;
43
+ } | null;
18
44
  declare var MERCHANT_CARD_ENDPOINT_LIMITS: Readonly<{
19
45
  bodyBytes: number;
20
46
  answerBytes: number;
@@ -23,7 +49,10 @@ declare var MERCHANT_CARD_ENDPOINT_LIMITS: Readonly<{
23
49
  headerBytes: number;
24
50
  cookies: 64;
25
51
  }>;
52
+ declare function merchantCardEndpointRequestOrigin(profile: any): any;
26
53
  declare function merchantCardEndpointBodyRefusal(profile: any, body: any, contentType: any): string | null;
54
+ declare function merchantCardEndpointPasses(profile: any, body: any, contentType: any): boolean;
55
+ declare function merchantCardEndpointSessionTtl(profile: any, body: any, contentType: any): any;
27
56
  declare function merchantCardEndpointAmount(profile: any, body: any, contentType: any): {
28
57
  amountCents: null;
29
58
  currency: any;
@@ -31,13 +60,18 @@ declare function merchantCardEndpointAmount(profile: any, body: any, contentType
31
60
  amountCents: number;
32
61
  currency: any;
33
62
  };
63
+ declare function merchantCardEndpointCarriesCard(profile: any, body: any, contentType: any): any;
34
64
  declare function merchantCardEndpointMatches(profile: any, rawUrl: any, method: any, opts: any): boolean;
35
65
  declare function matchMerchantCardEndpoint(rawUrl: any, method: any, opts: any): any;
66
+ declare function matchMerchantCardEndpointResend(rawUrl: any, method: any): any;
36
67
  declare function assertMerchantCardEndpoint(authorization: any): URL & {
37
68
  profile: any;
38
69
  };
39
70
  declare function merchantCardEndpointSessionRefusal(profile: any, bundle: any): string | null;
71
+ declare function merchantCardEndpointCheckoutKey(profile: any, bundle: any): string | null;
72
+ declare function merchantCardEndpointEncrypts(profile: any): boolean;
40
73
  declare function substituteMerchantCardEndpoint(body: any, contentType: any, profile: any, card: any): any;
74
+ declare function encryptMerchantCardEndpointBody(body: any, contentType: any, profile: any, card: any, crypto: any): Promise<any>;
41
75
  declare function merchantEndpointRequest(profile: any, bundle: any, card: any): {
42
76
  url: any;
43
77
  method: any;
@@ -46,7 +80,16 @@ declare function merchantEndpointRequest(profile: any, bundle: any, card: any):
46
80
  };
47
81
  body: any;
48
82
  };
83
+ declare function encryptedMerchantEndpointRequest(profile: any, bundle: any, card: any, crypto: any): Promise<{
84
+ url: any;
85
+ method: any;
86
+ headers: {
87
+ "content-type": any;
88
+ };
89
+ body: any;
90
+ }>;
49
91
  declare function responseCardLeak(card: any, response: any): "card_in_response" | "unreadable_in_response" | null;
92
+ declare function merchantCardEndpointAnswerRefusal(profile: any, bodyText: any): "refused_step_in_response" | null;
50
93
  declare function merchantCardEndpointAnswer(profile: any, response: any, card: any): {
51
94
  status: any;
52
95
  withheld: string;
@@ -60,4 +103,20 @@ declare function merchantCardEndpointAnswer(profile: any, response: any, card: a
60
103
  bodyText: any;
61
104
  withheld?: undefined;
62
105
  };
63
- export { MERCHANT_CARD_ENDPOINT_CLIENT_TABLE, MERCHANT_CARD_ENDPOINT_LIMITS, MERCHANT_CARD_ENDPOINT_MODE, MERCHANT_CARD_ENDPOINT_PROFILES, MERCHANT_CARD_ENDPOINT_PSP, MERCHANT_CARD_ENDPOINT_RECOGNIZERS, SubstitutionError, assertMerchantCardEndpoint, matchMerchantCardEndpoint, merchantCardEndpointAmount, merchantCardEndpointAnswer, merchantCardEndpointBodyRefusal, merchantCardEndpointById, merchantCardEndpointLive, merchantCardEndpointMatches, merchantCardEndpointRecognizerById, merchantCardEndpointSessionRefusal, merchantEndpointRequest, responseCardLeak, substituteMerchantCardEndpoint, trustedMerchantCardEndpoint };
106
+ declare function merchantCardEndpointNavigationAnswer(profile: any, answer: any, requestUrl: any): {
107
+ kind: string;
108
+ reason?: undefined;
109
+ status?: undefined;
110
+ location?: undefined;
111
+ } | {
112
+ kind: string;
113
+ reason: string;
114
+ status?: undefined;
115
+ location?: undefined;
116
+ } | {
117
+ kind: string;
118
+ status: any;
119
+ location: string;
120
+ reason?: undefined;
121
+ };
122
+ export { HILTON_CREATE_RESERVATION_DOCUMENTS, MERCHANT_CARD_ENDPOINT_CLIENT_TABLE, MERCHANT_CARD_ENDPOINT_FACTS_TEXT_MAX, MERCHANT_CARD_ENDPOINT_FACT_READERS, MERCHANT_CARD_ENDPOINT_LIMITS, MERCHANT_CARD_ENDPOINT_MODE, MERCHANT_CARD_ENDPOINT_PROFILES, MERCHANT_CARD_ENDPOINT_PSP, MERCHANT_CARD_ENDPOINT_RECOGNIZERS, SubstitutionError, assertMerchantCardEndpoint, encryptMerchantCardEndpointBody, encryptedMerchantEndpointRequest, matchMerchantCardEndpoint, matchMerchantCardEndpointResend, merchantCardEndpointAmount, merchantCardEndpointAnswer, merchantCardEndpointAnswerRefusal, merchantCardEndpointBodyRefusal, merchantCardEndpointById, merchantCardEndpointCarriesCard, merchantCardEndpointCheckoutKey, merchantCardEndpointEncrypts, merchantCardEndpointFactsRefusal, merchantCardEndpointFactsRole, merchantCardEndpointLive, merchantCardEndpointMatches, merchantCardEndpointNavigationAnswer, merchantCardEndpointPasses, merchantCardEndpointRecognizerById, merchantCardEndpointRequestOrigin, merchantCardEndpointSessionRefusal, merchantCardEndpointSessionTtl, merchantEndpointRequest, projectMerchantCardEndpointFacts, readMerchantCardEndpointFacts, responseCardLeak, substituteMerchantCardEndpoint, trustedMerchantCardEndpoint };