@onefootprint/footprint-js
Advanced tools
Comparing version 0.0.8-alpha.1 to 0.0.8-alpha.2
@@ -1,3 +0,153 @@ | ||
export * from './index' | ||
import FootprintJS from './index' | ||
export default FootprintJS | ||
import * as CSS from 'csstype'; | ||
declare type FootprintShowParams = { | ||
publicKey: string; | ||
onCompleted: (validationToken: string) => void; | ||
onCanceled: () => void; | ||
}; | ||
declare type FootprintAppearanceParams = { | ||
fontSrc?: string; | ||
rules?: FootprintAppearanceRules; | ||
theme?: FootprintAppearanceTheme; | ||
variables?: FootprintAppearanceVariables; | ||
}; | ||
declare type FootprintAppearanceVariables = FootprintMainStyles & FootprintExternalStyles; | ||
declare type FootprintAppearanceTheme = 'light' | 'dark'; | ||
declare type FootprintAppearanceRules = Partial<{ | ||
button: CSS.Properties; | ||
'button:hover': CSS.Properties; | ||
'button:focus': CSS.Properties; | ||
'button:active': CSS.Properties; | ||
input: CSS.Properties; | ||
'input:hover': CSS.Properties; | ||
'input:focus': CSS.Properties; | ||
'input:active': CSS.Properties; | ||
label: CSS.Properties; | ||
hint: CSS.Properties; | ||
link: CSS.Properties; | ||
'link:hover': CSS.Properties; | ||
'link:active': CSS.Properties; | ||
}>; | ||
declare type FootprintMainStyles = Partial<{ | ||
borderRadius: CSS.Property.BorderRadius; | ||
colorInfo: CSS.Property.Color; | ||
colorError: CSS.Property.Color; | ||
colorWarning: CSS.Property.Color; | ||
colorSuccess: CSS.Property.Color; | ||
colorAccent: CSS.Property.Color; | ||
borderColorError: CSS.Property.BorderColor; | ||
linkColor: CSS.Property.Color; | ||
dialogBg: CSS.Property.Background; | ||
dialogBoxShadow: CSS.Property.BoxShadow; | ||
dialogBorderRadius: CSS.Property.BorderRadius; | ||
fontFamily: CSS.Property.FontFamily; | ||
labelColor: CSS.Property.Color; | ||
labelFont: CSS.Property.Font; | ||
inputBorderRadius: CSS.Property.BorderRadius; | ||
inputBorderWidth: CSS.Property.BorderWidth; | ||
inputFont: CSS.Property.Font; | ||
inputHeight: CSS.Property.Height; | ||
inputPlaceholderColor: CSS.Property.Color; | ||
inputColor: CSS.Property.Color; | ||
inputBg: CSS.Property.Background; | ||
inputBorderColor: CSS.Property.BorderColor; | ||
inputHoverBg: CSS.Property.Background; | ||
inputHoverBorderColor: CSS.Property.BorderColor; | ||
inputFocusBg: CSS.Property.Background; | ||
inputFocusBorderColor: CSS.Property.BorderColor; | ||
inputFocusElevation: CSS.Property.BoxShadow; | ||
inputErrorBg: CSS.Property.Background; | ||
inputErrorBorderColor: CSS.Property.BorderColor; | ||
inputErrorHoverBg: CSS.Property.Background; | ||
inputErrorHoverBorderColor: CSS.Property.BorderColor; | ||
inputErrorFocusBg: CSS.Property.Background; | ||
inputErrorFocusBorderColor: CSS.Property.BorderColor; | ||
inputErrorFocusElevation: CSS.Property.BoxShadow; | ||
hintColor: CSS.Property.Color; | ||
hintErrorColor: CSS.Property.Color; | ||
hintFont: CSS.Property.Font; | ||
linkButtonColor: CSS.Property.Color; | ||
linkButtonHoverColor: CSS.Property.Color; | ||
linkButtonActiveColor: CSS.Property.Color; | ||
linkButtonDestructiveColor: CSS.Property.Color; | ||
linkButtonDestructiveHoverColor: CSS.Property.Color; | ||
linkButtonDestructiveActiveColor: CSS.Property.Color; | ||
buttonBorderRadius: CSS.Property.BorderRadius; | ||
buttonBorderWidth: CSS.Property.BorderWidth; | ||
buttonElevation: CSS.Property.BoxShadow; | ||
buttonElevationHover: CSS.Property.BoxShadow; | ||
buttonElevationActive: CSS.Property.BoxShadow; | ||
buttonOutlineOffset: CSS.Property.OutlineOffset; | ||
buttonPrimaryBg: CSS.Property.Background; | ||
buttonPrimaryColor: CSS.Property.Color; | ||
buttonPrimaryBorderColor: CSS.Property.BorderColor; | ||
buttonPrimaryHoverBg: CSS.Property.Background; | ||
buttonPrimaryHoverColor: CSS.Property.Color; | ||
buttonPrimaryHoverBorderColor: CSS.Property.BorderColor; | ||
buttonPrimaryActiveBg: CSS.Property.Background; | ||
buttonPrimaryActiveColor: CSS.Property.Color; | ||
buttonPrimaryActiveBorderColor: CSS.Property.BorderColor; | ||
buttonPrimaryDisabledBg: CSS.Property.Background; | ||
buttonPrimaryDisabledColor: CSS.Property.Color; | ||
buttonPrimaryDisabledBorderColor: CSS.Property.BorderColor; | ||
buttonPrimaryLoadingBg: CSS.Property.Background; | ||
buttonPrimaryLoadingColor: CSS.Property.Color; | ||
buttonSecondaryBg: CSS.Property.Background; | ||
buttonSecondaryColor: CSS.Property.Color; | ||
buttonSecondaryBorderColor: CSS.Property.BorderColor; | ||
buttonSecondaryHoverBg: CSS.Property.Background; | ||
buttonSecondaryHoverColor: CSS.Property.Color; | ||
buttonSecondaryHoverBorderColor: CSS.Property.BorderColor; | ||
buttonSecondaryActiveBg: CSS.Property.Background; | ||
buttonSecondaryActiveColor: CSS.Property.Color; | ||
buttonSecondaryActiveBorderColor: CSS.Property.BorderColor; | ||
buttonSecondaryDisabledBg: CSS.Property.Background; | ||
buttonSecondaryDisabledColor: CSS.Property.Color; | ||
buttonSecondaryDisabledBorderColor: CSS.Property.BorderColor; | ||
buttonSecondaryLoadingBg: CSS.Property.Background; | ||
buttonSecondaryLoadingColor: CSS.Property.Color; | ||
dropdownBg: CSS.Property.Background; | ||
dropdownHoverBg: CSS.Property.Background; | ||
dropdownBorderColor: CSS.Property.BorderColor; | ||
dropdownBorderWidth: CSS.Property.BorderWidth; | ||
dropdownBorderRadius: CSS.Property.BorderRadius; | ||
dropdownElevation: CSS.Property.BoxShadow; | ||
dropdownColorPrimary: CSS.Property.Color; | ||
dropdownColorSecondary: CSS.Property.Color; | ||
dropdownFooterBg: CSS.Property.Background; | ||
}>; | ||
declare type FootprintExternalStyles = Partial<{ | ||
fpButtonHeight: CSS.Property.Height; | ||
fpButtonBorderRadius: CSS.Property.Height; | ||
loadingBg: CSS.Property.Background; | ||
loadingColor: CSS.Property.Color; | ||
loadingBorderRadius: CSS.Property.BorderRadius; | ||
loadingPadding: CSS.Property.Padding; | ||
overlayBg: CSS.Property.Background; | ||
}>; | ||
declare type FootprintAppearance = { | ||
fontSrc?: string; | ||
rules?: FootprintAppearanceRules; | ||
theme?: FootprintAppearanceTheme; | ||
variables?: FootprintAppearanceVariables; | ||
}; | ||
declare type ShowFootprint = { | ||
appearance?: FootprintAppearance; | ||
onCanceled?: () => void; | ||
onCompleted?: (validationToken: string) => void; | ||
publicKey?: string; | ||
}; | ||
declare type Footprint = { | ||
show: ({ publicKey, onCompleted, onCanceled, }: ShowFootprint) => Promise<void>; | ||
}; | ||
declare enum FootprintEvents { | ||
closed = "closed", | ||
completed = "completed", | ||
canceled = "canceled" | ||
} | ||
declare const footprint: { | ||
show: ({ appearance, publicKey, onCompleted, onCanceled, }: ShowFootprint) => Promise<void>; | ||
}; | ||
export { Footprint, FootprintAppearance, FootprintAppearanceParams, FootprintAppearanceRules, FootprintAppearanceTheme, FootprintAppearanceVariables, FootprintEvents, FootprintExternalStyles, FootprintMainStyles, FootprintShowParams, ShowFootprint, footprint as default }; |
@@ -1,17 +0,29 @@ | ||
(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 et=Object.defineProperty;var nt=(c,p,f)=>p in c?et(c,p,{enumerable:!0,configurable:!0,writable:!0,value:f}):c[p]=f;var S=(c,p,f)=>(nt(c,typeof p!="symbol"?p+"":p,f),f);const p="",f=()=>"https://id.onefootprint.com",P=e=>{const n=f(),{publicKey:t,variables:r,rules:o,fontSrc:i}=e,a=new URLSearchParams;return t&&a.append("public_key",t),r&&a.append("tokens",r),o&&a.append("rules",o),i&&a.append("font_src",i),`${n}?${a.toString()}`},_=({fontSrc:e,variables:n={},rules:t={}}={})=>{const{fpButtonBorderRadius:r,fpButtonHeight:o,loadingBg:i,loadingBorderRadius:a,loadingColor:s,loadingPadding:d,overlayBg:l,...u}=n,h=()=>Object.keys(u).length?encodeURIComponent(JSON.stringify(u)):void 0,y=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0;return{fontSrc:e,variables:h(),rules:y()}};var w=(e=>(e.closed="closed",e.completed="completed",e.canceled="canceled",e))(w||{});/** | ||
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 | ||
**/var m="application/x-postmate-v1+json",M=5,R=0,$=function(){return++R},N=function(n){var t=document.createElement("a");t.href=n;var r=t.protocol.length>4?t.protocol:window.location.protocol,o=t.host.length?t.port==="80"||t.port==="443"?t.hostname:t.host:window.location.host;return t.origin||r+"//"+o},H={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},b=function(n,t){return!(typeof t=="string"&&n.origin!==t||!n.data||typeof n.data=="object"&&!("postmate"in n.data)||n.data.type!==m||!H[n.data.postmate])},T=function(n,t){var r=typeof n[t]=="function"?n[t]():n[t];return g.Promise.resolve(r)},x=function(){function e(t){var r=this;this.parent=t.parent,this.frame=t.frame,this.child=t.child,this.childOrigin=t.childOrigin,this.events={},this.listener=function(o){if(!b(o,r.childOrigin))return!1;var i=((o||{}).data||{}).value||{},a=i.data,s=i.name;o.data.postmate==="emit"&&s in r.events&&r.events[s].call(r,a)},this.parent.addEventListener("message",this.listener,!1)}var n=e.prototype;return n.get=function(r){var o=this;return new g.Promise(function(i){var a=$(),s=function d(l){l.data.uid===a&&l.data.postmate==="reply"&&(o.parent.removeEventListener("message",d,!1),i(l.data.value))};o.parent.addEventListener("message",s,!1),o.child.postMessage({postmate:"request",type:m,property:r,uid:a},o.childOrigin)})},n.call=function(r,o){this.child.postMessage({postmate:"call",type:m,property:r,data:o},this.childOrigin)},n.on=function(r,o){this.events[r]=o},n.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},e}(),F=function(){function e(t){var r=this;this.model=t.model,this.parent=t.parent,this.parentOrigin=t.parentOrigin,this.child=t.child,this.child.addEventListener("message",function(o){if(!!b(o,r.parentOrigin)){var i=o.data,a=i.property,s=i.uid,d=i.data;if(o.data.postmate==="call"){a in r.model&&typeof r.model[a]=="function"&&r.model[a](d);return}T(r.model,a).then(function(l){return o.source.postMessage({property:a,postmate:"reply",type:m,uid:s,value:l},o.origin)})}})}var n=e.prototype;return n.emit=function(r,o){this.parent.postMessage({postmate:"emit",type:m,value:{name:r,data:o}},this.parentOrigin)},e}(),g=function(){function e(t){var r=t.container,o=r===void 0?typeof o<"u"?o:document.body:r,i=t.model,a=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),o.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var n=e.prototype;return n.sendHandshake=function(r){var o=this,i=N(r),a=0,s;return new e.Promise(function(d,l){var u=function I(L){return b(L,i)?L.data.postmate==="handshake-reply"?(clearInterval(s),o.parent.removeEventListener("message",I,!1),o.childOrigin=L.origin,d(new x(o))):l("Failed handshake"):!1};o.parent.addEventListener("message",u,!1);var h=function(){a++,o.child.postMessage({postmate:"handshake",type:m,model:o.model},i),a===M&&clearInterval(s)},y=function(){h(),s=setInterval(h,500)};o.frame.attachEvent?o.frame.attachEvent("onload",y):o.frame.onload=y,o.frame.src=r})},e}();g.debug=!1,g.Promise=function(){try{return window?window.Promise:Promise}catch{return null}}(),g.Model=function(){function e(t){return this.child=window,this.model=t,this.parent=this.child.parent,this.sendHandshakeReply()}var n=e.prototype;return n.sendHandshakeReply=function(){var r=this;return new g.Promise(function(o,i){var a=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:m},d.origin),r.parentOrigin=d.origin;var l=d.data.model;return l&&Object.keys(l).forEach(function(u){r.model[u]=l[u]}),o(new F(r))}return i("Handshake Reply Failed")}};r.child.addEventListener("message",a,!1)})},e}();const C="footprint-container",A="footprint-overlay",O="footprint-loading-indicator",j="footprint-custom-styles",D=e=>{if(typeof window>"u")return;const n=document.getElementById(j);n&&n.remove();const t=document.createElement("style");t.setAttribute("id","footprint-custom-styles"),t.textContent=e,document.head.append(t)},v=(e,n)=>n?`${e}: ${n}`:"",V=({variables:e={}})=>{D(` | ||
(function (exports) { | ||
'use strict'; | ||
var E=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var w=(e,o)=>{var t={};for(var n in e)W.call(e,n)&&o.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&E)for(var n of E(e))o.indexOf(n)<0&&U.call(e,n)&&(t[n]=e[n]);return t};var g=(e,o,t)=>new Promise((n,r)=>{var i=p=>{try{d(t.next(p));}catch(s){r(s);}},a=p=>{try{d(t.throw(p));}catch(s){r(s);}},d=p=>p.done?n(p.value):Promise.resolve(p.value).then(i,a);d((t=t.apply(e,o)).next());});var A=(n=>(n.closed="closed",n.completed="completed",n.canceled="canceled",n))(A||{});var h="application/x-postmate-v1+json",K=5,q=0,z=function(){return ++q},l=function(){var o;return y.debug?(o=console).log.apply(o,arguments):null},J=function(o){var t=document.createElement("a");t.href=o;var n=t.protocol.length>4?t.protocol:window.location.protocol,r=t.host.length?t.port==="80"||t.port==="443"?t.hostname:t.host:window.location.host;return t.origin||n+"//"+r},Y={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},v=function(o,t){return !(typeof t=="string"&&o.origin!==t||!o.data||typeof o.data=="object"&&!("postmate"in o.data)||o.data.type!==h||!Y[o.data.postmate])},Z=function(o,t){var n=typeof o[t]=="function"?o[t]():o[t];return y.Promise.resolve(n)},G=function(){function e(t){var n=this;this.parent=t.parent,this.frame=t.frame,this.child=t.child,this.childOrigin=t.childOrigin,this.events={},process.env.NODE_ENV!=="production"&&(l("Parent: Registering API"),l("Parent: Awaiting messages...")),this.listener=function(r){if(!v(r,n.childOrigin))return !1;var i=((r||{}).data||{}).value||{},a=i.data,d=i.name;r.data.postmate==="emit"&&(process.env.NODE_ENV!=="production"&&l("Parent: Received event emission: "+d),d in n.events&&n.events[d].call(n,a));},this.parent.addEventListener("message",this.listener,!1),process.env.NODE_ENV!=="production"&&l("Parent: Awaiting event emissions from Child");}var o=e.prototype;return o.get=function(n){var r=this;return new y.Promise(function(i){var a=z(),d=function p(s){s.data.uid===a&&s.data.postmate==="reply"&&(r.parent.removeEventListener("message",p,!1),i(s.data.value));};r.parent.addEventListener("message",d,!1),r.child.postMessage({postmate:"request",type:h,property:n,uid:a},r.childOrigin);})},o.call=function(n,r){this.child.postMessage({postmate:"call",type:h,property:n,data:r},this.childOrigin);},o.on=function(n,r){this.events[n]=r;},o.destroy=function(){process.env.NODE_ENV!=="production"&&l("Parent: Destroying Postmate instance"),window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame);},e}(),Q=function(){function e(t){var n=this;this.model=t.model,this.parent=t.parent,this.parentOrigin=t.parentOrigin,this.child=t.child,process.env.NODE_ENV!=="production"&&(l("Child: Registering API"),l("Child: Awaiting messages...")),this.child.addEventListener("message",function(r){if(!!v(r,n.parentOrigin)){process.env.NODE_ENV!=="production"&&l("Child: Received request",r.data);var i=r.data,a=i.property,d=i.uid,p=i.data;if(r.data.postmate==="call"){a in n.model&&typeof n.model[a]=="function"&&n.model[a](p);return}Z(n.model,a).then(function(s){return r.source.postMessage({property:a,postmate:"reply",type:h,uid:d,value:s},r.origin)});}});}var o=e.prototype;return o.emit=function(n,r){process.env.NODE_ENV!=="production"&&l('Child: Emitting Event "'+n+'"',r),this.parent.postMessage({postmate:"emit",type:h,value:{name:n,data:r}},this.parentOrigin);},e}(),y=function(){function e(t){var n=t.container,r=n===void 0?typeof r!="undefined"?r:document.body:n,i=t.model,a=t.url,d=t.name,p=t.classListArray,s=p===void 0?[]:p;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=d||"",this.frame.classList.add.apply(this.frame.classList,s),r.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=i||{},this.sendHandshake(a)}var o=e.prototype;return o.sendHandshake=function(n){var r=this,i=J(n),a=0,d;return new e.Promise(function(p,s){var c=function m(f){return v(f,i)?f.data.postmate==="handshake-reply"?(clearInterval(d),process.env.NODE_ENV!=="production"&&l("Parent: Received handshake reply from Child"),r.parent.removeEventListener("message",m,!1),r.childOrigin=f.origin,process.env.NODE_ENV!=="production"&&l("Parent: Saving Child origin",r.childOrigin),p(new G(r))):(process.env.NODE_ENV!=="production"&&l("Parent: Invalid handshake reply"),s("Failed handshake")):!1};r.parent.addEventListener("message",c,!1);var u=function(){a++,process.env.NODE_ENV!=="production"&&l("Parent: Sending handshake attempt "+a,{childOrigin:i}),r.child.postMessage({postmate:"handshake",type:h,model:r.model},i),a===K&&clearInterval(d);},S=function(){u(),d=setInterval(u,500);};r.frame.attachEvent?r.frame.attachEvent("onload",S):r.frame.onload=S,process.env.NODE_ENV!=="production"&&l("Parent: Loading frame",{url:n}),r.frame.src=n;})},e}();y.debug=!1;y.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}();y.Model=function(){function e(t){return this.child=window,this.model=t,this.parent=this.child.parent,this.sendHandshakeReply()}var o=e.prototype;return o.sendHandshakeReply=function(){var n=this;return new y.Promise(function(r,i){var a=function d(p){if(!!p.data.postmate){if(p.data.postmate==="handshake"){process.env.NODE_ENV!=="production"&&l("Child: Received handshake from Parent"),n.child.removeEventListener("message",d,!1),process.env.NODE_ENV!=="production"&&l("Child: Sending handshake reply to Parent"),p.source.postMessage({postmate:"handshake-reply",type:h},p.origin),n.parentOrigin=p.origin;var s=p.data.model;return s&&(Object.keys(s).forEach(function(c){n.model[c]=s[c];}),process.env.NODE_ENV!=="production"&&l("Child: Inherited and extended model from Parent")),process.env.NODE_ENV!=="production"&&l("Child: Saving Parent origin",n.parentOrigin),r(new Q(n))}return i("Handshake Reply Failed")}};n.child.addEventListener("message",a,!1);})},e}();var k=y;var F="footprint-container",O="footprint-overlay",x="footprint-loading-indicator",X="footprint-custom-styles",tt=e=>{if(typeof window=="undefined")return;let o=document.getElementById(X);o&&o.remove();let t=document.createElement("style");t.setAttribute("id","footprint-custom-styles"),t.textContent=e,document.head.append(t);},C=(e,o)=>o?`${e}: ${o}`:"",L=({variables:e={}})=>{tt(` | ||
:root { | ||
${v("--fp-fp-button-height",e.fpButtonHeight)} | ||
${v("--fp-fp-button-border-radius",e.fpButtonBorderRadius)} | ||
${v("--fp-loading-bg",e.loadingBg)} | ||
${v("--fp-loading-color",e.loadingColor)} | ||
${v("--fp-loading-border-radius",e.loadingBorderRadius)} | ||
${v("--fp-loading-padding",e.loadingPadding)} | ||
${v("--fp-overlay-bg",e.overlayBg)} | ||
${C("--fp-fp-button-height",e.fpButtonHeight)} | ||
${C("--fp-fp-button-border-radius",e.fpButtonBorderRadius)} | ||
${C("--fp-loading-bg",e.loadingBg)} | ||
${C("--fp-loading-color",e.loadingColor)} | ||
${C("--fp-loading-border-radius",e.loadingBorderRadius)} | ||
${C("--fp-loading-padding",e.loadingPadding)} | ||
${C("--fp-overlay-bg",e.overlayBg)} | ||
} | ||
`)},U=e=>{const n=k();return e.appendChild(n),n},q=e=>{document.body.classList.add("footprint-body-locked");const n=document.createElement("div");n.setAttribute("id",A);const t=W(O);n.appendChild(t),n.classList.add("footprint-overlay"),e.appendChild(n)},J=()=>{const e=document.getElementById(O);e&&e.remove()},z=()=>{document.body.classList.remove("footprint-body-locked");const e=document.getElementById(A);e&&e.remove()},K=()=>{const e=document.getElementById(C);if(e)return e;const n=document.createElement("div");return n.setAttribute("id",C),document.body.appendChild(n),n},W=e=>{const n=document.createElement("div");n.setAttribute("id",e),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 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"),r.appendChild(o),t.appendChild(r),n.appendChild(t),n},Y=()=>{const e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width","24px"),e.setAttribute("height","24px"),e.setAttribute("fill","none"),e.setAttribute("aria-hidden","true");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"),e.appendChild(n),e},k=()=>{const e=Y(),n=document.createElement("button");n.appendChild(e);const t=document.createElement("span");return t.innerText="Verify with Footprint",n.appendChild(t),n.classList.add("footprint-button"),n};class Z{constructor(){S(this,"child",null)}async show(n){const t=()=>{J()},r=K();q(r);const o=await new g({classListArray:["footprint-modal"],container:r,name:"footprint-iframe",url:n});o.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),t(),o.on(w.closed,()=>this.hide()),this.child=o}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(){z(),this.child&&this.child.destroy()}createButton(n){const t=k();return n.appendChild(t),t}}const G=Z,E=new G,Q=()=>{const e=({theme:o="light",variables:i={}}={})=>{const{fpButtonBorderRadius:a,fpButtonHeight:s,loadingBg:d,loadingBorderRadius:l,loadingColor:u,loadingPadding:h,overlayBg:y}=i;V({theme:o,variables:{fpButtonBorderRadius:a,fpButtonHeight:s,loadingBg:d,loadingBorderRadius:l,loadingColor:u,loadingPadding:h,overlayBg:y}})},n=o=>E.on(w.completed,i=>{i&&typeof i=="string"&&o(i)}),t=o=>E.on(w.canceled,o);return{show:async({appearance:o,publicKey:i,onCompleted:a,onCanceled:s})=>{e(o);const{fontSrc:d,rules:l,variables:u}=_(o),h=P({fontSrc:d,publicKey:i,rules:l,variables:u});await E.show(h),a&&n(a),s&&t(s)}}},X=e=>{window.setTimeout(e,0)},tt=e=>{if(typeof window>"u")return;const n=async o=>{await e.show({publicKey:o,onCanceled:()=>{var i;(i=window.onFootprintCanceled)==null||i.call(window)},onCompleted:i=>{var a;(a=window.onFootprintCompleted)==null||a.call(window,i)}})},t=()=>{const o=document.getElementById("footprint-button");if(!o)return;const i=o.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,o)},r=(o,i)=>{X(()=>{U(i).addEventListener("click",()=>{n(o)})})};document.addEventListener("DOMContentLoaded",()=>t())},B=Q();tt(B),c.FootprintEvents=w,c.default=B,Object.defineProperties(c,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}); | ||
`);},R=e=>{let o=P();return e.appendChild(o),o},N=e=>{document.body.classList.add("footprint-body-locked");let o=document.createElement("div");o.setAttribute("id",O);let t=ot(x);o.appendChild(t),o.classList.add("footprint-overlay"),e.appendChild(o);},I=()=>{let e=document.getElementById(x);e&&e.remove();},H=()=>{document.body.classList.remove("footprint-body-locked");let e=document.getElementById(O);e&&e.remove();},_=()=>{let e=document.getElementById(F);if(e)return e;let o=document.createElement("div");return o.setAttribute("id",F),document.body.appendChild(o),o},ot=e=>{let o=document.createElement("div");o.setAttribute("id",e),o.classList.add("footprint-loading-indicator");let t=document.createElement("div");t.classList.add("footprint-loading-spin");let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width","24px"),n.setAttribute("height","24px"),n.setAttribute("fill","none"),n.setAttribute("aria-hidden","true");let r=document.createElementNS("http://www.w3.org/2000/svg","path");return r.setAttribute("d","M12 2a10 10 0 0 1 10 10h-2a7.999 7.999 0 0 0-8-8V2Z"),n.appendChild(r),t.appendChild(n),o.appendChild(t),o},et=()=>{let e=document.createElementNS("http://www.w3.org/2000/svg","svg");e.setAttribute("width","24px"),e.setAttribute("height","24px"),e.setAttribute("fill","none"),e.setAttribute("aria-hidden","true");let o=document.createElementNS("http://www.w3.org/2000/svg","path");return o.setAttribute("d","M14.66 14h2.666v-2.36a2.666 2.666 0 1 1 0-4.614V4H6.66v16h4.666v-2.666A3.333 3.333 0 0 1 14.66 14Z"),o.setAttribute("fill","#76fb8f"),e.appendChild(o),e},P=()=>{let e=et(),o=document.createElement("button");o.appendChild(e);let t=document.createElement("span");return t.innerText="Verify with Footprint",o.appendChild(t),o.classList.add("footprint-button"),o};var B=class{constructor(){this.child=null;}show(o){return g(this,null,function*(){let t=()=>{I();},n=_();N(n);let r=yield new k({classListArray:["footprint-modal"],container:n,name:"footprint-iframe",url:o});r.frame.setAttribute("allow","otp-credentials; publickey-credentials-get *; camera *;"),t(),r.on("closed",()=>this.hide()),this.child=r;})}on(o,t){if(!this.child)throw new Error("Footprint should be open in order to listen events");return this.child.on(o,t)}hide(){H(),this.child&&this.child.destroy();}createButton(o){let t=P();return o.appendChild(t),t}},D=B;var V=e=>{let o="https://id.onefootprint.com",{publicKey:t,variables:n,rules:r,fontSrc:i}=e,a=new URLSearchParams;return t&&a.append("public_key",t),n&&a.append("tokens",n),r&&a.append("rules",r),i&&a.append("font_src",i),`${o}?${a.toString()}`},M=({fontSrc:e,variables:o={},rules:t={}}={})=>{let m=o,c=w(m,["fpButtonBorderRadius","fpButtonHeight","loadingBg","loadingBorderRadius","loadingColor","loadingPadding","overlayBg"]),u=()=>Object.keys(c).length?encodeURIComponent(JSON.stringify(c)):void 0,S=()=>Object.keys(t).length?encodeURIComponent(JSON.stringify(t)):void 0;return {fontSrc:e,variables:u(),rules:S()}};var b=new D,rt=()=>{let e=({theme:r="light",variables:i={}}={})=>{let{fpButtonBorderRadius:a,fpButtonHeight:d,loadingBg:p,loadingBorderRadius:s,loadingColor:c,loadingPadding:u,overlayBg:S}=i;L({theme:r,variables:{fpButtonBorderRadius:a,fpButtonHeight:d,loadingBg:p,loadingBorderRadius:s,loadingColor:c,loadingPadding:u,overlayBg:S}});},o=r=>b.on("completed",i=>{i&&typeof i=="string"&&r(i);}),t=r=>b.on("canceled",r);return {show:p=>g(void 0,[p],function*({appearance:r,publicKey:i,onCompleted:a,onCanceled:d}){e(r);let{fontSrc:s,rules:c,variables:u}=M(r),S=V({fontSrc:s,publicKey:i,rules:c,variables:u});yield b.show(S),a&&o(a),d&&t(d);})}},T=rt;var nt=e=>{window.setTimeout(e,0);},it=e=>{if(typeof window=="undefined")return;let o=r=>{e.show({publicKey:r,onCanceled:()=>{var i;(i=window.onFootprintCanceled)==null||i.call(window);},onCompleted:i=>{var a;(a=window.onFootprintCompleted)==null||a.call(window,i);}});},t=()=>{let r=document.getElementById("footprint-button");if(!r)return;let i=r.getAttribute("data-public-key");if(!i)throw Error("A public key must be passed as `data-public-key` in the #footprint-button element");n(i,r);},n=(r,i)=>{nt(()=>{R(i).addEventListener("click",()=>{o(r);});});};document.addEventListener("DOMContentLoaded",()=>t());},$=it;var j=T();$(j);var Ft=j;/** | ||
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 | ||
**/ | ||
exports.FootprintEvents = A; | ||
exports.default = Ft; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
return exports; | ||
})({}); |
{ | ||
"name": "@onefootprint/footprint-js", | ||
"private": false, | ||
"version": "0.0.8-alpha.1", | ||
"type": "module", | ||
"version": "0.0.8-alpha.2", | ||
"main": "./dist/footprint-js.umd.js", | ||
"module": "./dist/footprint-js.mjs", | ||
"module": "./dist/footprint-js.js", | ||
"types": "./dist/footprint-js.d.ts", | ||
@@ -11,8 +12,8 @@ "exports": { | ||
"require": "./dist/footprint-js.umd.js", | ||
"import": "./dist/footprint-js.mjs", | ||
"import": "./dist/footprint-js.js", | ||
"types": "./dist/footprint-js.d.ts" | ||
}, | ||
"./dist/style.css": { | ||
"import": "./dist/style.css", | ||
"require": "./dist/style.css" | ||
"./dist/footprint-js.css": { | ||
"import": "./dist/footprint-js.css", | ||
"require": "./dist/footprint-js.css" | ||
} | ||
@@ -26,4 +27,4 @@ }, | ||
"scripts": { | ||
"dev": "vite build --watch --mode development", | ||
"build": "yarn typecheck && vite build", | ||
"dev": "tsup --watch", | ||
"build": "tsup", | ||
"lint": "eslint src --fix", | ||
@@ -34,4 +35,2 @@ "typecheck": "yarn tsc --noEmit", | ||
"devDependencies": { | ||
"@onefootprint/footprint-core": "*", | ||
"@onefootprint/design-tokens": "*", | ||
"@onefootprint/jest-presets": "*", | ||
@@ -44,5 +43,4 @@ "@onefootprint/types": "*", | ||
"tsconfig": "*", | ||
"typescript": "4.8.4", | ||
"vite": "^3.1.7", | ||
"vite-plugin-dts": "^1.6.5" | ||
"tsup": "^6.5.0", | ||
"typescript": "4.8.4" | ||
}, | ||
@@ -49,0 +47,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
43682
9
340
Yes
6