New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@onefootprint/footprint-js

Package Overview
Dependencies
Maintainers
3
Versions
76
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.3.0 to 0.3.1-beta.0

CHANGELOG.md

86

dist/footprint-js.cjs.js

@@ -1,84 +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,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 {
overflow: hidden;
}
'use strict';
.footprint-overlay {
align-items: center;
background: rgba(0, 0, 0, 0.3);
display: flex;
height: 100%;
justify-content: center;
left: 0;
overflow-y: hidden;
position: fixed;
top: 0;
width: 100%;
z-index: 50000;
}
@keyframes footprint-rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.footprint-loading-indicator {
background: rgba(0, 0, 0, 0.6);
border-radius: 4px;
padding: 16px;
}
.footprint-loading-spin {
animation: footprint-rotate 0.8s linear infinite;
}
.footprint-modal {
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
z-index: 50001;
}
.footprint-button {
-webkit-box-align: center;
align-items: center;
background-color: rgb(14, 20, 56);
border-radius: 6px;
border: 0px;
box-shadow: rgb(0 0 0 / 0%) 0px 1px 1px, transparent 0px 0px 0px 1px;
color: rgb(255, 255, 255);
cursor: pointer;
display: flex;
-webkit-box-pack: center;
justify-content: center;
text-decoration: none;
user-select: none;
font-family: "DM Sans";
font-size: 16px;
font-weight: 500;
line-height: 24px;
padding: 12px 24px;
}
.footprint-button:hover {
background: linear-gradient(rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.14)), linear-gradient(rgb(14, 20, 56), rgb(14, 20, 56));
}
.footprint-button:active {
background: linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)), linear-gradient(rgb(14, 20, 56), rgb(14, 20, 56));
}
.footprint-button svg {
margin-right: 8px;
}
`,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={});
/**
var p="application/x-postmate-v1+json",M=5,V=0,S=function(){return ++V};var T=function(t){var e=document.createElement("a");e.href=t;var r=e.protocol.length>4?e.protocol:window.location.protocol,n=e.host.length?e.port==="80"||e.port==="443"?e.hostname:e.host:window.location.host;return e.origin||r+"//"+n},R={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},m=function(t,e){return !(typeof e=="string"&&t.origin!==e||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==p||!R[t.data.postmate])},B=function(t,e){var r=typeof t[e]=="function"?t[e]():t[e];return c.Promise.resolve(r)},H=function(){function o(e){var r=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},this.listener=function(n){if(!m(n,r.childOrigin))return !1;var a=((n||{}).data||{}).value||{},i=a.data,s=a.name;n.data.postmate==="emit"&&s in r.events&&r.events[s].call(r,i);},this.parent.addEventListener("message",this.listener,!1);}var t=o.prototype;return t.get=function(r){var n=this;return new c.Promise(function(a){var i=S(),s=function d(l){l.data.uid===i&&l.data.postmate==="reply"&&(n.parent.removeEventListener("message",d,!1),a(l.data.value));};n.parent.addEventListener("message",s,!1),n.child.postMessage({postmate:"request",type:p,property:r,uid:i},n.childOrigin);})},t.call=function(r,n){this.child.postMessage({postmate:"call",type:p,property:r,data:n},this.childOrigin);},t.on=function(r,n){this.events[r]=n;},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},o}(),j=function(){function o(e){var r=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.child.addEventListener("message",function(n){if(!!m(n,r.parentOrigin)){var a=n.data,i=a.property,s=a.uid,d=a.data;if(n.data.postmate==="call"){i in r.model&&typeof r.model[i]=="function"&&r.model[i](d);return}B(r.model,i).then(function(l){return n.source.postMessage({property:i,postmate:"reply",type:p,uid:s,value:l},n.origin)});}});}var t=o.prototype;return t.emit=function(r,n){this.parent.postMessage({postmate:"emit",type:p,value:{name:r,data:n}},this.parentOrigin);},o}(),c=function(){function o(e){var r=e.container,n=r===void 0?typeof n<"u"?n:document.body:r,a=e.model,i=e.url,s=e.name,d=e.classListArray,l=d===void 0?[]:d;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=s||"",this.frame.classList.add.apply(this.frame.classList,l),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(i)}var t=o.prototype;return t.sendHandshake=function(r){var n=this,a=T(r),i=0,s;return new o.Promise(function(d,l){var u=function h(f){return m(f,a)?f.data.postmate==="handshake-reply"?(clearInterval(s),n.parent.removeEventListener("message",h,!1),n.childOrigin=f.origin,d(new H(n))):l("Failed handshake"):!1};n.parent.addEventListener("message",u,!1);var w=function(){i++,n.child.postMessage({postmate:"handshake",type:p,model:n.model},a),i===M&&clearInterval(s);},E=function(){w(),s=setInterval(w,500);};n.frame.attachEvent?n.frame.attachEvent("onload",E):n.frame.onload=E,n.frame.src=r;})},o}();c.debug=!1;c.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}();c.Model=function(){function o(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}var t=o.prototype;return t.sendHandshakeReply=function(){var r=this;return new c.Promise(function(n,a){var i=function s(d){if(!!d.data.postmate){if(d.data.postmate==="handshake"){r.child.removeEventListener("message",s,!1),d.source.postMessage({postmate:"handshake-reply",type:p},d.origin),r.parentOrigin=d.origin;var l=d.data.model;return l&&Object.keys(l).forEach(function(u){r.model[u]=l[u];}),n(new j(r))}return a("Handshake Reply Failed")}};r.child.addEventListener("message",i,!1);})},o}();var b=c;var x="footprint-container",O="footprint-overlay",L="footprint-loading-indicator",C=o=>{let t=g();return o.appendChild(t),t},N=o=>{document.body.classList.add("footprint-body-locked");let t=document.createElement("div");t.setAttribute("id",O);let e=$(L);t.appendChild(e),t.classList.add("footprint-overlay"),o.appendChild(t);},_=()=>{let o=document.getElementById(L);o&&o.remove();},k=()=>{document.body.classList.remove("footprint-body-locked");let o=document.getElementById(O);o&&o.remove();},P=()=>{let o=document.getElementById(x);if(o)return o;let t=document.createElement("div");return t.setAttribute("id",x),document.body.appendChild(t),t},$=o=>{let t=document.createElement("div");t.setAttribute("id",o),t.classList.add("footprint-loading-indicator");let e=document.createElement("div");e.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"),n.setAttribute("fill","#FFFFFF"),r.appendChild(n),e.appendChild(r),t.appendChild(e),t},z=()=>{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 t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.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"),t.setAttribute("fill","#76fb8f"),o.appendChild(t),o},g=()=>{let o=z(),t=document.createElement("button");t.appendChild(o);let e=document.createElement("span");return e.innerText="Verify with Footprint",t.appendChild(e),t.classList.add("footprint-button"),t};var v=class{constructor(){this.child=null;}async show({url:t}){let e=()=>{_();},r=P();N(r);let n=await new b({classListArray:["footprint-modal"],container:r,name:"footprint-iframe",url:t});n.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),e(),n.on("closed",()=>this.hide()),this.child=n;}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(){k(),this.child&&this.child.destroy();}createButton(t){let e=g();return t.appendChild(e),e}},A=v;var y=new A,U=o=>{let t=r=>y.on("completed",n=>{n&&typeof n=="string"&&r(n);}),e=r=>y.on("userCanceled",r);return {show:async({publicKey:r,onCompleted:n,onUserCanceled:a})=>{let i=new URLSearchParams;i.append("flow","onboarding"),i.append("public_key",r),await y.show({url:`${o}?${i.toString()}`}),n&&t(n),a&&e(a);}}},I=U;var q=typeof window>"u",G=o=>{window.setTimeout(o,0);},W=o=>{let t=async a=>{await o.show({publicKey:a,onUserCanceled:()=>{var i;(i=window.onFootprintCanceled)==null||i.call(window);},onCompleted:i=>{var s;(s=window.onFootprintCompleted)==null||s.call(window,i);}});},e=()=>{let a=document.getElementById("footprint-button");if(!a)return;let i=a.getAttribute("data-public-key");if(!i)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");r(i,a);},r=(a,i)=>{G(()=>{C(i).addEventListener("click",()=>{t(a);});});},n=()=>{q||document.addEventListener("DOMContentLoaded",()=>e());};return ()=>{n();}},D=W;var X=(o="production",t)=>o==="local"?"http://localhost:3000/":o==="development"?"https://id.preview.onefootprint.com":o==="preview"&&t?t==="development"?"https://id.preview.onefootprint.com":`https://bifrost-git-${t.toLowerCase().split("/").join("-")}.preview.onefootprint.com`:"https://id.onefootprint.com",Z=X("production",""),F=I(Z);D(F)();var pt=F;/**
postmate - A powerful, simple, promise-based postMessage library

@@ -90,1 +10,3 @@ @version v1.5.2

**/
module.exports = pt;

@@ -1,51 +0,11 @@

declare type Footprint = {
init(options?: {
publicKey?: string;
}): void;
show(callback?: {
onAuthenticated?: (vtok: string) => void;
onCompleted?: (validationToken: string) => void;
onUserCanceled?: () => void;
}): Promise<void>;
createButton(container: HTMLElement): HTMLButtonElement;
declare type ShowFootprint = {
publicKey: string;
onCompleted?: (validationToken: string) => void;
onUserCanceled?: () => void;
};
declare enum FootprintEvents {
authenticated = "authenticated",
closed = "closed",
completed = "completed",
userCanceled = "userCanceled"
}
declare type FootprintEvent = FootprintEvents;
declare type OpenOptions = {
url: string;
declare const footprint: {
show: ({ publicKey, onCompleted, onUserCanceled }: ShowFootprint) => Promise<void>;
};
declare type UIManager = {
createButton(container: HTMLElement): HTMLButtonElement;
on(eventName: FootprintEvent, callback: (data?: any) => void): void;
show(option?: OpenOptions): Promise<void>;
hide(option?: OpenOptions): void;
};
declare class export_default implements Footprint {
private url;
private uiManager;
private publicKey;
private flow;
constructor(url: string, uiManager: UIManager);
init(options?: {
publicKey?: string;
}): void;
private onAuthenticated;
private onCompleted;
private onUserCanceled;
show(callback?: {
onAuthenticated?: (vtok: string) => void;
onCompleted?: (validationToken: string) => void;
onUserCanceled?: () => void;
}): Promise<void>;
createButton(container: HTMLElement): HTMLButtonElement;
}
declare const footprint: export_default;
export { footprint as default };

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

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 {
overflow: hidden;
}
.footprint-overlay {
align-items: center;
background: rgba(0, 0, 0, 0.3);
display: flex;
height: 100%;
justify-content: center;
left: 0;
overflow-y: hidden;
position: fixed;
top: 0;
width: 100%;
z-index: 50000;
}
@keyframes footprint-rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.footprint-loading-indicator {
background: rgba(0, 0, 0, 0.6);
border-radius: 4px;
padding: 16px;
}
.footprint-loading-spin {
animation: footprint-rotate 0.8s linear infinite;
}
.footprint-modal {
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
z-index: 50001;
}
.footprint-button {
-webkit-box-align: center;
align-items: center;
background-color: rgb(14, 20, 56);
border-radius: 6px;
border: 0px;
box-shadow: rgb(0 0 0 / 0%) 0px 1px 1px, transparent 0px 0px 0px 1px;
color: rgb(255, 255, 255);
cursor: pointer;
display: flex;
-webkit-box-pack: center;
justify-content: center;
text-decoration: none;
user-select: none;
font-family: "DM Sans";
font-size: 16px;
font-weight: 500;
line-height: 24px;
padding: 12px 24px;
}
.footprint-button:hover {
background: linear-gradient(rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.14)), linear-gradient(rgb(14, 20, 56), rgb(14, 20, 56));
}
.footprint-button:active {
background: linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)), linear-gradient(rgb(14, 20, 56), rgb(14, 20, 56));
}
.footprint-button svg {
margin-right: 8px;
}
`,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};
/**
var p="application/x-postmate-v1+json",M=5,V=0,S=function(){return ++V};var T=function(t){var e=document.createElement("a");e.href=t;var r=e.protocol.length>4?e.protocol:window.location.protocol,n=e.host.length?e.port==="80"||e.port==="443"?e.hostname:e.host:window.location.host;return e.origin||r+"//"+n},R={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},m=function(t,e){return !(typeof e=="string"&&t.origin!==e||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==p||!R[t.data.postmate])},B=function(t,e){var r=typeof t[e]=="function"?t[e]():t[e];return c.Promise.resolve(r)},H=function(){function o(e){var r=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},this.listener=function(n){if(!m(n,r.childOrigin))return !1;var a=((n||{}).data||{}).value||{},i=a.data,s=a.name;n.data.postmate==="emit"&&s in r.events&&r.events[s].call(r,i);},this.parent.addEventListener("message",this.listener,!1);}var t=o.prototype;return t.get=function(r){var n=this;return new c.Promise(function(a){var i=S(),s=function d(l){l.data.uid===i&&l.data.postmate==="reply"&&(n.parent.removeEventListener("message",d,!1),a(l.data.value));};n.parent.addEventListener("message",s,!1),n.child.postMessage({postmate:"request",type:p,property:r,uid:i},n.childOrigin);})},t.call=function(r,n){this.child.postMessage({postmate:"call",type:p,property:r,data:n},this.childOrigin);},t.on=function(r,n){this.events[r]=n;},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},o}(),j=function(){function o(e){var r=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.child.addEventListener("message",function(n){if(!!m(n,r.parentOrigin)){var a=n.data,i=a.property,s=a.uid,d=a.data;if(n.data.postmate==="call"){i in r.model&&typeof r.model[i]=="function"&&r.model[i](d);return}B(r.model,i).then(function(l){return n.source.postMessage({property:i,postmate:"reply",type:p,uid:s,value:l},n.origin)});}});}var t=o.prototype;return t.emit=function(r,n){this.parent.postMessage({postmate:"emit",type:p,value:{name:r,data:n}},this.parentOrigin);},o}(),c=function(){function o(e){var r=e.container,n=r===void 0?typeof n<"u"?n:document.body:r,a=e.model,i=e.url,s=e.name,d=e.classListArray,l=d===void 0?[]:d;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=s||"",this.frame.classList.add.apply(this.frame.classList,l),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(i)}var t=o.prototype;return t.sendHandshake=function(r){var n=this,a=T(r),i=0,s;return new o.Promise(function(d,l){var u=function h(f){return m(f,a)?f.data.postmate==="handshake-reply"?(clearInterval(s),n.parent.removeEventListener("message",h,!1),n.childOrigin=f.origin,d(new H(n))):l("Failed handshake"):!1};n.parent.addEventListener("message",u,!1);var w=function(){i++,n.child.postMessage({postmate:"handshake",type:p,model:n.model},a),i===M&&clearInterval(s);},E=function(){w(),s=setInterval(w,500);};n.frame.attachEvent?n.frame.attachEvent("onload",E):n.frame.onload=E,n.frame.src=r;})},o}();c.debug=!1;c.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}();c.Model=function(){function o(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}var t=o.prototype;return t.sendHandshakeReply=function(){var r=this;return new c.Promise(function(n,a){var i=function s(d){if(!!d.data.postmate){if(d.data.postmate==="handshake"){r.child.removeEventListener("message",s,!1),d.source.postMessage({postmate:"handshake-reply",type:p},d.origin),r.parentOrigin=d.origin;var l=d.data.model;return l&&Object.keys(l).forEach(function(u){r.model[u]=l[u];}),n(new j(r))}return a("Handshake Reply Failed")}};r.child.addEventListener("message",i,!1);})},o}();var b=c;var x="footprint-container",O="footprint-overlay",L="footprint-loading-indicator",C=o=>{let t=g();return o.appendChild(t),t},N=o=>{document.body.classList.add("footprint-body-locked");let t=document.createElement("div");t.setAttribute("id",O);let e=$(L);t.appendChild(e),t.classList.add("footprint-overlay"),o.appendChild(t);},_=()=>{let o=document.getElementById(L);o&&o.remove();},k=()=>{document.body.classList.remove("footprint-body-locked");let o=document.getElementById(O);o&&o.remove();},P=()=>{let o=document.getElementById(x);if(o)return o;let t=document.createElement("div");return t.setAttribute("id",x),document.body.appendChild(t),t},$=o=>{let t=document.createElement("div");t.setAttribute("id",o),t.classList.add("footprint-loading-indicator");let e=document.createElement("div");e.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"),n.setAttribute("fill","#FFFFFF"),r.appendChild(n),e.appendChild(r),t.appendChild(e),t},z=()=>{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 t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.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"),t.setAttribute("fill","#76fb8f"),o.appendChild(t),o},g=()=>{let o=z(),t=document.createElement("button");t.appendChild(o);let e=document.createElement("span");return e.innerText="Verify with Footprint",t.appendChild(e),t.classList.add("footprint-button"),t};var v=class{constructor(){this.child=null;}async show({url:t}){let e=()=>{_();},r=P();N(r);let n=await new b({classListArray:["footprint-modal"],container:r,name:"footprint-iframe",url:t});n.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),e(),n.on("closed",()=>this.hide()),this.child=n;}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(){k(),this.child&&this.child.destroy();}createButton(t){let e=g();return t.appendChild(e),e}},A=v;var y=new A,U=o=>{let t=r=>y.on("completed",n=>{n&&typeof n=="string"&&r(n);}),e=r=>y.on("userCanceled",r);return {show:async({publicKey:r,onCompleted:n,onUserCanceled:a})=>{let i=new URLSearchParams;i.append("flow","onboarding"),i.append("public_key",r),await y.show({url:`${o}?${i.toString()}`}),n&&t(n),a&&e(a);}}},I=U;var q=typeof window>"u",G=o=>{window.setTimeout(o,0);},W=o=>{let t=async a=>{await o.show({publicKey:a,onUserCanceled:()=>{var i;(i=window.onFootprintCanceled)==null||i.call(window);},onCompleted:i=>{var s;(s=window.onFootprintCompleted)==null||s.call(window,i);}});},e=()=>{let a=document.getElementById("footprint-button");if(!a)return;let i=a.getAttribute("data-public-key");if(!i)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");r(i,a);},r=(a,i)=>{G(()=>{C(i).addEventListener("click",()=>{t(a);});});},n=()=>{q||document.addEventListener("DOMContentLoaded",()=>e());};return ()=>{n();}},D=W;var X=(o="production",t)=>o==="local"?"http://localhost:3000/":o==="development"?"https://id.preview.onefootprint.com":o==="preview"&&t?t==="development"?"https://id.preview.onefootprint.com":`https://bifrost-git-${t.toLowerCase().split("/").join("-")}.preview.onefootprint.com`:"https://id.onefootprint.com",Z=X("production",""),F=I(Z);D(F)();var pt=F;/**
postmate - A powerful, simple, promise-based postMessage library

@@ -90,1 +8,3 @@ @version v1.5.2

**/
export { pt as default };

@@ -1,89 +0,14 @@

"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 {
overflow: hidden;
}
(function () {
'use strict';
.footprint-overlay {
align-items: center;
background: rgba(0, 0, 0, 0.3);
display: flex;
height: 100%;
justify-content: center;
left: 0;
overflow-y: hidden;
position: fixed;
top: 0;
width: 100%;
z-index: 50000;
}
var p="application/x-postmate-v1+json",M=5,V=0,S=function(){return ++V};var T=function(t){var e=document.createElement("a");e.href=t;var r=e.protocol.length>4?e.protocol:window.location.protocol,n=e.host.length?e.port==="80"||e.port==="443"?e.hostname:e.host:window.location.host;return e.origin||r+"//"+n},R={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},m=function(t,e){return !(typeof e=="string"&&t.origin!==e||!t.data||typeof t.data=="object"&&!("postmate"in t.data)||t.data.type!==p||!R[t.data.postmate])},B=function(t,e){var r=typeof t[e]=="function"?t[e]():t[e];return c.Promise.resolve(r)},H=function(){function o(e){var r=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},this.listener=function(n){if(!m(n,r.childOrigin))return !1;var a=((n||{}).data||{}).value||{},i=a.data,s=a.name;n.data.postmate==="emit"&&s in r.events&&r.events[s].call(r,i);},this.parent.addEventListener("message",this.listener,!1);}var t=o.prototype;return t.get=function(r){var n=this;return new c.Promise(function(a){var i=S(),s=function d(l){l.data.uid===i&&l.data.postmate==="reply"&&(n.parent.removeEventListener("message",d,!1),a(l.data.value));};n.parent.addEventListener("message",s,!1),n.child.postMessage({postmate:"request",type:p,property:r,uid:i},n.childOrigin);})},t.call=function(r,n){this.child.postMessage({postmate:"call",type:p,property:r,data:n},this.childOrigin);},t.on=function(r,n){this.events[r]=n;},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},o}(),j=function(){function o(e){var r=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.child.addEventListener("message",function(n){if(!!m(n,r.parentOrigin)){var a=n.data,i=a.property,s=a.uid,d=a.data;if(n.data.postmate==="call"){i in r.model&&typeof r.model[i]=="function"&&r.model[i](d);return}B(r.model,i).then(function(l){return n.source.postMessage({property:i,postmate:"reply",type:p,uid:s,value:l},n.origin)});}});}var t=o.prototype;return t.emit=function(r,n){this.parent.postMessage({postmate:"emit",type:p,value:{name:r,data:n}},this.parentOrigin);},o}(),c=function(){function o(e){var r=e.container,n=r===void 0?typeof n<"u"?n:document.body:r,a=e.model,i=e.url,s=e.name,d=e.classListArray,l=d===void 0?[]:d;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=s||"",this.frame.classList.add.apply(this.frame.classList,l),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(i)}var t=o.prototype;return t.sendHandshake=function(r){var n=this,a=T(r),i=0,s;return new o.Promise(function(d,l){var u=function h(f){return m(f,a)?f.data.postmate==="handshake-reply"?(clearInterval(s),n.parent.removeEventListener("message",h,!1),n.childOrigin=f.origin,d(new H(n))):l("Failed handshake"):!1};n.parent.addEventListener("message",u,!1);var w=function(){i++,n.child.postMessage({postmate:"handshake",type:p,model:n.model},a),i===M&&clearInterval(s);},E=function(){w(),s=setInterval(w,500);};n.frame.attachEvent?n.frame.attachEvent("onload",E):n.frame.onload=E,n.frame.src=r;})},o}();c.debug=!1;c.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}();c.Model=function(){function o(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}var t=o.prototype;return t.sendHandshakeReply=function(){var r=this;return new c.Promise(function(n,a){var i=function s(d){if(!!d.data.postmate){if(d.data.postmate==="handshake"){r.child.removeEventListener("message",s,!1),d.source.postMessage({postmate:"handshake-reply",type:p},d.origin),r.parentOrigin=d.origin;var l=d.data.model;return l&&Object.keys(l).forEach(function(u){r.model[u]=l[u];}),n(new j(r))}return a("Handshake Reply Failed")}};r.child.addEventListener("message",i,!1);})},o}();var b=c;var x="footprint-container",O="footprint-overlay",L="footprint-loading-indicator",C=o=>{let t=g();return o.appendChild(t),t},N=o=>{document.body.classList.add("footprint-body-locked");let t=document.createElement("div");t.setAttribute("id",O);let e=$(L);t.appendChild(e),t.classList.add("footprint-overlay"),o.appendChild(t);},_=()=>{let o=document.getElementById(L);o&&o.remove();},k=()=>{document.body.classList.remove("footprint-body-locked");let o=document.getElementById(O);o&&o.remove();},P=()=>{let o=document.getElementById(x);if(o)return o;let t=document.createElement("div");return t.setAttribute("id",x),document.body.appendChild(t),t},$=o=>{let t=document.createElement("div");t.setAttribute("id",o),t.classList.add("footprint-loading-indicator");let e=document.createElement("div");e.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"),n.setAttribute("fill","#FFFFFF"),r.appendChild(n),e.appendChild(r),t.appendChild(e),t},z=()=>{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 t=document.createElementNS("http://www.w3.org/2000/svg","path");return t.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"),t.setAttribute("fill","#76fb8f"),o.appendChild(t),o},g=()=>{let o=z(),t=document.createElement("button");t.appendChild(o);let e=document.createElement("span");return e.innerText="Verify with Footprint",t.appendChild(e),t.classList.add("footprint-button"),t};var v=class{constructor(){this.child=null;}async show({url:t}){let e=()=>{_();},r=P();N(r);let n=await new b({classListArray:["footprint-modal"],container:r,name:"footprint-iframe",url:t});n.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),e(),n.on("closed",()=>this.hide()),this.child=n;}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(){k(),this.child&&this.child.destroy();}createButton(t){let e=g();return t.appendChild(e),e}},A=v;var y=new A,U=o=>{let t=r=>y.on("completed",n=>{n&&typeof n=="string"&&r(n);}),e=r=>y.on("userCanceled",r);return {show:async({publicKey:r,onCompleted:n,onUserCanceled:a})=>{let i=new URLSearchParams;i.append("flow","onboarding"),i.append("public_key",r),await y.show({url:`${o}?${i.toString()}`}),n&&t(n),a&&e(a);}}},I=U;var q=typeof window>"u",G=o=>{window.setTimeout(o,0);},W=o=>{let t=async a=>{await o.show({publicKey:a,onUserCanceled:()=>{var i;(i=window.onFootprintCanceled)==null||i.call(window);},onCompleted:i=>{var s;(s=window.onFootprintCompleted)==null||s.call(window,i);}});},e=()=>{let a=document.getElementById("footprint-button");if(!a)return;let i=a.getAttribute("data-public-key");if(!i)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");r(i,a);},r=(a,i)=>{G(()=>{C(i).addEventListener("click",()=>{t(a);});});},n=()=>{q||document.addEventListener("DOMContentLoaded",()=>e());};return ()=>{n();}},D=W;var X=(o="production",t)=>o==="local"?"http://localhost:3000/":o==="development"?"https://id.preview.onefootprint.com":o==="preview"&&t?t==="development"?"https://id.preview.onefootprint.com":`https://bifrost-git-${t.toLowerCase().split("/").join("-")}.preview.onefootprint.com`:"https://id.onefootprint.com",Z=X("production",""),F=I(Z);D(F)();var pt=F;/**
postmate - A powerful, simple, promise-based postMessage library
@version v1.5.2
@link https://github.com/dollarshaveclub/postmate
@author Jacob Kelley <jakie8@gmail.com>
@license MIT
**/
@keyframes footprint-rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
return pt;
.footprint-loading-indicator {
background: rgba(0, 0, 0, 0.6);
border-radius: 4px;
padding: 16px;
}
.footprint-loading-spin {
animation: footprint-rotate 0.8s linear infinite;
}
.footprint-modal {
height: 100%;
left: 0;
position: fixed;
top: 0;
width: 100%;
z-index: 50001;
}
.footprint-button {
-webkit-box-align: center;
align-items: center;
background-color: rgb(14, 20, 56);
border-radius: 6px;
border: 0px;
box-shadow: rgb(0 0 0 / 0%) 0px 1px 1px, transparent 0px 0px 0px 1px;
color: rgb(255, 255, 255);
cursor: pointer;
display: flex;
-webkit-box-pack: center;
justify-content: center;
text-decoration: none;
user-select: none;
font-family: "DM Sans";
font-size: 16px;
font-weight: 500;
line-height: 24px;
padding: 12px 24px;
}
.footprint-button:hover {
background: linear-gradient(rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.14)), linear-gradient(rgb(14, 20, 56), rgb(14, 20, 56));
}
.footprint-button:active {
background: linear-gradient(rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.18)), linear-gradient(rgb(14, 20, 56), rgb(14, 20, 56));
}
.footprint-button svg {
margin-right: 8px;
}
`,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;})();
/**
postmate - A powerful, simple, promise-based postMessage library
@version v1.5.2
@link https://github.com/dollarshaveclub/postmate
@author Jacob Kelley <jakie8@gmail.com>
@license MIT
**/
})();
{
"name": "@onefootprint/footprint-js",
"private": false,
"version": "0.3.0",
"version": "0.3.1-beta.0",
"main": "./dist/footprint-js.umd.js",

@@ -28,10 +28,11 @@ "module": "./dist/footprint-js.esm.js",

"devDependencies": {
"@onefootprint/jest-presets": "*",
"@onefootprint/types": "*",
"@types/postmate": "^1.5.2",
"eslint-config-footprint": "*",
"jest-presets": "*",
"postcss": "^8.4.17",
"postmate": "^1.5.2",
"tsconfig": "*",
"tsup": "^6.2.2",
"@onefootprint/types": "*",
"typescript": "4.7.4"
"typescript": "4.8.4"
},

@@ -42,4 +43,4 @@ "publishConfig": {

"jest": {
"preset": "jest-presets/jest/web"
"preset": "@onefootprint/jest-presets/jest/web"
}
}
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