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 0.2.0 to 0.3.0

6

dist/footprint-js.cjs.js

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

"use strict";var y=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var F=(t,e)=>{for(var n in e)y(t,n,{get:e[n],enumerable:!0})},S=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of M(e))!D.call(t,o)&&o!==n&&y(t,o,{get:()=>e[o],enumerable:!(r=P(e,o))||r.enumerable});return t};var V=t=>S(y({},"__esModule",{value:!0}),t);var J={};F(J,{default:()=>Z});module.exports=V(J);var w="footprint-container",E="footprint-overlay",b="footprint-loading-indicator",f=typeof window>"u";var R=t=>{window.setTimeout(t,0)},T=t=>{let e=async()=>{await t.show({onUserCanceled:()=>{var i;(i=window.onFootprintCanceled)==null||i.call(window)},onCompleted:i=>{var a;(a=window.onFootprintCompleted)==null||a.call(window,i)}})},n=()=>{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");r(a,i)},r=(i,a)=>{t.init({publicKey:i}),R(()=>{t.createButton(a).addEventListener("click",()=>{e()})})},o=()=>{f||document.addEventListener("DOMContentLoaded",()=>n())};return()=>{o()}},x=T;var u=class{constructor(t,e){this.url=t;this.uiManager=e;this.publicKey=null;this.flow="authentication"}init(t={}){t.publicKey&&(this.flow="onboarding",this.publicKey=t.publicKey)}onAuthenticated(t){return this.uiManager.on("authenticated",e=>{e&&typeof e=="string"&&t(e)})}onCompleted(t){return this.uiManager.on("completed",e=>{e&&typeof e=="string"&&t(e)})}onUserCanceled(t){return this.uiManager.on("userCanceled",t)}async show(t={}){let e=new URLSearchParams;e.append("flow",this.flow),this.publicKey&&e.append("public_key",this.publicKey),await this.uiManager.show({url:`${this.url}?${e.toString()}`}),t.onAuthenticated&&this.onAuthenticated(t.onAuthenticated),t.onCompleted&&this.onCompleted(t.onCompleted),t.onUserCanceled&&this.onUserCanceled(t.onUserCanceled)}createButton(t){return this.uiManager.createButton(t)}};var p="application/x-postmate-v1+json",B=5,H=0,U=function(){return++H};var K=function(e){var n=document.createElement("a");n.href=e;var r=n.protocol.length>4?n.protocol:window.location.protocol,o=n.host.length?n.port==="80"||n.port==="443"?n.hostname:n.host:window.location.host;return n.origin||r+"//"+o},j={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},C=function(e,n){return!(typeof n=="string"&&e.origin!==n||!e.data||typeof e.data=="object"&&!("postmate"in e.data)||e.data.type!==p||!j[e.data.postmate])},$=function(e,n){var r=typeof e[n]=="function"?e[n]():e[n];return c.Promise.resolve(r)},z=function(){function t(n){var r=this;this.parent=n.parent,this.frame=n.frame,this.child=n.child,this.childOrigin=n.childOrigin,this.events={},this.listener=function(o){if(!C(o,r.childOrigin))return!1;var i=((o||{}).data||{}).value||{},a=i.data,d=i.name;o.data.postmate==="emit"&&d in r.events&&r.events[d].call(r,a)},this.parent.addEventListener("message",this.listener,!1)}var e=t.prototype;return e.get=function(r){var o=this;return new c.Promise(function(i){var a=U(),d=function s(l){l.data.uid===a&&l.data.postmate==="reply"&&(o.parent.removeEventListener("message",s,!1),i(l.data.value))};o.parent.addEventListener("message",d,!1),o.child.postMessage({postmate:"request",type:p,property:r,uid:a},o.childOrigin)})},e.call=function(r,o){this.child.postMessage({postmate:"call",type:p,property:r,data:o},this.childOrigin)},e.on=function(r,o){this.events[r]=o},e.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},t}(),q=function(){function t(n){var r=this;this.model=n.model,this.parent=n.parent,this.parentOrigin=n.parentOrigin,this.child=n.child,this.child.addEventListener("message",function(o){if(!!C(o,r.parentOrigin)){var i=o.data,a=i.property,d=i.uid,s=i.data;if(o.data.postmate==="call"){a in r.model&&typeof r.model[a]=="function"&&r.model[a](s);return}$(r.model,a).then(function(l){return o.source.postMessage({property:a,postmate:"reply",type:p,uid:d,value:l},o.origin)})}})}var e=t.prototype;return e.emit=function(r,o){this.parent.postMessage({postmate:"emit",type:p,value:{name:r,data:o}},this.parentOrigin)},t}(),c=function(){function t(n){var r=n.container,o=r===void 0?typeof o<"u"?o:document.body:r,i=n.model,a=n.url,d=n.name,s=n.classListArray,l=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,l),o.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var e=t.prototype;return e.sendHandshake=function(r){var o=this,i=K(r),a=0,d;return new t.Promise(function(s,l){var h=function g(v){return C(v,i)?v.data.postmate==="handshake-reply"?(clearInterval(d),o.parent.removeEventListener("message",g,!1),o.childOrigin=v.origin,s(new z(o))):l("Failed handshake"):!1};o.parent.addEventListener("message",h,!1);var O=function(){a++,o.child.postMessage({postmate:"handshake",type:p,model:o.model},i),a===B&&clearInterval(d)},I=function(){O(),d=setInterval(O,500)};o.frame.attachEvent?o.frame.attachEvent("onload",I):o.frame.onload=I,o.frame.src=r})},t}();c.debug=!1;c.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}();c.Model=function(){function t(n){return this.child=window,this.model=n,this.parent=this.child.parent,this.sendHandshakeReply()}var e=t.prototype;return e.sendHandshakeReply=function(){var r=this;return new c.Promise(function(o,i){var a=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:p},s.origin),r.parentOrigin=s.origin;var l=s.data.model;return l&&Object.keys(l).forEach(function(h){r.model[h]=l[h]}),o(new q(r))}return i("Handshake Reply Failed")}};r.child.addEventListener("message",a,!1)})},t}();var L=c;var _=()=>{let t=document.createElement("style");t.type="text/css",t.innerHTML=`
"use strict";var y=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var F=(t,e)=>{for(var n in e)y(t,n,{get:e[n],enumerable:!0})},S=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of M(e))!D.call(t,o)&&o!==n&&y(t,o,{get:()=>e[o],enumerable:!(i=P(e,o))||i.enumerable});return t};var V=t=>S(y({},"__esModule",{value:!0}),t);var J={};F(J,{default:()=>Z});module.exports=V(J);var w="footprint-container",E="footprint-overlay",b="footprint-loading-indicator",f=typeof window>"u";var R=t=>{window.setTimeout(t,0)},T=t=>{let e=async()=>{await t.show({onUserCanceled:()=>{var r;(r=window.onFootprintCanceled)==null||r.call(window)},onCompleted:r=>{var a;(a=window.onFootprintCompleted)==null||a.call(window,r)}})},n=()=>{let r=document.getElementById("footprint-button");if(!r)return;let a=r.getAttribute("data-public-key");if(!a)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");i(a,r)},i=(r,a)=>{t.init({publicKey:r}),R(()=>{t.createButton(a).addEventListener("click",()=>{e()})})},o=()=>{f||document.addEventListener("DOMContentLoaded",()=>n())};return()=>{o()}},x=T;var u=class{constructor(t,e){this.url=t;this.uiManager=e;this.publicKey=null;this.flow="authentication"}init(t={}){t.publicKey&&(this.flow="onboarding",this.publicKey=t.publicKey)}onAuthenticated(t){return this.uiManager.on("authenticated",e=>{e&&typeof e=="string"&&t(e)})}onCompleted(t){return this.uiManager.on("completed",e=>{e&&typeof e=="string"&&t(e)})}onUserCanceled(t){return this.uiManager.on("userCanceled",t)}async show(t={}){let e=new URLSearchParams;e.append("flow",this.flow),this.publicKey&&e.append("public_key",this.publicKey),await this.uiManager.show({url:`${this.url}?${e.toString()}`}),t.onAuthenticated&&this.onAuthenticated(t.onAuthenticated),t.onCompleted&&this.onCompleted(t.onCompleted),t.onUserCanceled&&this.onUserCanceled(t.onUserCanceled)}createButton(t){return this.uiManager.createButton(t)}};var p="application/x-postmate-v1+json",B=5,H=0,U=function(){return++H};var K=function(e){var n=document.createElement("a");n.href=e;var i=n.protocol.length>4?n.protocol:window.location.protocol,o=n.host.length?n.port==="80"||n.port==="443"?n.hostname:n.host:window.location.host;return n.origin||i+"//"+o},j={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},C=function(e,n){return!(typeof n=="string"&&e.origin!==n||!e.data||typeof e.data=="object"&&!("postmate"in e.data)||e.data.type!==p||!j[e.data.postmate])},$=function(e,n){var i=typeof e[n]=="function"?e[n]():e[n];return c.Promise.resolve(i)},z=function(){function t(n){var i=this;this.parent=n.parent,this.frame=n.frame,this.child=n.child,this.childOrigin=n.childOrigin,this.events={},this.listener=function(o){if(!C(o,i.childOrigin))return!1;var r=((o||{}).data||{}).value||{},a=r.data,d=r.name;o.data.postmate==="emit"&&d in i.events&&i.events[d].call(i,a)},this.parent.addEventListener("message",this.listener,!1)}var e=t.prototype;return e.get=function(i){var o=this;return new c.Promise(function(r){var a=U(),d=function s(l){l.data.uid===a&&l.data.postmate==="reply"&&(o.parent.removeEventListener("message",s,!1),r(l.data.value))};o.parent.addEventListener("message",d,!1),o.child.postMessage({postmate:"request",type:p,property:i,uid:a},o.childOrigin)})},e.call=function(i,o){this.child.postMessage({postmate:"call",type:p,property:i,data:o},this.childOrigin)},e.on=function(i,o){this.events[i]=o},e.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},t}(),q=function(){function t(n){var i=this;this.model=n.model,this.parent=n.parent,this.parentOrigin=n.parentOrigin,this.child=n.child,this.child.addEventListener("message",function(o){if(!!C(o,i.parentOrigin)){var r=o.data,a=r.property,d=r.uid,s=r.data;if(o.data.postmate==="call"){a in i.model&&typeof i.model[a]=="function"&&i.model[a](s);return}$(i.model,a).then(function(l){return o.source.postMessage({property:a,postmate:"reply",type:p,uid:d,value:l},o.origin)})}})}var e=t.prototype;return e.emit=function(i,o){this.parent.postMessage({postmate:"emit",type:p,value:{name:i,data:o}},this.parentOrigin)},t}(),c=function(){function t(n){var i=n.container,o=i===void 0?typeof o<"u"?o:document.body:i,r=n.model,a=n.url,d=n.name,s=n.classListArray,l=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,l),o.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=r||{},this.sendHandshake(a)}var e=t.prototype;return e.sendHandshake=function(i){var o=this,r=K(i),a=0,d;return new t.Promise(function(s,l){var h=function g(v){return C(v,r)?v.data.postmate==="handshake-reply"?(clearInterval(d),o.parent.removeEventListener("message",g,!1),o.childOrigin=v.origin,s(new z(o))):l("Failed handshake"):!1};o.parent.addEventListener("message",h,!1);var O=function(){a++,o.child.postMessage({postmate:"handshake",type:p,model:o.model},r),a===B&&clearInterval(d)},I=function(){O(),d=setInterval(O,500)};o.frame.attachEvent?o.frame.attachEvent("onload",I):o.frame.onload=I,o.frame.src=i})},t}();c.debug=!1;c.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}();c.Model=function(){function t(n){return this.child=window,this.model=n,this.parent=this.child.parent,this.sendHandshakeReply()}var e=t.prototype;return e.sendHandshakeReply=function(){var i=this;return new c.Promise(function(o,r){var a=function d(s){if(!!s.data.postmate){if(s.data.postmate==="handshake"){i.child.removeEventListener("message",d,!1),s.source.postMessage({postmate:"handshake-reply",type:p},s.origin),i.parentOrigin=s.origin;var l=s.data.model;return l&&Object.keys(l).forEach(function(h){i.model[h]=l[h]}),o(new q(i))}return r("Handshake Reply Failed")}};i.child.addEventListener("message",a,!1)})},t}();var L=c;var _=()=>{let t=document.createElement("style");t.type="text/css",t.innerHTML=`
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@500&display=swap');
.footprint-body-locked {

@@ -80,3 +82,3 @@ overflow: hidden;

}
`,document.head.appendChild(t)},A=t=>{let e=document.createElement("div");e.setAttribute("id",t),e.classList.add("footprint-loading-indicator");let n=document.createElement("div");n.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 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"),o.setAttribute("fill","#FFFFFF"),r.appendChild(o),n.appendChild(r),e.appendChild(n),e},G=()=>{let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("width","24px"),t.setAttribute("height","24px"),t.setAttribute("fill","none"),t.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"),t.appendChild(e),t},N=()=>{let t=G(),e=document.createElement("button");e.appendChild(t);let n=document.createElement("span");return n.innerText="Verify with Footprint",e.appendChild(n),e.classList.add("footprint-button"),e};var m=class{constructor(){this.child=null;f||_()}async show({url:t}){let e=()=>{let o=document.getElementById(b);o&&o.remove()},n=this.createContainer();this.showOverlay(n);let r=await new L({classListArray:["footprint-modal"],container:n,name:"footprint-iframe",url:t});r.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *"),e(),r.on("closed",()=>this.hide()),this.child=r}on(t,e){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(t,e)}hide(){this.hideOverlay(),this.child&&this.child.destroy()}createButton(t){let e=N();return t.appendChild(e),e}showOverlay(t){document.body.classList.add("footprint-body-locked");let e=document.createElement("div");e.setAttribute("id",E);let n=A(b);e.appendChild(n),e.classList.add("footprint-overlay"),t.appendChild(e)}hideOverlay(){document.body.classList.remove("footprint-body-locked");let t=document.getElementById(E);t&&t.remove()}createContainer(){let t=document.getElementById(w);if(t)return t;let e=document.createElement("div");return e.setAttribute("id",w),document.body.appendChild(e),e}};var W=(t="production",e)=>t==="local"?"http://localhost:3000/":t==="development"?"https://id.preview.onefootprint.com":t==="preview"&&e?e==="development"?"https://id.preview.onefootprint.com":`https://bifrost-git-${e.toLowerCase().split("/").join("-")}.preview.onefootprint.com`:"https://id.onefootprint.com",X=W("",""),Y=new m,k=new u(X,Y);x(k)();var Z=k;0&&(module.exports={});
`,document.head.appendChild(t)},A=t=>{let e=document.createElement("div");e.setAttribute("id",t),e.classList.add("footprint-loading-indicator");let n=document.createElement("div");n.classList.add("footprint-loading-spin");let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width","24px"),i.setAttribute("height","24px"),i.setAttribute("fill","none"),i.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"),o.setAttribute("fill","#FFFFFF"),i.appendChild(o),n.appendChild(i),e.appendChild(n),e},G=()=>{let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("width","24px"),t.setAttribute("height","24px"),t.setAttribute("fill","none"),t.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"),t.appendChild(e),t},N=()=>{let t=G(),e=document.createElement("button");e.appendChild(t);let n=document.createElement("span");return n.innerText="Verify with Footprint",e.appendChild(n),e.classList.add("footprint-button"),e};var m=class{constructor(){this.child=null;f||_()}async show({url:t}){let e=()=>{let o=document.getElementById(b);o&&o.remove()},n=this.createContainer();this.showOverlay(n);let i=await new L({classListArray:["footprint-modal"],container:n,name:"footprint-iframe",url:t});i.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),e(),i.on("closed",()=>this.hide()),this.child=i}on(t,e){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(t,e)}hide(){this.hideOverlay(),this.child&&this.child.destroy()}createButton(t){let e=N();return t.appendChild(e),e}showOverlay(t){document.body.classList.add("footprint-body-locked");let e=document.createElement("div");e.setAttribute("id",E);let n=A(b);e.appendChild(n),e.classList.add("footprint-overlay"),t.appendChild(e)}hideOverlay(){document.body.classList.remove("footprint-body-locked");let t=document.getElementById(E);t&&t.remove()}createContainer(){let t=document.getElementById(w);if(t)return t;let e=document.createElement("div");return e.setAttribute("id",w),document.body.appendChild(e),e}};var W=(t="production",e)=>t==="local"?"http://localhost:3000/":t==="development"?"https://id.preview.onefootprint.com":t==="preview"&&e?e==="development"?"https://id.preview.onefootprint.com":`https://bifrost-git-${e.toLowerCase().split("/").join("-")}.preview.onefootprint.com`:"https://id.onefootprint.com",X=W("production",""),Y=new m,k=new u(X,Y);x(k)();var Z=k;0&&(module.exports={});
/**

@@ -83,0 +85,0 @@ postmate - A powerful, simple, promise-based postMessage library

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

var y="footprint-container",w="footprint-overlay",E="footprint-loading-indicator",f=typeof window>"u";var k=t=>{window.setTimeout(t,0)},P=t=>{let e=async()=>{await t.show({onUserCanceled:()=>{var i;(i=window.onFootprintCanceled)==null||i.call(window)},onCompleted:i=>{var a;(a=window.onFootprintCompleted)==null||a.call(window,i)}})},n=()=>{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");r(a,i)},r=(i,a)=>{t.init({publicKey:i}),k(()=>{t.createButton(a).addEventListener("click",()=>{e()})})},o=()=>{f||document.addEventListener("DOMContentLoaded",()=>n())};return()=>{o()}},I=P;var u=class{constructor(t,e){this.url=t;this.uiManager=e;this.publicKey=null;this.flow="authentication"}init(t={}){t.publicKey&&(this.flow="onboarding",this.publicKey=t.publicKey)}onAuthenticated(t){return this.uiManager.on("authenticated",e=>{e&&typeof e=="string"&&t(e)})}onCompleted(t){return this.uiManager.on("completed",e=>{e&&typeof e=="string"&&t(e)})}onUserCanceled(t){return this.uiManager.on("userCanceled",t)}async show(t={}){let e=new URLSearchParams;e.append("flow",this.flow),this.publicKey&&e.append("public_key",this.publicKey),await this.uiManager.show({url:`${this.url}?${e.toString()}`}),t.onAuthenticated&&this.onAuthenticated(t.onAuthenticated),t.onCompleted&&this.onCompleted(t.onCompleted),t.onUserCanceled&&this.onUserCanceled(t.onUserCanceled)}createButton(t){return this.uiManager.createButton(t)}};var p="application/x-postmate-v1+json",M=5,D=0,F=function(){return++D};var S=function(e){var n=document.createElement("a");n.href=e;var r=n.protocol.length>4?n.protocol:window.location.protocol,o=n.host.length?n.port==="80"||n.port==="443"?n.hostname:n.host:window.location.host;return n.origin||r+"//"+o},V={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},b=function(e,n){return!(typeof n=="string"&&e.origin!==n||!e.data||typeof e.data=="object"&&!("postmate"in e.data)||e.data.type!==p||!V[e.data.postmate])},R=function(e,n){var r=typeof e[n]=="function"?e[n]():e[n];return c.Promise.resolve(r)},T=function(){function t(n){var r=this;this.parent=n.parent,this.frame=n.frame,this.child=n.child,this.childOrigin=n.childOrigin,this.events={},this.listener=function(o){if(!b(o,r.childOrigin))return!1;var i=((o||{}).data||{}).value||{},a=i.data,d=i.name;o.data.postmate==="emit"&&d in r.events&&r.events[d].call(r,a)},this.parent.addEventListener("message",this.listener,!1)}var e=t.prototype;return e.get=function(r){var o=this;return new c.Promise(function(i){var a=F(),d=function s(l){l.data.uid===a&&l.data.postmate==="reply"&&(o.parent.removeEventListener("message",s,!1),i(l.data.value))};o.parent.addEventListener("message",d,!1),o.child.postMessage({postmate:"request",type:p,property:r,uid:a},o.childOrigin)})},e.call=function(r,o){this.child.postMessage({postmate:"call",type:p,property:r,data:o},this.childOrigin)},e.on=function(r,o){this.events[r]=o},e.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},t}(),B=function(){function t(n){var r=this;this.model=n.model,this.parent=n.parent,this.parentOrigin=n.parentOrigin,this.child=n.child,this.child.addEventListener("message",function(o){if(!!b(o,r.parentOrigin)){var i=o.data,a=i.property,d=i.uid,s=i.data;if(o.data.postmate==="call"){a in r.model&&typeof r.model[a]=="function"&&r.model[a](s);return}R(r.model,a).then(function(l){return o.source.postMessage({property:a,postmate:"reply",type:p,uid:d,value:l},o.origin)})}})}var e=t.prototype;return e.emit=function(r,o){this.parent.postMessage({postmate:"emit",type:p,value:{name:r,data:o}},this.parentOrigin)},t}(),c=function(){function t(n){var r=n.container,o=r===void 0?typeof o<"u"?o:document.body:r,i=n.model,a=n.url,d=n.name,s=n.classListArray,l=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,l),o.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var e=t.prototype;return e.sendHandshake=function(r){var o=this,i=S(r),a=0,d;return new t.Promise(function(s,l){var h=function g(v){return b(v,i)?v.data.postmate==="handshake-reply"?(clearInterval(d),o.parent.removeEventListener("message",g,!1),o.childOrigin=v.origin,s(new T(o))):l("Failed handshake"):!1};o.parent.addEventListener("message",h,!1);var C=function(){a++,o.child.postMessage({postmate:"handshake",type:p,model:o.model},i),a===M&&clearInterval(d)},O=function(){C(),d=setInterval(C,500)};o.frame.attachEvent?o.frame.attachEvent("onload",O):o.frame.onload=O,o.frame.src=r})},t}();c.debug=!1;c.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}();c.Model=function(){function t(n){return this.child=window,this.model=n,this.parent=this.child.parent,this.sendHandshakeReply()}var e=t.prototype;return e.sendHandshakeReply=function(){var r=this;return new c.Promise(function(o,i){var a=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:p},s.origin),r.parentOrigin=s.origin;var l=s.data.model;return l&&Object.keys(l).forEach(function(h){r.model[h]=l[h]}),o(new B(r))}return i("Handshake Reply Failed")}};r.child.addEventListener("message",a,!1)})},t}();var x=c;var L=()=>{let t=document.createElement("style");t.type="text/css",t.innerHTML=`
var y="footprint-container",w="footprint-overlay",E="footprint-loading-indicator",f=typeof window>"u";var k=t=>{window.setTimeout(t,0)},P=t=>{let e=async()=>{await t.show({onUserCanceled:()=>{var r;(r=window.onFootprintCanceled)==null||r.call(window)},onCompleted:r=>{var a;(a=window.onFootprintCompleted)==null||a.call(window,r)}})},n=()=>{let r=document.getElementById("footprint-button");if(!r)return;let a=r.getAttribute("data-public-key");if(!a)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");i(a,r)},i=(r,a)=>{t.init({publicKey:r}),k(()=>{t.createButton(a).addEventListener("click",()=>{e()})})},o=()=>{f||document.addEventListener("DOMContentLoaded",()=>n())};return()=>{o()}},I=P;var u=class{constructor(t,e){this.url=t;this.uiManager=e;this.publicKey=null;this.flow="authentication"}init(t={}){t.publicKey&&(this.flow="onboarding",this.publicKey=t.publicKey)}onAuthenticated(t){return this.uiManager.on("authenticated",e=>{e&&typeof e=="string"&&t(e)})}onCompleted(t){return this.uiManager.on("completed",e=>{e&&typeof e=="string"&&t(e)})}onUserCanceled(t){return this.uiManager.on("userCanceled",t)}async show(t={}){let e=new URLSearchParams;e.append("flow",this.flow),this.publicKey&&e.append("public_key",this.publicKey),await this.uiManager.show({url:`${this.url}?${e.toString()}`}),t.onAuthenticated&&this.onAuthenticated(t.onAuthenticated),t.onCompleted&&this.onCompleted(t.onCompleted),t.onUserCanceled&&this.onUserCanceled(t.onUserCanceled)}createButton(t){return this.uiManager.createButton(t)}};var p="application/x-postmate-v1+json",M=5,D=0,F=function(){return++D};var S=function(e){var n=document.createElement("a");n.href=e;var i=n.protocol.length>4?n.protocol:window.location.protocol,o=n.host.length?n.port==="80"||n.port==="443"?n.hostname:n.host:window.location.host;return n.origin||i+"//"+o},V={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},b=function(e,n){return!(typeof n=="string"&&e.origin!==n||!e.data||typeof e.data=="object"&&!("postmate"in e.data)||e.data.type!==p||!V[e.data.postmate])},R=function(e,n){var i=typeof e[n]=="function"?e[n]():e[n];return c.Promise.resolve(i)},T=function(){function t(n){var i=this;this.parent=n.parent,this.frame=n.frame,this.child=n.child,this.childOrigin=n.childOrigin,this.events={},this.listener=function(o){if(!b(o,i.childOrigin))return!1;var r=((o||{}).data||{}).value||{},a=r.data,d=r.name;o.data.postmate==="emit"&&d in i.events&&i.events[d].call(i,a)},this.parent.addEventListener("message",this.listener,!1)}var e=t.prototype;return e.get=function(i){var o=this;return new c.Promise(function(r){var a=F(),d=function s(l){l.data.uid===a&&l.data.postmate==="reply"&&(o.parent.removeEventListener("message",s,!1),r(l.data.value))};o.parent.addEventListener("message",d,!1),o.child.postMessage({postmate:"request",type:p,property:i,uid:a},o.childOrigin)})},e.call=function(i,o){this.child.postMessage({postmate:"call",type:p,property:i,data:o},this.childOrigin)},e.on=function(i,o){this.events[i]=o},e.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},t}(),B=function(){function t(n){var i=this;this.model=n.model,this.parent=n.parent,this.parentOrigin=n.parentOrigin,this.child=n.child,this.child.addEventListener("message",function(o){if(!!b(o,i.parentOrigin)){var r=o.data,a=r.property,d=r.uid,s=r.data;if(o.data.postmate==="call"){a in i.model&&typeof i.model[a]=="function"&&i.model[a](s);return}R(i.model,a).then(function(l){return o.source.postMessage({property:a,postmate:"reply",type:p,uid:d,value:l},o.origin)})}})}var e=t.prototype;return e.emit=function(i,o){this.parent.postMessage({postmate:"emit",type:p,value:{name:i,data:o}},this.parentOrigin)},t}(),c=function(){function t(n){var i=n.container,o=i===void 0?typeof o<"u"?o:document.body:i,r=n.model,a=n.url,d=n.name,s=n.classListArray,l=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,l),o.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=r||{},this.sendHandshake(a)}var e=t.prototype;return e.sendHandshake=function(i){var o=this,r=S(i),a=0,d;return new t.Promise(function(s,l){var h=function g(v){return b(v,r)?v.data.postmate==="handshake-reply"?(clearInterval(d),o.parent.removeEventListener("message",g,!1),o.childOrigin=v.origin,s(new T(o))):l("Failed handshake"):!1};o.parent.addEventListener("message",h,!1);var C=function(){a++,o.child.postMessage({postmate:"handshake",type:p,model:o.model},r),a===M&&clearInterval(d)},O=function(){C(),d=setInterval(C,500)};o.frame.attachEvent?o.frame.attachEvent("onload",O):o.frame.onload=O,o.frame.src=i})},t}();c.debug=!1;c.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}();c.Model=function(){function t(n){return this.child=window,this.model=n,this.parent=this.child.parent,this.sendHandshakeReply()}var e=t.prototype;return e.sendHandshakeReply=function(){var i=this;return new c.Promise(function(o,r){var a=function d(s){if(!!s.data.postmate){if(s.data.postmate==="handshake"){i.child.removeEventListener("message",d,!1),s.source.postMessage({postmate:"handshake-reply",type:p},s.origin),i.parentOrigin=s.origin;var l=s.data.model;return l&&Object.keys(l).forEach(function(h){i.model[h]=l[h]}),o(new B(i))}return r("Handshake Reply Failed")}};i.child.addEventListener("message",a,!1)})},t}();var x=c;var L=()=>{let t=document.createElement("style");t.type="text/css",t.innerHTML=`
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@500&display=swap');
.footprint-body-locked {

@@ -80,3 +82,3 @@ overflow: hidden;

}
`,document.head.appendChild(t)},_=t=>{let e=document.createElement("div");e.setAttribute("id",t),e.classList.add("footprint-loading-indicator");let n=document.createElement("div");n.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 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"),o.setAttribute("fill","#FFFFFF"),r.appendChild(o),n.appendChild(r),e.appendChild(n),e},H=()=>{let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("width","24px"),t.setAttribute("height","24px"),t.setAttribute("fill","none"),t.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"),t.appendChild(e),t},A=()=>{let t=H(),e=document.createElement("button");e.appendChild(t);let n=document.createElement("span");return n.innerText="Verify with Footprint",e.appendChild(n),e.classList.add("footprint-button"),e};var m=class{constructor(){this.child=null;f||L()}async show({url:t}){let e=()=>{let o=document.getElementById(E);o&&o.remove()},n=this.createContainer();this.showOverlay(n);let r=await new x({classListArray:["footprint-modal"],container:n,name:"footprint-iframe",url:t});r.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *"),e(),r.on("closed",()=>this.hide()),this.child=r}on(t,e){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(t,e)}hide(){this.hideOverlay(),this.child&&this.child.destroy()}createButton(t){let e=A();return t.appendChild(e),e}showOverlay(t){document.body.classList.add("footprint-body-locked");let e=document.createElement("div");e.setAttribute("id",w);let n=_(E);e.appendChild(n),e.classList.add("footprint-overlay"),t.appendChild(e)}hideOverlay(){document.body.classList.remove("footprint-body-locked");let t=document.getElementById(w);t&&t.remove()}createContainer(){let t=document.getElementById(y);if(t)return t;let e=document.createElement("div");return e.setAttribute("id",y),document.body.appendChild(e),e}};var U=(t="production",e)=>t==="local"?"http://localhost:3000/":t==="development"?"https://id.preview.onefootprint.com":t==="preview"&&e?e==="development"?"https://id.preview.onefootprint.com":`https://bifrost-git-${e.toLowerCase().split("/").join("-")}.preview.onefootprint.com`:"https://id.onefootprint.com",K=U("",""),j=new m,N=new u(K,j);I(N)();var st=N;export{st as default};
`,document.head.appendChild(t)},_=t=>{let e=document.createElement("div");e.setAttribute("id",t),e.classList.add("footprint-loading-indicator");let n=document.createElement("div");n.classList.add("footprint-loading-spin");let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width","24px"),i.setAttribute("height","24px"),i.setAttribute("fill","none"),i.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"),o.setAttribute("fill","#FFFFFF"),i.appendChild(o),n.appendChild(i),e.appendChild(n),e},H=()=>{let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("width","24px"),t.setAttribute("height","24px"),t.setAttribute("fill","none"),t.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"),t.appendChild(e),t},A=()=>{let t=H(),e=document.createElement("button");e.appendChild(t);let n=document.createElement("span");return n.innerText="Verify with Footprint",e.appendChild(n),e.classList.add("footprint-button"),e};var m=class{constructor(){this.child=null;f||L()}async show({url:t}){let e=()=>{let o=document.getElementById(E);o&&o.remove()},n=this.createContainer();this.showOverlay(n);let i=await new x({classListArray:["footprint-modal"],container:n,name:"footprint-iframe",url:t});i.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),e(),i.on("closed",()=>this.hide()),this.child=i}on(t,e){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(t,e)}hide(){this.hideOverlay(),this.child&&this.child.destroy()}createButton(t){let e=A();return t.appendChild(e),e}showOverlay(t){document.body.classList.add("footprint-body-locked");let e=document.createElement("div");e.setAttribute("id",w);let n=_(E);e.appendChild(n),e.classList.add("footprint-overlay"),t.appendChild(e)}hideOverlay(){document.body.classList.remove("footprint-body-locked");let t=document.getElementById(w);t&&t.remove()}createContainer(){let t=document.getElementById(y);if(t)return t;let e=document.createElement("div");return e.setAttribute("id",y),document.body.appendChild(e),e}};var U=(t="production",e)=>t==="local"?"http://localhost:3000/":t==="development"?"https://id.preview.onefootprint.com":t==="preview"&&e?e==="development"?"https://id.preview.onefootprint.com":`https://bifrost-git-${e.toLowerCase().split("/").join("-")}.preview.onefootprint.com`:"https://id.onefootprint.com",K=U("production",""),j=new m,N=new u(K,j);I(N)();var st=N;export{st as default};
/**

@@ -83,0 +85,0 @@ postmate - A powerful, simple, promise-based postMessage library

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

"use strict";(()=>{var y="footprint-container",w="footprint-overlay",E="footprint-loading-indicator",f=typeof window>"u";var k=t=>{window.setTimeout(t,0)},P=t=>{let e=async()=>{await t.show({onUserCanceled:()=>{var i;(i=window.onFootprintCanceled)==null||i.call(window)},onCompleted:i=>{var a;(a=window.onFootprintCompleted)==null||a.call(window,i)}})},n=()=>{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");r(a,i)},r=(i,a)=>{t.init({publicKey:i}),k(()=>{t.createButton(a).addEventListener("click",()=>{e()})})},o=()=>{f||document.addEventListener("DOMContentLoaded",()=>n())};return()=>{o()}},I=P;var u=class{constructor(t,e){this.url=t;this.uiManager=e;this.publicKey=null;this.flow="authentication"}init(t={}){t.publicKey&&(this.flow="onboarding",this.publicKey=t.publicKey)}onAuthenticated(t){return this.uiManager.on("authenticated",e=>{e&&typeof e=="string"&&t(e)})}onCompleted(t){return this.uiManager.on("completed",e=>{e&&typeof e=="string"&&t(e)})}onUserCanceled(t){return this.uiManager.on("userCanceled",t)}async show(t={}){let e=new URLSearchParams;e.append("flow",this.flow),this.publicKey&&e.append("public_key",this.publicKey),await this.uiManager.show({url:`${this.url}?${e.toString()}`}),t.onAuthenticated&&this.onAuthenticated(t.onAuthenticated),t.onCompleted&&this.onCompleted(t.onCompleted),t.onUserCanceled&&this.onUserCanceled(t.onUserCanceled)}createButton(t){return this.uiManager.createButton(t)}};var p="application/x-postmate-v1+json",M=5,D=0,F=function(){return++D};var S=function(e){var n=document.createElement("a");n.href=e;var r=n.protocol.length>4?n.protocol:window.location.protocol,o=n.host.length?n.port==="80"||n.port==="443"?n.hostname:n.host:window.location.host;return n.origin||r+"//"+o},V={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},b=function(e,n){return!(typeof n=="string"&&e.origin!==n||!e.data||typeof e.data=="object"&&!("postmate"in e.data)||e.data.type!==p||!V[e.data.postmate])},R=function(e,n){var r=typeof e[n]=="function"?e[n]():e[n];return c.Promise.resolve(r)},T=function(){function t(n){var r=this;this.parent=n.parent,this.frame=n.frame,this.child=n.child,this.childOrigin=n.childOrigin,this.events={},this.listener=function(o){if(!b(o,r.childOrigin))return!1;var i=((o||{}).data||{}).value||{},a=i.data,d=i.name;o.data.postmate==="emit"&&d in r.events&&r.events[d].call(r,a)},this.parent.addEventListener("message",this.listener,!1)}var e=t.prototype;return e.get=function(r){var o=this;return new c.Promise(function(i){var a=F(),d=function s(l){l.data.uid===a&&l.data.postmate==="reply"&&(o.parent.removeEventListener("message",s,!1),i(l.data.value))};o.parent.addEventListener("message",d,!1),o.child.postMessage({postmate:"request",type:p,property:r,uid:a},o.childOrigin)})},e.call=function(r,o){this.child.postMessage({postmate:"call",type:p,property:r,data:o},this.childOrigin)},e.on=function(r,o){this.events[r]=o},e.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},t}(),B=function(){function t(n){var r=this;this.model=n.model,this.parent=n.parent,this.parentOrigin=n.parentOrigin,this.child=n.child,this.child.addEventListener("message",function(o){if(!!b(o,r.parentOrigin)){var i=o.data,a=i.property,d=i.uid,s=i.data;if(o.data.postmate==="call"){a in r.model&&typeof r.model[a]=="function"&&r.model[a](s);return}R(r.model,a).then(function(l){return o.source.postMessage({property:a,postmate:"reply",type:p,uid:d,value:l},o.origin)})}})}var e=t.prototype;return e.emit=function(r,o){this.parent.postMessage({postmate:"emit",type:p,value:{name:r,data:o}},this.parentOrigin)},t}(),c=function(){function t(n){var r=n.container,o=r===void 0?typeof o<"u"?o:document.body:r,i=n.model,a=n.url,d=n.name,s=n.classListArray,l=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,l),o.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var e=t.prototype;return e.sendHandshake=function(r){var o=this,i=S(r),a=0,d;return new t.Promise(function(s,l){var h=function g(v){return b(v,i)?v.data.postmate==="handshake-reply"?(clearInterval(d),o.parent.removeEventListener("message",g,!1),o.childOrigin=v.origin,s(new T(o))):l("Failed handshake"):!1};o.parent.addEventListener("message",h,!1);var C=function(){a++,o.child.postMessage({postmate:"handshake",type:p,model:o.model},i),a===M&&clearInterval(d)},O=function(){C(),d=setInterval(C,500)};o.frame.attachEvent?o.frame.attachEvent("onload",O):o.frame.onload=O,o.frame.src=r})},t}();c.debug=!1;c.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}();c.Model=function(){function t(n){return this.child=window,this.model=n,this.parent=this.child.parent,this.sendHandshakeReply()}var e=t.prototype;return e.sendHandshakeReply=function(){var r=this;return new c.Promise(function(o,i){var a=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:p},s.origin),r.parentOrigin=s.origin;var l=s.data.model;return l&&Object.keys(l).forEach(function(h){r.model[h]=l[h]}),o(new B(r))}return i("Handshake Reply Failed")}};r.child.addEventListener("message",a,!1)})},t}();var x=c;var L=()=>{let t=document.createElement("style");t.type="text/css",t.innerHTML=`
"use strict";(()=>{var y="footprint-container",w="footprint-overlay",E="footprint-loading-indicator",f=typeof window>"u";var k=t=>{window.setTimeout(t,0)},P=t=>{let e=async()=>{await t.show({onUserCanceled:()=>{var r;(r=window.onFootprintCanceled)==null||r.call(window)},onCompleted:r=>{var a;(a=window.onFootprintCompleted)==null||a.call(window,r)}})},n=()=>{let r=document.getElementById("footprint-button");if(!r)return;let a=r.getAttribute("data-public-key");if(!a)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");i(a,r)},i=(r,a)=>{t.init({publicKey:r}),k(()=>{t.createButton(a).addEventListener("click",()=>{e()})})},o=()=>{f||document.addEventListener("DOMContentLoaded",()=>n())};return()=>{o()}},I=P;var u=class{constructor(t,e){this.url=t;this.uiManager=e;this.publicKey=null;this.flow="authentication"}init(t={}){t.publicKey&&(this.flow="onboarding",this.publicKey=t.publicKey)}onAuthenticated(t){return this.uiManager.on("authenticated",e=>{e&&typeof e=="string"&&t(e)})}onCompleted(t){return this.uiManager.on("completed",e=>{e&&typeof e=="string"&&t(e)})}onUserCanceled(t){return this.uiManager.on("userCanceled",t)}async show(t={}){let e=new URLSearchParams;e.append("flow",this.flow),this.publicKey&&e.append("public_key",this.publicKey),await this.uiManager.show({url:`${this.url}?${e.toString()}`}),t.onAuthenticated&&this.onAuthenticated(t.onAuthenticated),t.onCompleted&&this.onCompleted(t.onCompleted),t.onUserCanceled&&this.onUserCanceled(t.onUserCanceled)}createButton(t){return this.uiManager.createButton(t)}};var p="application/x-postmate-v1+json",M=5,D=0,F=function(){return++D};var S=function(e){var n=document.createElement("a");n.href=e;var i=n.protocol.length>4?n.protocol:window.location.protocol,o=n.host.length?n.port==="80"||n.port==="443"?n.hostname:n.host:window.location.host;return n.origin||i+"//"+o},V={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},b=function(e,n){return!(typeof n=="string"&&e.origin!==n||!e.data||typeof e.data=="object"&&!("postmate"in e.data)||e.data.type!==p||!V[e.data.postmate])},R=function(e,n){var i=typeof e[n]=="function"?e[n]():e[n];return c.Promise.resolve(i)},T=function(){function t(n){var i=this;this.parent=n.parent,this.frame=n.frame,this.child=n.child,this.childOrigin=n.childOrigin,this.events={},this.listener=function(o){if(!b(o,i.childOrigin))return!1;var r=((o||{}).data||{}).value||{},a=r.data,d=r.name;o.data.postmate==="emit"&&d in i.events&&i.events[d].call(i,a)},this.parent.addEventListener("message",this.listener,!1)}var e=t.prototype;return e.get=function(i){var o=this;return new c.Promise(function(r){var a=F(),d=function s(l){l.data.uid===a&&l.data.postmate==="reply"&&(o.parent.removeEventListener("message",s,!1),r(l.data.value))};o.parent.addEventListener("message",d,!1),o.child.postMessage({postmate:"request",type:p,property:i,uid:a},o.childOrigin)})},e.call=function(i,o){this.child.postMessage({postmate:"call",type:p,property:i,data:o},this.childOrigin)},e.on=function(i,o){this.events[i]=o},e.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},t}(),B=function(){function t(n){var i=this;this.model=n.model,this.parent=n.parent,this.parentOrigin=n.parentOrigin,this.child=n.child,this.child.addEventListener("message",function(o){if(!!b(o,i.parentOrigin)){var r=o.data,a=r.property,d=r.uid,s=r.data;if(o.data.postmate==="call"){a in i.model&&typeof i.model[a]=="function"&&i.model[a](s);return}R(i.model,a).then(function(l){return o.source.postMessage({property:a,postmate:"reply",type:p,uid:d,value:l},o.origin)})}})}var e=t.prototype;return e.emit=function(i,o){this.parent.postMessage({postmate:"emit",type:p,value:{name:i,data:o}},this.parentOrigin)},t}(),c=function(){function t(n){var i=n.container,o=i===void 0?typeof o<"u"?o:document.body:i,r=n.model,a=n.url,d=n.name,s=n.classListArray,l=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,l),o.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=r||{},this.sendHandshake(a)}var e=t.prototype;return e.sendHandshake=function(i){var o=this,r=S(i),a=0,d;return new t.Promise(function(s,l){var h=function g(v){return b(v,r)?v.data.postmate==="handshake-reply"?(clearInterval(d),o.parent.removeEventListener("message",g,!1),o.childOrigin=v.origin,s(new T(o))):l("Failed handshake"):!1};o.parent.addEventListener("message",h,!1);var C=function(){a++,o.child.postMessage({postmate:"handshake",type:p,model:o.model},r),a===M&&clearInterval(d)},O=function(){C(),d=setInterval(C,500)};o.frame.attachEvent?o.frame.attachEvent("onload",O):o.frame.onload=O,o.frame.src=i})},t}();c.debug=!1;c.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}();c.Model=function(){function t(n){return this.child=window,this.model=n,this.parent=this.child.parent,this.sendHandshakeReply()}var e=t.prototype;return e.sendHandshakeReply=function(){var i=this;return new c.Promise(function(o,r){var a=function d(s){if(!!s.data.postmate){if(s.data.postmate==="handshake"){i.child.removeEventListener("message",d,!1),s.source.postMessage({postmate:"handshake-reply",type:p},s.origin),i.parentOrigin=s.origin;var l=s.data.model;return l&&Object.keys(l).forEach(function(h){i.model[h]=l[h]}),o(new B(i))}return r("Handshake Reply Failed")}};i.child.addEventListener("message",a,!1)})},t}();var x=c;var L=()=>{let t=document.createElement("style");t.type="text/css",t.innerHTML=`
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@500&display=swap');
.footprint-body-locked {

@@ -80,3 +82,3 @@ overflow: hidden;

}
`,document.head.appendChild(t)},_=t=>{let e=document.createElement("div");e.setAttribute("id",t),e.classList.add("footprint-loading-indicator");let n=document.createElement("div");n.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 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"),o.setAttribute("fill","#FFFFFF"),r.appendChild(o),n.appendChild(r),e.appendChild(n),e},H=()=>{let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("width","24px"),t.setAttribute("height","24px"),t.setAttribute("fill","none"),t.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"),t.appendChild(e),t},A=()=>{let t=H(),e=document.createElement("button");e.appendChild(t);let n=document.createElement("span");return n.innerText="Verify with Footprint",e.appendChild(n),e.classList.add("footprint-button"),e};var m=class{constructor(){this.child=null;f||L()}async show({url:t}){let e=()=>{let o=document.getElementById(E);o&&o.remove()},n=this.createContainer();this.showOverlay(n);let r=await new x({classListArray:["footprint-modal"],container:n,name:"footprint-iframe",url:t});r.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *"),e(),r.on("closed",()=>this.hide()),this.child=r}on(t,e){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(t,e)}hide(){this.hideOverlay(),this.child&&this.child.destroy()}createButton(t){let e=A();return t.appendChild(e),e}showOverlay(t){document.body.classList.add("footprint-body-locked");let e=document.createElement("div");e.setAttribute("id",w);let n=_(E);e.appendChild(n),e.classList.add("footprint-overlay"),t.appendChild(e)}hideOverlay(){document.body.classList.remove("footprint-body-locked");let t=document.getElementById(w);t&&t.remove()}createContainer(){let t=document.getElementById(y);if(t)return t;let e=document.createElement("div");return e.setAttribute("id",y),document.body.appendChild(e),e}};var U=(t="production",e)=>t==="local"?"http://localhost:3000/":t==="development"?"https://id.preview.onefootprint.com":t==="preview"&&e?e==="development"?"https://id.preview.onefootprint.com":`https://bifrost-git-${e.toLowerCase().split("/").join("-")}.preview.onefootprint.com`:"https://id.onefootprint.com",K=U("",""),j=new m,N=new u(K,j);I(N)();var st=N;})();
`,document.head.appendChild(t)},_=t=>{let e=document.createElement("div");e.setAttribute("id",t),e.classList.add("footprint-loading-indicator");let n=document.createElement("div");n.classList.add("footprint-loading-spin");let i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width","24px"),i.setAttribute("height","24px"),i.setAttribute("fill","none"),i.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"),o.setAttribute("fill","#FFFFFF"),i.appendChild(o),n.appendChild(i),e.appendChild(n),e},H=()=>{let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.setAttribute("width","24px"),t.setAttribute("height","24px"),t.setAttribute("fill","none"),t.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"),t.appendChild(e),t},A=()=>{let t=H(),e=document.createElement("button");e.appendChild(t);let n=document.createElement("span");return n.innerText="Verify with Footprint",e.appendChild(n),e.classList.add("footprint-button"),e};var m=class{constructor(){this.child=null;f||L()}async show({url:t}){let e=()=>{let o=document.getElementById(E);o&&o.remove()},n=this.createContainer();this.showOverlay(n);let i=await new x({classListArray:["footprint-modal"],container:n,name:"footprint-iframe",url:t});i.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),e(),i.on("closed",()=>this.hide()),this.child=i}on(t,e){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(t,e)}hide(){this.hideOverlay(),this.child&&this.child.destroy()}createButton(t){let e=A();return t.appendChild(e),e}showOverlay(t){document.body.classList.add("footprint-body-locked");let e=document.createElement("div");e.setAttribute("id",w);let n=_(E);e.appendChild(n),e.classList.add("footprint-overlay"),t.appendChild(e)}hideOverlay(){document.body.classList.remove("footprint-body-locked");let t=document.getElementById(w);t&&t.remove()}createContainer(){let t=document.getElementById(y);if(t)return t;let e=document.createElement("div");return e.setAttribute("id",y),document.body.appendChild(e),e}};var U=(t="production",e)=>t==="local"?"http://localhost:3000/":t==="development"?"https://id.preview.onefootprint.com":t==="preview"&&e?e==="development"?"https://id.preview.onefootprint.com":`https://bifrost-git-${e.toLowerCase().split("/").join("-")}.preview.onefootprint.com`:"https://id.onefootprint.com",K=U("production",""),j=new m,N=new u(K,j);I(N)();var st=N;})();
/**

@@ -83,0 +85,0 @@ postmate - A powerful, simple, promise-based postMessage library

{
"name": "@onefootprint/footprint-js",
"private": false,
"version": "0.2.0",
"version": "0.3.0",
"main": "./dist/footprint-js.umd.js",

@@ -34,4 +34,4 @@ "module": "./dist/footprint-js.esm.js",

"tsup": "^6.2.2",
"types": "*",
"typescript": "^4.7.4"
"@onefootprint/types": "*",
"typescript": "4.7.4"
},

@@ -44,2 +44,2 @@ "publishConfig": {

}
}
}
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