@onefootprint/footprint-js
Advanced tools
Comparing version 3.14.1 to 3.14.2
@@ -1,6 +0,5 @@ | ||
import lt from 'crypto'; | ||
import Mt from '@onefootprint/postmate'; | ||
import Lt from '@onefootprint/postmate'; | ||
var st=Object.defineProperty,dt=Object.defineProperties;var pt=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var Ce=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable;var Pe=(e,t,o)=>t in e?st(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,h=(e,t)=>{for(var o in t||(t={}))Ce.call(t,o)&&Pe(e,o,t[o]);if(R)for(var o of R(t))be.call(t,o)&&Pe(e,o,t[o]);return e},P=(e,t)=>dt(e,pt(t));var ve=(e,t)=>{var o={};for(var n in e)Ce.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&R)for(var n of R(e))t.indexOf(n)<0&&be.call(e,n)&&(o[n]=e[n]);return o};var u=(e,t,o)=>new Promise((n,r)=>{var a=p=>{try{s(o.next(p));}catch(d){r(d);}},i=p=>{try{s(o.throw(p));}catch(d){r(d);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(a,i);s((o=o.apply(e,t)).next());});var K=new Uint8Array(256),D=K.length;function Z(){return D>K.length-16&&(lt.randomFillSync(K),D=0),K.slice(D,D+=16)}var y=[];for(let e=0;e<256;++e)y.push((e+256).toString(16).slice(1));function we(e,t=0){return (y[e[t+0]]+y[e[t+1]]+y[e[t+2]]+y[e[t+3]]+"-"+y[e[t+4]]+y[e[t+5]]+"-"+y[e[t+6]]+y[e[t+7]]+"-"+y[e[t+8]]+y[e[t+9]]+"-"+y[e[t+10]]+y[e[t+11]]+y[e[t+12]]+y[e[t+13]]+y[e[t+14]]+y[e[t+15]]).toLowerCase()}var G={randomUUID:lt.randomUUID};function mt(e,t,o){if(G.randomUUID&&!t&&!e)return G.randomUUID();e=e||{};let n=e.random||(e.rng||Z)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){o=o||0;for(let r=0;r<16;++r)t[o+r]=n[r];return t}return we(n)}var ee=mt;var Se="fp-session-id",xe=typeof window!="undefined",te="xfpsessionid",Ve=(e,t)=>new URL(t).searchParams.get(e),ft=e=>{var t,o;try{let n=(o=(t=window==null?void 0:window.top)==null?void 0:t.location)==null?void 0:o.href;return n?Ve(e,n):null}catch(n){return null}},Ie=e=>xe?Ve(e,window.location.href)||ft(e):null,Ae=()=>{if((!xe||!window.sessionStorage))return !1;try{let e="test";return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return !1}},yt=()=>{let e=Ie(te)||ee();if(Ae())try{sessionStorage.setItem(Se,e);}catch(t){console.error("Failed to create session id",t);}return e},gt=()=>{let e=Ie(te);return e||(Ae()?sessionStorage.getItem(Se):null)},Oe=()=>gt()||yt(),O=(e,t=Oe())=>{let o=new URL(e);return o.searchParams.set(te,t),o.toString()};var T=Oe;var U="3.14.1";var B=(s=>(s.Auth="auth",s.Components="components",s.Form="form",s.Render="render",s.UpdateLoginMethods="update_login_methods",s.Verify="verify",s.VerifyButton="verify-button",s))(B||{});var F=(i=>(i.auth="auth",i.canceled="canceled",i.clicked="clicked",i.closed="closed",i.completed="completed",i.relayToComponents="relayToComponents",i))(F||{}),_=(i=>(i.formSaveComplete="formSaveComplete",i.formSaveFailed="formSaveFailed",i.formSaved="formSaved",i.propsReceived="propsReceived",i.started="started",i.relayFromComponents="relayFromComponents",i))(_||{});var Fe="footprint-inline-container",Le="footprint-body-locked",Ee="footprint-overlay",Pt="footprint-overlay-container",Re=Fe,De=Ee,Ke="footprint-loading-indicator",M=e=>`${Pt}-${e}`,V=(e,t)=>`${e}-${t}`,Te=e=>u(void 0,null,function*(){oe(e),bt(e),yield Ct(e);}),Ue=e=>{let t=M(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},Ct=e=>u(void 0,null,function*(){let t=M(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(s=>{setTimeout(s,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(s=>{setTimeout(s,100);}));let a=V(De,e),i=document.getElementById(a);i&&(i.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),i.remove(),document.body.classList.remove(Le));}),Be=(e,t)=>{let o=V(Re,e),n=document.createElement("div");return n.classList.add(Fe),n.setAttribute("id",o),t.appendChild(n),n},bt=e=>{let t=V(Re,e),o=document.getElementById(t);o&&o.remove();},oe=e=>{let t=V(Ke,e),o=document.getElementById(t);o&&o.remove();},ne=(e,t)=>{let o=V(Ke,t),n=vt(o);e.appendChild(n);},_e=(e,t)=>{document.body.classList.add(Le);let o=document.createElement("div"),n=V(De,t);return o.setAttribute("id",n),o.classList.add(Ee),e.appendChild(o),o},vt=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},Me=e=>{let t=document.getElementById(M(e));t&&(t.style.opacity="1",t.style.display="block");},$e=e=>{let t=document.getElementById(M(e));t&&(t.style.opacity="0",t.style.display="none");},Ne=e=>{let t=document.createElement("div");t.classList.add("modal-error-container"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Oops! Something\u2019s not quite right.");let o=document.createElement("div");o.classList.add("modal-error");let n=document.createElement("button");n.setAttribute("aria-label","Close"),n.classList.add("modal-error-close-button"),n.addEventListener("click",()=>{e.remove();});let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20"),r.setAttribute("fill","none");let a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d","M5 5L15 15M15 5L5 15"),a.setAttribute("stroke","black"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),r.appendChild(a),n.appendChild(r);let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width","40"),i.setAttribute("height","40"),i.setAttribute("viewBox","0 0 40 40"),i.setAttribute("fill","none"),i.setAttribute("class","error-icon");let s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M25 15L15 25M25 25L15 15M35 20C35 28.2843 28.2843 35 20 35C11.7157 35 5 28.2843 5 20C5 11.7157 11.7157 5 20 5C28.2843 5 35 11.7157 35 20Z"),s.setAttribute("stroke","black"),s.setAttribute("stroke-width","3.33333"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),i.appendChild(s);let p=document.createElement("h2");p.textContent="Oops! Something\u2019s not quite right.";let d=document.createElement("p");d.textContent="It looks like there was an issue loading the page. Try reloading and we\u2019ll get things back on track.",o.appendChild(n),o.appendChild(i),o.appendChild(p),o.appendChild(d),t.appendChild(o),e.appendChild(t);};var wt=()=>Math.random().toString(36).substring(2),$=wt;var N="https://api.onefootprint.com",j=U,H="footprint-js";var b={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var St=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),re=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let a;return Array.isArray(r)?a=r.map(re(e)):Object(r)===r?a=re(e)(r):a=r,[e(n),a]});return Object.fromEntries(o)},xt=re(St),q=xt;var Vt=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:H,sdkVersion:j,logLevel:o,logMessage:t,sessionId:T()};try{fetch(`${N}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(q(r))});}catch(a){}},z=Vt;var L=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}z(e,t,"info",n);}return o},ie=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}z(e,t,"warn",n);}return o},J=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}z(e,t,"error",n);}return o};var je={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},He={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var qe={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},It=Object.values(F),At=(...e)=>{},v=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),se=e=>v(e)&&Object.keys(e).length>0,Ot=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},W=(e,t)=>{var r;if(!t)return;let o=(r=qe[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},I=e=>{var o;let t=(o=qe[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},Q=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(B);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},ze=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:a,onClick:i,label:s,containerId:p}=t,d=ve(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return P(h({},d),{variant:a,kind:"verify"})}};var Je=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||At,de=(e,t,o)=>{var s;let{kind:n}=e,r=(s=je[n])!=null?s:{},a={},i=ze(e);return Object.entries(r).forEach(([p,d])=>{let c=p;if(!It.includes(c))return;let C=Je(e,d),A=c==="closed"||c==="canceled",m=n==="verify-button"&&c==="clicked";a[c]=k=>{C(k),A&&(t==null||t()),m&&i&&(o==null||o(i));};}),a},E=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||I(t);return Q(t),W(t,o),Ot(r,n),se(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),P(h({},e),{variant:r})},w=e=>se(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:se(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var Ft=e=>e==="auth";var Lt=e=>e==="update_login_methods";var pe=e=>e.kind==="components";var le=e=>typeof e=="string"&&e.length>0,X=e=>Ft(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),Et=e=>Lt(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),ce=e=>[X,Et].some(t=>t(e));var Rt=3,Dt=!1,Kt=e=>ce(e)?"update_auth_methods_v1":b[e.kind],Tt=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return P(h({},w(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,sandboxId:e.sandboxId,isComponentsSdk:t==="components"});if(t==="update_login_methods")return P(h({},w(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return X(e)?P(h({},w(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&Dt?P(h({},w(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):P(h({},w(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return P(h({},w(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n});J(t,"Invalid kind provided");},We=(e,t)=>u(void 0,null,function*(){return fetch(`${N}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${H} ${j} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return We(e,t-1)})}),Ut=e=>u(void 0,null,function*(){L(b[e.kind],"Sending SDK args");let t=Tt(e);if(!t)return;let o=yield We({data:q(t),kind:Kt(e)},Rt);return o?o.token:void 0}),Qe=Ut;var Xe=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,a=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:a(),variant:n}},Ye=()=>{let e=window.footprintAppearance;return !e||!v(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var Ze=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Bt=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:a}=e,{fontSrc:i,rules:s,variables:p}=Xe(o),d=new URLSearchParams;return p&&d.append("variables",p),s&&d.append("rules",s),i&&d.append("font_src",i),r!=null&&r.language&&d.append("lng",r.language),d.append("variant",a||I(n)),`${d.toString()}#${t}`},_t=(e,t)=>{let{kind:o}=e,n=Bt(e,t),r=`https://components.onefootprint.com/${o}`,a=`https://components2.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user",a="https://auth2.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com",a="https://auth2.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com",a="https://id2.onefootprint.com"),!le(r))throw new Error(`${o}_URL environment variable is not defined.`);return r+=`?${n}`.trim(),a+=`?${n}`.trim(),{url:r,fallbackUrl:a}},Ge=_t;var $t=e=>{let t=null,o=!1,n,r,{formSaveComplete:a,formSaved:i,formSaveFailed:s,started:p}=_,d=E(e),{variant:c,containerId:C}=d,A=c==="modal"||c==="drawer",m=$(),k=(l,f)=>{var x;let g=J(b[d.kind],l);(x=d.onError)==null||x.call(d,g),o&&f&&(n(),o=!1);},rt=()=>{if(!t){k("Footprint should be initialized in order to register callback props");return}let l=de(d,n,r);Object.entries(l).forEach(([f,g])=>{t==null||t.on(f,g),t==null||t.on(`${m}:${f}`,g);});},at=()=>{if(A)return Ue(m);if(!C){k("containerId is required when rendering inline");return}let l=document.getElementById(C);if(!l){k(`Could not find container with id ${C} while rendering footprint`);return}return Be(m,l)},Y=(l,f)=>{if(!f){oe(m),t==null||t.frame.classList.remove("fp-hide"),t==null||t.frame.classList.remove(`footprint-${c}-loading`),t==null||t.frame.classList.add(`footprint-${c}-loaded`);return}if(A){let g=_e(l,m);ne(g,m);}else ne(l,m);},fe=()=>{var f;if(!t){k("Footprint should be initialized in order to set up refs");return}if(d.kind!=="form"||!d.getRef)return;let l={save:()=>(t||k("Footprint should be initialized to call ref methods"),new Promise((g,x)=>{t==null||t.on(a,()=>{g();}),t==null||t.on(s,ge=>{x(ge);}),t==null||t.on(`${m}:${a}`,g),t==null||t.on(`${m}:${s}`,x),t==null||t.call(i);}))};(f=d.getRef)==null||f.call(d,l);},ye=(l,f)=>u(void 0,null,function*(){try{return t=yield new Mt({classListArray:[`footprint-${c}`,`footprint-${c}-loading`,"fp-hide"],container:l,name:`footprint-iframe-${m}`,url:f,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:d.authToken,initId:m,sdkUrl:Ze(),sdkVersion:U||""}}),{success:!0,parentApi:t}}catch(g){return k(`Initializing iframe with ${new URL(f).host} failed with error ${g}`),{success:!1}}}),it=(x,ge)=>u(void 0,[x,ge],function*(l,{url:f,fallbackUrl:g}){L(b[d.kind],`Initializing iframe with ${new URL(f).host}`);let he=yield ye(l,f);if(he.success)return he.parentApi;L(b[d.kind],`Initializing iframe with ${new URL(g).host} as fallback`);let ke=yield ye(l,g);if(!ke.success)throw new Error("Failed to initialize iframe");return ke.parentApi});return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Me(m));},props:d,isRendered:o,render:()=>u(void 0,null,function*(){if(o){ie(b[d.kind],"Footprint component is already rendered");return}o=!0;let l=at();if(!l){ie(b[d.kind],"Unable to create container for Footprint component");return}l.hasChildNodes()&&(l.innerHTML=""),Y(l,!0);let f=yield Qe(d);if(!f){k("Unable to get SDK args token.",!0),Y(l,!1);return}let{url:g,fallbackUrl:x}=Ge(d,f||"");try{yield it(l,{url:O(g),fallbackUrl:O(x)}),rt();}catch(ge){Ne(l),o=!1;}Y(l,!1),t==null||t.on(p,()=>fe()),t==null||t.on(`${m}:${p}`,fe),d.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{$e(m);}));}),destroy:()=>u(void 0,null,function*(){o&&(o=!1,yield Te(m),t&&(t.destroy(),t=null));}),registerOnDestroy:l=>{!l||typeof l!="function"||(n=l);},registerOnRenderSecondary:l=>{!l||typeof l!="function"||(r=l);}}},me=$t;var S=e=>{let t=E(e);return JSON.stringify(t)},Nt=()=>{let e=Object.create(null);return {getOrCreate:a=>{let i=S(a.props),s=Object.values(e).find(p=>S(p.iframe.props)===i);return s?s.iframe:(e[i]={iframe:a,secondaryIframes:{}},a)},getOrCreateSecondary:(a,i)=>{let s=S(a.props),p=S(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:d}=e[s],c=Object.values(d).find(C=>S(C.props)===p);return c||(d[p]=i,i)},remove:a=>{let i=S(a.props),s=e[i];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[i]);},removeSecondary:(a,i)=>{let s=S(a.props),p=S(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:d}=e[s],c=d[p];c&&(c.destroy(),delete d[p]);}}},et=Nt;var jt=()=>{let e=et();return {init:o=>{let n=me(o),r=()=>u(void 0,null,function*(){e.remove(n),yield n.destroy();}),a=d=>u(void 0,null,function*(){e.removeSecondary(n,d),yield d.destroy();}),i=d=>u(void 0,null,function*(){let c=me(d);c=e.getOrCreateSecondary(n,c),c.registerOnDestroy(()=>{a(c);}),c.render();}),s=()=>u(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(i),yield n.render();}),p={};return pe(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),h({render:s,destroy:r},p)}}},Ht=jt(),ue=Ht;var qt=e=>{window.setTimeout(e,0);},zt=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let a=(s=window.footprintCallbacks)!=null?s:{};if(!v(a))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return He[r].forEach(p=>{if(!a[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),a},o=r=>{var m;let a=r.getAttribute("data-kind");Q(a);let i=(m=r.getAttribute("data-variant"))!=null?m:I(a);W(a,i);let s=Ye(),p=t(a),d=r.getAttribute("data-props")||"",c;try{c=JSON.parse(d);}catch(k){throw Error("Could not parse `data-props` for footprint.")}if(!v(c))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let C=$();r.setAttribute("id",C),e.init(h(h({kind:a,variant:i,appearance:s,containerId:r.id},p),c)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(a=>{o(a);});};document.addEventListener("DOMContentLoaded",()=>qt(n));},tt=zt;var Jt="http://test",ot=e=>u(void 0,null,function*(){let t=yield fetch(`${Jt}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),Wt=e=>u(void 0,null,function*(){if(!v(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield ot({email:t}))?!0:o?yield ot({phone_number:o}):!1}),nt=Wt;var zn=ue;tt(ue); | ||
var et=Object.defineProperty,tt=Object.defineProperties;var ot=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var fe=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var ue=(e,t,o)=>t in e?et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,g=(e,t)=>{for(var o in t||(t={}))fe.call(t,o)&&ue(e,o,t[o]);if(R)for(var o of R(t))ye.call(t,o)&&ue(e,o,t[o]);return e},k=(e,t)=>tt(e,ot(t));var ge=(e,t)=>{var o={};for(var n in e)fe.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&R)for(var n of R(e))t.indexOf(n)<0&&ye.call(e,n)&&(o[n]=e[n]);return o};var u=(e,t,o)=>new Promise((n,r)=>{var a=p=>{try{i(o.next(p));}catch(d){r(d);}},s=p=>{try{i(o.throw(p));}catch(d){r(d);}},i=p=>p.done?n(p.value):Promise.resolve(p.value).then(a,s);i((o=o.apply(e,t)).next());});var he="fp-session-id",ke=typeof window!="undefined",Q="xfpsessionid",rt=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),Ce=(e,t)=>new URL(t).searchParams.get(e),at=e=>{var t,o;try{let n=(o=(t=window==null?void 0:window.top)==null?void 0:t.location)==null?void 0:o.href;return n?Ce(e,n):null}catch(n){return null}},Pe=e=>ke?Ce(e,window.location.href)||at(e):null,be=()=>{if((!ke||!window.sessionStorage))return !1;try{let e="test";return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return !1}},st=()=>{let e=Pe(Q)||rt();if(be())try{sessionStorage.setItem(he,e);}catch(t){console.error("Failed to create session id",t);}return e},it=()=>{let e=Pe(Q);return e||(be()?sessionStorage.getItem(he):null)},ve=()=>it()||st(),x=(e,t=ve())=>{let o=new URL(e);return o.searchParams.set(Q,t),o.toString()};var E=ve;var D="3.14.2";var K=(i=>(i.Auth="auth",i.Components="components",i.Form="form",i.Render="render",i.UpdateLoginMethods="update_login_methods",i.Verify="verify",i.VerifyButton="verify-button",i))(K||{});var O=(s=>(s.auth="auth",s.canceled="canceled",s.clicked="clicked",s.closed="closed",s.completed="completed",s.relayToComponents="relayToComponents",s))(O||{}),T=(s=>(s.formSaveComplete="formSaveComplete",s.formSaveFailed="formSaveFailed",s.formSaved="formSaved",s.propsReceived="propsReceived",s.started="started",s.relayFromComponents="relayFromComponents",s))(T||{});var we="footprint-inline-container",Se="footprint-body-locked",Ve="footprint-overlay",lt="footprint-overlay-container",Ae=we,Ie=Ve,xe="footprint-loading-indicator",B=e=>`${lt}-${e}`,V=(e,t)=>`${e}-${t}`,Oe=e=>u(void 0,null,function*(){X(e),mt(e),yield ct(e);}),Fe=e=>{let t=B(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},ct=e=>u(void 0,null,function*(){let t=B(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(i=>{setTimeout(i,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(i=>{setTimeout(i,100);}));let a=V(Ie,e),s=document.getElementById(a);s&&(s.classList.add("footprint-overlay-fading"),yield new Promise(i=>{setTimeout(i,200);}),o.remove(),s.remove(),document.body.classList.remove(Se));}),Le=(e,t)=>{let o=V(Ae,e),n=document.createElement("div");return n.classList.add(we),n.setAttribute("id",o),t.appendChild(n),n},mt=e=>{let t=V(Ae,e),o=document.getElementById(t);o&&o.remove();},X=e=>{let t=V(xe,e),o=document.getElementById(t);o&&o.remove();},Y=(e,t)=>{let o=V(xe,t),n=ut(o);e.appendChild(n);},Re=(e,t)=>{document.body.classList.add(Se);let o=document.createElement("div"),n=V(Ie,t);return o.setAttribute("id",n),o.classList.add(Ve),e.appendChild(o),o},ut=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},Ee=e=>{let t=document.getElementById(B(e));t&&(t.style.opacity="1",t.style.display="block");},De=e=>{let t=document.getElementById(B(e));t&&(t.style.opacity="0",t.style.display="none");},Ke=e=>{let t=document.createElement("div");t.classList.add("modal-error-container"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Oops! Something\u2019s not quite right.");let o=document.createElement("div");o.classList.add("modal-error");let n=document.createElement("button");n.setAttribute("aria-label","Close"),n.classList.add("modal-error-close-button"),n.addEventListener("click",()=>{e.remove();});let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20"),r.setAttribute("fill","none");let a=document.createElementNS("http://www.w3.org/2000/svg","path");a.setAttribute("d","M5 5L15 15M15 5L5 15"),a.setAttribute("stroke","black"),a.setAttribute("stroke-width","1.5"),a.setAttribute("stroke-linecap","round"),r.appendChild(a),n.appendChild(r);let s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("xmlns","http://www.w3.org/2000/svg"),s.setAttribute("width","40"),s.setAttribute("height","40"),s.setAttribute("viewBox","0 0 40 40"),s.setAttribute("fill","none"),s.setAttribute("class","error-icon");let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d","M25 15L15 25M25 25L15 15M35 20C35 28.2843 28.2843 35 20 35C11.7157 35 5 28.2843 5 20C5 11.7157 11.7157 5 20 5C28.2843 5 35 11.7157 35 20Z"),i.setAttribute("stroke","black"),i.setAttribute("stroke-width","3.33333"),i.setAttribute("stroke-linecap","round"),i.setAttribute("stroke-linejoin","round"),s.appendChild(i);let p=document.createElement("h2");p.textContent="Oops! Something\u2019s not quite right.";let d=document.createElement("p");d.textContent="It looks like there was an issue loading the page. Try reloading and we\u2019ll get things back on track.",o.appendChild(n),o.appendChild(s),o.appendChild(p),o.appendChild(d),t.appendChild(o),e.appendChild(t);};var ft=()=>Math.random().toString(36).substring(2),U=ft;var _="https://api.onefootprint.com",M=D,$="footprint-js";var P={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var yt=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),Z=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let a;return Array.isArray(r)?a=r.map(Z(e)):Object(r)===r?a=Z(e)(r):a=r,[e(n),a]});return Object.fromEntries(o)},gt=Z(yt),N=gt;var ht=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:$,sdkVersion:M,logLevel:o,logMessage:t,sessionId:E()};try{fetch(`${_}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N(r))});}catch(a){}},j=ht;var F=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}j(e,t,"info",n);}return o},ee=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}j(e,t,"warn",n);}return o},H=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}j(e,t,"error",n);}return o};var Te={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},Be={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var Ue={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},kt=Object.values(O),Ct=(...e)=>{},b=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),te=e=>b(e)&&Object.keys(e).length>0,Pt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},q=(e,t)=>{var r;if(!t)return;let o=(r=Ue[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},A=e=>{var o;let t=(o=Ue[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},z=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(K);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},_e=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:a,onClick:s,label:i,containerId:p}=t,d=ge(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return k(g({},d),{variant:a,kind:"verify"})}};var Me=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||Ct,oe=(e,t,o)=>{var i;let{kind:n}=e,r=(i=Te[n])!=null?i:{},a={},s=_e(e);return Object.entries(r).forEach(([p,d])=>{let c=p;if(!kt.includes(c))return;let C=Me(e,d),I=c==="closed"||c==="canceled",m=n==="verify-button"&&c==="clicked";a[c]=h=>{C(h),I&&(t==null||t()),m&&s&&(o==null||o(s));};}),a},L=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||A(t);return z(t),q(t,o),Pt(r,n),te(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),k(g({},e),{variant:r})},v=e=>te(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:te(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var bt=e=>e==="auth";var vt=e=>e==="update_login_methods";var ne=e=>e.kind==="components";var re=e=>typeof e=="string"&&e.length>0,J=e=>bt(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),wt=e=>vt(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),ae=e=>[J,wt].some(t=>t(e));var St=3,Vt=!1,At=e=>ae(e)?"update_auth_methods_v1":P[e.kind],It=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return k(g({},v(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,sandboxId:e.sandboxId,isComponentsSdk:t==="components"});if(t==="update_login_methods")return k(g({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return J(e)?k(g({},v(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&Vt?k(g({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):k(g({},v(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return k(g({},v(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n});H(t,"Invalid kind provided");},$e=(e,t)=>u(void 0,null,function*(){return fetch(`${_}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${$} ${M} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return $e(e,t-1)})}),xt=e=>u(void 0,null,function*(){F(P[e.kind],"Sending SDK args");let t=It(e);if(!t)return;let o=yield $e({data:N(t),kind:At(e)},St);return o?o.token:void 0}),Ne=xt;var je=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,a=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:a(),variant:n}},He=()=>{let e=window.footprintAppearance;return !e||!b(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var qe=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Ot=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:a}=e,{fontSrc:s,rules:i,variables:p}=je(o),d=new URLSearchParams;return p&&d.append("variables",p),i&&d.append("rules",i),s&&d.append("font_src",s),r!=null&&r.language&&d.append("lng",r.language),d.append("variant",a||A(n)),`${d.toString()}#${t}`},Ft=(e,t)=>{let{kind:o}=e,n=Ot(e,t),r=`https://components.onefootprint.com/${o}`,a=`https://components2.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user",a="https://auth2.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com",a="https://auth2.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com",a="https://id2.onefootprint.com"),!re(r))throw new Error(`${o}_URL environment variable is not defined.`);return r+=`?${n}`.trim(),a+=`?${n}`.trim(),{url:r,fallbackUrl:a}},ze=Ft;var Rt=e=>{let t=null,o=!1,n,r,{formSaveComplete:a,formSaved:s,formSaveFailed:i,started:p}=T,d=L(e),{variant:c,containerId:C}=d,I=c==="modal"||c==="drawer",m=U(),h=(l,f)=>{var S;let y=H(P[d.kind],l);(S=d.onError)==null||S.call(d,y),o&&f&&(n(),o=!1);},Ye=()=>{if(!t){h("Footprint should be initialized in order to register callback props");return}let l=oe(d,n,r);Object.entries(l).forEach(([f,y])=>{t==null||t.on(f,y),t==null||t.on(`${m}:${f}`,y);});},Ze=()=>{if(I)return Fe(m);if(!C){h("containerId is required when rendering inline");return}let l=document.getElementById(C);if(!l){h(`Could not find container with id ${C} while rendering footprint`);return}return Le(m,l)},W=(l,f)=>{if(!f){X(m),t==null||t.frame.classList.remove("fp-hide"),t==null||t.frame.classList.remove(`footprint-${c}-loading`),t==null||t.frame.classList.add(`footprint-${c}-loaded`);return}if(I){let y=Re(l,m);Y(y,m);}else Y(l,m);},de=()=>{var f;if(!t){h("Footprint should be initialized in order to set up refs");return}if(d.kind!=="form"||!d.getRef)return;let l={save:()=>(t||h("Footprint should be initialized to call ref methods"),new Promise((y,S)=>{t==null||t.on(a,()=>{y();}),t==null||t.on(i,le=>{S(le);}),t==null||t.on(`${m}:${a}`,y),t==null||t.on(`${m}:${i}`,S),t==null||t.call(s);}))};(f=d.getRef)==null||f.call(d,l);},pe=(l,f)=>u(void 0,null,function*(){try{return t=yield new Lt({classListArray:[`footprint-${c}`,`footprint-${c}-loading`,"fp-hide"],container:l,name:`footprint-iframe-${m}`,url:f,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:d.authToken,initId:m,sdkUrl:qe(),sdkVersion:D||""}}),{success:!0,parentApi:t}}catch(y){return h(`Initializing iframe with ${new URL(f).host} failed with error ${y}`),{success:!1}}}),Ge=(S,le)=>u(void 0,[S,le],function*(l,{url:f,fallbackUrl:y}){F(P[d.kind],`Initializing iframe with ${new URL(f).host}`);let ce=yield pe(l,f);if(ce.success)return ce.parentApi;F(P[d.kind],`Initializing iframe with ${new URL(y).host} as fallback`);let me=yield pe(l,y);if(!me.success)throw new Error("Failed to initialize iframe");return me.parentApi});return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Ee(m));},props:d,isRendered:o,render:()=>u(void 0,null,function*(){if(o){ee(P[d.kind],"Footprint component is already rendered");return}o=!0;let l=Ze();if(!l){ee(P[d.kind],"Unable to create container for Footprint component");return}l.hasChildNodes()&&(l.innerHTML=""),W(l,!0);let f=yield Ne(d);if(!f){h("Unable to get SDK args token.",!0),W(l,!1);return}let{url:y,fallbackUrl:S}=ze(d,f||"");try{yield Ge(l,{url:x(y),fallbackUrl:x(S)}),Ye();}catch(le){Ke(l),o=!1;}W(l,!1),t==null||t.on(p,()=>de()),t==null||t.on(`${m}:${p}`,de),d.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{De(m);}));}),destroy:()=>u(void 0,null,function*(){o&&(o=!1,yield Oe(m),t&&(t.destroy(),t=null));}),registerOnDestroy:l=>{!l||typeof l!="function"||(n=l);},registerOnRenderSecondary:l=>{!l||typeof l!="function"||(r=l);}}},se=Rt;var w=e=>{let t=L(e);return JSON.stringify(t)},Et=()=>{let e=Object.create(null);return {getOrCreate:a=>{let s=w(a.props),i=Object.values(e).find(p=>w(p.iframe.props)===s);return i?i.iframe:(e[s]={iframe:a,secondaryIframes:{}},a)},getOrCreateSecondary:(a,s)=>{let i=w(a.props),p=w(s.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:d}=e[i],c=Object.values(d).find(C=>w(C.props)===p);return c||(d[p]=s,s)},remove:a=>{let s=w(a.props),i=e[s];i&&(Object.keys(i.secondaryIframes).forEach(p=>{i.secondaryIframes[p].destroy();}),delete e[s]);},removeSecondary:(a,s)=>{let i=w(a.props),p=w(s.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:d}=e[i],c=d[p];c&&(c.destroy(),delete d[p]);}}},Je=Et;var Dt=()=>{let e=Je();return {init:o=>{let n=se(o),r=()=>u(void 0,null,function*(){e.remove(n),yield n.destroy();}),a=d=>u(void 0,null,function*(){e.removeSecondary(n,d),yield d.destroy();}),s=d=>u(void 0,null,function*(){let c=se(d);c=e.getOrCreateSecondary(n,c),c.registerOnDestroy(()=>{a(c);}),c.render();}),i=()=>u(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(s),yield n.render();}),p={};return ne(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),g({render:i,destroy:r},p)}}},Kt=Dt(),ie=Kt;var Tt=e=>{window.setTimeout(e,0);},Bt=e=>{if(typeof window=="undefined")return;let t=r=>{var i;let a=(i=window.footprintCallbacks)!=null?i:{};if(!b(a))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Be[r].forEach(p=>{if(!a[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),a},o=r=>{var m;let a=r.getAttribute("data-kind");z(a);let s=(m=r.getAttribute("data-variant"))!=null?m:A(a);q(a,s);let i=He(),p=t(a),d=r.getAttribute("data-props")||"",c;try{c=JSON.parse(d);}catch(h){throw Error("Could not parse `data-props` for footprint.")}if(!b(c))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let C=U();r.setAttribute("id",C),e.init(g(g({kind:a,variant:s,appearance:i,containerId:r.id},p),c)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(a=>{o(a);});};document.addEventListener("DOMContentLoaded",()=>Tt(n));},We=Bt;var Ut="http://test",Qe=e=>u(void 0,null,function*(){let t=yield fetch(`${Ut}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),_t=e=>u(void 0,null,function*(){if(!b(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield Qe({email:t}))?!0:o?yield Qe({phone_number:o}):!1}),Xe=_t;var Vn=ie;We(ie); | ||
export { B as FootprintComponentKind, _ as FootprintPrivateEvent, F as FootprintPublicEvent, zn as default, nt as identifyFootprintUser }; | ||
export { K as FootprintComponentKind, T as FootprintPrivateEvent, O as FootprintPublicEvent, Vn as default, Xe as identifyFootprintUser }; |
@@ -1,10 +0,6 @@ | ||
(function (exports, ft) { | ||
(function (exports) { | ||
'use strict'; | ||
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } | ||
var rt=Object.defineProperty,at=Object.defineProperties;var it=Object.getOwnPropertyDescriptors;var D=Object.getOwnPropertySymbols;var he=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable;var ge=(e,t,o)=>t in e?rt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,h=(e,t)=>{for(var o in t||(t={}))he.call(t,o)&&ge(e,o,t[o]);if(D)for(var o of D(t))ve.call(t,o)&&ge(e,o,t[o]);return e},k=(e,t)=>at(e,it(t));var Pe=(e,t)=>{var o={};for(var n in e)he.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&D)for(var n of D(e))t.indexOf(n)<0&&ve.call(e,n)&&(o[n]=e[n]);return o};var u=(e,t,o)=>new Promise((n,r)=>{var i=p=>{try{s(o.next(p));}catch(d){r(d);}},a=p=>{try{s(o.throw(p));}catch(d){r(d);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(i,a);s((o=o.apply(e,t)).next());});var ke="fp-session-id",Ce=typeof window!="undefined",Y="xfpsessionid",dt=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,e=>(+e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+e/4).toString(16)),we=(e,t)=>new URL(t).searchParams.get(e),pt=e=>{var t,o;try{let n=(o=(t=window==null?void 0:window.top)==null?void 0:t.location)==null?void 0:o.href;return n?we(e,n):null}catch(n){return null}},be=e=>Ce?we(e,window.location.href)||pt(e):null,Ve=()=>{if((!Ce||!window.sessionStorage))return !1;try{let e="test";return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return !1}},lt=()=>{let e=be(Y)||dt();if(Ve())try{sessionStorage.setItem(ke,e);}catch(t){console.error("Failed to create session id",t);}return e},ct=()=>{let e=be(Y);return e||(Ve()?sessionStorage.getItem(ke):null)},Se=()=>ct()||lt(),x=(e,t=Se())=>{let o=new URL(e);return o.searchParams.set(Y,t),o.toString()};var K=Se;var E="application/x-postmate-v1+json",ut=5,ft=0,yt=function(){return ++ft};var gt=function(t){var o=document.createElement("a");o.href=t;var n=o.protocol.length>4?o.protocol:window.location.protocol,r=o.host.length?o.port==="80"||o.port==="443"?o.hostname:o.host:window.location.host;return o.origin||n+"//"+r},ht={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},Z=function(t,o){return !(typeof o=="string"&&t.origin!==o||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==E||!ht[t.data.postmate])},vt=function(t,o){var n=typeof t[o]=="function"?t[o]():t[o];return O.Promise.resolve(n)},Pt=function(){function e(o){var n=this;this.parent=o.parent,this.frame=o.frame,this.child=o.child,this.childOrigin=o.childOrigin,this.events={},this.listener=function(r){if(!Z(r,n.childOrigin))return !1;var i=((r||{}).data||{}).value||{},a=i.data,s=i.name;r.data.postmate==="emit"&&s in n.events&&n.events[s].forEach(function(p){p.call(n,a);});},this.parent.addEventListener("message",this.listener,!1);}var t=e.prototype;return t.get=function(n){var r=this;return new O.Promise(function(i){var a=yt(),s=function p(d){d.data.uid===a&&d.data.postmate==="reply"&&(r.parent.removeEventListener("message",p,!1),i(d.data.value));};r.parent.addEventListener("message",s,!1),r.child.postMessage({postmate:"request",type:E,property:n,uid:a},r.childOrigin);})},t.call=function(n,r){this.child.postMessage({postmate:"call",type:E,property:n,data:r},this.childOrigin);},t.on=function(n,r){this.events[n]||(this.events[n]=[]),this.events[n].push(r);},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),kt=function(){function e(o){var n=this;this.model=o.model,this.parent=o.parent,this.parentOrigin=o.parentOrigin,this.child=o.child,this.child.addEventListener("message",function(r){if(Z(r,n.parentOrigin)){var i=r.data,a=i.property,s=i.uid,p=i.data;if(r.data.postmate==="call"){a in n.model&&typeof n.model[a]=="function"&&n.model[a](p);return}vt(n.model,a).then(function(d){return r.source.postMessage({property:a,postmate:"reply",type:E,uid:s,value:d},r.origin)});}});}var t=e.prototype;return t.emit=function(n,r){this.parent.postMessage({postmate:"emit",type:E,value:{name:n,data:r}},this.parentOrigin);},e}(),O=function(){function e(o){var n=o.container,r=n===void 0?typeof r!="undefined"?r:document.body:n,i=o.model,a=o.url,s=o.name,p=s===void 0?"":s,d=o.allow,l=o.id,g=o.classListArray,P=g===void 0?[]:g;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=p||"",this.frame.classList.add.apply(this.frame.classList,P),d&&(this.frame.allow=d),l&&(this.frame.id=l),r.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var t=e.prototype;return t.sendHandshake=function(n){var r=this,i=gt(n),a=0,s;return new e.Promise(function(p,d){var l=function m(v){return Z(v,i)?v.data.postmate==="handshake-reply"?(clearInterval(s),r.parent.removeEventListener("message",m,!1),r.childOrigin=v.origin,p(new Pt(r))):d("Failed handshake"):!1};r.parent.addEventListener("message",l,!1);var g=function(){if(a++,r.child.postMessage({postmate:"handshake",type:E,model:r.model},i),a===ut)return clearInterval(s),d("Failed to handshake")},P=function(){g(),s=setInterval(g,500);};r.frame.attachEvent?r.frame.attachEvent("onload",P):r.frame.addEventListener("load",P),r.frame.src=n;})},e}();O.debug=!1;O.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();O.Model=function(){function e(o){return this.child=window,this.model=o,this.parent=this.child.parent,this.sendHandshakeReply()}var t=e.prototype;return t.sendHandshakeReply=function(){var n=this;return new O.Promise(function(r,i){var a=function s(p){if(p.data.postmate){if(p.data.postmate==="handshake"){n.child.removeEventListener("message",s,!1),p.source.postMessage({postmate:"handshake-reply",type:E},p.origin),n.parentOrigin=p.origin;var d=p.data.model;return d&&Object.keys(d).forEach(function(l){n.model[l]=d[l];}),r(new kt(n))}return i("Handshake Reply Failed")}};n.child.addEventListener("message",a,!1);})},e}();var Ee=O;var _="3.14.2";var T=(s=>(s.Auth="auth",s.Components="components",s.Form="form",s.Render="render",s.UpdateLoginMethods="update_login_methods",s.Verify="verify",s.VerifyButton="verify-button",s))(T||{});var L=(a=>(a.auth="auth",a.canceled="canceled",a.clicked="clicked",a.closed="closed",a.completed="completed",a.relayToComponents="relayToComponents",a))(L||{}),B=(a=>(a.formSaveComplete="formSaveComplete",a.formSaveFailed="formSaveFailed",a.formSaved="formSaved",a.propsReceived="propsReceived",a.started="started",a.relayFromComponents="relayFromComponents",a))(B||{});var Oe="footprint-inline-container",Ae="footprint-body-locked",Ie="footprint-overlay",wt="footprint-overlay-container",xe=Oe,Le=Ie,Fe="footprint-loading-indicator",U=e=>`${wt}-${e}`,A=(e,t)=>`${e}-${t}`,Re=e=>u(void 0,null,function*(){G(e),Vt(e),yield bt(e);}),De=e=>{let t=U(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},bt=e=>u(void 0,null,function*(){let t=U(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(s=>{setTimeout(s,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(s=>{setTimeout(s,100);}));let i=A(Le,e),a=document.getElementById(i);a&&(a.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),a.remove(),document.body.classList.remove(Ae));}),Ke=(e,t)=>{let o=A(xe,e),n=document.createElement("div");return n.classList.add(Oe),n.setAttribute("id",o),t.appendChild(n),n},Vt=e=>{let t=A(xe,e),o=document.getElementById(t);o&&o.remove();},G=e=>{let t=A(Fe,e),o=document.getElementById(t);o&&o.remove();},ee=(e,t)=>{let o=A(Fe,t),n=St(o);e.appendChild(n);},_e=(e,t)=>{document.body.classList.add(Ae);let o=document.createElement("div"),n=A(Le,t);return o.setAttribute("id",n),o.classList.add(Ie),e.appendChild(o),o},St=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},Te=e=>{let t=document.getElementById(U(e));t&&(t.style.opacity="1",t.style.display="block");},Be=e=>{let t=document.getElementById(U(e));t&&(t.style.opacity="0",t.style.display="none");},Ue=e=>{let t=document.createElement("div");t.classList.add("modal-error-container"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Oops! Something\u2019s not quite right.");let o=document.createElement("div");o.classList.add("modal-error");let n=document.createElement("button");n.setAttribute("aria-label","Close"),n.classList.add("modal-error-close-button"),n.addEventListener("click",()=>{e.remove();});let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20"),r.setAttribute("fill","none");let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d","M5 5L15 15M15 5L5 15"),i.setAttribute("stroke","black"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke-linecap","round"),r.appendChild(i),n.appendChild(r);let a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("xmlns","http://www.w3.org/2000/svg"),a.setAttribute("width","40"),a.setAttribute("height","40"),a.setAttribute("viewBox","0 0 40 40"),a.setAttribute("fill","none"),a.setAttribute("class","error-icon");let s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M25 15L15 25M25 25L15 15M35 20C35 28.2843 28.2843 35 20 35C11.7157 35 5 28.2843 5 20C5 11.7157 11.7157 5 20 5C28.2843 5 35 11.7157 35 20Z"),s.setAttribute("stroke","black"),s.setAttribute("stroke-width","3.33333"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),a.appendChild(s);let p=document.createElement("h2");p.textContent="Oops! Something\u2019s not quite right.";let d=document.createElement("p");d.textContent="It looks like there was an issue loading the page. Try reloading and we\u2019ll get things back on track.",o.appendChild(n),o.appendChild(a),o.appendChild(p),o.appendChild(d),t.appendChild(o),e.appendChild(t);};var Et=()=>Math.random().toString(36).substring(2),M=Et;var N="https://api.onefootprint.com",$=_,H="footprint-js";var C={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var Ot=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),te=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let i;return Array.isArray(r)?i=r.map(te(e)):Object(r)===r?i=te(e)(r):i=r,[e(n),i]});return Object.fromEntries(o)},At=te(Ot),j=At;var It=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:H,sdkVersion:$,logLevel:o,logMessage:t,sessionId:K()};try{fetch(`${N}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j(r))});}catch(i){}},q=It;var F=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}q(e,t,"info",n);}return o},ne=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}q(e,t,"warn",n);}return o},z=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}q(e,t,"error",n);}return o};var Me={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},Ne={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var $e={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},xt=Object.values(L),Lt=(...e)=>{},w=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),re=e=>w(e)&&Object.keys(e).length>0,Ft=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},W=(e,t)=>{var r;if(!t)return;let o=(r=$e[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},I=e=>{var o;let t=(o=$e[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},J=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(T);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},He=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:i,onClick:a,label:s,containerId:p}=t,d=Pe(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return k(h({},d),{variant:i,kind:"verify"})}};var je=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||Lt,ae=(e,t,o)=>{var s;let{kind:n}=e,r=(s=Me[n])!=null?s:{},i={},a=He(e);return Object.entries(r).forEach(([p,d])=>{let l=p;if(!xt.includes(l))return;let g=je(e,d),P=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";i[l]=v=>{g(v),P&&(t==null||t()),m&&a&&(o==null||o(a));};}),i},R=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||I(t);return J(t),W(t,o),Ft(r,n),re(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),k(h({},e),{variant:r})},b=e=>re(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:re(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var Rt=e=>e==="auth";var Dt=e=>e==="update_login_methods";var ie=e=>e.kind==="components";var se=e=>typeof e=="string"&&e.length>0,Q=e=>Rt(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),Kt=e=>Dt(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),de=e=>[Q,Kt].some(t=>t(e));var _t=3,Tt=!1,Bt=e=>de(e)?"update_auth_methods_v1":C[e.kind],Ut=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return k(h({},b(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,sandboxId:e.sandboxId,isComponentsSdk:t==="components"});if(t==="update_login_methods")return k(h({},b(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return Q(e)?k(h({},b(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&Tt?k(h({},b(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):k(h({},b(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return k(h({},b(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n});z(t,"Invalid kind provided");},qe=(e,t)=>u(void 0,null,function*(){return fetch(`${N}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${H} ${$} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return qe(e,t-1)})}),Mt=e=>u(void 0,null,function*(){F(C[e.kind],"Sending SDK args");let t=Ut(e);if(!t)return;let o=yield qe({data:j(t),kind:Bt(e)},_t);return o?o.token:void 0}),ze=Mt;var We=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,i=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:i(),variant:n}},Je=()=>{let e=window.footprintAppearance;return !e||!w(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var Qe=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Nt=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:i}=e,{fontSrc:a,rules:s,variables:p}=We(o),d=new URLSearchParams;return p&&d.append("variables",p),s&&d.append("rules",s),a&&d.append("font_src",a),r!=null&&r.language&&d.append("lng",r.language),d.append("variant",i||I(n)),`${d.toString()}#${t}`},$t=(e,t)=>{let{kind:o}=e,n=Nt(e,t),r=`https://components.onefootprint.com/${o}`,i=`https://components2.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user",i="https://auth2.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com",i="https://auth2.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com",i="https://id2.onefootprint.com"),!se(r))throw new Error(`${o}_URL environment variable is not defined.`);return r+=`?${n}`.trim(),i+=`?${n}`.trim(),{url:r,fallbackUrl:i}},Xe=$t;var Ht=e=>{let t=null,o=!1,n,r,{formSaveComplete:i,formSaved:a,formSaveFailed:s,started:p}=B,d=R(e),{variant:l,containerId:g}=d,P=l==="modal"||l==="drawer",m=M(),v=(c,f)=>{var S;let y=z(C[d.kind],c);(S=d.onError)==null||S.call(d,y),o&&f&&(n(),o=!1);},tt=()=>{if(!t){v("Footprint should be initialized in order to register callback props");return}let c=ae(d,n,r);Object.entries(c).forEach(([f,y])=>{t==null||t.on(f,y),t==null||t.on(`${m}:${f}`,y);});},ot=()=>{if(P)return De(m);if(!g){v("containerId is required when rendering inline");return}let c=document.getElementById(g);if(!c){v(`Could not find container with id ${g} while rendering footprint`);return}return Ke(m,c)},X=(c,f)=>{if(!f){G(m),t==null||t.frame.classList.remove("fp-hide"),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(P){let y=_e(c,m);ee(y,m);}else ee(c,m);},ce=()=>{var f;if(!t){v("Footprint should be initialized in order to set up refs");return}if(d.kind!=="form"||!d.getRef)return;let c={save:()=>(t||v("Footprint should be initialized to call ref methods"),new Promise((y,S)=>{t==null||t.on(i,()=>{y();}),t==null||t.on(s,ue=>{S(ue);}),t==null||t.on(`${m}:${i}`,y),t==null||t.on(`${m}:${s}`,S),t==null||t.call(a);}))};(f=d.getRef)==null||f.call(d,c);},me=(c,f)=>u(void 0,null,function*(){try{return t=yield new Ee({classListArray:[`footprint-${l}`,`footprint-${l}-loading`,"fp-hide"],container:c,name:`footprint-iframe-${m}`,url:f,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:d.authToken,initId:m,sdkUrl:Qe(),sdkVersion:_||""}}),{success:!0,parentApi:t}}catch(y){return v(`Initializing iframe with ${new URL(f).host} failed with error ${y}`),{success:!1}}}),nt=(S,ue)=>u(void 0,[S,ue],function*(c,{url:f,fallbackUrl:y}){F(C[d.kind],`Initializing iframe with ${new URL(f).host}`);let fe=yield me(c,f);if(fe.success)return fe.parentApi;F(C[d.kind],`Initializing iframe with ${new URL(y).host} as fallback`);let ye=yield me(c,y);if(!ye.success)throw new Error("Failed to initialize iframe");return ye.parentApi});return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Te(m));},props:d,isRendered:o,render:()=>u(void 0,null,function*(){if(o){ne(C[d.kind],"Footprint component is already rendered");return}o=!0;let c=ot();if(!c){ne(C[d.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),X(c,!0);let f=yield ze(d);if(!f){v("Unable to get SDK args token.",!0),X(c,!1);return}let{url:y,fallbackUrl:S}=Xe(d,f||"");try{yield nt(c,{url:x(y),fallbackUrl:x(S)}),tt();}catch(ue){Ue(c),o=!1;}X(c,!1),t==null||t.on(p,()=>ce()),t==null||t.on(`${m}:${p}`,ce),d.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{Be(m);}));}),destroy:()=>u(void 0,null,function*(){o&&(o=!1,yield Re(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},pe=Ht;var V=e=>{let t=R(e);return JSON.stringify(t)},jt=()=>{let e=Object.create(null);return {getOrCreate:i=>{let a=V(i.props),s=Object.values(e).find(p=>V(p.iframe.props)===a);return s?s.iframe:(e[a]={iframe:i,secondaryIframes:{}},i)},getOrCreateSecondary:(i,a)=>{let s=V(i.props),p=V(a.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:d}=e[s],l=Object.values(d).find(g=>V(g.props)===p);return l||(d[p]=a,a)},remove:i=>{let a=V(i.props),s=e[a];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[a]);},removeSecondary:(i,a)=>{let s=V(i.props),p=V(a.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:d}=e[s],l=d[p];l&&(l.destroy(),delete d[p]);}}},Ye=jt;var qt=()=>{let e=Ye();return {init:o=>{let n=pe(o),r=()=>u(void 0,null,function*(){e.remove(n),yield n.destroy();}),i=d=>u(void 0,null,function*(){e.removeSecondary(n,d),yield d.destroy();}),a=d=>u(void 0,null,function*(){let l=pe(d);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{i(l);}),l.render();}),s=()=>u(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(a),yield n.render();}),p={};return ie(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),h({render:s,destroy:r},p)}}},zt=qt(),le=zt;var Wt=e=>{window.setTimeout(e,0);},Jt=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let i=(s=window.footprintCallbacks)!=null?s:{};if(!w(i))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Ne[r].forEach(p=>{if(!i[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),i},o=r=>{var m;let i=r.getAttribute("data-kind");J(i);let a=(m=r.getAttribute("data-variant"))!=null?m:I(i);W(i,a);let s=Je(),p=t(i),d=r.getAttribute("data-props")||"",l;try{l=JSON.parse(d);}catch(v){throw Error("Could not parse `data-props` for footprint.")}if(!w(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let g=M();r.setAttribute("id",g),e.init(h(h({kind:i,variant:a,appearance:s,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(i=>{o(i);});};document.addEventListener("DOMContentLoaded",()=>Wt(n));},Ze=Jt;var Qt="http://test",Ge=e=>u(void 0,null,function*(){let t=yield fetch(`${Qt}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),Xt=e=>u(void 0,null,function*(){if(!w(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield Ge({email:t}))?!0:o?yield Ge({phone_number:o}):!1}),et=Xt;var Tn=le;Ze(le);/*! Bundled license information: | ||
var ft__default = /*#__PURE__*/_interopDefault(ft); | ||
var ct=Object.defineProperty,mt=Object.defineProperties;var ut=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,Se=Object.prototype.propertyIsEnumerable;var we=(e,t,o)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,v=(e,t)=>{for(var o in t||(t={}))be.call(t,o)&&we(e,o,t[o]);if(K)for(var o of K(t))Se.call(t,o)&&we(e,o,t[o]);return e},C=(e,t)=>mt(e,ut(t));var Ve=(e,t)=>{var o={};for(var n in e)be.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&K)for(var n of K(e))t.indexOf(n)<0&&Se.call(e,n)&&(o[n]=e[n]);return o};var u=(e,t,o)=>new Promise((n,r)=>{var i=p=>{try{s(o.next(p));}catch(d){r(d);}},a=p=>{try{s(o.throw(p));}catch(d){r(d);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(i,a);s((o=o.apply(e,t)).next());});var T=new Uint8Array(256),_=T.length;function ee(){return _>T.length-16&&(ft__default.default.randomFillSync(T),_=0),T.slice(_,_+=16)}var y=[];for(let e=0;e<256;++e)y.push((e+256).toString(16).slice(1));function Ee(e,t=0){return (y[e[t+0]]+y[e[t+1]]+y[e[t+2]]+y[e[t+3]]+"-"+y[e[t+4]]+y[e[t+5]]+"-"+y[e[t+6]]+y[e[t+7]]+"-"+y[e[t+8]]+y[e[t+9]]+"-"+y[e[t+10]]+y[e[t+11]]+y[e[t+12]]+y[e[t+13]]+y[e[t+14]]+y[e[t+15]]).toLowerCase()}var te={randomUUID:ft__default.default.randomUUID};function gt(e,t,o){if(te.randomUUID&&!t&&!e)return te.randomUUID();e=e||{};let n=e.random||(e.rng||ee)();if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){o=o||0;for(let r=0;r<16;++r)t[o+r]=n[r];return t}return Ee(n)}var oe=gt;var Oe="fp-session-id",xe=typeof window!="undefined",ne="xfpsessionid",Ie=(e,t)=>new URL(t).searchParams.get(e),vt=e=>{var t,o;try{let n=(o=(t=window==null?void 0:window.top)==null?void 0:t.location)==null?void 0:o.href;return n?Ie(e,n):null}catch(n){return null}},Ae=e=>xe?Ie(e,window.location.href)||vt(e):null,Le=()=>{if((!xe||!window.sessionStorage))return !1;try{let e="test";return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(e){return !1}},Pt=()=>{let e=Ae(ne)||oe();if(Le())try{sessionStorage.setItem(Oe,e);}catch(t){console.error("Failed to create session id",t);}return e},kt=()=>{let e=Ae(ne);return e||(Le()?sessionStorage.getItem(Oe):null)},De=()=>kt()||Pt(),L=(e,t=De())=>{let o=new URL(e);return o.searchParams.set(ne,t),o.toString()};var U=De;var O="application/x-postmate-v1+json",wt=5,bt=0,St=function(){return ++bt};var Vt=function(t){var o=document.createElement("a");o.href=t;var n=o.protocol.length>4?o.protocol:window.location.protocol,r=o.host.length?o.port==="80"||o.port==="443"?o.hostname:o.host:window.location.host;return o.origin||n+"//"+r},Et={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},re=function(t,o){return !(typeof o=="string"&&t.origin!==o||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==O||!Et[t.data.postmate])},Ot=function(t,o){var n=typeof t[o]=="function"?t[o]():t[o];return x.Promise.resolve(n)},xt=function(){function e(o){var n=this;this.parent=o.parent,this.frame=o.frame,this.child=o.child,this.childOrigin=o.childOrigin,this.events={},this.listener=function(r){if(!re(r,n.childOrigin))return !1;var i=((r||{}).data||{}).value||{},a=i.data,s=i.name;r.data.postmate==="emit"&&s in n.events&&n.events[s].forEach(function(p){p.call(n,a);});},this.parent.addEventListener("message",this.listener,!1);}var t=e.prototype;return t.get=function(n){var r=this;return new x.Promise(function(i){var a=St(),s=function p(d){d.data.uid===a&&d.data.postmate==="reply"&&(r.parent.removeEventListener("message",p,!1),i(d.data.value));};r.parent.addEventListener("message",s,!1),r.child.postMessage({postmate:"request",type:O,property:n,uid:a},r.childOrigin);})},t.call=function(n,r){this.child.postMessage({postmate:"call",type:O,property:n,data:r},this.childOrigin);},t.on=function(n,r){this.events[n]||(this.events[n]=[]),this.events[n].push(r);},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),It=function(){function e(o){var n=this;this.model=o.model,this.parent=o.parent,this.parentOrigin=o.parentOrigin,this.child=o.child,this.child.addEventListener("message",function(r){if(re(r,n.parentOrigin)){var i=r.data,a=i.property,s=i.uid,p=i.data;if(r.data.postmate==="call"){a in n.model&&typeof n.model[a]=="function"&&n.model[a](p);return}Ot(n.model,a).then(function(d){return r.source.postMessage({property:a,postmate:"reply",type:O,uid:s,value:d},r.origin)});}});}var t=e.prototype;return t.emit=function(n,r){this.parent.postMessage({postmate:"emit",type:O,value:{name:n,data:r}},this.parentOrigin);},e}(),x=function(){function e(o){var n=o.container,r=n===void 0?typeof r!="undefined"?r:document.body:n,i=o.model,a=o.url,s=o.name,p=s===void 0?"":s,d=o.allow,l=o.id,h=o.classListArray,k=h===void 0?[]:h;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=p||"",this.frame.classList.add.apply(this.frame.classList,k),d&&(this.frame.allow=d),l&&(this.frame.id=l),r.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var t=e.prototype;return t.sendHandshake=function(n){var r=this,i=Vt(n),a=0,s;return new e.Promise(function(p,d){var l=function m(P){return re(P,i)?P.data.postmate==="handshake-reply"?(clearInterval(s),r.parent.removeEventListener("message",m,!1),r.childOrigin=P.origin,p(new xt(r))):d("Failed handshake"):!1};r.parent.addEventListener("message",l,!1);var h=function(){if(a++,r.child.postMessage({postmate:"handshake",type:O,model:r.model},i),a===wt)return clearInterval(s),d("Failed to handshake")},k=function(){h(),s=setInterval(h,500);};r.frame.attachEvent?r.frame.attachEvent("onload",k):r.frame.addEventListener("load",k),r.frame.src=n;})},e}();x.debug=!1;x.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();x.Model=function(){function e(o){return this.child=window,this.model=o,this.parent=this.child.parent,this.sendHandshakeReply()}var t=e.prototype;return t.sendHandshakeReply=function(){var n=this;return new x.Promise(function(r,i){var a=function s(p){if(p.data.postmate){if(p.data.postmate==="handshake"){n.child.removeEventListener("message",s,!1),p.source.postMessage({postmate:"handshake-reply",type:O},p.origin),n.parentOrigin=p.origin;var d=p.data.model;return d&&Object.keys(d).forEach(function(l){n.model[l]=d[l];}),r(new It(n))}return i("Handshake Reply Failed")}};n.child.addEventListener("message",a,!1);})},e}();var Fe=x;var B="3.14.1";var M=(s=>(s.Auth="auth",s.Components="components",s.Form="form",s.Render="render",s.UpdateLoginMethods="update_login_methods",s.Verify="verify",s.VerifyButton="verify-button",s))(M||{});var D=(a=>(a.auth="auth",a.canceled="canceled",a.clicked="clicked",a.closed="closed",a.completed="completed",a.relayToComponents="relayToComponents",a))(D||{}),N=(a=>(a.formSaveComplete="formSaveComplete",a.formSaveFailed="formSaveFailed",a.formSaved="formSaved",a.propsReceived="propsReceived",a.started="started",a.relayFromComponents="relayFromComponents",a))(N||{});var Re="footprint-inline-container",Ke="footprint-body-locked",_e="footprint-overlay",Lt="footprint-overlay-container",Te=Re,Ue=_e,Be="footprint-loading-indicator",$=e=>`${Lt}-${e}`,I=(e,t)=>`${e}-${t}`,Me=e=>u(void 0,null,function*(){ae(e),Ft(e),yield Dt(e);}),Ne=e=>{let t=$(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},Dt=e=>u(void 0,null,function*(){let t=$(e),o=document.getElementById(t);if(!o)return;let n=o.querySelector("iframe.footprint-drawer");n&&(n==null||n.classList.add("footprint-drawer-closing"),yield new Promise(s=>{setTimeout(s,300);}));let r=o.querySelector("iframe.footprint-modal");r&&(r==null||r.classList.add("footprint-modal-closing"),yield new Promise(s=>{setTimeout(s,100);}));let i=I(Ue,e),a=document.getElementById(i);a&&(a.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),a.remove(),document.body.classList.remove(Ke));}),$e=(e,t)=>{let o=I(Te,e),n=document.createElement("div");return n.classList.add(Re),n.setAttribute("id",o),t.appendChild(n),n},Ft=e=>{let t=I(Te,e),o=document.getElementById(t);o&&o.remove();},ae=e=>{let t=I(Be,e),o=document.getElementById(t);o&&o.remove();},ie=(e,t)=>{let o=I(Be,t),n=Rt(o);e.appendChild(n);},He=(e,t)=>{document.body.classList.add(Ke);let o=document.createElement("div"),n=I(Ue,t);return o.setAttribute("id",n),o.classList.add(_e),e.appendChild(o),o},Rt=e=>{let t=document.createElement("div");t.setAttribute("id",e),t.classList.add("footprint-loading-indicator");let o=document.createElement("div");o.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),o.appendChild(n),t.appendChild(o),t},je=e=>{let t=document.getElementById($(e));t&&(t.style.opacity="1",t.style.display="block");},qe=e=>{let t=document.getElementById($(e));t&&(t.style.opacity="0",t.style.display="none");},ze=e=>{let t=document.createElement("div");t.classList.add("modal-error-container"),t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label","Oops! Something\u2019s not quite right.");let o=document.createElement("div");o.classList.add("modal-error");let n=document.createElement("button");n.setAttribute("aria-label","Close"),n.classList.add("modal-error-close-button"),n.addEventListener("click",()=>{e.remove();});let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.setAttribute("width","20"),r.setAttribute("height","20"),r.setAttribute("viewBox","0 0 20 20"),r.setAttribute("fill","none");let i=document.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d","M5 5L15 15M15 5L5 15"),i.setAttribute("stroke","black"),i.setAttribute("stroke-width","1.5"),i.setAttribute("stroke-linecap","round"),r.appendChild(i),n.appendChild(r);let a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("xmlns","http://www.w3.org/2000/svg"),a.setAttribute("width","40"),a.setAttribute("height","40"),a.setAttribute("viewBox","0 0 40 40"),a.setAttribute("fill","none"),a.setAttribute("class","error-icon");let s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d","M25 15L15 25M25 25L15 15M35 20C35 28.2843 28.2843 35 20 35C11.7157 35 5 28.2843 5 20C5 11.7157 11.7157 5 20 5C28.2843 5 35 11.7157 35 20Z"),s.setAttribute("stroke","black"),s.setAttribute("stroke-width","3.33333"),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),a.appendChild(s);let p=document.createElement("h2");p.textContent="Oops! Something\u2019s not quite right.";let d=document.createElement("p");d.textContent="It looks like there was an issue loading the page. Try reloading and we\u2019ll get things back on track.",o.appendChild(n),o.appendChild(a),o.appendChild(p),o.appendChild(d),t.appendChild(o),e.appendChild(t);};var Kt=()=>Math.random().toString(36).substring(2),H=Kt;var j="https://api.onefootprint.com",q=B,z="footprint-js";var w={["auth"]:"auth_v1",["form"]:"form_v1",["render"]:"render_v1",["update_login_methods"]:"update_auth_methods_v1",["verify"]:"verify_v1",["verify-button"]:"verify_button_v1",["components"]:"verify_v1"};var _t=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),se=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let i;return Array.isArray(r)?i=r.map(se(e)):Object(r)===r?i=se(e)(r):i=r,[e(n),i]});return Object.fromEntries(o)},Tt=se(_t),W=Tt;var Ut=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:z,sdkVersion:q,logLevel:o,logMessage:t,sessionId:U()};try{fetch(`${j}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W(r))});}catch(i){}},J=Ut;var F=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}J(e,t,"info",n);}return o},pe=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}J(e,t,"warn",n);}return o},Q=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}J(e,t,"error",n);}return o};var We={["auth"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["update_login_methods"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["form"]:{["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["verify"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete"},["components"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["closed"]:"onClose",["completed"]:"onComplete",["relayToComponents"]:"onRelayToComponents"},["verify-button"]:{["auth"]:"onAuth",["canceled"]:"onCancel",["clicked"]:"onClick",["closed"]:"onClose",["completed"]:"onComplete"},["render"]:{}},Je={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var Qe={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},Bt=Object.values(D),Mt=(...e)=>{},b=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),le=e=>b(e)&&Object.keys(e).length>0,Nt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},X=(e,t)=>{var r;if(!t)return;let o=(r=Qe[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},A=e=>{var o;let t=(o=Qe[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},Y=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(M);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},Xe=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:i,onClick:a,label:s,containerId:p}=t,d=Ve(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return C(v({},d),{variant:i,kind:"verify"})}};var Ye=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||Mt,ce=(e,t,o)=>{var s;let{kind:n}=e,r=(s=We[n])!=null?s:{},i={},a=Xe(e);return Object.entries(r).forEach(([p,d])=>{let l=p;if(!Bt.includes(l))return;let h=Ye(e,d),k=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";i[l]=P=>{h(P),k&&(t==null||t()),m&&a&&(o==null||o(a));};}),i},R=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||A(t);return Y(t),X(t,o),Nt(r,n),le(e==null?void 0:e.userData)&&console.warn("userData is deprecated and will be removed in the next major version. Please use bootstrapData instead."),C(v({},e),{variant:r})},S=e=>le(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:le(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var $t=e=>e==="auth";var Ht=e=>e==="update_login_methods";var me=e=>e.kind==="components";var ue=e=>typeof e=="string"&&e.length>0,Z=e=>$t(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),jt=e=>Ht(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),fe=e=>[Z,jt].some(t=>t(e));var qt=3,zt=!1,Wt=e=>fe(e)?"update_auth_methods_v1":w[e.kind],Jt=e=>{var o,n;let{kind:t}=e;if(t==="verify"||t==="components")return C(v({},S(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,fixtureResult:(o=e.sandboxOutcome)==null?void 0:o.overallOutcome,documentFixtureResult:(n=e.sandboxOutcome)==null?void 0:n.documentOutcome,sandboxId:e.sandboxId,isComponentsSdk:t==="components"});if(t==="update_login_methods")return C(v({},S(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return Z(e)?C(v({},S(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&zt?C(v({},S(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):C(v({},S(e)),{publicKey:e.publicKey,options:e.options,l10n:e.l10n});if(t==="form")return {authToken:e.authToken,options:e.options,title:e.title,l10n:e.l10n};if(t==="render")return {authToken:e.authToken,canCopy:e.canCopy,defaultHidden:e.defaultHidden,id:e.id,label:e.label,showHiddenToggle:e.showHiddenToggle,l10n:e.l10n};if(t==="verify-button")return C(v({},S(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n});Q(t,"Invalid kind provided");},Ze=(e,t)=>u(void 0,null,function*(){return fetch(`${j}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${z} ${q} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return Ze(e,t-1)})}),Qt=e=>u(void 0,null,function*(){F(w[e.kind],"Sending SDK args");let t=Jt(e);if(!t)return;let o=yield Ze({data:W(t),kind:Wt(e)},qt);return o?o.token:void 0}),Ge=Qt;var et=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,i=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:i(),variant:n}},tt=()=>{let e=window.footprintAppearance;return !e||!b(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,variables:e.variables}};var ot=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Xt=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:i}=e,{fontSrc:a,rules:s,variables:p}=et(o),d=new URLSearchParams;return p&&d.append("variables",p),s&&d.append("rules",s),a&&d.append("font_src",a),r!=null&&r.language&&d.append("lng",r.language),d.append("variant",i||A(n)),`${d.toString()}#${t}`},Yt=(e,t)=>{let{kind:o}=e,n=Xt(e,t),r=`https://components.onefootprint.com/${o}`,i=`https://components2.onefootprint.com/${o}`;if(o==="update_login_methods"&&(r="https://auth.onefootprint.com/user",i="https://auth2.onefootprint.com/user"),o==="auth"&&(r="https://auth.onefootprint.com",i="https://auth2.onefootprint.com"),(o==="verify"||o==="verify-button"||o==="components")&&(r="https://id.onefootprint.com",i="https://id2.onefootprint.com"),!ue(r))throw new Error(`${o}_URL environment variable is not defined.`);return r+=`?${n}`.trim(),i+=`?${n}`.trim(),{url:r,fallbackUrl:i}},nt=Yt;var Zt=e=>{let t=null,o=!1,n,r,{formSaveComplete:i,formSaved:a,formSaveFailed:s,started:p}=N,d=R(e),{variant:l,containerId:h}=d,k=l==="modal"||l==="drawer",m=H(),P=(c,f)=>{var E;let g=Q(w[d.kind],c);(E=d.onError)==null||E.call(d,g),o&&f&&(n(),o=!1);},dt=()=>{if(!t){P("Footprint should be initialized in order to register callback props");return}let c=ce(d,n,r);Object.entries(c).forEach(([f,g])=>{t==null||t.on(f,g),t==null||t.on(`${m}:${f}`,g);});},pt=()=>{if(k)return Ne(m);if(!h){P("containerId is required when rendering inline");return}let c=document.getElementById(h);if(!c){P(`Could not find container with id ${h} while rendering footprint`);return}return $e(m,c)},G=(c,f)=>{if(!f){ae(m),t==null||t.frame.classList.remove("fp-hide"),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(k){let g=He(c,m);ie(g,m);}else ie(c,m);},he=()=>{var f;if(!t){P("Footprint should be initialized in order to set up refs");return}if(d.kind!=="form"||!d.getRef)return;let c={save:()=>(t||P("Footprint should be initialized to call ref methods"),new Promise((g,E)=>{t==null||t.on(i,()=>{g();}),t==null||t.on(s,Pe=>{E(Pe);}),t==null||t.on(`${m}:${i}`,g),t==null||t.on(`${m}:${s}`,E),t==null||t.call(a);}))};(f=d.getRef)==null||f.call(d,c);},ve=(c,f)=>u(void 0,null,function*(){try{return t=yield new Fe({classListArray:[`footprint-${l}`,`footprint-${l}-loading`,"fp-hide"],container:c,name:`footprint-iframe-${m}`,url:f,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:d.authToken,initId:m,sdkUrl:ot(),sdkVersion:B||""}}),{success:!0,parentApi:t}}catch(g){return P(`Initializing iframe with ${new URL(f).host} failed with error ${g}`),{success:!1}}}),lt=(E,Pe)=>u(void 0,[E,Pe],function*(c,{url:f,fallbackUrl:g}){F(w[d.kind],`Initializing iframe with ${new URL(f).host}`);let ke=yield ve(c,f);if(ke.success)return ke.parentApi;F(w[d.kind],`Initializing iframe with ${new URL(g).host} as fallback`);let Ce=yield ve(c,g);if(!Ce.success)throw new Error("Failed to initialize iframe");return Ce.parentApi});return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),je(m));},props:d,isRendered:o,render:()=>u(void 0,null,function*(){if(o){pe(w[d.kind],"Footprint component is already rendered");return}o=!0;let c=pt();if(!c){pe(w[d.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),G(c,!0);let f=yield Ge(d);if(!f){P("Unable to get SDK args token.",!0),G(c,!1);return}let{url:g,fallbackUrl:E}=nt(d,f||"");try{yield lt(c,{url:L(g),fallbackUrl:L(E)}),dt();}catch(Pe){ze(c),o=!1;}G(c,!1),t==null||t.on(p,()=>he()),t==null||t.on(`${m}:${p}`,he),d.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{qe(m);}));}),destroy:()=>u(void 0,null,function*(){o&&(o=!1,yield Me(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},ye=Zt;var V=e=>{let t=R(e);return JSON.stringify(t)},Gt=()=>{let e=Object.create(null);return {getOrCreate:i=>{let a=V(i.props),s=Object.values(e).find(p=>V(p.iframe.props)===a);return s?s.iframe:(e[a]={iframe:i,secondaryIframes:{}},i)},getOrCreateSecondary:(i,a)=>{let s=V(i.props),p=V(a.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:d}=e[s],l=Object.values(d).find(h=>V(h.props)===p);return l||(d[p]=a,a)},remove:i=>{let a=V(i.props),s=e[a];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[a]);},removeSecondary:(i,a)=>{let s=V(i.props),p=V(a.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:d}=e[s],l=d[p];l&&(l.destroy(),delete d[p]);}}},rt=Gt;var eo=()=>{let e=rt();return {init:o=>{let n=ye(o),r=()=>u(void 0,null,function*(){e.remove(n),yield n.destroy();}),i=d=>u(void 0,null,function*(){e.removeSecondary(n,d),yield d.destroy();}),a=d=>u(void 0,null,function*(){let l=ye(d);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{i(l);}),l.render();}),s=()=>u(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(a),yield n.render();}),p={};return me(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),v({render:s,destroy:r},p)}}},to=eo(),ge=to;var oo=e=>{window.setTimeout(e,0);},no=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let i=(s=window.footprintCallbacks)!=null?s:{};if(!b(i))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Je[r].forEach(p=>{if(!i[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),i},o=r=>{var m;let i=r.getAttribute("data-kind");Y(i);let a=(m=r.getAttribute("data-variant"))!=null?m:A(i);X(i,a);let s=tt(),p=t(i),d=r.getAttribute("data-props")||"",l;try{l=JSON.parse(d);}catch(P){throw Error("Could not parse `data-props` for footprint.")}if(!b(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let h=H();r.setAttribute("id",h),e.init(v(v({kind:i,variant:a,appearance:s,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(i=>{o(i);});};document.addEventListener("DOMContentLoaded",()=>oo(n));},at=no;var ro="http://test",it=e=>u(void 0,null,function*(){let t=yield fetch(`${ro}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),ao=e=>u(void 0,null,function*(){if(!b(e))throw new Error("User data must be passed in order to identify an user");let t=e["id.email"],o=e["id.phone_number"];return t&&(yield it({email:t}))?!0:o?yield it({phone_number:o}):!1}),st=ao;var rr=ge;at(ge);/*! Bundled license information: | ||
@onefootprint/postmate/build/postmate.es.js: | ||
@@ -20,7 +16,7 @@ (** | ||
exports.FootprintComponentKind = M; | ||
exports.FootprintPrivateEvent = N; | ||
exports.FootprintPublicEvent = D; | ||
exports.default = rr; | ||
exports.identifyFootprintUser = st; | ||
exports.FootprintComponentKind = T; | ||
exports.FootprintPrivateEvent = B; | ||
exports.FootprintPublicEvent = L; | ||
exports.default = Tn; | ||
exports.identifyFootprintUser = et; | ||
@@ -31,2 +27,2 @@ Object.defineProperty(exports, '__esModule', { value: true }); | ||
})({}, ft); | ||
})({}); |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "3.14.1", | ||
"version": "3.14.2", | ||
"main": "./dist/footprint-js.cjs", | ||
@@ -8,0 +8,0 @@ "module": "./dist/footprint-js.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85646
670