@agent-cards/sdk 0.23.28 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/PREFLIGHT.md +7 -1
- package/README.md +137 -99
- package/dist/aci.d.ts +52 -22
- package/dist/aci.js +79 -15
- package/dist/adyen-merchant-hosted.generated.d.ts +1 -1
- package/dist/adyen-merchant-hosted.generated.js +459 -21
- package/dist/agent-amount.generated.js +1 -1
- package/dist/agentcard.d.ts +4 -5
- package/dist/agentcard.js +4 -5
- package/dist/amadeus.d.ts +9 -3
- package/dist/amadeus.js +33 -4
- package/dist/api-module.d.ts +1 -7
- package/dist/api-module.js +3 -5
- package/dist/{voice-retry.js → api-retry.js} +1 -1
- package/dist/api-types.d.ts +53 -0
- package/dist/{voice-types.js → api-types.js} +7 -2
- package/dist/approvals.d.ts +166 -0
- package/dist/approvals.js +213 -0
- package/dist/buy.d.ts +20 -101
- package/dist/buy.js +19 -74
- package/dist/capabilities.generated.js +1 -1
- package/dist/card-fields.generated.js +1398 -106
- package/dist/cdp.d.ts +3 -13
- package/dist/cdp.js +231 -175
- package/dist/client.d.ts +104 -22
- package/dist/client.js +215 -40
- package/dist/creditguard.generated.d.ts +4 -4
- package/dist/datatrans.generated.js +22 -1
- package/dist/elavon-converge.generated.js +5 -3
- package/dist/hold.d.ts +8 -0
- package/dist/hold.js +43 -2
- package/dist/hosted-entry.js +2 -0
- package/dist/index.d.ts +9 -15
- package/dist/index.js +6 -10
- package/dist/lifecycle.d.ts +9 -61
- package/dist/lifecycle.js +24 -10
- package/dist/merchant-card-endpoints.generated.d.ts +6 -1
- package/dist/merchant-card-endpoints.generated.js +344 -19
- package/dist/merchant-hosted.d.ts +8 -1
- package/dist/nike-order.d.ts +51 -0
- package/dist/nike-order.js +81 -0
- package/dist/oceanpayment.d.ts +38 -0
- package/dist/oceanpayment.js +70 -0
- package/dist/paddle-tokenex.generated.js +105 -10
- package/dist/payplug.d.ts +41 -0
- package/dist/payplug.js +71 -0
- package/dist/payrails.generated.js +27 -7
- package/dist/pre-claim.d.ts +9 -0
- package/dist/pre-claim.js +86 -7
- package/dist/preflight-capabilities.generated.d.ts +0 -4
- package/dist/preflight-capabilities.generated.js +0 -5
- package/dist/preflight-catalog.json +46 -5
- package/dist/preflight-playwright.d.ts +2 -2
- package/dist/preflight-playwright.js +63 -14
- package/dist/preflight-schemas.json +4 -0
- package/dist/preflight.generated.d.ts +0 -4
- package/dist/preflight.generated.js +24 -1
- package/dist/prepared-processor.d.ts +18 -5
- package/dist/prepared-processor.js +48 -8
- package/dist/primer.generated.js +1418 -120
- package/dist/processout.generated.d.ts +61 -0
- package/dist/processout.generated.js +577 -0
- package/dist/requests.js +1 -1
- package/dist/shiji-sts.generated.js +105 -10
- package/dist/stripe-checkout.generated.js +1405 -234
- package/dist/substitutions.generated.js +460 -26
- package/dist/tap-payments.generated.js +105 -10
- package/dist/twoc2p.generated.js +105 -10
- package/dist/url-masks/bluesnap.d.ts +2 -0
- package/dist/url-masks/bluesnap.js +15 -0
- package/dist/url-masks/oceanpayment.d.ts +2 -0
- package/dist/url-masks/oceanpayment.js +13 -0
- package/dist/url-masks/payplug.d.ts +2 -0
- package/dist/url-masks/payplug.js +13 -0
- package/dist/url-masks/vtex_payments.d.ts +2 -0
- package/dist/url-masks/vtex_payments.js +12 -0
- package/dist/url-masks.generated.d.ts +1 -1
- package/dist/url-masks.generated.js +6 -2
- package/dist/verifone.generated.js +42 -2
- package/dist/vtex-payments.generated.d.ts +127 -0
- package/dist/vtex-payments.generated.js +544 -0
- package/dist/webhooks.d.ts +2 -2
- package/dist/webhooks.js +2 -2
- package/examples/preflight/kernel-native/inventory.json +1 -1
- package/package.json +6 -8
- package/dist/languages.d.ts +0 -23
- package/dist/languages.js +0 -76
- package/dist/voice-pkce.d.ts +0 -49
- package/dist/voice-pkce.js +0 -147
- package/dist/voice-stream.generated.d.ts +0 -118
- package/dist/voice-stream.generated.js +0 -170
- package/dist/voice-types.d.ts +0 -735
- package/dist/voice.d.ts +0 -373
- package/dist/voice.js +0 -815
- package/readme.test.mjs +0 -53
- /package/dist/{voice-retry.d.ts → api-retry.d.ts} +0 -0
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// Generated from @agent-cards/payment-core. Do not edit.
|
|
3
|
+
// artifact-sha256: 07dfa13862b2c6a1a9256394c968c0a364e25eb763d8dee500aaed4f0fe259a7
|
|
4
|
+
// src/deep-freeze.js
|
|
5
|
+
function deepFreeze(value) {
|
|
6
|
+
if (value && typeof value === "object" && !Object.isFrozen(value)) {
|
|
7
|
+
for (const child of Object.values(value))
|
|
8
|
+
deepFreeze(child);
|
|
9
|
+
Object.freeze(value);
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
// src/registration.js
|
|
14
|
+
var PARTS = {
|
|
15
|
+
psp: "id",
|
|
16
|
+
definitions: "list",
|
|
17
|
+
refusedOperations: "list",
|
|
18
|
+
settlementReadback: "any",
|
|
19
|
+
exactUrl: "rule",
|
|
20
|
+
bodyGate: "rule",
|
|
21
|
+
amount: "rule",
|
|
22
|
+
hostedEntry: "rule",
|
|
23
|
+
limitations: "sentences"
|
|
24
|
+
};
|
|
25
|
+
var DEVICE_PARTS = { psp: "id", testPans: "numbers", deviceCheck: "rule", fill: "rule", refusalCode: "rule", outcome: "rule", relayOnly: "flag" };
|
|
26
|
+
var PSP_ID = /^[a-z][a-z0-9_]*$/;
|
|
27
|
+
function problemsOf(spec, parts) {
|
|
28
|
+
if (!spec || typeof spec !== "object")
|
|
29
|
+
return ["a registration is an object"];
|
|
30
|
+
const psp = spec.psp;
|
|
31
|
+
if (typeof psp !== "string" || !PSP_ID.test(psp))
|
|
32
|
+
return [`${JSON.stringify(psp)} is not a processor id`];
|
|
33
|
+
const problems = Object.keys(spec).filter((key) => !(key in parts)).map((key) => `${psp}: ${key} is no registration part`);
|
|
34
|
+
for (const [key, kind] of Object.entries(parts)) {
|
|
35
|
+
const value = spec[key];
|
|
36
|
+
if (value === void 0)
|
|
37
|
+
continue;
|
|
38
|
+
if (kind === "rule" && typeof value !== "function")
|
|
39
|
+
problems.push(`${psp}: ${key} is not a function`);
|
|
40
|
+
if (kind === "flag" && value !== true)
|
|
41
|
+
problems.push(`${psp}: ${key} is not true`);
|
|
42
|
+
if (kind === "numbers" && !((Array.isArray(value) || value instanceof Set) && [...value].every((n) => typeof n === "string" && /^\d{12,19}$/.test(n)))) {
|
|
43
|
+
problems.push(`${psp}: ${key} is not a list of card numbers`);
|
|
44
|
+
}
|
|
45
|
+
if (kind === "sentences" && !(Array.isArray(value) && value.length > 0 && value.every((s) => typeof s === "string" && s.trim() !== ""))) {
|
|
46
|
+
problems.push(`${psp}: ${key} is not a list of sentences`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if ("definitions" in parts) {
|
|
50
|
+
if (!Array.isArray(spec.definitions) || spec.definitions.length === 0)
|
|
51
|
+
problems.push(`${psp}: names no definition`);
|
|
52
|
+
else if (spec.definitions.some((definition) => definition?.psp !== psp))
|
|
53
|
+
problems.push(`${psp}: a definition names another processor`);
|
|
54
|
+
for (const id of spec.refusedOperations ?? []) {
|
|
55
|
+
if (typeof id !== "string" || !id.startsWith(`${psp}.`))
|
|
56
|
+
problems.push(`${psp}: ${JSON.stringify(id)} is not one of its operations`);
|
|
57
|
+
}
|
|
58
|
+
const pages = Array.isArray(spec.definitions) ? spec.definitions.filter((d) => d?.hostedForm?.cardIn === "processor_page") : [];
|
|
59
|
+
if (spec.hostedEntry !== void 0 && (pages.length === 0 || pages.some((d) => d.hostedForm.policy !== void 0))) {
|
|
60
|
+
problems.push(`${psp}: hostedEntry needs a definition whose hosted form takes the card on the processor's page and names no policy`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return problems;
|
|
64
|
+
}
|
|
65
|
+
function registered(spec, parts) {
|
|
66
|
+
const problems = problemsOf(spec, parts);
|
|
67
|
+
if (problems.length)
|
|
68
|
+
throw new Error(`payment-core registration refused: ${problems.join("; ")}`);
|
|
69
|
+
return deepFreeze({ ...spec });
|
|
70
|
+
}
|
|
71
|
+
function registerProcessor(spec) {
|
|
72
|
+
return registered(spec, PARTS);
|
|
73
|
+
}
|
|
74
|
+
function registerDeviceRules(psp, rules) {
|
|
75
|
+
const checked = registered({ psp, ...rules }, DEVICE_PARTS);
|
|
76
|
+
return checked.testPans ? Object.freeze({ ...checked, testPans: new Set(checked.testPans) }) : checked;
|
|
77
|
+
}
|
|
78
|
+
// src/processors/vtex_payments.js
|
|
79
|
+
var VTEX_PAYMENTS_PSP = "vtex_payments";
|
|
80
|
+
var VTEX_PAYMENTS_CAPABILITY = "vtex_payments_card_payment";
|
|
81
|
+
var VTEX_PAYMENTS_OPERATION = "vtex_payments.card_request";
|
|
82
|
+
var VTEX_PAYMENTS_FALLBACK_HOST = "api.vtexvault.com";
|
|
83
|
+
var VTEX_PAYMENTS_PREPARATION_URL = "https://api.vtexvault.com/api/payments/transactions/prepared/payments";
|
|
84
|
+
var VTEX_PAYMENTS_REFUSAL_CODES = /* @__PURE__ */ Object.freeze([
|
|
85
|
+
"vtex_payments_url_refused",
|
|
86
|
+
"vtex_payments_fallback_refused",
|
|
87
|
+
"vtex_payments_headers_refused",
|
|
88
|
+
"vtex_payments_saved_card",
|
|
89
|
+
"vtex_payments_split_payment",
|
|
90
|
+
"vtex_payments_installments",
|
|
91
|
+
"vtex_payments_body_unsupported"
|
|
92
|
+
]);
|
|
93
|
+
var VTEX_PAYMENTS_LINE_KEYS = /* @__PURE__ */ Object.freeze([
|
|
94
|
+
"currencyCode",
|
|
95
|
+
"paymentSystem",
|
|
96
|
+
"accountId",
|
|
97
|
+
"value",
|
|
98
|
+
"referenceValue",
|
|
99
|
+
"installments",
|
|
100
|
+
"installmentsInterestRate",
|
|
101
|
+
"installmentsValue",
|
|
102
|
+
"groupName",
|
|
103
|
+
"fields",
|
|
104
|
+
"transaction",
|
|
105
|
+
"id"
|
|
106
|
+
]);
|
|
107
|
+
var VTEX_PAYMENTS_FIELD_KEYS = /* @__PURE__ */ Object.freeze([
|
|
108
|
+
"address",
|
|
109
|
+
"accountId",
|
|
110
|
+
"validationCode",
|
|
111
|
+
"metadata",
|
|
112
|
+
"document",
|
|
113
|
+
"holderName",
|
|
114
|
+
"cardNumber",
|
|
115
|
+
"dueDate",
|
|
116
|
+
"deviceFingerprint",
|
|
117
|
+
"addressId"
|
|
118
|
+
]);
|
|
119
|
+
var VTEX_PAYMENTS_ADDRESS_KEYS = /* @__PURE__ */ Object.freeze([
|
|
120
|
+
"street",
|
|
121
|
+
"complement",
|
|
122
|
+
"number",
|
|
123
|
+
"city",
|
|
124
|
+
"reference",
|
|
125
|
+
"addressType",
|
|
126
|
+
"neighborhood",
|
|
127
|
+
"addressId",
|
|
128
|
+
"state",
|
|
129
|
+
"country",
|
|
130
|
+
"postalCode"
|
|
131
|
+
]);
|
|
132
|
+
var VTEX_PAYMENTS_NETWORKS = /* @__PURE__ */ Object.freeze({ 1: "amex", 2: "visa", 4: "mastercard", 5: "discover" });
|
|
133
|
+
var VTEX_PAYMENTS_MERCHANT_PINS = /* @__PURE__ */ Object.freeze([
|
|
134
|
+
Object.freeze({ account: "alssports", origin: "https://www.als.com", merchant: "Al's Sporting Goods", currency: "USD" }),
|
|
135
|
+
Object.freeze({ account: "roadrunnersports", origin: "https://www.roadrunnersports.com", merchant: "Road Runner Sports", currency: "USD" })
|
|
136
|
+
]);
|
|
137
|
+
var BODY_LIMIT = 16384;
|
|
138
|
+
var ACCOUNT_HOST = /^([a-z0-9]{1,63})\.vtexvault\.com$/;
|
|
139
|
+
var PATH = /^\/api\/payments\/transactions\/([0-9A-Fa-f]{32})\/payments$/;
|
|
140
|
+
var ORDER_GROUP = /^[0-9]{6,24}$/;
|
|
141
|
+
var BASE64 = /^[A-Za-z0-9+/]{4,1020}={0,2}$/;
|
|
142
|
+
var JSON_TYPE = /^application\/json(?:\s*;\s*charset=utf-8)?$/i;
|
|
143
|
+
var CARD_NUMBER = /^[0-9]{12,19}$/;
|
|
144
|
+
var SECURITY_CODE = /^[0-9]{3,4}$/;
|
|
145
|
+
var DUE_DATE = /^(?:0[1-9]|1[0-2])\/[0-9]{2}$/;
|
|
146
|
+
var CURRENCY = /^[A-Z]{3}$/;
|
|
147
|
+
var TRANSACTION_ID = /^[0-9A-Fa-f]{32}$/;
|
|
148
|
+
var MERCHANT_NAME = /^[A-Za-z0-9_.-]{1,64}$/;
|
|
149
|
+
var SHORT_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
150
|
+
var FINGERPRINT = /^[A-Za-z0-9_.:=+/-]{1,256}$/;
|
|
151
|
+
var TEXT = /^[^\u0000-\u001f\u007f]{1,200}$/;
|
|
152
|
+
var CARD_DIGITS = /[0-9]{12,}/;
|
|
153
|
+
var DEVICE_INFO_KEYS = Object.freeze(["sw", "sh", "cd", "tz", "lang", "java", "sourceApplication"]);
|
|
154
|
+
var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
155
|
+
var own = (value, key) => Object.prototype.hasOwnProperty.call(value, key);
|
|
156
|
+
var refuse = (code) => Object.freeze({ verdict: "refuse", code });
|
|
157
|
+
var CARD = /* @__PURE__ */ Object.freeze({ verdict: "card" });
|
|
158
|
+
var inOrder = (value, keys) => {
|
|
159
|
+
let at = 0;
|
|
160
|
+
for (const name of Object.keys(value)) {
|
|
161
|
+
while (at < keys.length && keys[at] !== name)
|
|
162
|
+
at += 1;
|
|
163
|
+
if (at === keys.length)
|
|
164
|
+
return false;
|
|
165
|
+
at += 1;
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
};
|
|
169
|
+
var cardDigits = (text) => CARD_DIGITS.test(text.replace(/[^0-9A-Za-z]/g, ""));
|
|
170
|
+
var plainText = (value) => typeof value === "string" && TEXT.test(value) && !cardDigits(value);
|
|
171
|
+
var count = (value) => Number.isSafeInteger(value) && value >= 0;
|
|
172
|
+
var BASE64_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
173
|
+
function base64Text(input) {
|
|
174
|
+
if (input.length % 4 !== 0)
|
|
175
|
+
return null;
|
|
176
|
+
const stripped = input.replace(/={1,2}$/, "");
|
|
177
|
+
let out = "";
|
|
178
|
+
let bits = 0;
|
|
179
|
+
let value = 0;
|
|
180
|
+
for (const character of stripped) {
|
|
181
|
+
const sextet = BASE64_ALPHABET.indexOf(character);
|
|
182
|
+
if (sextet < 0)
|
|
183
|
+
return null;
|
|
184
|
+
value = value << 6 | sextet;
|
|
185
|
+
bits += 6;
|
|
186
|
+
if (bits >= 8) {
|
|
187
|
+
bits -= 8;
|
|
188
|
+
out += String.fromCharCode(value >> bits & 255);
|
|
189
|
+
value &= (1 << bits) - 1;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return out;
|
|
193
|
+
}
|
|
194
|
+
function deviceInfoSound(text) {
|
|
195
|
+
if (typeof text !== "string" || !BASE64.test(text))
|
|
196
|
+
return false;
|
|
197
|
+
const decoded = base64Text(text);
|
|
198
|
+
if (decoded === null)
|
|
199
|
+
return false;
|
|
200
|
+
let info;
|
|
201
|
+
try {
|
|
202
|
+
info = JSON.parse(decoded);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return false;
|
|
206
|
+
}
|
|
207
|
+
if (!record(info) || !Object.keys(info).every((key) => DEVICE_INFO_KEYS.includes(key)))
|
|
208
|
+
return false;
|
|
209
|
+
for (const key of ["sw", "sh", "cd"])
|
|
210
|
+
if (own(info, key) && !(count(info[key]) && info[key] <= 1e5))
|
|
211
|
+
return false;
|
|
212
|
+
if (own(info, "tz") && !(Number.isSafeInteger(info.tz) && Math.abs(info.tz) <= 1440))
|
|
213
|
+
return false;
|
|
214
|
+
if (own(info, "lang") && !(typeof info.lang === "string" && /^[A-Za-z]{0,8}$/.test(info.lang)))
|
|
215
|
+
return false;
|
|
216
|
+
if (own(info, "java") && typeof info.java !== "boolean")
|
|
217
|
+
return false;
|
|
218
|
+
return !own(info, "sourceApplication") || typeof info.sourceApplication === "string" && /^[A-Za-z0-9_.-]{1,32}$/.test(info.sourceApplication);
|
|
219
|
+
}
|
|
220
|
+
function vtexPaymentsCardTarget(url) {
|
|
221
|
+
if (typeof url !== "string" || url.length > 8192)
|
|
222
|
+
return null;
|
|
223
|
+
let parsed;
|
|
224
|
+
try {
|
|
225
|
+
parsed = new URL(url);
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
return null;
|
|
229
|
+
}
|
|
230
|
+
if (parsed.href !== url || parsed.protocol !== "https:" || parsed.port || parsed.username || parsed.password || parsed.hash)
|
|
231
|
+
return null;
|
|
232
|
+
const path = PATH.exec(parsed.pathname);
|
|
233
|
+
const host = ACCOUNT_HOST.exec(parsed.hostname);
|
|
234
|
+
if (!path || !host)
|
|
235
|
+
return null;
|
|
236
|
+
const fallback = parsed.hostname === VTEX_PAYMENTS_FALLBACK_HOST;
|
|
237
|
+
const names = [...parsed.searchParams.keys()];
|
|
238
|
+
const expected = ["orderId", "deviceInfo", ...parsed.searchParams.has("callbackUrl") ? ["callbackUrl"] : [], ...fallback ? ["an"] : []];
|
|
239
|
+
if (names.length !== expected.length || names.some((name, i) => name !== expected[i]))
|
|
240
|
+
return null;
|
|
241
|
+
const orderId = parsed.searchParams.get("orderId");
|
|
242
|
+
if (!ORDER_GROUP.test(orderId) || !deviceInfoSound(parsed.searchParams.get("deviceInfo")))
|
|
243
|
+
return null;
|
|
244
|
+
if (parsed.searchParams.has("callbackUrl")) {
|
|
245
|
+
let callback;
|
|
246
|
+
try {
|
|
247
|
+
callback = new URL(parsed.searchParams.get("callbackUrl"));
|
|
248
|
+
}
|
|
249
|
+
catch {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
if (callback.protocol !== "https:" || callback.username || callback.password || callback.searchParams.get("step") !== "payment" || callback.searchParams.get("og") !== orderId)
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
const account = fallback ? parsed.searchParams.get("an") : host[1];
|
|
256
|
+
if (!/^[a-z0-9]{1,63}$/.test(account) || account === "api")
|
|
257
|
+
return null;
|
|
258
|
+
return Object.freeze({ account, transactionId: path[1], orderId, fallback });
|
|
259
|
+
}
|
|
260
|
+
function isVtexPaymentsCardUrl(url) {
|
|
261
|
+
const target = vtexPaymentsCardTarget(url);
|
|
262
|
+
return target !== null && !target.fallback;
|
|
263
|
+
}
|
|
264
|
+
function readBody(body) {
|
|
265
|
+
if (typeof body !== "string" || body === "" || body.length > BODY_LIMIT)
|
|
266
|
+
return null;
|
|
267
|
+
let value;
|
|
268
|
+
try {
|
|
269
|
+
value = JSON.parse(body);
|
|
270
|
+
if (!Array.isArray(value) || JSON.stringify(value) !== body)
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
return value;
|
|
277
|
+
}
|
|
278
|
+
function cardLine(line) {
|
|
279
|
+
if (!record(line))
|
|
280
|
+
return false;
|
|
281
|
+
const fields = record(line.fields) ? line.fields : {};
|
|
282
|
+
return line.groupName === "creditCardPaymentGroup" || line.groupName === "debitCardPaymentGroup" || own(line, "accountId") || own(fields, "accountId") || own(fields, "cardNumber") || own(fields, "validationCode") || own(fields, "dueDate");
|
|
283
|
+
}
|
|
284
|
+
function addressSound(address) {
|
|
285
|
+
if (!record(address) || !inOrder(address, VTEX_PAYMENTS_ADDRESS_KEYS))
|
|
286
|
+
return false;
|
|
287
|
+
for (const [key, value] of Object.entries(address)) {
|
|
288
|
+
if (key === "addressType") {
|
|
289
|
+
if (value !== "billing")
|
|
290
|
+
return false;
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
293
|
+
if (key === "addressId") {
|
|
294
|
+
if (!(typeof value === "string" && SHORT_ID.test(value)))
|
|
295
|
+
return false;
|
|
296
|
+
continue;
|
|
297
|
+
}
|
|
298
|
+
if (value === null && (key === "complement" || key === "reference"))
|
|
299
|
+
continue;
|
|
300
|
+
if (!(value === "" || plainText(value)))
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
return true;
|
|
304
|
+
}
|
|
305
|
+
function fieldsSound(fields) {
|
|
306
|
+
if (!record(fields) || !inOrder(fields, VTEX_PAYMENTS_FIELD_KEYS) || own(fields, "metadata"))
|
|
307
|
+
return false;
|
|
308
|
+
if (!(typeof fields.cardNumber === "string" && CARD_NUMBER.test(fields.cardNumber)))
|
|
309
|
+
return false;
|
|
310
|
+
if (!(typeof fields.validationCode === "string" && SECURITY_CODE.test(fields.validationCode)))
|
|
311
|
+
return false;
|
|
312
|
+
if (!(typeof fields.dueDate === "string" && DUE_DATE.test(fields.dueDate)))
|
|
313
|
+
return false;
|
|
314
|
+
if (!plainText(fields.holderName))
|
|
315
|
+
return false;
|
|
316
|
+
if (own(fields, "document") && !(fields.document === "" || plainText(fields.document) && fields.document.length <= 32))
|
|
317
|
+
return false;
|
|
318
|
+
if (own(fields, "address") && !addressSound(fields.address))
|
|
319
|
+
return false;
|
|
320
|
+
if (own(fields, "deviceFingerprint") && !(typeof fields.deviceFingerprint === "string" && FINGERPRINT.test(fields.deviceFingerprint)))
|
|
321
|
+
return false;
|
|
322
|
+
return !own(fields, "addressId") || typeof fields.addressId === "string" && SHORT_ID.test(fields.addressId);
|
|
323
|
+
}
|
|
324
|
+
function vtexPaymentsBodyVerdict(body, target) {
|
|
325
|
+
const lines = readBody(body);
|
|
326
|
+
if (lines === null || lines.length === 0 || !lines.every(record))
|
|
327
|
+
return refuse("vtex_payments_body_unsupported");
|
|
328
|
+
const cards = lines.filter(cardLine);
|
|
329
|
+
if (cards.some((line2) => own(line2, "accountId") || own(line2.fields ?? {}, "accountId")))
|
|
330
|
+
return refuse("vtex_payments_saved_card");
|
|
331
|
+
if (cards.length === 0)
|
|
332
|
+
return refuse("vtex_payments_body_unsupported");
|
|
333
|
+
if (lines.length !== 1 || own(lines[0], "id"))
|
|
334
|
+
return refuse("vtex_payments_split_payment");
|
|
335
|
+
const line = lines[0];
|
|
336
|
+
if (!inOrder(line, VTEX_PAYMENTS_LINE_KEYS) || line.groupName !== "creditCardPaymentGroup")
|
|
337
|
+
return refuse("vtex_payments_body_unsupported");
|
|
338
|
+
if (!(typeof line.currencyCode === "string" && CURRENCY.test(line.currencyCode)) || !own(VTEX_PAYMENTS_NETWORKS, line.paymentSystem) || !Number.isSafeInteger(line.paymentSystem) || !(count(line.value) && line.value > 0))
|
|
339
|
+
return refuse("vtex_payments_body_unsupported");
|
|
340
|
+
if (line.installments !== 1 || line.referenceValue !== line.value || own(line, "installmentsInterestRate") && line.installmentsInterestRate !== 0 || own(line, "installmentsValue") && line.installmentsValue !== line.value)
|
|
341
|
+
return refuse("vtex_payments_installments");
|
|
342
|
+
const transaction = line.transaction;
|
|
343
|
+
if (!record(transaction) || Object.keys(transaction).join() !== "id,merchantName" || !(typeof transaction.id === "string" && TRANSACTION_ID.test(transaction.id)) || !(typeof transaction.merchantName === "string" && MERCHANT_NAME.test(transaction.merchantName)))
|
|
344
|
+
return refuse("vtex_payments_body_unsupported");
|
|
345
|
+
if (target && transaction.id.toUpperCase() !== target.transactionId.toUpperCase())
|
|
346
|
+
return refuse("vtex_payments_split_payment");
|
|
347
|
+
return fieldsSound(line.fields) ? CARD : refuse("vtex_payments_body_unsupported");
|
|
348
|
+
}
|
|
349
|
+
function headerValue(headers, name) {
|
|
350
|
+
const found = Object.keys(headers).filter((key) => key.toLowerCase() === name);
|
|
351
|
+
if (found.length === 0)
|
|
352
|
+
return void 0;
|
|
353
|
+
return found.length === 1 && typeof headers[found[0]] === "string" ? headers[found[0]] : null;
|
|
354
|
+
}
|
|
355
|
+
function vtexPaymentsRequestRefusal(request) {
|
|
356
|
+
if (!record(request) || typeof request.method !== "string" || request.method.toUpperCase() !== "POST")
|
|
357
|
+
return "vtex_payments_url_refused";
|
|
358
|
+
const target = vtexPaymentsCardTarget(request.url);
|
|
359
|
+
if (target === null)
|
|
360
|
+
return "vtex_payments_url_refused";
|
|
361
|
+
if (target.fallback)
|
|
362
|
+
return "vtex_payments_fallback_refused";
|
|
363
|
+
const headers = record(request.headers) ? request.headers : {};
|
|
364
|
+
const contentType = headerValue(headers, "content-type");
|
|
365
|
+
if (typeof contentType !== "string" || !JSON_TYPE.test(contentType.trim()) || Object.keys(headers).length !== new Set(Object.keys(headers).map((key) => key.toLowerCase())).size) {
|
|
366
|
+
return "vtex_payments_headers_refused";
|
|
367
|
+
}
|
|
368
|
+
const verdict = vtexPaymentsBodyVerdict(request.body, target);
|
|
369
|
+
return verdict.verdict === "card" ? null : verdict.code;
|
|
370
|
+
}
|
|
371
|
+
function isPreparedVtexPaymentsRequest(url, method, body, environment, headers) {
|
|
372
|
+
return environment === "production" && typeof method === "string" && method.toUpperCase() === "POST" && vtexPaymentsRequestRefusal({ url, method: "POST", headers: record(headers) ? headers : {}, body }) === null;
|
|
373
|
+
}
|
|
374
|
+
function vtexPaymentsOriginPin(merchantOrigin, pins = VTEX_PAYMENTS_MERCHANT_PINS) {
|
|
375
|
+
return typeof merchantOrigin === "string" ? pins.find((pin) => pin.origin === merchantOrigin) ?? null : null;
|
|
376
|
+
}
|
|
377
|
+
function vtexPaymentsAccountPin(account, pins = VTEX_PAYMENTS_MERCHANT_PINS) {
|
|
378
|
+
return typeof account === "string" ? pins.find((pin) => pin.account === account) ?? null : null;
|
|
379
|
+
}
|
|
380
|
+
function linePinned(body, pin) {
|
|
381
|
+
if (vtexPaymentsBodyVerdict(body).verdict !== "card")
|
|
382
|
+
return false;
|
|
383
|
+
const [line] = JSON.parse(body);
|
|
384
|
+
return line.currencyCode === pin.currency && line.transaction.merchantName.toLowerCase() === pin.account;
|
|
385
|
+
}
|
|
386
|
+
function callbackPinned(url, pin) {
|
|
387
|
+
let callback;
|
|
388
|
+
try {
|
|
389
|
+
const parsed = new URL(url);
|
|
390
|
+
if (!parsed.searchParams.has("callbackUrl"))
|
|
391
|
+
return true;
|
|
392
|
+
callback = new URL(parsed.searchParams.get("callbackUrl"));
|
|
393
|
+
}
|
|
394
|
+
catch {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
return callback.origin === pin.origin;
|
|
398
|
+
}
|
|
399
|
+
function vtexPaymentsMerchantRefusal(merchantOrigin, request, pins = VTEX_PAYMENTS_MERCHANT_PINS) {
|
|
400
|
+
const pin = vtexPaymentsOriginPin(merchantOrigin, pins);
|
|
401
|
+
const target = record(request) ? vtexPaymentsCardTarget(request.url) : null;
|
|
402
|
+
return pin !== null && target !== null && !target.fallback && target.account === pin.account && linePinned(request.body, pin) && callbackPinned(request.url, pin) ? null : "vtex_payments_merchant_unreviewed";
|
|
403
|
+
}
|
|
404
|
+
function vtexPaymentsAmount(body) {
|
|
405
|
+
if (vtexPaymentsBodyVerdict(body).verdict !== "card")
|
|
406
|
+
return null;
|
|
407
|
+
const [line] = JSON.parse(body);
|
|
408
|
+
return { amountCents: line.value, currency: line.currencyCode.toLowerCase() };
|
|
409
|
+
}
|
|
410
|
+
var REFUSAL_MESSAGES = /* @__PURE__ */ Object.freeze({
|
|
411
|
+
vtex_payments_url_refused: "Refusing to pay: this VTEX card request does not go to the store's own VTEX payments address as the checkout sends it. Nothing was sent.",
|
|
412
|
+
vtex_payments_fallback_refused: "Refusing to pay: this VTEX card request is the checkout's resend to VTEX's shared host, which never takes the card. Nothing was sent.",
|
|
413
|
+
vtex_payments_headers_refused: "Refusing to pay: this VTEX card request does not carry the checkout's own headers. Nothing was sent.",
|
|
414
|
+
vtex_payments_saved_card: "Refusing to pay: this VTEX payment would charge a card the store keeps on file, not the card you chose. Nothing was sent.",
|
|
415
|
+
vtex_payments_split_payment: "Refusing to pay: this VTEX payment splits the price with a gift card, another card or another seller. Nothing was sent.",
|
|
416
|
+
vtex_payments_installments: "Refusing to pay: this VTEX payment is in installments or adds interest to the price. Nothing was sent.",
|
|
417
|
+
vtex_payments_body_unsupported: "Refusing to pay: this is not the card request of the store's VTEX checkout. Nothing was sent.",
|
|
418
|
+
vtex_payments_merchant_unreviewed: "Refusing to pay: this VTEX payment goes to a store Agentcard has not reviewed. Nothing was sent."
|
|
419
|
+
});
|
|
420
|
+
function vtexPaymentsRefusalMessage(code) {
|
|
421
|
+
return own(REFUSAL_MESSAGES, code) ? REFUSAL_MESSAGES[code] : REFUSAL_MESSAGES.vtex_payments_body_unsupported;
|
|
422
|
+
}
|
|
423
|
+
function vtexPaymentsDeviceRefusal(request) {
|
|
424
|
+
const refusal = vtexPaymentsRequestRefusal(request);
|
|
425
|
+
if (refusal)
|
|
426
|
+
return refusal;
|
|
427
|
+
const pin = vtexPaymentsAccountPin(vtexPaymentsCardTarget(request.url).account);
|
|
428
|
+
return pin !== null && linePinned(request.body, pin) && callbackPinned(request.url, pin) ? null : "vtex_payments_merchant_unreviewed";
|
|
429
|
+
}
|
|
430
|
+
var FILL_FAILED = "Could not fill the card fields for VTEX. Nothing was sent.";
|
|
431
|
+
var cardText = (value) => typeof value === "string" ? value : Number.isSafeInteger(value) ? String(value) : "";
|
|
432
|
+
var NETWORK_OF = Object.freeze({
|
|
433
|
+
visa: (number) => /^4[0-9]{12}(?:[0-9]{3}){0,2}$/.test(number),
|
|
434
|
+
mastercard: (number) => /^(?:5[1-5][0-9]{14}|2(?:2(?:2[1-9]|[3-9][0-9])|[3-6][0-9]{2}|7(?:[01][0-9]|20))[0-9]{12})$/.test(number),
|
|
435
|
+
amex: (number) => /^3[47][0-9]{13}$/.test(number),
|
|
436
|
+
discover: (number) => /^(?:6011[0-9]{12}|64[4-9][0-9]{13}|65[0-9]{14})$/.test(number)
|
|
437
|
+
});
|
|
438
|
+
var NETWORK_NAME = Object.freeze({ visa: "Visa", mastercard: "Mastercard", amex: "American Express", discover: "Discover" });
|
|
439
|
+
var whole = (value) => {
|
|
440
|
+
if (Number.isSafeInteger(value) && value >= 0)
|
|
441
|
+
return value;
|
|
442
|
+
return typeof value === "string" && /^[0-9]{1,4}$/.test(value) ? Number(value) : NaN;
|
|
443
|
+
};
|
|
444
|
+
function injectVtexPaymentsCard(body, card) {
|
|
445
|
+
const verdict = vtexPaymentsBodyVerdict(body);
|
|
446
|
+
if (verdict.verdict !== "card")
|
|
447
|
+
throw new Error(vtexPaymentsRefusalMessage(verdict.code));
|
|
448
|
+
const number = card ? cardText(card.number) : "";
|
|
449
|
+
const cvc = card ? cardText(card.cvc) : "";
|
|
450
|
+
const month = card ? whole(card.month) : NaN;
|
|
451
|
+
const rawYear = card ? whole(card.year) : NaN;
|
|
452
|
+
const year = rawYear >= 2e3 && rawYear <= 2099 ? rawYear - 2e3 : rawYear;
|
|
453
|
+
if (!CARD_NUMBER.test(number) || !SECURITY_CODE.test(cvc) || !(month >= 1 && month <= 12) || !(year >= 0 && year <= 99))
|
|
454
|
+
throw new Error(FILL_FAILED);
|
|
455
|
+
const lines = JSON.parse(body);
|
|
456
|
+
const network = VTEX_PAYMENTS_NETWORKS[lines[0].paymentSystem];
|
|
457
|
+
if (!NETWORK_OF[network](number)) {
|
|
458
|
+
throw new Error(`Refusing to pay: the store's checkout routes this payment as ${NETWORK_NAME[network]}, and the card you chose is not one. Nothing was sent.`);
|
|
459
|
+
}
|
|
460
|
+
if (cvc.length !== (network === "amex" ? 4 : 3))
|
|
461
|
+
throw new Error(FILL_FAILED);
|
|
462
|
+
const fields = lines[0].fields;
|
|
463
|
+
fields.cardNumber = number;
|
|
464
|
+
fields.validationCode = cvc;
|
|
465
|
+
fields.dueDate = `${String(month).padStart(2, "0")}/${String(year).padStart(2, "0")}`;
|
|
466
|
+
const where = ["fields.cardNumber", "fields.validationCode", "fields.dueDate"];
|
|
467
|
+
const name = card && typeof card.name === "string" ? card.name.trim() : "";
|
|
468
|
+
if (name && plainText(name)) {
|
|
469
|
+
fields.holderName = name;
|
|
470
|
+
where.push("fields.holderName");
|
|
471
|
+
}
|
|
472
|
+
return { body: JSON.stringify(lines), where };
|
|
473
|
+
}
|
|
474
|
+
var ANSWER_LIMIT = 65536;
|
|
475
|
+
var ERROR_CODE = /^[A-Za-z0-9_.-]{1,48}$/;
|
|
476
|
+
function vtexPaymentsRefusalCode(text) {
|
|
477
|
+
if (typeof text !== "string" || text === "" || text.length > ANSWER_LIMIT)
|
|
478
|
+
return null;
|
|
479
|
+
let answer;
|
|
480
|
+
try {
|
|
481
|
+
answer = JSON.parse(text);
|
|
482
|
+
}
|
|
483
|
+
catch {
|
|
484
|
+
return null;
|
|
485
|
+
}
|
|
486
|
+
const code = record(answer) && record(answer.error) ? answer.error.code : void 0;
|
|
487
|
+
return typeof code === "string" && ERROR_CODE.test(code) && !cardDigits(code) ? `vtex_payments_${code}` : null;
|
|
488
|
+
}
|
|
489
|
+
function vtexPaymentsAnswerOutcome(status, text) {
|
|
490
|
+
if (!Number.isInteger(status))
|
|
491
|
+
return { outcome: "unknown", reason: "vtex_payments_unconfirmed" };
|
|
492
|
+
if (status >= 500)
|
|
493
|
+
return { outcome: "unknown", reason: "server_error" };
|
|
494
|
+
if (status >= 400)
|
|
495
|
+
return { outcome: "refused", code: vtexPaymentsRefusalCode(text) ?? `http_${status}` };
|
|
496
|
+
if (status === 201 && (text === "" || text === void 0 || text === null))
|
|
497
|
+
return { outcome: "approved", body: "", pending: "processing" };
|
|
498
|
+
return { outcome: "unknown", reason: "vtex_payments_unconfirmed" };
|
|
499
|
+
}
|
|
500
|
+
var vtex_payments_default = /* @__PURE__ */ registerProcessor({
|
|
501
|
+
psp: VTEX_PAYMENTS_PSP,
|
|
502
|
+
definitions: [
|
|
503
|
+
{
|
|
504
|
+
psp: "vtex_payments",
|
|
505
|
+
// Ollie's card post to a VTEX account's own vault, as the header above reads it, and the fallback host, which
|
|
506
|
+
// the gate recognizes only to refuse, so the agent's placeholder never reaches it either. VTEX has no test host:
|
|
507
|
+
// every request is live. Prepared only: Ollie gives the post 12 seconds. Ships dark: served only to a client that
|
|
508
|
+
// declares `vtex_payments_card_payment`, on for Agentcard's own company alone (backend
|
|
509
|
+
// checkout-processor-gate.ts), and autopilot never sends it.
|
|
510
|
+
capability: "vtex_payments_card_payment",
|
|
511
|
+
match: "[a-z0-9-]{1,63}\\.vtexvault\\.com/api/payments/transactions/[A-Za-z0-9-]{1,64}/payments(?![\\w/.%-])",
|
|
512
|
+
hosts: ["^[a-z0-9-]{1,63}\\.vtexvault\\.com$"],
|
|
513
|
+
preparationRequired: true,
|
|
514
|
+
encoding: "json",
|
|
515
|
+
// Ollie's fetch sets the JSON content type alone. Origin, Referer and cookies never ride.
|
|
516
|
+
passthroughHeaders: [],
|
|
517
|
+
jsonCardFields: [[0, "fields", "cardNumber"]]
|
|
518
|
+
}
|
|
519
|
+
],
|
|
520
|
+
// Only the cardholder's device sends it, after a person approves; no reviewed list names vtex_payments.
|
|
521
|
+
refusedOperations: [VTEX_PAYMENTS_OPERATION],
|
|
522
|
+
// Not surveyed: VTEX names a payment's end only to the store's own API keys and at the gatewayCallback that follows.
|
|
523
|
+
settlementReadback: "not_surveyed",
|
|
524
|
+
exactUrl: isVtexPaymentsCardUrl,
|
|
525
|
+
bodyGate: (url, body) => {
|
|
526
|
+
if (url === void 0)
|
|
527
|
+
return vtexPaymentsBodyVerdict(body);
|
|
528
|
+
const target = vtexPaymentsCardTarget(url);
|
|
529
|
+
if (target === null)
|
|
530
|
+
return refuse("vtex_payments_url_refused");
|
|
531
|
+
return target.fallback ? refuse("vtex_payments_fallback_refused") : vtexPaymentsBodyVerdict(body, target);
|
|
532
|
+
},
|
|
533
|
+
amount: (template) => record(template) && isVtexPaymentsCardUrl(template.url) ? vtexPaymentsAmount(template.body) : null
|
|
534
|
+
});
|
|
535
|
+
var device = /* @__PURE__ */ registerDeviceRules(VTEX_PAYMENTS_PSP, {
|
|
536
|
+
deviceCheck: (request) => {
|
|
537
|
+
const refusal = vtexPaymentsDeviceRefusal(request);
|
|
538
|
+
return refusal ? vtexPaymentsRefusalMessage(refusal) : null;
|
|
539
|
+
},
|
|
540
|
+
fill: injectVtexPaymentsCard,
|
|
541
|
+
refusalCode: (text) => vtexPaymentsRefusalCode(text),
|
|
542
|
+
outcome: (status, text) => vtexPaymentsAnswerOutcome(status, text)
|
|
543
|
+
});
|
|
544
|
+
export { VTEX_PAYMENTS_ADDRESS_KEYS, VTEX_PAYMENTS_CAPABILITY, VTEX_PAYMENTS_FALLBACK_HOST, VTEX_PAYMENTS_FIELD_KEYS, VTEX_PAYMENTS_LINE_KEYS, VTEX_PAYMENTS_MERCHANT_PINS, VTEX_PAYMENTS_NETWORKS, VTEX_PAYMENTS_OPERATION, VTEX_PAYMENTS_PREPARATION_URL, VTEX_PAYMENTS_PSP, VTEX_PAYMENTS_REFUSAL_CODES, vtex_payments_default as default, device, injectVtexPaymentsCard, isPreparedVtexPaymentsRequest, isVtexPaymentsCardUrl, vtexPaymentsAccountPin, vtexPaymentsAmount, vtexPaymentsAnswerOutcome, vtexPaymentsBodyVerdict, vtexPaymentsCardTarget, vtexPaymentsDeviceRefusal, vtexPaymentsMerchantRefusal, vtexPaymentsOriginPin, vtexPaymentsRefusalCode, vtexPaymentsRefusalMessage, vtexPaymentsRequestRefusal };
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* missed event, and hands back the event typed by its `type`. WebCrypto only,
|
|
8
8
|
* so it runs wherever the client runs.
|
|
9
9
|
*/
|
|
10
|
-
import { type AuthorizationStatus, type Settlement, type TerminalReason } from './
|
|
10
|
+
import { type AuthorizationStatus, type Settlement, type TerminalReason } from './api-types.js';
|
|
11
11
|
/** The purchase events an endpoint receives, `checkout_authorization.*`. */
|
|
12
|
-
export declare const CHECKOUT_AUTHORIZATION_EVENT_TYPES: readonly ["checkout_authorization.created", "checkout_authorization.notified", "checkout_authorization.watched", "checkout_authorization.approved", "checkout_authorization.declined", "checkout_authorization.refused", "checkout_authorization.expired", "checkout_authorization.cancelled", "checkout_authorization.submitted", "checkout_authorization.submitted_on_device", "checkout_authorization.replay_started", "checkout_authorization.amount_mismatch", "checkout_authorization.duplicate_charge", "checkout_authorization.duplicate_guard_reported", "checkout_authorization.outcome_reported", "checkout_authorization.continuation_checked", "checkout_authorization.bank_check_started", "checkout_authorization.settled", "checkout_authorization.settlement_unconfirmed", "checkout_authorization.autopilot_dispatched", "checkout_authorization.autopilot_completed"
|
|
12
|
+
export declare const CHECKOUT_AUTHORIZATION_EVENT_TYPES: readonly ["checkout_authorization.created", "checkout_authorization.notified", "checkout_authorization.watched", "checkout_authorization.approved", "checkout_authorization.declined", "checkout_authorization.refused", "checkout_authorization.expired", "checkout_authorization.cancelled", "checkout_authorization.submitted", "checkout_authorization.submitted_on_device", "checkout_authorization.replay_started", "checkout_authorization.amount_mismatch", "checkout_authorization.duplicate_charge", "checkout_authorization.duplicate_guard_reported", "checkout_authorization.outcome_reported", "checkout_authorization.continuation_checked", "checkout_authorization.bank_check_started", "checkout_authorization.settled", "checkout_authorization.settlement_unconfirmed", "checkout_authorization.autopilot_dispatched", "checkout_authorization.autopilot_completed"];
|
|
13
13
|
export type CheckoutAuthorizationEventType = (typeof CHECKOUT_AUTHORIZATION_EVENT_TYPES)[number];
|
|
14
14
|
/** The Vault events, `vault.*`: a person connected, stored a card, added or used a passkey. */
|
|
15
15
|
export declare const VAULT_EVENT_TYPES: readonly ["vault.session_linked", "vault.card_stored", "vault.passkey_added", "vault.passkey_signin"];
|
package/dist/webhooks.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* missed event, and hands back the event typed by its `type`. WebCrypto only,
|
|
8
8
|
* so it runs wherever the client runs.
|
|
9
9
|
*/
|
|
10
|
-
import { AgentcardError } from './
|
|
10
|
+
import { AgentcardError } from './api-types.js';
|
|
11
11
|
/** The purchase events an endpoint receives, `checkout_authorization.*`. */
|
|
12
12
|
export const CHECKOUT_AUTHORIZATION_EVENT_TYPES = [
|
|
13
13
|
'checkout_authorization.created', 'checkout_authorization.notified', 'checkout_authorization.watched', 'checkout_authorization.approved',
|
|
@@ -16,7 +16,7 @@ export const CHECKOUT_AUTHORIZATION_EVENT_TYPES = [
|
|
|
16
16
|
'checkout_authorization.amount_mismatch', 'checkout_authorization.duplicate_charge', 'checkout_authorization.duplicate_guard_reported',
|
|
17
17
|
'checkout_authorization.outcome_reported', 'checkout_authorization.continuation_checked', 'checkout_authorization.bank_check_started',
|
|
18
18
|
'checkout_authorization.settled', 'checkout_authorization.settlement_unconfirmed',
|
|
19
|
-
'checkout_authorization.autopilot_dispatched', 'checkout_authorization.autopilot_completed',
|
|
19
|
+
'checkout_authorization.autopilot_dispatched', 'checkout_authorization.autopilot_completed',
|
|
20
20
|
];
|
|
21
21
|
/** The Vault events, `vault.*`: a person connected, stored a card, added or used a passkey. */
|
|
22
22
|
export const VAULT_EVENT_TYPES = ['vault.session_linked', 'vault.card_stored', 'vault.passkey_added', 'vault.passkey_signin'];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema_version": 1,
|
|
3
3
|
"catalog_version": "2026-09-15.1",
|
|
4
|
-
"catalog_sha256": "
|
|
4
|
+
"catalog_sha256": "d27bf03744adafed6b1e6731f61439bb410e90ab4937dcb279d3e5db46784784",
|
|
5
5
|
"baseline_version": "kernel-native-docs-2026-09-11.1",
|
|
6
6
|
"baseline_sha256": "d86722f49633d8223fccae54cd3d485df4375aee06aa156a273cc689b7c8507c",
|
|
7
7
|
"native_build": null,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-cards/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Agentcard's SDK: one client, Agentcard, with two modules. checkout pauses a browser purchase and pays it with the person's own card;
|
|
3
|
+
"version": "0.24.0",
|
|
4
|
+
"description": "Agentcard's SDK: one client, Agentcard, with two modules. checkout pauses a browser purchase and pays it with the person's own card; buy asks the Purchase API for a cart and places it. Card data never enters your process.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -24,16 +24,15 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"_comment_build": "The public SDK keeps zero runtime dependencies. Its build vendors deterministic metadata and substitution artifacts from the internal payment core (src/*.generated.ts)
|
|
28
|
-
"build": "node
|
|
27
|
+
"_comment_build": "The public SDK keeps zero runtime dependencies. Its build vendors deterministic metadata and substitution artifacts from the internal payment core (src/*.generated.ts) and the Kernel kit's inventory from the built catalog; git ignores every file it writes. TypeScript remains pinned. The build starts from an empty dist, so a module the source no longer has never reaches a packed tarball.",
|
|
28
|
+
"build": "node scripts/clean-dist.mjs && node ../payment-core/scripts/build.mjs && node scripts/generate-payment-core.mjs && node scripts/generate-url-masks.mjs && node scripts/generate-capabilities.mjs && node scripts/generate-agent-amount.mjs && npx -y -p typescript@5.9.3 tsc && node scripts/generate-preflight-contract.mjs && node scripts/generate-kernel-native-inventory.mjs",
|
|
29
29
|
"prepublishOnly": "pnpm build",
|
|
30
30
|
"_comment_test": "check:built runs first and names the command when a file the build generates (the copies in src/, the preflight contracts in dist/, the Kernel inventory) is missing or stale; verify:pack runs last, on the same dist.",
|
|
31
|
-
"check:built": "node scripts/generate-payment-core.mjs --check && node scripts/generate-
|
|
31
|
+
"check:built": "node scripts/generate-payment-core.mjs --check && node scripts/generate-url-masks.mjs --check && node scripts/generate-capabilities.mjs --check && node scripts/generate-agent-amount.mjs --check && node scripts/generate-preflight-contract.mjs --check && node scripts/generate-kernel-native-inventory.mjs --check",
|
|
32
32
|
"verify:pack": "node scripts/verify-pack.mjs",
|
|
33
|
-
"test": "npm run check:built && node test.mjs && node --test lifecycle.test.mjs merchant-abort.test.mjs preparation.test.mjs braintree.test.mjs pre-claim.test.mjs ekashu.test.mjs redsys.test.mjs quickpay.test.mjs paytrail.test.mjs paypal-hosted-fields.test.mjs paypal-card-forms.test.mjs cybersource-secure-acceptance.test.mjs ebanx.test.mjs payrexx.test.mjs payrexx-follow-ups.test.mjs payrexx-adapters.test.mjs autopilot.test.mjs stripe-checkout.test.mjs stripe-setup.test.mjs stripe-legacy-checkout.test.mjs payment-core.test.mjs prepared-processor.test.mjs merchant-hosted.test.mjs merchant-total.test.mjs sandbox-declaration.test.mjs minimum-delay.test.mjs paysafe.test.mjs wix-payments.test.mjs hipay.test.mjs openpay.test.mjs payu.test.mjs attachment.test.mjs worker-targets.test.mjs mercado-checkout.test.mjs mercado-polling.test.mjs amadeus.test.mjs pelecard.test.mjs aci.test.mjs primer.test.mjs payrails.test.mjs elavon-converge.test.mjs
|
|
33
|
+
"test": "npm run check:built && node test.mjs && node --test lifecycle.test.mjs merchant-abort.test.mjs preparation.test.mjs braintree.test.mjs pre-claim.test.mjs ekashu.test.mjs redsys.test.mjs quickpay.test.mjs paytrail.test.mjs paypal-hosted-fields.test.mjs paypal-card-forms.test.mjs cybersource-secure-acceptance.test.mjs ebanx.test.mjs payrexx.test.mjs payrexx-follow-ups.test.mjs payrexx-adapters.test.mjs nike-order.test.mjs nike-order-adapters.test.mjs autopilot.test.mjs stripe-checkout.test.mjs stripe-setup.test.mjs stripe-legacy-checkout.test.mjs payment-core.test.mjs prepared-processor.test.mjs merchant-hosted.test.mjs merchant-total.test.mjs sandbox-declaration.test.mjs minimum-delay.test.mjs paysafe.test.mjs wix-payments.test.mjs hipay.test.mjs openpay.test.mjs processout.test.mjs payu.test.mjs attachment.test.mjs worker-targets.test.mjs mercado-checkout.test.mjs mercado-polling.test.mjs amadeus.test.mjs pelecard.test.mjs aci.test.mjs primer.test.mjs payrails.test.mjs elavon-converge.test.mjs agentcard.test.mjs buy.test.mjs clean-dist.test.mjs approvals.test.mjs gmo.test.mjs cybersource-flex.test.mjs juspay-gate.test.mjs card-endpoint.test.mjs card-endpoint-fastspring.test.mjs card-endpoint-navigation.test.mjs merchant-session-probe.test.mjs datatrans.test.mjs authorize-net-dpm.test.mjs creditguard.test.mjs eprotect.test.mjs wspay.test.mjs shiji-sts.test.mjs worldline-mycheckout.test.mjs verifone.test.mjs gravy.test.mjs paddle-vgs.test.mjs sbps.test.mjs hold.test.mjs paddle-tokenex.test.mjs lyra.test.mjs gopay.test.mjs paygent.test.mjs twoc2p.test.mjs tap-payments.test.mjs pay-nl.test.mjs toast.test.mjs redact-url.test.mjs hosted-entry.test.mjs comgate.test.mjs przelewy24.test.mjs tokenex-iframe.test.mjs transbank.test.mjs sumup.test.mjs clover.test.mjs eximbay.test.mjs xendit.test.mjs omise.test.mjs fastspring.test.mjs amazon-payment-services.test.mjs barion.test.mjs paymob.test.mjs payu-latam.test.mjs nexi-checkout.test.mjs oceanpayment.test.mjs pin-payments.test.mjs payplug.test.mjs paymentwall.test.mjs vtex-payments.test.mjs vtex-payments-window.test.mjs iyzico.test.mjs usaepay.test.mjs && node --test preflight-package.test.mjs preflight-collector.test.mjs browser-tests.test.mjs && node --test kernel-native-qualification.test.mjs && node --test ../vault/scripts/recurly-validation/watch-duty-sdk-result.test.mjs && node scripts/verify-pack.mjs",
|
|
34
34
|
"test:browser": "node browser-tests.mjs",
|
|
35
35
|
"check:payment-core": "node scripts/generate-payment-core.mjs --check",
|
|
36
|
-
"check:voice-stream": "node scripts/generate-voice-stream.mjs --check",
|
|
37
36
|
"test:preflight": "node --test preflight-package.test.mjs preflight-collector.test.mjs kernel-native-qualification.test.mjs",
|
|
38
37
|
"test:preflight:browser": "node preflight-browser.test.mjs",
|
|
39
38
|
"pack:preview": "node scripts/pack-preflight-preview.mjs",
|
|
@@ -46,7 +45,6 @@
|
|
|
46
45
|
"browser-automation",
|
|
47
46
|
"pci",
|
|
48
47
|
"checkout",
|
|
49
|
-
"voice",
|
|
50
48
|
"agentcard"
|
|
51
49
|
],
|
|
52
50
|
"engines": {
|