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.0.6 to 0.0.7

1

dist/footprint-js.js

@@ -288,3 +288,4 @@ var k = Object.defineProperty;

export {
u as FootprintEvents,
U as default
};

4

dist/footprint-js.umd.js

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

(function(u,s){typeof exports=="object"&&typeof module<"u"?module.exports=s():typeof define=="function"&&define.amd?define(s):(u=typeof globalThis<"u"?globalThis:u||self,u.FootprintJS=s())})(this,function(){"use strict";var Z=Object.defineProperty;var G=(u,s,l)=>s in u?Z(u,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):u[s]=l;var C=(u,s,l)=>(G(u,typeof s!="symbol"?s+"":s,l),l);const u="";var s=(o=>(o.closed="closed",o.completed="completed",o.canceled="canceled",o))(s||{});/**
(function(c,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(c=typeof globalThis<"u"?globalThis:c||self,p(c.FootprintJS={}))})(this,function(c){"use strict";var G=Object.defineProperty;var J=(c,p,u)=>p in c?G(c,p,{enumerable:!0,configurable:!0,writable:!0,value:u}):c[p]=u;var O=(c,p,u)=>(J(c,typeof p!="symbol"?p+"":p,u),u);const p="";var u=(o=>(o.closed="closed",o.completed="completed",o.canceled="canceled",o))(u||{});/**
postmate - A powerful, simple, promise-based postMessage library

@@ -7,2 +7,2 @@ @version v1.5.2

@license MIT
**/var l="application/x-postmate-v1+json",O=5,P=0,M=function(){return++P},_=function(n){var t=document.createElement("a");t.href=n;var r=t.protocol.length>4?t.protocol:window.location.protocol,e=t.host.length?t.port==="80"||t.port==="443"?t.hostname:t.host:window.location.host;return t.origin||r+"//"+e},F={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},f=function(n,t){return!(typeof t=="string"&&n.origin!==t||!n.data||typeof n.data=="object"&&!("postmate"in n.data)||n.data.type!==l||!F[n.data.postmate])},x=function(n,t){var r=typeof n[t]=="function"?n[t]():n[t];return h.Promise.resolve(r)},N=function(){function o(t){var r=this;this.parent=t.parent,this.frame=t.frame,this.child=t.child,this.childOrigin=t.childOrigin,this.events={},this.listener=function(e){if(!f(e,r.childOrigin))return!1;var a=((e||{}).data||{}).value||{},i=a.data,d=a.name;e.data.postmate==="emit"&&d in r.events&&r.events[d].call(r,i)},this.parent.addEventListener("message",this.listener,!1)}var n=o.prototype;return n.get=function(r){var e=this;return new h.Promise(function(a){var i=M(),d=function c(p){p.data.uid===i&&p.data.postmate==="reply"&&(e.parent.removeEventListener("message",c,!1),a(p.data.value))};e.parent.addEventListener("message",d,!1),e.child.postMessage({postmate:"request",type:l,property:r,uid:i},e.childOrigin)})},n.call=function(r,e){this.child.postMessage({postmate:"call",type:l,property:r,data:e},this.childOrigin)},n.on=function(r,e){this.events[r]=e},n.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},o}(),B=function(){function o(t){var r=this;this.model=t.model,this.parent=t.parent,this.parentOrigin=t.parentOrigin,this.child=t.child,this.child.addEventListener("message",function(e){if(!!f(e,r.parentOrigin)){var a=e.data,i=a.property,d=a.uid,c=a.data;if(e.data.postmate==="call"){i in r.model&&typeof r.model[i]=="function"&&r.model[i](c);return}x(r.model,i).then(function(p){return e.source.postMessage({property:i,postmate:"reply",type:l,uid:d,value:p},e.origin)})}})}var n=o.prototype;return n.emit=function(r,e){this.parent.postMessage({postmate:"emit",type:l,value:{name:r,data:e}},this.parentOrigin)},o}(),h=function(){function o(t){var r=t.container,e=r===void 0?typeof e<"u"?e:document.body:r,a=t.model,i=t.url,d=t.name,c=t.classListArray,p=c===void 0?[]:c;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=d||"",this.frame.classList.add.apply(this.frame.classList,p),e.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=a||{},this.sendHandshake(i)}var n=o.prototype;return n.sendHandshake=function(r){var e=this,a=_(r),i=0,d;return new o.Promise(function(c,p){var m=function g(y){return f(y,a)?y.data.postmate==="handshake-reply"?(clearInterval(d),e.parent.removeEventListener("message",g,!1),e.childOrigin=y.origin,c(new N(e))):p("Failed handshake"):!1};e.parent.addEventListener("message",m,!1);var I=function(){i++,e.child.postMessage({postmate:"handshake",type:l,model:e.model},a),i===O&&clearInterval(d)},k=function(){I(),d=setInterval(I,500)};e.frame.attachEvent?e.frame.attachEvent("onload",k):e.frame.onload=k,e.frame.src=r})},o}();h.debug=!1,h.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}(),h.Model=function(){function o(t){return this.child=window,this.model=t,this.parent=this.child.parent,this.sendHandshakeReply()}var n=o.prototype;return n.sendHandshakeReply=function(){var r=this;return new h.Promise(function(e,a){var i=function d(c){if(!!c.data.postmate){if(c.data.postmate==="handshake"){r.child.removeEventListener("message",d,!1),c.source.postMessage({postmate:"handshake-reply",type:l},c.origin),r.parentOrigin=c.origin;var p=c.data.model;return p&&Object.keys(p).forEach(function(m){r.model[m]=p[m]}),e(new B(r))}return a("Handshake Reply Failed")}};r.child.addEventListener("message",i,!1)})},o}();const w="footprint-container",b="footprint-overlay",A="footprint-loading-indicator",H=o=>{const n=L();return o.appendChild(n),n},R=o=>{document.body.classList.add("footprint-body-locked");const n=document.createElement("div");n.setAttribute("id",b);const t=V(A);n.appendChild(t),n.classList.add("footprint-overlay"),o.appendChild(n)},S=()=>{const o=document.getElementById(A);o&&o.remove()},T=()=>{document.body.classList.remove("footprint-body-locked");const o=document.getElementById(b);o&&o.remove()},D=()=>{const o=document.getElementById(w);if(o)return o;const n=document.createElement("div");return n.setAttribute("id",w),document.body.appendChild(n),n},V=o=>{const n=document.createElement("div");n.setAttribute("id",o),n.classList.add("footprint-loading-indicator");const t=document.createElement("div");t.classList.add("footprint-loading-spin");const 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");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),e.setAttribute("fill","#FFFFFF"),r.appendChild(e),t.appendChild(r),n.appendChild(t),n},$=()=>{const 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");const n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.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"),n.setAttribute("fill","#76fb8f"),o.appendChild(n),o},L=()=>{const o=$(),n=document.createElement("button");n.appendChild(o);const t=document.createElement("span");return t.innerText="Verify with Footprint",n.appendChild(t),n.classList.add("footprint-button"),n};class j{constructor(){C(this,"child",null)}async show(n){const{url:t}=n,r=()=>{S()},e=D();R(e);const a=await new h({classListArray:["footprint-modal"],container:e,name:"footprint-iframe",url:t});a.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),r(),a.on(s.closed,()=>this.hide()),this.child=a}on(n,t){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(n,t)}hide(){T(),this.child&&this.child.destroy()}createButton(n){const t=L();return n.appendChild(t),t}}const v=new j,q=o=>{const n=r=>v.on(s.completed,e=>{e&&typeof e=="string"&&r(e)}),t=r=>v.on(s.canceled,r);return{show:async({publicKey:r,onCompleted:e,onCanceled:a})=>{await v.show({url:r?`${o}?public_key=${r}`:o}),e&&n(e),a&&t(a)}}},z=o=>{window.setTimeout(o,0)},U=o=>{if(typeof window>"u")return;const n=async e=>{await o.show({publicKey:e,onCanceled:()=>{var a;(a=window.onFootprintCanceled)==null||a.call(window)},onCompleted:a=>{var i;(i=window.onFootprintCompleted)==null||i.call(window,a)}})},t=()=>{const e=document.getElementById("footprint-button");if(!e)return;const a=e.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,e)},r=(e,a)=>{z(()=>{H(a).addEventListener("click",()=>{n(e)})})};document.addEventListener("DOMContentLoaded",()=>t())},W=(()=>"https://id.onefootprint.com")(),E=q(W);return U(E),E});
**/var h="application/x-postmate-v1+json",M=5,P=0,_=function(){return++P},F=function(n){var t=document.createElement("a");t.href=n;var a=t.protocol.length>4?t.protocol:window.location.protocol,e=t.host.length?t.port==="80"||t.port==="443"?t.hostname:t.host:window.location.host;return t.origin||a+"//"+e},N={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},v=function(n,t){return!(typeof t=="string"&&n.origin!==t||!n.data||typeof n.data=="object"&&!("postmate"in n.data)||n.data.type!==h||!N[n.data.postmate])},x=function(n,t){var a=typeof n[t]=="function"?n[t]():n[t];return f.Promise.resolve(a)},B=function(){function o(t){var a=this;this.parent=t.parent,this.frame=t.frame,this.child=t.child,this.childOrigin=t.childOrigin,this.events={},this.listener=function(e){if(!v(e,a.childOrigin))return!1;var r=((e||{}).data||{}).value||{},i=r.data,s=r.name;e.data.postmate==="emit"&&s in a.events&&a.events[s].call(a,i)},this.parent.addEventListener("message",this.listener,!1)}var n=o.prototype;return n.get=function(a){var e=this;return new f.Promise(function(r){var i=_(),s=function d(l){l.data.uid===i&&l.data.postmate==="reply"&&(e.parent.removeEventListener("message",d,!1),r(l.data.value))};e.parent.addEventListener("message",s,!1),e.child.postMessage({postmate:"request",type:h,property:a,uid:i},e.childOrigin)})},n.call=function(a,e){this.child.postMessage({postmate:"call",type:h,property:a,data:e},this.childOrigin)},n.on=function(a,e){this.events[a]=e},n.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},o}(),S=function(){function o(t){var a=this;this.model=t.model,this.parent=t.parent,this.parentOrigin=t.parentOrigin,this.child=t.child,this.child.addEventListener("message",function(e){if(!!v(e,a.parentOrigin)){var r=e.data,i=r.property,s=r.uid,d=r.data;if(e.data.postmate==="call"){i in a.model&&typeof a.model[i]=="function"&&a.model[i](d);return}x(a.model,i).then(function(l){return e.source.postMessage({property:i,postmate:"reply",type:h,uid:s,value:l},e.origin)})}})}var n=o.prototype;return n.emit=function(a,e){this.parent.postMessage({postmate:"emit",type:h,value:{name:a,data:e}},this.parentOrigin)},o}(),f=function(){function o(t){var a=t.container,e=a===void 0?typeof e<"u"?e:document.body:a,r=t.model,i=t.url,s=t.name,d=t.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),e.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=r||{},this.sendHandshake(i)}var n=o.prototype;return n.sendHandshake=function(a){var e=this,r=F(a),i=0,s;return new o.Promise(function(d,l){var m=function y(w){return v(w,r)?w.data.postmate==="handshake-reply"?(clearInterval(s),e.parent.removeEventListener("message",y,!1),e.childOrigin=w.origin,d(new B(e))):l("Failed handshake"):!1};e.parent.addEventListener("message",m,!1);var k=function(){i++,e.child.postMessage({postmate:"handshake",type:h,model:e.model},r),i===M&&clearInterval(s)},C=function(){k(),s=setInterval(k,500)};e.frame.attachEvent?e.frame.attachEvent("onload",C):e.frame.onload=C,e.frame.src=a})},o}();f.debug=!1,f.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}(),f.Model=function(){function o(t){return this.child=window,this.model=t,this.parent=this.child.parent,this.sendHandshakeReply()}var n=o.prototype;return n.sendHandshakeReply=function(){var a=this;return new f.Promise(function(e,r){var i=function s(d){if(!!d.data.postmate){if(d.data.postmate==="handshake"){a.child.removeEventListener("message",s,!1),d.source.postMessage({postmate:"handshake-reply",type:h},d.origin),a.parentOrigin=d.origin;var l=d.data.model;return l&&Object.keys(l).forEach(function(m){a.model[m]=l[m]}),e(new S(a))}return r("Handshake Reply Failed")}};a.child.addEventListener("message",i,!1)})},o}();const b="footprint-container",A="footprint-overlay",E="footprint-loading-indicator",H=o=>{const n=L();return o.appendChild(n),n},T=o=>{document.body.classList.add("footprint-body-locked");const n=document.createElement("div");n.setAttribute("id",A);const t=$(E);n.appendChild(t),n.classList.add("footprint-overlay"),o.appendChild(n)},R=()=>{const o=document.getElementById(E);o&&o.remove()},D=()=>{document.body.classList.remove("footprint-body-locked");const o=document.getElementById(A);o&&o.remove()},V=()=>{const o=document.getElementById(b);if(o)return o;const n=document.createElement("div");return n.setAttribute("id",b),document.body.appendChild(n),n},$=o=>{const n=document.createElement("div");n.setAttribute("id",o),n.classList.add("footprint-loading-indicator");const t=document.createElement("div");t.classList.add("footprint-loading-spin");const a=document.createElementNS("http://www.w3.org/2000/svg","svg");a.setAttribute("width","24px"),a.setAttribute("height","24px"),a.setAttribute("fill","none"),a.setAttribute("aria-hidden","true");const e=document.createElementNS("http://www.w3.org/2000/svg","path");return e.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),e.setAttribute("fill","#FFFFFF"),a.appendChild(e),t.appendChild(a),n.appendChild(t),n},j=()=>{const 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");const n=document.createElementNS("http://www.w3.org/2000/svg","path");return n.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"),n.setAttribute("fill","#76fb8f"),o.appendChild(n),o},L=()=>{const o=j(),n=document.createElement("button");n.appendChild(o);const t=document.createElement("span");return t.innerText="Verify with Footprint",n.appendChild(t),n.classList.add("footprint-button"),n};class q{constructor(){O(this,"child",null)}async show(n){const{url:t}=n,a=()=>{R()},e=V();T(e);const r=await new f({classListArray:["footprint-modal"],container:e,name:"footprint-iframe",url:t});r.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),a(),r.on(u.closed,()=>this.hide()),this.child=r}on(n,t){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(n,t)}hide(){D(),this.child&&this.child.destroy()}createButton(n){const t=L();return n.appendChild(t),t}}const g=new q,z=o=>{const n=a=>g.on(u.completed,e=>{e&&typeof e=="string"&&a(e)}),t=a=>g.on(u.canceled,a);return{show:async({publicKey:a,onCompleted:e,onCanceled:r})=>{await g.show({url:a?`${o}?public_key=${a}`:o}),e&&n(e),r&&t(r)}}},U=o=>{window.setTimeout(o,0)},W=o=>{if(typeof window>"u")return;const n=async e=>{await o.show({publicKey:e,onCanceled:()=>{var r;(r=window.onFootprintCanceled)==null||r.call(window)},onCompleted:r=>{var i;(i=window.onFootprintCompleted)==null||i.call(window,r)}})},t=()=>{const e=document.getElementById("footprint-button");if(!e)return;const r=e.getAttribute("data-public-key");if(!r)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");a(r,e)},a=(e,r)=>{U(()=>{H(r).addEventListener("click",()=>{n(e)})})};document.addEventListener("DOMContentLoaded",()=>t())},Z=(()=>"https://id.onefootprint.com")(),I=z(Z);W(I),c.FootprintEvents=u,c.default=I,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});

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

export declare type Flow = 'authentication' | 'onboarding';
export declare enum FootprintEvents {

@@ -3,0 +2,0 @@ closed = "closed",

declare const footprint: {
show: ({ publicKey, onCompleted, onCanceled }: import("./footprint-types").ShowFootprint) => Promise<void>;
};
export * from './footprint-types';
export default footprint;
//# sourceMappingURL=index.d.ts.map

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

"type": "module",
"version": "0.0.6",
"version": "0.0.7",
"main": "./dist/footprint-js.umd.cjs",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc