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.0 to 3.8.1

1

dist/footprint-js.d.ts

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

formSaveComplete = "formSaveComplete",
formSaveFailed = "formSaveFailed",
formSaved = "formSaved",

@@ -278,0 +279,0 @@ propsReceived = "propsReceived",

6

dist/footprint-js.js

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

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

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

exports.FootprintComponentKind = I;
exports.FootprintPrivateEvent = z;
exports.FootprintPublicEvent = R;
exports.default = dr;
exports.identifyFootprintUser = ve;
exports.FootprintComponentKind = R;
exports.FootprintPrivateEvent = W;
exports.FootprintPublicEvent = F;
exports.default = lr;
exports.identifyFootprintUser = Ce;

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

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

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc