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