@onefootprint/footprint-js
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -1,2 +0,2 @@ | ||
var w=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var E=(e,o)=>{var t={};for(var r in e)z.call(e,r)&&o.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&w)for(var r of w(e))o.indexOf(r)<0&&Y.call(e,r)&&(t[r]=e[r]);return t};var S=(e,o,t)=>new Promise((r,n)=>{var a=s=>{try{d(t.next(s));}catch(p){n(p);}},i=s=>{try{d(t.throw(s));}catch(p){n(p);}},d=s=>s.done?r(s.value):Promise.resolve(s.value).then(a,i);d((t=t.apply(e,o)).next());});var A=(r=>(r.closed="closed",r.completed="completed",r.canceled="canceled",r))(A||{}),F=(t=>(t.bootstrapDataReceived="bootstrapDataReceived",t.ready="ready",t))(F||{});var h="application/x-postmate-v1+json",Z=5,G=0,Q=function(){return ++G};var X=function(o){var t=document.createElement("a");t.href=o;var r=t.protocol.length>4?t.protocol:window.location.protocol,n=t.host.length?t.port==="80"||t.port==="443"?t.hostname:t.host:window.location.host;return t.origin||r+"//"+n},tt={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},P=function(o,t){return !(typeof t=="string"&&o.origin!==t||!o.data||typeof o.data=="object"&&!("postmate"in o.data)||o.data.type!==h||!tt[o.data.postmate])},et=function(o,t){var r=typeof o[t]=="function"?o[t]():o[t];return m.Promise.resolve(r)},ot=function(){function e(t){var r=this;this.parent=t.parent,this.frame=t.frame,this.child=t.child,this.childOrigin=t.childOrigin,this.events={},this.listener=function(n){if(!P(n,r.childOrigin))return !1;var a=((n||{}).data||{}).value||{},i=a.data,d=a.name;n.data.postmate==="emit"&&d in r.events&&r.events[d].call(r,i);},this.parent.addEventListener("message",this.listener,!1);}var o=e.prototype;return o.get=function(r){var n=this;return new m.Promise(function(a){var i=Q(),d=function s(p){p.data.uid===i&&p.data.postmate==="reply"&&(n.parent.removeEventListener("message",s,!1),a(p.data.value));};n.parent.addEventListener("message",d,!1),n.child.postMessage({postmate:"request",type:h,property:r,uid:i},n.childOrigin);})},o.call=function(r,n){this.child.postMessage({postmate:"call",type:h,property:r,data:n},this.childOrigin);},o.on=function(r,n){this.events[r]=n;},o.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),rt=function(){function e(t){var r=this;this.model=t.model,this.parent=t.parent,this.parentOrigin=t.parentOrigin,this.child=t.child,this.child.addEventListener("message",function(n){if(!!P(n,r.parentOrigin)){var a=n.data,i=a.property,d=a.uid,s=a.data;if(n.data.postmate==="call"){i in r.model&&typeof r.model[i]=="function"&&r.model[i](s);return}et(r.model,i).then(function(p){return n.source.postMessage({property:i,postmate:"reply",type:h,uid:d,value:p},n.origin)});}});}var o=e.prototype;return o.emit=function(r,n){this.parent.postMessage({postmate:"emit",type:h,value:{name:r,data:n}},this.parentOrigin);},e}(),m=function(){function e(t){var r=t.container,n=r===void 0?typeof n!="undefined"?n:document.body:r,a=t.model,i=t.url,d=t.name,s=t.classListArray,p=s===void 0?[]:s;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=d||"",this.frame.classList.add.apply(this.frame.classList,p),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(i)}var o=e.prototype;return o.sendHandshake=function(r){var n=this,a=X(r),i=0,d;return new e.Promise(function(s,p){var l=function c(y){return P(y,a)?y.data.postmate==="handshake-reply"?(clearInterval(d),n.parent.removeEventListener("message",c,!1),n.childOrigin=y.origin,s(new ot(n))):p("Failed handshake"):!1};n.parent.addEventListener("message",l,!1);var g=function(){i++,n.child.postMessage({postmate:"handshake",type:h,model:n.model},a),i===Z&&clearInterval(d);},u=function(){g(),d=setInterval(g,500);};n.frame.attachEvent?n.frame.attachEvent("onload",u):n.frame.onload=u,n.frame.src=r;})},e}();m.debug=!1;m.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();m.Model=function(){function e(t){return this.child=window,this.model=t,this.parent=this.child.parent,this.sendHandshakeReply()}var o=e.prototype;return o.sendHandshakeReply=function(){var r=this;return new m.Promise(function(n,a){var i=function d(s){if(!!s.data.postmate){if(s.data.postmate==="handshake"){r.child.removeEventListener("message",d,!1),s.source.postMessage({postmate:"handshake-reply",type:h},s.origin),r.parentOrigin=s.origin;var p=s.data.model;return p&&Object.keys(p).forEach(function(l){r.model[l]=p[l];}),n(new rt(r))}return a("Handshake Reply Failed")}};r.child.addEventListener("message",i,!1);})},e}();var k=m;var O="footprint-container",x="footprint-overlay",L="footprint-loading-indicator",nt="footprint-custom-styles",it=e=>{if(typeof window=="undefined")return;let o=document.getElementById(nt);o&&o.remove();let t=document.createElement("style");t.setAttribute("id","footprint-custom-styles"),t.textContent=e,document.head.append(t);},f=(e,o)=>o?`${e}: ${o}`:"",R=({variables:e={}})=>{it(` | ||
var w=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var A=(e,o)=>{var t={};for(var r in e)z.call(e,r)&&o.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&w)for(var r of w(e))o.indexOf(r)<0&&Y.call(e,r)&&(t[r]=e[r]);return t};var S=(e,o,t)=>new Promise((r,n)=>{var a=s=>{try{d(t.next(s));}catch(p){n(p);}},i=s=>{try{d(t.throw(s));}catch(p){n(p);}},d=s=>s.done?r(s.value):Promise.resolve(s.value).then(a,i);d((t=t.apply(e,o)).next());});var F=(r=>(r.closed="closed",r.completed="completed",r.canceled="canceled",r))(F||{}),k=(t=>(t.bootstrapDataReceived="bootstrapDataReceived",t.ready="ready",t))(k||{});var h="application/x-postmate-v1+json",Z=5,G=0,Q=function(){return ++G};var X=function(o){var t=document.createElement("a");t.href=o;var r=t.protocol.length>4?t.protocol:window.location.protocol,n=t.host.length?t.port==="80"||t.port==="443"?t.hostname:t.host:window.location.host;return t.origin||r+"//"+n},tt={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},P=function(o,t){return !(typeof t=="string"&&o.origin!==t||!o.data||typeof o.data=="object"&&!("postmate"in o.data)||o.data.type!==h||!tt[o.data.postmate])},et=function(o,t){var r=typeof o[t]=="function"?o[t]():o[t];return m.Promise.resolve(r)},ot=function(){function e(t){var r=this;this.parent=t.parent,this.frame=t.frame,this.child=t.child,this.childOrigin=t.childOrigin,this.events={},this.listener=function(n){if(!P(n,r.childOrigin))return !1;var a=((n||{}).data||{}).value||{},i=a.data,d=a.name;n.data.postmate==="emit"&&d in r.events&&r.events[d].call(r,i);},this.parent.addEventListener("message",this.listener,!1);}var o=e.prototype;return o.get=function(r){var n=this;return new m.Promise(function(a){var i=Q(),d=function s(p){p.data.uid===i&&p.data.postmate==="reply"&&(n.parent.removeEventListener("message",s,!1),a(p.data.value));};n.parent.addEventListener("message",d,!1),n.child.postMessage({postmate:"request",type:h,property:r,uid:i},n.childOrigin);})},o.call=function(r,n){this.child.postMessage({postmate:"call",type:h,property:r,data:n},this.childOrigin);},o.on=function(r,n){this.events[r]=n;},o.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),rt=function(){function e(t){var r=this;this.model=t.model,this.parent=t.parent,this.parentOrigin=t.parentOrigin,this.child=t.child,this.child.addEventListener("message",function(n){if(!!P(n,r.parentOrigin)){var a=n.data,i=a.property,d=a.uid,s=a.data;if(n.data.postmate==="call"){i in r.model&&typeof r.model[i]=="function"&&r.model[i](s);return}et(r.model,i).then(function(p){return n.source.postMessage({property:i,postmate:"reply",type:h,uid:d,value:p},n.origin)});}});}var o=e.prototype;return o.emit=function(r,n){this.parent.postMessage({postmate:"emit",type:h,value:{name:r,data:n}},this.parentOrigin);},e}(),m=function(){function e(t){var r=t.container,n=r===void 0?typeof n!="undefined"?n:document.body:r,a=t.model,i=t.url,d=t.name,s=t.classListArray,p=s===void 0?[]:s;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=d||"",this.frame.classList.add.apply(this.frame.classList,p),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(i)}var o=e.prototype;return o.sendHandshake=function(r){var n=this,a=X(r),i=0,d;return new e.Promise(function(s,p){var l=function c(y){return P(y,a)?y.data.postmate==="handshake-reply"?(clearInterval(d),n.parent.removeEventListener("message",c,!1),n.childOrigin=y.origin,s(new ot(n))):p("Failed handshake"):!1};n.parent.addEventListener("message",l,!1);var g=function(){i++,n.child.postMessage({postmate:"handshake",type:h,model:n.model},a),i===Z&&clearInterval(d);},u=function(){g(),d=setInterval(g,500);};n.frame.attachEvent?n.frame.attachEvent("onload",u):n.frame.onload=u,n.frame.src=r;})},e}();m.debug=!1;m.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();m.Model=function(){function e(t){return this.child=window,this.model=t,this.parent=this.child.parent,this.sendHandshakeReply()}var o=e.prototype;return o.sendHandshakeReply=function(){var r=this;return new m.Promise(function(n,a){var i=function d(s){if(!!s.data.postmate){if(s.data.postmate==="handshake"){r.child.removeEventListener("message",d,!1),s.source.postMessage({postmate:"handshake-reply",type:h},s.origin),r.parentOrigin=s.origin;var p=s.data.model;return p&&Object.keys(p).forEach(function(l){r.model[l]=p[l];}),n(new rt(r))}return a("Handshake Reply Failed")}};r.child.addEventListener("message",i,!1);})},e}();var O=m;var x="footprint-container",L="footprint-overlay",R="footprint-loading-indicator",nt="footprint-custom-styles",it=e=>{if(typeof window=="undefined")return;let o=document.getElementById(nt);o&&o.remove();let t=document.createElement("style");t.setAttribute("id","footprint-custom-styles"),t.textContent=e,document.head.append(t);},f=(e,o)=>o?`${e}: ${o}`:"",N=({variables:e={}})=>{it(` | ||
:root { | ||
@@ -11,3 +11,3 @@ ${f("--fp-fp-button-height",e.fpButtonHeight)} | ||
} | ||
`);},v=e=>{if(!e)throw new Error("A container is required to create a Footprint button");let o=B();return e.appendChild(o),o},N=e=>{document.body.classList.add("footprint-body-locked");let o=document.createElement("div");o.setAttribute("id",x);let t=at(L);o.appendChild(t),o.classList.add("footprint-overlay"),e.appendChild(o);},D=()=>{let e=document.getElementById(L);e&&e.remove();},I=()=>{document.body.classList.remove("footprint-body-locked");let e=document.getElementById(x);e&&e.remove();},_=()=>{let e=document.getElementById(O);if(e)return e;let o=document.createElement("div");return o.setAttribute("id",O),document.body.appendChild(o),o},at=e=>{let o=document.createElement("div");o.setAttribute("id",e),o.classList.add("footprint-loading-indicator");let t=document.createElement("div");t.classList.add("footprint-loading-spin");let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("width","24px"),r.setAttribute("height","24px"),r.setAttribute("fill","none"),r.setAttribute("aria-hidden","true");let n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),r.appendChild(n),t.appendChild(r),o.appendChild(t),o},st=()=>{let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width","24px"),e.setAttribute("height","24px"),e.setAttribute("fill","none"),e.setAttribute("aria-hidden","true");let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("d","M14.66 14h2.666v-2.36a2.666 2.666 0 1 1 0-4.614V4H6.66v16h4.666v-2.666A3.333 3.333 0 0 1 14.66 14Z"),o.setAttribute("fill","#76fb8f"),e.appendChild(o),e},B=()=>{let e=st(),o=document.createElement("button");o.appendChild(e);let t=document.createElement("span");return t.innerText="Verify with Footprint",o.appendChild(t),o.classList.add("footprint-button"),o};var b=class{constructor(){this.child=null;this.handleIframeLoaded=()=>{D();};}bootstrap(o){var t;o&&((t=this.child)==null||t.call("bootstrapDataReceived",o));}open(o,t){return S(this,null,function*(){let r=_();N(r),this.child=yield new k({classListArray:["footprint-modal"],container:r,name:"footprint-iframe",url:o}),this.handleIframeLoaded(),this.child.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),this.child.on("closed",()=>this.close()),this.child.on("ready",()=>{this.bootstrap(t);});})}on(o,t){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(o,t)}close(){I(),this.child&&this.child.destroy();}createButton(o){let t=B();return o.appendChild(t),t}},H=b;var V=e=>{let o="https://id.onefootprint.com",{publicKey:t,variables:r,rules:n,fontSrc:a}=e,i=new URLSearchParams;return t&&i.append("public_key",t),r&&i.append("tokens",r),n&&i.append("rules",n),a&&i.append("font_src",a),`${o}?${i.toString()}`},M=({fontSrc:e,variables:o={},rules:t={}}={})=>{let c=o,l=E(c,["fpButtonBorderRadius","fpButtonHeight","loadingBg","loadingBorderRadius","loadingColor","loadingPadding","overlayBg"]),g=()=>Object.keys(l).length?encodeURIComponent(JSON.stringify(l)):void 0,u=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0;return {fontSrc:e,variables:g(),rules:u()}};var C=new H,T=!1,dt=()=>{let e=({theme:i="light",variables:d={}}={})=>{let{fpButtonBorderRadius:s,fpButtonHeight:p,loadingBg:l,loadingBorderRadius:g,loadingColor:u,loadingPadding:c,overlayBg:y}=d;R({theme:i,variables:{fpButtonBorderRadius:s,fpButtonHeight:p,loadingBg:l,loadingBorderRadius:g,loadingColor:u,loadingPadding:c,overlayBg:y}});},o=i=>C.on("completed",d=>{d&&typeof d=="string"&&i(d);}),t=i=>C.on("canceled",i),r=i=>C.on("closed",i),n=g=>S(void 0,[g],function*({appearance:i,onCanceled:d,onCompleted:s,publicKey:p,userData:l}){if(T){console.warn("Cannot open two instances of Footprint at the same time");return}e(i);let{fontSrc:u,rules:c,variables:y}=M(i),J=V({fontSrc:u,publicKey:p,rules:c,variables:y});yield C.open(J,l),s&&o(s),d&&t(d),r(a);}),a=()=>S(void 0,null,function*(){yield C.close(),T=!1;});return {open:n,close:a,createButton:v}},U=dt;var pt=e=>{window.setTimeout(e,0);},j=e=>typeof e=="function",lt=e=>typeof e=="object"&&!!e,ct=e=>{if(typeof window=="undefined")return;let o=()=>{let a=window.footprintAppearance;if(!(!a||!lt(a)))return {fontSrc:a.fontSrc,rules:a.rules,theme:a.theme,variables:a.variables}},t=(a,i)=>{let d=i.getAttribute("data-user-email"),s=i.getAttribute("data-user-phone-number");e.open({publicKey:a,appearance:o(),onCanceled:()=>{var p;j(window.onFootprintCanceled)&&((p=window.onFootprintCanceled)==null||p.call(window));},onCompleted:p=>{var l;j(window.onFootprintCompleted)&&((l=window.onFootprintCompleted)==null||l.call(window,p));},userData:{email:d,phoneNumber:s}});},r=()=>{let a=document.getElementById("footprint-button");if(!a)return;let i=a.getAttribute("data-public-key");if(!i)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");n(i,a);},n=(a,i)=>{pt(()=>{v(i).addEventListener("click",()=>{t(a,i);});});};document.addEventListener("DOMContentLoaded",()=>r());},$=ct;var q=e=>S(void 0,null,function*(){let o=yield fetch("https://api.onefootprint.com/hosted/identify",{method:"POST",body:JSON.stringify(e)});if(!o.ok)throw Error(o.statusText);return (yield o.json()).user_found}),ut=e=>S(void 0,null,function*(){if(!e)throw new Error("User data must be passed in order to identify an user");let{email:o,phoneNumber:t}=e;return o&&(yield q({identifier:{email:o}}))?!0:t?yield q({identifier:{phone_number:t}}):!1}),W=ut;var K=U();$(K);var Mt=K;/** | ||
`);},v=e=>{if(!e)throw new Error("A container is required to create a Footprint button");let o=B();return e.appendChild(o),o},D=e=>{document.body.classList.add("footprint-body-locked");let o=document.createElement("div");o.setAttribute("id",L);let t=at(R);o.appendChild(t),o.classList.add("footprint-overlay"),e.appendChild(o);},I=()=>{let e=document.getElementById(R);e&&e.remove();},_=()=>{document.body.classList.remove("footprint-body-locked");let e=document.getElementById(L);e&&e.remove();},H=()=>{let e=document.getElementById(x);if(e)return e;let o=document.createElement("div");return o.setAttribute("id",x),document.body.appendChild(o),o},at=e=>{let o=document.createElement("div");o.setAttribute("id",e),o.classList.add("footprint-loading-indicator");let t=document.createElement("div");t.classList.add("footprint-loading-spin");let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("width","24px"),r.setAttribute("height","24px"),r.setAttribute("fill","none"),r.setAttribute("aria-hidden","true");let n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),r.appendChild(n),t.appendChild(r),o.appendChild(t),o},st=()=>{let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width","24px"),e.setAttribute("height","24px"),e.setAttribute("fill","none"),e.setAttribute("aria-hidden","true");let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("d","M14.66 14h2.666v-2.36a2.666 2.666 0 1 1 0-4.614V4H6.66v16h4.666v-2.666A3.333 3.333 0 0 1 14.66 14Z"),o.setAttribute("fill","#76fb8f"),e.appendChild(o),e},B=()=>{let e=st(),o=document.createElement("button");o.appendChild(e);let t=document.createElement("span");return t.innerText="Verify with Footprint",o.appendChild(t),o.classList.add("footprint-button"),o};var b=class{constructor(){this.child=null;this.handleIframeLoaded=()=>{I();};}bootstrap(o){var t;o&&((t=this.child)==null||t.call("bootstrapDataReceived",o));}open(o,t){return S(this,null,function*(){let r=H();D(r),this.child=yield new O({classListArray:["footprint-modal"],container:r,name:"footprint-iframe",url:o}),this.handleIframeLoaded(),this.child.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),this.child.on("closed",()=>this.close()),this.child.on("ready",()=>{this.bootstrap(t);});})}on(o,t){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(o,t)}close(){_(),this.child&&this.child.destroy();}createButton(o){let t=B();return o.appendChild(t),t}},V=b;var M=e=>{let o="https://id.onefootprint.com",{publicKey:t,variables:r,rules:n,fontSrc:a}=e,i=new URLSearchParams;return t&&i.append("public_key",t),r&&i.append("tokens",r),n&&i.append("rules",n),a&&i.append("font_src",a),`${o}?${i.toString()}`},T=({fontSrc:e,variables:o={},rules:t={}}={})=>{let c=o,l=A(c,["fpButtonBorderRadius","fpButtonHeight","loadingBg","loadingBorderRadius","loadingColor","loadingPadding","overlayBg"]),g=()=>Object.keys(l).length?encodeURIComponent(JSON.stringify(l)):void 0,u=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0;return {fontSrc:e,variables:g(),rules:u()}};var C=new V,E=!1,dt=()=>{let e=({theme:i="light",variables:d={}}={})=>{let{fpButtonBorderRadius:s,fpButtonHeight:p,loadingBg:l,loadingBorderRadius:g,loadingColor:u,loadingPadding:c,overlayBg:y}=d;N({theme:i,variables:{fpButtonBorderRadius:s,fpButtonHeight:p,loadingBg:l,loadingBorderRadius:g,loadingColor:u,loadingPadding:c,overlayBg:y}});},o=i=>C.on("completed",d=>{d&&typeof d=="string"&&i(d);}),t=i=>C.on("canceled",i),r=i=>C.on("closed",i),n=g=>S(void 0,[g],function*({appearance:i,onCanceled:d,onCompleted:s,publicKey:p,userData:l}){if(E)return;E=!0,e(i);let{fontSrc:u,rules:c,variables:y}=T(i),J=M({fontSrc:u,publicKey:p,rules:c,variables:y});yield C.open(J,l),s&&o(s),d&&t(d),r(a);}),a=()=>S(void 0,null,function*(){yield C.close(),E=!1;});return {open:n,close:a,createButton:v}},U=dt;var pt=e=>{window.setTimeout(e,0);},j=e=>typeof e=="function",lt=e=>typeof e=="object"&&!!e,ct=e=>{if(typeof window=="undefined")return;let o=()=>{let a=window.footprintAppearance;if(!(!a||!lt(a)))return {fontSrc:a.fontSrc,rules:a.rules,theme:a.theme,variables:a.variables}},t=(a,i)=>{let d=i.getAttribute("data-user-email"),s=i.getAttribute("data-user-phone-number");e.open({publicKey:a,appearance:o(),onCanceled:()=>{var p;j(window.onFootprintCanceled)&&((p=window.onFootprintCanceled)==null||p.call(window));},onCompleted:p=>{var l;j(window.onFootprintCompleted)&&((l=window.onFootprintCompleted)==null||l.call(window,p));},userData:{email:d,phoneNumber:s}});},r=()=>{let a=document.getElementById("footprint-button");if(!a)return;let i=a.getAttribute("data-public-key");if(!i)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");n(i,a);},n=(a,i)=>{pt(()=>{v(i).addEventListener("click",()=>{t(a,i);});});};document.addEventListener("DOMContentLoaded",()=>r());},$=ct;var q=e=>S(void 0,null,function*(){let o=yield fetch("https://api.onefootprint.com/hosted/identify",{method:"POST",body:JSON.stringify(e)});if(!o.ok)throw Error(o.statusText);return (yield o.json()).user_found}),ut=e=>S(void 0,null,function*(){if(!e)throw new Error("User data must be passed in order to identify an user");let{email:o,phoneNumber:t}=e;return o&&(yield q({identifier:{email:o}}))?!0:t?yield q({identifier:{phone_number:t}}):!1}),W=ut;var K=U();$(K);var Mt=K;/** | ||
postmate - A powerful, simple, promise-based postMessage library | ||
@@ -20,2 +20,2 @@ @version v1.5.2 | ||
export { F as FootprintInternalEvent, A as FootprintPublicEvent, Mt as default, W as identifyUser }; | ||
export { k as FootprintInternalEvent, F as FootprintPublicEvent, Mt as default, W as identifyUser }; |
(function (exports) { | ||
'use strict'; | ||
var w=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var E=(e,o)=>{var t={};for(var r in e)z.call(e,r)&&o.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&w)for(var r of w(e))o.indexOf(r)<0&&Y.call(e,r)&&(t[r]=e[r]);return t};var S=(e,o,t)=>new Promise((r,n)=>{var a=s=>{try{d(t.next(s));}catch(p){n(p);}},i=s=>{try{d(t.throw(s));}catch(p){n(p);}},d=s=>s.done?r(s.value):Promise.resolve(s.value).then(a,i);d((t=t.apply(e,o)).next());});var A=(r=>(r.closed="closed",r.completed="completed",r.canceled="canceled",r))(A||{}),F=(t=>(t.bootstrapDataReceived="bootstrapDataReceived",t.ready="ready",t))(F||{});var h="application/x-postmate-v1+json",Z=5,G=0,Q=function(){return ++G};var X=function(o){var t=document.createElement("a");t.href=o;var r=t.protocol.length>4?t.protocol:window.location.protocol,n=t.host.length?t.port==="80"||t.port==="443"?t.hostname:t.host:window.location.host;return t.origin||r+"//"+n},tt={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},P=function(o,t){return !(typeof t=="string"&&o.origin!==t||!o.data||typeof o.data=="object"&&!("postmate"in o.data)||o.data.type!==h||!tt[o.data.postmate])},et=function(o,t){var r=typeof o[t]=="function"?o[t]():o[t];return m.Promise.resolve(r)},ot=function(){function e(t){var r=this;this.parent=t.parent,this.frame=t.frame,this.child=t.child,this.childOrigin=t.childOrigin,this.events={},this.listener=function(n){if(!P(n,r.childOrigin))return !1;var a=((n||{}).data||{}).value||{},i=a.data,d=a.name;n.data.postmate==="emit"&&d in r.events&&r.events[d].call(r,i);},this.parent.addEventListener("message",this.listener,!1);}var o=e.prototype;return o.get=function(r){var n=this;return new m.Promise(function(a){var i=Q(),d=function s(p){p.data.uid===i&&p.data.postmate==="reply"&&(n.parent.removeEventListener("message",s,!1),a(p.data.value));};n.parent.addEventListener("message",d,!1),n.child.postMessage({postmate:"request",type:h,property:r,uid:i},n.childOrigin);})},o.call=function(r,n){this.child.postMessage({postmate:"call",type:h,property:r,data:n},this.childOrigin);},o.on=function(r,n){this.events[r]=n;},o.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),rt=function(){function e(t){var r=this;this.model=t.model,this.parent=t.parent,this.parentOrigin=t.parentOrigin,this.child=t.child,this.child.addEventListener("message",function(n){if(!!P(n,r.parentOrigin)){var a=n.data,i=a.property,d=a.uid,s=a.data;if(n.data.postmate==="call"){i in r.model&&typeof r.model[i]=="function"&&r.model[i](s);return}et(r.model,i).then(function(p){return n.source.postMessage({property:i,postmate:"reply",type:h,uid:d,value:p},n.origin)});}});}var o=e.prototype;return o.emit=function(r,n){this.parent.postMessage({postmate:"emit",type:h,value:{name:r,data:n}},this.parentOrigin);},e}(),m=function(){function e(t){var r=t.container,n=r===void 0?typeof n!="undefined"?n:document.body:r,a=t.model,i=t.url,d=t.name,s=t.classListArray,p=s===void 0?[]:s;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=d||"",this.frame.classList.add.apply(this.frame.classList,p),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(i)}var o=e.prototype;return o.sendHandshake=function(r){var n=this,a=X(r),i=0,d;return new e.Promise(function(s,p){var l=function c(y){return P(y,a)?y.data.postmate==="handshake-reply"?(clearInterval(d),n.parent.removeEventListener("message",c,!1),n.childOrigin=y.origin,s(new ot(n))):p("Failed handshake"):!1};n.parent.addEventListener("message",l,!1);var g=function(){i++,n.child.postMessage({postmate:"handshake",type:h,model:n.model},a),i===Z&&clearInterval(d);},u=function(){g(),d=setInterval(g,500);};n.frame.attachEvent?n.frame.attachEvent("onload",u):n.frame.onload=u,n.frame.src=r;})},e}();m.debug=!1;m.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();m.Model=function(){function e(t){return this.child=window,this.model=t,this.parent=this.child.parent,this.sendHandshakeReply()}var o=e.prototype;return o.sendHandshakeReply=function(){var r=this;return new m.Promise(function(n,a){var i=function d(s){if(!!s.data.postmate){if(s.data.postmate==="handshake"){r.child.removeEventListener("message",d,!1),s.source.postMessage({postmate:"handshake-reply",type:h},s.origin),r.parentOrigin=s.origin;var p=s.data.model;return p&&Object.keys(p).forEach(function(l){r.model[l]=p[l];}),n(new rt(r))}return a("Handshake Reply Failed")}};r.child.addEventListener("message",i,!1);})},e}();var k=m;var O="footprint-container",x="footprint-overlay",L="footprint-loading-indicator",nt="footprint-custom-styles",it=e=>{if(typeof window=="undefined")return;let o=document.getElementById(nt);o&&o.remove();let t=document.createElement("style");t.setAttribute("id","footprint-custom-styles"),t.textContent=e,document.head.append(t);},f=(e,o)=>o?`${e}: ${o}`:"",R=({variables:e={}})=>{it(` | ||
var w=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var A=(e,o)=>{var t={};for(var r in e)z.call(e,r)&&o.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&w)for(var r of w(e))o.indexOf(r)<0&&Y.call(e,r)&&(t[r]=e[r]);return t};var S=(e,o,t)=>new Promise((r,n)=>{var a=s=>{try{d(t.next(s));}catch(p){n(p);}},i=s=>{try{d(t.throw(s));}catch(p){n(p);}},d=s=>s.done?r(s.value):Promise.resolve(s.value).then(a,i);d((t=t.apply(e,o)).next());});var F=(r=>(r.closed="closed",r.completed="completed",r.canceled="canceled",r))(F||{}),k=(t=>(t.bootstrapDataReceived="bootstrapDataReceived",t.ready="ready",t))(k||{});var h="application/x-postmate-v1+json",Z=5,G=0,Q=function(){return ++G};var X=function(o){var t=document.createElement("a");t.href=o;var r=t.protocol.length>4?t.protocol:window.location.protocol,n=t.host.length?t.port==="80"||t.port==="443"?t.hostname:t.host:window.location.host;return t.origin||r+"//"+n},tt={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},P=function(o,t){return !(typeof t=="string"&&o.origin!==t||!o.data||typeof o.data=="object"&&!("postmate"in o.data)||o.data.type!==h||!tt[o.data.postmate])},et=function(o,t){var r=typeof o[t]=="function"?o[t]():o[t];return m.Promise.resolve(r)},ot=function(){function e(t){var r=this;this.parent=t.parent,this.frame=t.frame,this.child=t.child,this.childOrigin=t.childOrigin,this.events={},this.listener=function(n){if(!P(n,r.childOrigin))return !1;var a=((n||{}).data||{}).value||{},i=a.data,d=a.name;n.data.postmate==="emit"&&d in r.events&&r.events[d].call(r,i);},this.parent.addEventListener("message",this.listener,!1);}var o=e.prototype;return o.get=function(r){var n=this;return new m.Promise(function(a){var i=Q(),d=function s(p){p.data.uid===i&&p.data.postmate==="reply"&&(n.parent.removeEventListener("message",s,!1),a(p.data.value));};n.parent.addEventListener("message",d,!1),n.child.postMessage({postmate:"request",type:h,property:r,uid:i},n.childOrigin);})},o.call=function(r,n){this.child.postMessage({postmate:"call",type:h,property:r,data:n},this.childOrigin);},o.on=function(r,n){this.events[r]=n;},o.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),rt=function(){function e(t){var r=this;this.model=t.model,this.parent=t.parent,this.parentOrigin=t.parentOrigin,this.child=t.child,this.child.addEventListener("message",function(n){if(!!P(n,r.parentOrigin)){var a=n.data,i=a.property,d=a.uid,s=a.data;if(n.data.postmate==="call"){i in r.model&&typeof r.model[i]=="function"&&r.model[i](s);return}et(r.model,i).then(function(p){return n.source.postMessage({property:i,postmate:"reply",type:h,uid:d,value:p},n.origin)});}});}var o=e.prototype;return o.emit=function(r,n){this.parent.postMessage({postmate:"emit",type:h,value:{name:r,data:n}},this.parentOrigin);},e}(),m=function(){function e(t){var r=t.container,n=r===void 0?typeof n!="undefined"?n:document.body:r,a=t.model,i=t.url,d=t.name,s=t.classListArray,p=s===void 0?[]:s;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=d||"",this.frame.classList.add.apply(this.frame.classList,p),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(i)}var o=e.prototype;return o.sendHandshake=function(r){var n=this,a=X(r),i=0,d;return new e.Promise(function(s,p){var l=function c(y){return P(y,a)?y.data.postmate==="handshake-reply"?(clearInterval(d),n.parent.removeEventListener("message",c,!1),n.childOrigin=y.origin,s(new ot(n))):p("Failed handshake"):!1};n.parent.addEventListener("message",l,!1);var g=function(){i++,n.child.postMessage({postmate:"handshake",type:h,model:n.model},a),i===Z&&clearInterval(d);},u=function(){g(),d=setInterval(g,500);};n.frame.attachEvent?n.frame.attachEvent("onload",u):n.frame.onload=u,n.frame.src=r;})},e}();m.debug=!1;m.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();m.Model=function(){function e(t){return this.child=window,this.model=t,this.parent=this.child.parent,this.sendHandshakeReply()}var o=e.prototype;return o.sendHandshakeReply=function(){var r=this;return new m.Promise(function(n,a){var i=function d(s){if(!!s.data.postmate){if(s.data.postmate==="handshake"){r.child.removeEventListener("message",d,!1),s.source.postMessage({postmate:"handshake-reply",type:h},s.origin),r.parentOrigin=s.origin;var p=s.data.model;return p&&Object.keys(p).forEach(function(l){r.model[l]=p[l];}),n(new rt(r))}return a("Handshake Reply Failed")}};r.child.addEventListener("message",i,!1);})},e}();var O=m;var x="footprint-container",L="footprint-overlay",R="footprint-loading-indicator",nt="footprint-custom-styles",it=e=>{if(typeof window=="undefined")return;let o=document.getElementById(nt);o&&o.remove();let t=document.createElement("style");t.setAttribute("id","footprint-custom-styles"),t.textContent=e,document.head.append(t);},f=(e,o)=>o?`${e}: ${o}`:"",N=({variables:e={}})=>{it(` | ||
:root { | ||
@@ -14,3 +14,3 @@ ${f("--fp-fp-button-height",e.fpButtonHeight)} | ||
} | ||
`);},v=e=>{if(!e)throw new Error("A container is required to create a Footprint button");let o=B();return e.appendChild(o),o},N=e=>{document.body.classList.add("footprint-body-locked");let o=document.createElement("div");o.setAttribute("id",x);let t=at(L);o.appendChild(t),o.classList.add("footprint-overlay"),e.appendChild(o);},D=()=>{let e=document.getElementById(L);e&&e.remove();},I=()=>{document.body.classList.remove("footprint-body-locked");let e=document.getElementById(x);e&&e.remove();},_=()=>{let e=document.getElementById(O);if(e)return e;let o=document.createElement("div");return o.setAttribute("id",O),document.body.appendChild(o),o},at=e=>{let o=document.createElement("div");o.setAttribute("id",e),o.classList.add("footprint-loading-indicator");let t=document.createElement("div");t.classList.add("footprint-loading-spin");let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("width","24px"),r.setAttribute("height","24px"),r.setAttribute("fill","none"),r.setAttribute("aria-hidden","true");let n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),r.appendChild(n),t.appendChild(r),o.appendChild(t),o},st=()=>{let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width","24px"),e.setAttribute("height","24px"),e.setAttribute("fill","none"),e.setAttribute("aria-hidden","true");let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("d","M14.66 14h2.666v-2.36a2.666 2.666 0 1 1 0-4.614V4H6.66v16h4.666v-2.666A3.333 3.333 0 0 1 14.66 14Z"),o.setAttribute("fill","#76fb8f"),e.appendChild(o),e},B=()=>{let e=st(),o=document.createElement("button");o.appendChild(e);let t=document.createElement("span");return t.innerText="Verify with Footprint",o.appendChild(t),o.classList.add("footprint-button"),o};var b=class{constructor(){this.child=null;this.handleIframeLoaded=()=>{D();};}bootstrap(o){var t;o&&((t=this.child)==null||t.call("bootstrapDataReceived",o));}open(o,t){return S(this,null,function*(){let r=_();N(r),this.child=yield new k({classListArray:["footprint-modal"],container:r,name:"footprint-iframe",url:o}),this.handleIframeLoaded(),this.child.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),this.child.on("closed",()=>this.close()),this.child.on("ready",()=>{this.bootstrap(t);});})}on(o,t){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(o,t)}close(){I(),this.child&&this.child.destroy();}createButton(o){let t=B();return o.appendChild(t),t}},H=b;var V=e=>{let o="https://id.onefootprint.com",{publicKey:t,variables:r,rules:n,fontSrc:a}=e,i=new URLSearchParams;return t&&i.append("public_key",t),r&&i.append("tokens",r),n&&i.append("rules",n),a&&i.append("font_src",a),`${o}?${i.toString()}`},M=({fontSrc:e,variables:o={},rules:t={}}={})=>{let c=o,l=E(c,["fpButtonBorderRadius","fpButtonHeight","loadingBg","loadingBorderRadius","loadingColor","loadingPadding","overlayBg"]),g=()=>Object.keys(l).length?encodeURIComponent(JSON.stringify(l)):void 0,u=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0;return {fontSrc:e,variables:g(),rules:u()}};var C=new H,T=!1,dt=()=>{let e=({theme:i="light",variables:d={}}={})=>{let{fpButtonBorderRadius:s,fpButtonHeight:p,loadingBg:l,loadingBorderRadius:g,loadingColor:u,loadingPadding:c,overlayBg:y}=d;R({theme:i,variables:{fpButtonBorderRadius:s,fpButtonHeight:p,loadingBg:l,loadingBorderRadius:g,loadingColor:u,loadingPadding:c,overlayBg:y}});},o=i=>C.on("completed",d=>{d&&typeof d=="string"&&i(d);}),t=i=>C.on("canceled",i),r=i=>C.on("closed",i),n=g=>S(void 0,[g],function*({appearance:i,onCanceled:d,onCompleted:s,publicKey:p,userData:l}){if(T){console.warn("Cannot open two instances of Footprint at the same time");return}e(i);let{fontSrc:u,rules:c,variables:y}=M(i),J=V({fontSrc:u,publicKey:p,rules:c,variables:y});yield C.open(J,l),s&&o(s),d&&t(d),r(a);}),a=()=>S(void 0,null,function*(){yield C.close(),T=!1;});return {open:n,close:a,createButton:v}},U=dt;var pt=e=>{window.setTimeout(e,0);},j=e=>typeof e=="function",lt=e=>typeof e=="object"&&!!e,ct=e=>{if(typeof window=="undefined")return;let o=()=>{let a=window.footprintAppearance;if(!(!a||!lt(a)))return {fontSrc:a.fontSrc,rules:a.rules,theme:a.theme,variables:a.variables}},t=(a,i)=>{let d=i.getAttribute("data-user-email"),s=i.getAttribute("data-user-phone-number");e.open({publicKey:a,appearance:o(),onCanceled:()=>{var p;j(window.onFootprintCanceled)&&((p=window.onFootprintCanceled)==null||p.call(window));},onCompleted:p=>{var l;j(window.onFootprintCompleted)&&((l=window.onFootprintCompleted)==null||l.call(window,p));},userData:{email:d,phoneNumber:s}});},r=()=>{let a=document.getElementById("footprint-button");if(!a)return;let i=a.getAttribute("data-public-key");if(!i)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");n(i,a);},n=(a,i)=>{pt(()=>{v(i).addEventListener("click",()=>{t(a,i);});});};document.addEventListener("DOMContentLoaded",()=>r());},$=ct;var q=e=>S(void 0,null,function*(){let o=yield fetch("https://api.onefootprint.com/hosted/identify",{method:"POST",body:JSON.stringify(e)});if(!o.ok)throw Error(o.statusText);return (yield o.json()).user_found}),ut=e=>S(void 0,null,function*(){if(!e)throw new Error("User data must be passed in order to identify an user");let{email:o,phoneNumber:t}=e;return o&&(yield q({identifier:{email:o}}))?!0:t?yield q({identifier:{phone_number:t}}):!1}),W=ut;var K=U();$(K);var Mt=K;/** | ||
`);},v=e=>{if(!e)throw new Error("A container is required to create a Footprint button");let o=B();return e.appendChild(o),o},D=e=>{document.body.classList.add("footprint-body-locked");let o=document.createElement("div");o.setAttribute("id",L);let t=at(R);o.appendChild(t),o.classList.add("footprint-overlay"),e.appendChild(o);},I=()=>{let e=document.getElementById(R);e&&e.remove();},_=()=>{document.body.classList.remove("footprint-body-locked");let e=document.getElementById(L);e&&e.remove();},H=()=>{let e=document.getElementById(x);if(e)return e;let o=document.createElement("div");return o.setAttribute("id",x),document.body.appendChild(o),o},at=e=>{let o=document.createElement("div");o.setAttribute("id",e),o.classList.add("footprint-loading-indicator");let t=document.createElement("div");t.classList.add("footprint-loading-spin");let r=document.createElementNS("http://www.w3.org/2000/svg","svg");r.setAttribute("width","24px"),r.setAttribute("height","24px"),r.setAttribute("fill","none"),r.setAttribute("aria-hidden","true");let n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),r.appendChild(n),t.appendChild(r),o.appendChild(t),o},st=()=>{let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width","24px"),e.setAttribute("height","24px"),e.setAttribute("fill","none"),e.setAttribute("aria-hidden","true");let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("d","M14.66 14h2.666v-2.36a2.666 2.666 0 1 1 0-4.614V4H6.66v16h4.666v-2.666A3.333 3.333 0 0 1 14.66 14Z"),o.setAttribute("fill","#76fb8f"),e.appendChild(o),e},B=()=>{let e=st(),o=document.createElement("button");o.appendChild(e);let t=document.createElement("span");return t.innerText="Verify with Footprint",o.appendChild(t),o.classList.add("footprint-button"),o};var b=class{constructor(){this.child=null;this.handleIframeLoaded=()=>{I();};}bootstrap(o){var t;o&&((t=this.child)==null||t.call("bootstrapDataReceived",o));}open(o,t){return S(this,null,function*(){let r=H();D(r),this.child=yield new O({classListArray:["footprint-modal"],container:r,name:"footprint-iframe",url:o}),this.handleIframeLoaded(),this.child.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),this.child.on("closed",()=>this.close()),this.child.on("ready",()=>{this.bootstrap(t);});})}on(o,t){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(o,t)}close(){_(),this.child&&this.child.destroy();}createButton(o){let t=B();return o.appendChild(t),t}},V=b;var M=e=>{let o="https://id.onefootprint.com",{publicKey:t,variables:r,rules:n,fontSrc:a}=e,i=new URLSearchParams;return t&&i.append("public_key",t),r&&i.append("tokens",r),n&&i.append("rules",n),a&&i.append("font_src",a),`${o}?${i.toString()}`},T=({fontSrc:e,variables:o={},rules:t={}}={})=>{let c=o,l=A(c,["fpButtonBorderRadius","fpButtonHeight","loadingBg","loadingBorderRadius","loadingColor","loadingPadding","overlayBg"]),g=()=>Object.keys(l).length?encodeURIComponent(JSON.stringify(l)):void 0,u=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0;return {fontSrc:e,variables:g(),rules:u()}};var C=new V,E=!1,dt=()=>{let e=({theme:i="light",variables:d={}}={})=>{let{fpButtonBorderRadius:s,fpButtonHeight:p,loadingBg:l,loadingBorderRadius:g,loadingColor:u,loadingPadding:c,overlayBg:y}=d;N({theme:i,variables:{fpButtonBorderRadius:s,fpButtonHeight:p,loadingBg:l,loadingBorderRadius:g,loadingColor:u,loadingPadding:c,overlayBg:y}});},o=i=>C.on("completed",d=>{d&&typeof d=="string"&&i(d);}),t=i=>C.on("canceled",i),r=i=>C.on("closed",i),n=g=>S(void 0,[g],function*({appearance:i,onCanceled:d,onCompleted:s,publicKey:p,userData:l}){if(E)return;E=!0,e(i);let{fontSrc:u,rules:c,variables:y}=T(i),J=M({fontSrc:u,publicKey:p,rules:c,variables:y});yield C.open(J,l),s&&o(s),d&&t(d),r(a);}),a=()=>S(void 0,null,function*(){yield C.close(),E=!1;});return {open:n,close:a,createButton:v}},U=dt;var pt=e=>{window.setTimeout(e,0);},j=e=>typeof e=="function",lt=e=>typeof e=="object"&&!!e,ct=e=>{if(typeof window=="undefined")return;let o=()=>{let a=window.footprintAppearance;if(!(!a||!lt(a)))return {fontSrc:a.fontSrc,rules:a.rules,theme:a.theme,variables:a.variables}},t=(a,i)=>{let d=i.getAttribute("data-user-email"),s=i.getAttribute("data-user-phone-number");e.open({publicKey:a,appearance:o(),onCanceled:()=>{var p;j(window.onFootprintCanceled)&&((p=window.onFootprintCanceled)==null||p.call(window));},onCompleted:p=>{var l;j(window.onFootprintCompleted)&&((l=window.onFootprintCompleted)==null||l.call(window,p));},userData:{email:d,phoneNumber:s}});},r=()=>{let a=document.getElementById("footprint-button");if(!a)return;let i=a.getAttribute("data-public-key");if(!i)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");n(i,a);},n=(a,i)=>{pt(()=>{v(i).addEventListener("click",()=>{t(a,i);});});};document.addEventListener("DOMContentLoaded",()=>r());},$=ct;var q=e=>S(void 0,null,function*(){let o=yield fetch("https://api.onefootprint.com/hosted/identify",{method:"POST",body:JSON.stringify(e)});if(!o.ok)throw Error(o.statusText);return (yield o.json()).user_found}),ut=e=>S(void 0,null,function*(){if(!e)throw new Error("User data must be passed in order to identify an user");let{email:o,phoneNumber:t}=e;return o&&(yield q({identifier:{email:o}}))?!0:t?yield q({identifier:{phone_number:t}}):!1}),W=ut;var K=U();$(K);var Mt=K;/** | ||
postmate - A powerful, simple, promise-based postMessage library | ||
@@ -23,4 +23,4 @@ @version v1.5.2 | ||
exports.FootprintInternalEvent = F; | ||
exports.FootprintPublicEvent = A; | ||
exports.FootprintInternalEvent = k; | ||
exports.FootprintPublicEvent = F; | ||
exports.default = Mt; | ||
@@ -27,0 +27,0 @@ exports.identifyUser = W; |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"main": "./dist/footprint-js.umd.js", | ||
@@ -8,0 +8,0 @@ "module": "./dist/footprint-js.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44216