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.6.0 to 3.7.0

55

dist/footprint-js.d.ts

@@ -155,15 +155,15 @@ import * as CSS from 'csstype';

'id.nationality': string;
'id.usLegalStatus': string;
'id.us_legal_status': string;
'id.citizenships': string[];
'id.visaKind': string;
'id.visaExpirationDate': string;
'id.visa_kind': string;
'id.visa_expiration_date': string;
}>;
interface Footprint {
type Footprint = {
init: (props: Props) => Component;
}
interface Component {
};
type Component = {
render: () => Promise<void>;
destroy: () => void;
}
};
type SupportedLocale = 'en-US' | 'es-MX';

@@ -181,3 +181,3 @@ type L10n = {

type Variant = 'modal' | 'drawer' | 'inline';
interface PropsBase {
type PropsBase = {
kind: ComponentKind;

@@ -188,3 +188,3 @@ appearance?: Appearance;

l10n?: L10n;
}
};
type VerifyOptions = {

@@ -194,6 +194,11 @@ showCompletionPage?: boolean;

};
interface VerifyProps extends PropsBase {
kind: ComponentKind.Verify;
variant?: 'modal' | 'drawer';
type VerifyAuthToken = {
authToken: string;
publicKey?: never;
};
type VerifyPublicKey = {
publicKey: string;
authToken?: never;
};
type VerifySharedProps = (VerifyAuthToken | VerifyPublicKey) & {
userData?: FootprintUserData;

@@ -204,4 +209,8 @@ options?: VerifyOptions;

onClose?: () => void;
}
interface VerifyButtonProps extends PropsBase {
};
type VerifyProps = PropsBase & VerifySharedProps & {
kind: ComponentKind.Verify;
variant?: 'modal' | 'drawer';
};
type VerifyButtonProps = PropsBase & Partial<VerifySharedProps> & {
kind: ComponentKind.VerifyButton;

@@ -213,10 +222,4 @@ variant: 'inline';

label?: string;
publicKey?: string;
userData?: FootprintUserData;
options?: VerifyOptions;
onComplete?: (validationToken: string) => void;
onCancel?: () => void;
onClose?: () => void;
}
interface RenderProps extends PropsBase {
};
type RenderProps = PropsBase & {
kind: ComponentKind.Render;

@@ -231,3 +234,3 @@ authToken: string;

containerId: string;
}
};
type FormOptions = {

@@ -240,3 +243,3 @@ hideFootprintLogo?: boolean;

};
interface FormProps extends PropsBase {
type FormProps = PropsBase & {
kind: ComponentKind.Form;

@@ -252,3 +255,3 @@ authToken: string;

onClose?: () => void;
}
};

@@ -280,2 +283,2 @@ declare const footprint: Footprint;

export { Footprint, Appearance as FootprintAppearance, AppearanceRules as FootprintAppearanceRules, AppearanceTheme as FootprintAppearanceTheme, AppearanceVariables as FootprintAppearanceVariables, Component as FootprintComponent, ComponentKind as FootprintComponentKind, FormOptions as FootprintFormOptions, FormProps as FootprintFormProps, FormRef as FootprintFormRef, IdentifyRequest as FootprintIdentifyRequest, PrivateEvent as FootprintPrivateEvent, Props as FootprintProps, PropsBase as FootprintPropsBase, PublicEvent as FootprintPublicEvent, RenderProps as FootprintRenderProps, FootprintUserData, Variant as FootprintVariant, VerifyButtonProps as FootprintVerifyButtonProps, VerifyOptions as FootprintVerifyOptions, VerifyProps as FootprintVerifyProps, L10n, SupportedLocale, footprint as default, identifyUser as identifyFootprintUser };
export { Footprint, Appearance as FootprintAppearance, AppearanceRules as FootprintAppearanceRules, AppearanceTheme as FootprintAppearanceTheme, AppearanceVariables as FootprintAppearanceVariables, Component as FootprintComponent, ComponentKind as FootprintComponentKind, FormOptions as FootprintFormOptions, FormProps as FootprintFormProps, FormRef as FootprintFormRef, IdentifyRequest as FootprintIdentifyRequest, PrivateEvent as FootprintPrivateEvent, Props as FootprintProps, PropsBase as FootprintPropsBase, PublicEvent as FootprintPublicEvent, RenderProps as FootprintRenderProps, FootprintUserData, Variant as FootprintVariant, VerifyAuthToken as FootprintVerifyAuthToken, VerifyButtonProps as FootprintVerifyButtonProps, VerifyOptions as FootprintVerifyOptions, VerifyProps as FootprintVerifyProps, VerifyPublicKey as FootprintVerifyPublicKey, L10n, SupportedLocale, footprint as default, identifyUser as identifyFootprintUser };

@@ -1,2 +0,2 @@

var ve=Object.defineProperty,ge=Object.defineProperties;var he=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var $=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var U=(e,t,r)=>t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w=(e,t)=>{for(var r in t||(t={}))$.call(t,r)&&U(e,r,t[r]);if(V)for(var r of V(t))j.call(t,r)&&U(e,r,t[r]);return e},x=(e,t)=>ge(e,he(t));var F=(e,t)=>{var r={};for(var n in e)$.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&V)for(var n of V(e))t.indexOf(n)<0&&j.call(e,n)&&(r[n]=e[n]);return r};var f=(e,t,r)=>new Promise((n,o)=>{var a=i=>{try{p(r.next(i));}catch(s){o(s);}},d=i=>{try{p(r.throw(i));}catch(s){o(s);}},p=i=>i.done?n(i.value):Promise.resolve(i.value).then(a,d);p((r=r.apply(e,t)).next());});var E="application/x-postmate-v1+json",Pe=5,Ee=0,Ce=function(){return ++Ee};var we=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},S=function(t,r){return !(typeof r=="string"&&t.origin!==r||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==E||!Ie[t.data.postmate])},be=function(t,r){var n=typeof t[r]=="function"?t[r]():t[r];return C.Promise.resolve(n)},Oe=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(!S(o,n.childOrigin))return !1;var a=((o||{}).data||{}).value||{},d=a.data,p=a.name;o.data.postmate==="emit"&&p in n.events&&n.events[p].forEach(function(i){i.call(n,d);});},this.parent.addEventListener("message",this.listener,!1);}var t=e.prototype;return t.get=function(n){var o=this;return new C.Promise(function(a){var d=Ce(),p=function i(s){s.data.uid===d&&s.data.postmate==="reply"&&(o.parent.removeEventListener("message",i,!1),a(s.data.value));};o.parent.addEventListener("message",p,!1),o.child.postMessage({postmate:"request",type:E,property:n,uid:d},o.childOrigin);})},t.call=function(n,o){this.child.postMessage({postmate:"call",type:E,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}(),Ve=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(S(o,n.parentOrigin)){var a=o.data,d=a.property,p=a.uid,i=a.data;if(o.data.postmate==="call"){d in n.model&&typeof n.model[d]=="function"&&n.model[d](i);return}be(n.model,d).then(function(s){return o.source.postMessage({property:d,postmate:"reply",type:E,uid:p,value:s},o.origin)});}});}var t=e.prototype;return t.emit=function(n,o){this.parent.postMessage({postmate:"emit",type:E,value:{name:n,data:o}},this.parentOrigin);},e}(),C=function(){function e(r){var n=r.container,o=n===void 0?typeof o!="undefined"?o:document.body:n,a=r.model,d=r.url,p=r.name,i=p===void 0?"":p,s=r.allow,c=r.classListArray,m=c===void 0?[]:c;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=i||"",this.frame.classList.add.apply(this.frame.classList,m),s&&(this.frame.allow=s),o.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(d)}var t=e.prototype;return t.sendHandshake=function(n){var o=this,a=we(n),d=0,p;return new e.Promise(function(i,s){var c=function v(g){return S(g,a)?g.data.postmate==="handshake-reply"?(clearInterval(p),o.parent.removeEventListener("message",v,!1),o.childOrigin=g.origin,i(new Oe(o))):s("Failed handshake"):!1};o.parent.addEventListener("message",c,!1);var m=function(){d++,o.child.postMessage({postmate:"handshake",type:E,model:o.model},a),d===Pe&&clearInterval(p);},y=function(){m(),p=setInterval(m,500);};o.frame.attachEvent?o.frame.attachEvent("onload",y):o.frame.addEventListener("load",y),o.frame.src=n;})},e}();C.debug=!1;C.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();C.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 C.Promise(function(o,a){var d=function p(i){if(i.data.postmate){if(i.data.postmate==="handshake"){n.child.removeEventListener("message",p,!1),i.source.postMessage({postmate:"handshake-reply",type:E},i.origin),n.parentOrigin=i.origin;var s=i.data.model;return s&&Object.keys(s).forEach(function(c){n.model[c]=s[c];}),o(new Ve(n))}return a("Handshake Reply Failed")}};n.child.addEventListener("message",d,!1);})},e}();var q=C;var b=(o=>(o.Verify="verify",o.Form="form",o.Render="render",o.VerifyButton="verify-button",o))(b||{});var R=(o=>(o.closed="closed",o.canceled="canceled",o.completed="completed",o.clicked="clicked",o))(R||{}),H=(o=>(o.propsReceived="propsReceived",o.started="started",o.formSaved="formSaved",o.formSaveComplete="formSaveComplete",o))(H||{});var z="footprint-inline-container",J="footprint-body-locked",X="footprint-overlay",Y="footprint-overlay-container",W=z,G=X,Z="footprint-loading-indicator",h=(e,t)=>`${e}-${t}`,Q=e=>f(void 0,null,function*(){A(e),ke(e),yield Re(e);}),ee=e=>{let t=h(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},Re=e=>f(void 0,null,function*(){let t=h(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(p=>{setTimeout(p,300);}));let o=r.querySelector("iframe.footprint-modal");o&&(o==null||o.classList.add("footprint-modal-closing"),yield new Promise(p=>{setTimeout(p,100);}));let a=h(G,e),d=document.getElementById(a);d&&(d.classList.add("footprint-overlay-fading"),yield new Promise(p=>{setTimeout(p,200);}),r.remove(),d.remove(),document.body.classList.remove(J));}),te=(e,t)=>{let r=h(W,e),n=document.createElement("div");return n.classList.add(z),n.setAttribute("id",r),t.appendChild(n),n},ke=e=>{let t=h(W,e),r=document.getElementById(t);r&&r.remove();},A=e=>{let t=h(Z,e),r=document.getElementById(t);r&&r.remove();},N=(e,t)=>{let r=h(Z,t),n=Le(r);e.appendChild(n);},re=(e,t)=>{document.body.classList.add(J);let r=document.createElement("div"),n=h(G,t);return r.setAttribute("id",n),r.classList.add(X),e.appendChild(r),r},Le=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 xe=()=>`${Math.floor(Math.random()*1e3)}`,k=xe;var _={["form"]:{["closed"]:"onClose",["canceled"]:"onCancel",["completed"]:"onComplete"},["verify"]:{["closed"]:"onClose",["canceled"]:"onCancel",["completed"]:"onComplete"},["verify-button"]:{["clicked"]:"onClick",["closed"]:"onClose",["canceled"]:"onCancel",["completed"]:"onComplete"},["render"]:{}},ne={["form"]:[],["verify"]:[],["render"]:[],["verify-button"]:[]};var Fe={["form"]:["getRef"],["verify"]:[],["verify-button"]:[],["render"]:[]},oe=Fe;var ae={["verify"]:["modal","drawer"],["verify-button"]:["inline"],["form"]:["inline","modal","drawer"],["render"]:["inline"]},D=(e,t)=>{var o;if(!t)return;let r=(o=ae[e])!=null?o:[];if(!r.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${r.join(", ")}`)},I=e=>{var r;let t=(r=ae[e])!=null?r:[];if(!t.length)throw new Error(`Invalid kind: ${e}`);return t[0]},B=e=>{if(!e)throw new Error("Kind is required");if(!Object.values(b).includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${Object.values(b).join(", ")}}`)},Se=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},Ae=e=>{let{kind:t}=e;if(t==="verify-button"){let r=e,{kind:n,appearance:o,variant:a,dialogVariant:d,onClick:p,label:i,containerId:s}=r,c=F(r,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return x(w({},c),{variant:d,kind:"verify"})}},Ne=e=>{var n;let{kind:t}=e;return (n=oe[t])!=null?n:[]},ie=(e,t,r)=>{var d;let{kind:n}=e,o=(d=_[n])!=null?d:{},a={};return Object.entries(o).forEach(([p,i])=>{let s=p;if(!Object.values(R).includes(s))return;let c=e[i];(!c||typeof c!="function")&&(c=()=>{});let m=s==="closed"||s==="canceled",y=n==="verify-button"&&s==="clicked";a[s]=v=>{c(v),m&&(t==null||t());let g=Ae(e);y&&g&&(r==null||r(g));};}),a},se=e=>{var m;let c=e,{kind:t,appearance:r,containerId:n}=c,o=F(c,["kind","appearance","containerId"]),a=(m=_[t])!=null?m:{},d=Object.values(a),p=Ne(e),i=Object.values(p);return Object.fromEntries(Object.entries(o).filter(([y])=>!d.includes(y)&&!i.includes(y)))},L=e=>{let{kind:t,variant:r,containerId:n}=e;B(t),D(t,r);let o=r||I(t);return Se(o,n),x(w({},e),{variant:o})};var _e=e=>typeof e=="object"&&!!e,K=({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}},de=()=>{let e=window.footprintAppearance;return !e||!_e(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,theme:e.theme,variables:e.variables}};var De=e=>{let{kind:t}=e;return t==="verify"?Be(e):Ke(e)},Be=e=>{let{appearance:t,publicKey:r,variant:n,kind:o}=e,{fontSrc:a,rules:d,variables:p}=K(t),i="https://id.onefootprint.com",s=new URLSearchParams;r&&s.append("public_key",r),p&&s.append("variables",p),d&&s.append("rules",d),a&&s.append("font_src",a),s.append("variant",n!=null?n:I(o));let c=s.toString();return `${i}?${c}`},Ke=e=>{let{appearance:t,kind:r,variant:n}=e,{fontSrc:o,rules:a,variables:d}=K(t),p="https://components.onefootprint.com",i=new URLSearchParams;d&&i.append("variables",d),a&&i.append("rules",a),o&&i.append("font_src",o),i.append("variant",n!=null?n:I(r));let s=i.toString();return `${p}/${r}?${s}`},pe=De;var Me=e=>{let t=null,r=!1,n=L(e),{variant:o,containerId:a}=n,d=o==="modal"||o==="drawer",p,i,s=k(),c=()=>{if(!t)throw new Error("Footprint should be initialized in order to listen events");let l=ie(n,p,i);Object.entries(l).forEach(([u,O])=>{t==null||t.on(u,O);});},m=()=>{if(!t)throw new Error("Footprint should be initialized in order to set up refs");let{kind:l}=n;if(l!=="form")return;let{getRef:u}=n;if(!u)return;u({save:()=>{if(!t)throw new Error("Footprint should be initialized to call ref methods");return new Promise(ye=>{t==null||t.call("formSaved"),t==null||t.on("formSaveComplete",()=>{ye();});})}});},y=()=>{if(!t)throw new Error("Footprint should be initialized in order to receive props");let l=se(n);t.call("propsReceived",l);},v=()=>{if(d)return ee(s);if(!a)throw new Error("containerId is required when rendering inline");let l=document.getElementById(a);if(!l)throw new Error(`Could not find container with id ${a} while rendering footprint`);return te(s,l)},g=(l,u)=>{if(!u){A(s),t==null||t.frame.classList.remove(`footprint-${o}-loading`),t==null||t.frame.classList.add(`footprint-${o}-loaded`);return}if(d){let O=re(l,s);N(O,s);}else N(l,s);};return {props:n,isRendered:r,render:()=>f(void 0,null,function*(){if(r)return;let l=v();if(!l)return;l.hasChildNodes()&&(l.innerHTML="");let u=pe(n);r=!0,g(l,!0),t=yield new q({classListArray:[`footprint-${o}`,`footprint-${o}-loading`],container:l,name:`footprint-iframe-${s}`,url:u,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;"}),g(l,!1),c(),t.on("started",()=>{y(),m();});}),destroy:()=>f(void 0,null,function*(){r&&(r=!1,yield Q(s),t&&(t.destroy(),t=null));}),registerEvent:(l,u)=>{l==="renderSecondary"?i=u:l==="destroy"&&(p=u);}}},M=Me;var P=e=>{let t=L(e);return JSON.stringify(t)},Te=()=>{let e={};return {getOrCreate:a=>{let d=P(a.props),p=Object.values(e).find(i=>P(i.iframe.props)===d);return p?p.iframe:(e[d]={iframe:a,secondaryIframes:{}},a)},remove:a=>{let d=P(a.props),p=e[d];p&&(Object.keys(p.secondaryIframes).forEach(i=>{p.secondaryIframes[i].destroy();}),delete e[d]);},getOrCreateSecondary:(a,d)=>{let p=P(a.props),i=P(d.props);if(!e[p])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:s}=e[p],c=Object.values(s).find(m=>P(m.props)===i);return c||(s[i]=d,d)},removeSecondary:(a,d)=>{let p=P(a.props),i=P(d.props);if(!e[p])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:s}=e[p],c=s[i];c&&(c.destroy(),delete s[i]);}}},ce=Te;var Ue=()=>{let e=ce();return {init:r=>{let n=M(r),o=()=>f(void 0,null,function*(){e.remove(n),yield n.destroy();}),a=i=>f(void 0,null,function*(){e.removeSecondary(n,i),yield i.destroy();}),d=i=>f(void 0,null,function*(){let s=M(i);s=e.getOrCreateSecondary(n,s),s.registerEvent("destroy",()=>{a(s);}),s.render();});return {render:()=>f(void 0,null,function*(){n=e.getOrCreate(n),n.registerEvent("destroy",o),n.registerEvent("renderSecondary",d),yield n.render();}),destroy:o}}}},$e=Ue(),T=$e;var je=e=>{window.setTimeout(e,0);},le=e=>typeof e=="object"&&!!e,qe=e=>{if(typeof window=="undefined")return;let t=o=>{var p;let a=(p=window.footprintCallbacks)!=null?p:{};if(!le(a))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return ne[o].forEach(i=>{if(!a[i])throw Error(`Callback '${i}' must be defined in window.footprintCallbacks`)}),a},r=o=>{var v;let a=o.getAttribute("data-kind");B(a);let d=(v=o.getAttribute("data-variant"))!=null?v:I(a);D(a,d);let p=de(),i=t(a),s=o.getAttribute("data-props")||"",c;try{c=JSON.parse(s);}catch(g){throw Error("Could not parse `data-props` for footprint.")}if(!le(c))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let m=k();o.setAttribute("id",m),e.init(w(w({kind:a,variant:d,appearance:p,containerId:o.id},i),c)).render();},n=()=>{let o=document.querySelectorAll("[data-footprint]");o.length&&o.forEach(a=>{r(a);});};document.addEventListener("DOMContentLoaded",()=>je(n));},me=qe;var fe=e=>f(void 0,null,function*(){let t=yield fetch("https://api.onefootprint.com/hosted/identify",{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),He=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 fe({identifier:{email:t}}))?!0:r?yield fe({identifier:{phone_number:r}}):!1}),ue=He;var $t=T;me(T);/*! Bundled license information:
var ve=Object.defineProperty,ge=Object.defineProperties;var he=Object.getOwnPropertyDescriptors;var O=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var $=(e,t,r)=>t in e?ve(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,w=(e,t)=>{for(var r in t||(t={}))U.call(t,r)&&$(e,r,t[r]);if(O)for(var r of O(t))j.call(t,r)&&$(e,r,t[r]);return e},S=(e,t)=>ge(e,he(t));var L=(e,t)=>{var r={};for(var n in e)U.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&&j.call(e,n)&&(r[n]=e[n]);return r};var f=(e,t,r)=>new Promise((n,o)=>{var i=a=>{try{d(r.next(a));}catch(p){o(p);}},s=a=>{try{d(r.throw(a));}catch(p){o(p);}},d=a=>a.done?n(a.value):Promise.resolve(a.value).then(i,s);d((r=r.apply(e,t)).next());});var E="application/x-postmate-v1+json",Pe=5,Ee=0,Ce=function(){return ++Ee};var we=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!==E||!Ie[t.data.postmate])},be=function(t,r){var n=typeof t[r]=="function"?t[r]():t[r];return C.Promise.resolve(n)},Ve=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 i=((o||{}).data||{}).value||{},s=i.data,d=i.name;o.data.postmate==="emit"&&d in n.events&&n.events[d].forEach(function(a){a.call(n,s);});},this.parent.addEventListener("message",this.listener,!1);}var t=e.prototype;return t.get=function(n){var o=this;return new C.Promise(function(i){var s=Ce(),d=function a(p){p.data.uid===s&&p.data.postmate==="reply"&&(o.parent.removeEventListener("message",a,!1),i(p.data.value));};o.parent.addEventListener("message",d,!1),o.child.postMessage({postmate:"request",type:E,property:n,uid:s},o.childOrigin);})},t.call=function(n,o){this.child.postMessage({postmate:"call",type:E,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}(),Oe=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 i=o.data,s=i.property,d=i.uid,a=i.data;if(o.data.postmate==="call"){s in n.model&&typeof n.model[s]=="function"&&n.model[s](a);return}be(n.model,s).then(function(p){return o.source.postMessage({property:s,postmate:"reply",type:E,uid:d,value:p},o.origin)});}});}var t=e.prototype;return t.emit=function(n,o){this.parent.postMessage({postmate:"emit",type:E,value:{name:n,data:o}},this.parentOrigin);},e}(),C=function(){function e(r){var n=r.container,o=n===void 0?typeof o!="undefined"?o:document.body:n,i=r.model,s=r.url,d=r.name,a=d===void 0?"":d,p=r.allow,c=r.classListArray,m=c===void 0?[]:c;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=a||"",this.frame.classList.add.apply(this.frame.classList,m),p&&(this.frame.allow=p),o.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(s)}var t=e.prototype;return t.sendHandshake=function(n){var o=this,i=we(n),s=0,d;return new e.Promise(function(a,p){var c=function v(g){return x(g,i)?g.data.postmate==="handshake-reply"?(clearInterval(d),o.parent.removeEventListener("message",v,!1),o.childOrigin=g.origin,a(new Ve(o))):p("Failed handshake"):!1};o.parent.addEventListener("message",c,!1);var m=function(){s++,o.child.postMessage({postmate:"handshake",type:E,model:o.model},i),s===Pe&&clearInterval(d);},y=function(){m(),d=setInterval(m,500);};o.frame.attachEvent?o.frame.attachEvent("onload",y):o.frame.addEventListener("load",y),o.frame.src=n;})},e}();C.debug=!1;C.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();C.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 C.Promise(function(o,i){var s=function d(a){if(a.data.postmate){if(a.data.postmate==="handshake"){n.child.removeEventListener("message",d,!1),a.source.postMessage({postmate:"handshake-reply",type:E},a.origin),n.parentOrigin=a.origin;var p=a.data.model;return p&&Object.keys(p).forEach(function(c){n.model[c]=p[c];}),o(new Oe(n))}return i("Handshake Reply Failed")}};n.child.addEventListener("message",s,!1);})},e}();var q=C;var b=(o=>(o.Verify="verify",o.Form="form",o.Render="render",o.VerifyButton="verify-button",o))(b||{});var k=(o=>(o.closed="closed",o.canceled="canceled",o.completed="completed",o.clicked="clicked",o))(k||{}),H=(o=>(o.propsReceived="propsReceived",o.started="started",o.formSaved="formSaved",o.formSaveComplete="formSaveComplete",o))(H||{});var z="footprint-inline-container",J="footprint-body-locked",X="footprint-overlay",Y="footprint-overlay-container",W=z,G=X,Z="footprint-loading-indicator",h=(e,t)=>`${e}-${t}`,Q=e=>f(void 0,null,function*(){A(e),Re(e),yield ke(e);}),ee=e=>{let t=h(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},ke=e=>f(void 0,null,function*(){let t=h(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(d=>{setTimeout(d,300);}));let o=r.querySelector("iframe.footprint-modal");o&&(o==null||o.classList.add("footprint-modal-closing"),yield new Promise(d=>{setTimeout(d,100);}));let i=h(G,e),s=document.getElementById(i);s&&(s.classList.add("footprint-overlay-fading"),yield new Promise(d=>{setTimeout(d,200);}),r.remove(),s.remove(),document.body.classList.remove(J));}),te=(e,t)=>{let r=h(W,e),n=document.createElement("div");return n.classList.add(z),n.setAttribute("id",r),t.appendChild(n),n},Re=e=>{let t=h(W,e),r=document.getElementById(t);r&&r.remove();},A=e=>{let t=h(Z,e),r=document.getElementById(t);r&&r.remove();},N=(e,t)=>{let r=h(Z,t),n=Fe(r);e.appendChild(n);},re=(e,t)=>{document.body.classList.add(J);let r=document.createElement("div"),n=h(G,t);return r.setAttribute("id",n),r.classList.add(X),e.appendChild(r),r},Fe=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 Se=()=>`${Math.floor(Math.random()*1e3)}`,R=Se;var _={["form"]:{["closed"]:"onClose",["canceled"]:"onCancel",["completed"]:"onComplete"},["verify"]:{["closed"]:"onClose",["canceled"]:"onCancel",["completed"]:"onComplete"},["verify-button"]:{["clicked"]:"onClick",["closed"]:"onClose",["canceled"]:"onCancel",["completed"]:"onComplete"},["render"]:{}},ne={["form"]:[],["verify"]:[],["render"]:[],["verify-button"]:[]};var Le={["form"]:["getRef"],["verify"]:[],["verify-button"]:[],["render"]:[]},oe=Le;var ae={["verify"]:["modal","drawer"],["verify-button"]:["inline"],["form"]:["inline","modal","drawer"],["render"]:["inline"]},K=(e,t)=>{var o;if(!t)return;let r=(o=ae[e])!=null?o:[];if(!r.includes(t))throw new Error(`Invalid variant: ${JSON.stringify(t)}. Valid variants for ${e} are ${r.join(", ")}`)},I=e=>{var r;let t=(r=ae[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");if(!Object.values(b).includes(e))throw new Error(`Invalid kind: ${e}. Valid kinds are: ${Object.values(b).join(", ")}}`)},xe=(e,t)=>{if(e==="inline"&&!t)throw new Error(`Inline component requires a containerId. Received ${t}`)},Ae=e=>{let{kind:t}=e;if(t==="verify-button"){let r=e,{kind:n,appearance:o,variant:i,dialogVariant:s,onClick:d,label:a,containerId:p}=r,c=L(r,["kind","appearance","variant","dialogVariant","onClick","label","containerId"]);return S(w({},c),{variant:s,kind:"verify"})}},Ne=e=>{var n;let{kind:t}=e;return (n=oe[t])!=null?n:[]},ie=(e,t,r)=>{var s;let{kind:n}=e,o=(s=_[n])!=null?s:{},i={};return Object.entries(o).forEach(([d,a])=>{let p=d;if(!Object.values(k).includes(p))return;let c=e[a];(!c||typeof c!="function")&&(c=()=>{});let m=p==="closed"||p==="canceled",y=n==="verify-button"&&p==="clicked";i[p]=v=>{c(v),m&&(t==null||t());let g=Ae(e);y&&g&&(r==null||r(g));};}),i},se=e=>{var m;let c=e,{kind:t,appearance:r,containerId:n}=c,o=L(c,["kind","appearance","containerId"]),i=(m=_[t])!=null?m:{},s=Object.values(i),d=Ne(e),a=Object.values(d);return Object.fromEntries(Object.entries(o).filter(([y])=>!s.includes(y)&&!a.includes(y)))},F=e=>{let{kind:t,variant:r,containerId:n}=e;D(t),K(t,r);let o=r||I(t);return xe(o,n),S(w({},e),{variant:o})};var _e=e=>typeof e=="object"&&!!e,B=({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}},de=()=>{let e=window.footprintAppearance;return !e||!_e(e)?{}:{fontSrc:e.fontSrc,rules:e.rules,theme:e.theme,variables:e.variables}};var Ke=e=>{let{kind:t}=e;return t==="verify"?De(e):Be(e)},De=e=>{let{appearance:t,variant:r,kind:n}=e,{fontSrc:o,rules:i,variables:s}=B(t),d="https://id.onefootprint.com",a=new URLSearchParams;"publicKey"in e&&e.publicKey&&a.append("public_key",e.publicKey),s&&a.append("variables",s),i&&a.append("rules",i),o&&a.append("font_src",o),a.append("variant",r!=null?r:I(n));let p=a.toString();return `${d}?${p}`},Be=e=>{let{appearance:t,kind:r,variant:n}=e,{fontSrc:o,rules:i,variables:s}=B(t),d="https://components.onefootprint.com",a=new URLSearchParams;s&&a.append("variables",s),i&&a.append("rules",i),o&&a.append("font_src",o),a.append("variant",n!=null?n:I(r));let p=a.toString();return `${d}/${r}?${p}`},pe=Ke;var Te=e=>{let t=null,r=!1,n=F(e),{variant:o,containerId:i}=n,s=o==="modal"||o==="drawer",d,a,p=R(),c=()=>{if(!t)throw new Error("Footprint should be initialized in order to listen events");let l=ie(n,d,a);Object.entries(l).forEach(([u,V])=>{t==null||t.on(u,V);});},m=()=>{if(!t)throw new Error("Footprint should be initialized in order to set up refs");let{kind:l}=n;if(l!=="form")return;let{getRef:u}=n;if(!u)return;u({save:()=>{if(!t)throw new Error("Footprint should be initialized to call ref methods");return new Promise(ye=>{t==null||t.call("formSaved"),t==null||t.on("formSaveComplete",()=>{ye();});})}});},y=()=>{if(!t)throw new Error("Footprint should be initialized in order to receive props");let l=se(n);t.call("propsReceived",l);},v=()=>{if(s)return ee(p);if(!i)throw new Error("containerId is required when rendering inline");let l=document.getElementById(i);if(!l)throw new Error(`Could not find container with id ${i} while rendering footprint`);return te(p,l)},g=(l,u)=>{if(!u){A(p),t==null||t.frame.classList.remove(`footprint-${o}-loading`),t==null||t.frame.classList.add(`footprint-${o}-loaded`);return}if(s){let V=re(l,p);N(V,p);}else N(l,p);};return {props:n,isRendered:r,render:()=>f(void 0,null,function*(){if(r)return;let l=v();if(!l)return;l.hasChildNodes()&&(l.innerHTML="");let u=pe(n);r=!0,g(l,!0),t=yield new q({classListArray:[`footprint-${o}`,`footprint-${o}-loading`],container:l,name:`footprint-iframe-${p}`,url:u,allow:"otp-credentials; publickey-credentials-get *; camera *; clipboard-write;"}),g(l,!1),c(),t.on("started",()=>{y(),m();});}),destroy:()=>f(void 0,null,function*(){r&&(r=!1,yield Q(p),t&&(t.destroy(),t=null));}),registerEvent:(l,u)=>{l==="renderSecondary"?a=u:l==="destroy"&&(d=u);}}},T=Te;var P=e=>{let t=F(e);return JSON.stringify(t)},Me=()=>{let e={};return {getOrCreate:i=>{let s=P(i.props),d=Object.values(e).find(a=>P(a.iframe.props)===s);return d?d.iframe:(e[s]={iframe:i,secondaryIframes:{}},i)},remove:i=>{let s=P(i.props),d=e[s];d&&(Object.keys(d.secondaryIframes).forEach(a=>{d.secondaryIframes[a].destroy();}),delete e[s]);},getOrCreateSecondary:(i,s)=>{let d=P(i.props),a=P(s.props);if(!e[d])throw new Error("iframe manager: primary iframe does not exist while adding secondary");let{secondaryIframes:p}=e[d],c=Object.values(p).find(m=>P(m.props)===a);return c||(p[a]=s,s)},removeSecondary:(i,s)=>{let d=P(i.props),a=P(s.props);if(!e[d])throw new Error("iframe manager: primary iframe does not exist while removing secondary");let{secondaryIframes:p}=e[d],c=p[a];c&&(c.destroy(),delete p[a]);}}},ce=Me;var $e=()=>{let e=ce();return {init:r=>{let n=T(r),o=()=>f(void 0,null,function*(){e.remove(n),yield n.destroy();}),i=a=>f(void 0,null,function*(){e.removeSecondary(n,a),yield a.destroy();}),s=a=>f(void 0,null,function*(){let p=T(a);p=e.getOrCreateSecondary(n,p),p.registerEvent("destroy",()=>{i(p);}),p.render();});return {render:()=>f(void 0,null,function*(){n=e.getOrCreate(n),n.registerEvent("destroy",o),n.registerEvent("renderSecondary",s),yield n.render();}),destroy:o}}}},Ue=$e(),M=Ue;var je=e=>{window.setTimeout(e,0);},le=e=>typeof e=="object"&&!!e,qe=e=>{if(typeof window=="undefined")return;let t=o=>{var d;let i=(d=window.footprintCallbacks)!=null?d:{};if(!le(i))throw Error("`window.footprintCallbacks` must be a valid mapping from callback names to functions.");return ne[o].forEach(a=>{if(!i[a])throw Error(`Callback '${a}' must be defined in window.footprintCallbacks`)}),i},r=o=>{var v;let i=o.getAttribute("data-kind");D(i);let s=(v=o.getAttribute("data-variant"))!=null?v:I(i);K(i,s);let d=de(),a=t(i),p=o.getAttribute("data-props")||"",c;try{c=JSON.parse(p);}catch(g){throw Error("Could not parse `data-props` for footprint.")}if(!le(c))throw Error("`data-props` on the footprint element has to be a valid JSON object stringified.");let m=R();o.setAttribute("id",m),e.init(w(w({kind:i,variant:s,appearance:d,containerId:o.id},a),c)).render();},n=()=>{let o=document.querySelectorAll("[data-footprint]");o.length&&o.forEach(i=>{r(i);});};document.addEventListener("DOMContentLoaded",()=>je(n));},me=qe;var fe=e=>f(void 0,null,function*(){let t=yield fetch("https://api.onefootprint.com/hosted/identify",{method:"POST",body:JSON.stringify(e)});if(!t.ok)throw Error(t.statusText);return (yield t.json()).user_found}),He=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 fe({identifier:{email:t}}))?!0:r?yield fe({identifier:{phone_number:r}}):!1}),ue=He;var Ut=M;me(M);/*! Bundled license information:

@@ -13,2 +13,2 @@ @onefootprint/postmate/build/postmate.es.js:

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

@@ -18,4 +18,4 @@ @onefootprint/postmate/build/postmate.es.js:

exports.FootprintPrivateEvent = H;
exports.FootprintPublicEvent = R;
exports.default = $t;
exports.FootprintPublicEvent = k;
exports.default = Ut;
exports.identifyFootprintUser = ue;

@@ -22,0 +22,0 @@

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

"type": "module",
"version": "3.6.0",
"version": "3.7.0",
"main": "./dist/footprint-js.cjs",

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc