@onefootprint/footprint-js
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -182,2 +182,3 @@ import * as CSS from 'csstype'; | ||
showCompletionPage?: boolean; | ||
showLogo?: boolean; | ||
}; | ||
@@ -184,0 +185,0 @@ |
@@ -1,2 +0,2 @@ | ||
var c=(o,e,t)=>new Promise((r,n)=>{var i=d=>{try{p(t.next(d));}catch(s){n(s);}},a=d=>{try{p(t.throw(d));}catch(s){n(s);}},p=d=>d.done?r(d.value):Promise.resolve(d.value).then(i,a);p((t=t.apply(o,e)).next());});var E=(r=>(r.closed="closed",r.completed="completed",r.canceled="canceled",r))(E||{}),w=(r=>(r.bootstrapDataReceived="bootstrapDataReceived",r.optionsReceived="optionsReceived",r.started="started",r))(w||{}),O=["showCompletionPage"],F=["id.email","id.phone_number","id.first_name","id.last_name","id.dob","id.address_line1","id.address_line2","id.city","id.state","id.country","id.zip","id.ssn9","id.ssn4"];var u="application/x-postmate-v1+json",$=5,Y=0,z=function(){return ++Y};var J=function(e){var t=document.createElement("a");t.href=e;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},Z={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},v=function(e,t){return !(typeof t=="string"&&e.origin!==t||!e.data||typeof e.data=="object"&&!("postmate"in e.data)||e.data.type!==u||!Z[e.data.postmate])},G=function(e,t){var r=typeof e[t]=="function"?e[t]():e[t];return S.Promise.resolve(r)},Q=function(){function o(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(!v(n,r.childOrigin))return !1;var i=((n||{}).data||{}).value||{},a=i.data,p=i.name;n.data.postmate==="emit"&&p in r.events&&r.events[p].forEach(function(d){d.call(r,a);});},this.parent.addEventListener("message",this.listener,!1);}var e=o.prototype;return e.get=function(r){var n=this;return new S.Promise(function(i){var a=z(),p=function d(s){s.data.uid===a&&s.data.postmate==="reply"&&(n.parent.removeEventListener("message",d,!1),i(s.data.value));};n.parent.addEventListener("message",p,!1),n.child.postMessage({postmate:"request",type:u,property:r,uid:a},n.childOrigin);})},e.call=function(r,n){this.child.postMessage({postmate:"call",type:u,property:r,data:n},this.childOrigin);},e.on=function(r,n){this.events[r]||(this.events[r]=[]),this.events[r].push(n);},e.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},o}(),X=function(){function o(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(v(n,r.parentOrigin)){var i=n.data,a=i.property,p=i.uid,d=i.data;if(n.data.postmate==="call"){a in r.model&&typeof r.model[a]=="function"&&r.model[a](d);return}G(r.model,a).then(function(s){return n.source.postMessage({property:a,postmate:"reply",type:u,uid:p,value:s},n.origin)});}});}var e=o.prototype;return e.emit=function(r,n){this.parent.postMessage({postmate:"emit",type:u,value:{name:r,data:n}},this.parentOrigin);},o}(),S=function(){function o(t){var r=t.container,n=r===void 0?typeof n!="undefined"?n:document.body:r,i=t.model,a=t.url,p=t.name,d=p===void 0?"":p,s=t.allow,l=t.classListArray,y=l===void 0?[]:l;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=d||"",this.frame.classList.add.apply(this.frame.classList,y),s&&(this.frame.allow=s),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var e=o.prototype;return e.sendHandshake=function(r){var n=this,i=J(r),a=0,p;return new o.Promise(function(d,s){var l=function h(C){return v(C,i)?C.data.postmate==="handshake-reply"?(clearInterval(p),n.parent.removeEventListener("message",h,!1),n.childOrigin=C.origin,d(new Q(n))):s("Failed handshake"):!1};n.parent.addEventListener("message",l,!1);var y=function(){a++,n.child.postMessage({postmate:"handshake",type:u,model:n.model},i),a===$&&clearInterval(p);},f=function(){y(),p=setInterval(y,500);};n.frame.attachEvent?n.frame.attachEvent("onload",f):n.frame.addEventListener("load",f),n.frame.src=r;})},o}();S.debug=!1;S.Promise=function(){try{return window?window.Promise:Promise}catch(o){return null}}();S.Model=function(){function o(t){return this.child=window,this.model=t,this.parent=this.child.parent,this.sendHandshakeReply()}var e=o.prototype;return e.sendHandshakeReply=function(){var r=this;return new S.Promise(function(n,i){var a=function p(d){if(d.data.postmate){if(d.data.postmate==="handshake"){r.child.removeEventListener("message",p,!1),d.source.postMessage({postmate:"handshake-reply",type:u},d.origin),r.parentOrigin=d.origin;var s=d.data.model;return s&&Object.keys(s).forEach(function(l){r.model[l]=s[l];}),n(new X(r))}return i("Handshake Reply Failed")}};r.child.addEventListener("message",a,!1);})},o}();var k=S;var A="footprint-container",_="footprint-overlay",x="footprint-loading-indicator",g=o=>{if(!o)throw new Error("A container is required to create a Footprint button");let e=P();return o.appendChild(e),e},L=o=>{document.body.classList.add("footprint-body-locked");let e=document.createElement("div");e.setAttribute("id",_);let t=tt(x);e.appendChild(t),e.classList.add("footprint-overlay"),o.appendChild(e);},I=()=>{let o=document.getElementById(x);o&&o.remove();},R=()=>{document.body.classList.remove("footprint-body-locked");let o=document.getElementById(_);o&&o.remove();},N=()=>{let o=document.getElementById(A);if(o)return o;let e=document.createElement("div");return e.setAttribute("id",A),document.body.appendChild(e),e},tt=o=>{let e=document.createElement("div");e.setAttribute("id",o),e.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),e.appendChild(t),e},et=()=>{let o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("width","24px"),o.setAttribute("height","24px"),o.setAttribute("fill","none"),o.setAttribute("aria-hidden","true");let e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.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"),e.setAttribute("fill","#76fb8f"),o.appendChild(e),o},P=()=>{let o=et(),e=document.createElement("button");e.appendChild(o);let t=document.createElement("span");return t.innerText="Verify with Footprint",e.appendChild(t),e.classList.add("footprint-button"),e};var B=class{constructor(){this.child=null;this.handleIframeLoaded=()=>{var e,t;I(),(e=this.child)==null||e.frame.classList.remove("footprint-modal-loading"),(t=this.child)==null||t.frame.classList.add("footprint-modal-loaded");};}sendOptions(e){var t;e&&((t=this.child)==null||t.call("optionsReceived",e));}bootstrap(e){var t;e&&((t=this.child)==null||t.call("bootstrapDataReceived",e));}open(e,t,r){return c(this,null,function*(){let n=N();L(n),this.child=yield new k({classListArray:["footprint-modal","footprint-modal-loading"],container:n,name:"footprint-iframe",url:e,allow:"otp-credentials; publickey-credentials-get *; camera *;"}),this.handleIframeLoaded(),this.child.on("started",()=>{this.bootstrap(t),this.sendOptions(r);});})}on(e,t){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(e,t)}close(){R(),this.child&&this.child.destroy();}createButton(e){let t=P();return e.appendChild(t),t}},D=B;var H=o=>{let e="https://id.onefootprint.com",{publicKey:t,variables:r,rules:n,fontSrc:i}=o,a=new URLSearchParams;return t&&a.append("public_key",t),r&&a.append("tokens",r),n&&a.append("rules",n),i&&a.append("font_src",i),`${e}?${a.toString()}`},T=({fontSrc:o,variables:e={},rules:t={}}={})=>{let r=()=>Object.keys(e).length?encodeURIComponent(JSON.stringify(e)):void 0,n=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0;return {fontSrc:o,variables:r(),rules:n()}};var m=new D,b=!1,ot=()=>{let o=i=>m.on("completed",a=>{a&&typeof a=="string"&&i(a);}),e=i=>m.on("canceled",i),t=i=>m.on("closed",i),r=y=>c(void 0,[y],function*({appearance:i,onCanceled:a,onCompleted:p,publicKey:d,userData:s,options:l}){if(b)return;b=!0;let{fontSrc:f,rules:h,variables:C}=T(i),K=H({fontSrc:f,publicKey:d,rules:h,variables:C});yield m.open(K,s,l),p&&o(p),a&&e(a),t(n);}),n=()=>c(void 0,null,function*(){yield m.close(),b=!1;});return {open:r,close:n,createButton:g}},V=ot;var rt=o=>{window.setTimeout(o,0);},U=o=>typeof o=="function",nt=o=>typeof o=="object"&&!!o,it=o=>{if(typeof window=="undefined")return;let e=()=>{let i=window.footprintAppearance;if(!(!i||!nt(i)))return {fontSrc:i.fontSrc,rules:i.rules,theme:i.theme,variables:i.variables}},t=(i,a)=>{let p={};F.forEach(s=>{let l=a.getAttribute(`footprint-user-data-${s}`);l&&(p[s]=l);});let d={};O.forEach(s=>{let l=a.getAttribute(`footprint-option-${s}`);l&&(p[s]=l);}),o.open({publicKey:i,appearance:e(),onCanceled:()=>{var s;U(window.onFootprintCanceled)&&((s=window.onFootprintCanceled)==null||s.call(window));},onCompleted:s=>{var l;U(window.onFootprintCompleted)&&((l=window.onFootprintCompleted)==null||l.call(window,s));},userData:p,options:d});},r=()=>{let i=document.getElementById("footprint-button");if(!i)return;let a=i.getAttribute("data-public-key");if(!a)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");n(a,i);},n=(i,a)=>{rt(()=>{g(a).addEventListener("click",()=>{t(i,a);});});};document.addEventListener("DOMContentLoaded",()=>r());},M=it;var j=o=>c(void 0,null,function*(){let e=yield fetch("https://api.onefootprint.com/hosted/identify",{method:"POST",body:JSON.stringify(o)});if(!e.ok)throw Error(e.statusText);return (yield e.json()).user_found}),at=o=>c(void 0,null,function*(){if(!o)throw new Error("User data must be passed in order to identify an user");let e=o["id.email"],t=o["id.phone_number"];return e&&(yield j({identifier:{email:e}}))?!0:t?yield j({identifier:{phone_number:t}}):!1}),W=at;var q=V();M(q);var Nt=q;/*! Bundled license information: | ||
var c=(e,o,t)=>new Promise((r,n)=>{var i=d=>{try{p(t.next(d));}catch(s){n(s);}},a=d=>{try{p(t.throw(d));}catch(s){n(s);}},p=d=>d.done?r(d.value):Promise.resolve(d.value).then(i,a);p((t=t.apply(e,o)).next());});var E=(r=>(r.closed="closed",r.completed="completed",r.canceled="canceled",r))(E||{}),w=(r=>(r.bootstrapDataReceived="bootstrapDataReceived",r.optionsReceived="optionsReceived",r.started="started",r))(w||{}),O=["showCompletionPage"],F=["id.email","id.phone_number","id.first_name","id.last_name","id.dob","id.address_line1","id.address_line2","id.city","id.state","id.country","id.zip","id.ssn9","id.ssn4"];var u="application/x-postmate-v1+json",$=5,Y=0,z=function(){return ++Y};var J=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},Z={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},v=function(o,t){return !(typeof t=="string"&&o.origin!==t||!o.data||typeof o.data=="object"&&!("postmate"in o.data)||o.data.type!==u||!Z[o.data.postmate])},G=function(o,t){var r=typeof o[t]=="function"?o[t]():o[t];return S.Promise.resolve(r)},Q=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(!v(n,r.childOrigin))return !1;var i=((n||{}).data||{}).value||{},a=i.data,p=i.name;n.data.postmate==="emit"&&p in r.events&&r.events[p].forEach(function(d){d.call(r,a);});},this.parent.addEventListener("message",this.listener,!1);}var o=e.prototype;return o.get=function(r){var n=this;return new S.Promise(function(i){var a=z(),p=function d(s){s.data.uid===a&&s.data.postmate==="reply"&&(n.parent.removeEventListener("message",d,!1),i(s.data.value));};n.parent.addEventListener("message",p,!1),n.child.postMessage({postmate:"request",type:u,property:r,uid:a},n.childOrigin);})},o.call=function(r,n){this.child.postMessage({postmate:"call",type:u,property:r,data:n},this.childOrigin);},o.on=function(r,n){this.events[r]||(this.events[r]=[]),this.events[r].push(n);},o.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),X=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(v(n,r.parentOrigin)){var i=n.data,a=i.property,p=i.uid,d=i.data;if(n.data.postmate==="call"){a in r.model&&typeof r.model[a]=="function"&&r.model[a](d);return}G(r.model,a).then(function(s){return n.source.postMessage({property:a,postmate:"reply",type:u,uid:p,value:s},n.origin)});}});}var o=e.prototype;return o.emit=function(r,n){this.parent.postMessage({postmate:"emit",type:u,value:{name:r,data:n}},this.parentOrigin);},e}(),S=function(){function e(t){var r=t.container,n=r===void 0?typeof n!="undefined"?n:document.body:r,i=t.model,a=t.url,p=t.name,d=p===void 0?"":p,s=t.allow,l=t.classListArray,y=l===void 0?[]:l;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=d||"",this.frame.classList.add.apply(this.frame.classList,y),s&&(this.frame.allow=s),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var o=e.prototype;return o.sendHandshake=function(r){var n=this,i=J(r),a=0,p;return new e.Promise(function(d,s){var l=function h(C){return v(C,i)?C.data.postmate==="handshake-reply"?(clearInterval(p),n.parent.removeEventListener("message",h,!1),n.childOrigin=C.origin,d(new Q(n))):s("Failed handshake"):!1};n.parent.addEventListener("message",l,!1);var y=function(){a++,n.child.postMessage({postmate:"handshake",type:u,model:n.model},i),a===$&&clearInterval(p);},f=function(){y(),p=setInterval(y,500);};n.frame.attachEvent?n.frame.attachEvent("onload",f):n.frame.addEventListener("load",f),n.frame.src=r;})},e}();S.debug=!1;S.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();S.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 S.Promise(function(n,i){var a=function p(d){if(d.data.postmate){if(d.data.postmate==="handshake"){r.child.removeEventListener("message",p,!1),d.source.postMessage({postmate:"handshake-reply",type:u},d.origin),r.parentOrigin=d.origin;var s=d.data.model;return s&&Object.keys(s).forEach(function(l){r.model[l]=s[l];}),n(new X(r))}return i("Handshake Reply Failed")}};r.child.addEventListener("message",a,!1);})},e}();var k=S;var A="footprint-container",_="footprint-overlay",L="footprint-loading-indicator",g=e=>{if(!e)throw new Error("A container is required to create a Footprint button");let o=P();return e.appendChild(o),o},x=e=>{document.body.classList.add("footprint-body-locked");let o=document.createElement("div");o.setAttribute("id",_);let t=tt(L);o.appendChild(t),o.classList.add("footprint-overlay"),e.appendChild(o);},I=()=>{let e=document.getElementById(L);e&&e.remove();},R=()=>{document.body.classList.remove("footprint-body-locked");let e=document.getElementById(_);e&&e.remove();},N=()=>{let e=document.getElementById(A);if(e)return e;let o=document.createElement("div");return o.setAttribute("id",A),document.body.appendChild(o),o},tt=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},ot=()=>{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},P=()=>{let e=ot(),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=()=>{var o,t;I(),(o=this.child)==null||o.frame.classList.remove("footprint-modal-loading"),(t=this.child)==null||t.frame.classList.add("footprint-modal-loaded");};}sendOptions(o){var t;o&&((t=this.child)==null||t.call("optionsReceived",o));}bootstrap(o){var t;o&&((t=this.child)==null||t.call("bootstrapDataReceived",o));}open(o,t,r){return c(this,null,function*(){let n=N();x(n),this.child=yield new k({classListArray:["footprint-modal","footprint-modal-loading"],container:n,name:"footprint-iframe",url:o,allow:"otp-credentials; publickey-credentials-get *; camera *;"}),this.handleIframeLoaded(),this.child.on("started",()=>{this.bootstrap(t),this.sendOptions(r);});})}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(){R(),this.child&&this.child.destroy();}createButton(o){let t=P();return o.appendChild(t),t}},D=B;var H=e=>{let o="https://id.onefootprint.com",{publicKey:t,variables:r,rules:n,fontSrc:i}=e,a=new URLSearchParams;return t&&a.append("public_key",t),r&&a.append("tokens",r),n&&a.append("rules",n),i&&a.append("font_src",i),`${o}?${a.toString()}`},T=({fontSrc:e,variables:o={},rules:t={}}={})=>{let r=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0,n=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0;return {fontSrc:e,variables:r(),rules:n()}};var m=new D,b=!1,et=()=>{let e=i=>m.on("completed",a=>{a&&typeof a=="string"&&(i==null||i(a));}),o=i=>m.on("canceled",i),t=i=>m.on("closed",i),r=y=>c(void 0,[y],function*({appearance:i,onCanceled:a,onCompleted:p,publicKey:d,userData:s,options:l}){if(b)return;b=!0;let{fontSrc:f,rules:h,variables:C}=T(i),K=H({fontSrc:f,publicKey:d,rules:h,variables:C});yield m.open(K,s,l),e(p),o(()=>{a==null||a(),n();}),t(n);}),n=()=>c(void 0,null,function*(){yield m.close(),b=!1;});return {open:r,close:n,createButton:g}},V=et;var rt=e=>{window.setTimeout(e,0);},U=e=>typeof e=="function",nt=e=>typeof e=="object"&&!!e,it=e=>{if(typeof window=="undefined")return;let o=()=>{let i=window.footprintAppearance;if(!(!i||!nt(i)))return {fontSrc:i.fontSrc,rules:i.rules,theme:i.theme,variables:i.variables}},t=(i,a)=>{let p={};F.forEach(s=>{let l=a.getAttribute(`footprint-user-data-${s}`);l&&(p[s]=l);});let d={};O.forEach(s=>{let l=a.getAttribute(`footprint-option-${s}`);l&&(p[s]=l);}),e.open({publicKey:i,appearance:o(),onCanceled:()=>{var s;U(window.onFootprintCanceled)&&((s=window.onFootprintCanceled)==null||s.call(window));},onCompleted:s=>{var l;U(window.onFootprintCompleted)&&((l=window.onFootprintCompleted)==null||l.call(window,s));},userData:p,options:d});},r=()=>{let i=document.getElementById("footprint-button");if(!i)return;let a=i.getAttribute("data-public-key");if(!a)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");n(a,i);},n=(i,a)=>{rt(()=>{g(a).addEventListener("click",()=>{t(i,a);});});};document.addEventListener("DOMContentLoaded",()=>r());},M=it;var j=e=>c(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}),at=e=>c(void 0,null,function*(){if(!e)throw new Error("User data must be passed in order to identify an user");let o=e["id.email"],t=e["id.phone_number"];return o&&(yield j({identifier:{email:o}}))?!0:t?yield j({identifier:{phone_number:t}}):!1}),W=at;var q=V();M(q);var Nt=q;/*! Bundled license information: | ||
@@ -3,0 +3,0 @@ @onefootprint/postmate/build/postmate.es.js: |
(function (exports) { | ||
'use strict'; | ||
var c=(o,e,t)=>new Promise((r,n)=>{var i=d=>{try{p(t.next(d));}catch(s){n(s);}},a=d=>{try{p(t.throw(d));}catch(s){n(s);}},p=d=>d.done?r(d.value):Promise.resolve(d.value).then(i,a);p((t=t.apply(o,e)).next());});var E=(r=>(r.closed="closed",r.completed="completed",r.canceled="canceled",r))(E||{}),w=(r=>(r.bootstrapDataReceived="bootstrapDataReceived",r.optionsReceived="optionsReceived",r.started="started",r))(w||{}),O=["showCompletionPage"],F=["id.email","id.phone_number","id.first_name","id.last_name","id.dob","id.address_line1","id.address_line2","id.city","id.state","id.country","id.zip","id.ssn9","id.ssn4"];var u="application/x-postmate-v1+json",$=5,Y=0,z=function(){return ++Y};var J=function(e){var t=document.createElement("a");t.href=e;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},Z={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},v=function(e,t){return !(typeof t=="string"&&e.origin!==t||!e.data||typeof e.data=="object"&&!("postmate"in e.data)||e.data.type!==u||!Z[e.data.postmate])},G=function(e,t){var r=typeof e[t]=="function"?e[t]():e[t];return S.Promise.resolve(r)},Q=function(){function o(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(!v(n,r.childOrigin))return !1;var i=((n||{}).data||{}).value||{},a=i.data,p=i.name;n.data.postmate==="emit"&&p in r.events&&r.events[p].forEach(function(d){d.call(r,a);});},this.parent.addEventListener("message",this.listener,!1);}var e=o.prototype;return e.get=function(r){var n=this;return new S.Promise(function(i){var a=z(),p=function d(s){s.data.uid===a&&s.data.postmate==="reply"&&(n.parent.removeEventListener("message",d,!1),i(s.data.value));};n.parent.addEventListener("message",p,!1),n.child.postMessage({postmate:"request",type:u,property:r,uid:a},n.childOrigin);})},e.call=function(r,n){this.child.postMessage({postmate:"call",type:u,property:r,data:n},this.childOrigin);},e.on=function(r,n){this.events[r]||(this.events[r]=[]),this.events[r].push(n);},e.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},o}(),X=function(){function o(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(v(n,r.parentOrigin)){var i=n.data,a=i.property,p=i.uid,d=i.data;if(n.data.postmate==="call"){a in r.model&&typeof r.model[a]=="function"&&r.model[a](d);return}G(r.model,a).then(function(s){return n.source.postMessage({property:a,postmate:"reply",type:u,uid:p,value:s},n.origin)});}});}var e=o.prototype;return e.emit=function(r,n){this.parent.postMessage({postmate:"emit",type:u,value:{name:r,data:n}},this.parentOrigin);},o}(),S=function(){function o(t){var r=t.container,n=r===void 0?typeof n!="undefined"?n:document.body:r,i=t.model,a=t.url,p=t.name,d=p===void 0?"":p,s=t.allow,l=t.classListArray,y=l===void 0?[]:l;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=d||"",this.frame.classList.add.apply(this.frame.classList,y),s&&(this.frame.allow=s),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var e=o.prototype;return e.sendHandshake=function(r){var n=this,i=J(r),a=0,p;return new o.Promise(function(d,s){var l=function h(C){return v(C,i)?C.data.postmate==="handshake-reply"?(clearInterval(p),n.parent.removeEventListener("message",h,!1),n.childOrigin=C.origin,d(new Q(n))):s("Failed handshake"):!1};n.parent.addEventListener("message",l,!1);var y=function(){a++,n.child.postMessage({postmate:"handshake",type:u,model:n.model},i),a===$&&clearInterval(p);},f=function(){y(),p=setInterval(y,500);};n.frame.attachEvent?n.frame.attachEvent("onload",f):n.frame.addEventListener("load",f),n.frame.src=r;})},o}();S.debug=!1;S.Promise=function(){try{return window?window.Promise:Promise}catch(o){return null}}();S.Model=function(){function o(t){return this.child=window,this.model=t,this.parent=this.child.parent,this.sendHandshakeReply()}var e=o.prototype;return e.sendHandshakeReply=function(){var r=this;return new S.Promise(function(n,i){var a=function p(d){if(d.data.postmate){if(d.data.postmate==="handshake"){r.child.removeEventListener("message",p,!1),d.source.postMessage({postmate:"handshake-reply",type:u},d.origin),r.parentOrigin=d.origin;var s=d.data.model;return s&&Object.keys(s).forEach(function(l){r.model[l]=s[l];}),n(new X(r))}return i("Handshake Reply Failed")}};r.child.addEventListener("message",a,!1);})},o}();var k=S;var A="footprint-container",_="footprint-overlay",x="footprint-loading-indicator",g=o=>{if(!o)throw new Error("A container is required to create a Footprint button");let e=P();return o.appendChild(e),e},L=o=>{document.body.classList.add("footprint-body-locked");let e=document.createElement("div");e.setAttribute("id",_);let t=tt(x);e.appendChild(t),e.classList.add("footprint-overlay"),o.appendChild(e);},I=()=>{let o=document.getElementById(x);o&&o.remove();},R=()=>{document.body.classList.remove("footprint-body-locked");let o=document.getElementById(_);o&&o.remove();},N=()=>{let o=document.getElementById(A);if(o)return o;let e=document.createElement("div");return e.setAttribute("id",A),document.body.appendChild(e),e},tt=o=>{let e=document.createElement("div");e.setAttribute("id",o),e.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),e.appendChild(t),e},et=()=>{let o=document.createElementNS("http://www.w3.org/2000/svg","svg");o.setAttribute("width","24px"),o.setAttribute("height","24px"),o.setAttribute("fill","none"),o.setAttribute("aria-hidden","true");let e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.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"),e.setAttribute("fill","#76fb8f"),o.appendChild(e),o},P=()=>{let o=et(),e=document.createElement("button");e.appendChild(o);let t=document.createElement("span");return t.innerText="Verify with Footprint",e.appendChild(t),e.classList.add("footprint-button"),e};var B=class{constructor(){this.child=null;this.handleIframeLoaded=()=>{var e,t;I(),(e=this.child)==null||e.frame.classList.remove("footprint-modal-loading"),(t=this.child)==null||t.frame.classList.add("footprint-modal-loaded");};}sendOptions(e){var t;e&&((t=this.child)==null||t.call("optionsReceived",e));}bootstrap(e){var t;e&&((t=this.child)==null||t.call("bootstrapDataReceived",e));}open(e,t,r){return c(this,null,function*(){let n=N();L(n),this.child=yield new k({classListArray:["footprint-modal","footprint-modal-loading"],container:n,name:"footprint-iframe",url:e,allow:"otp-credentials; publickey-credentials-get *; camera *;"}),this.handleIframeLoaded(),this.child.on("started",()=>{this.bootstrap(t),this.sendOptions(r);});})}on(e,t){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(e,t)}close(){R(),this.child&&this.child.destroy();}createButton(e){let t=P();return e.appendChild(t),t}},D=B;var H=o=>{let e="https://id.onefootprint.com",{publicKey:t,variables:r,rules:n,fontSrc:i}=o,a=new URLSearchParams;return t&&a.append("public_key",t),r&&a.append("tokens",r),n&&a.append("rules",n),i&&a.append("font_src",i),`${e}?${a.toString()}`},T=({fontSrc:o,variables:e={},rules:t={}}={})=>{let r=()=>Object.keys(e).length?encodeURIComponent(JSON.stringify(e)):void 0,n=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0;return {fontSrc:o,variables:r(),rules:n()}};var m=new D,b=!1,ot=()=>{let o=i=>m.on("completed",a=>{a&&typeof a=="string"&&i(a);}),e=i=>m.on("canceled",i),t=i=>m.on("closed",i),r=y=>c(void 0,[y],function*({appearance:i,onCanceled:a,onCompleted:p,publicKey:d,userData:s,options:l}){if(b)return;b=!0;let{fontSrc:f,rules:h,variables:C}=T(i),K=H({fontSrc:f,publicKey:d,rules:h,variables:C});yield m.open(K,s,l),p&&o(p),a&&e(a),t(n);}),n=()=>c(void 0,null,function*(){yield m.close(),b=!1;});return {open:r,close:n,createButton:g}},V=ot;var rt=o=>{window.setTimeout(o,0);},U=o=>typeof o=="function",nt=o=>typeof o=="object"&&!!o,it=o=>{if(typeof window=="undefined")return;let e=()=>{let i=window.footprintAppearance;if(!(!i||!nt(i)))return {fontSrc:i.fontSrc,rules:i.rules,theme:i.theme,variables:i.variables}},t=(i,a)=>{let p={};F.forEach(s=>{let l=a.getAttribute(`footprint-user-data-${s}`);l&&(p[s]=l);});let d={};O.forEach(s=>{let l=a.getAttribute(`footprint-option-${s}`);l&&(p[s]=l);}),o.open({publicKey:i,appearance:e(),onCanceled:()=>{var s;U(window.onFootprintCanceled)&&((s=window.onFootprintCanceled)==null||s.call(window));},onCompleted:s=>{var l;U(window.onFootprintCompleted)&&((l=window.onFootprintCompleted)==null||l.call(window,s));},userData:p,options:d});},r=()=>{let i=document.getElementById("footprint-button");if(!i)return;let a=i.getAttribute("data-public-key");if(!a)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");n(a,i);},n=(i,a)=>{rt(()=>{g(a).addEventListener("click",()=>{t(i,a);});});};document.addEventListener("DOMContentLoaded",()=>r());},M=it;var j=o=>c(void 0,null,function*(){let e=yield fetch("https://api.onefootprint.com/hosted/identify",{method:"POST",body:JSON.stringify(o)});if(!e.ok)throw Error(e.statusText);return (yield e.json()).user_found}),at=o=>c(void 0,null,function*(){if(!o)throw new Error("User data must be passed in order to identify an user");let e=o["id.email"],t=o["id.phone_number"];return e&&(yield j({identifier:{email:e}}))?!0:t?yield j({identifier:{phone_number:t}}):!1}),W=at;var q=V();M(q);var Nt=q;/*! Bundled license information: | ||
var c=(e,o,t)=>new Promise((r,n)=>{var i=d=>{try{p(t.next(d));}catch(s){n(s);}},a=d=>{try{p(t.throw(d));}catch(s){n(s);}},p=d=>d.done?r(d.value):Promise.resolve(d.value).then(i,a);p((t=t.apply(e,o)).next());});var E=(r=>(r.closed="closed",r.completed="completed",r.canceled="canceled",r))(E||{}),w=(r=>(r.bootstrapDataReceived="bootstrapDataReceived",r.optionsReceived="optionsReceived",r.started="started",r))(w||{}),O=["showCompletionPage"],F=["id.email","id.phone_number","id.first_name","id.last_name","id.dob","id.address_line1","id.address_line2","id.city","id.state","id.country","id.zip","id.ssn9","id.ssn4"];var u="application/x-postmate-v1+json",$=5,Y=0,z=function(){return ++Y};var J=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},Z={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},v=function(o,t){return !(typeof t=="string"&&o.origin!==t||!o.data||typeof o.data=="object"&&!("postmate"in o.data)||o.data.type!==u||!Z[o.data.postmate])},G=function(o,t){var r=typeof o[t]=="function"?o[t]():o[t];return S.Promise.resolve(r)},Q=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(!v(n,r.childOrigin))return !1;var i=((n||{}).data||{}).value||{},a=i.data,p=i.name;n.data.postmate==="emit"&&p in r.events&&r.events[p].forEach(function(d){d.call(r,a);});},this.parent.addEventListener("message",this.listener,!1);}var o=e.prototype;return o.get=function(r){var n=this;return new S.Promise(function(i){var a=z(),p=function d(s){s.data.uid===a&&s.data.postmate==="reply"&&(n.parent.removeEventListener("message",d,!1),i(s.data.value));};n.parent.addEventListener("message",p,!1),n.child.postMessage({postmate:"request",type:u,property:r,uid:a},n.childOrigin);})},o.call=function(r,n){this.child.postMessage({postmate:"call",type:u,property:r,data:n},this.childOrigin);},o.on=function(r,n){this.events[r]||(this.events[r]=[]),this.events[r].push(n);},o.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),X=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(v(n,r.parentOrigin)){var i=n.data,a=i.property,p=i.uid,d=i.data;if(n.data.postmate==="call"){a in r.model&&typeof r.model[a]=="function"&&r.model[a](d);return}G(r.model,a).then(function(s){return n.source.postMessage({property:a,postmate:"reply",type:u,uid:p,value:s},n.origin)});}});}var o=e.prototype;return o.emit=function(r,n){this.parent.postMessage({postmate:"emit",type:u,value:{name:r,data:n}},this.parentOrigin);},e}(),S=function(){function e(t){var r=t.container,n=r===void 0?typeof n!="undefined"?n:document.body:r,i=t.model,a=t.url,p=t.name,d=p===void 0?"":p,s=t.allow,l=t.classListArray,y=l===void 0?[]:l;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=d||"",this.frame.classList.add.apply(this.frame.classList,y),s&&(this.frame.allow=s),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var o=e.prototype;return o.sendHandshake=function(r){var n=this,i=J(r),a=0,p;return new e.Promise(function(d,s){var l=function h(C){return v(C,i)?C.data.postmate==="handshake-reply"?(clearInterval(p),n.parent.removeEventListener("message",h,!1),n.childOrigin=C.origin,d(new Q(n))):s("Failed handshake"):!1};n.parent.addEventListener("message",l,!1);var y=function(){a++,n.child.postMessage({postmate:"handshake",type:u,model:n.model},i),a===$&&clearInterval(p);},f=function(){y(),p=setInterval(y,500);};n.frame.attachEvent?n.frame.attachEvent("onload",f):n.frame.addEventListener("load",f),n.frame.src=r;})},e}();S.debug=!1;S.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();S.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 S.Promise(function(n,i){var a=function p(d){if(d.data.postmate){if(d.data.postmate==="handshake"){r.child.removeEventListener("message",p,!1),d.source.postMessage({postmate:"handshake-reply",type:u},d.origin),r.parentOrigin=d.origin;var s=d.data.model;return s&&Object.keys(s).forEach(function(l){r.model[l]=s[l];}),n(new X(r))}return i("Handshake Reply Failed")}};r.child.addEventListener("message",a,!1);})},e}();var k=S;var A="footprint-container",_="footprint-overlay",L="footprint-loading-indicator",g=e=>{if(!e)throw new Error("A container is required to create a Footprint button");let o=P();return e.appendChild(o),o},x=e=>{document.body.classList.add("footprint-body-locked");let o=document.createElement("div");o.setAttribute("id",_);let t=tt(L);o.appendChild(t),o.classList.add("footprint-overlay"),e.appendChild(o);},I=()=>{let e=document.getElementById(L);e&&e.remove();},R=()=>{document.body.classList.remove("footprint-body-locked");let e=document.getElementById(_);e&&e.remove();},N=()=>{let e=document.getElementById(A);if(e)return e;let o=document.createElement("div");return o.setAttribute("id",A),document.body.appendChild(o),o},tt=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},ot=()=>{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},P=()=>{let e=ot(),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=()=>{var o,t;I(),(o=this.child)==null||o.frame.classList.remove("footprint-modal-loading"),(t=this.child)==null||t.frame.classList.add("footprint-modal-loaded");};}sendOptions(o){var t;o&&((t=this.child)==null||t.call("optionsReceived",o));}bootstrap(o){var t;o&&((t=this.child)==null||t.call("bootstrapDataReceived",o));}open(o,t,r){return c(this,null,function*(){let n=N();x(n),this.child=yield new k({classListArray:["footprint-modal","footprint-modal-loading"],container:n,name:"footprint-iframe",url:o,allow:"otp-credentials; publickey-credentials-get *; camera *;"}),this.handleIframeLoaded(),this.child.on("started",()=>{this.bootstrap(t),this.sendOptions(r);});})}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(){R(),this.child&&this.child.destroy();}createButton(o){let t=P();return o.appendChild(t),t}},D=B;var H=e=>{let o="https://id.onefootprint.com",{publicKey:t,variables:r,rules:n,fontSrc:i}=e,a=new URLSearchParams;return t&&a.append("public_key",t),r&&a.append("tokens",r),n&&a.append("rules",n),i&&a.append("font_src",i),`${o}?${a.toString()}`},T=({fontSrc:e,variables:o={},rules:t={}}={})=>{let r=()=>Object.keys(o).length?encodeURIComponent(JSON.stringify(o)):void 0,n=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0;return {fontSrc:e,variables:r(),rules:n()}};var m=new D,b=!1,et=()=>{let e=i=>m.on("completed",a=>{a&&typeof a=="string"&&(i==null||i(a));}),o=i=>m.on("canceled",i),t=i=>m.on("closed",i),r=y=>c(void 0,[y],function*({appearance:i,onCanceled:a,onCompleted:p,publicKey:d,userData:s,options:l}){if(b)return;b=!0;let{fontSrc:f,rules:h,variables:C}=T(i),K=H({fontSrc:f,publicKey:d,rules:h,variables:C});yield m.open(K,s,l),e(p),o(()=>{a==null||a(),n();}),t(n);}),n=()=>c(void 0,null,function*(){yield m.close(),b=!1;});return {open:r,close:n,createButton:g}},V=et;var rt=e=>{window.setTimeout(e,0);},U=e=>typeof e=="function",nt=e=>typeof e=="object"&&!!e,it=e=>{if(typeof window=="undefined")return;let o=()=>{let i=window.footprintAppearance;if(!(!i||!nt(i)))return {fontSrc:i.fontSrc,rules:i.rules,theme:i.theme,variables:i.variables}},t=(i,a)=>{let p={};F.forEach(s=>{let l=a.getAttribute(`footprint-user-data-${s}`);l&&(p[s]=l);});let d={};O.forEach(s=>{let l=a.getAttribute(`footprint-option-${s}`);l&&(p[s]=l);}),e.open({publicKey:i,appearance:o(),onCanceled:()=>{var s;U(window.onFootprintCanceled)&&((s=window.onFootprintCanceled)==null||s.call(window));},onCompleted:s=>{var l;U(window.onFootprintCompleted)&&((l=window.onFootprintCompleted)==null||l.call(window,s));},userData:p,options:d});},r=()=>{let i=document.getElementById("footprint-button");if(!i)return;let a=i.getAttribute("data-public-key");if(!a)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");n(a,i);},n=(i,a)=>{rt(()=>{g(a).addEventListener("click",()=>{t(i,a);});});};document.addEventListener("DOMContentLoaded",()=>r());},M=it;var j=e=>c(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}),at=e=>c(void 0,null,function*(){if(!e)throw new Error("User data must be passed in order to identify an user");let o=e["id.email"],t=e["id.phone_number"];return o&&(yield j({identifier:{email:o}}))?!0:t?yield j({identifier:{phone_number:t}}):!1}),W=at;var q=V();M(q);var Nt=q;/*! Bundled license information: | ||
@@ -6,0 +6,0 @@ @onefootprint/postmate/build/postmate.es.js: |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"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
43425
360