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.8.3 to 3.9.0

10

dist/footprint-js.d.ts

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

type FormDataProps = Pick<FormProps, 'authToken' | 'options' | 'title' | 'l10n'>;
type AuthProps = PropsBase & {
type AuthPropsBase = PropsBase & {
kind: ComponentKind.Auth;

@@ -265,7 +265,11 @@ onCancel?: () => void;

options?: Pick<Options, 'showLogo'>;
publicKey: string;
userData?: Pick<FootprintUserData, 'id.email' | 'id.phone_number'>;
variant?: 'modal' | 'drawer';
};
type AuthDataProps = Pick<AuthProps, 'publicKey' | 'userData' | 'options' | 'l10n'>;
type AuthProps = AuthPropsBase & {
publicKey?: string;
authToken?: string;
updateLoginMethods?: true;
};
type AuthDataProps = Pick<AuthProps, 'authToken' | 'updateLoginMethods' | 'publicKey' | 'userData' | 'l10n' | 'options'>;

@@ -272,0 +276,0 @@ declare const footprint: Footprint;

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

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

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

exports.FootprintComponentKind = R;
exports.FootprintPrivateEvent = D;
exports.FootprintPublicEvent = F;
exports.default = Ln;
exports.identifyFootprintUser = Fe;
exports.FootprintComponentKind = A;
exports.FootprintPrivateEvent = x;
exports.FootprintPublicEvent = D;
exports.default = qn;
exports.identifyFootprintUser = Ke;

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

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

"type": "module",
"version": "3.8.3",
"version": "3.9.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

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