@amos.com/amos-js 0.10.2 → 0.10.3
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/dist/index.js +3 -3
- package/dist/index.mjs +324 -257
- package/dist/jwt.d.ts +4 -0
- package/dist/log.d.ts +12 -0
- package/dist/types.d.ts +10 -0
- package/package.json +1 -1
- package/src/jwt.ts +25 -0
- package/src/log.ts +74 -0
- package/src/messaging.ts +19 -0
- package/src/plaid-bank-ui.ts +11 -0
- package/src/types.ts +11 -0
package/dist/index.mjs
CHANGED
|
@@ -74,7 +74,13 @@ function r(e) {
|
|
|
74
74
|
signature: r
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
-
function i(
|
|
77
|
+
function i() {
|
|
78
|
+
if (typeof window > "u") return !1;
|
|
79
|
+
let { hostname: e } = window.location;
|
|
80
|
+
return e === "localhost" || e.endsWith(".localhost");
|
|
81
|
+
}
|
|
82
|
+
function a(e) {
|
|
83
|
+
if (i()) return "https://embed.localhost";
|
|
78
84
|
let { env: t = "sandbox" } = r(e).payload;
|
|
79
85
|
switch (t) {
|
|
80
86
|
case "production": return "https://embed.amos.com";
|
|
@@ -83,71 +89,108 @@ function i(e) {
|
|
|
83
89
|
}
|
|
84
90
|
}
|
|
85
91
|
//#endregion
|
|
86
|
-
//#region src/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
a.set(e, t);
|
|
90
|
-
}
|
|
91
|
-
function s(e) {
|
|
92
|
-
if (e) return a.get(e);
|
|
93
|
-
}
|
|
94
|
-
function c(e) {
|
|
95
|
-
e && a.delete(e);
|
|
92
|
+
//#region src/types.ts
|
|
93
|
+
function o(e) {
|
|
94
|
+
return e;
|
|
96
95
|
}
|
|
97
96
|
//#endregion
|
|
98
|
-
//#region src/
|
|
97
|
+
//#region src/log.ts
|
|
98
|
+
var s = /* @__PURE__ */ new Set([
|
|
99
|
+
"authorization",
|
|
100
|
+
"cookie",
|
|
101
|
+
"set-cookie",
|
|
102
|
+
"x-api-key"
|
|
103
|
+
]), c = /* @__PURE__ */ new Set([
|
|
104
|
+
"authorization",
|
|
105
|
+
"encrypted_account_number",
|
|
106
|
+
"link_token",
|
|
107
|
+
"public_token",
|
|
108
|
+
"token"
|
|
109
|
+
]);
|
|
99
110
|
function l(e) {
|
|
111
|
+
let t = {};
|
|
112
|
+
for (let [n, r] of Object.entries(e)) t[n] = s.has(n.toLowerCase()) ? "[REDACTED]" : r;
|
|
113
|
+
return t;
|
|
114
|
+
}
|
|
115
|
+
function u(e) {
|
|
116
|
+
if (Array.isArray(e)) return e.map(u);
|
|
117
|
+
if (typeof e == "object" && e) {
|
|
118
|
+
let t = {};
|
|
119
|
+
for (let [n, r] of Object.entries(e)) t[n] = c.has(n) ? "[REDACTED]" : u(r);
|
|
120
|
+
return t;
|
|
121
|
+
}
|
|
100
122
|
return e;
|
|
101
123
|
}
|
|
124
|
+
function d({ iframe: e, message: t, endpoint: n, headers: r = {}, body: i }) {
|
|
125
|
+
e.contentWindow?.postMessage(o({
|
|
126
|
+
type: "PARENT_INFO_LOG",
|
|
127
|
+
message: t,
|
|
128
|
+
endpoint: n,
|
|
129
|
+
headers: l(r),
|
|
130
|
+
body: u(i)
|
|
131
|
+
}), new URL(e.src).origin);
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/plaid-session.ts
|
|
135
|
+
var f = /* @__PURE__ */ new WeakMap();
|
|
136
|
+
function p(e, t) {
|
|
137
|
+
f.set(e, t);
|
|
138
|
+
}
|
|
139
|
+
function m(e) {
|
|
140
|
+
if (e) return f.get(e);
|
|
141
|
+
}
|
|
142
|
+
function h(e) {
|
|
143
|
+
e && f.delete(e);
|
|
144
|
+
}
|
|
102
145
|
//#endregion
|
|
103
146
|
//#region src/messaging.ts
|
|
104
|
-
function
|
|
147
|
+
function g(e) {
|
|
105
148
|
return new URL(e.src).origin;
|
|
106
149
|
}
|
|
107
|
-
function
|
|
108
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
150
|
+
function _(e) {
|
|
151
|
+
e?.contentWindow && e.contentWindow.postMessage(o({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), g(e));
|
|
109
152
|
}
|
|
110
|
-
function
|
|
111
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
153
|
+
function v({ iframe: e, appearance: t = {} }) {
|
|
154
|
+
e?.contentWindow && e.contentWindow.postMessage(o({
|
|
112
155
|
type: "UPDATE_APPEARANCE",
|
|
113
156
|
appearance: t
|
|
114
|
-
}),
|
|
157
|
+
}), g(e));
|
|
115
158
|
}
|
|
116
|
-
function
|
|
117
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
159
|
+
function y({ iframe: e, props: t, height: n }) {
|
|
160
|
+
e?.contentWindow && e.contentWindow.postMessage(o({
|
|
118
161
|
type: "UPDATE_APPLE_PAY_BUTTON",
|
|
119
162
|
height: n,
|
|
120
163
|
props: t
|
|
121
|
-
}),
|
|
164
|
+
}), g(e));
|
|
122
165
|
}
|
|
123
|
-
function
|
|
124
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
166
|
+
function b({ iframe: e, props: t, height: n }) {
|
|
167
|
+
e?.contentWindow && e.contentWindow.postMessage(o({
|
|
125
168
|
type: "UPDATE_GOOGLE_PAY_BUTTON",
|
|
126
169
|
height: n,
|
|
127
170
|
props: t
|
|
128
|
-
}),
|
|
171
|
+
}), g(e));
|
|
129
172
|
}
|
|
130
|
-
function
|
|
131
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
173
|
+
function x({ iframe: e, amount: t }) {
|
|
174
|
+
e?.contentWindow && e.contentWindow.postMessage(o({
|
|
132
175
|
type: "UPDATE_AMOUNT",
|
|
133
176
|
amount: t
|
|
134
|
-
}),
|
|
177
|
+
}), g(e));
|
|
135
178
|
}
|
|
136
|
-
function
|
|
137
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
179
|
+
function S({ iframe: e, merchantName: t }) {
|
|
180
|
+
e?.contentWindow && e.contentWindow.postMessage(o({
|
|
138
181
|
type: "UPDATE_MERCHANT_NAME",
|
|
139
182
|
merchantName: t
|
|
140
|
-
}),
|
|
183
|
+
}), g(e));
|
|
141
184
|
}
|
|
142
|
-
function
|
|
143
|
-
let t =
|
|
185
|
+
function C({ iframe: e }) {
|
|
186
|
+
let t = m(e);
|
|
144
187
|
if (t?.requiresVerification) return Promise.resolve(!!t.plaid);
|
|
145
188
|
let n = crypto.randomUUID();
|
|
146
189
|
return new Promise((t) => {
|
|
147
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
190
|
+
e?.contentWindow && e.contentWindow.postMessage(o({
|
|
148
191
|
type: "VALIDATE_FORM",
|
|
149
192
|
requestId: n
|
|
150
|
-
}),
|
|
193
|
+
}), g(e));
|
|
151
194
|
let r = setTimeout(() => {
|
|
152
195
|
window.removeEventListener("message", i), t(!1);
|
|
153
196
|
}, 5e3);
|
|
@@ -157,7 +200,7 @@ function _({ iframe: e }) {
|
|
|
157
200
|
window.addEventListener("message", i);
|
|
158
201
|
});
|
|
159
202
|
}
|
|
160
|
-
var
|
|
203
|
+
var w = 1e4;
|
|
161
204
|
function ee({ iframe: e }) {
|
|
162
205
|
let t = crypto.randomUUID();
|
|
163
206
|
return new Promise((n, r) => {
|
|
@@ -166,96 +209,111 @@ function ee({ iframe: e }) {
|
|
|
166
209
|
return;
|
|
167
210
|
}
|
|
168
211
|
let i = e.contentWindow;
|
|
169
|
-
i.postMessage(
|
|
212
|
+
i.postMessage(o({
|
|
170
213
|
type: "CREATE_PLAID_LINK_TOKEN",
|
|
171
214
|
requestId: t
|
|
172
|
-
}),
|
|
215
|
+
}), g(e));
|
|
173
216
|
let a = setTimeout(() => {
|
|
174
|
-
window.removeEventListener("message",
|
|
175
|
-
},
|
|
176
|
-
function
|
|
217
|
+
window.removeEventListener("message", s), r(/* @__PURE__ */ Error("Timed out waiting for Plaid Link token."));
|
|
218
|
+
}, w);
|
|
219
|
+
function s(e) {
|
|
177
220
|
if (e.source === i && e.data.type === "PLAID_LINK_TOKEN" && e.data.requestId === t) {
|
|
178
|
-
if (window.removeEventListener("message",
|
|
221
|
+
if (window.removeEventListener("message", s), clearTimeout(a), e.data.link_token) {
|
|
179
222
|
n(e.data.link_token);
|
|
180
223
|
return;
|
|
181
224
|
}
|
|
182
225
|
r(Error(e.data.error ?? "Could not create Plaid Link token."));
|
|
183
226
|
}
|
|
184
227
|
}
|
|
185
|
-
window.addEventListener("message",
|
|
228
|
+
window.addEventListener("message", s);
|
|
186
229
|
});
|
|
187
230
|
}
|
|
188
|
-
function
|
|
189
|
-
|
|
231
|
+
function T({ iframe: e }) {
|
|
232
|
+
m(e)?.clearLinked?.(), E(e);
|
|
190
233
|
}
|
|
191
|
-
function
|
|
192
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
234
|
+
function E(e) {
|
|
235
|
+
e?.contentWindow && e.contentWindow.postMessage(o({ type: "RESET_FORM" }), g(e));
|
|
193
236
|
}
|
|
194
|
-
function
|
|
195
|
-
let i =
|
|
196
|
-
i?.requiresVerification && !a &&
|
|
237
|
+
function D({ iframe: e, type: t, token: n, id: r }) {
|
|
238
|
+
let i = m(e), a = i?.plaid;
|
|
239
|
+
i?.requiresVerification && !a && E(e);
|
|
240
|
+
let s = g(e);
|
|
241
|
+
d({
|
|
242
|
+
iframe: e,
|
|
243
|
+
message: t === "CONFIRM_PAYMENT_INTENT" ? "confirmPaymentIntent" : "confirmSetupIntent",
|
|
244
|
+
endpoint: t === "CONFIRM_PAYMENT_INTENT" ? "POST /embed/payment_intents/{id}/confirm_with_payment_method" : "POST /embed/setup_intents/{id}/confirm_with_payment_method",
|
|
245
|
+
headers: {
|
|
246
|
+
origin: window.location.origin,
|
|
247
|
+
"iframe-origin": s
|
|
248
|
+
},
|
|
249
|
+
body: {
|
|
250
|
+
id: r,
|
|
251
|
+
token: n,
|
|
252
|
+
...a ? { plaid: a } : {}
|
|
253
|
+
}
|
|
254
|
+
}), e.contentWindow?.postMessage(o({
|
|
197
255
|
type: t,
|
|
198
256
|
token: n,
|
|
199
257
|
id: r,
|
|
200
258
|
...a ? { plaid: a } : {}
|
|
201
|
-
}),
|
|
259
|
+
}), g(e));
|
|
202
260
|
}
|
|
203
|
-
function
|
|
261
|
+
function O({ iframe: e, token: t }) {
|
|
204
262
|
if (!e?.contentWindow) return;
|
|
205
263
|
let { payment_intent_id: n } = r(t).payload;
|
|
206
|
-
|
|
264
|
+
D({
|
|
207
265
|
iframe: e,
|
|
208
266
|
type: "CONFIRM_PAYMENT_INTENT",
|
|
209
267
|
token: t,
|
|
210
268
|
id: n ?? void 0
|
|
211
269
|
});
|
|
212
270
|
}
|
|
213
|
-
function
|
|
271
|
+
function k({ iframe: e, token: t }) {
|
|
214
272
|
if (!e?.contentWindow) return;
|
|
215
273
|
let { setup_intent_id: n } = r(t).payload;
|
|
216
|
-
|
|
274
|
+
D({
|
|
217
275
|
iframe: e,
|
|
218
276
|
type: "CONFIRM_SETUP_INTENT",
|
|
219
277
|
token: t,
|
|
220
278
|
id: n ?? void 0
|
|
221
279
|
});
|
|
222
280
|
}
|
|
223
|
-
function
|
|
224
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
281
|
+
function A({ iframe: e, result: t }) {
|
|
282
|
+
e?.contentWindow && e.contentWindow.postMessage(o({
|
|
225
283
|
type: "CONFIRMATION_RESULT",
|
|
226
284
|
result: t
|
|
227
|
-
}),
|
|
285
|
+
}), g(e));
|
|
228
286
|
}
|
|
229
287
|
//#endregion
|
|
230
288
|
//#region src/apple-pay.ts
|
|
231
|
-
function
|
|
232
|
-
return `${
|
|
289
|
+
function te(e) {
|
|
290
|
+
return `${a(e)}/iframe/apple-pay?token=${e}`;
|
|
233
291
|
}
|
|
234
|
-
function
|
|
292
|
+
function j() {
|
|
235
293
|
return "48px";
|
|
236
294
|
}
|
|
237
|
-
function
|
|
238
|
-
e.contentWindow?.postMessage(
|
|
295
|
+
function ne(e) {
|
|
296
|
+
e.contentWindow?.postMessage(o({ type: "APPLE_PAY_CANCEL" }), g(e));
|
|
239
297
|
}
|
|
240
|
-
function
|
|
298
|
+
function M(e, { height: r = "48px", ...i }) {
|
|
241
299
|
let a = {
|
|
242
300
|
...i,
|
|
243
301
|
height: r
|
|
244
302
|
};
|
|
245
303
|
function o() {
|
|
246
|
-
|
|
304
|
+
x({
|
|
247
305
|
iframe: e,
|
|
248
306
|
amount: a.amount
|
|
249
307
|
});
|
|
250
308
|
}
|
|
251
309
|
function s() {
|
|
252
|
-
|
|
310
|
+
S({
|
|
253
311
|
iframe: e,
|
|
254
312
|
merchantName: a.merchantName
|
|
255
313
|
});
|
|
256
314
|
}
|
|
257
315
|
function c() {
|
|
258
|
-
|
|
316
|
+
y({
|
|
259
317
|
iframe: e,
|
|
260
318
|
height: a.height ?? "48px",
|
|
261
319
|
props: a.buttonProps ?? {}
|
|
@@ -264,7 +322,7 @@ function O(e, { height: r = "48px", ...i }) {
|
|
|
264
322
|
function l(r) {
|
|
265
323
|
if (r.source === e.contentWindow) switch (r.data.type) {
|
|
266
324
|
case "IFRAME_READY":
|
|
267
|
-
|
|
325
|
+
_(e), v({
|
|
268
326
|
iframe: e,
|
|
269
327
|
appearance: {}
|
|
270
328
|
}), o(), s(), c();
|
|
@@ -273,7 +331,7 @@ function O(e, { height: r = "48px", ...i }) {
|
|
|
273
331
|
a.onHeightChange?.(r.data.height);
|
|
274
332
|
break;
|
|
275
333
|
case "UPDATE_APPEARANCE":
|
|
276
|
-
|
|
334
|
+
v({
|
|
277
335
|
iframe: e,
|
|
278
336
|
appearance: r.data.appearance
|
|
279
337
|
});
|
|
@@ -283,7 +341,7 @@ function O(e, { height: r = "48px", ...i }) {
|
|
|
283
341
|
break;
|
|
284
342
|
case "APPLE_PAY_WINDOW_OPEN":
|
|
285
343
|
t({ onCancel: () => {
|
|
286
|
-
|
|
344
|
+
ne(e), n();
|
|
287
345
|
} });
|
|
288
346
|
break;
|
|
289
347
|
case "APPLE_PAY_WINDOW_CLOSE":
|
|
@@ -294,7 +352,7 @@ function O(e, { height: r = "48px", ...i }) {
|
|
|
294
352
|
paymentIntentCreateAttributes: r.data.paymentIntentCreateAttributes,
|
|
295
353
|
customerCreateAttributes: r.data.customerCreateAttributes
|
|
296
354
|
}).then((t) => {
|
|
297
|
-
|
|
355
|
+
O({
|
|
298
356
|
iframe: e,
|
|
299
357
|
token: t
|
|
300
358
|
});
|
|
@@ -323,7 +381,7 @@ function O(e, { height: r = "48px", ...i }) {
|
|
|
323
381
|
}
|
|
324
382
|
//#endregion
|
|
325
383
|
//#region src/form-skeleton.ts
|
|
326
|
-
var
|
|
384
|
+
var N = "amos-js-form-skeleton-styles", re = {
|
|
327
385
|
"--accent": "oklch(0.97 0 0)",
|
|
328
386
|
"--radius": "0.625rem",
|
|
329
387
|
"--input-height": "2.25rem",
|
|
@@ -331,123 +389,123 @@ var k = "amos-js-form-skeleton-styles", te = {
|
|
|
331
389
|
"--field-gap": "1rem",
|
|
332
390
|
"--control-gap": "0.5rem",
|
|
333
391
|
"--label-font-size": "0.875rem"
|
|
334
|
-
},
|
|
335
|
-
function
|
|
336
|
-
if (document.getElementById(
|
|
392
|
+
}, ie = "\n.amos-js-form-skeleton {\n box-sizing: border-box;\n container-type: inline-size;\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n margin: 0 -4px;\n padding-block: 0.25rem;\n pointer-events: none;\n width: calc(100% + 8px);\n}\n.amos-js-form-skeleton-field {\n display: flex;\n flex: 1 1 0;\n flex-direction: column;\n min-width: 0;\n width: 100%;\n}\n.amos-js-form-skeleton-label {\n flex-shrink: 0;\n font-size: var(--label-font-size);\n height: 1.75rem;\n line-height: 1.75rem;\n}\n.amos-js-form-skeleton-input {\n animation: amos-js-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n background: var(--accent);\n border-radius: calc(var(--radius) * 0.8);\n box-sizing: border-box;\n height: var(--input-height);\n width: 100%;\n}\n.amos-js-form-skeleton-input-floating {\n height: var(--floating-input-height);\n}\n.amos-js-form-skeleton-row {\n align-items: flex-start;\n display: flex;\n gap: var(--control-gap);\n width: 100%;\n}\n.amos-js-form-skeleton-row-stack {\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n width: 100%;\n}\n@container (min-width: 24rem) {\n .amos-js-form-skeleton-row-stack {\n align-items: flex-start;\n flex-direction: row;\n gap: var(--control-gap);\n }\n}\n.amos-js-wallet-skeleton {\n flex: none;\n width: 100%;\n}\n@keyframes amos-js-skeleton-pulse {\n 50% { opacity: 0.5; }\n}\n@media (prefers-reduced-motion: reduce) {\n .amos-js-form-skeleton-input {\n animation: none;\n }\n}\n";
|
|
393
|
+
function P() {
|
|
394
|
+
if (document.getElementById(N)) return;
|
|
337
395
|
let e = document.createElement("style");
|
|
338
|
-
e.id =
|
|
396
|
+
e.id = N, e.textContent = ie, document.head.appendChild(e);
|
|
339
397
|
}
|
|
340
|
-
function
|
|
341
|
-
for (let [t, n] of Object.entries(
|
|
398
|
+
function ae(e, t) {
|
|
399
|
+
for (let [t, n] of Object.entries(re)) e.style.setProperty(t, n);
|
|
342
400
|
let n = t?.themeVariables;
|
|
343
401
|
if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && r.trim() !== "" && e.style.setProperty(t, r.trim());
|
|
344
402
|
}
|
|
345
|
-
function
|
|
403
|
+
function F(e, t) {
|
|
346
404
|
let n = document.createElement("div");
|
|
347
405
|
if (n.className = e, t) for (let e of t) n.appendChild(e);
|
|
348
406
|
return n;
|
|
349
407
|
}
|
|
350
|
-
function
|
|
351
|
-
let n =
|
|
352
|
-
t !== void 0 && (n.style.flexGrow = String(t)), e === "above" && n.appendChild(
|
|
353
|
-
let r =
|
|
408
|
+
function I(e, t) {
|
|
409
|
+
let n = F("amos-js-form-skeleton-field");
|
|
410
|
+
t !== void 0 && (n.style.flexGrow = String(t)), e === "above" && n.appendChild(F("amos-js-form-skeleton-label"));
|
|
411
|
+
let r = F("amos-js-form-skeleton-input");
|
|
354
412
|
return e === "floating" && r.classList.add("amos-js-form-skeleton-input-floating"), n.appendChild(r), n;
|
|
355
413
|
}
|
|
356
|
-
function
|
|
357
|
-
return
|
|
414
|
+
function L(e, t) {
|
|
415
|
+
return F(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
|
|
358
416
|
}
|
|
359
|
-
function
|
|
417
|
+
function R({ labels: e, requirement: t, wrapCountryZip: n }) {
|
|
360
418
|
return t === "full" ? [
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
419
|
+
I(e),
|
|
420
|
+
I(e),
|
|
421
|
+
L([
|
|
422
|
+
I(e, 1.4),
|
|
423
|
+
I(e, .7),
|
|
424
|
+
I(e, .8)
|
|
367
425
|
], !1),
|
|
368
|
-
|
|
369
|
-
] : [
|
|
426
|
+
I(e)
|
|
427
|
+
] : [L([I(e), I(e)], n)];
|
|
370
428
|
}
|
|
371
|
-
function
|
|
429
|
+
function oe(e) {
|
|
372
430
|
let t = e.appearance?.labels ?? "above", n = e.billingAddressRequirement ?? "country";
|
|
373
431
|
if (e.kind === "card") {
|
|
374
|
-
let r = [
|
|
375
|
-
return e.additionalFields?.cardholderName && r.push(
|
|
432
|
+
let r = [I(t), L([I(t), I(t)], !1)];
|
|
433
|
+
return e.additionalFields?.cardholderName && r.push(I(t)), r.push(...R({
|
|
376
434
|
labels: t,
|
|
377
435
|
requirement: n,
|
|
378
436
|
wrapCountryZip: !1
|
|
379
437
|
})), r;
|
|
380
438
|
}
|
|
381
439
|
return [
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
...
|
|
440
|
+
I(t),
|
|
441
|
+
L([I(t), I(t)], !0),
|
|
442
|
+
I(t),
|
|
443
|
+
L([I("above"), I("above")], !0),
|
|
444
|
+
...R({
|
|
387
445
|
labels: t,
|
|
388
446
|
requirement: n,
|
|
389
447
|
wrapCountryZip: !0
|
|
390
448
|
})
|
|
391
449
|
];
|
|
392
450
|
}
|
|
393
|
-
function
|
|
394
|
-
|
|
395
|
-
let t =
|
|
451
|
+
function z(e) {
|
|
452
|
+
P();
|
|
453
|
+
let t = F("amos-js-form-skeleton");
|
|
396
454
|
t.setAttribute("aria-hidden", "true");
|
|
397
455
|
function n(e) {
|
|
398
|
-
|
|
456
|
+
ae(t, e.appearance), t.replaceChildren(...oe(e));
|
|
399
457
|
}
|
|
400
458
|
return n(e), {
|
|
401
459
|
element: t,
|
|
402
460
|
update: n
|
|
403
461
|
};
|
|
404
462
|
}
|
|
405
|
-
function
|
|
406
|
-
|
|
407
|
-
let t =
|
|
463
|
+
function B(e) {
|
|
464
|
+
P();
|
|
465
|
+
let t = F("amos-js-form-skeleton-input amos-js-wallet-skeleton");
|
|
408
466
|
t.setAttribute("aria-hidden", "true");
|
|
409
467
|
function n(e) {
|
|
410
|
-
|
|
468
|
+
ae(t, void 0), t.style.height = e.height, t.style.borderRadius = e.borderRadius ?? "4px";
|
|
411
469
|
}
|
|
412
470
|
return n(e), {
|
|
413
471
|
element: t,
|
|
414
472
|
update: n
|
|
415
473
|
};
|
|
416
474
|
}
|
|
417
|
-
function
|
|
475
|
+
function V(e) {
|
|
418
476
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
419
477
|
if (typeof e == "string" && e.trim() !== "") return e.trim();
|
|
420
478
|
}
|
|
421
|
-
function
|
|
422
|
-
return
|
|
479
|
+
function H({ iframeStyle: e, buttonProps: t }) {
|
|
480
|
+
return V(e?.borderRadius) ?? V(t?.buttonRadius) ?? V(t?.style?.borderRadius) ?? V(t?.style?.["--apple-pay-button-border-radius"]) ?? "4px";
|
|
423
481
|
}
|
|
424
482
|
//#endregion
|
|
425
483
|
//#region src/google-pay.ts
|
|
426
|
-
function
|
|
427
|
-
return `${
|
|
484
|
+
function U(e) {
|
|
485
|
+
return `${a(e)}/iframe/google-pay?token=${e}`;
|
|
428
486
|
}
|
|
429
|
-
function
|
|
487
|
+
function W() {
|
|
430
488
|
return "48px";
|
|
431
489
|
}
|
|
432
|
-
function
|
|
490
|
+
function G(e, { height: t = "48px", ...n }) {
|
|
433
491
|
let r = {
|
|
434
492
|
...n,
|
|
435
493
|
height: t
|
|
436
494
|
};
|
|
437
495
|
function i() {
|
|
438
|
-
|
|
496
|
+
x({
|
|
439
497
|
iframe: e,
|
|
440
498
|
amount: r.amount
|
|
441
499
|
});
|
|
442
500
|
}
|
|
443
501
|
function a() {
|
|
444
|
-
|
|
502
|
+
S({
|
|
445
503
|
iframe: e,
|
|
446
504
|
merchantName: r.merchantName
|
|
447
505
|
});
|
|
448
506
|
}
|
|
449
507
|
function o() {
|
|
450
|
-
|
|
508
|
+
b({
|
|
451
509
|
iframe: e,
|
|
452
510
|
height: r.height ?? "48px",
|
|
453
511
|
props: r.buttonProps ?? {}
|
|
@@ -456,7 +514,7 @@ function B(e, { height: t = "48px", ...n }) {
|
|
|
456
514
|
function s(t) {
|
|
457
515
|
if (t.source === e.contentWindow) switch (t.data.type) {
|
|
458
516
|
case "IFRAME_READY":
|
|
459
|
-
|
|
517
|
+
_(e), v({
|
|
460
518
|
iframe: e,
|
|
461
519
|
appearance: {}
|
|
462
520
|
}), i(), a(), o();
|
|
@@ -465,7 +523,7 @@ function B(e, { height: t = "48px", ...n }) {
|
|
|
465
523
|
r.onHeightChange?.(t.data.height);
|
|
466
524
|
break;
|
|
467
525
|
case "UPDATE_APPEARANCE":
|
|
468
|
-
|
|
526
|
+
v({
|
|
469
527
|
iframe: e,
|
|
470
528
|
appearance: t.data.appearance
|
|
471
529
|
});
|
|
@@ -478,7 +536,7 @@ function B(e, { height: t = "48px", ...n }) {
|
|
|
478
536
|
paymentIntentCreateAttributes: t.data.paymentIntentCreateAttributes,
|
|
479
537
|
customerCreateAttributes: t.data.customerCreateAttributes
|
|
480
538
|
}).then((t) => {
|
|
481
|
-
|
|
539
|
+
O({
|
|
482
540
|
iframe: e,
|
|
483
541
|
token: t
|
|
484
542
|
});
|
|
@@ -505,7 +563,7 @@ function B(e, { height: t = "48px", ...n }) {
|
|
|
505
563
|
}
|
|
506
564
|
};
|
|
507
565
|
}
|
|
508
|
-
function
|
|
566
|
+
function se({ paymentData: e }) {
|
|
509
567
|
return { paymentMethod: {
|
|
510
568
|
type: "googlepay",
|
|
511
569
|
billing_address_attributes: {
|
|
@@ -524,40 +582,40 @@ function oe({ paymentData: e }) {
|
|
|
524
582
|
}
|
|
525
583
|
//#endregion
|
|
526
584
|
//#region src/payment-method-form.ts
|
|
527
|
-
var
|
|
585
|
+
var K = {
|
|
528
586
|
country: 212,
|
|
529
587
|
full: 452
|
|
530
|
-
},
|
|
588
|
+
}, ce = 80, q = {
|
|
531
589
|
country: 400,
|
|
532
590
|
full: 640
|
|
533
591
|
};
|
|
534
|
-
function
|
|
535
|
-
let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","),
|
|
592
|
+
function J(e, t = { cardholderName: !1 }, n = "country") {
|
|
593
|
+
let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","), i = new URLSearchParams({
|
|
536
594
|
token: e,
|
|
537
595
|
additionalFields: r,
|
|
538
596
|
billingAddressRequirement: n
|
|
539
597
|
});
|
|
540
|
-
return `${
|
|
598
|
+
return `${a(e)}/iframe/card?${i}`;
|
|
541
599
|
}
|
|
542
|
-
function
|
|
600
|
+
function Y(e, t = "country", n = "payment") {
|
|
543
601
|
let r = new URLSearchParams({
|
|
544
602
|
token: e,
|
|
545
603
|
billingAddressRequirement: t
|
|
546
604
|
});
|
|
547
|
-
return n === "setup" && r.set("intent", "setup"), `${
|
|
605
|
+
return n === "setup" && r.set("intent", "setup"), `${a(e)}/iframe/bank?${r}`;
|
|
548
606
|
}
|
|
549
|
-
function
|
|
550
|
-
return `${(
|
|
607
|
+
function le(e = { cardholderName: !1 }, t = "country") {
|
|
608
|
+
return `${(K[t] ?? K.country) + (e.cardholderName ? ce : 0)}px`;
|
|
551
609
|
}
|
|
552
|
-
function
|
|
553
|
-
return `${
|
|
610
|
+
function ue(e = "country") {
|
|
611
|
+
return `${q[e] ?? q.country}px`;
|
|
554
612
|
}
|
|
555
|
-
function
|
|
613
|
+
function de(e, t) {
|
|
556
614
|
let n = { ...t };
|
|
557
615
|
function r(t) {
|
|
558
616
|
if (t.source === e.contentWindow) switch (t.data.type) {
|
|
559
617
|
case "IFRAME_READY":
|
|
560
|
-
|
|
618
|
+
_(e), v({
|
|
561
619
|
iframe: e,
|
|
562
620
|
appearance: n.appearance
|
|
563
621
|
});
|
|
@@ -566,7 +624,7 @@ function q(e, t) {
|
|
|
566
624
|
n.onHeightChange?.(t.data.height);
|
|
567
625
|
break;
|
|
568
626
|
case "UPDATE_APPEARANCE":
|
|
569
|
-
|
|
627
|
+
v({
|
|
570
628
|
iframe: e,
|
|
571
629
|
appearance: t.data.appearance
|
|
572
630
|
});
|
|
@@ -575,7 +633,7 @@ function q(e, t) {
|
|
|
575
633
|
n.onAppearanceReady?.();
|
|
576
634
|
break;
|
|
577
635
|
case "FORM_VALIDITY_CHANGE":
|
|
578
|
-
if (
|
|
636
|
+
if (m(e)?.requiresVerification) break;
|
|
579
637
|
n.onValidityChange?.({ isValid: t.data.isValid });
|
|
580
638
|
break;
|
|
581
639
|
case "CARD_BRAND_CHANGE":
|
|
@@ -590,7 +648,7 @@ function q(e, t) {
|
|
|
590
648
|
n = {
|
|
591
649
|
...n,
|
|
592
650
|
...t
|
|
593
|
-
}, r &&
|
|
651
|
+
}, r && v({
|
|
594
652
|
iframe: e,
|
|
595
653
|
appearance: n.appearance
|
|
596
654
|
});
|
|
@@ -602,21 +660,21 @@ function q(e, t) {
|
|
|
602
660
|
}
|
|
603
661
|
//#endregion
|
|
604
662
|
//#region src/plaid.ts
|
|
605
|
-
var
|
|
606
|
-
function
|
|
663
|
+
var fe = "https://cdn.plaid.com/link/v2/stable/link-initialize.js";
|
|
664
|
+
function pe({ amount: e, achThreshold: t }) {
|
|
607
665
|
return t != null && (e ?? 0) >= t;
|
|
608
666
|
}
|
|
609
|
-
function
|
|
667
|
+
function me(e) {
|
|
610
668
|
if (e == null) return;
|
|
611
669
|
let t = e.trim();
|
|
612
670
|
if (t === "") return;
|
|
613
671
|
let n = Number(t.replace(/[^\d.]/g, ""));
|
|
614
672
|
if (Number.isFinite(n)) return Math.round(n * 100);
|
|
615
673
|
}
|
|
616
|
-
function
|
|
674
|
+
function he(e) {
|
|
617
675
|
return e.account_id ?? e.account?.id ?? e.accounts?.[0]?.id;
|
|
618
676
|
}
|
|
619
|
-
function
|
|
677
|
+
function ge(e) {
|
|
620
678
|
let t = e.account ?? e.accounts?.[0];
|
|
621
679
|
return {
|
|
622
680
|
bankName: e.institution?.name ?? "Bank account",
|
|
@@ -624,13 +682,13 @@ function ue(e) {
|
|
|
624
682
|
};
|
|
625
683
|
}
|
|
626
684
|
var X;
|
|
627
|
-
function
|
|
628
|
-
for (let e of document.querySelectorAll(`script[src="${
|
|
685
|
+
function _e() {
|
|
686
|
+
for (let e of document.querySelectorAll(`script[src="${fe}"]`)) e.remove();
|
|
629
687
|
}
|
|
630
|
-
function
|
|
631
|
-
return typeof window > "u" ? Promise.reject(/* @__PURE__ */ Error("Plaid Link requires a browser")) : window.Plaid ? Promise.resolve() : X || (
|
|
688
|
+
function ve() {
|
|
689
|
+
return typeof window > "u" ? Promise.reject(/* @__PURE__ */ Error("Plaid Link requires a browser")) : window.Plaid ? Promise.resolve() : X || (_e(), X = new Promise((e, t) => {
|
|
632
690
|
let n = document.createElement("script");
|
|
633
|
-
n.src =
|
|
691
|
+
n.src = fe, n.async = !0;
|
|
634
692
|
let r = (e) => {
|
|
635
693
|
n.remove(), X = void 0, t(Error(e));
|
|
636
694
|
};
|
|
@@ -643,8 +701,8 @@ function fe() {
|
|
|
643
701
|
}, { once: !0 }), n.addEventListener("error", () => r("Failed to load Plaid Link"), { once: !0 }), document.head.append(n);
|
|
644
702
|
}), X);
|
|
645
703
|
}
|
|
646
|
-
async function
|
|
647
|
-
if (await
|
|
704
|
+
async function ye({ token: e, onSuccess: t, onExit: n, signal: r }) {
|
|
705
|
+
if (await ve(), r?.aborted) return () => {};
|
|
648
706
|
if (!window.Plaid) throw Error("Plaid Link failed to initialize");
|
|
649
707
|
let i = window.Plaid.create({
|
|
650
708
|
token: e,
|
|
@@ -659,126 +717,135 @@ async function pe({ token: e, onSuccess: t, onExit: n, signal: r }) {
|
|
|
659
717
|
}
|
|
660
718
|
//#endregion
|
|
661
719
|
//#region src/plaid-bank-ui.ts
|
|
662
|
-
var
|
|
663
|
-
function
|
|
664
|
-
if (document.getElementById(
|
|
720
|
+
var be = "amos-js-plaid-bank-ui-styles", xe = "\n.amos-js-plaid-panel {\n box-sizing: border-box;\n color: var(--foreground, oklch(0.145 0 0));\n display: none;\n flex-direction: column;\n font-family: inherit;\n gap: var(--control-gap, 0.5rem);\n width: 100%;\n}\n.amos-js-plaid-panel[data-mode=\"connect\"],\n.amos-js-plaid-panel[data-mode=\"linked\"] {\n display: flex;\n}\n.amos-js-plaid-connect {\n align-items: center;\n background: var(--background, oklch(1 0 0));\n border: var(--input-border-width, 1px) solid var(--border, oklch(0.922 0 0));\n border-radius: calc(var(--radius, 0.625rem) * 0.8);\n box-shadow: var(--input-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05));\n box-sizing: border-box;\n color: var(--foreground, oklch(0.145 0 0));\n cursor: pointer;\n display: inline-flex;\n flex-shrink: 0;\n font: inherit;\n font-size: var(--input-font-size, 0.875rem);\n font-weight: 500;\n height: var(--input-height, 2.25rem);\n justify-content: center;\n line-height: 1.25;\n outline: none;\n padding: 0 var(--input-padding, 0.75rem);\n transition: color 150ms, background-color 150ms, border-color 150ms, box-shadow 150ms;\n width: 100%;\n}\n.amos-js-plaid-panel[data-mode=\"linked\"] .amos-js-plaid-connect {\n display: none;\n}\n.amos-js-plaid-connect:hover:not(:disabled) {\n background: var(--accent, oklch(0.97 0 0));\n color: var(--accent-foreground, oklch(0.205 0 0));\n}\n.amos-js-plaid-connect:focus-visible {\n border-color: var(--ring, oklch(0.708 0 0));\n box-shadow:\n var(--input-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05)),\n 0 0 0 var(--ring-width, 3px)\n color-mix(in oklab, var(--ring, oklch(0.708 0 0)) 50%, transparent);\n}\n.amos-js-plaid-connect:disabled {\n cursor: default;\n opacity: 0.5;\n pointer-events: none;\n}\n.amos-js-plaid-linked {\n display: none;\n flex-direction: column;\n gap: 0.25rem;\n}\n.amos-js-plaid-panel[data-mode=\"linked\"] .amos-js-plaid-linked {\n display: flex;\n}\n.amos-js-plaid-linked-name {\n font-size: var(--input-font-size, 0.875rem);\n font-weight: 500;\n}\n.amos-js-plaid-linked-meta {\n color: var(--muted-foreground, oklch(0.556 0 0));\n font-size: 0.75rem;\n}\n.amos-js-plaid-disconnect {\n align-self: flex-start;\n background: none;\n border: none;\n border-radius: calc(var(--radius, 0.625rem) * 0.8);\n color: var(--muted-foreground, oklch(0.556 0 0));\n cursor: pointer;\n font: inherit;\n font-size: var(--input-font-size, 0.875rem);\n margin-top: 0.25rem;\n outline: none;\n padding: 0;\n}\n.amos-js-plaid-disconnect:hover {\n color: var(--accent-foreground, oklch(0.205 0 0));\n}\n.amos-js-plaid-disconnect:focus-visible {\n box-shadow:\n 0 0 0 var(--ring-width, 3px)\n color-mix(in oklab, var(--ring, oklch(0.708 0 0)) 50%, transparent);\n}\n.amos-js-plaid-error {\n color: var(--destructive, oklch(0.577 0.245 27.325));\n display: none;\n font-size: var(--error-font-size, 0.875rem);\n margin: 0;\n}\n.amos-js-plaid-error:not(:empty) {\n display: block;\n}\n@media (prefers-reduced-motion: reduce) {\n .amos-js-plaid-connect {\n transition: none;\n }\n}\n";
|
|
721
|
+
function Se() {
|
|
722
|
+
if (document.getElementById(be)) return;
|
|
665
723
|
let e = document.createElement("style");
|
|
666
|
-
e.id =
|
|
724
|
+
e.id = be, e.textContent = xe, document.head.append(e);
|
|
667
725
|
}
|
|
668
|
-
function
|
|
726
|
+
function Ce(e, t, n) {
|
|
669
727
|
for (let t of n) e.style.removeProperty(t);
|
|
670
728
|
n.length = 0;
|
|
671
729
|
let r = t?.themeVariables;
|
|
672
730
|
if (r) for (let [t, i] of Object.entries(r)) typeof i == "string" && i.trim() !== "" && (e.style.setProperty(t, i.trim()), n.push(t));
|
|
673
731
|
}
|
|
674
|
-
function
|
|
675
|
-
|
|
732
|
+
function we({ host: e, iframe: t, options: n }) {
|
|
733
|
+
Se();
|
|
676
734
|
let r = {
|
|
677
735
|
...n,
|
|
678
736
|
amount: n.amount ?? "0"
|
|
679
|
-
}, i = [], a = !1,
|
|
680
|
-
|
|
681
|
-
let
|
|
682
|
-
|
|
683
|
-
let
|
|
684
|
-
|
|
685
|
-
let y = document.createElement("span");
|
|
686
|
-
y.className = "amos-js-plaid-linked-name";
|
|
737
|
+
}, i = [], a = !1, o, s = !1, c, l = !1, u, f, m = new AbortController(), g, _ = document.createElement("div");
|
|
738
|
+
_.className = "amos-js-plaid-panel", _.setAttribute("data-amos-plaid-panel", "true"), _.dataset.mode = "hidden", Ce(_, r.appearance, i);
|
|
739
|
+
let v = document.createElement("button");
|
|
740
|
+
v.type = "button", v.className = "amos-js-plaid-connect", v.textContent = "Connect bank account", v.setAttribute("data-testid", "amos-plaid-connect");
|
|
741
|
+
let y = document.createElement("div");
|
|
742
|
+
y.className = "amos-js-plaid-linked";
|
|
687
743
|
let b = document.createElement("span");
|
|
688
|
-
b.className = "amos-js-plaid-linked-
|
|
689
|
-
let x = document.createElement("
|
|
690
|
-
x.
|
|
691
|
-
let S = document.createElement("
|
|
692
|
-
S.className = "amos-js-plaid-
|
|
693
|
-
let C =
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
return a ? l ? !0 : Y({
|
|
699
|
-
amount: ce(r.amount),
|
|
700
|
-
achThreshold: s
|
|
701
|
-
}) : !1;
|
|
744
|
+
b.className = "amos-js-plaid-linked-name";
|
|
745
|
+
let x = document.createElement("span");
|
|
746
|
+
x.className = "amos-js-plaid-linked-meta";
|
|
747
|
+
let S = document.createElement("button");
|
|
748
|
+
S.type = "button", S.className = "amos-js-plaid-disconnect", S.textContent = "Disconnect", S.setAttribute("aria-label", "Disconnect bank account");
|
|
749
|
+
let C = document.createElement("p");
|
|
750
|
+
C.className = "amos-js-plaid-error", C.setAttribute("role", "alert"), y.append(b, x, S), _.append(v, y, C), e.append(_);
|
|
751
|
+
let w = t.parentElement;
|
|
752
|
+
function T(e) {
|
|
753
|
+
C.textContent = e ?? "";
|
|
702
754
|
}
|
|
703
755
|
function E() {
|
|
704
|
-
|
|
705
|
-
|
|
756
|
+
return a ? s ? !0 : pe({
|
|
757
|
+
amount: me(r.amount),
|
|
758
|
+
achThreshold: o
|
|
759
|
+
}) : !1;
|
|
706
760
|
}
|
|
707
761
|
function D() {
|
|
708
|
-
let e =
|
|
709
|
-
|
|
762
|
+
let e = !!g;
|
|
763
|
+
u !== e && (u = e, r.onValidityChange?.({ isValid: e }));
|
|
764
|
+
}
|
|
765
|
+
function O() {
|
|
766
|
+
let e = E();
|
|
767
|
+
if (p(t, {
|
|
710
768
|
requiresVerification: e,
|
|
711
|
-
plaid: e ?
|
|
712
|
-
clearLinked:
|
|
769
|
+
plaid: e ? g?.credentials : void 0,
|
|
770
|
+
clearLinked: k
|
|
713
771
|
}), !e) {
|
|
714
|
-
|
|
772
|
+
_.dataset.mode = "hidden", w && (w.style.display = ""), u = void 0;
|
|
715
773
|
return;
|
|
716
774
|
}
|
|
717
|
-
|
|
775
|
+
_.dataset.mode = g ? "linked" : "connect", w && (w.style.display = "none"), g && (b.textContent = g.bankName, x.textContent = g.last4 ? `****${g.last4}` : "Connected"), D();
|
|
718
776
|
}
|
|
719
|
-
function
|
|
720
|
-
|
|
777
|
+
function k() {
|
|
778
|
+
g = void 0, c = void 0, f?.(), f = void 0, T(void 0), O();
|
|
721
779
|
}
|
|
722
|
-
function
|
|
780
|
+
function A(e) {
|
|
723
781
|
if (e.source === t.contentWindow && e.data.type === "ACH_THRESHOLD") {
|
|
724
|
-
if (a = !0,
|
|
725
|
-
|
|
782
|
+
if (a = !0, o = e.data.achThreshold ?? void 0, s = e.data.requireVerification === !0, d({
|
|
783
|
+
iframe: t,
|
|
784
|
+
message: "merchant ach_threshold",
|
|
785
|
+
endpoint: "ACH_THRESHOLD",
|
|
786
|
+
headers: { origin: e.origin },
|
|
787
|
+
body: {
|
|
788
|
+
achThreshold: o,
|
|
789
|
+
requireVerification: s
|
|
790
|
+
}
|
|
791
|
+
}), g && !E()) {
|
|
792
|
+
k();
|
|
726
793
|
return;
|
|
727
794
|
}
|
|
728
|
-
|
|
795
|
+
O();
|
|
729
796
|
}
|
|
730
797
|
}
|
|
731
|
-
return window.addEventListener("message",
|
|
732
|
-
|
|
733
|
-
}),
|
|
798
|
+
return window.addEventListener("message", A), O(), S.addEventListener("click", () => {
|
|
799
|
+
k();
|
|
800
|
+
}), v.addEventListener("click", () => {
|
|
734
801
|
(async () => {
|
|
735
|
-
if (!(m.signal.aborted ||
|
|
736
|
-
|
|
802
|
+
if (!(m.signal.aborted || l)) {
|
|
803
|
+
l = !0, v.disabled = !0, T(void 0);
|
|
737
804
|
try {
|
|
738
|
-
if (
|
|
739
|
-
let e =
|
|
740
|
-
|
|
805
|
+
if (c ||= await ee({ iframe: t }), m.signal.aborted) return;
|
|
806
|
+
let e = c;
|
|
807
|
+
f?.(), f = await ye({
|
|
741
808
|
token: e,
|
|
742
809
|
signal: m.signal,
|
|
743
810
|
onSuccess: (e, t) => {
|
|
744
811
|
if (m.signal.aborted) return;
|
|
745
|
-
let n =
|
|
812
|
+
let n = he(t);
|
|
746
813
|
if (!n) {
|
|
747
|
-
|
|
814
|
+
T("Select a bank account to continue.");
|
|
748
815
|
return;
|
|
749
816
|
}
|
|
750
|
-
let r =
|
|
751
|
-
|
|
817
|
+
let r = ge(t);
|
|
818
|
+
g = {
|
|
752
819
|
credentials: {
|
|
753
820
|
public_token: e,
|
|
754
821
|
account_id: n
|
|
755
822
|
},
|
|
756
823
|
bankName: r.bankName,
|
|
757
824
|
last4: r.last4
|
|
758
|
-
},
|
|
825
|
+
}, c = void 0, O();
|
|
759
826
|
},
|
|
760
827
|
onExit: (e) => {
|
|
761
|
-
m.signal.aborted || e?.error_code === "INVALID_LINK_TOKEN" && (
|
|
828
|
+
m.signal.aborted || e?.error_code === "INVALID_LINK_TOKEN" && (c = void 0);
|
|
762
829
|
}
|
|
763
|
-
}), m.signal.aborted && (
|
|
830
|
+
}), m.signal.aborted && (f(), f = void 0);
|
|
764
831
|
} catch (e) {
|
|
765
|
-
if (
|
|
766
|
-
|
|
832
|
+
if (c = void 0, m.signal.aborted) return;
|
|
833
|
+
T(e instanceof Error ? e.message : "Could not connect bank.");
|
|
767
834
|
} finally {
|
|
768
|
-
|
|
835
|
+
l = !1, m.signal.aborted || (v.disabled = !1);
|
|
769
836
|
}
|
|
770
837
|
}
|
|
771
838
|
})();
|
|
772
839
|
}), {
|
|
773
840
|
update(e) {
|
|
774
|
-
if ("amount" in e && (r.amount = e.amount ?? "0"), "onValidityChange" in e && (r.onValidityChange = e.onValidityChange), "appearance" in e && (r.appearance = e.appearance,
|
|
775
|
-
|
|
841
|
+
if ("amount" in e && (r.amount = e.amount ?? "0"), "onValidityChange" in e && (r.onValidityChange = e.onValidityChange), "appearance" in e && (r.appearance = e.appearance, Ce(_, r.appearance, i)), g && !E()) {
|
|
842
|
+
k();
|
|
776
843
|
return;
|
|
777
844
|
}
|
|
778
|
-
|
|
845
|
+
O();
|
|
779
846
|
},
|
|
780
847
|
destroy() {
|
|
781
|
-
m.abort(), window.removeEventListener("message",
|
|
848
|
+
m.abort(), window.removeEventListener("message", A), f?.(), f = void 0, h(t), _.remove();
|
|
782
849
|
}
|
|
783
850
|
};
|
|
784
851
|
}
|
|
@@ -792,19 +859,19 @@ function Z(e) {
|
|
|
792
859
|
}
|
|
793
860
|
return e;
|
|
794
861
|
}
|
|
795
|
-
var
|
|
862
|
+
var Q = {
|
|
796
863
|
width: "calc(100% + 8px)",
|
|
797
864
|
transition: "opacity 150ms ease-in, height 200ms ease-in-out",
|
|
798
865
|
margin: "0 -4px",
|
|
799
866
|
opacity: "0",
|
|
800
867
|
border: "0"
|
|
801
|
-
},
|
|
868
|
+
}, Te = {
|
|
802
869
|
width: "100%",
|
|
803
870
|
transition: "height 200ms ease-in-out",
|
|
804
871
|
margin: "0",
|
|
805
872
|
opacity: "0",
|
|
806
873
|
border: "0"
|
|
807
|
-
},
|
|
874
|
+
}, Ee = {
|
|
808
875
|
position: "absolute",
|
|
809
876
|
top: "0",
|
|
810
877
|
left: "0",
|
|
@@ -814,7 +881,7 @@ var ye = {
|
|
|
814
881
|
opacity: "0",
|
|
815
882
|
transition: "none",
|
|
816
883
|
pointerEvents: "none"
|
|
817
|
-
},
|
|
884
|
+
}, De = {
|
|
818
885
|
position: "absolute",
|
|
819
886
|
top: "0",
|
|
820
887
|
left: "-4px",
|
|
@@ -824,15 +891,15 @@ var ye = {
|
|
|
824
891
|
transition: "none",
|
|
825
892
|
pointerEvents: "none"
|
|
826
893
|
};
|
|
827
|
-
function
|
|
894
|
+
function $({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o = Q }) {
|
|
828
895
|
let s = document.createElement("iframe");
|
|
829
896
|
return s.src = e, s.title = t, s.name = n, s.setAttribute("role", "presentation"), s.scrolling = "no", i && (s.allow = i), a != null && (s.className = a), Object.assign(s.style, o, { height: r }), s;
|
|
830
897
|
}
|
|
831
|
-
function
|
|
898
|
+
function Oe({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
832
899
|
let i = document.createElement("div");
|
|
833
900
|
i.style.position = "relative", i.style.width = "100%", i.setAttribute("aria-busy", "true");
|
|
834
|
-
let a =
|
|
835
|
-
Object.assign(t.style,
|
|
901
|
+
let a = z(r);
|
|
902
|
+
Object.assign(t.style, De), i.append(a.element, t), e.appendChild(i);
|
|
836
903
|
let o = !1, s = !1, c, l = r.appearance, u, d;
|
|
837
904
|
function f() {
|
|
838
905
|
return i.getBoundingClientRect().height;
|
|
@@ -844,7 +911,7 @@ function Ce({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
844
911
|
if (o) return;
|
|
845
912
|
o = !0, d !== void 0 && (clearTimeout(d), d = void 0);
|
|
846
913
|
let e = f(), n = p(), r = Number.isFinite(n) ? Math.max(n, e) : e;
|
|
847
|
-
t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin =
|
|
914
|
+
t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin = Q.margin ?? "", t.style.height = `${r}px`, t.style.opacity = "1", t.style.pointerEvents = "", a.element.remove(), i.removeAttribute("aria-busy"), u = setTimeout(() => {
|
|
848
915
|
t.style.transition = "height 200ms ease-in-out";
|
|
849
916
|
}, 400);
|
|
850
917
|
}
|
|
@@ -853,7 +920,7 @@ function Ce({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
853
920
|
let e = p(), t = f();
|
|
854
921
|
Number.isFinite(e) && e >= t - 2 && m();
|
|
855
922
|
}
|
|
856
|
-
let g =
|
|
923
|
+
let g = de(t, {
|
|
857
924
|
...n,
|
|
858
925
|
onHeightChange: (e) => {
|
|
859
926
|
c = e, o ? t.style.height = e : h(), n.onHeightChange?.(e);
|
|
@@ -877,15 +944,15 @@ function Ce({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
877
944
|
}
|
|
878
945
|
};
|
|
879
946
|
}
|
|
880
|
-
function
|
|
947
|
+
function ke({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListeners: i }) {
|
|
881
948
|
let a = {
|
|
882
949
|
height: n.height ?? "48px",
|
|
883
|
-
borderRadius:
|
|
950
|
+
borderRadius: H({
|
|
884
951
|
iframeStyle: r,
|
|
885
952
|
buttonProps: n.buttonProps
|
|
886
953
|
})
|
|
887
|
-
}, o =
|
|
888
|
-
s.style.position = "relative", s.style.width = "100%", s.style.height = a.height, s.style.overflow = "hidden", s.setAttribute("aria-busy", "true"), Object.assign(t.style,
|
|
954
|
+
}, o = B(a), s = document.createElement("div");
|
|
955
|
+
s.style.position = "relative", s.style.width = "100%", s.style.height = a.height, s.style.overflow = "hidden", s.setAttribute("aria-busy", "true"), Object.assign(t.style, Ee), t.style.height = "100%", s.append(o.element, t), e.appendChild(s);
|
|
889
956
|
let c = !1, l = !1, u, d = n;
|
|
890
957
|
function f() {
|
|
891
958
|
c || (c = !0, u !== void 0 && (clearTimeout(u), u = void 0), t.style.opacity = "1", t.style.pointerEvents = "", o.element.remove(), s.removeAttribute("aria-busy"));
|
|
@@ -914,7 +981,7 @@ function $({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListe
|
|
|
914
981
|
let t = { ...e };
|
|
915
982
|
delete t.onAppearanceReady, delete t.onHeightChange, m.update(t), a = {
|
|
916
983
|
height: d.height ?? a.height,
|
|
917
|
-
borderRadius:
|
|
984
|
+
borderRadius: H({
|
|
918
985
|
iframeStyle: r,
|
|
919
986
|
buttonProps: d.buttonProps
|
|
920
987
|
})
|
|
@@ -925,15 +992,15 @@ function $({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListe
|
|
|
925
992
|
}
|
|
926
993
|
};
|
|
927
994
|
}
|
|
928
|
-
function
|
|
995
|
+
function Ae(e, t) {
|
|
929
996
|
let n = Z(e), { renderToken: r, additionalFields: i = { cardholderName: !1 }, billingAddressRequirement: a = "country", ...o } = t;
|
|
930
|
-
return
|
|
997
|
+
return Oe({
|
|
931
998
|
host: n,
|
|
932
|
-
iframe:
|
|
933
|
-
src:
|
|
999
|
+
iframe: $({
|
|
1000
|
+
src: J(r, i, a),
|
|
934
1001
|
title: "Secure credit card payment method form powered by Amos",
|
|
935
1002
|
name: "amos-credit-card-payment-method-form",
|
|
936
|
-
height:
|
|
1003
|
+
height: le(i, a)
|
|
937
1004
|
}),
|
|
938
1005
|
listenerOptions: o,
|
|
939
1006
|
skeletonOptions: {
|
|
@@ -944,13 +1011,13 @@ function we(e, t) {
|
|
|
944
1011
|
}
|
|
945
1012
|
});
|
|
946
1013
|
}
|
|
947
|
-
function
|
|
948
|
-
let n = Z(e), { renderToken: r, billingAddressRequirement: i = "country", amount: a = "0", intent: o = "payment", ...s } = t, c =
|
|
949
|
-
src:
|
|
1014
|
+
function je(e, t) {
|
|
1015
|
+
let n = Z(e), { renderToken: r, billingAddressRequirement: i = "country", amount: a = "0", intent: o = "payment", ...s } = t, c = $({
|
|
1016
|
+
src: Y(r, i, o),
|
|
950
1017
|
title: "Secure bank account payment method form powered by Amos",
|
|
951
1018
|
name: "amos-bank-account-payment-method-form",
|
|
952
|
-
height:
|
|
953
|
-
}), l =
|
|
1019
|
+
height: ue(i)
|
|
1020
|
+
}), l = Oe({
|
|
954
1021
|
host: n,
|
|
955
1022
|
iframe: c,
|
|
956
1023
|
listenerOptions: s,
|
|
@@ -959,7 +1026,7 @@ function Te(e, t) {
|
|
|
959
1026
|
appearance: s.appearance,
|
|
960
1027
|
billingAddressRequirement: i
|
|
961
1028
|
}
|
|
962
|
-
}), u =
|
|
1029
|
+
}), u = we({
|
|
963
1030
|
host: n,
|
|
964
1031
|
iframe: c,
|
|
965
1032
|
options: {
|
|
@@ -978,41 +1045,41 @@ function Te(e, t) {
|
|
|
978
1045
|
}
|
|
979
1046
|
};
|
|
980
1047
|
}
|
|
981
|
-
function
|
|
982
|
-
let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s =
|
|
983
|
-
src:
|
|
1048
|
+
function Me(e, t) {
|
|
1049
|
+
let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = $({
|
|
1050
|
+
src: U(r),
|
|
984
1051
|
title: "Secure Google Pay button powered by Amos",
|
|
985
1052
|
name: "amos-google-pay-button",
|
|
986
|
-
height: o.height ??
|
|
1053
|
+
height: o.height ?? W(),
|
|
987
1054
|
allow: "payment",
|
|
988
1055
|
className: i,
|
|
989
|
-
style:
|
|
1056
|
+
style: Te
|
|
990
1057
|
});
|
|
991
|
-
return Object.assign(s.style, a),
|
|
1058
|
+
return Object.assign(s.style, a), ke({
|
|
992
1059
|
host: n,
|
|
993
1060
|
iframe: s,
|
|
994
1061
|
listenerOptions: o,
|
|
995
1062
|
iframeStyle: a,
|
|
996
|
-
attachListeners:
|
|
1063
|
+
attachListeners: G
|
|
997
1064
|
});
|
|
998
1065
|
}
|
|
999
|
-
function
|
|
1000
|
-
let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s =
|
|
1001
|
-
src:
|
|
1066
|
+
function Ne(e, t) {
|
|
1067
|
+
let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = $({
|
|
1068
|
+
src: te(r),
|
|
1002
1069
|
title: "Secure Apple Pay button powered by Amos",
|
|
1003
1070
|
name: "amos-apple-pay-button",
|
|
1004
|
-
height: o.height ??
|
|
1071
|
+
height: o.height ?? j(),
|
|
1005
1072
|
allow: "payment",
|
|
1006
1073
|
className: i,
|
|
1007
|
-
style:
|
|
1074
|
+
style: Te
|
|
1008
1075
|
});
|
|
1009
|
-
return Object.assign(s.style, a),
|
|
1076
|
+
return Object.assign(s.style, a), ke({
|
|
1010
1077
|
host: n,
|
|
1011
1078
|
iframe: s,
|
|
1012
1079
|
listenerOptions: o,
|
|
1013
1080
|
iframeStyle: a,
|
|
1014
|
-
attachListeners:
|
|
1081
|
+
attachListeners: M
|
|
1015
1082
|
});
|
|
1016
1083
|
}
|
|
1017
1084
|
//#endregion
|
|
1018
|
-
export {
|
|
1085
|
+
export { ie as SKELETON_STYLES, M as attachApplePayButtonListeners, G as attachGooglePayButtonListeners, de as attachPaymentMethodFormListeners, O as confirmPaymentIntent, k as confirmSetupIntent, o as createMessage, z as createPaymentMethodFormSkeleton, B as createWalletButtonSkeleton, r as decodeJwt, P as ensureSkeletonStyles, se as formatGooglePayPaymentData, j as getApplePayButtonInitialHeight, te as getApplePayButtonSrc, ue as getBankAccountFormInitialHeight, Y as getBankAccountFormSrc, le as getCreditCardFormInitialHeight, J as getCreditCardFormSrc, a as getEmbedOrigin, W as getGooglePayButtonInitialHeight, U as getGooglePayButtonSrc, ge as linkedBankLabelFromMetadata, ve as loadPlaidScript, Ne as mountAmosApplePayButton, je as mountAmosBankAccountPaymentMethodForm, Ae as mountAmosCreditCardPaymentMethodForm, Me as mountAmosGooglePayButton, ye as openPlaidLink, he as plaidAccountIdFromMetadata, pe as requiresAchVerification, T as resetForm, H as resolveWalletButtonSkeletonBorderRadius, A as sendConfirmationResult, _ as sendParentReadyMessage, x as updateAmount, v as updateAppearance, y as updateApplePayButton, b as updateGooglePayButton, S as updateMerchantName, C as validateForm };
|