@openrails/billing-ui 0.252.0 → 0.253.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 +13 -0
- package/README.md +15 -4
- package/dist/admin/context.d.ts +4 -4
- package/dist/admin/lib/api/endpoints.d.ts +2 -2
- package/dist/admin/lib/api/index.d.ts +1 -1
- package/dist/admin/lib/mutations.d.ts +1 -1
- package/dist/{admin-detail-DG-YaHhS.js → admin-detail-DAOjLNL9.js} +2 -2
- package/dist/admin-detail-DAOjLNL9.js.map +1 -0
- package/dist/{admin-orders-8XzHf7b-.js → admin-orders-DMSOum9t.js} +2 -2
- package/dist/admin-orders-DMSOum9t.js.map +1 -0
- package/dist/admin-utils-DnVY5fYd.js.map +1 -1
- package/dist/admin.js +2 -2
- package/dist/buy-button.d.ts +4 -1
- package/dist/cart.d.ts +4 -1
- package/dist/client/generated/error-codes.d.ts +1 -1
- package/dist/client/generated/routes.d.ts +4 -4
- package/dist/client/generated/wire.d.ts +8 -3
- package/dist/client/types.d.ts +13 -7
- package/dist/{client-imFR1UCe.js → client-Di2a3HGM.js} +4 -3
- package/dist/client-Di2a3HGM.js.map +1 -0
- package/dist/client.js +1 -1
- package/dist/components/platform-card-form.d.ts +8 -0
- package/dist/create-card-BEILS1VB-DeyyfyFD.js +140 -0
- package/dist/create-card-BEILS1VB-DeyyfyFD.js.map +1 -0
- package/dist/create-card-display-Dv5pcpzc-BWB6vzo2.js +166 -0
- package/dist/create-card-display-Dv5pcpzc-BWB6vzo2.js.map +1 -0
- package/dist/create-copy-button-CAYmfugS-qNapojfj.js +125 -0
- package/dist/create-copy-button-CAYmfugS-qNapojfj.js.map +1 -0
- package/dist/embedded-payment.d.ts +4 -1
- package/dist/fallbacks.d.ts +25 -0
- package/dist/{hooks-C9JkHcRt.js → hooks-Bx0aLyvy.js} +2 -2
- package/dist/{hooks-C9JkHcRt.js.map → hooks-Bx0aLyvy.js.map} +1 -1
- package/dist/index-rGw83t5v-BE6naeQR.js +1801 -0
- package/dist/index-rGw83t5v-BE6naeQR.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1128 -975
- package/dist/index.js.map +1 -1
- package/dist/order-payment.d.ts +8 -1
- package/dist/product-list.d.ts +4 -1
- package/dist/react.js +1 -1
- package/package.json +2 -1
- package/dist/admin-detail-DG-YaHhS.js.map +0 -1
- package/dist/admin-orders-8XzHf7b-.js.map +0 -1
- package/dist/client-imFR1UCe.js.map +0 -1
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s } from "./index-rGw83t5v-BE6naeQR.js";
|
|
2
|
+
//#region node_modules/.pnpm/@basis-theory+web-elements@3.2.0/node_modules/@basis-theory/web-elements/dist/create-card-BEILS1VB.js
|
|
3
|
+
var c = 400, l = () => document.featurePolicy?.features().includes("tools") ?? !1, u = (u, d, f = {}, p, m, h, g) => {
|
|
4
|
+
let _ = null, v = null, y = null, b = !1, x = null, S = null, C = new EventTarget(), w = p, T = "card", E = () => {
|
|
5
|
+
v && (S = e({
|
|
6
|
+
elementType: T,
|
|
7
|
+
elementId: w,
|
|
8
|
+
client: v,
|
|
9
|
+
eventTarget: C
|
|
10
|
+
}), S.setupSubscriptions());
|
|
11
|
+
}, D = (e) => ({
|
|
12
|
+
id: e,
|
|
13
|
+
type: "card",
|
|
14
|
+
get mounted() {
|
|
15
|
+
return b;
|
|
16
|
+
},
|
|
17
|
+
mount: () => {
|
|
18
|
+
throw o("Sub-field refs cannot be mounted independently");
|
|
19
|
+
},
|
|
20
|
+
unmount: () => {},
|
|
21
|
+
update: () => Promise.resolve(),
|
|
22
|
+
focus: () => {},
|
|
23
|
+
blur: () => {},
|
|
24
|
+
clear: () => {},
|
|
25
|
+
on: () => () => {}
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
id: w,
|
|
29
|
+
type: T,
|
|
30
|
+
get mounted() {
|
|
31
|
+
return b;
|
|
32
|
+
},
|
|
33
|
+
get loaded() {
|
|
34
|
+
return b;
|
|
35
|
+
},
|
|
36
|
+
number: D(`${w}__number`),
|
|
37
|
+
expiryDate: D(`${w}__expiry`),
|
|
38
|
+
cvc: D(`${w}__cvc`),
|
|
39
|
+
mount: async (e) => {
|
|
40
|
+
if (b) throw o("Element is already mounted");
|
|
41
|
+
if (x = typeof e == "string" ? document.querySelector(e) : e, !x) throw o(`Container not found: ${e}`);
|
|
42
|
+
let r = window.location.origin, i = new URL(`${d.elementsBaseUrl}/card.html`);
|
|
43
|
+
i.searchParams.set("parentOrigin", r), i.searchParams.set("elementId", w), i.searchParams.set("measurePerformance", String(d.measurePerformance || !1)), i.searchParams.set("debug", String(d.debug || !1)), _ = a({
|
|
44
|
+
src: i.toString(),
|
|
45
|
+
sandbox: "allow-scripts allow-same-origin",
|
|
46
|
+
title: f.ariaLabel || "Card Input",
|
|
47
|
+
...f.agentTools && l() && { allow: "payment *; tools" }
|
|
48
|
+
}), _.setAttribute("data-bt-element-id", w), _.setAttribute("data-theme-mode", d.themeMode || "auto"), v = t(_, {
|
|
49
|
+
targetOrigin: d.iframeOrigin,
|
|
50
|
+
timeout: d.timeoutMs,
|
|
51
|
+
retries: d.retryConfig.maxRetries,
|
|
52
|
+
debug: d.debug
|
|
53
|
+
}), y = s(), E();
|
|
54
|
+
let p = new Promise((e, t) => {
|
|
55
|
+
let n = setTimeout(() => {
|
|
56
|
+
t(o(`Iframe EVENT_READY not received within ${d.timeoutMs}ms`, w, {
|
|
57
|
+
elementType: T,
|
|
58
|
+
timeoutMs: d.timeoutMs
|
|
59
|
+
}));
|
|
60
|
+
}, d.timeoutMs);
|
|
61
|
+
C.addEventListener("ready", () => {
|
|
62
|
+
clearTimeout(n), e();
|
|
63
|
+
}, { once: !0 });
|
|
64
|
+
});
|
|
65
|
+
y.mount(x, _, { timeoutMs: d.timeoutMs }), b = !0;
|
|
66
|
+
try {
|
|
67
|
+
await m(), await p, await n({
|
|
68
|
+
elementId: w,
|
|
69
|
+
elementType: T,
|
|
70
|
+
client: v,
|
|
71
|
+
coordinatorRequest: g
|
|
72
|
+
}), await v.sendRequest("CMD_SET_CONFIG", {
|
|
73
|
+
elementId: w,
|
|
74
|
+
apiKey: u,
|
|
75
|
+
environment: d.environment,
|
|
76
|
+
apiTimeout: d.timeoutMs,
|
|
77
|
+
apiRetries: d.retryConfig.maxRetries,
|
|
78
|
+
theme: d.theme,
|
|
79
|
+
darkTheme: d.darkTheme,
|
|
80
|
+
themeMode: d.themeMode,
|
|
81
|
+
direction: d.direction,
|
|
82
|
+
language: d.language,
|
|
83
|
+
placeholder: f.placeholder,
|
|
84
|
+
...f.style !== void 0 && { style: f.style },
|
|
85
|
+
disabled: f.disabled,
|
|
86
|
+
readOnly: f.readOnly,
|
|
87
|
+
layout: f.layout || "auto",
|
|
88
|
+
stackAt: f.stackAt || c,
|
|
89
|
+
iconPosition: f.iconPosition || "left",
|
|
90
|
+
...f.cardBrands !== void 0 && { cardBrands: f.cardBrands },
|
|
91
|
+
...f.agentTools !== void 0 && { agentTools: f.agentTools },
|
|
92
|
+
...f.cvvRequired !== void 0 && { cvvRequired: f.cvvRequired },
|
|
93
|
+
...f.binLookup !== void 0 && { binLookup: f.binLookup },
|
|
94
|
+
...f.coBadge !== void 0 && { coBadge: f.coBadge },
|
|
95
|
+
...f.enterKeyHint !== void 0 && { enterKeyHint: f.enterKeyHint },
|
|
96
|
+
debug: d.debug
|
|
97
|
+
}), _ && (_.style.opacity = "1");
|
|
98
|
+
} catch (e) {
|
|
99
|
+
throw S && S.dispatchError("MOUNT_ERROR", e.message, e), b = !1, v &&= (v.destroy(), null), y && _ && (y.unmount(_), _ = null, y = null), S = null, x = null, e;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
unmount: () => {
|
|
103
|
+
if (!b) throw o("Element is not mounted");
|
|
104
|
+
h(w).catch((e) => {
|
|
105
|
+
r("Failed to notify coordinator of element unmount", { error: e.message });
|
|
106
|
+
}), v &&= (v.destroy(), null), y && _ && (y.unmount(_), _ = null, y = null), S = null, x = null, b = !1;
|
|
107
|
+
},
|
|
108
|
+
update: async (e) => {
|
|
109
|
+
if (!b || !v) throw o("Element must be mounted before updating");
|
|
110
|
+
let t = e, n = { elementId: w };
|
|
111
|
+
if (t.placeholder !== void 0 && (n.placeholder = t.placeholder), t.style !== void 0 && (n.style = t.style), t.disabled !== void 0 && (n.disabled = t.disabled), t.readOnly !== void 0 && (n.readOnly = t.readOnly), t.layout !== void 0 && (n.layout = t.layout), t.stackAt !== void 0 && (n.stackAt = t.stackAt), t.iconPosition !== void 0 && (n.iconPosition = t.iconPosition), t.cardBrands !== void 0 && (n.cardBrands = t.cardBrands), t.agentTools !== void 0) {
|
|
112
|
+
if (t.agentTools && !f.agentTools) throw i("agentTools must be set when the card element is created");
|
|
113
|
+
n.agentTools = t.agentTools;
|
|
114
|
+
}
|
|
115
|
+
if (t.cvvRequired !== void 0 && t.cvvRequired !== (f.cvvRequired ?? !0)) throw i("cvvRequired must be set when the card element is created");
|
|
116
|
+
t.binLookup !== void 0 && (n.binLookup = t.binLookup), t.coBadge !== void 0 && (n.coBadge = t.coBadge), "enterKeyHint" in t && (n.enterKeyHint = t.enterKeyHint), e.themeMode !== void 0 && (n.themeMode = e.themeMode, n.theme = d.theme, n.darkTheme = d.darkTheme), await v.sendRequest("CMD_UPDATE_CONFIG", n);
|
|
117
|
+
},
|
|
118
|
+
focus: () => {
|
|
119
|
+
if (!b || !v) throw o("Element must be mounted before focusing");
|
|
120
|
+
v.sendRequest("CMD_FOCUS", {});
|
|
121
|
+
},
|
|
122
|
+
blur: () => {
|
|
123
|
+
if (!b || !v) throw o("Element must be mounted before blurring");
|
|
124
|
+
v.sendRequest("CMD_BLUR", {});
|
|
125
|
+
},
|
|
126
|
+
clear: () => {
|
|
127
|
+
if (!b || !v) throw o("Element must be mounted before clearing");
|
|
128
|
+
v.sendRequest("CMD_CLEAR", {});
|
|
129
|
+
},
|
|
130
|
+
on: (e, t) => (C.addEventListener(e, t), () => C.removeEventListener(e, t)),
|
|
131
|
+
setNetwork: async (e) => {
|
|
132
|
+
if (!b || !v) throw o("Element must be mounted before setNetwork");
|
|
133
|
+
await v.sendRequest("CMD_SET_NETWORK", { network: e });
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
//#endregion
|
|
138
|
+
export { u as createCardElement };
|
|
139
|
+
|
|
140
|
+
//# sourceMappingURL=create-card-BEILS1VB-DeyyfyFD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-card-BEILS1VB-DeyyfyFD.js","names":[],"sources":["../node_modules/.pnpm/@basis-theory+web-elements@3.2.0/node_modules/@basis-theory/web-elements/dist/create-card-BEILS1VB.js"],"sourcesContent":["import { E as ElementError, c as createIframe, a as createPostMessageClient, b as bindCoordinatorPort, d as createEventDispatcher, C as ConfigurationError, l as log, e as createMounter } from \"./index-rGw83t5v.js\";\nconst DEFAULT_CARD_STACK_THRESHOLD = 400;\nconst supportsToolsPermission = () => {\n var _a;\n return ((_a = document.featurePolicy) == null ? void 0 : _a.features().includes(\"tools\")) ?? false;\n};\nconst createCardElement = (apiKey, sdkConfig, options = {}, coordinatorElementId, ensureCoordinatorReady, notifyCoordinatorElementUnmount, coordinatorRequest) => {\n let iframe = null;\n let client = null;\n let mounter = null;\n let isMounted = false;\n let container = null;\n let eventDispatcher = null;\n const eventTarget = new EventTarget();\n const id = coordinatorElementId;\n const type = \"card\";\n const setupEventListeners = () => {\n if (!client) {\n return;\n }\n eventDispatcher = createEventDispatcher({\n elementType: type,\n elementId: id,\n client,\n eventTarget\n });\n eventDispatcher.setupSubscriptions();\n };\n const createSubElementRef = (subId) => ({\n id: subId,\n type: \"card\",\n get mounted() {\n return isMounted;\n },\n mount: () => {\n throw ElementError(\"Sub-field refs cannot be mounted independently\");\n },\n unmount: () => {\n },\n update: () => Promise.resolve(),\n focus: () => {\n },\n blur: () => {\n },\n clear: () => {\n },\n on: () => () => {\n }\n });\n const numberRef = createSubElementRef(`${id}__number`);\n const expiryDateRef = createSubElementRef(`${id}__expiry`);\n const cvcRef = createSubElementRef(`${id}__cvc`);\n const cardElement = {\n id,\n type,\n get mounted() {\n return isMounted;\n },\n get loaded() {\n return isMounted;\n },\n // Sub-field references for tokenization\n number: numberRef,\n expiryDate: expiryDateRef,\n cvc: cvcRef,\n mount: async (selector) => {\n if (isMounted) {\n throw ElementError(\"Element is already mounted\");\n }\n container = typeof selector === \"string\" ? document.querySelector(selector) : selector;\n if (!container) {\n throw ElementError(`Container not found: ${selector}`);\n }\n const parentOrigin = window.location.origin;\n const iframeUrl = new URL(`${sdkConfig.elementsBaseUrl}/card.html`);\n iframeUrl.searchParams.set(\"parentOrigin\", parentOrigin);\n iframeUrl.searchParams.set(\"elementId\", id);\n iframeUrl.searchParams.set(\n \"measurePerformance\",\n String(sdkConfig.measurePerformance || false)\n );\n iframeUrl.searchParams.set(\"debug\", String(sdkConfig.debug || false));\n iframe = createIframe({\n src: iframeUrl.toString(),\n sandbox: \"allow-scripts allow-same-origin\",\n title: options.ariaLabel || \"Card Input\",\n // A cross-origin iframe can only register WebMCP tools when granted `tools`\n ...options.agentTools && supportsToolsPermission() && { allow: \"payment *; tools\" }\n });\n iframe.setAttribute(\"data-bt-element-id\", id);\n iframe.setAttribute(\"data-theme-mode\", sdkConfig.themeMode || \"auto\");\n client = createPostMessageClient(iframe, {\n targetOrigin: sdkConfig.iframeOrigin,\n timeout: sdkConfig.timeoutMs,\n retries: sdkConfig.retryConfig.maxRetries,\n debug: sdkConfig.debug\n });\n mounter = createMounter();\n setupEventListeners();\n const readyPromise = new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n reject(\n ElementError(\n `Iframe EVENT_READY not received within ${sdkConfig.timeoutMs}ms`,\n id,\n { elementType: type, timeoutMs: sdkConfig.timeoutMs }\n )\n );\n }, sdkConfig.timeoutMs);\n const handleReady = () => {\n clearTimeout(timeout);\n resolve();\n };\n eventTarget.addEventListener(\"ready\", handleReady, { once: true });\n });\n mounter.mount(container, iframe, {\n timeoutMs: sdkConfig.timeoutMs\n });\n isMounted = true;\n try {\n await ensureCoordinatorReady();\n await readyPromise;\n await bindCoordinatorPort({\n elementId: id,\n elementType: type,\n client,\n coordinatorRequest\n });\n await client.sendRequest(\"CMD_SET_CONFIG\", {\n elementId: id,\n apiKey,\n environment: sdkConfig.environment,\n apiTimeout: sdkConfig.timeoutMs,\n apiRetries: sdkConfig.retryConfig.maxRetries,\n theme: sdkConfig.theme,\n darkTheme: sdkConfig.darkTheme,\n themeMode: sdkConfig.themeMode,\n direction: sdkConfig.direction,\n language: sdkConfig.language,\n placeholder: options.placeholder,\n ...options.style !== void 0 && { style: options.style },\n disabled: options.disabled,\n readOnly: options.readOnly,\n layout: options.layout || \"auto\",\n stackAt: options.stackAt || DEFAULT_CARD_STACK_THRESHOLD,\n iconPosition: options.iconPosition || \"left\",\n ...options.cardBrands !== void 0 && { cardBrands: options.cardBrands },\n ...options.agentTools !== void 0 && { agentTools: options.agentTools },\n ...options.cvvRequired !== void 0 && { cvvRequired: options.cvvRequired },\n ...options.binLookup !== void 0 && { binLookup: options.binLookup },\n ...options.coBadge !== void 0 && { coBadge: options.coBadge },\n ...options.enterKeyHint !== void 0 && {\n enterKeyHint: options.enterKeyHint\n },\n debug: sdkConfig.debug\n });\n if (iframe) iframe.style.opacity = \"1\";\n } catch (error) {\n if (eventDispatcher) {\n eventDispatcher.dispatchError(\n \"MOUNT_ERROR\",\n error.message,\n error\n );\n }\n isMounted = false;\n if (client) {\n client.destroy();\n client = null;\n }\n if (mounter && iframe) {\n mounter.unmount(iframe);\n iframe = null;\n mounter = null;\n }\n eventDispatcher = null;\n container = null;\n throw error;\n }\n },\n unmount: () => {\n if (!isMounted) {\n throw ElementError(\"Element is not mounted\");\n }\n notifyCoordinatorElementUnmount(id).catch((error) => {\n log(\"Failed to notify coordinator of element unmount\", {\n error: error.message\n });\n });\n if (client) {\n client.destroy();\n client = null;\n }\n if (mounter && iframe) {\n mounter.unmount(iframe);\n iframe = null;\n mounter = null;\n }\n eventDispatcher = null;\n container = null;\n isMounted = false;\n },\n update: async (newOptions) => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before updating\");\n }\n const cardOptions = newOptions;\n const updatePayload = {\n elementId: id\n };\n if (cardOptions.placeholder !== void 0) {\n updatePayload.placeholder = cardOptions.placeholder;\n }\n if (cardOptions.style !== void 0) {\n updatePayload.style = cardOptions.style;\n }\n if (cardOptions.disabled !== void 0) {\n updatePayload.disabled = cardOptions.disabled;\n }\n if (cardOptions.readOnly !== void 0) {\n updatePayload.readOnly = cardOptions.readOnly;\n }\n if (cardOptions.layout !== void 0) {\n updatePayload.layout = cardOptions.layout;\n }\n if (cardOptions.stackAt !== void 0) {\n updatePayload.stackAt = cardOptions.stackAt;\n }\n if (cardOptions.iconPosition !== void 0) {\n updatePayload.iconPosition = cardOptions.iconPosition;\n }\n if (cardOptions.cardBrands !== void 0) {\n updatePayload.cardBrands = cardOptions.cardBrands;\n }\n if (cardOptions.agentTools !== void 0) {\n if (cardOptions.agentTools && !options.agentTools) {\n throw ConfigurationError(\n \"agentTools must be set when the card element is created\"\n );\n }\n updatePayload.agentTools = cardOptions.agentTools;\n }\n if (cardOptions.cvvRequired !== void 0 && cardOptions.cvvRequired !== (options.cvvRequired ?? true)) {\n throw ConfigurationError(\n \"cvvRequired must be set when the card element is created\"\n );\n }\n if (cardOptions.binLookup !== void 0) {\n updatePayload.binLookup = cardOptions.binLookup;\n }\n if (cardOptions.coBadge !== void 0) {\n updatePayload.coBadge = cardOptions.coBadge;\n }\n if (\"enterKeyHint\" in cardOptions) {\n updatePayload.enterKeyHint = cardOptions.enterKeyHint;\n }\n if (newOptions.themeMode !== void 0) {\n updatePayload.themeMode = newOptions.themeMode;\n updatePayload.theme = sdkConfig.theme;\n updatePayload.darkTheme = sdkConfig.darkTheme;\n }\n await client.sendRequest(\"CMD_UPDATE_CONFIG\", updatePayload);\n },\n focus: () => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before focusing\");\n }\n client.sendRequest(\"CMD_FOCUS\", {});\n },\n blur: () => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before blurring\");\n }\n client.sendRequest(\"CMD_BLUR\", {});\n },\n clear: () => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before clearing\");\n }\n client.sendRequest(\"CMD_CLEAR\", {});\n },\n on: (eventType, listener) => {\n eventTarget.addEventListener(\n eventType,\n listener\n );\n return () => eventTarget.removeEventListener(\n eventType,\n listener\n );\n },\n setNetwork: async (network) => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before setNetwork\");\n }\n await client.sendRequest(\"CMD_SET_NETWORK\", { network });\n }\n };\n return cardElement;\n};\nexport {\n createCardElement\n};\n"],"x_google_ignoreList":[0],"mappings":";;AACA,IAAM,IAA+B,KAC/B,UAEU,SAAS,eAAqC,SAAS,CAAC,CAAC,SAAS,OAAO,KAAM,IAEzF,KAAqB,GAAQ,GAAW,IAAU,CAAC,GAAG,GAAsB,GAAwB,GAAiC,MAAuB;CAChK,IAAI,IAAS,MACT,IAAS,MACT,IAAU,MACV,IAAY,IACZ,IAAY,MACZ,IAAkB,MAChB,IAAc,IAAI,YAAY,GAC9B,IAAK,GACL,IAAO,QACP,UAA4B;EAC3B,MAGL,IAAkB,EAAsB;GACtC,aAAa;GACb,WAAW;GACX;GACA;EACF,CAAC,GACD,EAAgB,mBAAmB;CACrC,GACM,KAAuB,OAAW;EACtC,IAAI;EACJ,MAAM;EACN,IAAI,UAAU;GACZ,OAAO;EACT;EACA,aAAa;GACX,MAAM,EAAa,gDAAgD;EACrE;EACA,eAAe,CACf;EACA,cAAc,QAAQ,QAAQ;EAC9B,aAAa,CACb;EACA,YAAY,CACZ;EACA,aAAa,CACb;EACA,gBAAgB,CAChB;CACF;CA0PA,OAAO;EArPL;EACA;EACA,IAAI,UAAU;GACZ,OAAO;EACT;EACA,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kB,MACpB,EAAc,eAAe,EAAY,eAEvC,EAAW,cAAc,KAAK,MAChC,EAAc,YAAY,EAAW,WACrC,EAAc,QAAQ,EAAU,OAChC,EAAc,YAAY,EAAU,YAEtC,MAAM,EAAO,YAAY,qBAAqB,CAAa;EAC7D;EACA,aAAa;GACX,IAAI,CAAC,KAAa,CAAC,GACjB,MAAM,EAAa,yCAAyC;GAE9D,EAAO,YAAY,aAAa,CAAC,CAAC;EACpC;EACA,YAAY;GACV,IAAI,CAAC,KAAa,CAAC,GACjB,MAAM,EAAa,yCAAyC;GAE9D,EAAO,YAAY,YAAY,CAAC,CAAC;EACnC;EACA,aAAa;GACX,IAAI,CAAC,KAAa,CAAC,GACjB,MAAM,EAAa,yCAAyC;GAE9D,EAAO,YAAY,aAAa,CAAC,CAAC;EACpC;EACA,KAAK,GAAW,OACd,EAAY,iBACV,GACA,CACF,SACa,EAAY,oBACvB,GACA,CACF;EAEF,YAAY,OAAO,MAAY;GAC7B,IAAI,CAAC,KAAa,CAAC,GACjB,MAAM,EAAa,2CAA2C;GAEhE,MAAM,EAAO,YAAY,mBAAmB,EAAE,WAAQ,CAAC;EACzD;CAEe;AACnB"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { c as e, i as t, l as n, n as r, o as i, r as a, s as o } from "./index-rGw83t5v-BE6naeQR.js";
|
|
2
|
+
//#region node_modules/.pnpm/@basis-theory+web-elements@3.2.0/node_modules/@basis-theory/web-elements/dist/create-card-display-Dv5pcpzc.js
|
|
3
|
+
var s = 3e4, c = (c, l, u, d, f, p, m) => {
|
|
4
|
+
if (!u.tokenId || typeof u.tokenId != "string") throw r("tokenId is required for cardDisplay element");
|
|
5
|
+
if (u.allowClipboard === !0 && !l.allowClipboard) throw r("cardDisplay clipboard access requires allowClipboard: true on BasisTheory() initialization.");
|
|
6
|
+
let h = null, g = null, _ = null, v = !1, y = !1, b = null, x = u.tokenId, S = new EventTarget(), C = d, w = "cardDisplay", T = (e, t) => {
|
|
7
|
+
S.dispatchEvent(new CustomEvent(e, { detail: {
|
|
8
|
+
elementType: w,
|
|
9
|
+
elementId: C,
|
|
10
|
+
timestamp: Date.now(),
|
|
11
|
+
...t
|
|
12
|
+
} }));
|
|
13
|
+
}, E = (e, t) => {
|
|
14
|
+
n("Failed to load display token", { error: t.message }), T("error", {
|
|
15
|
+
code: e,
|
|
16
|
+
message: t.message
|
|
17
|
+
});
|
|
18
|
+
}, D = async () => {
|
|
19
|
+
try {
|
|
20
|
+
await m("CMD_CLEAR_DISPLAY_SESSION", { elementId: C });
|
|
21
|
+
} catch (e) {
|
|
22
|
+
n("Failed to release display session", { error: e.message });
|
|
23
|
+
}
|
|
24
|
+
}, O = async (e) => {
|
|
25
|
+
if (!l.sessionAuthorizationUrl) {
|
|
26
|
+
E("SESSION_AUTHORIZATION_FAILED", r("sessionAuthorizationUrl is required to load cardDisplay data"));
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
let t;
|
|
30
|
+
try {
|
|
31
|
+
let n = await m("CMD_CREATE_DISPLAY_SESSION", {
|
|
32
|
+
tokenId: e,
|
|
33
|
+
elementId: C
|
|
34
|
+
});
|
|
35
|
+
if (!n?.nonce) return;
|
|
36
|
+
t = n.nonce;
|
|
37
|
+
} catch (e) {
|
|
38
|
+
E("SESSION_CREATION_FAILED", e);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let n = new AbortController(), i = setTimeout(() => n.abort(), s), o;
|
|
42
|
+
try {
|
|
43
|
+
o = await fetch(l.sessionAuthorizationUrl, {
|
|
44
|
+
method: "POST",
|
|
45
|
+
headers: { "Content-Type": "application/json" },
|
|
46
|
+
body: JSON.stringify({ nonce: t }),
|
|
47
|
+
signal: n.signal
|
|
48
|
+
});
|
|
49
|
+
} catch (e) {
|
|
50
|
+
await D(), E("NETWORK_ERROR", e);
|
|
51
|
+
return;
|
|
52
|
+
} finally {
|
|
53
|
+
clearTimeout(i);
|
|
54
|
+
}
|
|
55
|
+
if (!o.ok) {
|
|
56
|
+
await D(), E("SESSION_AUTHORIZATION_FAILED", a(`Session authorization failed: ${o.status} ${o.statusText}`, C));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
await m("CMD_RETRIEVE_DISPLAY_TOKEN", {
|
|
61
|
+
tokenId: e,
|
|
62
|
+
elementId: C
|
|
63
|
+
});
|
|
64
|
+
} catch (e) {
|
|
65
|
+
E("TOKEN_RETRIEVAL_FAILED", e);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
id: C,
|
|
70
|
+
type: w,
|
|
71
|
+
get mounted() {
|
|
72
|
+
return v;
|
|
73
|
+
},
|
|
74
|
+
get loaded() {
|
|
75
|
+
return y;
|
|
76
|
+
},
|
|
77
|
+
mount: async (n) => {
|
|
78
|
+
if (v) throw a("Element is already mounted", C);
|
|
79
|
+
if (b = typeof n == "string" ? document.querySelector(n) : n, !b) throw a(`Container not found: ${n}`);
|
|
80
|
+
let r = window.location.origin, s = new URL(`${l.elementsBaseUrl}/card-display.html`);
|
|
81
|
+
s.searchParams.set("parentOrigin", r), s.searchParams.set("elementId", C), s.searchParams.set("debug", String(l.debug || !1)), h = i({
|
|
82
|
+
src: s.toString(),
|
|
83
|
+
sandbox: "allow-scripts allow-same-origin",
|
|
84
|
+
allow: u.allowClipboard === !0 ? "clipboard-write" : "",
|
|
85
|
+
title: "Card Display"
|
|
86
|
+
}), h.setAttribute("data-bt-element-id", C), g = e(h, {
|
|
87
|
+
targetOrigin: l.iframeOrigin,
|
|
88
|
+
timeout: l.timeoutMs,
|
|
89
|
+
retries: l.retryConfig.maxRetries,
|
|
90
|
+
debug: l.debug
|
|
91
|
+
}), _ = o();
|
|
92
|
+
let c = new Promise((e, t) => {
|
|
93
|
+
let n = setTimeout(() => {
|
|
94
|
+
t(a(`Iframe EVENT_READY not received within ${l.timeoutMs}ms`, C, {
|
|
95
|
+
elementType: w,
|
|
96
|
+
timeoutMs: l.timeoutMs
|
|
97
|
+
}));
|
|
98
|
+
}, l.timeoutMs), r = g.subscribe("EVENT_READY", () => {
|
|
99
|
+
clearTimeout(n), r(), e();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
g.subscribe("EVENT_CHANGE", (e) => {
|
|
103
|
+
e.loaded && (y = !0), T("change", e);
|
|
104
|
+
}), g.subscribe("EVENT_ERROR", (e) => {
|
|
105
|
+
T("error", e);
|
|
106
|
+
}), g.subscribe("EVENT_CONTENT_HEIGHT", (e) => {
|
|
107
|
+
let t = e?.heightPx;
|
|
108
|
+
if (!h || typeof t != "number" || !Number.isFinite(t) || t <= 0) return;
|
|
109
|
+
let n = Math.ceil(t);
|
|
110
|
+
h.style.height = `${n}px`, T("resize", { height: n });
|
|
111
|
+
}), _.mount(b, h, { timeoutMs: l.timeoutMs }), v = !0;
|
|
112
|
+
try {
|
|
113
|
+
await f(), await c, await t({
|
|
114
|
+
elementId: C,
|
|
115
|
+
elementType: w,
|
|
116
|
+
client: g,
|
|
117
|
+
coordinatorRequest: m
|
|
118
|
+
}), await g.sendRequest("CMD_SET_CONFIG", {
|
|
119
|
+
elementId: C,
|
|
120
|
+
tokenId: x,
|
|
121
|
+
theme: l.theme,
|
|
122
|
+
darkTheme: l.darkTheme,
|
|
123
|
+
themeMode: l.themeMode,
|
|
124
|
+
direction: l.direction,
|
|
125
|
+
language: l.language,
|
|
126
|
+
number: u.number,
|
|
127
|
+
cvc: u.cvc,
|
|
128
|
+
expiration: u.expiration,
|
|
129
|
+
layout: u.layout,
|
|
130
|
+
fieldOrder: u.fieldOrder,
|
|
131
|
+
showToggle: u.showToggle,
|
|
132
|
+
allowClipboard: u.allowClipboard,
|
|
133
|
+
debug: l.debug
|
|
134
|
+
}), h && (h.style.opacity = "1"), T("ready", {}), x && O(x);
|
|
135
|
+
} catch (e) {
|
|
136
|
+
throw T("error", {
|
|
137
|
+
code: "MOUNT_ERROR",
|
|
138
|
+
message: e.message
|
|
139
|
+
}), v = !1, g &&= (g.destroy(), null), _ && h && (_.unmount(h), h = null, _ = null), b = null, e;
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
unmount: () => {
|
|
143
|
+
if (!v) throw a("Element is not mounted");
|
|
144
|
+
D(), p(C).catch((e) => {
|
|
145
|
+
n("Failed to notify coordinator of element unmount", { error: e.message });
|
|
146
|
+
}), g &&= (g.sendRequest("CMD_CLEAR", {}).catch((e) => {
|
|
147
|
+
n("Failed to send clear command", { error: e.message });
|
|
148
|
+
}), g.destroy(), null), _ && h && (_.unmount(h), h = null, _ = null), b = null, v = !1, y = !1;
|
|
149
|
+
},
|
|
150
|
+
update: async (e) => {
|
|
151
|
+
if (!v || !g) throw a("Element must be mounted before updating", C);
|
|
152
|
+
if (e.allowClipboard === !0 && !l.allowClipboard) throw r("cardDisplay clipboard access requires allowClipboard: true on BasisTheory() initialization.");
|
|
153
|
+
e.tokenId !== void 0 && e.tokenId !== x && (x = e.tokenId, y = !1, await g.sendRequest("CMD_CLEAR", {}), O(x));
|
|
154
|
+
let t = {};
|
|
155
|
+
e.number !== void 0 && (t.number = e.number), e.cvc !== void 0 && (t.cvc = e.cvc), e.expiration !== void 0 && (t.expiration = e.expiration), e.layout !== void 0 && (t.layout = e.layout), e.fieldOrder !== void 0 && (t.fieldOrder = e.fieldOrder), e.showToggle !== void 0 && (t.showToggle = e.showToggle), e.allowClipboard !== void 0 && (t.allowClipboard = e.allowClipboard, h?.setAttribute("allow", e.allowClipboard ? "clipboard-write" : "")), e.themeMode !== void 0 && (t.themeMode = e.themeMode, t.theme = l.theme, t.darkTheme = l.darkTheme), Object.keys(t).length > 0 && await g.sendRequest("CMD_UPDATE_CONFIG", t);
|
|
156
|
+
},
|
|
157
|
+
on: (e, t) => (S.addEventListener(e, t), () => S.removeEventListener(e, t)),
|
|
158
|
+
focus: () => {},
|
|
159
|
+
blur: () => {},
|
|
160
|
+
clear: () => {}
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
//#endregion
|
|
164
|
+
export { c as createCardDisplayElement };
|
|
165
|
+
|
|
166
|
+
//# sourceMappingURL=create-card-display-Dv5pcpzc-BWB6vzo2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-card-display-Dv5pcpzc-BWB6vzo2.js","names":[],"sources":["../node_modules/.pnpm/@basis-theory+web-elements@3.2.0/node_modules/@basis-theory/web-elements/dist/create-card-display-Dv5pcpzc.js"],"sourcesContent":["import { C as ConfigurationError, E as ElementError, c as createIframe, a as createPostMessageClient, b as bindCoordinatorPort, l as log, e as createMounter } from \"./index-rGw83t5v.js\";\nconst SESSION_AUTH_TIMEOUT_MS = 3e4;\nconst createCardDisplayElement = (_apiKey, sdkConfig, options, coordinatorElementId, ensureCoordinatorReady, notifyCoordinatorElementUnmount, coordinatorRequest) => {\n if (!options.tokenId || typeof options.tokenId !== \"string\") {\n throw ConfigurationError(\"tokenId is required for cardDisplay element\");\n }\n if (options.allowClipboard === true && !sdkConfig.allowClipboard) {\n throw ConfigurationError(\n \"cardDisplay clipboard access requires allowClipboard: true on BasisTheory() initialization.\"\n );\n }\n let iframe = null;\n let client = null;\n let mounter = null;\n let isMounted = false;\n let isLoaded = false;\n let container = null;\n let currentTokenId = options.tokenId;\n const eventTarget = new EventTarget();\n const id = coordinatorElementId;\n const type = \"cardDisplay\";\n const dispatchEvent = (eventType, detail) => {\n eventTarget.dispatchEvent(new CustomEvent(eventType, {\n detail: {\n elementType: type,\n elementId: id,\n timestamp: Date.now(),\n ...detail\n }\n }));\n };\n const dispatchLoadError = (code, error) => {\n log(\"Failed to load display token\", {\n error: error.message\n });\n dispatchEvent(\"error\", { code, message: error.message });\n };\n const releaseDisplaySession = async () => {\n try {\n await coordinatorRequest(\"CMD_CLEAR_DISPLAY_SESSION\", { elementId: id });\n } catch (error) {\n log(\"Failed to release display session\", {\n error: error.message\n });\n }\n };\n const loadDisplayToken = async (tokenId) => {\n if (!sdkConfig.sessionAuthorizationUrl) {\n dispatchLoadError(\n \"SESSION_AUTHORIZATION_FAILED\",\n ConfigurationError(\"sessionAuthorizationUrl is required to load cardDisplay data\")\n );\n return;\n }\n let nonce;\n try {\n const result = await coordinatorRequest(\n \"CMD_CREATE_DISPLAY_SESSION\",\n { tokenId, elementId: id }\n );\n if (!(result == null ? void 0 : result.nonce)) {\n return;\n }\n nonce = result.nonce;\n } catch (error) {\n dispatchLoadError(\"SESSION_CREATION_FAILED\", error);\n return;\n }\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), SESSION_AUTH_TIMEOUT_MS);\n let authResponse;\n try {\n authResponse = await fetch(sdkConfig.sessionAuthorizationUrl, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/json\" },\n // No credentials: the request only carries the session nonce, and\n // sending credentials is incompatible with a wildcard CORS origin\n // (Access-Control-Allow-Origin: *), which merchant authorize endpoints\n // commonly use.\n body: JSON.stringify({ nonce }),\n signal: controller.signal\n });\n } catch (error) {\n await releaseDisplaySession();\n dispatchLoadError(\"NETWORK_ERROR\", error);\n return;\n } finally {\n clearTimeout(timeout);\n }\n if (!authResponse.ok) {\n await releaseDisplaySession();\n dispatchLoadError(\n \"SESSION_AUTHORIZATION_FAILED\",\n ElementError(\n `Session authorization failed: ${authResponse.status} ${authResponse.statusText}`,\n id\n )\n );\n return;\n }\n try {\n await coordinatorRequest(\"CMD_RETRIEVE_DISPLAY_TOKEN\", {\n tokenId,\n elementId: id\n });\n } catch (error) {\n dispatchLoadError(\"TOKEN_RETRIEVAL_FAILED\", error);\n }\n };\n const element = {\n id,\n type,\n get mounted() {\n return isMounted;\n },\n get loaded() {\n return isLoaded;\n },\n mount: async (selector) => {\n if (isMounted) {\n throw ElementError(\"Element is already mounted\", id);\n }\n container = typeof selector === \"string\" ? document.querySelector(selector) : selector;\n if (!container) {\n throw ElementError(`Container not found: ${selector}`);\n }\n const parentOrigin = window.location.origin;\n const iframeUrl = new URL(`${sdkConfig.elementsBaseUrl}/card-display.html`);\n iframeUrl.searchParams.set(\"parentOrigin\", parentOrigin);\n iframeUrl.searchParams.set(\"elementId\", id);\n iframeUrl.searchParams.set(\"debug\", String(sdkConfig.debug || false));\n iframe = createIframe({\n src: iframeUrl.toString(),\n sandbox: \"allow-scripts allow-same-origin\",\n allow: options.allowClipboard === true ? \"clipboard-write\" : \"\",\n title: \"Card Display\"\n });\n iframe.setAttribute(\"data-bt-element-id\", id);\n client = createPostMessageClient(iframe, {\n targetOrigin: sdkConfig.iframeOrigin,\n timeout: sdkConfig.timeoutMs,\n retries: sdkConfig.retryConfig.maxRetries,\n debug: sdkConfig.debug\n });\n mounter = createMounter();\n const readyPromise = new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n reject(ElementError(\n `Iframe EVENT_READY not received within ${sdkConfig.timeoutMs}ms`,\n id,\n { elementType: type, timeoutMs: sdkConfig.timeoutMs }\n ));\n }, sdkConfig.timeoutMs);\n const unsubscribe = client.subscribe(\"EVENT_READY\", () => {\n clearTimeout(timeout);\n unsubscribe();\n resolve();\n });\n });\n client.subscribe(\"EVENT_CHANGE\", (payload) => {\n if (payload.loaded) {\n isLoaded = true;\n }\n dispatchEvent(\"change\", payload);\n });\n client.subscribe(\"EVENT_ERROR\", (payload) => {\n dispatchEvent(\"error\", payload);\n });\n client.subscribe(\"EVENT_CONTENT_HEIGHT\", (payload) => {\n const height = payload == null ? void 0 : payload.heightPx;\n if (!iframe || typeof height !== \"number\" || !Number.isFinite(height) || height <= 0) {\n return;\n }\n const roundedHeight = Math.ceil(height);\n iframe.style.height = `${roundedHeight}px`;\n dispatchEvent(\"resize\", { height: roundedHeight });\n });\n mounter.mount(container, iframe, {\n timeoutMs: sdkConfig.timeoutMs\n });\n isMounted = true;\n try {\n await ensureCoordinatorReady();\n await readyPromise;\n await bindCoordinatorPort({\n elementId: id,\n elementType: type,\n client,\n coordinatorRequest\n });\n await client.sendRequest(\"CMD_SET_CONFIG\", {\n elementId: id,\n tokenId: currentTokenId,\n theme: sdkConfig.theme,\n darkTheme: sdkConfig.darkTheme,\n themeMode: sdkConfig.themeMode,\n direction: sdkConfig.direction,\n language: sdkConfig.language,\n number: options.number,\n cvc: options.cvc,\n expiration: options.expiration,\n layout: options.layout,\n fieldOrder: options.fieldOrder,\n showToggle: options.showToggle,\n allowClipboard: options.allowClipboard,\n debug: sdkConfig.debug\n });\n if (iframe) iframe.style.opacity = \"1\";\n dispatchEvent(\"ready\", {});\n if (currentTokenId) {\n void loadDisplayToken(currentTokenId);\n }\n } catch (error) {\n dispatchEvent(\"error\", {\n code: \"MOUNT_ERROR\",\n message: error.message\n });\n isMounted = false;\n if (client) {\n client.destroy();\n client = null;\n }\n if (mounter && iframe) {\n mounter.unmount(iframe);\n iframe = null;\n mounter = null;\n }\n container = null;\n throw error;\n }\n },\n unmount: () => {\n if (!isMounted) {\n throw ElementError(\"Element is not mounted\");\n }\n void releaseDisplaySession();\n notifyCoordinatorElementUnmount(id).catch((error) => {\n log(\"Failed to notify coordinator of element unmount\", {\n error: error.message\n });\n });\n if (client) {\n client.sendRequest(\"CMD_CLEAR\", {}).catch((error) => {\n log(\"Failed to send clear command\", {\n error: error.message\n });\n });\n client.destroy();\n client = null;\n }\n if (mounter && iframe) {\n mounter.unmount(iframe);\n iframe = null;\n mounter = null;\n }\n container = null;\n isMounted = false;\n isLoaded = false;\n },\n update: async (newOptions) => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before updating\", id);\n }\n if (newOptions.allowClipboard === true && !sdkConfig.allowClipboard) {\n throw ConfigurationError(\n \"cardDisplay clipboard access requires allowClipboard: true on BasisTheory() initialization.\"\n );\n }\n if (newOptions.tokenId !== void 0 && newOptions.tokenId !== currentTokenId) {\n currentTokenId = newOptions.tokenId;\n isLoaded = false;\n await client.sendRequest(\"CMD_CLEAR\", {});\n void loadDisplayToken(currentTokenId);\n }\n const updatePayload = {};\n if (newOptions.number !== void 0) {\n updatePayload.number = newOptions.number;\n }\n if (newOptions.cvc !== void 0) {\n updatePayload.cvc = newOptions.cvc;\n }\n if (newOptions.expiration !== void 0) {\n updatePayload.expiration = newOptions.expiration;\n }\n if (newOptions.layout !== void 0) {\n updatePayload.layout = newOptions.layout;\n }\n if (newOptions.fieldOrder !== void 0) {\n updatePayload.fieldOrder = newOptions.fieldOrder;\n }\n if (newOptions.showToggle !== void 0) {\n updatePayload.showToggle = newOptions.showToggle;\n }\n if (newOptions.allowClipboard !== void 0) {\n updatePayload.allowClipboard = newOptions.allowClipboard;\n iframe == null ? void 0 : iframe.setAttribute(\"allow\", newOptions.allowClipboard ? \"clipboard-write\" : \"\");\n }\n if (newOptions.themeMode !== void 0) {\n updatePayload.themeMode = newOptions.themeMode;\n updatePayload.theme = sdkConfig.theme;\n updatePayload.darkTheme = sdkConfig.darkTheme;\n }\n if (Object.keys(updatePayload).length > 0) {\n await client.sendRequest(\"CMD_UPDATE_CONFIG\", updatePayload);\n }\n },\n on: (eventType, listener) => {\n eventTarget.addEventListener(\n eventType,\n listener\n );\n return () => eventTarget.removeEventListener(\n eventType,\n listener\n );\n },\n // No-ops for API compatibility with Element interface\n focus: () => {\n },\n blur: () => {\n },\n clear: () => {\n }\n };\n return element;\n};\nexport {\n createCardDisplayElement\n};\n"],"x_google_ignoreList":[0],"mappings":";;AACA,IAAM,IAA0B,KAC1B,KAA4B,GAAS,GAAW,GAAS,GAAsB,GAAwB,GAAiC,MAAuB;CACnK,IAAI,CAAC,EAAQ,WAAW,OAAO,EAAQ,WAAY,UACjD,MAAM,EAAmB,6CAA6C;CAExE,IAAI,EAAQ,mBAAmB,MAAQ,CAAC,EAAU,gBAChD,MAAM,EACJ,6FACF;CAEF,IAAI,IAAS,MACT,IAAS,MACT,IAAU,MACV,IAAY,IACZ,IAAW,IACX,IAAY,MACZ,IAAiB,EAAQ,SACvB,IAAc,IAAI,YAAY,GAC9B,IAAK,GACL,IAAO,eACP,KAAiB,GAAW,MAAW;EAC3C,EAAY,cAAc,IAAI,YAAY,GAAW,EACnD,QAAQ;GACN,aAAa;GACb,WAAW;GACX,WAAW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AAM,EAAO,YAAY,qBAAqB,CAAa;EAE/D;EACA,KAAK,GAAW,OACd,EAAY,iBACV,GACA,CACF,SACa,EAAY,oBACvB,GACA,CACF;EAGF,aAAa,CACb;EACA,YAAY,CACZ;EACA,aAAa,CACb;CAEW;AACf"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s } from "./index-rGw83t5v-BE6naeQR.js";
|
|
2
|
+
//#region node_modules/.pnpm/@basis-theory+web-elements@3.2.0/node_modules/@basis-theory/web-elements/dist/create-copy-button-CAYmfugS.js
|
|
3
|
+
var c = (c, l, u, d, f, p, m) => {
|
|
4
|
+
let h = u;
|
|
5
|
+
if (h?.allowClipboard !== !0) throw i("CopyButton requires allowClipboard: true. Clipboard access for raw card data may not be PCI compliant and must be explicitly enabled.", {
|
|
6
|
+
received: h?.allowClipboard,
|
|
7
|
+
expected: !0,
|
|
8
|
+
elementType: "copyButton"
|
|
9
|
+
});
|
|
10
|
+
if (!l.allowClipboard) throw i("CopyButton also requires allowClipboard: true on BasisTheory() initialization. The coordinator only honors copy references when clipboard access was enabled at init.", {
|
|
11
|
+
received: l.allowClipboard,
|
|
12
|
+
expected: !0,
|
|
13
|
+
elementType: "copyButton"
|
|
14
|
+
});
|
|
15
|
+
let g = null, _ = null, v = null, y = !1, b = null, x = null, S = new EventTarget(), C = d, w = "copyButton", T = () => {
|
|
16
|
+
_ && (x = e({
|
|
17
|
+
elementType: w,
|
|
18
|
+
elementId: C,
|
|
19
|
+
client: _,
|
|
20
|
+
eventTarget: S
|
|
21
|
+
}), x.setupSubscriptions(), _.subscribe("EVENT_COPY", (e) => {
|
|
22
|
+
let t = new CustomEvent("copy", { detail: {
|
|
23
|
+
elementType: w,
|
|
24
|
+
elementId: C,
|
|
25
|
+
timestamp: Date.now(),
|
|
26
|
+
success: e?.success ?? !1,
|
|
27
|
+
error: e?.error
|
|
28
|
+
} });
|
|
29
|
+
S.dispatchEvent(t);
|
|
30
|
+
}));
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
id: C,
|
|
34
|
+
type: w,
|
|
35
|
+
get mounted() {
|
|
36
|
+
return y;
|
|
37
|
+
},
|
|
38
|
+
get loaded() {
|
|
39
|
+
return y;
|
|
40
|
+
},
|
|
41
|
+
mount: async (e) => {
|
|
42
|
+
if (y) throw o("Element is already mounted", C);
|
|
43
|
+
if (b = typeof e == "string" ? document.querySelector(e) : e, !b) throw o(`Container not found: ${e}`);
|
|
44
|
+
let r = window.location.origin, i = new URL(`${l.elementsBaseUrl}/copy-button.html`);
|
|
45
|
+
i.searchParams.set("parentOrigin", r), i.searchParams.set("elementId", C), i.searchParams.set("measurePerformance", String(l.measurePerformance || !1)), i.searchParams.set("debug", String(l.debug || !1)), g = a({
|
|
46
|
+
src: i.toString(),
|
|
47
|
+
sandbox: "allow-scripts allow-same-origin",
|
|
48
|
+
allow: "clipboard-write",
|
|
49
|
+
title: "Copy Button"
|
|
50
|
+
}), g.setAttribute("data-bt-element-id", C), _ = t(g, {
|
|
51
|
+
targetOrigin: l.iframeOrigin,
|
|
52
|
+
timeout: l.timeoutMs,
|
|
53
|
+
retries: l.retryConfig.maxRetries,
|
|
54
|
+
debug: l.debug
|
|
55
|
+
}), v = s(), T();
|
|
56
|
+
let c = new Promise((e, t) => {
|
|
57
|
+
let n = setTimeout(() => {
|
|
58
|
+
t(o(`Iframe EVENT_READY not received within ${l.timeoutMs}ms`, C, {
|
|
59
|
+
elementType: w,
|
|
60
|
+
timeoutMs: l.timeoutMs
|
|
61
|
+
}));
|
|
62
|
+
}, l.timeoutMs);
|
|
63
|
+
S.addEventListener("ready", () => {
|
|
64
|
+
clearTimeout(n), e();
|
|
65
|
+
}, { once: !0 });
|
|
66
|
+
});
|
|
67
|
+
v.mount(b, g, { timeoutMs: l.timeoutMs }), y = !0;
|
|
68
|
+
try {
|
|
69
|
+
await f(), await c, await n({
|
|
70
|
+
elementId: C,
|
|
71
|
+
elementType: w,
|
|
72
|
+
client: _,
|
|
73
|
+
coordinatorRequest: m
|
|
74
|
+
}), await _.sendRequest("CMD_SET_CONFIG", {
|
|
75
|
+
elementId: C,
|
|
76
|
+
theme: l.theme,
|
|
77
|
+
darkTheme: l.darkTheme,
|
|
78
|
+
themeMode: l.themeMode,
|
|
79
|
+
direction: l.direction,
|
|
80
|
+
language: l.language,
|
|
81
|
+
text: h.text || "Copy",
|
|
82
|
+
value: h.value,
|
|
83
|
+
disabled: h.disabled,
|
|
84
|
+
debug: l.debug
|
|
85
|
+
}), g && (g.style.opacity = "1");
|
|
86
|
+
} catch (e) {
|
|
87
|
+
throw x && x.dispatchError("MOUNT_ERROR", e.message, e), y = !1, _ &&= (_.destroy(), null), v && g && (v.unmount(g), g = null, v = null), x = null, b = null, e;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
unmount: () => {
|
|
91
|
+
if (!y) throw o("Element is not mounted");
|
|
92
|
+
p(C).catch((e) => {
|
|
93
|
+
r("Failed to notify coordinator of element unmount", { error: e.message });
|
|
94
|
+
}), _ &&= (_.destroy(), null), v && g && (v.unmount(g), g = null, v = null), x = null, b = null, y = !1;
|
|
95
|
+
},
|
|
96
|
+
update: async (e) => {
|
|
97
|
+
if (!y || !_) throw o("Element must be mounted before updating", C);
|
|
98
|
+
let t = {}, n = e;
|
|
99
|
+
n.text !== void 0 && (t.text = n.text), n.value !== void 0 && (t.value = n.value), n.disabled !== void 0 && (t.disabled = n.disabled), e.themeMode !== void 0 && (t.themeMode = e.themeMode, t.theme = l.theme, t.darkTheme = l.darkTheme), await _.sendRequest("CMD_UPDATE_CONFIG", t);
|
|
100
|
+
},
|
|
101
|
+
focus: () => {
|
|
102
|
+
if (!y || !_) throw o("Element must be mounted before focusing", C);
|
|
103
|
+
_.sendRequest("CMD_FOCUS", {});
|
|
104
|
+
},
|
|
105
|
+
blur: () => {
|
|
106
|
+
if (!y || !_) throw o("Element must be mounted before blurring", C);
|
|
107
|
+
_.sendRequest("CMD_BLUR", {});
|
|
108
|
+
},
|
|
109
|
+
clear: () => {},
|
|
110
|
+
on: (e, t) => (S.addEventListener(e, t), () => S.removeEventListener(e, t)),
|
|
111
|
+
setValueRef: async (e) => {
|
|
112
|
+
if (r("setValueRef called", { refElementId: e?.id }), !e || !e.id) throw o("setValueRef requires a valid Element with an ID", C);
|
|
113
|
+
if (!y || !_) throw o("Element must be mounted before calling setValueRef", C);
|
|
114
|
+
let t = await m("CMD_SET_COPY_REFERENCE", {
|
|
115
|
+
elementId: C,
|
|
116
|
+
referenceElementId: e.id
|
|
117
|
+
});
|
|
118
|
+
if (!t?.success) throw o(`Coordinator rejected the copy reference (${t?.error ?? "UNKNOWN"})`, C);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
//#endregion
|
|
123
|
+
export { c as createCopyButtonElement };
|
|
124
|
+
|
|
125
|
+
//# sourceMappingURL=create-copy-button-CAYmfugS-qNapojfj.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-copy-button-CAYmfugS-qNapojfj.js","names":[],"sources":["../node_modules/.pnpm/@basis-theory+web-elements@3.2.0/node_modules/@basis-theory/web-elements/dist/create-copy-button-CAYmfugS.js"],"sourcesContent":["import { C as ConfigurationError, l as log, E as ElementError, c as createIframe, a as createPostMessageClient, b as bindCoordinatorPort, d as createEventDispatcher, e as createMounter } from \"./index-rGw83t5v.js\";\nconst createCopyButtonElement = (_apiKey, sdkConfig, inputOptions, coordinatorElementId, ensureCoordinatorReady, notifyCoordinatorElementUnmount, coordinatorRequest) => {\n const options = inputOptions;\n if ((options == null ? void 0 : options.allowClipboard) !== true) {\n throw ConfigurationError(\n \"CopyButton requires allowClipboard: true. Clipboard access for raw card data may not be PCI compliant and must be explicitly enabled.\",\n {\n received: options == null ? void 0 : options.allowClipboard,\n expected: true,\n elementType: \"copyButton\"\n }\n );\n }\n if (!sdkConfig.allowClipboard) {\n throw ConfigurationError(\n \"CopyButton also requires allowClipboard: true on BasisTheory() initialization. The coordinator only honors copy references when clipboard access was enabled at init.\",\n {\n received: sdkConfig.allowClipboard,\n expected: true,\n elementType: \"copyButton\"\n }\n );\n }\n let iframe = null;\n let client = null;\n let mounter = null;\n let isMounted = false;\n let container = null;\n let eventDispatcher = null;\n const eventTarget = new EventTarget();\n const id = coordinatorElementId;\n const type = \"copyButton\";\n const setupEventListeners = () => {\n if (!client) return;\n eventDispatcher = createEventDispatcher({\n elementType: type,\n elementId: id,\n client,\n eventTarget\n });\n eventDispatcher.setupSubscriptions();\n client.subscribe(\"EVENT_COPY\", (payload) => {\n const event = new CustomEvent(\"copy\", {\n detail: {\n elementType: type,\n elementId: id,\n timestamp: Date.now(),\n success: (payload == null ? void 0 : payload.success) ?? false,\n error: payload == null ? void 0 : payload.error\n }\n });\n eventTarget.dispatchEvent(event);\n });\n };\n const element = {\n id,\n type,\n get mounted() {\n return isMounted;\n },\n get loaded() {\n return isMounted;\n },\n mount: async (selector) => {\n if (isMounted) {\n throw ElementError(\"Element is already mounted\", id);\n }\n container = typeof selector === \"string\" ? document.querySelector(selector) : selector;\n if (!container) {\n throw ElementError(`Container not found: ${selector}`);\n }\n const parentOrigin = window.location.origin;\n const iframeUrl = new URL(`${sdkConfig.elementsBaseUrl}/copy-button.html`);\n iframeUrl.searchParams.set(\"parentOrigin\", parentOrigin);\n iframeUrl.searchParams.set(\"elementId\", id);\n iframeUrl.searchParams.set(\n \"measurePerformance\",\n String(sdkConfig.measurePerformance || false)\n );\n iframeUrl.searchParams.set(\"debug\", String(sdkConfig.debug || false));\n iframe = createIframe({\n src: iframeUrl.toString(),\n sandbox: \"allow-scripts allow-same-origin\",\n // clipboard-write is required for Firefox/Safari clipboard access in iframes\n allow: \"clipboard-write\",\n title: \"Copy Button\"\n });\n iframe.setAttribute(\"data-bt-element-id\", id);\n client = createPostMessageClient(iframe, {\n targetOrigin: sdkConfig.iframeOrigin,\n timeout: sdkConfig.timeoutMs,\n retries: sdkConfig.retryConfig.maxRetries,\n debug: sdkConfig.debug\n });\n mounter = createMounter();\n setupEventListeners();\n const readyPromise = new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n reject(\n ElementError(\n `Iframe EVENT_READY not received within ${sdkConfig.timeoutMs}ms`,\n id,\n { elementType: type, timeoutMs: sdkConfig.timeoutMs }\n )\n );\n }, sdkConfig.timeoutMs);\n const handleReady = () => {\n clearTimeout(timeout);\n resolve();\n };\n eventTarget.addEventListener(\"ready\", handleReady, { once: true });\n });\n mounter.mount(container, iframe, {\n timeoutMs: sdkConfig.timeoutMs\n });\n isMounted = true;\n try {\n await ensureCoordinatorReady();\n await readyPromise;\n await bindCoordinatorPort({\n elementId: id,\n elementType: type,\n client,\n coordinatorRequest\n });\n await client.sendRequest(\"CMD_SET_CONFIG\", {\n elementId: id,\n theme: sdkConfig.theme,\n darkTheme: sdkConfig.darkTheme,\n themeMode: sdkConfig.themeMode,\n direction: sdkConfig.direction,\n language: sdkConfig.language,\n text: options.text || \"Copy\",\n value: options.value,\n disabled: options.disabled,\n debug: sdkConfig.debug\n });\n if (iframe) iframe.style.opacity = \"1\";\n } catch (error) {\n if (eventDispatcher) {\n eventDispatcher.dispatchError(\n \"MOUNT_ERROR\",\n error.message,\n error\n );\n }\n isMounted = false;\n if (client) {\n client.destroy();\n client = null;\n }\n if (mounter && iframe) {\n mounter.unmount(iframe);\n iframe = null;\n mounter = null;\n }\n eventDispatcher = null;\n container = null;\n throw error;\n }\n },\n unmount: () => {\n if (!isMounted) {\n throw ElementError(\"Element is not mounted\");\n }\n notifyCoordinatorElementUnmount(id).catch((error) => {\n log(\"Failed to notify coordinator of element unmount\", {\n error: error.message\n });\n });\n if (client) {\n client.destroy();\n client = null;\n }\n if (mounter && iframe) {\n mounter.unmount(iframe);\n iframe = null;\n mounter = null;\n }\n eventDispatcher = null;\n container = null;\n isMounted = false;\n },\n update: async (newOptions) => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before updating\", id);\n }\n const updatePayload = {};\n const copyButtonOptions = newOptions;\n if (copyButtonOptions.text !== void 0) {\n updatePayload.text = copyButtonOptions.text;\n }\n if (copyButtonOptions.value !== void 0) {\n updatePayload.value = copyButtonOptions.value;\n }\n if (copyButtonOptions.disabled !== void 0) {\n updatePayload.disabled = copyButtonOptions.disabled;\n }\n if (newOptions.themeMode !== void 0) {\n updatePayload.themeMode = newOptions.themeMode;\n updatePayload.theme = sdkConfig.theme;\n updatePayload.darkTheme = sdkConfig.darkTheme;\n }\n await client.sendRequest(\"CMD_UPDATE_CONFIG\", updatePayload);\n },\n focus: () => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before focusing\", id);\n }\n client.sendRequest(\"CMD_FOCUS\", {});\n },\n blur: () => {\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before blurring\", id);\n }\n client.sendRequest(\"CMD_BLUR\", {});\n },\n // No-op for CopyButton (nothing to clear in a button)\n clear: () => {\n },\n on: (eventType, listener) => {\n eventTarget.addEventListener(\n eventType,\n listener\n );\n return () => eventTarget.removeEventListener(\n eventType,\n listener\n );\n },\n /**\n * Link this copy button to another element's value.\n *\n * Authorized by the coordinator, not the iframe: it checks both ids are ones\n * it registered, then forwards the value over this button's port.\n */\n setValueRef: async (refElement) => {\n log(\"setValueRef called\", {\n refElementId: refElement == null ? void 0 : refElement.id\n });\n if (!refElement || !refElement.id) {\n throw ElementError(\"setValueRef requires a valid Element with an ID\", id);\n }\n if (!isMounted || !client) {\n throw ElementError(\"Element must be mounted before calling setValueRef\", id);\n }\n const result = await coordinatorRequest(\n \"CMD_SET_COPY_REFERENCE\",\n { elementId: id, referenceElementId: refElement.id }\n );\n if (!(result == null ? void 0 : result.success)) {\n throw ElementError(\n `Coordinator rejected the copy reference (${(result == null ? void 0 : result.error) ?? \"UNKNOWN\"})`,\n id\n );\n }\n }\n };\n return element;\n};\nexport {\n createCopyButtonElement\n};\n"],"x_google_ignoreList":[0],"mappings":";;AACA,IAAM,KAA2B,GAAS,GAAW,GA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GAE1E,IAAI,CAAC,KAAa,CAAC,GACjB,MAAM,EAAa,sDAAsD,CAAE;GAE7E,IAAM,IAAS,MAAM,EACnB,0BACA;IAAE,WAAW;IAAI,oBAAoB,EAAW;GAAG,CACrD;GACA,IAAI,CAAE,GAAiC,SACrC,MAAM,EACJ,4CAA6C,GAAiC,SAAU,UAAU,IAClG,CACF;EAEJ;CAEW;AACf"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PaymentFallbacks } from './fallbacks';
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
/** The framed page's message once the order completes. */
|
|
3
4
|
export declare const PAYMENT_COMPLETE_MESSAGE = "openrails.payment.complete";
|
|
@@ -19,7 +20,9 @@ export interface EmbeddedPaymentProps {
|
|
|
19
20
|
* order's success_url, if it has one.
|
|
20
21
|
*/
|
|
21
22
|
onComplete?: (completion: EmbeddedPaymentCompletion) => void;
|
|
23
|
+
/** As OrderPayment's: the framed page keeps these PSPs back the same way. */
|
|
24
|
+
fallbacks?: PaymentFallbacks;
|
|
22
25
|
title?: string;
|
|
23
26
|
className?: string;
|
|
24
27
|
}
|
|
25
|
-
export declare function EmbeddedPayment({ url, onComplete, title, className, }: EmbeddedPaymentProps): React.JSX.Element | null;
|
|
28
|
+
export declare function EmbeddedPayment({ url, onComplete, fallbacks, title, className, }: EmbeddedPaymentProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Order } from './client/types';
|
|
2
|
+
import { PspConfig } from './psp';
|
|
3
|
+
/** A PSP kept back for others, named by key. */
|
|
4
|
+
export interface PaymentFallback {
|
|
5
|
+
/** The PSP keys it stands in for, e.g. `["mobius"]`. */
|
|
6
|
+
for: string[];
|
|
7
|
+
/** Failed attempts through them on the order, combined, that reveal it. */
|
|
8
|
+
afterFailures: number;
|
|
9
|
+
}
|
|
10
|
+
/** Fallback PSPs by key: `{ ccbill: { for: ["mobius"], afterFailures: 2 } }`. */
|
|
11
|
+
export type PaymentFallbacks = Record<string, PaymentFallback>;
|
|
12
|
+
type Option = Order["payment_options"][number];
|
|
13
|
+
/**
|
|
14
|
+
* The psp_ids of the options a fallback keeps back: one of its `for` PSPs is
|
|
15
|
+
* offered here and they have failed fewer than `afterFailures` times.
|
|
16
|
+
*/
|
|
17
|
+
export declare function hiddenFallbacks(fallbacks: PaymentFallbacks | undefined, options: Option[], psps: PspConfig[]): Set<string>;
|
|
18
|
+
/** The pay URL carrying fallbacks to the pay page in its fragment. */
|
|
19
|
+
export declare function withPaymentFallbacks(url: string, fallbacks?: PaymentFallbacks): string;
|
|
20
|
+
/** A pay URL fragment's secret and fallbacks; invalid fallbacks are dropped. */
|
|
21
|
+
export declare function readPaymentFragment(hash: string): {
|
|
22
|
+
secret: string | null;
|
|
23
|
+
fallbacks?: PaymentFallbacks;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as e, O as t, c as n, l as r, o as i, u as a } from "./client-
|
|
1
|
+
import { A as e, O as t, c as n, l as r, o as i, u as a } from "./client-Di2a3HGM.js";
|
|
2
2
|
import { en as o } from "./locales/en.js";
|
|
3
3
|
import { createContext as s, useCallback as c, useContext as l, useEffect as u, useMemo as d, useRef as f, useState as p, useSyncExternalStore as m } from "react";
|
|
4
4
|
import { jsx as h } from "react/jsx-runtime";
|
|
@@ -550,4 +550,4 @@ function ee(e = {}) {
|
|
|
550
550
|
//#endregion
|
|
551
551
|
export { E as _, U as a, b, L as c, z as d, P as f, O as g, j as h, K as i, I as l, A as m, ee as n, G as o, N as p, Z as r, W as s, Q as t, R as u, _ as v, y as x, g as y };
|
|
552
552
|
|
|
553
|
-
//# sourceMappingURL=hooks-
|
|
553
|
+
//# sourceMappingURL=hooks-Bx0aLyvy.js.map
|