@agent-cards/checkout 0.19.0 → 0.21.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/README.md +6 -753
- package/cdp.d.ts +1 -0
- package/cdp.js +2 -0
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +33 -33
- package/playwright.d.ts +1 -0
- package/playwright.js +2 -0
- package/preflight.d.ts +1 -0
- package/preflight.js +2 -0
- package/CHANGELOG.md +0 -132
- package/PREFLIGHT.md +0 -312
- package/dist/adyen-merchant-hosted.generated.d.ts +0 -277
- package/dist/adyen-merchant-hosted.generated.js +0 -1902
- package/dist/adyen.generated.d.ts +0 -24
- package/dist/adyen.generated.js +0 -64
- package/dist/attachment.d.ts +0 -11
- package/dist/attachment.js +0 -50
- package/dist/braintree.d.ts +0 -2
- package/dist/braintree.generated.d.ts +0 -10
- package/dist/braintree.generated.js +0 -302
- package/dist/braintree.js +0 -2
- package/dist/builtin-registry.generated.d.ts +0 -2
- package/dist/builtin-registry.generated.js +0 -1
- package/dist/card-fields.generated.d.ts +0 -3
- package/dist/card-fields.generated.js +0 -46
- package/dist/cdp.d.ts +0 -192
- package/dist/cdp.js +0 -2393
- package/dist/checkout-com.generated.d.ts +0 -4
- package/dist/checkout-com.generated.js +0 -183
- package/dist/client.d.ts +0 -849
- package/dist/client.js +0 -1754
- package/dist/cse-body.d.ts +0 -25
- package/dist/cse-body.js +0 -41
- package/dist/fiserv.d.ts +0 -65
- package/dist/fiserv.generated.d.ts +0 -73
- package/dist/fiserv.generated.js +0 -830
- package/dist/fiserv.js +0 -104
- package/dist/hosted-form.d.ts +0 -44
- package/dist/hosted-form.js +0 -78
- package/dist/index.d.ts +0 -18
- package/dist/index.js +0 -10
- package/dist/lifecycle.d.ts +0 -179
- package/dist/lifecycle.js +0 -395
- package/dist/mercado-checkout.d.ts +0 -20
- package/dist/mercado-checkout.generated.d.ts +0 -52
- package/dist/mercado-checkout.generated.js +0 -198
- package/dist/mercado-checkout.js +0 -108
- package/dist/merchant-handoff.d.ts +0 -54
- package/dist/merchant-handoff.js +0 -100
- package/dist/merchant-hosted.d.ts +0 -140
- package/dist/merchant-hosted.js +0 -170
- package/dist/merchant-total-watch.d.ts +0 -115
- package/dist/merchant-total-watch.js +0 -268
- package/dist/merchant-total.d.ts +0 -257
- package/dist/merchant-total.js +0 -383
- package/dist/owned-shop.generated.d.ts +0 -24
- package/dist/owned-shop.generated.js +0 -108
- package/dist/paysafe.generated.d.ts +0 -12
- package/dist/paysafe.generated.js +0 -87
- package/dist/playwright.d.ts +0 -3
- package/dist/playwright.js +0 -3
- package/dist/pre-claim.d.ts +0 -123
- package/dist/pre-claim.js +0 -386
- package/dist/preflight-capabilities.generated.d.ts +0 -1253
- package/dist/preflight-capabilities.generated.js +0 -1929
- package/dist/preflight-catalog.json +0 -4727
- package/dist/preflight-playwright.d.ts +0 -34
- package/dist/preflight-playwright.js +0 -355
- package/dist/preflight-schemas.json +0 -1122
- package/dist/preflight.d.ts +0 -1
- package/dist/preflight.generated.d.ts +0 -1965
- package/dist/preflight.generated.js +0 -570
- package/dist/preflight.js +0 -2
- package/dist/preparation.d.ts +0 -38
- package/dist/preparation.js +0 -191
- package/dist/prepared-processor.d.ts +0 -43
- package/dist/prepared-processor.js +0 -172
- package/dist/recurly.generated.d.ts +0 -1
- package/dist/recurly.generated.js +0 -87
- package/dist/registry.d.ts +0 -121
- package/dist/registry.js +0 -310
- package/dist/spreedly.generated.d.ts +0 -10
- package/dist/spreedly.generated.js +0 -332
- package/dist/stripe-checkout.d.ts +0 -81
- package/dist/stripe-checkout.generated.d.ts +0 -82
- package/dist/stripe-checkout.generated.js +0 -1093
- package/dist/stripe-checkout.js +0 -140
- package/dist/substitute.d.ts +0 -38
- package/dist/substitute.js +0 -23
- package/dist/substitutions.generated.d.ts +0 -11
- package/dist/substitutions.generated.js +0 -818
- package/examples/existing-browser.mjs +0 -63
- package/examples/preflight/classify-direct.mjs +0 -21
- package/examples/preflight/classify-kernel.mjs +0 -30
- package/examples/preflight/inspect-browser.mjs +0 -44
- package/examples/preflight/kernel-native/README.md +0 -112
- package/examples/preflight/kernel-native/documented-adapters.json +0 -113
- package/examples/preflight/kernel-native/inventory.json +0 -233
- package/examples/preflight/kernel-native/qualification.mjs +0 -182
- package/examples/preflight/kernel-profile.empty.json +0 -11
- package/examples/preflight/mollie-hosted.observations.json +0 -23
- package/examples/preflight/mollie-hosted.result.json +0 -103
- package/examples/preflight/stripe-script.direct.result.json +0 -92
- package/examples/preflight/stripe-script.observations.json +0 -16
- package/examples/preflight/stripe-script.result.json +0 -87
|
@@ -1,332 +0,0 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
|
-
// Generated from @agent-cards/payment-core. Do not edit.
|
|
3
|
-
// artifact-sha256: bd953f414724afdcc2930f895f106fbc908b78875358b33d01c0ee55985b9a29
|
|
4
|
-
// src/spreedly.js
|
|
5
|
-
var SPREEDLY_TOKEN_ENDPOINT = "https://core.spreedly.com/v1/payment_methods/restricted.json";
|
|
6
|
-
var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
7
|
-
var owns = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
8
|
-
var exact = (pattern, value) => typeof value === "string" && pattern.exec(value)?.[0] === value;
|
|
9
|
-
var text = (value, max = 1024) => typeof value === "string" && value.length <= max && !/[\u0000-\u001f\u007f]/.test(value);
|
|
10
|
-
var id = (value) => exact(/^[A-Za-z0-9_-]{1,128}$/, value);
|
|
11
|
-
var keys = (value, allowed) => record(value) && Object.keys(value).every((key) => allowed.includes(key));
|
|
12
|
-
var digits = (value, min, max) => typeof value === "string" && value.length >= min && value.length <= max && !/[^0-9]/.test(value);
|
|
13
|
-
var month = (value) => (Number.isInteger(value) || digits(value, 1, 2)) && Number(value) >= 1 && Number(value) <= 12;
|
|
14
|
-
var year = (value) => (Number.isInteger(value) || digits(value, 2, 4)) && (Number(value) >= 0 && Number(value) <= 99 || Number(value) >= 2e3 && Number(value) <= 9999);
|
|
15
|
-
var CARD_TEXT = [
|
|
16
|
-
"first_name",
|
|
17
|
-
"last_name",
|
|
18
|
-
"full_name",
|
|
19
|
-
"email",
|
|
20
|
-
"address1",
|
|
21
|
-
"address2",
|
|
22
|
-
"city",
|
|
23
|
-
"state",
|
|
24
|
-
"zip",
|
|
25
|
-
"country",
|
|
26
|
-
"phone_number",
|
|
27
|
-
"company",
|
|
28
|
-
"shipping_address1",
|
|
29
|
-
"shipping_address2",
|
|
30
|
-
"shipping_city",
|
|
31
|
-
"shipping_state",
|
|
32
|
-
"shipping_zip",
|
|
33
|
-
"shipping_country",
|
|
34
|
-
"shipping_phone_number"
|
|
35
|
-
];
|
|
36
|
-
var AUTH = ["nonce", "timestamp", "certificate_token", "signature"];
|
|
37
|
-
var CARD_TYPES = /* @__PURE__ */ new Set([
|
|
38
|
-
"visa",
|
|
39
|
-
"master",
|
|
40
|
-
"american_express",
|
|
41
|
-
"diners_club",
|
|
42
|
-
"discover",
|
|
43
|
-
"jcb",
|
|
44
|
-
"maestro",
|
|
45
|
-
"maestro_no_luhn",
|
|
46
|
-
"elo",
|
|
47
|
-
"carnet",
|
|
48
|
-
"dankort",
|
|
49
|
-
"alelo",
|
|
50
|
-
"cabal",
|
|
51
|
-
"naranja",
|
|
52
|
-
"unionpay",
|
|
53
|
-
"alia",
|
|
54
|
-
"creditel",
|
|
55
|
-
"confiable",
|
|
56
|
-
"synchrony",
|
|
57
|
-
"routex",
|
|
58
|
-
"mada",
|
|
59
|
-
"passcard",
|
|
60
|
-
"edenred",
|
|
61
|
-
"anda",
|
|
62
|
-
"tarjeta_d",
|
|
63
|
-
"sodexo",
|
|
64
|
-
"sodexo_no_luhn",
|
|
65
|
-
"panal",
|
|
66
|
-
"verve",
|
|
67
|
-
"tuya",
|
|
68
|
-
"uatp",
|
|
69
|
-
"patagonia_365",
|
|
70
|
-
"tarjeta_sol",
|
|
71
|
-
"tarjeta_unica",
|
|
72
|
-
"consumax",
|
|
73
|
-
"tarjeta_fertil",
|
|
74
|
-
"favacard",
|
|
75
|
-
"elebar",
|
|
76
|
-
"tarjeta_axis",
|
|
77
|
-
"tarjeta_plan_platino",
|
|
78
|
-
"tarjeta_fiel",
|
|
79
|
-
"copeplus",
|
|
80
|
-
"tarjeta_credimas",
|
|
81
|
-
"tarjeta_local",
|
|
82
|
-
"tarjeta_sucredito",
|
|
83
|
-
"sidecreer",
|
|
84
|
-
"cliper",
|
|
85
|
-
"centrocard",
|
|
86
|
-
"wex",
|
|
87
|
-
"codensa"
|
|
88
|
-
]);
|
|
89
|
-
var panLike = (value) => /(?:[0-9][ _.:-]*){12,}/.test(value);
|
|
90
|
-
var opaqueId = (value) => id(value) && /[A-Za-z]/.test(value) && !panLike(value);
|
|
91
|
-
function readJson(body) {
|
|
92
|
-
if (typeof body !== "string" || !body || body.length > 65536)
|
|
93
|
-
return null;
|
|
94
|
-
let at = 0, nodes = 0;
|
|
95
|
-
const fail = () => {
|
|
96
|
-
throw new Error("invalid_spreedly_json");
|
|
97
|
-
};
|
|
98
|
-
const space = () => {
|
|
99
|
-
while (" \r\n".includes(body[at] ?? "\0"))
|
|
100
|
-
at++;
|
|
101
|
-
};
|
|
102
|
-
const string = () => {
|
|
103
|
-
space();
|
|
104
|
-
const start = at;
|
|
105
|
-
if (body[at++] !== '"')
|
|
106
|
-
fail();
|
|
107
|
-
while (at < body.length) {
|
|
108
|
-
const char = body[at++];
|
|
109
|
-
if (char === "\\") {
|
|
110
|
-
at++;
|
|
111
|
-
continue;
|
|
112
|
-
}
|
|
113
|
-
if (char === '"')
|
|
114
|
-
return JSON.parse(body.slice(start, at));
|
|
115
|
-
}
|
|
116
|
-
return fail();
|
|
117
|
-
};
|
|
118
|
-
const value = (depth) => {
|
|
119
|
-
if (depth > 12 || ++nodes > 1e3)
|
|
120
|
-
fail();
|
|
121
|
-
space();
|
|
122
|
-
const char = body[at];
|
|
123
|
-
if (char === '"')
|
|
124
|
-
return string();
|
|
125
|
-
if (char === "{") {
|
|
126
|
-
at++;
|
|
127
|
-
const result = /* @__PURE__ */ Object.create(null), seen = /* @__PURE__ */ new Set();
|
|
128
|
-
space();
|
|
129
|
-
if (body[at] === "}") {
|
|
130
|
-
at++;
|
|
131
|
-
return result;
|
|
132
|
-
}
|
|
133
|
-
while (true) {
|
|
134
|
-
const key = string();
|
|
135
|
-
if (seen.has(key) || ["__proto__", "prototype", "constructor"].includes(key))
|
|
136
|
-
fail();
|
|
137
|
-
seen.add(key);
|
|
138
|
-
space();
|
|
139
|
-
if (body[at++] !== ":")
|
|
140
|
-
fail();
|
|
141
|
-
result[key] = value(depth + 1);
|
|
142
|
-
space();
|
|
143
|
-
const next = body[at++];
|
|
144
|
-
if (next === "}")
|
|
145
|
-
return result;
|
|
146
|
-
if (next !== ",")
|
|
147
|
-
fail();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
if (char === "[") {
|
|
151
|
-
at++;
|
|
152
|
-
const result = [];
|
|
153
|
-
space();
|
|
154
|
-
if (body[at] === "]") {
|
|
155
|
-
at++;
|
|
156
|
-
return result;
|
|
157
|
-
}
|
|
158
|
-
while (true) {
|
|
159
|
-
result.push(value(depth + 1));
|
|
160
|
-
space();
|
|
161
|
-
const next = body[at++];
|
|
162
|
-
if (next === "]")
|
|
163
|
-
return result;
|
|
164
|
-
if (next !== ",")
|
|
165
|
-
fail();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
for (const literal of ["true", "false", "null"]) {
|
|
169
|
-
if (body.startsWith(literal, at)) {
|
|
170
|
-
at += literal.length;
|
|
171
|
-
return JSON.parse(literal);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
const number = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/.exec(body.slice(at));
|
|
175
|
-
if (!number)
|
|
176
|
-
fail();
|
|
177
|
-
at += number[0].length;
|
|
178
|
-
const parsed = Number(number[0]);
|
|
179
|
-
if (!Number.isFinite(parsed))
|
|
180
|
-
fail();
|
|
181
|
-
return parsed;
|
|
182
|
-
};
|
|
183
|
-
try {
|
|
184
|
-
const parsed = value(0);
|
|
185
|
-
space();
|
|
186
|
-
return at === body.length && record(parsed) ? parsed : null;
|
|
187
|
-
}
|
|
188
|
-
catch {
|
|
189
|
-
return null;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
function isSpreedlyTokenRequest(url, method = "POST") {
|
|
193
|
-
if (method !== "POST" || typeof url !== "string" || !url.startsWith(SPREEDLY_TOKEN_ENDPOINT + "?"))
|
|
194
|
-
return false;
|
|
195
|
-
try {
|
|
196
|
-
const parsed = new URL(url);
|
|
197
|
-
if (parsed.href !== url || parsed.origin + parsed.pathname !== SPREEDLY_TOKEN_ENDPOINT || parsed.hash)
|
|
198
|
-
return false;
|
|
199
|
-
const seen = /* @__PURE__ */ new Set();
|
|
200
|
-
for (const pair of parsed.search.slice(1).split("&")) {
|
|
201
|
-
const separator = pair.indexOf("=");
|
|
202
|
-
const name = pair.slice(0, separator), value = pair.slice(separator + 1);
|
|
203
|
-
if (separator < 1 || seen.has(name))
|
|
204
|
-
return false;
|
|
205
|
-
seen.add(name);
|
|
206
|
-
if (name === "from" ? value !== "iframe" : name === "v" ? !exact(/^1\.[0-9]{1,4}$/, value) : name === "client" ? !exact(/^[A-Za-z0-9_.-]{1,64}$/, value) : true)
|
|
207
|
-
return false;
|
|
208
|
-
}
|
|
209
|
-
return seen.has("from") && seen.has("v");
|
|
210
|
-
}
|
|
211
|
-
catch {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
function preparedBody(body) {
|
|
216
|
-
const value = readJson(body);
|
|
217
|
-
if (!keys(value, ["environment_key", "payment_method", ...AUTH]) || !id(value.environment_key) || !keys(value.payment_method, ["credit_card", "allow_blank_name", "allow_expired_date", "metadata"]))
|
|
218
|
-
return null;
|
|
219
|
-
const suppliedAuth = AUTH.filter((key) => owns(value, key));
|
|
220
|
-
if (suppliedAuth.length && (suppliedAuth.length !== AUTH.length || !text(value.nonce) || !value.nonce || !(digits(value.timestamp, 1, 16) || Number.isSafeInteger(value.timestamp) && value.timestamp > 0) || !id(value.certificate_token) || !exact(/^[A-Za-z0-9+/=_-]{1,8192}$/, value.signature)))
|
|
221
|
-
return null;
|
|
222
|
-
const pm = value.payment_method, cc = pm.credit_card;
|
|
223
|
-
if (!keys(cc, ["number", "verification_value", "month", "year", "eligible_for_card_updater", ...CARD_TEXT]) || !digits(cc.number, 12, 19) || !digits(cc.verification_value, 3, 4) || !month(cc.month) || !year(cc.year) || CARD_TEXT.some((key) => owns(cc, key) && !text(cc[key])) || owns(cc, "eligible_for_card_updater") && cc.eligible_for_card_updater !== false)
|
|
224
|
-
return null;
|
|
225
|
-
if (owns(pm, "allow_blank_name") && typeof pm.allow_blank_name !== "boolean" || owns(pm, "allow_expired_date") && pm.allow_expired_date !== false)
|
|
226
|
-
return null;
|
|
227
|
-
if (owns(pm, "metadata") && (!record(pm.metadata) || Object.keys(pm.metadata).length > 20 || Object.entries(pm.metadata).some(([key, value2]) => !exact(/^[A-Za-z][A-Za-z0-9_-]{0,63}$/, key) || !(value2 === null || typeof value2 === "boolean" || Number.isFinite(value2) || text(value2)))))
|
|
228
|
-
return null;
|
|
229
|
-
return value;
|
|
230
|
-
}
|
|
231
|
-
function isPreparedSpreedlyRequest(body) {
|
|
232
|
-
return preparedBody(body) !== null;
|
|
233
|
-
}
|
|
234
|
-
function isSpreedlyRequest(request) {
|
|
235
|
-
if (!record(request) || request.method !== "POST" || !isSpreedlyTokenRequest(request.url, request.method) || !record(request.headers))
|
|
236
|
-
return false;
|
|
237
|
-
const body = preparedBody(request.body);
|
|
238
|
-
if (!body)
|
|
239
|
-
return false;
|
|
240
|
-
const headers = /* @__PURE__ */ new Map();
|
|
241
|
-
for (const [name, value] of Object.entries(request.headers)) {
|
|
242
|
-
const lower = name.toLowerCase();
|
|
243
|
-
if (headers.has(lower) || !text(value, 8192))
|
|
244
|
-
return false;
|
|
245
|
-
headers.set(lower, value);
|
|
246
|
-
}
|
|
247
|
-
return exact(/^application\/json(?:;\s*charset=utf-8)?$/i, headers.get("content-type")) && headers.get("spreedly-environment-key") === body.environment_key;
|
|
248
|
-
}
|
|
249
|
-
function injectSpreedlyCard(body, card) {
|
|
250
|
-
const value = preparedBody(body);
|
|
251
|
-
if (!value)
|
|
252
|
-
throw new Error("Refusing to pay: unsupported Spreedly new-card request.");
|
|
253
|
-
if (!card || !digits(card.number, 12, 19) || !digits(card.cvc, 3, 4) || !month(card.month) || !year(card.year)) {
|
|
254
|
-
throw new Error("Could not fill the card fields for Spreedly. Nothing was sent.");
|
|
255
|
-
}
|
|
256
|
-
const cc = value.payment_method.credit_card;
|
|
257
|
-
cc.number = card.number;
|
|
258
|
-
cc.verification_value = card.cvc;
|
|
259
|
-
cc.month = typeof cc.month === "number" ? Number(card.month) : String(card.month);
|
|
260
|
-
const selectedYear = String(card.year), nativeYear = String(cc.year);
|
|
261
|
-
const replacementYear = nativeYear.length === 2 && selectedYear.length === 4 ? selectedYear.slice(-2) : nativeYear.length === 4 && selectedYear.length === 2 ? "20" + selectedYear : selectedYear;
|
|
262
|
-
cc.year = typeof cc.year === "number" ? Number(replacementYear) : replacementYear;
|
|
263
|
-
return { body: JSON.stringify(value), where: ["number", "verification_value", "month", "year"].map((key) => "payment_method.credit_card." + key) };
|
|
264
|
-
}
|
|
265
|
-
function sanitizeSpreedlyTokenResponse(body) {
|
|
266
|
-
const value = readJson(body), transaction = value?.transaction, pm = transaction?.payment_method;
|
|
267
|
-
const fail = () => {
|
|
268
|
-
throw new Error("Invalid Spreedly token response.");
|
|
269
|
-
};
|
|
270
|
-
if (!record(transaction) || !record(pm) || transaction.succeeded !== true || transaction.transaction_type !== "AddPaymentMethod" || transaction.state !== "succeeded" || pm.payment_method_type !== "credit_card" || !opaqueId(pm.token))
|
|
271
|
-
return fail();
|
|
272
|
-
if (!text(pm.number, 32) || !exact(/^[Xx*]{8,15}[0-9]{4}$/, pm.number.replace(/-/g, "")) || !digits(pm.last_four_digits, 4, 4) || !pm.number.endsWith(pm.last_four_digits) || !exact(/^[Xx*]{3,4}$/, pm.verification_value) || !month(pm.month) || !year(pm.year))
|
|
273
|
-
return fail();
|
|
274
|
-
const safePm = {
|
|
275
|
-
token: pm.token,
|
|
276
|
-
payment_method_type: "credit_card",
|
|
277
|
-
number: pm.number,
|
|
278
|
-
verification_value: pm.verification_value,
|
|
279
|
-
last_four_digits: pm.last_four_digits,
|
|
280
|
-
month: pm.month,
|
|
281
|
-
year: pm.year
|
|
282
|
-
};
|
|
283
|
-
if (owns(pm, "card_type")) {
|
|
284
|
-
if (!CARD_TYPES.has(pm.card_type))
|
|
285
|
-
return fail();
|
|
286
|
-
safePm.card_type = pm.card_type;
|
|
287
|
-
}
|
|
288
|
-
if (owns(pm, "storage_state")) {
|
|
289
|
-
if (!["cached", "retained"].includes(pm.storage_state))
|
|
290
|
-
return fail();
|
|
291
|
-
safePm.storage_state = pm.storage_state;
|
|
292
|
-
}
|
|
293
|
-
if (owns(pm, "fingerprint")) {
|
|
294
|
-
if (!opaqueId(pm.fingerprint))
|
|
295
|
-
return fail();
|
|
296
|
-
safePm.fingerprint = pm.fingerprint;
|
|
297
|
-
}
|
|
298
|
-
for (const [key, width] of [["first_six_digits", 6], ["first_eight_digits", 8]]) {
|
|
299
|
-
if (owns(pm, key) && pm[key] !== null) {
|
|
300
|
-
if (!digits(pm[key], width, width))
|
|
301
|
-
return fail();
|
|
302
|
-
safePm[key] = pm[key];
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
for (const key of ["test", "eligible_for_card_updater"]) {
|
|
306
|
-
if (owns(pm, key)) {
|
|
307
|
-
if (typeof pm[key] !== "boolean")
|
|
308
|
-
return fail();
|
|
309
|
-
safePm[key] = pm[key];
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
for (const key of CARD_TEXT) {
|
|
313
|
-
if (!owns(pm, key))
|
|
314
|
-
continue;
|
|
315
|
-
if (pm[key] !== null && (!text(pm[key]) || panLike(pm[key])))
|
|
316
|
-
return fail();
|
|
317
|
-
safePm[key] = pm[key];
|
|
318
|
-
}
|
|
319
|
-
if (owns(pm, "errors")) {
|
|
320
|
-
if (!Array.isArray(pm.errors) || pm.errors.length)
|
|
321
|
-
return fail();
|
|
322
|
-
safePm.errors = [];
|
|
323
|
-
}
|
|
324
|
-
const safeTransaction = { succeeded: true, transaction_type: "AddPaymentMethod", state: "succeeded", payment_method: safePm };
|
|
325
|
-
if (owns(transaction, "token")) {
|
|
326
|
-
if (!opaqueId(transaction.token))
|
|
327
|
-
return fail();
|
|
328
|
-
safeTransaction.token = transaction.token;
|
|
329
|
-
}
|
|
330
|
-
return JSON.stringify({ transaction: safeTransaction });
|
|
331
|
-
}
|
|
332
|
-
export { SPREEDLY_TOKEN_ENDPOINT, injectSpreedlyCard, isPreparedSpreedlyRequest, isSpreedlyRequest, isSpreedlyTokenRequest, sanitizeSpreedlyTokenResponse };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { STRIPE_CHECKOUT_VALIDATION_CODES } from './stripe-checkout.generated.js';
|
|
2
|
-
import type { PausedRequest } from './client.js';
|
|
3
|
-
/** Test by default. Production requires explicit opt-in and an independently admitted live grant. */
|
|
4
|
-
export interface StripeCheckoutOptions {
|
|
5
|
-
environment?: 'test' | 'production';
|
|
6
|
-
sessionId: string;
|
|
7
|
-
publishableKey: string;
|
|
8
|
-
}
|
|
9
|
-
type StubResponse = {
|
|
10
|
-
status: number;
|
|
11
|
-
headers: Record<string, string>;
|
|
12
|
-
body: string;
|
|
13
|
-
};
|
|
14
|
-
type Step = {
|
|
15
|
-
phase: 'tokenization';
|
|
16
|
-
response: StubResponse;
|
|
17
|
-
} | {
|
|
18
|
-
phase: 'final';
|
|
19
|
-
request: PausedRequest;
|
|
20
|
-
};
|
|
21
|
-
type Phase = Step['phase'] | 'unknown';
|
|
22
|
-
type GateState = 'fresh' | 'stubbed' | 'submitted' | 'stopped';
|
|
23
|
-
type ValidationCode = (typeof STRIPE_CHECKOUT_VALIDATION_CODES)[keyof typeof STRIPE_CHECKOUT_VALIDATION_CODES];
|
|
24
|
-
export type StripeCheckoutBlockStage = 'request_read' | 'classification' | 'claim' | 'readiness' | 'document' | 'stub_response';
|
|
25
|
-
type ReadinessReason = 'attachment_not_ready' | 'cancelled' | 'checkout_inactive' | 'approval_pending' | 'request_inactive';
|
|
26
|
-
export type StripeCheckoutBlockReason = ReadinessReason | 'request_unavailable' | 'request_validation_failed' | 'context_already_present' | 'duplicate_tokenization' | 'duplicate_confirmation' | 'preparation_unavailable' | 'preparation_missing' | 'claim_invalidated' | 'document_changed' | 'document_unavailable' | 'readiness_unavailable' | 'stub_response_failed';
|
|
27
|
-
/** Native pre-authorization refusal metadata. Never contains request or exception text.
|
|
28
|
-
* A classification code comes only from the shared core's fixed vocabulary.
|
|
29
|
-
* gate_state is observed before the adapter retires a failed claim. A preserved duplicate
|
|
30
|
-
* belongs to a competing request: consumers must not cancel the active checkout for it.
|
|
31
|
-
*/
|
|
32
|
-
export interface StripeCheckoutBlockedDetail {
|
|
33
|
-
version: 1;
|
|
34
|
-
processor: 'stripe';
|
|
35
|
-
endpoint_family: 'payment_methods' | 'payment_page_confirm' | 'other';
|
|
36
|
-
phase: Phase;
|
|
37
|
-
stage: StripeCheckoutBlockStage;
|
|
38
|
-
reason: StripeCheckoutBlockReason;
|
|
39
|
-
validation_code?: ValidationCode;
|
|
40
|
-
gate_state: GateState;
|
|
41
|
-
disposition: 'active_claim_preserved' | 'checkout_stopped';
|
|
42
|
-
}
|
|
43
|
-
declare class StripeCheckoutRejectionError extends Error {
|
|
44
|
-
readonly stage: StripeCheckoutBlockStage;
|
|
45
|
-
readonly reason: StripeCheckoutBlockReason;
|
|
46
|
-
readonly phase?: Phase | undefined;
|
|
47
|
-
readonly validationCode?: ValidationCode | undefined;
|
|
48
|
-
constructor(message: string, stage: StripeCheckoutBlockStage, reason: StripeCheckoutBlockReason, phase?: Phase | undefined, validationCode?: ValidationCode | undefined);
|
|
49
|
-
}
|
|
50
|
-
export declare function stripeCheckoutReadinessError(reason: ReadinessReason): Error;
|
|
51
|
-
/** A valid competing request must not retire the request that already claimed this step. */
|
|
52
|
-
export declare class StripeCheckoutClaimConflictError extends StripeCheckoutRejectionError {
|
|
53
|
-
constructor(phase: Step['phase']);
|
|
54
|
-
}
|
|
55
|
-
/** The two native browser requests belong to one attachment and one grant.
|
|
56
|
-
* Processor rules and form transformations live in the generated shared core.
|
|
57
|
-
* The local stub contains no selected-card data and starts no authorization.
|
|
58
|
-
*/
|
|
59
|
-
export declare class StripeCheckoutGate {
|
|
60
|
-
private state;
|
|
61
|
-
private billing?;
|
|
62
|
-
private readonly binding?;
|
|
63
|
-
constructor(options: {
|
|
64
|
-
stripeCheckout?: StripeCheckoutOptions;
|
|
65
|
-
executionMode?: string;
|
|
66
|
-
grantId?: string;
|
|
67
|
-
amount?: number | string;
|
|
68
|
-
currency?: string;
|
|
69
|
-
});
|
|
70
|
-
matches(url: string): boolean;
|
|
71
|
-
isEnabled(): boolean;
|
|
72
|
-
isPrepared(): boolean;
|
|
73
|
-
invalidate(): void;
|
|
74
|
-
/** Observability only: this endpoint label never participates in a payment decision. */
|
|
75
|
-
describeRejection(error: unknown, rawUrl: string, stage: StripeCheckoutBlockStage, phase?: Phase): StripeCheckoutBlockedDetail;
|
|
76
|
-
assertClaim(step: Step): void;
|
|
77
|
-
/** Check the actual top-level hosted document before preparing either step. */
|
|
78
|
-
assertDocument(raw: string): void;
|
|
79
|
-
claim(request: PausedRequest): Step | null;
|
|
80
|
-
}
|
|
81
|
-
export {};
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
declare var STRIPE_CHECKOUT_OPERATION: string;
|
|
2
|
-
declare var STRIPE_CHECKOUT_CONTEXT_HEADER: string;
|
|
3
|
-
declare var STRIPE_CHECKOUT_VALIDATION_CODES: Readonly<{
|
|
4
|
-
unclassified: "unclassified";
|
|
5
|
-
request_shape: "request_shape";
|
|
6
|
-
request_body_bounds: "request_body_bounds";
|
|
7
|
-
request_headers: "request_headers";
|
|
8
|
-
form_encoding: "form_encoding";
|
|
9
|
-
form_field_unknown: "form_field_unknown";
|
|
10
|
-
form_field_duplicate: "form_field_duplicate";
|
|
11
|
-
form_value_bounds: "form_value_bounds";
|
|
12
|
-
context_invalid: "context_invalid";
|
|
13
|
-
session_binding: "session_binding";
|
|
14
|
-
publishable_key: "publishable_key";
|
|
15
|
-
mode_binding: "mode_binding";
|
|
16
|
-
attribution_session: "attribution_session";
|
|
17
|
-
tokenization_fields: "tokenization_fields";
|
|
18
|
-
billing_email: "billing_email";
|
|
19
|
-
billing_binding: "billing_binding";
|
|
20
|
-
billing_conflict: "billing_conflict";
|
|
21
|
-
expected_amount: "expected_amount";
|
|
22
|
-
payment_method_type: "payment_method_type";
|
|
23
|
-
synthetic_payment_method: "synthetic_payment_method";
|
|
24
|
-
required_final_fields: "required_final_fields";
|
|
25
|
-
}>;
|
|
26
|
-
declare function stripeCheckoutValidationCode(error: any): "unclassified" | "request_shape" | "request_body_bounds" | "request_headers" | "form_encoding" | "form_field_unknown" | "form_field_duplicate" | "form_value_bounds" | "context_invalid" | "session_binding" | "publishable_key" | "mode_binding" | "attribution_session" | "tokenization_fields" | "billing_email" | "billing_binding" | "billing_conflict" | "expected_amount" | "payment_method_type" | "synthetic_payment_method" | "required_final_fields";
|
|
27
|
-
declare function validateStripeCheckoutIdentity(value: any): Readonly<{
|
|
28
|
-
environment: any;
|
|
29
|
-
livemode: boolean;
|
|
30
|
-
}>;
|
|
31
|
-
declare function validateStripeCheckoutCard(card: any, environment?: string): boolean;
|
|
32
|
-
declare function isStripeCheckoutHostedMode(value: any): boolean;
|
|
33
|
-
declare function encodeStripeCheckoutContext(value: any): string;
|
|
34
|
-
declare function hasStripeCheckoutMarker(request: any): boolean;
|
|
35
|
-
declare function parseStripeCheckoutContext(request: any): {
|
|
36
|
-
version: number;
|
|
37
|
-
session_id: any;
|
|
38
|
-
synthetic_payment_method_id: any;
|
|
39
|
-
} | null | undefined;
|
|
40
|
-
declare function isStripeCheckoutEndpoint(raw: any): boolean;
|
|
41
|
-
declare function captureStripeCheckoutBilling(request: any, options: any): Readonly<{
|
|
42
|
-
session_id: any;
|
|
43
|
-
synthetic_payment_method_id: any;
|
|
44
|
-
email: string | null;
|
|
45
|
-
}>;
|
|
46
|
-
declare function attachStripeCheckoutBilling(request: any, captured: any, options: any): any;
|
|
47
|
-
declare function classifyStripeCheckoutRequest(request: any, options?: {}): {
|
|
48
|
-
phase: string;
|
|
49
|
-
session_id: any;
|
|
50
|
-
publishable_key: any;
|
|
51
|
-
synthetic_payment_method_id?: undefined;
|
|
52
|
-
amount_cents?: undefined;
|
|
53
|
-
currency?: undefined;
|
|
54
|
-
} | {
|
|
55
|
-
phase: string;
|
|
56
|
-
session_id: any;
|
|
57
|
-
publishable_key: any;
|
|
58
|
-
synthetic_payment_method_id: string | undefined;
|
|
59
|
-
amount_cents: number;
|
|
60
|
-
currency: string;
|
|
61
|
-
} | null;
|
|
62
|
-
declare function createStripeCheckoutTokenizationStub(request: any, options: any): {
|
|
63
|
-
status: number;
|
|
64
|
-
headers: {
|
|
65
|
-
"content-type": string;
|
|
66
|
-
};
|
|
67
|
-
body: string;
|
|
68
|
-
};
|
|
69
|
-
declare function parseStripeCheckoutResponse(raw: any, options: any): any;
|
|
70
|
-
declare function prepareStripeCheckoutReplay(request: any, card: any, options?: {}): {
|
|
71
|
-
psp: string;
|
|
72
|
-
request: {
|
|
73
|
-
url: any;
|
|
74
|
-
method: string;
|
|
75
|
-
headers: {
|
|
76
|
-
"content-type": string;
|
|
77
|
-
};
|
|
78
|
-
body: string;
|
|
79
|
-
};
|
|
80
|
-
where: string[];
|
|
81
|
-
};
|
|
82
|
-
export { STRIPE_CHECKOUT_CONTEXT_HEADER, STRIPE_CHECKOUT_OPERATION, STRIPE_CHECKOUT_VALIDATION_CODES, attachStripeCheckoutBilling, captureStripeCheckoutBilling, classifyStripeCheckoutRequest, createStripeCheckoutTokenizationStub, encodeStripeCheckoutContext, hasStripeCheckoutMarker, isStripeCheckoutEndpoint, isStripeCheckoutHostedMode, parseStripeCheckoutContext, parseStripeCheckoutResponse, prepareStripeCheckoutReplay, stripeCheckoutValidationCode, validateStripeCheckoutCard, validateStripeCheckoutIdentity };
|