@agent-cards/checkout 0.18.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.
Files changed (88) hide show
  1. package/README.md +6 -669
  2. package/cdp.d.ts +1 -0
  3. package/cdp.js +2 -0
  4. package/index.d.ts +1 -0
  5. package/index.js +2 -0
  6. package/package.json +33 -33
  7. package/playwright.d.ts +1 -0
  8. package/playwright.js +2 -0
  9. package/preflight.d.ts +1 -0
  10. package/preflight.js +2 -0
  11. package/CHANGELOG.md +0 -124
  12. package/PREFLIGHT.md +0 -308
  13. package/dist/adyen.generated.d.ts +0 -24
  14. package/dist/adyen.generated.js +0 -64
  15. package/dist/attachment.d.ts +0 -11
  16. package/dist/attachment.js +0 -50
  17. package/dist/braintree.d.ts +0 -2
  18. package/dist/braintree.generated.d.ts +0 -10
  19. package/dist/braintree.generated.js +0 -302
  20. package/dist/braintree.js +0 -2
  21. package/dist/builtin-registry.generated.d.ts +0 -2
  22. package/dist/builtin-registry.generated.js +0 -1
  23. package/dist/card-fields.generated.d.ts +0 -3
  24. package/dist/card-fields.generated.js +0 -46
  25. package/dist/cdp.d.ts +0 -189
  26. package/dist/cdp.js +0 -2194
  27. package/dist/checkout-com.generated.d.ts +0 -4
  28. package/dist/checkout-com.generated.js +0 -183
  29. package/dist/client.d.ts +0 -618
  30. package/dist/client.js +0 -1251
  31. package/dist/hosted-form.d.ts +0 -44
  32. package/dist/hosted-form.js +0 -78
  33. package/dist/index.d.ts +0 -13
  34. package/dist/index.js +0 -6
  35. package/dist/lifecycle.d.ts +0 -165
  36. package/dist/lifecycle.js +0 -370
  37. package/dist/mercado-checkout.d.ts +0 -20
  38. package/dist/mercado-checkout.generated.d.ts +0 -52
  39. package/dist/mercado-checkout.generated.js +0 -198
  40. package/dist/mercado-checkout.js +0 -108
  41. package/dist/owned-shop.generated.d.ts +0 -24
  42. package/dist/owned-shop.generated.js +0 -108
  43. package/dist/paysafe.generated.d.ts +0 -12
  44. package/dist/paysafe.generated.js +0 -87
  45. package/dist/playwright.d.ts +0 -3
  46. package/dist/playwright.js +0 -3
  47. package/dist/preflight-capabilities.generated.d.ts +0 -1253
  48. package/dist/preflight-capabilities.generated.js +0 -1929
  49. package/dist/preflight-catalog.json +0 -4595
  50. package/dist/preflight-playwright.d.ts +0 -34
  51. package/dist/preflight-playwright.js +0 -355
  52. package/dist/preflight-schemas.json +0 -1110
  53. package/dist/preflight.d.ts +0 -1
  54. package/dist/preflight.generated.d.ts +0 -1965
  55. package/dist/preflight.generated.js +0 -556
  56. package/dist/preflight.js +0 -2
  57. package/dist/preparation.d.ts +0 -31
  58. package/dist/preparation.js +0 -164
  59. package/dist/prepared-processor.d.ts +0 -10
  60. package/dist/prepared-processor.js +0 -122
  61. package/dist/recurly.generated.d.ts +0 -1
  62. package/dist/recurly.generated.js +0 -87
  63. package/dist/registry.d.ts +0 -76
  64. package/dist/registry.js +0 -296
  65. package/dist/spreedly.generated.d.ts +0 -10
  66. package/dist/spreedly.generated.js +0 -332
  67. package/dist/stripe-checkout.d.ts +0 -81
  68. package/dist/stripe-checkout.generated.d.ts +0 -82
  69. package/dist/stripe-checkout.generated.js +0 -1004
  70. package/dist/stripe-checkout.js +0 -140
  71. package/dist/substitute.d.ts +0 -38
  72. package/dist/substitute.js +0 -23
  73. package/dist/substitutions.generated.d.ts +0 -10
  74. package/dist/substitutions.generated.js +0 -66
  75. package/examples/existing-browser.mjs +0 -63
  76. package/examples/preflight/classify-direct.mjs +0 -21
  77. package/examples/preflight/classify-kernel.mjs +0 -30
  78. package/examples/preflight/inspect-browser.mjs +0 -44
  79. package/examples/preflight/kernel-native/README.md +0 -112
  80. package/examples/preflight/kernel-native/documented-adapters.json +0 -113
  81. package/examples/preflight/kernel-native/inventory.json +0 -233
  82. package/examples/preflight/kernel-native/qualification.mjs +0 -182
  83. package/examples/preflight/kernel-profile.empty.json +0 -11
  84. package/examples/preflight/mollie-hosted.observations.json +0 -23
  85. package/examples/preflight/mollie-hosted.result.json +0 -103
  86. package/examples/preflight/stripe-script.direct.result.json +0 -92
  87. package/examples/preflight/stripe-script.observations.json +0 -16
  88. package/examples/preflight/stripe-script.result.json +0 -87
@@ -1,4 +0,0 @@
1
- declare function checkoutComPreparationUrl(environment: any): any;
2
- declare function checkoutComEnvironment(url: any): "production" | "sandbox" | undefined;
3
- declare function isPreparedCheckoutComRequest(url: any, method: any, body: any, environment: any, headers: any): boolean;
4
- export { checkoutComEnvironment, checkoutComPreparationUrl, isPreparedCheckoutComRequest };
@@ -1,183 +0,0 @@
1
- // @ts-nocheck
2
- // Generated from @agent-cards/payment-core. Do not edit.
3
- // artifact-sha256: aaa2f76129db849a23bf8bb44043f5cff2b45e853b16b5de4d61a1f6a10cd392
4
- // src/checkout-com.js
5
- var ENDPOINTS = Object.freeze({
6
- production: ["https://api.checkout.com/tokens", "https://card-acquisition-gateway.checkout.com/tokens"],
7
- sandbox: ["https://api.sandbox.checkout.com/tokens", "https://card-acquisition-gateway.sandbox.checkout.com/tokens"]
8
- });
9
- var record = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
10
- var own = (value, name) => Object.prototype.hasOwnProperty.call(value, name);
11
- var keys = (value, allowed) => record(value) && Object.keys(value).every((name) => allowed.includes(name));
12
- var exact = (pattern, value) => typeof value === "string" && pattern.exec(value)?.[0] === value;
13
- var text = (value, max = 1024) => typeof value === "string" && value.length <= max && !/[\u0000-\u001f\u007f]/.test(value);
14
- var digits = (value, min, max) => typeof value === "string" && value.length >= min && value.length <= max && !/[^0-9]/.test(value);
15
- function readBody(body) {
16
- if (typeof body !== "string" || !body || body.length > 65536)
17
- return null;
18
- let at = 0, nodes = 0;
19
- const fail = () => {
20
- throw new Error("invalid_checkout_com_json");
21
- };
22
- const space = () => {
23
- while (" \r\n".includes(body[at] ?? "\0"))
24
- at++;
25
- };
26
- const string = () => {
27
- space();
28
- const start = at;
29
- if (body[at++] !== '"')
30
- fail();
31
- while (at < body.length) {
32
- const char = body[at++];
33
- if (char === "\\") {
34
- at++;
35
- continue;
36
- }
37
- if (char === '"')
38
- return JSON.parse(body.slice(start, at));
39
- }
40
- return fail();
41
- };
42
- const value = (depth) => {
43
- if (depth > 12 || ++nodes > 1e3)
44
- fail();
45
- space();
46
- const char = body[at];
47
- if (char === '"')
48
- return string();
49
- if (char === "{") {
50
- at++;
51
- const result = /* @__PURE__ */ Object.create(null), seen = /* @__PURE__ */ new Set();
52
- space();
53
- if (body[at] === "}") {
54
- at++;
55
- return result;
56
- }
57
- while (true) {
58
- const key = string();
59
- if (seen.has(key) || ["__proto__", "constructor", "prototype"].includes(key))
60
- fail();
61
- seen.add(key);
62
- space();
63
- if (body[at++] !== ":")
64
- fail();
65
- result[key] = value(depth + 1);
66
- space();
67
- const next = body[at++];
68
- if (next === "}")
69
- return result;
70
- if (next !== ",")
71
- fail();
72
- }
73
- }
74
- if (char === "[") {
75
- at++;
76
- const result = [];
77
- space();
78
- if (body[at] === "]") {
79
- at++;
80
- return result;
81
- }
82
- while (true) {
83
- result.push(value(depth + 1));
84
- space();
85
- const next = body[at++];
86
- if (next === "]")
87
- return result;
88
- if (next !== ",")
89
- fail();
90
- }
91
- }
92
- for (const literal of ["true", "false", "null"]) {
93
- if (body.startsWith(literal, at)) {
94
- at += literal.length;
95
- return JSON.parse(literal);
96
- }
97
- }
98
- const number = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/.exec(body.slice(at));
99
- if (!number)
100
- fail();
101
- at += number[0].length;
102
- const parsed = Number(number[0]);
103
- if (!Number.isFinite(parsed))
104
- fail();
105
- return parsed;
106
- };
107
- try {
108
- const parsed = value(0);
109
- space();
110
- return at === body.length && record(parsed) ? parsed : null;
111
- }
112
- catch {
113
- return null;
114
- }
115
- }
116
- function checkoutComPreparationUrl(environment) {
117
- if (environment !== "production" && environment !== "sandbox")
118
- throw new Error("unsupported_preparation_environment");
119
- return ENDPOINTS[environment][1];
120
- }
121
- function checkoutComEnvironment(url) {
122
- if (ENDPOINTS.production.includes(url))
123
- return "production";
124
- if (ENDPOINTS.sandbox.includes(url))
125
- return "sandbox";
126
- return void 0;
127
- }
128
- var ADDRESS_TEXT = ["address_line1", "address_line2", "city", "state", "zip", "name"];
129
- function billing(value) {
130
- if (!keys(value, [...ADDRESS_TEXT, "country", "phone"]) || ADDRESS_TEXT.some((key) => own(value, key) && !text(value[key])))
131
- return false;
132
- if (own(value, "country") && !exact(/^[A-Za-z]{2}$/, value.country))
133
- return false;
134
- return !own(value, "phone") || keys(value.phone, ["country_code", "number"]) && Object.values(value.phone).every((value2) => text(value2, 64));
135
- }
136
- function guestCard(value) {
137
- if (!keys(value, ["type", "number", "expiry_month", "expiry_year", "cvv", "name", "billing_address", "consumer_wallet"]) || value.type !== "card" || !digits(value.number, 12, 19) || !digits(value.cvv, 3, 4) || !Number.isInteger(value.expiry_month) || value.expiry_month < 1 || value.expiry_month > 12 || !Number.isInteger(value.expiry_year) || value.expiry_year < 2e3 || value.expiry_year > 9999 || own(value, "name") && !text(value.name) || own(value, "billing_address") && !billing(value.billing_address))
138
- return false;
139
- if (own(value, "consumer_wallet")) {
140
- const wallet = value.consumer_wallet;
141
- if (!keys(wallet, ["settings"]) || !keys(wallet.settings, ["preferred_locale"]) || !exact(/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8}){0,3}$/, wallet.settings.preferred_locale))
142
- return false;
143
- }
144
- return true;
145
- }
146
- var BROWSER_HEADERS = /* @__PURE__ */ new Set([
147
- "accept",
148
- "accept-language",
149
- "accept-encoding",
150
- "content-length",
151
- "origin",
152
- "referer",
153
- "user-agent",
154
- "host",
155
- "connection",
156
- "cache-control",
157
- "pragma",
158
- "priority",
159
- "dnt",
160
- "sec-fetch-dest",
161
- "sec-fetch-mode",
162
- "sec-fetch-site",
163
- "sec-fetch-user"
164
- ]);
165
- function guestHeaders(headers) {
166
- if (!record(headers))
167
- return false;
168
- const parsed = /* @__PURE__ */ new Map();
169
- let bytes = 0;
170
- for (const [name, value] of Object.entries(headers)) {
171
- const lower = name.toLowerCase();
172
- if (parsed.size >= 64 || parsed.has(lower) || !exact(/^[A-Za-z0-9-]+$/, name) || !text(value, 8192) || (bytes += name.length + value.length) > 32768)
173
- return false;
174
- if (!["content-type", "authorization"].includes(lower) && !BROWSER_HEADERS.has(lower) && !exact(/^sec-ch-ua(?:-[a-z0-9-]+)?$/, lower))
175
- return false;
176
- parsed.set(lower, value);
177
- }
178
- return exact(/^application\/json(?:;\s*charset=utf-8)?$/i, parsed.get("content-type")) && exact(/^(?:Bearer )?pk_[A-Za-z0-9_-]{1,256}\$?$/, parsed.get("authorization"));
179
- }
180
- function isPreparedCheckoutComRequest(url, method, body, environment, headers) {
181
- return (environment === "production" || environment === "sandbox") && method === "POST" && checkoutComEnvironment(url) === environment && guestHeaders(headers) && guestCard(readBody(body));
182
- }
183
- export { checkoutComEnvironment, checkoutComPreparationUrl, isPreparedCheckoutComRequest };