@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
@@ -1,23 +1,84 @@
1
- export type PreparationProcessor = 'square' | 'braintree' | 'worldpay' | 'bambora' | 'mercado_pago' | 'recurly' | 'spreedly' | 'adyen' | 'checkout_com' | 'paysafe' | 'fiserv' | 'cybersource_flex';
1
+ /**
2
+ * aci: prepared only. ACI's widget gives up on Pay after 60 seconds, too soon for a prompt that
3
+ * waits on a person, so the cardholder approves before the agent clicks Pay. Its environments are
4
+ * its live hosts (production) and its INTEGRATOR_TEST hosts (sandbox).
5
+ *
6
+ * worldpay_eprotect: prepared only. Its merchants give up on the registration 10 to 15 seconds
7
+ * after Pay (5 before the vendor script fails over), too soon for a prompt that waits on a person,
8
+ * so the cardholder approves before the agent clicks Pay. Its environments are its two card hosts:
9
+ * the production primary and the pre-live host (sandbox).
10
+ *
11
+ * amadeus_checkout: prepared only. Its SDK tunnel abandons the add after 30 seconds, too soon
12
+ * for an approval after Pay. Its environments are its hosts: paypages (production) and
13
+ * paypages.test (sandbox).
14
+ */
15
+ export type PreparationProcessor = 'square' | 'braintree' | 'worldpay' | 'bambora' | 'mercado_pago' | 'recurly' | 'spreedly' | 'adyen' | 'checkout_com' | 'paysafe' | 'fiserv' | 'cybersource_flex' | 'aci' | 'creditguard' | 'worldpay_eprotect' | 'amadeus_checkout' | 'verifone';
2
16
  export type PreparationEnvironment = 'production' | 'sandbox' | 'shared';
3
17
  /**
4
18
  * How the approved card reaches the processor: the device's own request (token), or
5
19
  * ciphertext the device produces for this browser to send (cse: Adyen's four encrypted
6
- * fields, or Fiserv's Secure Data Capture envelope under a key Agentcard pinned).
20
+ * fields, Fiserv's Secure Data Capture envelope under a key Agentcard pinned, or a
21
+ * verifone.js blob under one).
7
22
  */
8
23
  export type PreparationMode = 'token' | 'cse';
9
24
  export declare function preparationMode(psp: string): PreparationMode;
25
+ /** The method of the native card request a preparation binds: the registration GET for Worldpay eProtect, a POST for every other processor. */
26
+ export declare function preparationRequestMethod(psp: string): 'GET' | 'POST';
10
27
  /**
11
28
  * Shared endpoint processors cannot attest test/live mode from their URL or key prefix.
12
29
  * Adyen can: test and live are separate hosts and key prefixes. Fiserv's are separate
13
30
  * hosts too: connect (production) and connect-cert (sandbox). So are CyberSource
14
31
  * Flex's: flex.cybersource.com is live, testflex.cybersource.com is test, and each has
15
- * its own signing keys.
32
+ * its own signing keys. A Verifone preparation pays in the environment of the key its reviewed
33
+ * profile pins.
16
34
  */
17
35
  export declare function validPreparationEnvironment(psp: string, environment: string): boolean;
36
+ /**
37
+ * ACI's prepared endpoint, the literal the API names (backend checkout-prepared-processor.ts): its
38
+ * environment's primary widget host and a checkout id that can never be real, since the merchant
39
+ * mints the checkout only at Pay time. The bind matches the card-number request by host
40
+ * environment and shape instead (matchesPreparedRequest).
41
+ */
42
+ export declare function aciPreparationUrl(environment: PreparationEnvironment): string;
43
+ /**
44
+ * A processor whose card request names an id the merchant mints only at Pay time (ACI's checkout
45
+ * id), so no URL can be prepared in advance: whether the adapters can intercept it is asked of the
46
+ * registry (VaultClient.recognizesProcessor), not of the prepared endpoint.
47
+ */
48
+ export declare function preparationBindsByShape(psp: string): boolean;
49
+ /**
50
+ * The endpoint a CreditGuard preparation stands for, per environment, as the API advertises it: the
51
+ * PPS card submit on pps (production) or ppsuat (sandbox) under the nil transaction id. It only
52
+ * proves the synced registry recognizes CreditGuard. A real submit names the txId of the page the
53
+ * preparation framed and may be on pps2, so it is matched by shape (matchesPreparedRequest), never
54
+ * by equality with this URL.
55
+ */
56
+ export declare function creditguardPreparationUrl(environment: 'production' | 'sandbox'): string;
18
57
  export declare function preparationEndpoint(psp: PreparationProcessor, environment: PreparationEnvironment): string;
19
- /** Processor identity and environment are part of the device's prior consent. */
20
- export declare function matchesPreparedRequest(psp: PreparationProcessor, environment: PreparationEnvironment, requestUrl: string, method: string, body?: string | null, headers?: Record<string, string>): boolean;
58
+ /**
59
+ * What a preparation binds beyond its processor and environment. CreditGuard: the merchant page the
60
+ * cardholder approved (the submit's ppDomain names it) and the hosted page the checkout framed (the
61
+ * submit must pay that page's own transaction). Worldpay eProtect: the paypageId naming the Worldpay
62
+ * merchant the registration is for, fixed before its page sent anything. Every other processor
63
+ * ignores all three.
64
+ */
65
+ export interface PreparedRequestBinding {
66
+ merchantOrigin?: string;
67
+ paymentPageUrl?: string;
68
+ paypageId?: string | null;
69
+ }
70
+ /**
71
+ * The approved merchant page's host, with its port if it has one: what the Amadeus SDK sends in its
72
+ * Amadeus-Checkout-Sdk-Host header (location.host). Null for anything but an http(s) origin. The
73
+ * API's twin (checkout-prepared-processor.ts) reads the same value.
74
+ */
75
+ export declare function merchantHostOf(merchantOrigin: string | null | undefined): string | null;
76
+ /**
77
+ * Processor identity and environment are part of the device's prior consent. `binding` carries what
78
+ * the preparation fixed beyond them (PreparedRequestBinding); Amadeus binds its SDK's Host header to
79
+ * `binding.merchantOrigin`, the origin the cardholder approved, and fails without one.
80
+ */
81
+ export declare function matchesPreparedRequest(psp: PreparationProcessor, environment: PreparationEnvironment, requestUrl: string, method: string, body?: string | null, headers?: Record<string, string>, binding?: PreparedRequestBinding): boolean;
21
82
  /**
22
83
  * The one request a merchant-hosted preparation pays: the reviewed profile's
23
84
  * card request itself (classifyMerchantRequest pauses it), at the profile's exact
@@ -34,6 +95,11 @@ export declare function matchesPreparedMerchantRequest(profileId: string, reques
34
95
  * the one its envelope's key is pinned as for its endpoint and merchant, must be that
35
96
  * pin, as the API's bind requires. Two pins in one environment (a merchant's old and new
36
97
  * keys during a rotation) never spend each other's approval. No other processor names one.
98
+ * A CreditGuard preparation binds the merchant page it approved and the page it framed
99
+ * (merchantOrigin, paymentPageUrl), which matchesPreparedRequest holds the submit to.
100
+ * A Worldpay eProtect preparation names the paypageId its registration must carry.
101
+ * An Amadeus preparation binds its SDK's Host header to the page the cardholder approved
102
+ * (merchantOrigin), as the API does.
37
103
  */
38
104
  export declare function matchesPreparation(preparation: {
39
105
  psp: PreparationProcessor;
@@ -42,4 +108,17 @@ export declare function matchesPreparation(preparation: {
42
108
  sandboxDeclaration?: {
43
109
  endpoint: string;
44
110
  };
111
+ merchantOrigin?: string;
112
+ paymentPageUrl?: string;
113
+ paypageId?: string;
45
114
  }, requestUrl: string, method: string, body?: string | null, headers?: Record<string, string>): boolean;
115
+ /**
116
+ * The reason a claim reports for a request its preparation does not match. An Amadeus preparation
117
+ * names what payment-core's Amadeus check refused on its own environment's card URL, as
118
+ * `amadeus_<reason>`: Air France's and KLM's add, whose expiry their own form keeps, is
119
+ * `amadeus_merchant_held_expiry`, every Data Collection Page store is
120
+ * `amadeus_dcp_field_config_unreviewed` until a merchant's field config is reviewed, and a Host
121
+ * header that does not name the approved page is `amadeus_header_binding`. Everything else, another
122
+ * processor's request or the other environment's host included, is `checkout_changed`.
123
+ */
124
+ export declare function preparedRequestRefusal(psp: PreparationProcessor, environment: PreparationEnvironment, requestUrl: string, body?: string | null, headers?: Record<string, string>, merchantOrigin?: string | null): string;
@@ -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
- /** Processor identity and environment are part of the device's prior consent. */
95
- export function matchesPreparedRequest(psp, environment, requestUrl, method, body, headers) {
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
  }
@@ -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 };