Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@onefootprint/footprint-js

Package Overview
Dependencies
Maintainers
0
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@onefootprint/footprint-js - npm Package Compare versions

Comparing version 3.12.0 to 3.12.1

22

dist/footprint-js.d.ts

@@ -173,3 +173,3 @@ import * as CSS from 'csstype';

middle_name: string;
ownership_stake: string;
ownership_stake: number;
phone_number: string;

@@ -180,3 +180,3 @@ };

'business.address_line2': string;
'business.beneficial_owners': Business_BeneficialOwners[];
'business.beneficial_owners': Partial<Business_BeneficialOwners>[];
'business.city': string;

@@ -188,3 +188,3 @@ 'business.corporation_type': string;

'business.formation_state': string;
'business.kyced_beneficial_owners': Business_BeneficialOwners[];
'business.kyced_beneficial_owners': Partial<Business_BeneficialOwners>[];
'business.name': string;

@@ -235,3 +235,3 @@ 'business.phone_number': string;

readonly containerId?: string;
readonly kind: ComponentKind;
readonly kind: `${ComponentKind}`;
readonly l10n?: L10n;

@@ -264,3 +264,3 @@ readonly onError?: (error: string) => void;

type VerifyProps = VerifyPropsBase<VerifyAuthToken | VerifyPublicKey> & {
readonly kind: ComponentKind.Verify;
readonly kind: `${ComponentKind.Verify}`;
readonly variant?: VerifyVariant;

@@ -274,3 +274,3 @@ };

readonly onRelayToComponents?: (authToken: string) => void;
readonly kind: ComponentKind.Components;
readonly kind: `${ComponentKind.Components}`;
readonly variant?: VerifyVariant;

@@ -282,3 +282,3 @@ };

readonly dialogVariant?: VerifyVariant;
readonly kind: ComponentKind.VerifyButton;
readonly kind: `${ComponentKind.VerifyButton}`;
readonly label?: string;

@@ -296,3 +296,3 @@ readonly onClick?: () => void;

readonly id: string;
readonly kind: ComponentKind.Render;
readonly kind: `${ComponentKind.Render}`;
readonly label?: string;

@@ -316,3 +316,3 @@ readonly showHiddenToggle?: boolean;

readonly getRef?: (ref: FormRef) => void;
readonly kind: ComponentKind.Form;
readonly kind: `${ComponentKind.Form}`;
readonly onCancel?: () => void;

@@ -329,3 +329,3 @@ readonly onClose?: () => void;

readonly bootstrapData?: Pick<BootstrapData, 'id.email' | 'id.phone_number'>;
readonly kind: ComponentKind.Auth;
readonly kind: `${ComponentKind.Auth}`;
readonly onCancel?: () => void;

@@ -350,3 +350,3 @@ readonly onClose?: () => void;

readonly bootstrapData?: Pick<BootstrapData, 'id.email' | 'id.phone_number'>;
readonly kind: ComponentKind.UpdateLoginMethods;
readonly kind: `${ComponentKind.UpdateLoginMethods}`;
readonly onCancel?: () => void;

@@ -353,0 +353,0 @@ readonly onClose?: () => void;

import yt from '@onefootprint/postmate';
var je=Object.defineProperty,qe=Object.defineProperties;var He=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var ae=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var re=(e,t,o)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,f=(e,t)=>{for(var o in t||(t={}))ae.call(t,o)&&re(e,o,t[o]);if(I)for(var o of I(t))ie.call(t,o)&&re(e,o,t[o]);return e},P=(e,t)=>qe(e,He(t));var se=(e,t)=>{var o={};for(var n in e)ae.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&I)for(var n of I(e))t.indexOf(n)<0&&ie.call(e,n)&&(o[n]=e[n]);return o};var y=(e,t,o)=>new Promise((n,r)=>{var d=p=>{try{s(o.next(p));}catch(a){r(a);}},i=p=>{try{s(o.throw(p));}catch(a){r(a);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(d,i);s((o=o.apply(e,t)).next());});var K="3.12.0";var R=(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))(R||{});var x=(i=>(i.auth="auth",i.canceled="canceled",i.clicked="clicked",i.closed="closed",i.completed="completed",i.relayToComponents="relayToComponents",i))(x||{}),E=(i=>(i.formSaveComplete="formSaveComplete",i.formSaveFailed="formSaveFailed",i.formSaved="formSaved",i.propsReceived="propsReceived",i.started="started",i.relayFromComponents="relayFromComponents",i))(E||{});var de="footprint-inline-container",pe="footprint-body-locked",le="footprint-overlay",Je="footprint-overlay-container",ce=de,me=le,ye="footprint-loading-indicator",L=e=>`${Je}-${e}`,w=(e,t)=>`${e}-${t}`,fe=e=>y(void 0,null,function*(){q(e),Xe(e),yield We(e);}),ue=e=>{let t=L(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},We=e=>y(void 0,null,function*(){let t=L(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 d=w(me,e),i=document.getElementById(d);i&&(i.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),i.remove(),document.body.classList.remove(pe));}),ge=(e,t)=>{let o=w(ce,e),n=document.createElement("div");return n.classList.add(de),n.setAttribute("id",o),t.appendChild(n),n},Xe=e=>{let t=w(ce,e),o=document.getElementById(t);o&&o.remove();},q=e=>{let t=w(ye,e),o=document.getElementById(t);o&&o.remove();},H=(e,t)=>{let o=w(ye,t),n=Ye(o);e.appendChild(n);},he=(e,t)=>{document.body.classList.add(pe);let o=document.createElement("div"),n=w(me,t);return o.setAttribute("id",n),o.classList.add(le),e.appendChild(o),o},Ye=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},Pe=e=>{let t=document.getElementById(L(e));t&&(t.style.opacity="1",t.style.display="block");},ke=e=>{let t=document.getElementById(L(e));t&&(t.style.opacity="0",t.style.display="none");};var Ge=()=>Math.random().toString(36).substring(2),T=Ge;var B="https://api.onefootprint.com",U=K,_="footprint-js";var S={["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 Ze=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 d;return Array.isArray(r)?d=r.map(z(e)):Object(r)===r?d=z(e)(r):d=r,[e(n),d]});return Object.fromEntries(o)},Qe=z(Ze),M=Qe;var et=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:_,sdkVersion:U,logLevel:o,logMessage:t};try{fetch(`${B}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M(r))});}catch(d){}},J=et;var W=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}J(e,t,"warn",n);}return o},ve=(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 be={["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"]:{}},Ve={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var we={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},tt=Object.values(x),ot=(...e)=>{},C=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),X=e=>C(e)&&Object.keys(e).length>0,nt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},$=(e,t)=>{var r;if(!t)return;let o=(r=we[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},F=e=>{var o;let t=(o=we[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},N=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(R);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},Se=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:d,onClick:i,label:s,containerId:p}=t,a=se(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return P(f({},a),{variant:d,kind:"verify"})}};var Fe=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||ot,Y=(e,t,o)=>{var s;let{kind:n}=e,r=(s=be[n])!=null?s:{},d={},i=Se(e);return Object.entries(r).forEach(([p,a])=>{let l=p;if(!tt.includes(l))return;let k=Fe(e,a),A=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";d[l]=h=>{k(h),A&&(t==null||t()),m&&i&&(o==null||o(i));};}),d},D=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||F(t);return N(t),$(t,o),nt(r,n),X(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(f({},e),{variant:r})},v=e=>X(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:X(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var Ae=e=>e==="auth",rt=e=>e==="verify",xe=e=>e==="update_login_methods",at=e=>e==="components",G=e=>e.kind==="components",Z=e=>[Ae,rt,at,xe].some(t=>t(e)),Q=e=>typeof e=="string"&&e.length>0,j=e=>Ae(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),it=e=>xe(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),O=e=>[j,it].some(t=>t(e));var st=3,dt=!1,pt=e=>O(e)?"update_auth_methods_v1":S[e.kind],lt=e=>{let{kind:t}=e;if(t==="verify"||t==="components")return P(f({},v(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,isComponentsSdk:t==="components"});if(t==="update_login_methods")return P(f({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return j(e)?P(f({},v(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&dt?P(f({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):P(f({},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 P(f({},v(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n})},De=(e,t)=>y(void 0,null,function*(){return fetch(`${B}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${_} ${U} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return De(e,t-1)})}),ct=e=>y(void 0,null,function*(){let t=lt(e);if(!t)return;let o=yield De({data:M(t),kind:pt(e)},st);return o?o.token:void 0}),Oe=ct;var Ie=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,d=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:d(),variant:n}},Ke=()=>{let e=window.footprintAppearance;return !e||!C(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,theme:e.theme,variables:e.variables}};var Ee=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Re=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:d}=e,{fontSrc:i,rules:s,variables:p}=Ie(o),a=new URLSearchParams;return p&&a.append("variables",p),s&&a.append("rules",s),i&&a.append("font_src",i),r!=null&&r.language&&a.append("lng",r.language),a.append("variant",d||F(n)),`${a.toString()}#${t}`},mt=(e,t)=>{let{kind:o}=e,n;switch(o){case"verify":case"components":n="https://id.onefootprint.com";break;case"auth":n=O(e)?"https://auth.onefootprint.com/user":"https://auth.onefootprint.com";break;default:n="https://components.onefootprint.com";}if(Q(n))return Z(o)?`${n}?${Re(e,t)}`.trim():`${n}/${o}?${Re(e,t)}`.trim();throw new Error(`${o}_URL environment variable is not defined.`)},Le=mt;var ft=e=>{let t=null,o=!1,n,r,{formSaveComplete:d,formSaved:i,formSaveFailed:s,started:p}=E,a=D(e),{variant:l,containerId:k}=a,A=l==="modal"||l==="drawer",m=T(),h=(c,u)=>{var V;let g=ve(S[a.kind],c);(V=a.onError)==null||V.call(a,g),o&&u&&(n(),o=!1);},Me=()=>{if(!t){h("Footprint should be initialized in order to register callback props");return}let c=Y(a,n,r);Object.entries(c).forEach(([u,g])=>{t==null||t.on(u,g),t==null||t.on(`${m}:${u}`,g);});},$e=()=>{if(A)return ue(m);if(!k){h("containerId is required when rendering inline");return}let c=document.getElementById(k);if(!c){h(`Could not find container with id ${k} while rendering footprint`);return}return ge(m,c)},oe=(c,u)=>{if(!u){q(m),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(A){let g=he(c,m);H(g,m);}else H(c,m);},ne=()=>{var u;if(!t){h("Footprint should be initialized in order to set up refs");return}if(a.kind!=="form"||!a.getRef)return;let c={save:()=>(t||h("Footprint should be initialized to call ref methods"),new Promise((g,V)=>{t==null||t.on(d,()=>{g();}),t==null||t.on(s,Ne=>{V(Ne);}),t==null||t.on(`${m}:${d}`,g),t==null||t.on(`${m}:${s}`,V),t==null||t.call(i);}))};(u=a.getRef)==null||u.call(a,c);};return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Pe(m));},props:a,isRendered:o,render:()=>y(void 0,null,function*(){if(o){W(S[a.kind],"Footprint component is already rendered");return}let c=$e();if(!c){W(S[a.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),o=!0,oe(c,!0);let u=yield Oe(a);if(!u){h("Unable to get SDK args token.",!0);return}let g=Le(a,u||"");try{t=yield new yt({classListArray:[`footprint-${l}`,`footprint-${l}-loading`],container:c,name:`footprint-iframe-${m}`,url:g,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:a.authToken,initId:m,sdkUrl:Ee(),sdkVersion:K||""}});}catch(V){h(`Initializing iframe failed with error ${V}`,!0);return}oe(c,!1),Me(),t==null||t.on(p,()=>ne()),t==null||t.on(`${m}:${p}`,ne),a.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{ke(m);}));}),destroy:()=>y(void 0,null,function*(){o&&(o=!1,yield fe(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},ee=ft;var b=e=>{let t=D(e);return JSON.stringify(t)},ut=()=>{let e=Object.create(null);return {getOrCreate:d=>{let i=b(d.props),s=Object.values(e).find(p=>b(p.iframe.props)===i);return s?s.iframe:(e[i]={iframe:d,secondaryIframes:{}},d)},getOrCreateSecondary:(d,i)=>{let s=b(d.props),p=b(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:a}=e[s],l=Object.values(a).find(k=>b(k.props)===p);return l||(a[p]=i,i)},remove:d=>{let i=b(d.props),s=e[i];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[i]);},removeSecondary:(d,i)=>{let s=b(d.props),p=b(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:a}=e[s],l=a[p];l&&(l.destroy(),delete a[p]);}}},Te=ut;var gt=()=>{let e=Te();return {init:o=>{let n=ee(o),r=()=>y(void 0,null,function*(){e.remove(n),yield n.destroy();}),d=a=>y(void 0,null,function*(){e.removeSecondary(n,a),yield a.destroy();}),i=a=>y(void 0,null,function*(){let l=ee(a);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{d(l);}),l.render();}),s=()=>y(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(i),yield n.render();}),p={};return G(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),f({render:s,destroy:r},p)}}},ht=gt(),te=ht;var Pt=e=>{window.setTimeout(e,0);},kt=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let d=(s=window.footprintCallbacks)!=null?s:{};if(!C(d))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Ve[r].forEach(p=>{if(!d[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),d},o=r=>{var m;let d=r.getAttribute("data-kind");N(d);let i=(m=r.getAttribute("data-variant"))!=null?m:F(d);$(d,i);let s=Ke(),p=t(d),a=r.getAttribute("data-props")||"",l;try{l=JSON.parse(a);}catch(h){throw Error("Could not parse `data-props` for footprint.")}if(!C(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let k=T();r.setAttribute("id",k),e.init(f(f({kind:d,variant:i,appearance:s,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(d=>{o(d);});};document.addEventListener("DOMContentLoaded",()=>Pt(n));},Be=kt;var Ct="http://test",Ue=e=>y(void 0,null,function*(){let t=yield fetch(`${Ct}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),vt=e=>y(void 0,null,function*(){if(!C(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 Ue({email:t}))?!0:o?yield Ue({phone_number:o}):!1}),_e=vt;var Yo=te;Be(te);
var je=Object.defineProperty,qe=Object.defineProperties;var He=Object.getOwnPropertyDescriptors;var I=Object.getOwnPropertySymbols;var ae=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var re=(e,t,o)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,f=(e,t)=>{for(var o in t||(t={}))ae.call(t,o)&&re(e,o,t[o]);if(I)for(var o of I(t))ie.call(t,o)&&re(e,o,t[o]);return e},P=(e,t)=>qe(e,He(t));var se=(e,t)=>{var o={};for(var n in e)ae.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(e!=null&&I)for(var n of I(e))t.indexOf(n)<0&&ie.call(e,n)&&(o[n]=e[n]);return o};var y=(e,t,o)=>new Promise((n,r)=>{var d=p=>{try{s(o.next(p));}catch(a){r(a);}},i=p=>{try{s(o.throw(p));}catch(a){r(a);}},s=p=>p.done?n(p.value):Promise.resolve(p.value).then(d,i);s((o=o.apply(e,t)).next());});var K="3.12.1";var R=(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))(R||{});var x=(i=>(i.auth="auth",i.canceled="canceled",i.clicked="clicked",i.closed="closed",i.completed="completed",i.relayToComponents="relayToComponents",i))(x||{}),E=(i=>(i.formSaveComplete="formSaveComplete",i.formSaveFailed="formSaveFailed",i.formSaved="formSaved",i.propsReceived="propsReceived",i.started="started",i.relayFromComponents="relayFromComponents",i))(E||{});var de="footprint-inline-container",pe="footprint-body-locked",le="footprint-overlay",Je="footprint-overlay-container",ce=de,me=le,ye="footprint-loading-indicator",L=e=>`${Je}-${e}`,w=(e,t)=>`${e}-${t}`,fe=e=>y(void 0,null,function*(){q(e),Xe(e),yield We(e);}),ue=e=>{let t=L(e),o=document.getElementById(t);if(o)return o;let n=document.createElement("div");return n.setAttribute("id",t),document.body.appendChild(n),n},We=e=>y(void 0,null,function*(){let t=L(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 d=w(me,e),i=document.getElementById(d);i&&(i.classList.add("footprint-overlay-fading"),yield new Promise(s=>{setTimeout(s,200);}),o.remove(),i.remove(),document.body.classList.remove(pe));}),ge=(e,t)=>{let o=w(ce,e),n=document.createElement("div");return n.classList.add(de),n.setAttribute("id",o),t.appendChild(n),n},Xe=e=>{let t=w(ce,e),o=document.getElementById(t);o&&o.remove();},q=e=>{let t=w(ye,e),o=document.getElementById(t);o&&o.remove();},H=(e,t)=>{let o=w(ye,t),n=Ye(o);e.appendChild(n);},he=(e,t)=>{document.body.classList.add(pe);let o=document.createElement("div"),n=w(me,t);return o.setAttribute("id",n),o.classList.add(le),e.appendChild(o),o},Ye=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},Pe=e=>{let t=document.getElementById(L(e));t&&(t.style.opacity="1",t.style.display="block");},ke=e=>{let t=document.getElementById(L(e));t&&(t.style.opacity="0",t.style.display="none");};var Ge=()=>Math.random().toString(36).substring(2),T=Ge;var B="https://api.onefootprint.com",U=K,_="footprint-js";var S={["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 Ze=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 d;return Array.isArray(r)?d=r.map(z(e)):Object(r)===r?d=z(e)(r):d=r,[e(n),d]});return Object.fromEntries(o)},Qe=z(Ze),M=Qe;var et=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:_,sdkVersion:U,logLevel:o,logMessage:t};try{fetch(`${B}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M(r))});}catch(d){}},J=et;var W=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}J(e,t,"warn",n);}return o},ve=(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 be={["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"]:{}},Ve={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var we={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},tt=Object.values(x),ot=(...e)=>{},C=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),X=e=>C(e)&&Object.keys(e).length>0,nt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},$=(e,t)=>{var r;if(!t)return;let o=(r=we[e])!=null?r:[];if(!o.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${o.join(", ")}`)},F=e=>{var o;let t=(o=we[e])!=null?o:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},N=e=>{if(!e)throw new Error("Kind is required");let t=Object.values(R);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},Se=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:d,onClick:i,label:s,containerId:p}=t,a=se(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return P(f({},a),{variant:d,kind:"verify"})}};var Fe=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||ot,Y=(e,t,o)=>{var s;let{kind:n}=e,r=(s=be[n])!=null?s:{},d={},i=Se(e);return Object.entries(r).forEach(([p,a])=>{let l=p;if(!tt.includes(l))return;let k=Fe(e,a),A=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";d[l]=h=>{k(h),A&&(t==null||t()),m&&i&&(o==null||o(i));};}),d},D=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||F(t);return N(t),$(t,o),nt(r,n),X(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(f({},e),{variant:r})},v=e=>X(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:X(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var Ae=e=>e==="auth",rt=e=>e==="verify",xe=e=>e==="update_login_methods",at=e=>e==="components",G=e=>e.kind==="components",Z=e=>[Ae,rt,at,xe].some(t=>t(e)),Q=e=>typeof e=="string"&&e.length>0,j=e=>Ae(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),it=e=>xe(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),O=e=>[j,it].some(t=>t(e));var st=3,dt=!1,pt=e=>O(e)?"update_auth_methods_v1":S[e.kind],lt=e=>{let{kind:t}=e;if(t==="verify"||t==="components")return P(f({},v(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,isComponentsSdk:t==="components"});if(t==="update_login_methods")return P(f({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return j(e)?P(f({},v(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&dt?P(f({},v(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):P(f({},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 P(f({},v(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n})},De=(e,t)=>y(void 0,null,function*(){return fetch(`${B}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${_} ${U} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return De(e,t-1)})}),ct=e=>y(void 0,null,function*(){let t=lt(e);if(!t)return;let o=yield De({data:M(t),kind:pt(e)},st);return o?o.token:void 0}),Oe=ct;var Ie=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,d=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:d(),variant:n}},Ke=()=>{let e=window.footprintAppearance;return !e||!C(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,theme:e.theme,variables:e.variables}};var Ee=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Re=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:d}=e,{fontSrc:i,rules:s,variables:p}=Ie(o),a=new URLSearchParams;return p&&a.append("variables",p),s&&a.append("rules",s),i&&a.append("font_src",i),r!=null&&r.language&&a.append("lng",r.language),a.append("variant",d||F(n)),`${a.toString()}#${t}`},mt=(e,t)=>{let{kind:o}=e,n;switch(o){case"verify":case"components":n="https://id.onefootprint.com";break;case"auth":n=O(e)?"https://auth.onefootprint.com/user":"https://auth.onefootprint.com";break;default:n="https://components.onefootprint.com";}if(Q(n))return Z(o)?`${n}?${Re(e,t)}`.trim():`${n}/${o}?${Re(e,t)}`.trim();throw new Error(`${o}_URL environment variable is not defined.`)},Le=mt;var ft=e=>{let t=null,o=!1,n,r,{formSaveComplete:d,formSaved:i,formSaveFailed:s,started:p}=E,a=D(e),{variant:l,containerId:k}=a,A=l==="modal"||l==="drawer",m=T(),h=(c,u)=>{var V;let g=ve(S[a.kind],c);(V=a.onError)==null||V.call(a,g),o&&u&&(n(),o=!1);},Me=()=>{if(!t){h("Footprint should be initialized in order to register callback props");return}let c=Y(a,n,r);Object.entries(c).forEach(([u,g])=>{t==null||t.on(u,g),t==null||t.on(`${m}:${u}`,g);});},$e=()=>{if(A)return ue(m);if(!k){h("containerId is required when rendering inline");return}let c=document.getElementById(k);if(!c){h(`Could not find container with id ${k} while rendering footprint`);return}return ge(m,c)},oe=(c,u)=>{if(!u){q(m),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(A){let g=he(c,m);H(g,m);}else H(c,m);},ne=()=>{var u;if(!t){h("Footprint should be initialized in order to set up refs");return}if(a.kind!=="form"||!a.getRef)return;let c={save:()=>(t||h("Footprint should be initialized to call ref methods"),new Promise((g,V)=>{t==null||t.on(d,()=>{g();}),t==null||t.on(s,Ne=>{V(Ne);}),t==null||t.on(`${m}:${d}`,g),t==null||t.on(`${m}:${s}`,V),t==null||t.call(i);}))};(u=a.getRef)==null||u.call(a,c);};return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Pe(m));},props:a,isRendered:o,render:()=>y(void 0,null,function*(){if(o){W(S[a.kind],"Footprint component is already rendered");return}let c=$e();if(!c){W(S[a.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),o=!0,oe(c,!0);let u=yield Oe(a);if(!u){h("Unable to get SDK args token.",!0);return}let g=Le(a,u||"");try{t=yield new yt({classListArray:[`footprint-${l}`,`footprint-${l}-loading`],container:c,name:`footprint-iframe-${m}`,url:g,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:a.authToken,initId:m,sdkUrl:Ee(),sdkVersion:K||""}});}catch(V){h(`Initializing iframe failed with error ${V}`,!0);return}oe(c,!1),Me(),t==null||t.on(p,()=>ne()),t==null||t.on(`${m}:${p}`,ne),a.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{ke(m);}));}),destroy:()=>y(void 0,null,function*(){o&&(o=!1,yield fe(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},ee=ft;var b=e=>{let t=D(e);return JSON.stringify(t)},ut=()=>{let e=Object.create(null);return {getOrCreate:d=>{let i=b(d.props),s=Object.values(e).find(p=>b(p.iframe.props)===i);return s?s.iframe:(e[i]={iframe:d,secondaryIframes:{}},d)},getOrCreateSecondary:(d,i)=>{let s=b(d.props),p=b(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:a}=e[s],l=Object.values(a).find(k=>b(k.props)===p);return l||(a[p]=i,i)},remove:d=>{let i=b(d.props),s=e[i];s&&(Object.keys(s.secondaryIframes).forEach(p=>{s.secondaryIframes[p].destroy();}),delete e[i]);},removeSecondary:(d,i)=>{let s=b(d.props),p=b(i.props);if(!e[s])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:a}=e[s],l=a[p];l&&(l.destroy(),delete a[p]);}}},Te=ut;var gt=()=>{let e=Te();return {init:o=>{let n=ee(o),r=()=>y(void 0,null,function*(){e.remove(n),yield n.destroy();}),d=a=>y(void 0,null,function*(){e.removeSecondary(n,a),yield a.destroy();}),i=a=>y(void 0,null,function*(){let l=ee(a);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{d(l);}),l.render();}),s=()=>y(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(i),yield n.render();}),p={};return G(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),f({render:s,destroy:r},p)}}},ht=gt(),te=ht;var Pt=e=>{window.setTimeout(e,0);},kt=e=>{if(typeof window=="undefined")return;let t=r=>{var s;let d=(s=window.footprintCallbacks)!=null?s:{};if(!C(d))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Ve[r].forEach(p=>{if(!d[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),d},o=r=>{var m;let d=r.getAttribute("data-kind");N(d);let i=(m=r.getAttribute("data-variant"))!=null?m:F(d);$(d,i);let s=Ke(),p=t(d),a=r.getAttribute("data-props")||"",l;try{l=JSON.parse(a);}catch(h){throw Error("Could not parse `data-props` for footprint.")}if(!C(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let k=T();r.setAttribute("id",k),e.init(f(f({kind:d,variant:i,appearance:s,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(d=>{o(d);});};document.addEventListener("DOMContentLoaded",()=>Pt(n));},Be=kt;var Ct="http://test",Ue=e=>y(void 0,null,function*(){let t=yield fetch(`${Ct}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),vt=e=>y(void 0,null,function*(){if(!C(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 Ue({email:t}))?!0:o?yield Ue({phone_number:o}):!1}),_e=vt;var Yo=te;Be(te);
export { R as FootprintComponentKind, E as FootprintPrivateEvent, x as FootprintPublicEvent, Yo as default, _e as identifyFootprintUser };
(function (exports) {
'use strict';
var We=Object.defineProperty,Je=Object.defineProperties;var Xe=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var se=(e,t,o)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,u=(e,t)=>{for(var o in t||(t={}))de.call(t,o)&&se(e,o,t[o]);if(R)for(var o of R(t))pe.call(t,o)&&se(e,o,t[o]);return e},P=(e,t)=>Je(e,Xe(t));var le=(e,t)=>{var o={};for(var n in e)de.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&&pe.call(e,n)&&(o[n]=e[n]);return o};var f=(e,t,o)=>new Promise((n,r)=>{var d=p=>{try{i(o.next(p));}catch(s){r(s);}},a=p=>{try{i(o.throw(p));}catch(s){r(s);}},i=p=>p.done?n(p.value):Promise.resolve(p.value).then(d,a);i((o=o.apply(e,t)).next());});var E="application/x-postmate-v1+json",Ye=5,Ge=0,Ze=function(){return ++Ge};var Qe=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},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||!et[t.data.postmate])},tt=function(t,o){var n=typeof t[o]=="function"?t[o]():t[o];return O.Promise.resolve(n)},ot=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 d=((r||{}).data||{}).value||{},a=d.data,i=d.name;r.data.postmate==="emit"&&i in n.events&&n.events[i].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(d){var a=Ze(),i=function p(s){s.data.uid===a&&s.data.postmate==="reply"&&(r.parent.removeEventListener("message",p,!1),d(s.data.value));};r.parent.addEventListener("message",i,!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}(),nt=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 d=r.data,a=d.property,i=d.uid,p=d.data;if(r.data.postmate==="call"){a in n.model&&typeof n.model[a]=="function"&&n.model[a](p);return}tt(n.model,a).then(function(s){return r.source.postMessage({property:a,postmate:"reply",type:E,uid:i,value:s},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,d=o.model,a=o.url,i=o.name,p=i===void 0?"":i,s=o.allow,l=o.classListArray,y=l===void 0?[]:l;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=p||"",this.frame.classList.add.apply(this.frame.classList,y),s&&(this.frame.allow=s),r.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=d||{},this.sendHandshake(a)}var t=e.prototype;return t.sendHandshake=function(n){var r=this,d=Qe(n),a=0,i;return new e.Promise(function(p,s){var l=function m(h){return z(h,d)?h.data.postmate==="handshake-reply"?(clearInterval(i),r.parent.removeEventListener("message",m,!1),r.childOrigin=h.origin,p(new ot(r))):s("Failed handshake"):!1};r.parent.addEventListener("message",l,!1);var y=function(){a++,r.child.postMessage({postmate:"handshake",type:E,model:r.model},d),a===Ye&&clearInterval(i);},C=function(){y(),i=setInterval(y,500);};r.frame.attachEvent?r.frame.attachEvent("onload",C):r.frame.addEventListener("load",C),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,d){var a=function i(p){if(p.data.postmate){if(p.data.postmate==="handshake"){n.child.removeEventListener("message",i,!1),p.source.postMessage({postmate:"handshake-reply",type:E},p.origin),n.parentOrigin=p.origin;var s=p.data.model;return s&&Object.keys(s).forEach(function(l){n.model[l]=s[l];}),r(new nt(n))}return d("Handshake Reply Failed")}};n.child.addEventListener("message",a,!1);})},e}();var ce=O;var L="3.12.0";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 I=(a=>(a.auth="auth",a.canceled="canceled",a.clicked="clicked",a.closed="closed",a.completed="completed",a.relayToComponents="relayToComponents",a))(I||{}),_=(a=>(a.formSaveComplete="formSaveComplete",a.formSaveFailed="formSaveFailed",a.formSaved="formSaved",a.propsReceived="propsReceived",a.started="started",a.relayFromComponents="relayFromComponents",a))(_||{});var me="footprint-inline-container",fe="footprint-body-locked",ue="footprint-overlay",at="footprint-overlay-container",ye=me,he=ue,ge="footprint-loading-indicator",T=e=>`${at}-${e}`,S=(e,t)=>`${e}-${t}`,ve=e=>f(void 0,null,function*(){W(e),st(e),yield it(e);}),Pe=e=>{let t=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},it=e=>f(void 0,null,function*(){let t=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(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 d=S(he,e),a=document.getElementById(d);a&&(a.classList.add("footprint-overlay-fading"),yield new Promise(i=>{setTimeout(i,200);}),o.remove(),a.remove(),document.body.classList.remove(fe));}),ke=(e,t)=>{let o=S(ye,e),n=document.createElement("div");return n.classList.add(me),n.setAttribute("id",o),t.appendChild(n),n},st=e=>{let t=S(ye,e),o=document.getElementById(t);o&&o.remove();},W=e=>{let t=S(ge,e),o=document.getElementById(t);o&&o.remove();},J=(e,t)=>{let o=S(ge,t),n=dt(o);e.appendChild(n);},Ce=(e,t)=>{document.body.classList.add(fe);let o=document.createElement("div"),n=S(he,t);return o.setAttribute("id",n),o.classList.add(ue),e.appendChild(o),o},dt=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},Ve=e=>{let t=document.getElementById(T(e));t&&(t.style.opacity="1",t.style.display="block");},be=e=>{let t=document.getElementById(T(e));t&&(t.style.opacity="0",t.style.display="none");};var pt=()=>Math.random().toString(36).substring(2),B=pt;var M="https://api.onefootprint.com",U=L,N="footprint-js";var D={["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 lt=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),X=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let d;return Array.isArray(r)?d=r.map(X(e)):Object(r)===r?d=X(e)(r):d=r,[e(n),d]});return Object.fromEntries(o)},ct=X(lt),$=ct;var mt=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:N,sdkVersion:U,logLevel:o,logMessage:t};try{fetch(`${M}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($(r))});}catch(d){}},Y=mt;var G=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}Y(e,t,"warn",n);}return o},Ee=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}Y(e,t,"error",n);}return o};var Oe={["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"]:{}},Se={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var De={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},ft=Object.values(I),ut=(...e)=>{},k=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Z=e=>k(e)&&Object.keys(e).length>0,yt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},H=(e,t)=>{var r;if(!t)return;let o=(r=De[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=De[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(K);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},Ae=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:d,onClick:a,label:i,containerId:p}=t,s=le(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return P(u({},s),{variant:d,kind:"verify"})}};var Ie=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||ut,Q=(e,t,o)=>{var i;let{kind:n}=e,r=(i=Oe[n])!=null?i:{},d={},a=Ae(e);return Object.entries(r).forEach(([p,s])=>{let l=p;if(!ft.includes(l))return;let y=Ie(e,s),C=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";d[l]=h=>{y(h),C&&(t==null||t()),m&&a&&(o==null||o(a));};}),d},F=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||A(t);return j(t),H(t,o),yt(r,n),Z(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(u({},e),{variant:r})},V=e=>Z(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:Z(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var Fe=e=>e==="auth",ht=e=>e==="verify",xe=e=>e==="update_login_methods",gt=e=>e==="components",ee=e=>e.kind==="components",te=e=>[Fe,ht,gt,xe].some(t=>t(e)),oe=e=>typeof e=="string"&&e.length>0,q=e=>Fe(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),vt=e=>xe(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),x=e=>[q,vt].some(t=>t(e));var Pt=3,kt=!1,Ct=e=>x(e)?"update_auth_methods_v1":D[e.kind],Vt=e=>{let{kind:t}=e;if(t==="verify"||t==="components")return P(u({},V(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,isComponentsSdk:t==="components"});if(t==="update_login_methods")return P(u({},V(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return q(e)?P(u({},V(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&kt?P(u({},V(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):P(u({},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 P(u({},V(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n})},Re=(e,t)=>f(void 0,null,function*(){return fetch(`${M}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${N} ${U} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return Re(e,t-1)})}),bt=e=>f(void 0,null,function*(){let t=Vt(e);if(!t)return;let o=yield Re({data:$(t),kind:Ct(e)},Pt);return o?o.token:void 0}),Le=bt;var Ke=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,d=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:d(),variant:n}},_e=()=>{let e=window.footprintAppearance;return !e||!k(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,theme:e.theme,variables:e.variables}};var Be=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Te=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:d}=e,{fontSrc:a,rules:i,variables:p}=Ke(o),s=new URLSearchParams;return p&&s.append("variables",p),i&&s.append("rules",i),a&&s.append("font_src",a),r!=null&&r.language&&s.append("lng",r.language),s.append("variant",d||A(n)),`${s.toString()}#${t}`},wt=(e,t)=>{let{kind:o}=e,n;switch(o){case"verify":case"components":n="https://id.onefootprint.com";break;case"auth":n=x(e)?"https://auth.onefootprint.com/user":"https://auth.onefootprint.com";break;default:n="https://components.onefootprint.com";}if(oe(n))return te(o)?`${n}?${Te(e,t)}`.trim():`${n}/${o}?${Te(e,t)}`.trim();throw new Error(`${o}_URL environment variable is not defined.`)},Me=wt;var Et=e=>{let t=null,o=!1,n,r,{formSaveComplete:d,formSaved:a,formSaveFailed:i,started:p}=_,s=F(e),{variant:l,containerId:y}=s,C=l==="modal"||l==="drawer",m=B(),h=(c,g)=>{var w;let v=Ee(D[s.kind],c);(w=s.onError)==null||w.call(s,v),o&&g&&(n(),o=!1);},je=()=>{if(!t){h("Footprint should be initialized in order to register callback props");return}let c=Q(s,n,r);Object.entries(c).forEach(([g,v])=>{t==null||t.on(g,v),t==null||t.on(`${m}:${g}`,v);});},qe=()=>{if(C)return Pe(m);if(!y){h("containerId is required when rendering inline");return}let c=document.getElementById(y);if(!c){h(`Could not find container with id ${y} while rendering footprint`);return}return ke(m,c)},ae=(c,g)=>{if(!g){W(m),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(C){let v=Ce(c,m);J(v,m);}else J(c,m);},ie=()=>{var g;if(!t){h("Footprint should be initialized in order to set up refs");return}if(s.kind!=="form"||!s.getRef)return;let c={save:()=>(t||h("Footprint should be initialized to call ref methods"),new Promise((v,w)=>{t==null||t.on(d,()=>{v();}),t==null||t.on(i,ze=>{w(ze);}),t==null||t.on(`${m}:${d}`,v),t==null||t.on(`${m}:${i}`,w),t==null||t.call(a);}))};(g=s.getRef)==null||g.call(s,c);};return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Ve(m));},props:s,isRendered:o,render:()=>f(void 0,null,function*(){if(o){G(D[s.kind],"Footprint component is already rendered");return}let c=qe();if(!c){G(D[s.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),o=!0,ae(c,!0);let g=yield Le(s);if(!g){h("Unable to get SDK args token.",!0);return}let v=Me(s,g||"");try{t=yield new ce({classListArray:[`footprint-${l}`,`footprint-${l}-loading`],container:c,name:`footprint-iframe-${m}`,url:v,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:s.authToken,initId:m,sdkUrl:Be(),sdkVersion:L||""}});}catch(w){h(`Initializing iframe failed with error ${w}`,!0);return}ae(c,!1),je(),t==null||t.on(p,()=>ie()),t==null||t.on(`${m}:${p}`,ie),s.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{be(m);}));}),destroy:()=>f(void 0,null,function*(){o&&(o=!1,yield ve(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},ne=Et;var b=e=>{let t=F(e);return JSON.stringify(t)},Ot=()=>{let e=Object.create(null);return {getOrCreate:d=>{let a=b(d.props),i=Object.values(e).find(p=>b(p.iframe.props)===a);return i?i.iframe:(e[a]={iframe:d,secondaryIframes:{}},d)},getOrCreateSecondary:(d,a)=>{let i=b(d.props),p=b(a.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:s}=e[i],l=Object.values(s).find(y=>b(y.props)===p);return l||(s[p]=a,a)},remove:d=>{let a=b(d.props),i=e[a];i&&(Object.keys(i.secondaryIframes).forEach(p=>{i.secondaryIframes[p].destroy();}),delete e[a]);},removeSecondary:(d,a)=>{let i=b(d.props),p=b(a.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:s}=e[i],l=s[p];l&&(l.destroy(),delete s[p]);}}},Ue=Ot;var St=()=>{let e=Ue();return {init:o=>{let n=ne(o),r=()=>f(void 0,null,function*(){e.remove(n),yield n.destroy();}),d=s=>f(void 0,null,function*(){e.removeSecondary(n,s),yield s.destroy();}),a=s=>f(void 0,null,function*(){let l=ne(s);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{d(l);}),l.render();}),i=()=>f(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(a),yield n.render();}),p={};return ee(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),u({render:i,destroy:r},p)}}},Dt=St(),re=Dt;var At=e=>{window.setTimeout(e,0);},It=e=>{if(typeof window=="undefined")return;let t=r=>{var i;let d=(i=window.footprintCallbacks)!=null?i:{};if(!k(d))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Se[r].forEach(p=>{if(!d[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),d},o=r=>{var m;let d=r.getAttribute("data-kind");j(d);let a=(m=r.getAttribute("data-variant"))!=null?m:A(d);H(d,a);let i=_e(),p=t(d),s=r.getAttribute("data-props")||"",l;try{l=JSON.parse(s);}catch(h){throw Error("Could not parse `data-props` for footprint.")}if(!k(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let y=B();r.setAttribute("id",y),e.init(u(u({kind:d,variant:a,appearance:i,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(d=>{o(d);});};document.addEventListener("DOMContentLoaded",()=>At(n));},Ne=It;var Ft="http://test",$e=e=>f(void 0,null,function*(){let t=yield fetch(`${Ft}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),xt=e=>f(void 0,null,function*(){if(!k(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 $e({email:t}))?!0:o?yield $e({phone_number:o}):!1}),He=xt;var pn=re;Ne(re);/*! Bundled license information:
var We=Object.defineProperty,Je=Object.defineProperties;var Xe=Object.getOwnPropertyDescriptors;var R=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var se=(e,t,o)=>t in e?We(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,u=(e,t)=>{for(var o in t||(t={}))de.call(t,o)&&se(e,o,t[o]);if(R)for(var o of R(t))pe.call(t,o)&&se(e,o,t[o]);return e},P=(e,t)=>Je(e,Xe(t));var le=(e,t)=>{var o={};for(var n in e)de.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&&pe.call(e,n)&&(o[n]=e[n]);return o};var f=(e,t,o)=>new Promise((n,r)=>{var d=p=>{try{i(o.next(p));}catch(s){r(s);}},a=p=>{try{i(o.throw(p));}catch(s){r(s);}},i=p=>p.done?n(p.value):Promise.resolve(p.value).then(d,a);i((o=o.apply(e,t)).next());});var E="application/x-postmate-v1+json",Ye=5,Ge=0,Ze=function(){return ++Ge};var Qe=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},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||!et[t.data.postmate])},tt=function(t,o){var n=typeof t[o]=="function"?t[o]():t[o];return O.Promise.resolve(n)},ot=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 d=((r||{}).data||{}).value||{},a=d.data,i=d.name;r.data.postmate==="emit"&&i in n.events&&n.events[i].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(d){var a=Ze(),i=function p(s){s.data.uid===a&&s.data.postmate==="reply"&&(r.parent.removeEventListener("message",p,!1),d(s.data.value));};r.parent.addEventListener("message",i,!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}(),nt=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 d=r.data,a=d.property,i=d.uid,p=d.data;if(r.data.postmate==="call"){a in n.model&&typeof n.model[a]=="function"&&n.model[a](p);return}tt(n.model,a).then(function(s){return r.source.postMessage({property:a,postmate:"reply",type:E,uid:i,value:s},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,d=o.model,a=o.url,i=o.name,p=i===void 0?"":i,s=o.allow,l=o.classListArray,y=l===void 0?[]:l;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=p||"",this.frame.classList.add.apply(this.frame.classList,y),s&&(this.frame.allow=s),r.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=d||{},this.sendHandshake(a)}var t=e.prototype;return t.sendHandshake=function(n){var r=this,d=Qe(n),a=0,i;return new e.Promise(function(p,s){var l=function m(h){return z(h,d)?h.data.postmate==="handshake-reply"?(clearInterval(i),r.parent.removeEventListener("message",m,!1),r.childOrigin=h.origin,p(new ot(r))):s("Failed handshake"):!1};r.parent.addEventListener("message",l,!1);var y=function(){a++,r.child.postMessage({postmate:"handshake",type:E,model:r.model},d),a===Ye&&clearInterval(i);},C=function(){y(),i=setInterval(y,500);};r.frame.attachEvent?r.frame.attachEvent("onload",C):r.frame.addEventListener("load",C),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,d){var a=function i(p){if(p.data.postmate){if(p.data.postmate==="handshake"){n.child.removeEventListener("message",i,!1),p.source.postMessage({postmate:"handshake-reply",type:E},p.origin),n.parentOrigin=p.origin;var s=p.data.model;return s&&Object.keys(s).forEach(function(l){n.model[l]=s[l];}),r(new nt(n))}return d("Handshake Reply Failed")}};n.child.addEventListener("message",a,!1);})},e}();var ce=O;var L="3.12.1";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 I=(a=>(a.auth="auth",a.canceled="canceled",a.clicked="clicked",a.closed="closed",a.completed="completed",a.relayToComponents="relayToComponents",a))(I||{}),_=(a=>(a.formSaveComplete="formSaveComplete",a.formSaveFailed="formSaveFailed",a.formSaved="formSaved",a.propsReceived="propsReceived",a.started="started",a.relayFromComponents="relayFromComponents",a))(_||{});var me="footprint-inline-container",fe="footprint-body-locked",ue="footprint-overlay",at="footprint-overlay-container",ye=me,he=ue,ge="footprint-loading-indicator",T=e=>`${at}-${e}`,S=(e,t)=>`${e}-${t}`,ve=e=>f(void 0,null,function*(){W(e),st(e),yield it(e);}),Pe=e=>{let t=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},it=e=>f(void 0,null,function*(){let t=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(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 d=S(he,e),a=document.getElementById(d);a&&(a.classList.add("footprint-overlay-fading"),yield new Promise(i=>{setTimeout(i,200);}),o.remove(),a.remove(),document.body.classList.remove(fe));}),ke=(e,t)=>{let o=S(ye,e),n=document.createElement("div");return n.classList.add(me),n.setAttribute("id",o),t.appendChild(n),n},st=e=>{let t=S(ye,e),o=document.getElementById(t);o&&o.remove();},W=e=>{let t=S(ge,e),o=document.getElementById(t);o&&o.remove();},J=(e,t)=>{let o=S(ge,t),n=dt(o);e.appendChild(n);},Ce=(e,t)=>{document.body.classList.add(fe);let o=document.createElement("div"),n=S(he,t);return o.setAttribute("id",n),o.classList.add(ue),e.appendChild(o),o},dt=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},Ve=e=>{let t=document.getElementById(T(e));t&&(t.style.opacity="1",t.style.display="block");},be=e=>{let t=document.getElementById(T(e));t&&(t.style.opacity="0",t.style.display="none");};var pt=()=>Math.random().toString(36).substring(2),B=pt;var M="https://api.onefootprint.com",U=L,N="footprint-js";var D={["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 lt=e=>e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`),X=e=>t=>{if(!t||typeof t!="object")return t;let o=Object.entries(t).map(([n,r])=>{let d;return Array.isArray(r)?d=r.map(X(e)):Object(r)===r?d=X(e)(r):d=r,[e(n),d]});return Object.fromEntries(o)},ct=X(lt),$=ct;var mt=(e,t,o,n)=>{let r={tenantDomain:n,sdkKind:e,sdkName:N,sdkVersion:U,logLevel:o,logMessage:t};try{fetch(`${M}/org/sdk_telemetry`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify($(r))});}catch(d){}},Y=mt;var G=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}Y(e,t,"warn",n);}return o},Ee=(e,t)=>{let o=`@onefootprint/footprint-js: ${t}`;{let n;try{n=window.location.href;}catch(r){}Y(e,t,"error",n);}return o};var Oe={["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"]:{}},Se={["auth"]:[],["form"]:[],["render"]:[],["update_login_methods"]:[],["verify"]:[],["components"]:[],["verify-button"]:[]};var De={["auth"]:["modal","drawer"],["components"]:["modal"],["form"]:["inline","modal","drawer"],["render"]:["inline"],["update_login_methods"]:["modal","drawer"],["verify"]:["modal","drawer"],["verify-button"]:["inline"]},ft=Object.values(I),ut=(...e)=>{},k=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Z=e=>k(e)&&Object.keys(e).length>0,yt=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},H=(e,t)=>{var r;if(!t)return;let o=(r=De[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=De[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(K);if(!t.includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${t.join(", ")}`)},Ae=e=>{if(e.kind==="verify-button"){let t=e,{kind:o,appearance:n,variant:r,dialogVariant:d,onClick:a,label:i,containerId:p}=t,s=le(t,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return P(u({},s),{variant:d,kind:"verify"})}};var Ie=(e,t)=>(Object.prototype.hasOwnProperty.call(e,t)&&typeof e[t]=="function"?e[t]:void 0)||ut,Q=(e,t,o)=>{var i;let{kind:n}=e,r=(i=Oe[n])!=null?i:{},d={},a=Ae(e);return Object.entries(r).forEach(([p,s])=>{let l=p;if(!ft.includes(l))return;let y=Ie(e,s),C=l==="closed"||l==="canceled",m=n==="verify-button"&&l==="clicked";d[l]=h=>{y(h),C&&(t==null||t()),m&&a&&(o==null||o(a));};}),d},F=e=>{let{kind:t,variant:o,containerId:n}=e,r=o||A(t);return j(t),H(t,o),yt(r,n),Z(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(u({},e),{variant:r})},V=e=>Z(e==null?void 0:e.bootstrapData)?{userData:e.bootstrapData}:Z(e==null?void 0:e.userData)?{userData:e.userData}:void 0;var Fe=e=>e==="auth",ht=e=>e==="verify",xe=e=>e==="update_login_methods",gt=e=>e==="components",ee=e=>e.kind==="components",te=e=>[Fe,ht,gt,xe].some(t=>t(e)),oe=e=>typeof e=="string"&&e.length>0,q=e=>Fe(e.kind)&&!!("updateLoginMethods"in e&&e.updateLoginMethods)&&!!e.authToken&&/tok_/.test(e.authToken),vt=e=>xe(e.kind)&&!!e.authToken&&/tok_/.test(e.authToken),x=e=>[q,vt].some(t=>t(e));var Pt=3,kt=!1,Ct=e=>x(e)?"update_auth_methods_v1":D[e.kind],Vt=e=>{let{kind:t}=e;if(t==="verify"||t==="components")return P(u({},V(e)),{publicKey:e.publicKey,authToken:e.authToken,options:e.options,l10n:e.l10n,isComponentsSdk:t==="components"});if(t==="update_login_methods")return P(u({},V(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n});if(t==="auth")return q(e)?P(u({},V(e)),{authToken:e.authToken,updateLoginMethods:e.updateLoginMethods,options:e.options,l10n:e.l10n}):e.authToken&&kt?P(u({},V(e)),{authToken:e.authToken,options:e.options,l10n:e.l10n}):P(u({},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 P(u({},V(e)),{publicKey:e.publicKey,options:e.options,authToken:e.authToken,label:e.label,l10n:e.l10n})},Re=(e,t)=>f(void 0,null,function*(){return fetch(`${M}/org/sdk_args`,{method:"POST",headers:{"x-fp-client-version":`${N} ${U} ${e.kind}`.trim(),"Content-Type":"application/json"},body:JSON.stringify(e)}).then(o=>{if(o.ok)return o.json();if(t>0)return Re(e,t-1)})}),bt=e=>f(void 0,null,function*(){let t=Vt(e);if(!t)return;let o=yield Re({data:$(t),kind:Ct(e)},Pt);return o?o.token:void 0}),Le=bt;var Ke=({fontSrc:e,variables:t={},rules:o={},variant:n}={})=>{let r=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0,d=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0;return {fontSrc:e,variables:r(),rules:d(),variant:n}},_e=()=>{let e=window.footprintAppearance;return !e||!k(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,theme:e.theme,variables:e.variables}};var Be=()=>{var e;return typeof window!="undefined"?((e=window.location)==null?void 0:e.href)||window.location.toString():""},Te=(e,t)=>{let{appearance:o,kind:n,l10n:r,variant:d}=e,{fontSrc:a,rules:i,variables:p}=Ke(o),s=new URLSearchParams;return p&&s.append("variables",p),i&&s.append("rules",i),a&&s.append("font_src",a),r!=null&&r.language&&s.append("lng",r.language),s.append("variant",d||A(n)),`${s.toString()}#${t}`},wt=(e,t)=>{let{kind:o}=e,n;switch(o){case"verify":case"components":n="https://id.onefootprint.com";break;case"auth":n=x(e)?"https://auth.onefootprint.com/user":"https://auth.onefootprint.com";break;default:n="https://components.onefootprint.com";}if(oe(n))return te(o)?`${n}?${Te(e,t)}`.trim():`${n}/${o}?${Te(e,t)}`.trim();throw new Error(`${o}_URL environment variable is not defined.`)},Me=wt;var Et=e=>{let t=null,o=!1,n,r,{formSaveComplete:d,formSaved:a,formSaveFailed:i,started:p}=_,s=F(e),{variant:l,containerId:y}=s,C=l==="modal"||l==="drawer",m=B(),h=(c,g)=>{var w;let v=Ee(D[s.kind],c);(w=s.onError)==null||w.call(s,v),o&&g&&(n(),o=!1);},je=()=>{if(!t){h("Footprint should be initialized in order to register callback props");return}let c=Q(s,n,r);Object.entries(c).forEach(([g,v])=>{t==null||t.on(g,v),t==null||t.on(`${m}:${g}`,v);});},qe=()=>{if(C)return Pe(m);if(!y){h("containerId is required when rendering inline");return}let c=document.getElementById(y);if(!c){h(`Could not find container with id ${y} while rendering footprint`);return}return ke(m,c)},ae=(c,g)=>{if(!g){W(m),t==null||t.frame.classList.remove(`footprint-${l}-loading`),t==null||t.frame.classList.add(`footprint-${l}-loaded`);return}if(C){let v=Ce(c,m);J(v,m);}else J(c,m);},ie=()=>{var g;if(!t){h("Footprint should be initialized in order to set up refs");return}if(s.kind!=="form"||!s.getRef)return;let c={save:()=>(t||h("Footprint should be initialized to call ref methods"),new Promise((v,w)=>{t==null||t.on(d,()=>{v();}),t==null||t.on(i,ze=>{w(ze);}),t==null||t.on(`${m}:${d}`,v),t==null||t.on(`${m}:${i}`,w),t==null||t.call(a);}))};(g=s.getRef)==null||g.call(s,c);};return {relayFromComponents:()=>{t&&(t.call("relayFromComponents"),Ve(m));},props:s,isRendered:o,render:()=>f(void 0,null,function*(){if(o){G(D[s.kind],"Footprint component is already rendered");return}let c=qe();if(!c){G(D[s.kind],"Unable to create container for Footprint component");return}c.hasChildNodes()&&(c.innerHTML=""),o=!0,ae(c,!0);let g=yield Le(s);if(!g){h("Unable to get SDK args token.",!0);return}let v=Me(s,g||"");try{t=yield new ce({classListArray:[`footprint-${l}`,`footprint-${l}-loading`],container:c,name:`footprint-iframe-${m}`,url:v,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;",model:{authToken:s.authToken,initId:m,sdkUrl:Be(),sdkVersion:L||""}});}catch(w){h(`Initializing iframe failed with error ${w}`,!0);return}ae(c,!1),je(),t==null||t.on(p,()=>ie()),t==null||t.on(`${m}:${p}`,ie),s.kind==="components"&&(t==null||t.on(`${m}:${"relayToComponents"}`,()=>{be(m);}));}),destroy:()=>f(void 0,null,function*(){o&&(o=!1,yield ve(m),t&&(t.destroy(),t=null));}),registerOnDestroy:c=>{!c||typeof c!="function"||(n=c);},registerOnRenderSecondary:c=>{!c||typeof c!="function"||(r=c);}}},ne=Et;var b=e=>{let t=F(e);return JSON.stringify(t)},Ot=()=>{let e=Object.create(null);return {getOrCreate:d=>{let a=b(d.props),i=Object.values(e).find(p=>b(p.iframe.props)===a);return i?i.iframe:(e[a]={iframe:d,secondaryIframes:{}},d)},getOrCreateSecondary:(d,a)=>{let i=b(d.props),p=b(a.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:s}=e[i],l=Object.values(s).find(y=>b(y.props)===p);return l||(s[p]=a,a)},remove:d=>{let a=b(d.props),i=e[a];i&&(Object.keys(i.secondaryIframes).forEach(p=>{i.secondaryIframes[p].destroy();}),delete e[a]);},removeSecondary:(d,a)=>{let i=b(d.props),p=b(a.props);if(!e[i])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:s}=e[i],l=s[p];l&&(l.destroy(),delete s[p]);}}},Ue=Ot;var St=()=>{let e=Ue();return {init:o=>{let n=ne(o),r=()=>f(void 0,null,function*(){e.remove(n),yield n.destroy();}),d=s=>f(void 0,null,function*(){e.removeSecondary(n,s),yield s.destroy();}),a=s=>f(void 0,null,function*(){let l=ne(s);l=e.getOrCreateSecondary(n,l),l.registerOnDestroy(()=>{d(l);}),l.render();}),i=()=>f(void 0,null,function*(){n=e.getOrCreate(n),n.registerOnDestroy(r),n.registerOnRenderSecondary(a),yield n.render();}),p={};return ee(o)&&(p={relayFromComponents:()=>{n.relayFromComponents();}}),u({render:i,destroy:r},p)}}},Dt=St(),re=Dt;var At=e=>{window.setTimeout(e,0);},It=e=>{if(typeof window=="undefined")return;let t=r=>{var i;let d=(i=window.footprintCallbacks)!=null?i:{};if(!k(d))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return Se[r].forEach(p=>{if(!d[p])throw Error(`Callback '${p}' must be defined in window.footprintCallbacks`)}),d},o=r=>{var m;let d=r.getAttribute("data-kind");j(d);let a=(m=r.getAttribute("data-variant"))!=null?m:A(d);H(d,a);let i=_e(),p=t(d),s=r.getAttribute("data-props")||"",l;try{l=JSON.parse(s);}catch(h){throw Error("Could not parse `data-props` for footprint.")}if(!k(l))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let y=B();r.setAttribute("id",y),e.init(u(u({kind:d,variant:a,appearance:i,containerId:r.id},p),l)).render();},n=()=>{let r=document.querySelectorAll("[data-footprint]");r.length&&r.forEach(d=>{o(d);});};document.addEventListener("DOMContentLoaded",()=>At(n));},Ne=It;var Ft="http://test",$e=e=>f(void 0,null,function*(){let t=yield fetch(`${Ft}/hosted/identify/lite`,{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),xt=e=>f(void 0,null,function*(){if(!k(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 $e({email:t}))?!0:o?yield $e({phone_number:o}):!1}),He=xt;var pn=re;Ne(re);/*! Bundled license information:

@@ -6,0 +6,0 @@ @onefootprint/postmate/build/postmate.es.js:

@@ -5,3 +5,3 @@ {

"type": "module",
"version": "3.12.0",
"version": "3.12.1",
"main": "./dist/footprint-js.cjs",

@@ -8,0 +8,0 @@ "module": "./dist/footprint-js.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc