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

@onefootprint/footprint-js

Package Overview
Dependencies
Maintainers
3
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.10.0 to 3.11.0

43

dist/footprint-js.d.ts

@@ -160,2 +160,4 @@ import * as CSS from 'csstype';

'id.visa_expiration_date': string;
} & {
[key: `custom.${string}`]: string;
}>;

@@ -169,2 +171,3 @@

Verify = "verify",
Components = "components",
VerifyButton = "verify-button"

@@ -183,10 +186,13 @@ }

type Variant = 'modal' | 'drawer' | 'inline';
type AdditionalComponentsSdkFunctionality = {
relayFromComponents?: () => void;
};
type Component = {
destroy: () => void;
render: () => Promise<void>;
};
} & AdditionalComponentsSdkFunctionality;
type Footprint = {
init: (props: Props) => Component;
};
type Props = AuthProps | FormProps | RenderProps | UpdateLoginMethodsProps | VerifyButtonProps | VerifyProps;
type Props = AuthProps | FormProps | RenderProps | UpdateLoginMethodsProps | VerifyButtonProps | VerifyProps | ComponentsSdkProps;
type PropsBase = {

@@ -210,4 +216,4 @@ readonly appearance?: Appearance;

type VerifyVariant = 'modal' | 'drawer';
type VerifyPropsBase = PropsBase & {
readonly onAuth?: (authToken: string) => void;
type VerifyPropsBase<TAuth> = PropsBase & {
readonly onAuth?: (validationToken: string) => void;
readonly onCancel?: () => void;

@@ -218,11 +224,19 @@ readonly onClose?: () => void;

readonly userData?: FootprintUserData;
} & (VerifyAuthToken | VerifyPublicKey);
type VerifyProps = VerifyPropsBase & {
} & TAuth;
type VerifyProps = VerifyPropsBase<VerifyAuthToken | VerifyPublicKey> & {
readonly kind: ComponentKind.Verify;
readonly variant?: VerifyVariant;
};
type VerifyDataProps = Pick<VerifyProps, VerifyDataKeys>;
type VerifyDataKeys = 'publicKey' | 'userData' | 'options' | 'authToken' | 'l10n';
type VerifyDataProps = Pick<VerifyProps, VerifyDataKeys> & {
isComponentsSdk?: boolean;
};
/** Components SDK. Just a subset of Verify */
type ComponentsSdkProps = VerifyPropsBase<VerifyPublicKey> & {
readonly onRelayToComponents?: (authToken: string) => void;
readonly kind: ComponentKind.Components;
readonly variant?: VerifyVariant;
};
/** verify-button */
type VerifyButtonProps = VerifyPropsBase & {
type VerifyButtonProps = VerifyPropsBase<VerifyAuthToken | VerifyPublicKey> & {
readonly containerId: string;

@@ -308,3 +322,4 @@ readonly dialogVariant?: VerifyVariant;

closed = "closed",
completed = "completed"
completed = "completed",
relayToComponents = "relayToComponents"
}

@@ -316,11 +331,9 @@ declare enum PrivateEvent {

propsReceived = "propsReceived",
started = "started"
started = "started",
relayFromComponents = "relayFromComponents"
}
type IdentifyRequest = {
identifier: {
email: string;
} | {
phone_number: string;
};
email?: string;
phone_number?: string;
};

@@ -327,0 +340,0 @@

@@ -1,5 +0,5 @@

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

@@ -16,7 +16,7 @@ @onefootprint/postmate/build/postmate.es.js:

exports.FootprintComponentKind = R;
exports.FootprintPrivateEvent = x;
exports.FootprintPublicEvent = D;
exports.default = Xo;
exports.identifyFootprintUser = Me;
exports.FootprintComponentKind = F;
exports.FootprintPrivateEvent = L;
exports.FootprintPublicEvent = O;
exports.default = tn;
exports.identifyFootprintUser = Ne;

@@ -23,0 +23,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

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

"type": "module",
"version": "3.10.0",
"version": "3.11.0",
"main": "./dist/footprint-js.cjs",

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

Sorry, the diff of this file is not supported yet

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