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.1 to 3.8.2

1

dist/footprint-js.d.ts

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

hideButtons?: boolean;
hideCancelButton?: boolean;
hideFootprintLogo?: boolean;

@@ -238,0 +239,0 @@ };

2

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

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

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

"type": "module",
"version": "3.8.1",
"version": "3.8.2",
"main": "./dist/footprint-js.cjs",

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

Sorry, the diff of this file is not supported yet

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