@amos.com/amos-js 0.10.3 → 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 +184 -190
- package/dist/jwt.d.ts +0 -4
- package/package.json +1 -1
- package/src/jwt.ts +0 -25
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`data-amos-apple-pay-waiting`;function t({onCancel:t}){let n=document.querySelector(`[${e}]`);if(n)return n;let r=document.createElement(`div`);r.setAttribute(e,`true`),r.setAttribute(`role`,`dialog`),r.setAttribute(`aria-modal`,`true`),r.setAttribute(`aria-labelledby`,`amos-apple-pay-waiting-title`),Object.assign(r.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`24px`,boxSizing:`border-box`,background:`rgba(0, 0, 0, 0.55)`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`});let i=document.createElement(`div`);Object.assign(i.style,{width:`100%`,maxWidth:`360px`,borderRadius:`12px`,background:`#fff`,padding:`28px 24px 20px`,boxSizing:`border-box`,textAlign:`center`,boxShadow:`0 12px 40px rgba(0, 0, 0, 0.25)`});let a=document.createElement(`div`);a.setAttribute(`aria-hidden`,`true`),Object.assign(a.style,{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,marginBottom:`16px`,fontSize:`28px`,fontWeight:`600`,letterSpacing:`-0.02em`,color:`#000`,lineHeight:`1`}),a.innerHTML=`<svg width="22" height="26" viewBox="0 0 814 1000" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M788.1 340.9c-5.8 4.5-108.2 62.2-108.2 190.5 0 148.4 130.3 200.9 134.2 202.2-.6 3.2-20.7 71.9-68.7 141.9-42.8 61.6-87.5 123.1-155.5 123.1s-85.5-39.5-164-39.5c-76.5 0-103.7 40.8-165.9 40.8s-105.6-57-155.5-127C46.7 790.7 0 663 0 541.8c0-194.4 126.4-297.5 250.8-297.5 66.1 0 121.2 43.4 162.7 43.4 39.5 0 101.1-46 176.3-46 28.5 0 130.9 2.6 198.3 99.2zm-234-181.5c31.1-36.9 53.1-88.1 53.1-139.3 0-7.1-.6-14.3-1.9-20.1-50.6 1.9-110.8 33.7-147.1 75.8-28.5 32.4-55.1 83.6-55.1 135.5 0 7.8 1.3 15.6 1.9 18.1 3.2.6 8.4 1.3 13.6 1.3 45.4 0 102.5-30.4 135.5-71.3z"/></svg><span>Pay</span>`;let o=document.createElement(`p`);o.id=`amos-apple-pay-waiting-title`,Object.assign(o.style,{margin:`0 0 20px`,fontSize:`15px`,lineHeight:`1.45`,color:`#1a1a1a`}),o.textContent=`Complete your payment in the open Apple Pay window, or close Apple Pay to continue paying another way.`;let s=document.createElement(`button`);return s.type=`button`,s.textContent=`Cancel payment`,Object.assign(s.style,{display:`block`,width:`100%`,border:`none`,borderRadius:`8px`,padding:`12px 16px`,background:`#2c2c2e`,color:`#fff`,fontSize:`15px`,fontWeight:`500`,cursor:`pointer`}),s.addEventListener(`click`,t),i.append(a,o,s),r.append(i),document.body.append(r),r}function n(){document.querySelector(`[${e}]`)?.remove()}function r(e){let[t=``,n=``,r=``]=e?.split(`.`)??[],i=typeof atob==`function`?atob:e=>Buffer.from(e,`base64`).toString(`utf8`);return{header:JSON.parse(i(t)),payload:JSON.parse(i(n)),signature:r}}function i(
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`data-amos-apple-pay-waiting`;function t({onCancel:t}){let n=document.querySelector(`[${e}]`);if(n)return n;let r=document.createElement(`div`);r.setAttribute(e,`true`),r.setAttribute(`role`,`dialog`),r.setAttribute(`aria-modal`,`true`),r.setAttribute(`aria-labelledby`,`amos-apple-pay-waiting-title`),Object.assign(r.style,{position:`fixed`,inset:`0`,zIndex:`2147483646`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`24px`,boxSizing:`border-box`,background:`rgba(0, 0, 0, 0.55)`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif`});let i=document.createElement(`div`);Object.assign(i.style,{width:`100%`,maxWidth:`360px`,borderRadius:`12px`,background:`#fff`,padding:`28px 24px 20px`,boxSizing:`border-box`,textAlign:`center`,boxShadow:`0 12px 40px rgba(0, 0, 0, 0.25)`});let a=document.createElement(`div`);a.setAttribute(`aria-hidden`,`true`),Object.assign(a.style,{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,marginBottom:`16px`,fontSize:`28px`,fontWeight:`600`,letterSpacing:`-0.02em`,color:`#000`,lineHeight:`1`}),a.innerHTML=`<svg width="22" height="26" viewBox="0 0 814 1000" fill="currentColor" xmlns="http://www.w3.org/2000/svg"><path d="M788.1 340.9c-5.8 4.5-108.2 62.2-108.2 190.5 0 148.4 130.3 200.9 134.2 202.2-.6 3.2-20.7 71.9-68.7 141.9-42.8 61.6-87.5 123.1-155.5 123.1s-85.5-39.5-164-39.5c-76.5 0-103.7 40.8-165.9 40.8s-105.6-57-155.5-127C46.7 790.7 0 663 0 541.8c0-194.4 126.4-297.5 250.8-297.5 66.1 0 121.2 43.4 162.7 43.4 39.5 0 101.1-46 176.3-46 28.5 0 130.9 2.6 198.3 99.2zm-234-181.5c31.1-36.9 53.1-88.1 53.1-139.3 0-7.1-.6-14.3-1.9-20.1-50.6 1.9-110.8 33.7-147.1 75.8-28.5 32.4-55.1 83.6-55.1 135.5 0 7.8 1.3 15.6 1.9 18.1 3.2.6 8.4 1.3 13.6 1.3 45.4 0 102.5-30.4 135.5-71.3z"/></svg><span>Pay</span>`;let o=document.createElement(`p`);o.id=`amos-apple-pay-waiting-title`,Object.assign(o.style,{margin:`0 0 20px`,fontSize:`15px`,lineHeight:`1.45`,color:`#1a1a1a`}),o.textContent=`Complete your payment in the open Apple Pay window, or close Apple Pay to continue paying another way.`;let s=document.createElement(`button`);return s.type=`button`,s.textContent=`Cancel payment`,Object.assign(s.style,{display:`block`,width:`100%`,border:`none`,borderRadius:`8px`,padding:`12px 16px`,background:`#2c2c2e`,color:`#fff`,fontSize:`15px`,fontWeight:`500`,cursor:`pointer`}),s.addEventListener(`click`,t),i.append(a,o,s),r.append(i),document.body.append(r),r}function n(){document.querySelector(`[${e}]`)?.remove()}function r(e){let[t=``,n=``,r=``]=e?.split(`.`)??[],i=typeof atob==`function`?atob:e=>Buffer.from(e,`base64`).toString(`utf8`);return{header:JSON.parse(i(t)),payload:JSON.parse(i(n)),signature:r}}function i(e){let{env:t=`sandbox`}=r(e).payload;switch(t){case`production`:return`https://embed.amos.com`;case`sandbox`:return`https://embed-sandbox.amos.com`;default:return`https://embed-sandbox.amos.com`}}function a(e){return e}var o=new Set([`authorization`,`cookie`,`set-cookie`,`x-api-key`]),s=new Set([`authorization`,`encrypted_account_number`,`link_token`,`public_token`,`token`]);function c(e){let t={};for(let[n,r]of Object.entries(e))t[n]=o.has(n.toLowerCase())?`[REDACTED]`:r;return t}function l(e){if(Array.isArray(e))return e.map(l);if(typeof e==`object`&&e){let t={};for(let[n,r]of Object.entries(e))t[n]=s.has(n)?`[REDACTED]`:l(r);return t}return e}function u({iframe:e,message:t,endpoint:n,headers:r={},body:i}){e.contentWindow?.postMessage(a({type:`PARENT_INFO_LOG`,message:t,endpoint:n,headers:c(r),body:l(i)}),new URL(e.src).origin)}var d=new WeakMap;function f(e,t){d.set(e,t)}function p(e){if(e)return d.get(e)}function m(e){e&&d.delete(e)}function h(e){return new URL(e.src).origin}function g(e){e?.contentWindow&&e.contentWindow.postMessage(a({type:`PARENT_ACKNOWLEDGED_IFRAME_READY`}),h(e))}function _({iframe:e,appearance:t={}}){e?.contentWindow&&e.contentWindow.postMessage(a({type:`UPDATE_APPEARANCE`,appearance:t}),h(e))}function v({iframe:e,props:t,height:n}){e?.contentWindow&&e.contentWindow.postMessage(a({type:`UPDATE_APPLE_PAY_BUTTON`,height:n,props:t}),h(e))}function y({iframe:e,props:t,height:n}){e?.contentWindow&&e.contentWindow.postMessage(a({type:`UPDATE_GOOGLE_PAY_BUTTON`,height:n,props:t}),h(e))}function b({iframe:e,amount:t}){e?.contentWindow&&e.contentWindow.postMessage(a({type:`UPDATE_AMOUNT`,amount:t}),h(e))}function x({iframe:e,merchantName:t}){e?.contentWindow&&e.contentWindow.postMessage(a({type:`UPDATE_MERCHANT_NAME`,merchantName:t}),h(e))}function S({iframe:e}){let t=p(e);if(t?.requiresVerification)return Promise.resolve(!!t.plaid);let n=crypto.randomUUID();return new Promise(t=>{e?.contentWindow&&e.contentWindow.postMessage(a({type:`VALIDATE_FORM`,requestId:n}),h(e));let r=setTimeout(()=>{window.removeEventListener(`message`,i),t(!1)},5e3);function i(e){e.data.type===`VALIDATE_FORM`&&e.data.requestId===n&&(window.removeEventListener(`message`,i),clearTimeout(r),t(e.data.isValid??!1))}window.addEventListener(`message`,i)})}var C=1e4;function ee({iframe:e}){let t=crypto.randomUUID();return new Promise((n,r)=>{if(!e?.contentWindow){r(Error(`Bank form is not ready.`));return}let i=e.contentWindow;i.postMessage(a({type:`CREATE_PLAID_LINK_TOKEN`,requestId:t}),h(e));let o=setTimeout(()=>{window.removeEventListener(`message`,s),r(Error(`Timed out waiting for Plaid Link token.`))},C);function s(e){if(e.source===i&&e.data.type===`PLAID_LINK_TOKEN`&&e.data.requestId===t){if(window.removeEventListener(`message`,s),clearTimeout(o),e.data.link_token){n(e.data.link_token);return}r(Error(e.data.error??`Could not create Plaid Link token.`))}}window.addEventListener(`message`,s)})}function w({iframe:e}){p(e)?.clearLinked?.(),T(e)}function T(e){e?.contentWindow&&e.contentWindow.postMessage(a({type:`RESET_FORM`}),h(e))}function E({iframe:e,type:t,token:n,id:r}){let i=p(e),o=i?.plaid;i?.requiresVerification&&!o&&T(e);let s=h(e);u({iframe:e,message:t===`CONFIRM_PAYMENT_INTENT`?`confirmPaymentIntent`:`confirmSetupIntent`,endpoint:t===`CONFIRM_PAYMENT_INTENT`?`POST /embed/payment_intents/{id}/confirm_with_payment_method`:`POST /embed/setup_intents/{id}/confirm_with_payment_method`,headers:{origin:window.location.origin,"iframe-origin":s},body:{id:r,token:n,...o?{plaid:o}:{}}}),e.contentWindow?.postMessage(a({type:t,token:n,id:r,...o?{plaid:o}:{}}),h(e))}function D({iframe:e,token:t}){if(!e?.contentWindow)return;let{payment_intent_id:n}=r(t).payload;E({iframe:e,type:`CONFIRM_PAYMENT_INTENT`,token:t,id:n??void 0})}function O({iframe:e,token:t}){if(!e?.contentWindow)return;let{setup_intent_id:n}=r(t).payload;E({iframe:e,type:`CONFIRM_SETUP_INTENT`,token:t,id:n??void 0})}function k({iframe:e,result:t}){e?.contentWindow&&e.contentWindow.postMessage(a({type:`CONFIRMATION_RESULT`,result:t}),h(e))}function A(e){return`${i(e)}/iframe/apple-pay?token=${e}`}function j(){return`48px`}function te(e){e.contentWindow?.postMessage(a({type:`APPLE_PAY_CANCEL`}),h(e))}function ne(e,{height:r=`48px`,...i}){let a={...i,height:r};function o(){b({iframe:e,amount:a.amount})}function s(){x({iframe:e,merchantName:a.merchantName})}function c(){v({iframe:e,height:a.height??`48px`,props:a.buttonProps??{}})}function l(r){if(r.source===e.contentWindow)switch(r.data.type){case`IFRAME_READY`:g(e),_({iframe:e,appearance:{}}),o(),s(),c();break;case`UPDATE_HEIGHT`:a.onHeightChange?.(r.data.height);break;case`UPDATE_APPEARANCE`:_({iframe:e,appearance:r.data.appearance});break;case`UPDATED_APPEARANCE`:a.onAppearanceReady?.();break;case`APPLE_PAY_WINDOW_OPEN`:t({onCancel:()=>{te(e),n()}});break;case`APPLE_PAY_WINDOW_CLOSE`:n();break;case`CREATE_PAYMENT_INTENT`:a.onInitiatePaymentIntentRequest({paymentIntentCreateAttributes:r.data.paymentIntentCreateAttributes,customerCreateAttributes:r.data.customerCreateAttributes}).then(t=>{D({iframe:e,token:t})}).catch(e=>{n(),a.onResult({status:`failed`,errorMessage:e instanceof Error?e.message:`Unknown error`})});break;case`CONFIRMATION_RESULT`:n(),a.onResult(r.data.result)}}return window.addEventListener(`message`,l),{update(e){let t=`amount`in e,n=`merchantName`in e,r=`height`in e||`buttonProps`in e;a={...a,...e},t&&o(),n&&s(),r&&c()},destroy(){window.removeEventListener(`message`,l),n()}}}var M=`amos-js-form-skeleton-styles`,re={"--accent":`oklch(0.97 0 0)`,"--radius":`0.625rem`,"--input-height":`2.25rem`,"--floating-input-height":`3.25rem`,"--field-gap":`1rem`,"--control-gap":`0.5rem`,"--label-font-size":`0.875rem`},N=`
|
|
2
2
|
.amos-js-form-skeleton {
|
|
3
3
|
box-sizing: border-box;
|
|
4
4
|
container-type: inline-size;
|
|
@@ -65,7 +65,7 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`data-a
|
|
|
65
65
|
animation: none;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
`;function P(){if(document.getElementById(
|
|
68
|
+
`;function P(){if(document.getElementById(M))return;let e=document.createElement(`style`);e.id=M,e.textContent=N,document.head.appendChild(e)}function ie(e,t){for(let[t,n]of Object.entries(re))e.style.setProperty(t,n);let n=t?.themeVariables;if(n)for(let[t,r]of Object.entries(n))typeof r==`string`&&r.trim()!==``&&e.style.setProperty(t,r.trim())}function F(e,t){let n=document.createElement(`div`);if(n.className=e,t)for(let e of t)n.appendChild(e);return n}function I(e,t){let n=F(`amos-js-form-skeleton-field`);t!==void 0&&(n.style.flexGrow=String(t)),e===`above`&&n.appendChild(F(`amos-js-form-skeleton-label`));let r=F(`amos-js-form-skeleton-input`);return e===`floating`&&r.classList.add(`amos-js-form-skeleton-input-floating`),n.appendChild(r),n}function L(e,t){return F(t?`amos-js-form-skeleton-row-stack`:`amos-js-form-skeleton-row`,e)}function R({labels:e,requirement:t,wrapCountryZip:n}){return t===`full`?[I(e),I(e),L([I(e,1.4),I(e,.7),I(e,.8)],!1),I(e)]:[L([I(e),I(e)],n)]}function ae(e){let t=e.appearance?.labels??`above`,n=e.billingAddressRequirement??`country`;if(e.kind===`card`){let r=[I(t),L([I(t),I(t)],!1)];return e.additionalFields?.cardholderName&&r.push(I(t)),r.push(...R({labels:t,requirement:n,wrapCountryZip:!1})),r}return[I(t),L([I(t),I(t)],!0),I(t),L([I(`above`),I(`above`)],!0),...R({labels:t,requirement:n,wrapCountryZip:!0})]}function z(e){P();let t=F(`amos-js-form-skeleton`);t.setAttribute(`aria-hidden`,`true`);function n(e){ie(t,e.appearance),t.replaceChildren(...ae(e))}return n(e),{element:t,update:n}}function B(e){P();let t=F(`amos-js-form-skeleton-input amos-js-wallet-skeleton`);t.setAttribute(`aria-hidden`,`true`);function n(e){ie(t,void 0),t.style.height=e.height,t.style.borderRadius=e.borderRadius??`4px`}return n(e),{element:t,update:n}}function V(e){if(typeof e==`number`&&Number.isFinite(e))return`${e}px`;if(typeof e==`string`&&e.trim()!==``)return e.trim()}function H({iframeStyle:e,buttonProps:t}){return V(e?.borderRadius)??V(t?.buttonRadius)??V(t?.style?.borderRadius)??V(t?.style?.[`--apple-pay-button-border-radius`])??`4px`}function U(e){return`${i(e)}/iframe/google-pay?token=${e}`}function W(){return`48px`}function G(e,{height:t=`48px`,...n}){let r={...n,height:t};function i(){b({iframe:e,amount:r.amount})}function a(){x({iframe:e,merchantName:r.merchantName})}function o(){y({iframe:e,height:r.height??`48px`,props:r.buttonProps??{}})}function s(t){if(t.source===e.contentWindow)switch(t.data.type){case`IFRAME_READY`:g(e),_({iframe:e,appearance:{}}),i(),a(),o();break;case`UPDATE_HEIGHT`:r.onHeightChange?.(t.data.height);break;case`UPDATE_APPEARANCE`:_({iframe:e,appearance:t.data.appearance});break;case`UPDATED_APPEARANCE`:r.onAppearanceReady?.();break;case`CREATE_PAYMENT_INTENT`:r.onInitiatePaymentIntentRequest({paymentIntentCreateAttributes:t.data.paymentIntentCreateAttributes,customerCreateAttributes:t.data.customerCreateAttributes}).then(t=>{D({iframe:e,token:t})}).catch(e=>{r.onResult({status:`failed`,errorMessage:e instanceof Error?e.message:`Unknown error`})});break;case`CONFIRMATION_RESULT`:r.onResult(t.data.result)}}return window.addEventListener(`message`,s),{update(e){let t=`amount`in e,n=`merchantName`in e,s=`height`in e||`buttonProps`in e;r={...r,...e},t&&i(),n&&a(),s&&o()},destroy(){window.removeEventListener(`message`,s)}}}function oe({paymentData:e}){return{paymentMethod:{type:`googlepay`,billing_address_attributes:{name:e.shippingAddress?.name,address_line1:e.shippingAddress?.address1,address_line2:e.shippingAddress?.address2,city:e.shippingAddress?.locality,state:e.shippingAddress?.administrativeArea,postal_code:e.shippingAddress?.postalCode,country:e.shippingAddress?.countryCode,email:e.email,phone:e.shippingAddress?.phoneNumber},card_profile_attributes:{wallet_payload:e.paymentMethodData.tokenizationData.token}}}}var K={country:212,full:452},se=80,q={country:400,full:640};function J(e,t={cardholderName:!1},n=`country`){let r=Object.entries(t).filter(([,e])=>e).map(([e])=>e).join(`,`),a=new URLSearchParams({token:e,additionalFields:r,billingAddressRequirement:n});return`${i(e)}/iframe/card?${a}`}function Y(e,t=`country`,n=`payment`){let r=new URLSearchParams({token:e,billingAddressRequirement:t});return n===`setup`&&r.set(`intent`,`setup`),`${i(e)}/iframe/bank?${r}`}function X(e={cardholderName:!1},t=`country`){return`${(K[t]??K.country)+(e.cardholderName?se:0)}px`}function ce(e=`country`){return`${q[e]??q.country}px`}function le(e,t){let n={...t};function r(t){if(t.source===e.contentWindow)switch(t.data.type){case`IFRAME_READY`:g(e),_({iframe:e,appearance:n.appearance});break;case`UPDATE_HEIGHT`:n.onHeightChange?.(t.data.height);break;case`UPDATE_APPEARANCE`:_({iframe:e,appearance:t.data.appearance});break;case`UPDATED_APPEARANCE`:n.onAppearanceReady?.();break;case`FORM_VALIDITY_CHANGE`:if(p(e)?.requiresVerification)break;n.onValidityChange?.({isValid:t.data.isValid});break;case`CARD_BRAND_CHANGE`:n.onCardBrandChanged?.({brand:t.data.brand});break;case`CONFIRMATION_RESULT`:n.onResult(t.data.result)}}return window.addEventListener(`message`,r),{update(t){let r=`appearance`in t;n={...n,...t},r&&_({iframe:e,appearance:n.appearance})},destroy(){window.removeEventListener(`message`,r)}}}var ue=`https://cdn.plaid.com/link/v2/stable/link-initialize.js`;function de({amount:e,achThreshold:t}){return t!=null&&(e??0)>=t}function fe(e){if(e==null)return;let t=e.trim();if(t===``)return;let n=Number(t.replace(/[^\d.]/g,``));if(Number.isFinite(n))return Math.round(n*100)}function pe(e){return e.account_id??e.account?.id??e.accounts?.[0]?.id}function me(e){let t=e.account??e.accounts?.[0];return{bankName:e.institution?.name??`Bank account`,last4:t?.mask??``}}var Z;function he(){for(let e of document.querySelectorAll(`script[src="${ue}"]`))e.remove()}function ge(){return typeof window>`u`?Promise.reject(Error(`Plaid Link requires a browser`)):window.Plaid?Promise.resolve():Z||(he(),Z=new Promise((e,t)=>{let n=document.createElement(`script`);n.src=ue,n.async=!0;let r=e=>{n.remove(),Z=void 0,t(Error(e))};n.addEventListener(`load`,()=>{if(window.Plaid){e();return}r(`Plaid Link failed to initialize`)},{once:!0}),n.addEventListener(`error`,()=>r(`Failed to load Plaid Link`),{once:!0}),document.head.append(n)}),Z)}async function _e({token:e,onSuccess:t,onExit:n,signal:r}){if(await ge(),r?.aborted)return()=>{};if(!window.Plaid)throw Error(`Plaid Link failed to initialize`);let i=window.Plaid.create({token:e,onSuccess:t,onExit:e=>{n?.(e)}});return r?.aborted?(i.destroy(),()=>{}):(i.open(),()=>{i.destroy()})}var ve=`amos-js-plaid-bank-ui-styles`,ye=`
|
|
69
69
|
.amos-js-plaid-panel {
|
|
70
70
|
box-sizing: border-box;
|
|
71
71
|
color: var(--foreground, oklch(0.145 0 0));
|
|
@@ -171,4 +171,4 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`data-a
|
|
|
171
171
|
transition: none;
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
`;function
|
|
174
|
+
`;function be(){if(document.getElementById(ve))return;let e=document.createElement(`style`);e.id=ve,e.textContent=ye,document.head.append(e)}function xe(e,t,n){for(let t of n)e.style.removeProperty(t);n.length=0;let r=t?.themeVariables;if(r)for(let[t,i]of Object.entries(r))typeof i==`string`&&i.trim()!==``&&(e.style.setProperty(t,i.trim()),n.push(t))}function Se({host:e,iframe:t,options:n}){be();let r={...n,amount:n.amount??`0`},i=[],a=!1,o,s=!1,c,l=!1,d,p,h=new AbortController,g,_=document.createElement(`div`);_.className=`amos-js-plaid-panel`,_.setAttribute(`data-amos-plaid-panel`,`true`),_.dataset.mode=`hidden`,xe(_,r.appearance,i);let v=document.createElement(`button`);v.type=`button`,v.className=`amos-js-plaid-connect`,v.textContent=`Connect bank account`,v.setAttribute(`data-testid`,`amos-plaid-connect`);let y=document.createElement(`div`);y.className=`amos-js-plaid-linked`;let b=document.createElement(`span`);b.className=`amos-js-plaid-linked-name`;let x=document.createElement(`span`);x.className=`amos-js-plaid-linked-meta`;let S=document.createElement(`button`);S.type=`button`,S.className=`amos-js-plaid-disconnect`,S.textContent=`Disconnect`,S.setAttribute(`aria-label`,`Disconnect bank account`);let C=document.createElement(`p`);C.className=`amos-js-plaid-error`,C.setAttribute(`role`,`alert`),y.append(b,x,S),_.append(v,y,C),e.append(_);let w=t.parentElement;function T(e){C.textContent=e??``}function E(){return a?s?!0:de({amount:fe(r.amount),achThreshold:o}):!1}function D(){let e=!!g;d!==e&&(d=e,r.onValidityChange?.({isValid:e}))}function O(){let e=E();if(f(t,{requiresVerification:e,plaid:e?g?.credentials:void 0,clearLinked:k}),!e){_.dataset.mode=`hidden`,w&&(w.style.display=``),d=void 0;return}_.dataset.mode=g?`linked`:`connect`,w&&(w.style.display=`none`),g&&(b.textContent=g.bankName,x.textContent=g.last4?`****${g.last4}`:`Connected`),D()}function k(){g=void 0,c=void 0,p?.(),p=void 0,T(void 0),O()}function A(e){if(e.source===t.contentWindow&&e.data.type===`ACH_THRESHOLD`){if(a=!0,o=e.data.achThreshold??void 0,s=e.data.requireVerification===!0,u({iframe:t,message:`merchant ach_threshold`,endpoint:`ACH_THRESHOLD`,headers:{origin:e.origin},body:{achThreshold:o,requireVerification:s}}),g&&!E()){k();return}O()}}return window.addEventListener(`message`,A),O(),S.addEventListener(`click`,()=>{k()}),v.addEventListener(`click`,()=>{(async()=>{if(!(h.signal.aborted||l)){l=!0,v.disabled=!0,T(void 0);try{if(c||=await ee({iframe:t}),h.signal.aborted)return;let e=c;p?.(),p=await _e({token:e,signal:h.signal,onSuccess:(e,t)=>{if(h.signal.aborted)return;let n=pe(t);if(!n){T(`Select a bank account to continue.`);return}let r=me(t);g={credentials:{public_token:e,account_id:n},bankName:r.bankName,last4:r.last4},c=void 0,O()},onExit:e=>{h.signal.aborted||e?.error_code===`INVALID_LINK_TOKEN`&&(c=void 0)}}),h.signal.aborted&&(p(),p=void 0)}catch(e){if(c=void 0,h.signal.aborted)return;T(e instanceof Error?e.message:`Could not connect bank.`)}finally{l=!1,h.signal.aborted||(v.disabled=!1)}}})()}),{update(e){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()){k();return}O()},destroy(){h.abort(),window.removeEventListener(`message`,A),p?.(),p=void 0,m(t),_.remove()}}}function Q(e){if(typeof e==`string`){let t=document.querySelector(e);if(!(t instanceof HTMLElement))throw Error(`[amos-js] Container "${e}" did not match any HTMLElement.`);return t}return e}var Ce={width:`calc(100% + 8px)`,transition:`opacity 150ms ease-in, height 200ms ease-in-out`,margin:`0 -4px`,opacity:`0`,border:`0`},we={width:`100%`,transition:`height 200ms ease-in-out`,margin:`0`,opacity:`0`,border:`0`},Te={position:`absolute`,top:`0`,left:`0`,width:`100%`,height:`100%`,margin:`0`,opacity:`0`,transition:`none`,pointerEvents:`none`},Ee={position:`absolute`,top:`0`,left:`-4px`,width:`calc(100% + 8px)`,height:`100%`,margin:`0`,transition:`none`,pointerEvents:`none`};function $({src:e,title:t,name:n,height:r,allow:i,className:a,style:o=Ce}){let s=document.createElement(`iframe`);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}function De({host:e,iframe:t,listenerOptions:n,skeletonOptions:r}){let i=document.createElement(`div`);i.style.position=`relative`,i.style.width=`100%`,i.setAttribute(`aria-busy`,`true`);let a=z(r);Object.assign(t.style,Ee),i.append(a.element,t),e.appendChild(i);let o=!1,s=!1,c,l=r.appearance,u,d;function f(){return i.getBoundingClientRect().height}function p(){return c?Number.parseFloat(c):NaN}function m(){if(o)return;o=!0,d!==void 0&&(clearTimeout(d),d=void 0);let e=f(),n=p(),r=Number.isFinite(n)?Math.max(n,e):e;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(()=>{t.style.transition=`height 200ms ease-in-out`},400)}function h(){if(o||!s)return;let e=p(),t=f();Number.isFinite(e)&&e>=t-2&&m()}let g=le(t,{...n,onHeightChange:e=>{c=e,o?t.style.height=e:h(),n.onHeightChange?.(e)},onAppearanceReady:()=>{s=!0,h(),!o&&d===void 0&&(d=setTimeout(()=>{m()},1500)),n.onAppearanceReady?.()}});return{iframe:t,update(e){g.update(e),!o&&`appearance`in e&&(l=e.appearance,a.update({...r,appearance:l}))},destroy(){u!==void 0&&clearTimeout(u),d!==void 0&&clearTimeout(d),g.destroy(),i.remove()}}}function Oe({host:e,iframe:t,listenerOptions:n,iframeStyle:r,attachListeners:i}){let a={height:n.height??`48px`,borderRadius:H({iframeStyle:r,buttonProps:n.buttonProps})},o=B(a),s=document.createElement(`div`);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);let c=!1,l=!1,u,d=n;function f(){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`))}function p(){c||!l||f()}let m=i(t,{...n,onHeightChange:e=>{d.onHeightChange?.(e)},onAppearanceReady:()=>{l=!0,p(),d.onAppearanceReady?.()}});return u=setTimeout(()=>{f()},1500),{iframe:t,update(e){d={...d,...e};let t={...e};delete t.onAppearanceReady,delete t.onHeightChange,m.update(t),a={height:d.height??a.height,borderRadius:H({iframeStyle:r,buttonProps:d.buttonProps})},s.style.height=a.height,c||o.update(a)},destroy(){u!==void 0&&clearTimeout(u),m.destroy(),s.remove()}}}function ke(e,t){let n=Q(e),{renderToken:r,additionalFields:i={cardholderName:!1},billingAddressRequirement:a=`country`,...o}=t;return De({host:n,iframe:$({src:J(r,i,a),title:`Secure credit card payment method form powered by Amos`,name:`amos-credit-card-payment-method-form`,height:X(i,a)}),listenerOptions:o,skeletonOptions:{kind:`card`,appearance:o.appearance,additionalFields:i,billingAddressRequirement:a}})}function Ae(e,t){let n=Q(e),{renderToken:r,billingAddressRequirement:i=`country`,amount:a=`0`,intent:o=`payment`,...s}=t,c=$({src:Y(r,i,o),title:`Secure bank account payment method form powered by Amos`,name:`amos-bank-account-payment-method-form`,height:ce(i)}),l=De({host:n,iframe:c,listenerOptions:s,skeletonOptions:{kind:`bank`,appearance:s.appearance,billingAddressRequirement:i}}),u=Se({host:n,iframe:c,options:{amount:a,appearance:s.appearance,onValidityChange:s.onValidityChange}});return{iframe:c,update(e){l.update(e),u.update(e)},destroy(){u.destroy(),l.destroy()}}}function je(e,t){let n=Q(e),{renderToken:r,iframeClassName:i,iframeStyle:a,...o}=t,s=$({src:U(r),title:`Secure Google Pay button powered by Amos`,name:`amos-google-pay-button`,height:o.height??W(),allow:`payment`,className:i,style:we});return Object.assign(s.style,a),Oe({host:n,iframe:s,listenerOptions:o,iframeStyle:a,attachListeners:G})}function Me(e,t){let n=Q(e),{renderToken:r,iframeClassName:i,iframeStyle:a,...o}=t,s=$({src:A(r),title:`Secure Apple Pay button powered by Amos`,name:`amos-apple-pay-button`,height:o.height??j(),allow:`payment`,className:i,style:we});return Object.assign(s.style,a),Oe({host:n,iframe:s,listenerOptions:o,iframeStyle:a,attachListeners:ne})}exports.SKELETON_STYLES=N,exports.attachApplePayButtonListeners=ne,exports.attachGooglePayButtonListeners=G,exports.attachPaymentMethodFormListeners=le,exports.confirmPaymentIntent=D,exports.confirmSetupIntent=O,exports.createMessage=a,exports.createPaymentMethodFormSkeleton=z,exports.createWalletButtonSkeleton=B,exports.decodeJwt=r,exports.ensureSkeletonStyles=P,exports.formatGooglePayPaymentData=oe,exports.getApplePayButtonInitialHeight=j,exports.getApplePayButtonSrc=A,exports.getBankAccountFormInitialHeight=ce,exports.getBankAccountFormSrc=Y,exports.getCreditCardFormInitialHeight=X,exports.getCreditCardFormSrc=J,exports.getEmbedOrigin=i,exports.getGooglePayButtonInitialHeight=W,exports.getGooglePayButtonSrc=U,exports.linkedBankLabelFromMetadata=me,exports.loadPlaidScript=ge,exports.mountAmosApplePayButton=Me,exports.mountAmosBankAccountPaymentMethodForm=Ae,exports.mountAmosCreditCardPaymentMethodForm=ke,exports.mountAmosGooglePayButton=je,exports.openPlaidLink=_e,exports.plaidAccountIdFromMetadata=pe,exports.requiresAchVerification=de,exports.resetForm=w,exports.resolveWalletButtonSkeletonBorderRadius=H,exports.sendConfirmationResult=k,exports.sendParentReadyMessage=g,exports.updateAmount=b,exports.updateAppearance=_,exports.updateApplePayButton=v,exports.updateGooglePayButton=y,exports.updateMerchantName=x,exports.validateForm=S;
|
package/dist/index.mjs
CHANGED
|
@@ -74,13 +74,7 @@ function r(e) {
|
|
|
74
74
|
signature: r
|
|
75
75
|
};
|
|
76
76
|
}
|
|
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";
|
|
77
|
+
function i(e) {
|
|
84
78
|
let { env: t = "sandbox" } = r(e).payload;
|
|
85
79
|
switch (t) {
|
|
86
80
|
case "production": return "https://embed.amos.com";
|
|
@@ -90,107 +84,107 @@ function a(e) {
|
|
|
90
84
|
}
|
|
91
85
|
//#endregion
|
|
92
86
|
//#region src/types.ts
|
|
93
|
-
function
|
|
87
|
+
function a(e) {
|
|
94
88
|
return e;
|
|
95
89
|
}
|
|
96
90
|
//#endregion
|
|
97
91
|
//#region src/log.ts
|
|
98
|
-
var
|
|
92
|
+
var o = /* @__PURE__ */ new Set([
|
|
99
93
|
"authorization",
|
|
100
94
|
"cookie",
|
|
101
95
|
"set-cookie",
|
|
102
96
|
"x-api-key"
|
|
103
|
-
]),
|
|
97
|
+
]), s = /* @__PURE__ */ new Set([
|
|
104
98
|
"authorization",
|
|
105
99
|
"encrypted_account_number",
|
|
106
100
|
"link_token",
|
|
107
101
|
"public_token",
|
|
108
102
|
"token"
|
|
109
103
|
]);
|
|
110
|
-
function
|
|
104
|
+
function c(e) {
|
|
111
105
|
let t = {};
|
|
112
|
-
for (let [n, r] of Object.entries(e)) t[n] =
|
|
106
|
+
for (let [n, r] of Object.entries(e)) t[n] = o.has(n.toLowerCase()) ? "[REDACTED]" : r;
|
|
113
107
|
return t;
|
|
114
108
|
}
|
|
115
|
-
function
|
|
116
|
-
if (Array.isArray(e)) return e.map(
|
|
109
|
+
function l(e) {
|
|
110
|
+
if (Array.isArray(e)) return e.map(l);
|
|
117
111
|
if (typeof e == "object" && e) {
|
|
118
112
|
let t = {};
|
|
119
|
-
for (let [n, r] of Object.entries(e)) t[n] =
|
|
113
|
+
for (let [n, r] of Object.entries(e)) t[n] = s.has(n) ? "[REDACTED]" : l(r);
|
|
120
114
|
return t;
|
|
121
115
|
}
|
|
122
116
|
return e;
|
|
123
117
|
}
|
|
124
|
-
function
|
|
125
|
-
e.contentWindow?.postMessage(
|
|
118
|
+
function u({ iframe: e, message: t, endpoint: n, headers: r = {}, body: i }) {
|
|
119
|
+
e.contentWindow?.postMessage(a({
|
|
126
120
|
type: "PARENT_INFO_LOG",
|
|
127
121
|
message: t,
|
|
128
122
|
endpoint: n,
|
|
129
|
-
headers:
|
|
130
|
-
body:
|
|
123
|
+
headers: c(r),
|
|
124
|
+
body: l(i)
|
|
131
125
|
}), new URL(e.src).origin);
|
|
132
126
|
}
|
|
133
127
|
//#endregion
|
|
134
128
|
//#region src/plaid-session.ts
|
|
135
|
-
var
|
|
136
|
-
function
|
|
137
|
-
|
|
129
|
+
var d = /* @__PURE__ */ new WeakMap();
|
|
130
|
+
function f(e, t) {
|
|
131
|
+
d.set(e, t);
|
|
138
132
|
}
|
|
139
|
-
function
|
|
140
|
-
if (e) return
|
|
133
|
+
function p(e) {
|
|
134
|
+
if (e) return d.get(e);
|
|
141
135
|
}
|
|
142
|
-
function
|
|
143
|
-
e &&
|
|
136
|
+
function m(e) {
|
|
137
|
+
e && d.delete(e);
|
|
144
138
|
}
|
|
145
139
|
//#endregion
|
|
146
140
|
//#region src/messaging.ts
|
|
147
|
-
function
|
|
141
|
+
function h(e) {
|
|
148
142
|
return new URL(e.src).origin;
|
|
149
143
|
}
|
|
150
|
-
function
|
|
151
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
144
|
+
function g(e) {
|
|
145
|
+
e?.contentWindow && e.contentWindow.postMessage(a({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), h(e));
|
|
152
146
|
}
|
|
153
|
-
function
|
|
154
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
147
|
+
function _({ iframe: e, appearance: t = {} }) {
|
|
148
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
155
149
|
type: "UPDATE_APPEARANCE",
|
|
156
150
|
appearance: t
|
|
157
|
-
}),
|
|
151
|
+
}), h(e));
|
|
158
152
|
}
|
|
159
|
-
function
|
|
160
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
153
|
+
function v({ iframe: e, props: t, height: n }) {
|
|
154
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
161
155
|
type: "UPDATE_APPLE_PAY_BUTTON",
|
|
162
156
|
height: n,
|
|
163
157
|
props: t
|
|
164
|
-
}),
|
|
158
|
+
}), h(e));
|
|
165
159
|
}
|
|
166
|
-
function
|
|
167
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
160
|
+
function y({ iframe: e, props: t, height: n }) {
|
|
161
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
168
162
|
type: "UPDATE_GOOGLE_PAY_BUTTON",
|
|
169
163
|
height: n,
|
|
170
164
|
props: t
|
|
171
|
-
}),
|
|
165
|
+
}), h(e));
|
|
172
166
|
}
|
|
173
|
-
function
|
|
174
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
167
|
+
function b({ iframe: e, amount: t }) {
|
|
168
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
175
169
|
type: "UPDATE_AMOUNT",
|
|
176
170
|
amount: t
|
|
177
|
-
}),
|
|
171
|
+
}), h(e));
|
|
178
172
|
}
|
|
179
|
-
function
|
|
180
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
173
|
+
function x({ iframe: e, merchantName: t }) {
|
|
174
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
181
175
|
type: "UPDATE_MERCHANT_NAME",
|
|
182
176
|
merchantName: t
|
|
183
|
-
}),
|
|
177
|
+
}), h(e));
|
|
184
178
|
}
|
|
185
|
-
function
|
|
186
|
-
let t =
|
|
179
|
+
function S({ iframe: e }) {
|
|
180
|
+
let t = p(e);
|
|
187
181
|
if (t?.requiresVerification) return Promise.resolve(!!t.plaid);
|
|
188
182
|
let n = crypto.randomUUID();
|
|
189
183
|
return new Promise((t) => {
|
|
190
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
184
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
191
185
|
type: "VALIDATE_FORM",
|
|
192
186
|
requestId: n
|
|
193
|
-
}),
|
|
187
|
+
}), h(e));
|
|
194
188
|
let r = setTimeout(() => {
|
|
195
189
|
window.removeEventListener("message", i), t(!1);
|
|
196
190
|
}, 5e3);
|
|
@@ -200,7 +194,7 @@ function C({ iframe: e }) {
|
|
|
200
194
|
window.addEventListener("message", i);
|
|
201
195
|
});
|
|
202
196
|
}
|
|
203
|
-
var
|
|
197
|
+
var C = 1e4;
|
|
204
198
|
function ee({ iframe: e }) {
|
|
205
199
|
let t = crypto.randomUUID();
|
|
206
200
|
return new Promise((n, r) => {
|
|
@@ -209,16 +203,16 @@ function ee({ iframe: e }) {
|
|
|
209
203
|
return;
|
|
210
204
|
}
|
|
211
205
|
let i = e.contentWindow;
|
|
212
|
-
i.postMessage(
|
|
206
|
+
i.postMessage(a({
|
|
213
207
|
type: "CREATE_PLAID_LINK_TOKEN",
|
|
214
208
|
requestId: t
|
|
215
|
-
}),
|
|
216
|
-
let
|
|
209
|
+
}), h(e));
|
|
210
|
+
let o = setTimeout(() => {
|
|
217
211
|
window.removeEventListener("message", s), r(/* @__PURE__ */ Error("Timed out waiting for Plaid Link token."));
|
|
218
|
-
},
|
|
212
|
+
}, C);
|
|
219
213
|
function s(e) {
|
|
220
214
|
if (e.source === i && e.data.type === "PLAID_LINK_TOKEN" && e.data.requestId === t) {
|
|
221
|
-
if (window.removeEventListener("message", s), clearTimeout(
|
|
215
|
+
if (window.removeEventListener("message", s), clearTimeout(o), e.data.link_token) {
|
|
222
216
|
n(e.data.link_token);
|
|
223
217
|
return;
|
|
224
218
|
}
|
|
@@ -228,17 +222,17 @@ function ee({ iframe: e }) {
|
|
|
228
222
|
window.addEventListener("message", s);
|
|
229
223
|
});
|
|
230
224
|
}
|
|
231
|
-
function
|
|
232
|
-
|
|
225
|
+
function w({ iframe: e }) {
|
|
226
|
+
p(e)?.clearLinked?.(), T(e);
|
|
233
227
|
}
|
|
234
|
-
function
|
|
235
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
228
|
+
function T(e) {
|
|
229
|
+
e?.contentWindow && e.contentWindow.postMessage(a({ type: "RESET_FORM" }), h(e));
|
|
236
230
|
}
|
|
237
|
-
function
|
|
238
|
-
let i =
|
|
239
|
-
i?.requiresVerification && !
|
|
240
|
-
let s =
|
|
241
|
-
|
|
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({
|
|
242
236
|
iframe: e,
|
|
243
237
|
message: t === "CONFIRM_PAYMENT_INTENT" ? "confirmPaymentIntent" : "confirmSetupIntent",
|
|
244
238
|
endpoint: t === "CONFIRM_PAYMENT_INTENT" ? "POST /embed/payment_intents/{id}/confirm_with_payment_method" : "POST /embed/setup_intents/{id}/confirm_with_payment_method",
|
|
@@ -249,71 +243,71 @@ function D({ iframe: e, type: t, token: n, id: r }) {
|
|
|
249
243
|
body: {
|
|
250
244
|
id: r,
|
|
251
245
|
token: n,
|
|
252
|
-
...
|
|
246
|
+
...o ? { plaid: o } : {}
|
|
253
247
|
}
|
|
254
|
-
}), e.contentWindow?.postMessage(
|
|
248
|
+
}), e.contentWindow?.postMessage(a({
|
|
255
249
|
type: t,
|
|
256
250
|
token: n,
|
|
257
251
|
id: r,
|
|
258
|
-
...
|
|
259
|
-
}),
|
|
252
|
+
...o ? { plaid: o } : {}
|
|
253
|
+
}), h(e));
|
|
260
254
|
}
|
|
261
|
-
function
|
|
255
|
+
function D({ iframe: e, token: t }) {
|
|
262
256
|
if (!e?.contentWindow) return;
|
|
263
257
|
let { payment_intent_id: n } = r(t).payload;
|
|
264
|
-
|
|
258
|
+
E({
|
|
265
259
|
iframe: e,
|
|
266
260
|
type: "CONFIRM_PAYMENT_INTENT",
|
|
267
261
|
token: t,
|
|
268
262
|
id: n ?? void 0
|
|
269
263
|
});
|
|
270
264
|
}
|
|
271
|
-
function
|
|
265
|
+
function O({ iframe: e, token: t }) {
|
|
272
266
|
if (!e?.contentWindow) return;
|
|
273
267
|
let { setup_intent_id: n } = r(t).payload;
|
|
274
|
-
|
|
268
|
+
E({
|
|
275
269
|
iframe: e,
|
|
276
270
|
type: "CONFIRM_SETUP_INTENT",
|
|
277
271
|
token: t,
|
|
278
272
|
id: n ?? void 0
|
|
279
273
|
});
|
|
280
274
|
}
|
|
281
|
-
function
|
|
282
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
275
|
+
function k({ iframe: e, result: t }) {
|
|
276
|
+
e?.contentWindow && e.contentWindow.postMessage(a({
|
|
283
277
|
type: "CONFIRMATION_RESULT",
|
|
284
278
|
result: t
|
|
285
|
-
}),
|
|
279
|
+
}), h(e));
|
|
286
280
|
}
|
|
287
281
|
//#endregion
|
|
288
282
|
//#region src/apple-pay.ts
|
|
289
|
-
function
|
|
290
|
-
return `${
|
|
283
|
+
function A(e) {
|
|
284
|
+
return `${i(e)}/iframe/apple-pay?token=${e}`;
|
|
291
285
|
}
|
|
292
286
|
function j() {
|
|
293
287
|
return "48px";
|
|
294
288
|
}
|
|
295
|
-
function
|
|
296
|
-
e.contentWindow?.postMessage(
|
|
289
|
+
function te(e) {
|
|
290
|
+
e.contentWindow?.postMessage(a({ type: "APPLE_PAY_CANCEL" }), h(e));
|
|
297
291
|
}
|
|
298
|
-
function
|
|
292
|
+
function ne(e, { height: r = "48px", ...i }) {
|
|
299
293
|
let a = {
|
|
300
294
|
...i,
|
|
301
295
|
height: r
|
|
302
296
|
};
|
|
303
297
|
function o() {
|
|
304
|
-
|
|
298
|
+
b({
|
|
305
299
|
iframe: e,
|
|
306
300
|
amount: a.amount
|
|
307
301
|
});
|
|
308
302
|
}
|
|
309
303
|
function s() {
|
|
310
|
-
|
|
304
|
+
x({
|
|
311
305
|
iframe: e,
|
|
312
306
|
merchantName: a.merchantName
|
|
313
307
|
});
|
|
314
308
|
}
|
|
315
309
|
function c() {
|
|
316
|
-
|
|
310
|
+
v({
|
|
317
311
|
iframe: e,
|
|
318
312
|
height: a.height ?? "48px",
|
|
319
313
|
props: a.buttonProps ?? {}
|
|
@@ -322,7 +316,7 @@ function M(e, { height: r = "48px", ...i }) {
|
|
|
322
316
|
function l(r) {
|
|
323
317
|
if (r.source === e.contentWindow) switch (r.data.type) {
|
|
324
318
|
case "IFRAME_READY":
|
|
325
|
-
|
|
319
|
+
g(e), _({
|
|
326
320
|
iframe: e,
|
|
327
321
|
appearance: {}
|
|
328
322
|
}), o(), s(), c();
|
|
@@ -331,7 +325,7 @@ function M(e, { height: r = "48px", ...i }) {
|
|
|
331
325
|
a.onHeightChange?.(r.data.height);
|
|
332
326
|
break;
|
|
333
327
|
case "UPDATE_APPEARANCE":
|
|
334
|
-
|
|
328
|
+
_({
|
|
335
329
|
iframe: e,
|
|
336
330
|
appearance: r.data.appearance
|
|
337
331
|
});
|
|
@@ -341,7 +335,7 @@ function M(e, { height: r = "48px", ...i }) {
|
|
|
341
335
|
break;
|
|
342
336
|
case "APPLE_PAY_WINDOW_OPEN":
|
|
343
337
|
t({ onCancel: () => {
|
|
344
|
-
|
|
338
|
+
te(e), n();
|
|
345
339
|
} });
|
|
346
340
|
break;
|
|
347
341
|
case "APPLE_PAY_WINDOW_CLOSE":
|
|
@@ -352,7 +346,7 @@ function M(e, { height: r = "48px", ...i }) {
|
|
|
352
346
|
paymentIntentCreateAttributes: r.data.paymentIntentCreateAttributes,
|
|
353
347
|
customerCreateAttributes: r.data.customerCreateAttributes
|
|
354
348
|
}).then((t) => {
|
|
355
|
-
|
|
349
|
+
D({
|
|
356
350
|
iframe: e,
|
|
357
351
|
token: t
|
|
358
352
|
});
|
|
@@ -381,7 +375,7 @@ function M(e, { height: r = "48px", ...i }) {
|
|
|
381
375
|
}
|
|
382
376
|
//#endregion
|
|
383
377
|
//#region src/form-skeleton.ts
|
|
384
|
-
var
|
|
378
|
+
var M = "amos-js-form-skeleton-styles", re = {
|
|
385
379
|
"--accent": "oklch(0.97 0 0)",
|
|
386
380
|
"--radius": "0.625rem",
|
|
387
381
|
"--input-height": "2.25rem",
|
|
@@ -389,13 +383,13 @@ var N = "amos-js-form-skeleton-styles", re = {
|
|
|
389
383
|
"--field-gap": "1rem",
|
|
390
384
|
"--control-gap": "0.5rem",
|
|
391
385
|
"--label-font-size": "0.875rem"
|
|
392
|
-
},
|
|
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";
|
|
393
387
|
function P() {
|
|
394
|
-
if (document.getElementById(
|
|
388
|
+
if (document.getElementById(M)) return;
|
|
395
389
|
let e = document.createElement("style");
|
|
396
|
-
e.id =
|
|
390
|
+
e.id = M, e.textContent = N, document.head.appendChild(e);
|
|
397
391
|
}
|
|
398
|
-
function
|
|
392
|
+
function ie(e, t) {
|
|
399
393
|
for (let [t, n] of Object.entries(re)) e.style.setProperty(t, n);
|
|
400
394
|
let n = t?.themeVariables;
|
|
401
395
|
if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && r.trim() !== "" && e.style.setProperty(t, r.trim());
|
|
@@ -426,7 +420,7 @@ function R({ labels: e, requirement: t, wrapCountryZip: n }) {
|
|
|
426
420
|
I(e)
|
|
427
421
|
] : [L([I(e), I(e)], n)];
|
|
428
422
|
}
|
|
429
|
-
function
|
|
423
|
+
function ae(e) {
|
|
430
424
|
let t = e.appearance?.labels ?? "above", n = e.billingAddressRequirement ?? "country";
|
|
431
425
|
if (e.kind === "card") {
|
|
432
426
|
let r = [I(t), L([I(t), I(t)], !1)];
|
|
@@ -453,7 +447,7 @@ function z(e) {
|
|
|
453
447
|
let t = F("amos-js-form-skeleton");
|
|
454
448
|
t.setAttribute("aria-hidden", "true");
|
|
455
449
|
function n(e) {
|
|
456
|
-
|
|
450
|
+
ie(t, e.appearance), t.replaceChildren(...ae(e));
|
|
457
451
|
}
|
|
458
452
|
return n(e), {
|
|
459
453
|
element: t,
|
|
@@ -465,7 +459,7 @@ function B(e) {
|
|
|
465
459
|
let t = F("amos-js-form-skeleton-input amos-js-wallet-skeleton");
|
|
466
460
|
t.setAttribute("aria-hidden", "true");
|
|
467
461
|
function n(e) {
|
|
468
|
-
|
|
462
|
+
ie(t, void 0), t.style.height = e.height, t.style.borderRadius = e.borderRadius ?? "4px";
|
|
469
463
|
}
|
|
470
464
|
return n(e), {
|
|
471
465
|
element: t,
|
|
@@ -482,7 +476,7 @@ function H({ iframeStyle: e, buttonProps: t }) {
|
|
|
482
476
|
//#endregion
|
|
483
477
|
//#region src/google-pay.ts
|
|
484
478
|
function U(e) {
|
|
485
|
-
return `${
|
|
479
|
+
return `${i(e)}/iframe/google-pay?token=${e}`;
|
|
486
480
|
}
|
|
487
481
|
function W() {
|
|
488
482
|
return "48px";
|
|
@@ -493,19 +487,19 @@ function G(e, { height: t = "48px", ...n }) {
|
|
|
493
487
|
height: t
|
|
494
488
|
};
|
|
495
489
|
function i() {
|
|
496
|
-
|
|
490
|
+
b({
|
|
497
491
|
iframe: e,
|
|
498
492
|
amount: r.amount
|
|
499
493
|
});
|
|
500
494
|
}
|
|
501
495
|
function a() {
|
|
502
|
-
|
|
496
|
+
x({
|
|
503
497
|
iframe: e,
|
|
504
498
|
merchantName: r.merchantName
|
|
505
499
|
});
|
|
506
500
|
}
|
|
507
501
|
function o() {
|
|
508
|
-
|
|
502
|
+
y({
|
|
509
503
|
iframe: e,
|
|
510
504
|
height: r.height ?? "48px",
|
|
511
505
|
props: r.buttonProps ?? {}
|
|
@@ -514,7 +508,7 @@ function G(e, { height: t = "48px", ...n }) {
|
|
|
514
508
|
function s(t) {
|
|
515
509
|
if (t.source === e.contentWindow) switch (t.data.type) {
|
|
516
510
|
case "IFRAME_READY":
|
|
517
|
-
|
|
511
|
+
g(e), _({
|
|
518
512
|
iframe: e,
|
|
519
513
|
appearance: {}
|
|
520
514
|
}), i(), a(), o();
|
|
@@ -523,7 +517,7 @@ function G(e, { height: t = "48px", ...n }) {
|
|
|
523
517
|
r.onHeightChange?.(t.data.height);
|
|
524
518
|
break;
|
|
525
519
|
case "UPDATE_APPEARANCE":
|
|
526
|
-
|
|
520
|
+
_({
|
|
527
521
|
iframe: e,
|
|
528
522
|
appearance: t.data.appearance
|
|
529
523
|
});
|
|
@@ -536,7 +530,7 @@ function G(e, { height: t = "48px", ...n }) {
|
|
|
536
530
|
paymentIntentCreateAttributes: t.data.paymentIntentCreateAttributes,
|
|
537
531
|
customerCreateAttributes: t.data.customerCreateAttributes
|
|
538
532
|
}).then((t) => {
|
|
539
|
-
|
|
533
|
+
D({
|
|
540
534
|
iframe: e,
|
|
541
535
|
token: t
|
|
542
536
|
});
|
|
@@ -563,7 +557,7 @@ function G(e, { height: t = "48px", ...n }) {
|
|
|
563
557
|
}
|
|
564
558
|
};
|
|
565
559
|
}
|
|
566
|
-
function
|
|
560
|
+
function oe({ paymentData: e }) {
|
|
567
561
|
return { paymentMethod: {
|
|
568
562
|
type: "googlepay",
|
|
569
563
|
billing_address_attributes: {
|
|
@@ -585,37 +579,37 @@ function se({ paymentData: e }) {
|
|
|
585
579
|
var K = {
|
|
586
580
|
country: 212,
|
|
587
581
|
full: 452
|
|
588
|
-
},
|
|
582
|
+
}, se = 80, q = {
|
|
589
583
|
country: 400,
|
|
590
584
|
full: 640
|
|
591
585
|
};
|
|
592
586
|
function J(e, t = { cardholderName: !1 }, n = "country") {
|
|
593
|
-
let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","),
|
|
587
|
+
let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","), a = new URLSearchParams({
|
|
594
588
|
token: e,
|
|
595
589
|
additionalFields: r,
|
|
596
590
|
billingAddressRequirement: n
|
|
597
591
|
});
|
|
598
|
-
return `${
|
|
592
|
+
return `${i(e)}/iframe/card?${a}`;
|
|
599
593
|
}
|
|
600
594
|
function Y(e, t = "country", n = "payment") {
|
|
601
595
|
let r = new URLSearchParams({
|
|
602
596
|
token: e,
|
|
603
597
|
billingAddressRequirement: t
|
|
604
598
|
});
|
|
605
|
-
return n === "setup" && r.set("intent", "setup"), `${
|
|
599
|
+
return n === "setup" && r.set("intent", "setup"), `${i(e)}/iframe/bank?${r}`;
|
|
606
600
|
}
|
|
607
|
-
function
|
|
608
|
-
return `${(K[t] ?? K.country) + (e.cardholderName ?
|
|
601
|
+
function X(e = { cardholderName: !1 }, t = "country") {
|
|
602
|
+
return `${(K[t] ?? K.country) + (e.cardholderName ? se : 0)}px`;
|
|
609
603
|
}
|
|
610
|
-
function
|
|
604
|
+
function ce(e = "country") {
|
|
611
605
|
return `${q[e] ?? q.country}px`;
|
|
612
606
|
}
|
|
613
|
-
function
|
|
607
|
+
function le(e, t) {
|
|
614
608
|
let n = { ...t };
|
|
615
609
|
function r(t) {
|
|
616
610
|
if (t.source === e.contentWindow) switch (t.data.type) {
|
|
617
611
|
case "IFRAME_READY":
|
|
618
|
-
|
|
612
|
+
g(e), _({
|
|
619
613
|
iframe: e,
|
|
620
614
|
appearance: n.appearance
|
|
621
615
|
});
|
|
@@ -624,7 +618,7 @@ function de(e, t) {
|
|
|
624
618
|
n.onHeightChange?.(t.data.height);
|
|
625
619
|
break;
|
|
626
620
|
case "UPDATE_APPEARANCE":
|
|
627
|
-
|
|
621
|
+
_({
|
|
628
622
|
iframe: e,
|
|
629
623
|
appearance: t.data.appearance
|
|
630
624
|
});
|
|
@@ -633,7 +627,7 @@ function de(e, t) {
|
|
|
633
627
|
n.onAppearanceReady?.();
|
|
634
628
|
break;
|
|
635
629
|
case "FORM_VALIDITY_CHANGE":
|
|
636
|
-
if (
|
|
630
|
+
if (p(e)?.requiresVerification) break;
|
|
637
631
|
n.onValidityChange?.({ isValid: t.data.isValid });
|
|
638
632
|
break;
|
|
639
633
|
case "CARD_BRAND_CHANGE":
|
|
@@ -648,7 +642,7 @@ function de(e, t) {
|
|
|
648
642
|
n = {
|
|
649
643
|
...n,
|
|
650
644
|
...t
|
|
651
|
-
}, r &&
|
|
645
|
+
}, r && _({
|
|
652
646
|
iframe: e,
|
|
653
647
|
appearance: n.appearance
|
|
654
648
|
});
|
|
@@ -660,37 +654,37 @@ function de(e, t) {
|
|
|
660
654
|
}
|
|
661
655
|
//#endregion
|
|
662
656
|
//#region src/plaid.ts
|
|
663
|
-
var
|
|
664
|
-
function
|
|
657
|
+
var ue = "https://cdn.plaid.com/link/v2/stable/link-initialize.js";
|
|
658
|
+
function de({ amount: e, achThreshold: t }) {
|
|
665
659
|
return t != null && (e ?? 0) >= t;
|
|
666
660
|
}
|
|
667
|
-
function
|
|
661
|
+
function fe(e) {
|
|
668
662
|
if (e == null) return;
|
|
669
663
|
let t = e.trim();
|
|
670
664
|
if (t === "") return;
|
|
671
665
|
let n = Number(t.replace(/[^\d.]/g, ""));
|
|
672
666
|
if (Number.isFinite(n)) return Math.round(n * 100);
|
|
673
667
|
}
|
|
674
|
-
function
|
|
668
|
+
function pe(e) {
|
|
675
669
|
return e.account_id ?? e.account?.id ?? e.accounts?.[0]?.id;
|
|
676
670
|
}
|
|
677
|
-
function
|
|
671
|
+
function me(e) {
|
|
678
672
|
let t = e.account ?? e.accounts?.[0];
|
|
679
673
|
return {
|
|
680
674
|
bankName: e.institution?.name ?? "Bank account",
|
|
681
675
|
last4: t?.mask ?? ""
|
|
682
676
|
};
|
|
683
677
|
}
|
|
684
|
-
var
|
|
685
|
-
function
|
|
686
|
-
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();
|
|
687
681
|
}
|
|
688
|
-
function
|
|
689
|
-
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) => {
|
|
690
684
|
let n = document.createElement("script");
|
|
691
|
-
n.src =
|
|
685
|
+
n.src = ue, n.async = !0;
|
|
692
686
|
let r = (e) => {
|
|
693
|
-
n.remove(),
|
|
687
|
+
n.remove(), Z = void 0, t(Error(e));
|
|
694
688
|
};
|
|
695
689
|
n.addEventListener("load", () => {
|
|
696
690
|
if (window.Plaid) {
|
|
@@ -699,10 +693,10 @@ function ve() {
|
|
|
699
693
|
}
|
|
700
694
|
r("Plaid Link failed to initialize");
|
|
701
695
|
}, { once: !0 }), n.addEventListener("error", () => r("Failed to load Plaid Link"), { once: !0 }), document.head.append(n);
|
|
702
|
-
}),
|
|
696
|
+
}), Z);
|
|
703
697
|
}
|
|
704
|
-
async function
|
|
705
|
-
if (await
|
|
698
|
+
async function _e({ token: e, onSuccess: t, onExit: n, signal: r }) {
|
|
699
|
+
if (await ge(), r?.aborted) return () => {};
|
|
706
700
|
if (!window.Plaid) throw Error("Plaid Link failed to initialize");
|
|
707
701
|
let i = window.Plaid.create({
|
|
708
702
|
token: e,
|
|
@@ -717,25 +711,25 @@ async function ye({ token: e, onSuccess: t, onExit: n, signal: r }) {
|
|
|
717
711
|
}
|
|
718
712
|
//#endregion
|
|
719
713
|
//#region src/plaid-bank-ui.ts
|
|
720
|
-
var
|
|
721
|
-
function
|
|
722
|
-
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;
|
|
723
717
|
let e = document.createElement("style");
|
|
724
|
-
e.id =
|
|
718
|
+
e.id = ve, e.textContent = ye, document.head.append(e);
|
|
725
719
|
}
|
|
726
|
-
function
|
|
720
|
+
function xe(e, t, n) {
|
|
727
721
|
for (let t of n) e.style.removeProperty(t);
|
|
728
722
|
n.length = 0;
|
|
729
723
|
let r = t?.themeVariables;
|
|
730
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));
|
|
731
725
|
}
|
|
732
|
-
function
|
|
733
|
-
|
|
726
|
+
function Se({ host: e, iframe: t, options: n }) {
|
|
727
|
+
be();
|
|
734
728
|
let r = {
|
|
735
729
|
...n,
|
|
736
730
|
amount: n.amount ?? "0"
|
|
737
|
-
}, i = [], a = !1, o, s = !1, c, l = !1,
|
|
738
|
-
_.className = "amos-js-plaid-panel", _.setAttribute("data-amos-plaid-panel", "true"), _.dataset.mode = "hidden",
|
|
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);
|
|
739
733
|
let v = document.createElement("button");
|
|
740
734
|
v.type = "button", v.className = "amos-js-plaid-connect", v.textContent = "Connect bank account", v.setAttribute("data-testid", "amos-plaid-connect");
|
|
741
735
|
let y = document.createElement("div");
|
|
@@ -753,33 +747,33 @@ function we({ host: e, iframe: t, options: n }) {
|
|
|
753
747
|
C.textContent = e ?? "";
|
|
754
748
|
}
|
|
755
749
|
function E() {
|
|
756
|
-
return a ? s ? !0 :
|
|
757
|
-
amount:
|
|
750
|
+
return a ? s ? !0 : de({
|
|
751
|
+
amount: fe(r.amount),
|
|
758
752
|
achThreshold: o
|
|
759
753
|
}) : !1;
|
|
760
754
|
}
|
|
761
755
|
function D() {
|
|
762
756
|
let e = !!g;
|
|
763
|
-
|
|
757
|
+
d !== e && (d = e, r.onValidityChange?.({ isValid: e }));
|
|
764
758
|
}
|
|
765
759
|
function O() {
|
|
766
760
|
let e = E();
|
|
767
|
-
if (
|
|
761
|
+
if (f(t, {
|
|
768
762
|
requiresVerification: e,
|
|
769
763
|
plaid: e ? g?.credentials : void 0,
|
|
770
764
|
clearLinked: k
|
|
771
765
|
}), !e) {
|
|
772
|
-
_.dataset.mode = "hidden", w && (w.style.display = ""),
|
|
766
|
+
_.dataset.mode = "hidden", w && (w.style.display = ""), d = void 0;
|
|
773
767
|
return;
|
|
774
768
|
}
|
|
775
769
|
_.dataset.mode = g ? "linked" : "connect", w && (w.style.display = "none"), g && (b.textContent = g.bankName, x.textContent = g.last4 ? `****${g.last4}` : "Connected"), D();
|
|
776
770
|
}
|
|
777
771
|
function k() {
|
|
778
|
-
g = void 0, c = void 0,
|
|
772
|
+
g = void 0, c = void 0, p?.(), p = void 0, T(void 0), O();
|
|
779
773
|
}
|
|
780
774
|
function A(e) {
|
|
781
775
|
if (e.source === t.contentWindow && e.data.type === "ACH_THRESHOLD") {
|
|
782
|
-
if (a = !0, o = e.data.achThreshold ?? void 0, s = e.data.requireVerification === !0,
|
|
776
|
+
if (a = !0, o = e.data.achThreshold ?? void 0, s = e.data.requireVerification === !0, u({
|
|
783
777
|
iframe: t,
|
|
784
778
|
message: "merchant ach_threshold",
|
|
785
779
|
endpoint: "ACH_THRESHOLD",
|
|
@@ -799,22 +793,22 @@ function we({ host: e, iframe: t, options: n }) {
|
|
|
799
793
|
k();
|
|
800
794
|
}), v.addEventListener("click", () => {
|
|
801
795
|
(async () => {
|
|
802
|
-
if (!(
|
|
796
|
+
if (!(h.signal.aborted || l)) {
|
|
803
797
|
l = !0, v.disabled = !0, T(void 0);
|
|
804
798
|
try {
|
|
805
|
-
if (c ||= await ee({ iframe: t }),
|
|
799
|
+
if (c ||= await ee({ iframe: t }), h.signal.aborted) return;
|
|
806
800
|
let e = c;
|
|
807
|
-
|
|
801
|
+
p?.(), p = await _e({
|
|
808
802
|
token: e,
|
|
809
|
-
signal:
|
|
803
|
+
signal: h.signal,
|
|
810
804
|
onSuccess: (e, t) => {
|
|
811
|
-
if (
|
|
812
|
-
let n =
|
|
805
|
+
if (h.signal.aborted) return;
|
|
806
|
+
let n = pe(t);
|
|
813
807
|
if (!n) {
|
|
814
808
|
T("Select a bank account to continue.");
|
|
815
809
|
return;
|
|
816
810
|
}
|
|
817
|
-
let r =
|
|
811
|
+
let r = me(t);
|
|
818
812
|
g = {
|
|
819
813
|
credentials: {
|
|
820
814
|
public_token: e,
|
|
@@ -825,33 +819,33 @@ function we({ host: e, iframe: t, options: n }) {
|
|
|
825
819
|
}, c = void 0, O();
|
|
826
820
|
},
|
|
827
821
|
onExit: (e) => {
|
|
828
|
-
|
|
822
|
+
h.signal.aborted || e?.error_code === "INVALID_LINK_TOKEN" && (c = void 0);
|
|
829
823
|
}
|
|
830
|
-
}),
|
|
824
|
+
}), h.signal.aborted && (p(), p = void 0);
|
|
831
825
|
} catch (e) {
|
|
832
|
-
if (c = void 0,
|
|
826
|
+
if (c = void 0, h.signal.aborted) return;
|
|
833
827
|
T(e instanceof Error ? e.message : "Could not connect bank.");
|
|
834
828
|
} finally {
|
|
835
|
-
l = !1,
|
|
829
|
+
l = !1, h.signal.aborted || (v.disabled = !1);
|
|
836
830
|
}
|
|
837
831
|
}
|
|
838
832
|
})();
|
|
839
833
|
}), {
|
|
840
834
|
update(e) {
|
|
841
|
-
if ("amount" in e && (r.amount = e.amount ?? "0"), "onValidityChange" in e && (r.onValidityChange = e.onValidityChange), "appearance" in e && (r.appearance = e.appearance,
|
|
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()) {
|
|
842
836
|
k();
|
|
843
837
|
return;
|
|
844
838
|
}
|
|
845
839
|
O();
|
|
846
840
|
},
|
|
847
841
|
destroy() {
|
|
848
|
-
|
|
842
|
+
h.abort(), window.removeEventListener("message", A), p?.(), p = void 0, m(t), _.remove();
|
|
849
843
|
}
|
|
850
844
|
};
|
|
851
845
|
}
|
|
852
846
|
//#endregion
|
|
853
847
|
//#region src/mount.ts
|
|
854
|
-
function
|
|
848
|
+
function Q(e) {
|
|
855
849
|
if (typeof e == "string") {
|
|
856
850
|
let t = document.querySelector(e);
|
|
857
851
|
if (!(t instanceof HTMLElement)) throw Error(`[amos-js] Container "${e}" did not match any HTMLElement.`);
|
|
@@ -859,19 +853,19 @@ function Z(e) {
|
|
|
859
853
|
}
|
|
860
854
|
return e;
|
|
861
855
|
}
|
|
862
|
-
var
|
|
856
|
+
var Ce = {
|
|
863
857
|
width: "calc(100% + 8px)",
|
|
864
858
|
transition: "opacity 150ms ease-in, height 200ms ease-in-out",
|
|
865
859
|
margin: "0 -4px",
|
|
866
860
|
opacity: "0",
|
|
867
861
|
border: "0"
|
|
868
|
-
},
|
|
862
|
+
}, we = {
|
|
869
863
|
width: "100%",
|
|
870
864
|
transition: "height 200ms ease-in-out",
|
|
871
865
|
margin: "0",
|
|
872
866
|
opacity: "0",
|
|
873
867
|
border: "0"
|
|
874
|
-
},
|
|
868
|
+
}, Te = {
|
|
875
869
|
position: "absolute",
|
|
876
870
|
top: "0",
|
|
877
871
|
left: "0",
|
|
@@ -881,7 +875,7 @@ var Q = {
|
|
|
881
875
|
opacity: "0",
|
|
882
876
|
transition: "none",
|
|
883
877
|
pointerEvents: "none"
|
|
884
|
-
},
|
|
878
|
+
}, Ee = {
|
|
885
879
|
position: "absolute",
|
|
886
880
|
top: "0",
|
|
887
881
|
left: "-4px",
|
|
@@ -891,15 +885,15 @@ var Q = {
|
|
|
891
885
|
transition: "none",
|
|
892
886
|
pointerEvents: "none"
|
|
893
887
|
};
|
|
894
|
-
function $({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o =
|
|
888
|
+
function $({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o = Ce }) {
|
|
895
889
|
let s = document.createElement("iframe");
|
|
896
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;
|
|
897
891
|
}
|
|
898
|
-
function
|
|
892
|
+
function De({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
899
893
|
let i = document.createElement("div");
|
|
900
894
|
i.style.position = "relative", i.style.width = "100%", i.setAttribute("aria-busy", "true");
|
|
901
895
|
let a = z(r);
|
|
902
|
-
Object.assign(t.style,
|
|
896
|
+
Object.assign(t.style, Ee), i.append(a.element, t), e.appendChild(i);
|
|
903
897
|
let o = !1, s = !1, c, l = r.appearance, u, d;
|
|
904
898
|
function f() {
|
|
905
899
|
return i.getBoundingClientRect().height;
|
|
@@ -911,7 +905,7 @@ function Oe({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
911
905
|
if (o) return;
|
|
912
906
|
o = !0, d !== void 0 && (clearTimeout(d), d = void 0);
|
|
913
907
|
let e = f(), n = p(), r = Number.isFinite(n) ? Math.max(n, e) : e;
|
|
914
|
-
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(() => {
|
|
915
909
|
t.style.transition = "height 200ms ease-in-out";
|
|
916
910
|
}, 400);
|
|
917
911
|
}
|
|
@@ -920,7 +914,7 @@ function Oe({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
920
914
|
let e = p(), t = f();
|
|
921
915
|
Number.isFinite(e) && e >= t - 2 && m();
|
|
922
916
|
}
|
|
923
|
-
let g =
|
|
917
|
+
let g = le(t, {
|
|
924
918
|
...n,
|
|
925
919
|
onHeightChange: (e) => {
|
|
926
920
|
c = e, o ? t.style.height = e : h(), n.onHeightChange?.(e);
|
|
@@ -944,7 +938,7 @@ function Oe({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
944
938
|
}
|
|
945
939
|
};
|
|
946
940
|
}
|
|
947
|
-
function
|
|
941
|
+
function Oe({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListeners: i }) {
|
|
948
942
|
let a = {
|
|
949
943
|
height: n.height ?? "48px",
|
|
950
944
|
borderRadius: H({
|
|
@@ -952,7 +946,7 @@ function ke({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachList
|
|
|
952
946
|
buttonProps: n.buttonProps
|
|
953
947
|
})
|
|
954
948
|
}, 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,
|
|
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);
|
|
956
950
|
let c = !1, l = !1, u, d = n;
|
|
957
951
|
function f() {
|
|
958
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"));
|
|
@@ -992,15 +986,15 @@ function ke({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachList
|
|
|
992
986
|
}
|
|
993
987
|
};
|
|
994
988
|
}
|
|
995
|
-
function
|
|
996
|
-
let n =
|
|
997
|
-
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({
|
|
998
992
|
host: n,
|
|
999
993
|
iframe: $({
|
|
1000
994
|
src: J(r, i, a),
|
|
1001
995
|
title: "Secure credit card payment method form powered by Amos",
|
|
1002
996
|
name: "amos-credit-card-payment-method-form",
|
|
1003
|
-
height:
|
|
997
|
+
height: X(i, a)
|
|
1004
998
|
}),
|
|
1005
999
|
listenerOptions: o,
|
|
1006
1000
|
skeletonOptions: {
|
|
@@ -1011,13 +1005,13 @@ function Ae(e, t) {
|
|
|
1011
1005
|
}
|
|
1012
1006
|
});
|
|
1013
1007
|
}
|
|
1014
|
-
function
|
|
1015
|
-
let n =
|
|
1008
|
+
function Ae(e, t) {
|
|
1009
|
+
let n = Q(e), { renderToken: r, billingAddressRequirement: i = "country", amount: a = "0", intent: o = "payment", ...s } = t, c = $({
|
|
1016
1010
|
src: Y(r, i, o),
|
|
1017
1011
|
title: "Secure bank account payment method form powered by Amos",
|
|
1018
1012
|
name: "amos-bank-account-payment-method-form",
|
|
1019
|
-
height:
|
|
1020
|
-
}), l =
|
|
1013
|
+
height: ce(i)
|
|
1014
|
+
}), l = De({
|
|
1021
1015
|
host: n,
|
|
1022
1016
|
iframe: c,
|
|
1023
1017
|
listenerOptions: s,
|
|
@@ -1026,7 +1020,7 @@ function je(e, t) {
|
|
|
1026
1020
|
appearance: s.appearance,
|
|
1027
1021
|
billingAddressRequirement: i
|
|
1028
1022
|
}
|
|
1029
|
-
}), u =
|
|
1023
|
+
}), u = Se({
|
|
1030
1024
|
host: n,
|
|
1031
1025
|
iframe: c,
|
|
1032
1026
|
options: {
|
|
@@ -1045,17 +1039,17 @@ function je(e, t) {
|
|
|
1045
1039
|
}
|
|
1046
1040
|
};
|
|
1047
1041
|
}
|
|
1048
|
-
function
|
|
1049
|
-
let n =
|
|
1042
|
+
function je(e, t) {
|
|
1043
|
+
let n = Q(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = $({
|
|
1050
1044
|
src: U(r),
|
|
1051
1045
|
title: "Secure Google Pay button powered by Amos",
|
|
1052
1046
|
name: "amos-google-pay-button",
|
|
1053
1047
|
height: o.height ?? W(),
|
|
1054
1048
|
allow: "payment",
|
|
1055
1049
|
className: i,
|
|
1056
|
-
style:
|
|
1050
|
+
style: we
|
|
1057
1051
|
});
|
|
1058
|
-
return Object.assign(s.style, a),
|
|
1052
|
+
return Object.assign(s.style, a), Oe({
|
|
1059
1053
|
host: n,
|
|
1060
1054
|
iframe: s,
|
|
1061
1055
|
listenerOptions: o,
|
|
@@ -1063,23 +1057,23 @@ function Me(e, t) {
|
|
|
1063
1057
|
attachListeners: G
|
|
1064
1058
|
});
|
|
1065
1059
|
}
|
|
1066
|
-
function
|
|
1067
|
-
let n =
|
|
1068
|
-
src:
|
|
1060
|
+
function Me(e, t) {
|
|
1061
|
+
let n = Q(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = $({
|
|
1062
|
+
src: A(r),
|
|
1069
1063
|
title: "Secure Apple Pay button powered by Amos",
|
|
1070
1064
|
name: "amos-apple-pay-button",
|
|
1071
1065
|
height: o.height ?? j(),
|
|
1072
1066
|
allow: "payment",
|
|
1073
1067
|
className: i,
|
|
1074
|
-
style:
|
|
1068
|
+
style: we
|
|
1075
1069
|
});
|
|
1076
|
-
return Object.assign(s.style, a),
|
|
1070
|
+
return Object.assign(s.style, a), Oe({
|
|
1077
1071
|
host: n,
|
|
1078
1072
|
iframe: s,
|
|
1079
1073
|
listenerOptions: o,
|
|
1080
1074
|
iframeStyle: a,
|
|
1081
|
-
attachListeners:
|
|
1075
|
+
attachListeners: ne
|
|
1082
1076
|
});
|
|
1083
1077
|
}
|
|
1084
1078
|
//#endregion
|
|
1085
|
-
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 };
|
package/dist/jwt.d.ts
CHANGED
|
@@ -12,9 +12,5 @@ export declare function decodeJwt(token: string | undefined): {
|
|
|
12
12
|
/**
|
|
13
13
|
* Resolve the Amos embed origin (production vs. sandbox) from a render
|
|
14
14
|
* token's decoded payload.
|
|
15
|
-
*
|
|
16
|
-
* When the parent page is on localhost / *.localhost, always target the
|
|
17
|
-
* local embed app (https://embed.localhost) so dashboard + embed can be
|
|
18
|
-
* developed together without pointing at sandbox/production iframes.
|
|
19
15
|
*/
|
|
20
16
|
export declare function getEmbedOrigin(renderToken: string): string;
|
package/package.json
CHANGED
package/src/jwt.ts
CHANGED
|
@@ -25,35 +25,11 @@ export function decodeJwt(token: string | undefined): {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
// --- BEGIN amos-ui sdk:link localhost embed origin ---
|
|
29
|
-
/**
|
|
30
|
-
* True when the parent page is running on localhost / *.localhost
|
|
31
|
-
* (e.g. https://dashboard.localhost via portless).
|
|
32
|
-
*
|
|
33
|
-
* Injected by amos-ui `pnpm sdk:link`; removed by `pnpm sdk:unlink`.
|
|
34
|
-
* Do not commit this block to amos-js.
|
|
35
|
-
*/
|
|
36
|
-
function isLocalhostParent(): boolean {
|
|
37
|
-
if (typeof window === "undefined") {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
const { hostname } = window.location;
|
|
41
|
-
return hostname === "localhost" || hostname.endsWith(".localhost");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
28
|
/**
|
|
45
29
|
* Resolve the Amos embed origin (production vs. sandbox) from a render
|
|
46
30
|
* token's decoded payload.
|
|
47
|
-
*
|
|
48
|
-
* When the parent page is on localhost / *.localhost, always target the
|
|
49
|
-
* local embed app (https://embed.localhost) so dashboard + embed can be
|
|
50
|
-
* developed together without pointing at sandbox/production iframes.
|
|
51
31
|
*/
|
|
52
32
|
export function getEmbedOrigin(renderToken: string): string {
|
|
53
|
-
if (isLocalhostParent()) {
|
|
54
|
-
return "https://embed.localhost";
|
|
55
|
-
}
|
|
56
|
-
|
|
57
33
|
const { env = "sandbox" }: components["schemas"]["RenderTokenJwt"] =
|
|
58
34
|
decodeJwt(renderToken).payload;
|
|
59
35
|
|
|
@@ -66,4 +42,3 @@ export function getEmbedOrigin(renderToken: string): string {
|
|
|
66
42
|
return "https://embed-sandbox.amos.com";
|
|
67
43
|
}
|
|
68
44
|
}
|
|
69
|
-
// --- END amos-ui sdk:link localhost embed origin ---
|