From 9fea73a9d31cd33d1702bf8a0f6c41fd8fdb1d37 Mon Sep 17 00:00:00 2001 From: Egor Komarov Date: Tue, 12 Mar 2024 11:55:46 +0100 Subject: [PATCH] feat: add ledger app v1.0.10 support --- docs/index-0eb59097.js | 7 + docs/index-f8bd1d8c.js | 7 - docs/index.html | 2 +- package-lock.json | 319 +++++++++++++++++++++-------------------- package.json | 10 +- src/js/ledger-app.js | 75 +++++++--- 6 files changed, 231 insertions(+), 189 deletions(-) create mode 100644 docs/index-0eb59097.js delete mode 100644 docs/index-f8bd1d8c.js diff --git a/docs/index-0eb59097.js b/docs/index-0eb59097.js new file mode 100644 index 0000000..5fb5375 --- /dev/null +++ b/docs/index-0eb59097.js @@ -0,0 +1,7 @@ +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const h of l.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function r(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(a){if(a.ep)return;a.ep=!0;const l=r(a);fetch(a.href,l)}})();function Ir(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var M={},We={};We.byteLength=Jr;We.toByteArray=en;We.fromByteArray=nn;var ne=[],z=[],zr=typeof Uint8Array<"u"?Uint8Array:Array,lt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var we=0,Zr=lt.length;we0)throw new Error("Invalid string. Length must be a multiple of 4");var r=i.indexOf("=");r===-1&&(r=e);var s=r===e?0:4-r%4;return[r,s]}function Jr(i){var e=xr(i),r=e[0],s=e[1];return(r+s)*3/4-s}function Qr(i,e,r){return(e+r)*3/4-r}function en(i){var e,r=xr(i),s=r[0],a=r[1],l=new zr(Qr(i,s,a)),h=0,c=a>0?s-4:s,p;for(p=0;p>16&255,l[h++]=e>>8&255,l[h++]=e&255;return a===2&&(e=z[i.charCodeAt(p)]<<2|z[i.charCodeAt(p+1)]>>4,l[h++]=e&255),a===1&&(e=z[i.charCodeAt(p)]<<10|z[i.charCodeAt(p+1)]<<4|z[i.charCodeAt(p+2)]>>2,l[h++]=e>>8&255,l[h++]=e&255),l}function tn(i){return ne[i>>18&63]+ne[i>>12&63]+ne[i>>6&63]+ne[i&63]}function rn(i,e,r){for(var s,a=[],l=e;lc?c:h+l));return s===1?(e=i[r-1],a.push(ne[e>>2]+ne[e<<4&63]+"==")):s===2&&(e=(i[r-2]<<8)+i[r-1],a.push(ne[e>>10]+ne[e>>4&63]+ne[e<<2&63]+"=")),a.join("")}var xt={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */xt.read=function(i,e,r,s,a){var l,h,c=a*8-s-1,p=(1<>1,g=-7,y=r?a-1:0,N=r?-1:1,I=i[e+y];for(y+=N,l=I&(1<<-g)-1,I>>=-g,g+=c;g>0;l=l*256+i[e+y],y+=N,g-=8);for(h=l&(1<<-g)-1,l>>=-g,g+=s;g>0;h=h*256+i[e+y],y+=N,g-=8);if(l===0)l=1-E;else{if(l===p)return h?NaN:(I?-1:1)*(1/0);h=h+Math.pow(2,s),l=l-E}return(I?-1:1)*h*Math.pow(2,l-s)};xt.write=function(i,e,r,s,a,l){var h,c,p,E=l*8-a-1,g=(1<>1,N=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=s?0:l-1,v=s?1:-1,k=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(c=isNaN(e)?1:0,h=g):(h=Math.floor(Math.log(e)/Math.LN2),e*(p=Math.pow(2,-h))<1&&(h--,p*=2),h+y>=1?e+=N/p:e+=N*Math.pow(2,1-y),e*p>=2&&(h++,p/=2),h+y>=g?(c=0,h=g):h+y>=1?(c=(e*p-1)*Math.pow(2,a),h=h+y):(c=e*Math.pow(2,y-1)*Math.pow(2,a),h=0));a>=8;i[r+I]=c&255,I+=v,c/=256,a-=8);for(h=h<0;i[r+I]=h&255,I+=v,h/=256,E-=8);i[r+I-v]|=k*128};/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */(function(i){const e=We,r=xt,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=c,i.SlowBuffer=_,i.INSPECT_MAX_BYTES=50;const a=2147483647;i.kMaxLength=a,c.TYPED_ARRAY_SUPPORT=l(),!c.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{const o=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(o,t),o.foo()===42}catch{return!1}}Object.defineProperty(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}});function h(o){if(o>a)throw new RangeError('The value "'+o+'" is invalid for option "size"');const t=new Uint8Array(o);return Object.setPrototypeOf(t,c.prototype),t}function c(o,t,n){if(typeof o=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return y(o)}return p(o,t,n)}c.poolSize=8192;function p(o,t,n){if(typeof o=="string")return N(o,t);if(ArrayBuffer.isView(o))return v(o);if(o==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o);if(ee(o,ArrayBuffer)||o&&ee(o.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ee(o,SharedArrayBuffer)||o&&ee(o.buffer,SharedArrayBuffer)))return k(o,t,n);if(typeof o=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const u=o.valueOf&&o.valueOf();if(u!=null&&u!==o)return c.from(u,t,n);const f=V(o);if(f)return f;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof o[Symbol.toPrimitive]=="function")return c.from(o[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o)}c.from=function(o,t,n){return p(o,t,n)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array);function E(o){if(typeof o!="number")throw new TypeError('"size" argument must be of type number');if(o<0)throw new RangeError('The value "'+o+'" is invalid for option "size"')}function g(o,t,n){return E(o),o<=0?h(o):t!==void 0?typeof n=="string"?h(o).fill(t,n):h(o).fill(t):h(o)}c.alloc=function(o,t,n){return g(o,t,n)};function y(o){return E(o),h(o<0?0:H(o)|0)}c.allocUnsafe=function(o){return y(o)},c.allocUnsafeSlow=function(o){return y(o)};function N(o,t){if((typeof t!="string"||t==="")&&(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const n=Y(o,t)|0;let u=h(n);const f=u.write(o,t);return f!==n&&(u=u.slice(0,f)),u}function I(o){const t=o.length<0?0:H(o.length)|0,n=h(t);for(let u=0;u=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return o|0}function _(o){return+o!=o&&(o=0),c.alloc(+o)}c.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==c.prototype},c.compare=function(t,n){if(ee(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),ee(n,Uint8Array)&&(n=c.from(n,n.offset,n.byteLength)),!c.isBuffer(t)||!c.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===n)return 0;let u=t.length,f=n.length;for(let d=0,m=Math.min(u,f);df.length?(c.isBuffer(m)||(m=c.from(m)),m.copy(f,d)):Uint8Array.prototype.set.call(f,m,d);else if(c.isBuffer(m))m.copy(f,d);else throw new TypeError('"list" argument must be an Array of Buffers');d+=m.length}return f};function Y(o,t){if(c.isBuffer(o))return o.length;if(ArrayBuffer.isView(o)||ee(o,ArrayBuffer))return o.byteLength;if(typeof o!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof o);const n=o.length,u=arguments.length>2&&arguments[2]===!0;if(!u&&n===0)return 0;let f=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return ct(o).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return Dt(o).length;default:if(f)return u?-1:ct(o).length;t=(""+t).toLowerCase(),f=!0}}c.byteLength=Y;function ce(o,t,n){let u=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return"";for(o||(o="utf8");;)switch(o){case"hex":return S(this,t,n);case"utf8":case"utf-8":return w(this,t,n);case"ascii":return $(this,t,n);case"latin1":case"binary":return R(this,t,n);case"base64":return x(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,n);default:if(u)throw new TypeError("Unknown encoding: "+o);o=(o+"").toLowerCase(),u=!0}}c.prototype._isBuffer=!0;function ie(o,t,n){const u=o[t];o[t]=o[n],o[n]=u}c.prototype.swap16=function(){const t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;nn&&(t+=" ... "),""},s&&(c.prototype[s]=c.prototype.inspect),c.prototype.compare=function(t,n,u,f,d){if(ee(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(n===void 0&&(n=0),u===void 0&&(u=t?t.length:0),f===void 0&&(f=0),d===void 0&&(d=this.length),n<0||u>t.length||f<0||d>this.length)throw new RangeError("out of range index");if(f>=d&&n>=u)return 0;if(f>=d)return-1;if(n>=u)return 1;if(n>>>=0,u>>>=0,f>>>=0,d>>>=0,this===t)return 0;let m=d-f,B=u-n;const G=Math.min(m,B),D=this.slice(f,d),j=t.slice(n,u);for(let F=0;F2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,ut(n)&&(n=f?0:o.length-1),n<0&&(n=o.length+n),n>=o.length){if(f)return-1;n=o.length-1}else if(n<0)if(f)n=0;else return-1;if(typeof t=="string"&&(t=c.from(t,u)),c.isBuffer(t))return t.length===0?-1:be(o,t,n,u,f);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?f?Uint8Array.prototype.indexOf.call(o,t,n):Uint8Array.prototype.lastIndexOf.call(o,t,n):be(o,[t],n,u,f);throw new TypeError("val must be string, number or Buffer")}function be(o,t,n,u,f){let d=1,m=o.length,B=t.length;if(u!==void 0&&(u=String(u).toLowerCase(),u==="ucs2"||u==="ucs-2"||u==="utf16le"||u==="utf-16le")){if(o.length<2||t.length<2)return-1;d=2,m/=2,B/=2,n/=2}function G(j,F){return d===1?j[F]:j.readUInt16BE(F*d)}let D;if(f){let j=-1;for(D=n;Dm&&(n=m-B),D=n;D>=0;D--){let j=!0;for(let F=0;Ff&&(u=f)):u=f;const d=t.length;u>d/2&&(u=d/2);let m;for(m=0;m>>0,isFinite(u)?(u=u>>>0,f===void 0&&(f="utf8")):(f=u,u=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const d=this.length-n;if((u===void 0||u>d)&&(u=d),t.length>0&&(u<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");f||(f="utf8");let m=!1;for(;;)switch(f){case"hex":return tt(this,t,n,u);case"utf8":case"utf-8":return rt(this,t,n,u);case"ascii":case"latin1":case"binary":return nt(this,t,n,u);case"base64":return it(this,t,n,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return st(this,t,n,u);default:if(m)throw new TypeError("Unknown encoding: "+f);f=(""+f).toLowerCase(),m=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(o,t,n){return t===0&&n===o.length?e.fromByteArray(o):e.fromByteArray(o.slice(t,n))}function w(o,t,n){n=Math.min(o.length,n);const u=[];let f=t;for(;f239?4:d>223?3:d>191?2:1;if(f+B<=n){let G,D,j,F;switch(B){case 1:d<128&&(m=d);break;case 2:G=o[f+1],(G&192)===128&&(F=(d&31)<<6|G&63,F>127&&(m=F));break;case 3:G=o[f+1],D=o[f+2],(G&192)===128&&(D&192)===128&&(F=(d&15)<<12|(G&63)<<6|D&63,F>2047&&(F<55296||F>57343)&&(m=F));break;case 4:G=o[f+1],D=o[f+2],j=o[f+3],(G&192)===128&&(D&192)===128&&(j&192)===128&&(F=(d&15)<<18|(G&63)<<12|(D&63)<<6|j&63,F>65535&&F<1114112&&(m=F))}}m===null?(m=65533,B=1):m>65535&&(m-=65536,u.push(m>>>10&1023|55296),m=56320|m&1023),u.push(m),f+=B}return A(u)}const T=4096;function A(o){const t=o.length;if(t<=T)return String.fromCharCode.apply(String,o);let n="",u=0;for(;uu)&&(n=u);let f="";for(let d=t;du&&(t=u),n<0?(n+=u,n<0&&(n=0)):n>u&&(n=u),nn)throw new RangeError("Trying to access beyond buffer length")}c.prototype.readUintLE=c.prototype.readUIntLE=function(t,n,u){t=t>>>0,n=n>>>0,u||L(t,n,this.length);let f=this[t],d=1,m=0;for(;++m>>0,n=n>>>0,u||L(t,n,this.length);let f=this[t+--n],d=1;for(;n>0&&(d*=256);)f+=this[t+--n]*d;return f},c.prototype.readUint8=c.prototype.readUInt8=function(t,n){return t=t>>>0,n||L(t,1,this.length),this[t]},c.prototype.readUint16LE=c.prototype.readUInt16LE=function(t,n){return t=t>>>0,n||L(t,2,this.length),this[t]|this[t+1]<<8},c.prototype.readUint16BE=c.prototype.readUInt16BE=function(t,n){return t=t>>>0,n||L(t,2,this.length),this[t]<<8|this[t+1]},c.prototype.readUint32LE=c.prototype.readUInt32LE=function(t,n){return t=t>>>0,n||L(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},c.prototype.readUint32BE=c.prototype.readUInt32BE=function(t,n){return t=t>>>0,n||L(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},c.prototype.readBigUInt64LE=le(function(t){t=t>>>0,ye(t,"offset");const n=this[t],u=this[t+7];(n===void 0||u===void 0)&&$e(t,this.length-8);const f=n+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,d=this[++t]+this[++t]*2**8+this[++t]*2**16+u*2**24;return BigInt(f)+(BigInt(d)<>>0,ye(t,"offset");const n=this[t],u=this[t+7];(n===void 0||u===void 0)&&$e(t,this.length-8);const f=n*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],d=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+u;return(BigInt(f)<>>0,n=n>>>0,u||L(t,n,this.length);let f=this[t],d=1,m=0;for(;++m=d&&(f-=Math.pow(2,8*n)),f},c.prototype.readIntBE=function(t,n,u){t=t>>>0,n=n>>>0,u||L(t,n,this.length);let f=n,d=1,m=this[t+--f];for(;f>0&&(d*=256);)m+=this[t+--f]*d;return d*=128,m>=d&&(m-=Math.pow(2,8*n)),m},c.prototype.readInt8=function(t,n){return t=t>>>0,n||L(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},c.prototype.readInt16LE=function(t,n){t=t>>>0,n||L(t,2,this.length);const u=this[t]|this[t+1]<<8;return u&32768?u|4294901760:u},c.prototype.readInt16BE=function(t,n){t=t>>>0,n||L(t,2,this.length);const u=this[t+1]|this[t]<<8;return u&32768?u|4294901760:u},c.prototype.readInt32LE=function(t,n){return t=t>>>0,n||L(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},c.prototype.readInt32BE=function(t,n){return t=t>>>0,n||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},c.prototype.readBigInt64LE=le(function(t){t=t>>>0,ye(t,"offset");const n=this[t],u=this[t+7];(n===void 0||u===void 0)&&$e(t,this.length-8);const f=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(u<<24);return(BigInt(f)<>>0,ye(t,"offset");const n=this[t],u=this[t+7];(n===void 0||u===void 0)&&$e(t,this.length-8);const f=(n<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(f)<>>0,n||L(t,4,this.length),r.read(this,t,!0,23,4)},c.prototype.readFloatBE=function(t,n){return t=t>>>0,n||L(t,4,this.length),r.read(this,t,!1,23,4)},c.prototype.readDoubleLE=function(t,n){return t=t>>>0,n||L(t,8,this.length),r.read(this,t,!0,52,8)},c.prototype.readDoubleBE=function(t,n){return t=t>>>0,n||L(t,8,this.length),r.read(this,t,!1,52,8)};function O(o,t,n,u,f,d){if(!c.isBuffer(o))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>f||to.length)throw new RangeError("Index out of range")}c.prototype.writeUintLE=c.prototype.writeUIntLE=function(t,n,u,f){if(t=+t,n=n>>>0,u=u>>>0,!f){const B=Math.pow(2,8*u)-1;O(this,t,n,u,B,0)}let d=1,m=0;for(this[n]=t&255;++m>>0,u=u>>>0,!f){const B=Math.pow(2,8*u)-1;O(this,t,n,u,B,0)}let d=u-1,m=1;for(this[n+d]=t&255;--d>=0&&(m*=256);)this[n+d]=t/m&255;return n+u},c.prototype.writeUint8=c.prototype.writeUInt8=function(t,n,u){return t=+t,n=n>>>0,u||O(this,t,n,1,255,0),this[n]=t&255,n+1},c.prototype.writeUint16LE=c.prototype.writeUInt16LE=function(t,n,u){return t=+t,n=n>>>0,u||O(this,t,n,2,65535,0),this[n]=t&255,this[n+1]=t>>>8,n+2},c.prototype.writeUint16BE=c.prototype.writeUInt16BE=function(t,n,u){return t=+t,n=n>>>0,u||O(this,t,n,2,65535,0),this[n]=t>>>8,this[n+1]=t&255,n+2},c.prototype.writeUint32LE=c.prototype.writeUInt32LE=function(t,n,u){return t=+t,n=n>>>0,u||O(this,t,n,4,4294967295,0),this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=t&255,n+4},c.prototype.writeUint32BE=c.prototype.writeUInt32BE=function(t,n,u){return t=+t,n=n>>>0,u||O(this,t,n,4,4294967295,0),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4};function W(o,t,n,u,f){Ft(t,u,f,o,n,7);let d=Number(t&BigInt(4294967295));o[n++]=d,d=d>>8,o[n++]=d,d=d>>8,o[n++]=d,d=d>>8,o[n++]=d;let m=Number(t>>BigInt(32)&BigInt(4294967295));return o[n++]=m,m=m>>8,o[n++]=m,m=m>>8,o[n++]=m,m=m>>8,o[n++]=m,n}function P(o,t,n,u,f){Ft(t,u,f,o,n,7);let d=Number(t&BigInt(4294967295));o[n+7]=d,d=d>>8,o[n+6]=d,d=d>>8,o[n+5]=d,d=d>>8,o[n+4]=d;let m=Number(t>>BigInt(32)&BigInt(4294967295));return o[n+3]=m,m=m>>8,o[n+2]=m,m=m>>8,o[n+1]=m,m=m>>8,o[n]=m,n+8}c.prototype.writeBigUInt64LE=le(function(t,n=0){return W(this,t,n,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeBigUInt64BE=le(function(t,n=0){return P(this,t,n,BigInt(0),BigInt("0xffffffffffffffff"))}),c.prototype.writeIntLE=function(t,n,u,f){if(t=+t,n=n>>>0,!f){const G=Math.pow(2,8*u-1);O(this,t,n,u,G-1,-G)}let d=0,m=1,B=0;for(this[n]=t&255;++d>0)-B&255;return n+u},c.prototype.writeIntBE=function(t,n,u,f){if(t=+t,n=n>>>0,!f){const G=Math.pow(2,8*u-1);O(this,t,n,u,G-1,-G)}let d=u-1,m=1,B=0;for(this[n+d]=t&255;--d>=0&&(m*=256);)t<0&&B===0&&this[n+d+1]!==0&&(B=1),this[n+d]=(t/m>>0)-B&255;return n+u},c.prototype.writeInt8=function(t,n,u){return t=+t,n=n>>>0,u||O(this,t,n,1,127,-128),t<0&&(t=255+t+1),this[n]=t&255,n+1},c.prototype.writeInt16LE=function(t,n,u){return t=+t,n=n>>>0,u||O(this,t,n,2,32767,-32768),this[n]=t&255,this[n+1]=t>>>8,n+2},c.prototype.writeInt16BE=function(t,n,u){return t=+t,n=n>>>0,u||O(this,t,n,2,32767,-32768),this[n]=t>>>8,this[n+1]=t&255,n+2},c.prototype.writeInt32LE=function(t,n,u){return t=+t,n=n>>>0,u||O(this,t,n,4,2147483647,-2147483648),this[n]=t&255,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24,n+4},c.prototype.writeInt32BE=function(t,n,u){return t=+t,n=n>>>0,u||O(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4},c.prototype.writeBigInt64LE=le(function(t,n=0){return W(this,t,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),c.prototype.writeBigInt64BE=le(function(t,n=0){return P(this,t,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ue(o,t,n,u,f,d){if(n+u>o.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function ot(o,t,n,u,f){return t=+t,n=n>>>0,f||ue(o,t,n,4),r.write(o,t,n,u,23,4),n+4}c.prototype.writeFloatLE=function(t,n,u){return ot(this,t,n,!0,u)},c.prototype.writeFloatBE=function(t,n,u){return ot(this,t,n,!1,u)};function Ut(o,t,n,u,f){return t=+t,n=n>>>0,f||ue(o,t,n,8),r.write(o,t,n,u,52,8),n+8}c.prototype.writeDoubleLE=function(t,n,u){return Ut(this,t,n,!0,u)},c.prototype.writeDoubleBE=function(t,n,u){return Ut(this,t,n,!1,u)},c.prototype.copy=function(t,n,u,f){if(!c.isBuffer(t))throw new TypeError("argument should be a Buffer");if(u||(u=0),!f&&f!==0&&(f=this.length),n>=t.length&&(n=t.length),n||(n=0),f>0&&f=this.length)throw new RangeError("Index out of range");if(f<0)throw new RangeError("sourceEnd out of bounds");f>this.length&&(f=this.length),t.length-n>>0,u=u===void 0?this.length:u>>>0,t||(t=0);let d;if(typeof t=="number")for(d=n;d2**32?f=bt(String(n)):typeof n=="bigint"&&(f=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(f=bt(f)),f+="n"),u+=` It must be ${t}. Received ${f}`,u},RangeError);function bt(o){let t="",n=o.length;const u=o[0]==="-"?1:0;for(;n>=u+4;n-=3)t=`_${o.slice(n-3,n)}${t}`;return`${o.slice(0,n)}${t}`}function Vr(o,t,n){ye(t,"offset"),(o[t]===void 0||o[t+n]===void 0)&&$e(t,o.length-(n+1))}function Ft(o,t,n,u,f,d){if(o>n||o3?t===0||t===BigInt(0)?B=`>= 0${m} and < 2${m} ** ${(d+1)*8}${m}`:B=`>= -(2${m} ** ${(d+1)*8-1}${m}) and < 2 ** ${(d+1)*8-1}${m}`:B=`>= ${t}${m} and <= ${n}${m}`,new me.ERR_OUT_OF_RANGE("value",B,o)}Vr(u,f,d)}function ye(o,t){if(typeof o!="number")throw new me.ERR_INVALID_ARG_TYPE(t,"number",o)}function $e(o,t,n){throw Math.floor(o)!==o?(ye(o,n),new me.ERR_OUT_OF_RANGE(n||"offset","an integer",o)):t<0?new me.ERR_BUFFER_OUT_OF_BOUNDS:new me.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${t}`,o)}const Xr=/[^+/0-9A-Za-z-_]/g;function Hr(o){if(o=o.split("=")[0],o=o.trim().replace(Xr,""),o.length<2)return"";for(;o.length%4!==0;)o=o+"=";return o}function ct(o,t){t=t||1/0;let n;const u=o.length;let f=null;const d=[];for(let m=0;m55295&&n<57344){if(!f){if(n>56319){(t-=3)>-1&&d.push(239,191,189);continue}else if(m+1===u){(t-=3)>-1&&d.push(239,191,189);continue}f=n;continue}if(n<56320){(t-=3)>-1&&d.push(239,191,189),f=n;continue}n=(f-55296<<10|n-56320)+65536}else f&&(t-=3)>-1&&d.push(239,191,189);if(f=null,n<128){if((t-=1)<0)break;d.push(n)}else if(n<2048){if((t-=2)<0)break;d.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;d.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;d.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return d}function qr(o){const t=[];for(let n=0;n>8,f=n%256,d.push(f),d.push(u);return d}function Dt(o){return e.toByteArray(Hr(o))}function Fe(o,t,n,u){let f;for(f=0;f=t.length||f>=o.length);++f)t[f+n]=o[f];return f}function ee(o,t){return o instanceof t||o!=null&&o.constructor!=null&&o.constructor.name!=null&&o.constructor.name===t.name}function ut(o){return o!==o}const Kr=function(){const o="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){const u=n*16;for(let f=0;f<16;++f)t[u+f]=o[n]+o[f]}return t}();function le(o){return typeof BigInt>"u"?Yr:o}function Yr(){throw new Error("BigInt not supported")}})(M);window.Buffer=M.Buffer;var vt={exports:{}},ve=typeof Reflect=="object"?Reflect:null,Pt=ve&&typeof ve.apply=="function"?ve.apply:function(e,r,s){return Function.prototype.apply.call(e,r,s)},Xe;ve&&typeof ve.ownKeys=="function"?Xe=ve.ownKeys:Object.getOwnPropertySymbols?Xe=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Xe=function(e){return Object.getOwnPropertyNames(e)};function sn(i){console&&console.warn&&console.warn(i)}var vr=Number.isNaN||function(e){return e!==e};function b(){b.init.call(this)}vt.exports=b;vt.exports.once=un;b.EventEmitter=b;b.prototype._events=void 0;b.prototype._eventsCount=0;b.prototype._maxListeners=void 0;var Mt=10;function Ke(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(b,"defaultMaxListeners",{enumerable:!0,get:function(){return Mt},set:function(i){if(typeof i!="number"||i<0||vr(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");Mt=i}});b.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};b.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||vr(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Rr(i){return i._maxListeners===void 0?b.defaultMaxListeners:i._maxListeners}b.prototype.getMaxListeners=function(){return Rr(this)};b.prototype.emit=function(e){for(var r=[],s=1;s0&&(h=r[0]),h instanceof Error)throw h;var c=new Error("Unhandled error."+(h?" ("+h.message+")":""));throw c.context=h,c}var p=l[e];if(p===void 0)return!1;if(typeof p=="function")Pt(p,this,r);else for(var E=p.length,g=Sr(p,E),s=0;s0&&h.length>a&&!h.warned){h.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+h.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=i,c.type=e,c.count=h.length,sn(c)}return i}b.prototype.addListener=function(e,r){return Lr(this,e,r,!1)};b.prototype.on=b.prototype.addListener;b.prototype.prependListener=function(e,r){return Lr(this,e,r,!0)};function on(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Ar(i,e,r){var s={fired:!1,wrapFn:void 0,target:i,type:e,listener:r},a=on.bind(s);return a.listener=r,s.wrapFn=a,a}b.prototype.once=function(e,r){return Ke(r),this.on(e,Ar(this,e,r)),this};b.prototype.prependOnceListener=function(e,r){return Ke(r),this.prependListener(e,Ar(this,e,r)),this};b.prototype.removeListener=function(e,r){var s,a,l,h,c;if(Ke(r),a=this._events,a===void 0)return this;if(s=a[e],s===void 0)return this;if(s===r||s.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete a[e],a.removeListener&&this.emit("removeListener",e,s.listener||r));else if(typeof s!="function"){for(l=-1,h=s.length-1;h>=0;h--)if(s[h]===r||s[h].listener===r){c=s[h].listener,l=h;break}if(l<0)return this;l===0?s.shift():an(s,l),s.length===1&&(a[e]=s[0]),a.removeListener!==void 0&&this.emit("removeListener",e,c||r)}return this};b.prototype.off=b.prototype.removeListener;b.prototype.removeAllListeners=function(e){var r,s,a;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[e]),this;if(arguments.length===0){var l=Object.keys(s),h;for(a=0;a=0;a--)this.removeListener(e,r[a]);return this};function $r(i,e,r){var s=i._events;if(s===void 0)return[];var a=s[e];return a===void 0?[]:typeof a=="function"?r?[a.listener||a]:[a]:r?cn(a):Sr(a,a.length)}b.prototype.listeners=function(e){return $r(this,e,!0)};b.prototype.rawListeners=function(e){return $r(this,e,!1)};b.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):Tr.call(i,e)};b.prototype.listenerCount=Tr;function Tr(i){var e=this._events;if(e!==void 0){var r=e[i];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}b.prototype.eventNames=function(){return this._eventsCount>0?Xe(this._events):[]};function Sr(i,e){for(var r=new Array(e),s=0;s{class e extends Error{constructor(s,a,l){if(super(s||i,l),Object.setPrototypeOf(this,e.prototype),this.name=i,a)for(const h in a)this[h]=a[h];if(l&&pn(l)&&"cause"in l&&!("cause"in this)){const h=l.cause;this.cause=h,"stack"in h&&(this.stack=this.stack+` +CAUSE: `+h.stack)}}}return e};function pn(i){return typeof i=="object"}const dn=Ye("DisconnectedDevice"),En=Ye("DisconnectedDeviceDuringOperation"),Gt=Ye("TransportOpenUserCancelled"),gn=Ye("TransportRaceCondition");var jt;(function(i){i.Unknown="Unknown",i.LocationServicesDisabled="LocationServicesDisabled",i.LocationServicesUnauthorized="LocationServicesUnauthorized",i.BluetoothScanStartFailed="BluetoothScanStartFailed"})(jt||(jt={}));class fe extends Error{constructor(e,r){const s="TransportError";super(e||s),this.name=s,this.message=e,this.stack=new Error(e).stack,this.id=r}}const Re={ACCESS_CONDITION_NOT_FULFILLED:38916,ALGORITHM_NOT_SUPPORTED:38020,CLA_NOT_SUPPORTED:28160,CODE_BLOCKED:38976,CODE_NOT_INITIALIZED:38914,COMMAND_INCOMPATIBLE_FILE_STRUCTURE:27009,CONDITIONS_OF_USE_NOT_SATISFIED:27013,CONTRADICTION_INVALIDATION:38928,CONTRADICTION_SECRET_CODE_STATUS:38920,CUSTOM_IMAGE_BOOTLOADER:26159,CUSTOM_IMAGE_EMPTY:26158,FILE_ALREADY_EXISTS:27273,FILE_NOT_FOUND:37892,GP_AUTH_FAILED:25344,HALTED:28586,INCONSISTENT_FILE:37896,INCORRECT_DATA:27264,INCORRECT_LENGTH:26368,INCORRECT_P1_P2:27392,INS_NOT_SUPPORTED:27904,DEVICE_NOT_ONBOARDED:27911,DEVICE_NOT_ONBOARDED_2:26129,INVALID_KCV:38021,INVALID_OFFSET:37890,LICENSING:28482,LOCKED_DEVICE:21781,MAX_VALUE_REACHED:38992,MEMORY_PROBLEM:37440,MISSING_CRITICAL_PARAMETER:26624,NO_EF_SELECTED:37888,NOT_ENOUGH_MEMORY_SPACE:27268,OK:36864,PIN_REMAINING_ATTEMPTS:25536,REFERENCED_DATA_NOT_FOUND:27272,SECURITY_STATUS_NOT_SATISFIED:27010,TECHNICAL_PROBLEM:28416,UNKNOWN_APDU:27906,USER_REFUSED_ON_DEVICE:21761,NOT_ENOUGH_SPACE:20738};function mn(i){switch(i){case 26368:return"Incorrect length";case 26624:return"Missing critical parameter";case 27010:return"Security not satisfied (dongle locked or have invalid access rights)";case 27013:return"Condition of use not satisfied (denied by the user?)";case 27264:return"Invalid data received";case 27392:return"Invalid parameter received";case 21781:return"Locked device"}if(28416<=i&&i<=28671)return"Internal error, please report"}class _e extends Error{constructor(e,{canBeMappedToChildError:r=!0}={}){const s=Object.keys(Re).find(c=>Re[c]===e)||"UNKNOWN_ERROR",a=mn(e)||s,l=e.toString(16),h=`Ledger device: ${a} (0x${l})`;if(super(h),this.name="TransportStatusError",this.statusCode=e,this.statusText=s,Object.setPrototypeOf(this,_e.prototype),r&&e===Re.LOCKED_DEVICE)return new Rt(h)}}class Rt extends _e{constructor(e){super(Re.LOCKED_DEVICE,{canBeMappedToChildError:!1}),e&&(this.message=e),this.name="LockedDeviceError",Object.setPrototypeOf(this,Rt.prototype)}}let Or=0;const he=[],kt=(i,e,r)=>{const s={type:i,id:String(++Or),date:new Date};e&&(s.message=e),r&&(s.data=r),Br(s)},yn=({type:i,message:e,data:r,context:s})=>{const a={type:i,id:String(++Or),date:new Date};e&&(a.message=e),r&&(a.data=r),s&&(a.context=s),Br(a)};class Oe{constructor(e,r){this.type=e,this.context=r}trace(e,r){yn({type:this.type,message:e,data:r,context:this.context})}getContext(){return this.context}setContext(e){this.context=e}updateContext(e){this.context=Object.assign(Object.assign({},this.context),e)}getType(){return this.type}setType(e){this.type=e}withType(e){return new Oe(e,this.context)}withContext(e){return new Oe(this.type,e)}withUpdatedContext(e){return new Oe(this.type,Object.assign(Object.assign({},this.context),e))}}const wn=i=>(he.push(i),()=>{const e=he.indexOf(i);e!==-1&&(he[e]=he[he.length-1],he.pop())});function Br(i){for(let e=0;eDe(this,void 0,void 0,function*(){const g=this.tracer.withUpdatedContext({function:"send"});if(c.length>=256)throw g.trace("data.length exceeded 256 bytes limit",{dataLength:c.length}),new fe("data.length exceed 256 bytes limit. Got: "+c.length,"DataLengthTooBig");g.trace("Starting an exchange",{abortTimeoutMs:E});const y=yield this.exchange(Buffer.concat([Buffer.from([s,a,l,h]),Buffer.from([c.length]),c]),{abortTimeoutMs:E});g.trace("Received response from exchange");const N=y.readUInt16BE(y.length-2);if(!p.some(I=>I===N))throw new _e(N);return y}),this._appAPIlock=null,this.tracer=new Oe(r??In,e)}exchange(e,{abortTimeoutMs:r}={}){throw new Error("exchange not implemented")}exchangeBulk(e,r){let s=!1;const a=()=>{s=!0};return(()=>De(this,void 0,void 0,function*(){if(!s)for(const h of e){const c=yield this.exchange(h);if(s)return;const p=c.readUInt16BE(c.length-2);if(p!==Re.OK)throw new _e(p);r.next(c)}}))().then(()=>!s&&r.complete(),h=>!s&&r.error(h)),{unsubscribe:a}}setScrambleKey(e){}close(){return Promise.resolve()}on(e,r){this._events.on(e,r)}off(e,r){this._events.removeListener(e,r)}emit(e,...r){this._events.emit(e,...r)}setDebugMode(){console.warn("setDebugMode is deprecated. use @ledgerhq/logs instead. No logs are emitted in this anymore.")}setExchangeTimeout(e){this.exchangeTimeout=e}setExchangeUnresponsiveTimeout(e){this.unresponsiveTimeout=e}static create(e=3e3,r){return new Promise((s,a)=>{let l=!1;const h=this.listen({next:p=>{l=!0,h&&h.unsubscribe(),c&&clearTimeout(c),this.open(p.descriptor,e).then(s,a)},error:p=>{c&&clearTimeout(c),a(p)},complete:()=>{c&&clearTimeout(c),l||a(new fe(this.ErrorMessage_NoDeviceFound,"NoDeviceFound"))}}),c=r?setTimeout(()=>{h.unsubscribe(),a(new fe(this.ErrorMessage_ListenTimeout,"ListenTimeout"))},r):null})}exchangeAtomicImpl(e){return De(this,void 0,void 0,function*(){const r=this.tracer.withUpdatedContext({function:"exchangeAtomicImpl",unresponsiveTimeout:this.unresponsiveTimeout});if(this.exchangeBusyPromise)throw r.trace("Atomic exchange is already busy"),new gn("An action was already pending on the Ledger device. Please deny or reconnect.");let s;const a=new Promise(c=>{s=c});this.exchangeBusyPromise=a;let l=!1;const h=setTimeout(()=>{r.trace('Timeout reached, emitting Transport event "unresponsive"',{unresponsiveTimeout:this.unresponsiveTimeout}),l=!0,this.emit("unresponsive")},this.unresponsiveTimeout);try{const c=yield e();return l&&(r.trace("Device was unresponsive, emitting responsive"),this.emit("responsive")),c}finally{r.trace("Finalize, clearing busy guard"),clearTimeout(h),s&&s(),this.exchangeBusyPromise=null}})}decorateAppAPIMethods(e,r,s){for(const a of r)e[a]=this.decorateAppAPIMethod(a,e[a],e,s)}decorateAppAPIMethod(e,r,s,a){return(...l)=>De(this,void 0,void 0,function*(){const{_appAPIlock:h}=this;if(h)return Promise.reject(new fe("Ledger Device is busy (lock "+h+")","TransportLocked"));try{return this._appAPIlock=e,this.setScrambleKey(a),yield r.apply(s,l)}finally{this._appAPIlock=null}})}setTraceContext(e){this.tracer=this.tracer.withContext(e)}updateTraceContext(e){this.tracer.updateContext(e)}getTraceContext(){return this.tracer.getContext()}}Lt.ErrorMessage_ListenTimeout="No Ledger device found (timeout)";Lt.ErrorMessage_NoDeviceFound="No Ledger device found";const Vt=5;function xn(i){const e=Buffer.alloc(2);return e.writeUInt16BE(i,0),e}const vn={data:Buffer.alloc(0),dataLength:0,sequence:0},Rn=(i,e)=>({makeBlocks(r){let s=Buffer.concat([xn(r.length),r]);const a=e-5,l=Math.ceil(s.length/a);s=Buffer.concat([s,Buffer.alloc(l*a-s.length+1).fill(0)]);const h=[];for(let c=0;cl&&(a=a.slice(0,l)),{data:a,dataLength:l,sequence:h}},getReducedResult(r){if(r&&r.dataLength===r.data.length)return r.data}});var wt={exports:{}};const Ln="2.0.0",_r=256,An=Number.MAX_SAFE_INTEGER||9007199254740991,$n=16,Tn=_r-6,Sn=["major","premajor","minor","preminor","patch","prepatch","prerelease"];var ze={MAX_LENGTH:_r,MAX_SAFE_COMPONENT_LENGTH:$n,MAX_SAFE_BUILD_LENGTH:Tn,MAX_SAFE_INTEGER:An,RELEASE_TYPES:Sn,SEMVER_SPEC_VERSION:Ln,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2};const Nn=typeof process=="object"&&process.env&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...i)=>console.error("SEMVER",...i):()=>{};var Ze=Nn;(function(i,e){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:a}=ze,l=Ze;e=i.exports={};const h=e.re=[],c=e.safeRe=[],p=e.src=[],E=e.t={};let g=0;const y="[a-zA-Z0-9-]",N=[["\\s",1],["\\d",a],[y,s]],I=k=>{for(const[V,H]of N)k=k.split(`${V}*`).join(`${V}{0,${H}}`).split(`${V}+`).join(`${V}{1,${H}}`);return k},v=(k,V,H)=>{const _=I(V),Y=g++;l(k,Y,V),E[k]=Y,p[Y]=V,h[Y]=new RegExp(V,H?"g":void 0),c[Y]=new RegExp(_,H?"g":void 0)};v("NUMERICIDENTIFIER","0|[1-9]\\d*"),v("NUMERICIDENTIFIERLOOSE","\\d+"),v("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${y}*`),v("MAINVERSION",`(${p[E.NUMERICIDENTIFIER]})\\.(${p[E.NUMERICIDENTIFIER]})\\.(${p[E.NUMERICIDENTIFIER]})`),v("MAINVERSIONLOOSE",`(${p[E.NUMERICIDENTIFIERLOOSE]})\\.(${p[E.NUMERICIDENTIFIERLOOSE]})\\.(${p[E.NUMERICIDENTIFIERLOOSE]})`),v("PRERELEASEIDENTIFIER",`(?:${p[E.NUMERICIDENTIFIER]}|${p[E.NONNUMERICIDENTIFIER]})`),v("PRERELEASEIDENTIFIERLOOSE",`(?:${p[E.NUMERICIDENTIFIERLOOSE]}|${p[E.NONNUMERICIDENTIFIER]})`),v("PRERELEASE",`(?:-(${p[E.PRERELEASEIDENTIFIER]}(?:\\.${p[E.PRERELEASEIDENTIFIER]})*))`),v("PRERELEASELOOSE",`(?:-?(${p[E.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${p[E.PRERELEASEIDENTIFIERLOOSE]})*))`),v("BUILDIDENTIFIER",`${y}+`),v("BUILD",`(?:\\+(${p[E.BUILDIDENTIFIER]}(?:\\.${p[E.BUILDIDENTIFIER]})*))`),v("FULLPLAIN",`v?${p[E.MAINVERSION]}${p[E.PRERELEASE]}?${p[E.BUILD]}?`),v("FULL",`^${p[E.FULLPLAIN]}$`),v("LOOSEPLAIN",`[v=\\s]*${p[E.MAINVERSIONLOOSE]}${p[E.PRERELEASELOOSE]}?${p[E.BUILD]}?`),v("LOOSE",`^${p[E.LOOSEPLAIN]}$`),v("GTLT","((?:<|>)?=?)"),v("XRANGEIDENTIFIERLOOSE",`${p[E.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),v("XRANGEIDENTIFIER",`${p[E.NUMERICIDENTIFIER]}|x|X|\\*`),v("XRANGEPLAIN",`[v=\\s]*(${p[E.XRANGEIDENTIFIER]})(?:\\.(${p[E.XRANGEIDENTIFIER]})(?:\\.(${p[E.XRANGEIDENTIFIER]})(?:${p[E.PRERELEASE]})?${p[E.BUILD]}?)?)?`),v("XRANGEPLAINLOOSE",`[v=\\s]*(${p[E.XRANGEIDENTIFIERLOOSE]})(?:\\.(${p[E.XRANGEIDENTIFIERLOOSE]})(?:\\.(${p[E.XRANGEIDENTIFIERLOOSE]})(?:${p[E.PRERELEASELOOSE]})?${p[E.BUILD]}?)?)?`),v("XRANGE",`^${p[E.GTLT]}\\s*${p[E.XRANGEPLAIN]}$`),v("XRANGELOOSE",`^${p[E.GTLT]}\\s*${p[E.XRANGEPLAINLOOSE]}$`),v("COERCEPLAIN",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`),v("COERCE",`${p[E.COERCEPLAIN]}(?:$|[^\\d])`),v("COERCEFULL",p[E.COERCEPLAIN]+`(?:${p[E.PRERELEASE]})?(?:${p[E.BUILD]})?(?:$|[^\\d])`),v("COERCERTL",p[E.COERCE],!0),v("COERCERTLFULL",p[E.COERCEFULL],!0),v("LONETILDE","(?:~>?)"),v("TILDETRIM",`(\\s*)${p[E.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",v("TILDE",`^${p[E.LONETILDE]}${p[E.XRANGEPLAIN]}$`),v("TILDELOOSE",`^${p[E.LONETILDE]}${p[E.XRANGEPLAINLOOSE]}$`),v("LONECARET","(?:\\^)"),v("CARETTRIM",`(\\s*)${p[E.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",v("CARET",`^${p[E.LONECARET]}${p[E.XRANGEPLAIN]}$`),v("CARETLOOSE",`^${p[E.LONECARET]}${p[E.XRANGEPLAINLOOSE]}$`),v("COMPARATORLOOSE",`^${p[E.GTLT]}\\s*(${p[E.LOOSEPLAIN]})$|^$`),v("COMPARATOR",`^${p[E.GTLT]}\\s*(${p[E.FULLPLAIN]})$|^$`),v("COMPARATORTRIM",`(\\s*)${p[E.GTLT]}\\s*(${p[E.LOOSEPLAIN]}|${p[E.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",v("HYPHENRANGE",`^\\s*(${p[E.XRANGEPLAIN]})\\s+-\\s+(${p[E.XRANGEPLAIN]})\\s*$`),v("HYPHENRANGELOOSE",`^\\s*(${p[E.XRANGEPLAINLOOSE]})\\s+-\\s+(${p[E.XRANGEPLAINLOOSE]})\\s*$`),v("STAR","(<|>)?=?\\s*\\*"),v("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),v("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(wt,wt.exports);var Ce=wt.exports;const On=Object.freeze({loose:!0}),Bn=Object.freeze({}),_n=i=>i?typeof i!="object"?On:i:Bn;var At=_n;const Xt=/^[0-9]+$/,Cr=(i,e)=>{const r=Xt.test(i),s=Xt.test(e);return r&&s&&(i=+i,e=+e),i===e?0:r&&!s?-1:s&&!r?1:iCr(e,i);var Ur={compareIdentifiers:Cr,rcompareIdentifiers:Cn};const Pe=Ze,{MAX_LENGTH:Ht,MAX_SAFE_INTEGER:Me}=ze,{safeRe:qt,t:Wt}=Ce,Un=At,{compareIdentifiers:Ie}=Ur;let bn=class re{constructor(e,r){if(r=Un(r),e instanceof re){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>Ht)throw new TypeError(`version is longer than ${Ht} characters`);Pe("SemVer",e,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;const s=e.trim().match(r.loose?qt[Wt.LOOSE]:qt[Wt.FULL]);if(!s)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>Me||this.major<0)throw new TypeError("Invalid major version");if(this.minor>Me||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>Me||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(a=>{if(/^[0-9]+$/.test(a)){const l=+a;if(l>=0&&l=0;)typeof this.prerelease[l]=="number"&&(this.prerelease[l]++,l=-2);if(l===-1){if(r===this.prerelease.join(".")&&s===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(a)}}if(r){let l=[r,a];s===!1&&(l=[r]),Ie(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=l):this.prerelease=l}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};var K=bn;const Kt=K,Fn=(i,e,r=!1)=>{if(i instanceof Kt)return i;try{return new Kt(i,e)}catch(s){if(!r)return null;throw s}};var Ae=Fn;const Dn=Ae,Pn=(i,e)=>{const r=Dn(i,e);return r?r.version:null};var Mn=Pn;const Gn=Ae,jn=(i,e)=>{const r=Gn(i.trim().replace(/^[=v]+/,""),e);return r?r.version:null};var kn=jn;const Yt=K,Vn=(i,e,r,s,a)=>{typeof r=="string"&&(a=s,s=r,r=void 0);try{return new Yt(i instanceof Yt?i.version:i,r).inc(e,s,a).version}catch{return null}};var Xn=Vn;const zt=Ae,Hn=(i,e)=>{const r=zt(i,null,!0),s=zt(e,null,!0),a=r.compare(s);if(a===0)return null;const l=a>0,h=l?r:s,c=l?s:r,p=!!h.prerelease.length;if(!!c.prerelease.length&&!p)return!c.patch&&!c.minor?"major":h.patch?"patch":h.minor?"minor":"major";const g=p?"pre":"";return r.major!==s.major?g+"major":r.minor!==s.minor?g+"minor":r.patch!==s.patch?g+"patch":"prerelease"};var qn=Hn;const Wn=K,Kn=(i,e)=>new Wn(i,e).major;var Yn=Kn;const zn=K,Zn=(i,e)=>new zn(i,e).minor;var Jn=Zn;const Qn=K,ei=(i,e)=>new Qn(i,e).patch;var ti=ei;const ri=Ae,ni=(i,e)=>{const r=ri(i,e);return r&&r.prerelease.length?r.prerelease:null};var ii=ni;const Zt=K,si=(i,e,r)=>new Zt(i,r).compare(new Zt(e,r));var J=si;const oi=J,ai=(i,e,r)=>oi(e,i,r);var ci=ai;const ui=J,li=(i,e)=>ui(i,e,!0);var hi=li;const Jt=K,fi=(i,e,r)=>{const s=new Jt(i,r),a=new Jt(e,r);return s.compare(a)||s.compareBuild(a)};var $t=fi;const pi=$t,di=(i,e)=>i.sort((r,s)=>pi(r,s,e));var Ei=di;const gi=$t,mi=(i,e)=>i.sort((r,s)=>gi(s,r,e));var yi=mi;const wi=J,Ii=(i,e,r)=>wi(i,e,r)>0;var Je=Ii;const xi=J,vi=(i,e,r)=>xi(i,e,r)<0;var Tt=vi;const Ri=J,Li=(i,e,r)=>Ri(i,e,r)===0;var br=Li;const Ai=J,$i=(i,e,r)=>Ai(i,e,r)!==0;var Fr=$i;const Ti=J,Si=(i,e,r)=>Ti(i,e,r)>=0;var St=Si;const Ni=J,Oi=(i,e,r)=>Ni(i,e,r)<=0;var Nt=Oi;const Bi=br,_i=Fr,Ci=Je,Ui=St,bi=Tt,Fi=Nt,Di=(i,e,r,s)=>{switch(e){case"===":return typeof i=="object"&&(i=i.version),typeof r=="object"&&(r=r.version),i===r;case"!==":return typeof i=="object"&&(i=i.version),typeof r=="object"&&(r=r.version),i!==r;case"":case"=":case"==":return Bi(i,r,s);case"!=":return _i(i,r,s);case">":return Ci(i,r,s);case">=":return Ui(i,r,s);case"<":return bi(i,r,s);case"<=":return Fi(i,r,s);default:throw new TypeError(`Invalid operator: ${e}`)}};var Dr=Di;const Pi=K,Mi=Ae,{safeRe:Ge,t:je}=Ce,Gi=(i,e)=>{if(i instanceof Pi)return i;if(typeof i=="number"&&(i=String(i)),typeof i!="string")return null;e=e||{};let r=null;if(!e.rtl)r=i.match(e.includePrerelease?Ge[je.COERCEFULL]:Ge[je.COERCE]);else{const p=e.includePrerelease?Ge[je.COERCERTLFULL]:Ge[je.COERCERTL];let E;for(;(E=p.exec(i))&&(!r||r.index+r[0].length!==i.length);)(!r||E.index+E[0].length!==r.index+r[0].length)&&(r=E),p.lastIndex=E.index+E[1].length+E[2].length;p.lastIndex=-1}if(r===null)return null;const s=r[2],a=r[3]||"0",l=r[4]||"0",h=e.includePrerelease&&r[5]?`-${r[5]}`:"",c=e.includePrerelease&&r[6]?`+${r[6]}`:"";return Mi(`${s}.${a}.${l}${h}${c}`,e)};var ji=Gi,ht,Qt;function ki(){return Qt||(Qt=1,ht=function(i){i.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}),ht}var Vi=C;C.Node=ge;C.create=C;function C(i){var e=this;if(e instanceof C||(e=new C),e.tail=null,e.head=null,e.length=0,i&&typeof i.forEach=="function")i.forEach(function(a){e.push(a)});else if(arguments.length>0)for(var r=0,s=arguments.length;r1)r=e;else if(this.head)s=this.head.next,r=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var a=0;s!==null;a++)r=i(r,s.value,a),s=s.next;return r};C.prototype.reduceReverse=function(i,e){var r,s=this.tail;if(arguments.length>1)r=e;else if(this.tail)s=this.tail.prev,r=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var a=this.length-1;s!==null;a--)r=i(r,s.value,a),s=s.prev;return r};C.prototype.toArray=function(){for(var i=new Array(this.length),e=0,r=this.head;r!==null;e++)i[e]=r.value,r=r.next;return i};C.prototype.toArrayReverse=function(){for(var i=new Array(this.length),e=0,r=this.tail;r!==null;e++)i[e]=r.value,r=r.prev;return i};C.prototype.slice=function(i,e){e=e||this.length,e<0&&(e+=this.length),i=i||0,i<0&&(i+=this.length);var r=new C;if(ethis.length&&(e=this.length);for(var s=0,a=this.head;a!==null&&sthis.length&&(e=this.length);for(var s=this.length,a=this.tail;a!==null&&s>e;s--)a=a.prev;for(;a!==null&&s>i;s--,a=a.prev)r.push(a.value);return r};C.prototype.splice=function(i,e,...r){i>this.length&&(i=this.length-1),i<0&&(i=this.length+i);for(var s=0,a=this.head;a!==null&&s1;class Ki{constructor(e){if(typeof e=="number"&&(e={max:e}),e||(e={}),e.max&&(typeof e.max!="number"||e.max<0))throw new TypeError("max must be a non-negative number");this[de]=e.max||1/0;const r=e.length||ft;if(this[xe]=typeof r!="function"?ft:r,this[Be]=e.stale||!1,e.maxAge&&typeof e.maxAge!="number")throw new TypeError("maxAge must be a number");this[Ee]=e.maxAge||0,this[se]=e.dispose,this[er]=e.noDisposeOnSet||!1,this[Pr]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!="number"||e<0)throw new TypeError("max must be a non-negative number");this[de]=e||1/0,Te(this)}get max(){return this[de]}set allowStale(e){this[Be]=!!e}get allowStale(){return this[Be]}set maxAge(e){if(typeof e!="number")throw new TypeError("maxAge must be a non-negative number");this[Ee]=e,Te(this)}get maxAge(){return this[Ee]}set lengthCalculator(e){typeof e!="function"&&(e=ft),e!==this[xe]&&(this[xe]=e,this[oe]=0,this[X].forEach(r=>{r.length=this[xe](r.value,r.key),this[oe]+=r.length})),Te(this)}get lengthCalculator(){return this[xe]}get length(){return this[oe]}get itemCount(){return this[X].length}rforEach(e,r){r=r||this;for(let s=this[X].tail;s!==null;){const a=s.prev;tr(this,e,s,r),s=a}}forEach(e,r){r=r||this;for(let s=this[X].head;s!==null;){const a=s.next;tr(this,e,s,r),s=a}}keys(){return this[X].toArray().map(e=>e.key)}values(){return this[X].toArray().map(e=>e.value)}reset(){this[se]&&this[X]&&this[X].length&&this[X].forEach(e=>this[se](e.key,e.value)),this[Z]=new Map,this[X]=new Wi,this[oe]=0}dump(){return this[X].map(e=>He(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[X]}set(e,r,s){if(s=s||this[Ee],s&&typeof s!="number")throw new TypeError("maxAge must be a number");const a=s?Date.now():0,l=this[xe](r,e);if(this[Z].has(e)){if(l>this[de])return Le(this,this[Z].get(e)),!1;const p=this[Z].get(e).value;return this[se]&&(this[er]||this[se](e,p.value)),p.now=a,p.maxAge=s,p.value=r,this[oe]+=l-p.length,p.length=l,this.get(e),Te(this),!0}const h=new Yi(e,r,l,a,s);return h.length>this[de]?(this[se]&&this[se](e,r),!1):(this[oe]+=h.length,this[X].unshift(h),this[Z].set(e,this[X].head),Te(this),!0)}has(e){if(!this[Z].has(e))return!1;const r=this[Z].get(e).value;return!He(this,r)}get(e){return pt(this,e,!0)}peek(e){return pt(this,e,!1)}pop(){const e=this[X].tail;return e?(Le(this,e),e.value):null}del(e){Le(this,this[Z].get(e))}load(e){this.reset();const r=Date.now();for(let s=e.length-1;s>=0;s--){const a=e[s],l=a.e||0;if(l===0)this.set(a.k,a.v);else{const h=l-r;h>0&&this.set(a.k,a.v,h)}}}prune(){this[Z].forEach((e,r)=>pt(this,r,!1))}}const pt=(i,e,r)=>{const s=i[Z].get(e);if(s){const a=s.value;if(He(i,a)){if(Le(i,s),!i[Be])return}else r&&(i[Pr]&&(s.value.now=Date.now()),i[X].unshiftNode(s));return a.value}},He=(i,e)=>{if(!e||!e.maxAge&&!i[Ee])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:i[Ee]&&r>i[Ee]},Te=i=>{if(i[oe]>i[de])for(let e=i[X].tail;i[oe]>i[de]&&e!==null;){const r=e.prev;Le(i,e),e=r}},Le=(i,e)=>{if(e){const r=e.value;i[se]&&i[se](r.key,r.value),i[oe]-=r.length,i[Z].delete(r.key),i[X].removeNode(e)}};class Yi{constructor(e,r,s,a,l){this.key=e,this.value=r,this.length=s,this.now=a,this.maxAge=l||0}}const tr=(i,e,r,s)=>{let a=r.value;He(i,a)&&(Le(i,r),i[Be]||(a=void 0)),a&&e.call(s,a.value,a.key,i)};var zi=Ki,dt,rr;function Q(){if(rr)return dt;rr=1;class i{constructor(w,T){if(T=s(T),w instanceof i)return w.loose===!!T.loose&&w.includePrerelease===!!T.includePrerelease?w:new i(w.raw,T);if(w instanceof a)return this.raw=w.value,this.set=[[w]],this.format(),this;if(this.options=T,this.loose=!!T.loose,this.includePrerelease=!!T.includePrerelease,this.raw=w.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map(A=>this.parseRange(A.trim())).filter(A=>A.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const A=this.set[0];if(this.set=this.set.filter($=>!v($[0])),this.set.length===0)this.set=[A];else if(this.set.length>1){for(const $ of this.set)if($.length===1&&k($[0])){this.set=[$];break}}}this.format()}format(){return this.range=this.set.map(w=>w.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(w){const A=((this.options.includePrerelease&&N)|(this.options.loose&&I))+":"+w,$=r.get(A);if($)return $;const R=this.options.loose,S=R?c[p.HYPHENRANGELOOSE]:c[p.HYPHENRANGE];w=w.replace(S,it(this.options.includePrerelease)),l("hyphen replace",w),w=w.replace(c[p.COMPARATORTRIM],E),l("comparator trim",w),w=w.replace(c[p.TILDETRIM],g),l("tilde trim",w),w=w.replace(c[p.CARETTRIM],y),l("caret trim",w);let U=w.split(" ").map(P=>H(P,this.options)).join(" ").split(/\s+/).map(P=>nt(P,this.options));R&&(U=U.filter(P=>(l("loose invalid filter",P,this.options),!!P.match(c[p.COMPARATORLOOSE])))),l("range list",U);const L=new Map,O=U.map(P=>new a(P,this.options));for(const P of O){if(v(P))return[P];L.set(P.value,P)}L.size>1&&L.has("")&&L.delete("");const W=[...L.values()];return r.set(A,W),W}intersects(w,T){if(!(w instanceof i))throw new TypeError("a Range is required");return this.set.some(A=>V(A,T)&&w.set.some($=>V($,T)&&A.every(R=>$.every(S=>R.intersects(S,T)))))}test(w){if(!w)return!1;if(typeof w=="string")try{w=new h(w,this.options)}catch{return!1}for(let T=0;Tx.value==="<0.0.0-0",k=x=>x.value==="",V=(x,w)=>{let T=!0;const A=x.slice();let $=A.pop();for(;T&&A.length;)T=A.every(R=>$.intersects(R,w)),$=A.pop();return T},H=(x,w)=>(l("comp",x,w),x=ie(x,w),l("caret",x),x=Y(x,w),l("tildes",x),x=be(x,w),l("xrange",x),x=rt(x,w),l("stars",x),x),_=x=>!x||x.toLowerCase()==="x"||x==="*",Y=(x,w)=>x.trim().split(/\s+/).map(T=>ce(T,w)).join(" "),ce=(x,w)=>{const T=w.loose?c[p.TILDELOOSE]:c[p.TILDE];return x.replace(T,(A,$,R,S,U)=>{l("tilde",x,A,$,R,S,U);let L;return _($)?L="":_(R)?L=`>=${$}.0.0 <${+$+1}.0.0-0`:_(S)?L=`>=${$}.${R}.0 <${$}.${+R+1}.0-0`:U?(l("replaceTilde pr",U),L=`>=${$}.${R}.${S}-${U} <${$}.${+R+1}.0-0`):L=`>=${$}.${R}.${S} <${$}.${+R+1}.0-0`,l("tilde return",L),L})},ie=(x,w)=>x.trim().split(/\s+/).map(T=>Ue(T,w)).join(" "),Ue=(x,w)=>{l("caret",x,w);const T=w.loose?c[p.CARETLOOSE]:c[p.CARET],A=w.includePrerelease?"-0":"";return x.replace(T,($,R,S,U,L)=>{l("caret",x,$,R,S,U,L);let O;return _(R)?O="":_(S)?O=`>=${R}.0.0${A} <${+R+1}.0.0-0`:_(U)?R==="0"?O=`>=${R}.${S}.0${A} <${R}.${+S+1}.0-0`:O=`>=${R}.${S}.0${A} <${+R+1}.0.0-0`:L?(l("replaceCaret pr",L),R==="0"?S==="0"?O=`>=${R}.${S}.${U}-${L} <${R}.${S}.${+U+1}-0`:O=`>=${R}.${S}.${U}-${L} <${R}.${+S+1}.0-0`:O=`>=${R}.${S}.${U}-${L} <${+R+1}.0.0-0`):(l("no pr"),R==="0"?S==="0"?O=`>=${R}.${S}.${U}${A} <${R}.${S}.${+U+1}-0`:O=`>=${R}.${S}.${U}${A} <${R}.${+S+1}.0-0`:O=`>=${R}.${S}.${U} <${+R+1}.0.0-0`),l("caret return",O),O})},be=(x,w)=>(l("replaceXRanges",x,w),x.split(/\s+/).map(T=>tt(T,w)).join(" ")),tt=(x,w)=>{x=x.trim();const T=w.loose?c[p.XRANGELOOSE]:c[p.XRANGE];return x.replace(T,(A,$,R,S,U,L)=>{l("xRange",x,A,$,R,S,U,L);const O=_(R),W=O||_(S),P=W||_(U),ue=P;return $==="="&&ue&&($=""),L=w.includePrerelease?"-0":"",O?$===">"||$==="<"?A="<0.0.0-0":A="*":$&&ue?(W&&(S=0),U=0,$===">"?($=">=",W?(R=+R+1,S=0,U=0):(S=+S+1,U=0)):$==="<="&&($="<",W?R=+R+1:S=+S+1),$==="<"&&(L="-0"),A=`${$+R}.${S}.${U}${L}`):W?A=`>=${R}.0.0${L} <${+R+1}.0.0-0`:P&&(A=`>=${R}.${S}.0${L} <${R}.${+S+1}.0-0`),l("xRange return",A),A})},rt=(x,w)=>(l("replaceStars",x,w),x.trim().replace(c[p.STAR],"")),nt=(x,w)=>(l("replaceGTE0",x,w),x.trim().replace(c[w.includePrerelease?p.GTE0PRE:p.GTE0],"")),it=x=>(w,T,A,$,R,S,U,L,O,W,P,ue,ot)=>(_(A)?T="":_($)?T=`>=${A}.0.0${x?"-0":""}`:_(R)?T=`>=${A}.${$}.0${x?"-0":""}`:S?T=`>=${T}`:T=`>=${T}${x?"-0":""}`,_(O)?L="":_(W)?L=`<${+O+1}.0.0-0`:_(P)?L=`<${O}.${+W+1}.0-0`:ue?L=`<=${O}.${W}.${P}-${ue}`:x?L=`<${O}.${W}.${+P+1}-0`:L=`<=${L}`,`${T} ${L}`.trim()),st=(x,w,T)=>{for(let A=0;A0){const $=x[A].semver;if($.major===w.major&&$.minor===w.minor&&$.patch===w.patch)return!0}return!1}return!0};return dt}var Et,nr;function Qe(){if(nr)return Et;nr=1;const i=Symbol("SemVer ANY");class e{static get ANY(){return i}constructor(g,y){if(y=r(y),g instanceof e){if(g.loose===!!y.loose)return g;g=g.value}g=g.trim().split(/\s+/).join(" "),h("comparator",g,y),this.options=y,this.loose=!!y.loose,this.parse(g),this.semver===i?this.value="":this.value=this.operator+this.semver.version,h("comp",this)}parse(g){const y=this.options.loose?s[a.COMPARATORLOOSE]:s[a.COMPARATOR],N=g.match(y);if(!N)throw new TypeError(`Invalid comparator: ${g}`);this.operator=N[1]!==void 0?N[1]:"",this.operator==="="&&(this.operator=""),N[2]?this.semver=new c(N[2],this.options.loose):this.semver=i}toString(){return this.value}test(g){if(h("Comparator.test",g,this.options.loose),this.semver===i||g===i)return!0;if(typeof g=="string")try{g=new c(g,this.options)}catch{return!1}return l(g,this.operator,this.semver,this.options)}intersects(g,y){if(!(g instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new p(g.value,y).test(this.value):g.operator===""?g.value===""?!0:new p(this.value,y).test(g.semver):(y=r(y),y.includePrerelease&&(this.value==="<0.0.0-0"||g.value==="<0.0.0-0")||!y.includePrerelease&&(this.value.startsWith("<0.0.0")||g.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&g.operator.startsWith(">")||this.operator.startsWith("<")&&g.operator.startsWith("<")||this.semver.version===g.semver.version&&this.operator.includes("=")&&g.operator.includes("=")||l(this.semver,"<",g.semver,y)&&this.operator.startsWith(">")&&g.operator.startsWith("<")||l(this.semver,">",g.semver,y)&&this.operator.startsWith("<")&&g.operator.startsWith(">")))}}Et=e;const r=At,{safeRe:s,t:a}=Ce,l=Dr,h=Ze,c=K,p=Q();return Et}const Zi=Q(),Ji=(i,e,r)=>{try{e=new Zi(e,r)}catch{return!1}return e.test(i)};var et=Ji;const Qi=Q(),es=(i,e)=>new Qi(i,e).set.map(r=>r.map(s=>s.value).join(" ").trim().split(" "));var ts=es;const rs=K,ns=Q(),is=(i,e,r)=>{let s=null,a=null,l=null;try{l=new ns(e,r)}catch{return null}return i.forEach(h=>{l.test(h)&&(!s||a.compare(h)===-1)&&(s=h,a=new rs(s,r))}),s};var ss=is;const os=K,as=Q(),cs=(i,e,r)=>{let s=null,a=null,l=null;try{l=new as(e,r)}catch{return null}return i.forEach(h=>{l.test(h)&&(!s||a.compare(h)===1)&&(s=h,a=new os(s,r))}),s};var us=cs;const gt=K,ls=Q(),ir=Je,hs=(i,e)=>{i=new ls(i,e);let r=new gt("0.0.0");if(i.test(r)||(r=new gt("0.0.0-0"),i.test(r)))return r;r=null;for(let s=0;s{const c=new gt(h.semver.version);switch(h.operator){case">":c.prerelease.length===0?c.patch++:c.prerelease.push(0),c.raw=c.format();case"":case">=":(!l||ir(c,l))&&(l=c);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${h.operator}`)}}),l&&(!r||ir(r,l))&&(r=l)}return r&&i.test(r)?r:null};var fs=hs;const ps=Q(),ds=(i,e)=>{try{return new ps(i,e).range||"*"}catch{return null}};var Es=ds;const gs=K,Mr=Qe(),{ANY:ms}=Mr,ys=Q(),ws=et,sr=Je,or=Tt,Is=Nt,xs=St,vs=(i,e,r,s)=>{i=new gs(i,s),e=new ys(e,s);let a,l,h,c,p;switch(r){case">":a=sr,l=Is,h=or,c=">",p=">=";break;case"<":a=or,l=xs,h=sr,c="<",p="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(ws(i,e,s))return!1;for(let E=0;E{I.semver===ms&&(I=new Mr(">=0.0.0")),y=y||I,N=N||I,a(I.semver,y.semver,s)?y=I:h(I.semver,N.semver,s)&&(N=I)}),y.operator===c||y.operator===p||(!N.operator||N.operator===c)&&l(i,N.semver))return!1;if(N.operator===p&&h(i,N.semver))return!1}return!0};var Ot=vs;const Rs=Ot,Ls=(i,e,r)=>Rs(i,e,">",r);var As=Ls;const $s=Ot,Ts=(i,e,r)=>$s(i,e,"<",r);var Ss=Ts;const ar=Q(),Ns=(i,e,r)=>(i=new ar(i,r),e=new ar(e,r),i.intersects(e,r));var Os=Ns;const Bs=et,_s=J;var Cs=(i,e,r)=>{const s=[];let a=null,l=null;const h=i.sort((g,y)=>_s(g,y,r));for(const g of h)Bs(g,e,r)?(l=g,a||(a=g)):(l&&s.push([a,l]),l=null,a=null);a&&s.push([a,null]);const c=[];for(const[g,y]of s)g===y?c.push(g):!y&&g===h[0]?c.push("*"):y?g===h[0]?c.push(`<=${y}`):c.push(`${g} - ${y}`):c.push(`>=${g}`);const p=c.join(" || "),E=typeof e.raw=="string"?e.raw:String(e);return p.length{if(i===e)return!0;i=new cr(i,r),e=new cr(e,r);let s=!1;e:for(const a of i.set){for(const l of e.set){const h=Fs(a,l,r);if(s=s||h!==null,h)continue e}if(s)return!1}return!0},bs=[new Bt(">=0.0.0-0")],ur=[new Bt(">=0.0.0")],Fs=(i,e,r)=>{if(i===e)return!0;if(i.length===1&&i[0].semver===mt){if(e.length===1&&e[0].semver===mt)return!0;r.includePrerelease?i=bs:i=ur}if(e.length===1&&e[0].semver===mt){if(r.includePrerelease)return!0;e=ur}const s=new Set;let a,l;for(const I of i)I.operator===">"||I.operator===">="?a=lr(a,I,r):I.operator==="<"||I.operator==="<="?l=hr(l,I,r):s.add(I.semver);if(s.size>1)return null;let h;if(a&&l){if(h=_t(a.semver,l.semver,r),h>0)return null;if(h===0&&(a.operator!==">="||l.operator!=="<="))return null}for(const I of s){if(a&&!Se(I,String(a),r)||l&&!Se(I,String(l),r))return null;for(const v of e)if(!Se(I,String(v),r))return!1;return!0}let c,p,E,g,y=l&&!r.includePrerelease&&l.semver.prerelease.length?l.semver:!1,N=a&&!r.includePrerelease&&a.semver.prerelease.length?a.semver:!1;y&&y.prerelease.length===1&&l.operator==="<"&&y.prerelease[0]===0&&(y=!1);for(const I of e){if(g=g||I.operator===">"||I.operator===">=",E=E||I.operator==="<"||I.operator==="<=",a){if(N&&I.semver.prerelease&&I.semver.prerelease.length&&I.semver.major===N.major&&I.semver.minor===N.minor&&I.semver.patch===N.patch&&(N=!1),I.operator===">"||I.operator===">="){if(c=lr(a,I,r),c===I&&c!==a)return!1}else if(a.operator===">="&&!Se(a.semver,String(I),r))return!1}if(l){if(y&&I.semver.prerelease&&I.semver.prerelease.length&&I.semver.major===y.major&&I.semver.minor===y.minor&&I.semver.patch===y.patch&&(y=!1),I.operator==="<"||I.operator==="<="){if(p=hr(l,I,r),p===I&&p!==l)return!1}else if(l.operator==="<="&&!Se(l.semver,String(I),r))return!1}if(!I.operator&&(l||a)&&h!==0)return!1}return!(a&&E&&!l&&h!==0||l&&g&&!a&&h!==0||N||y)},lr=(i,e,r)=>{if(!i)return e;const s=_t(i.semver,e.semver,r);return s>0?i:s<0||e.operator===">"&&i.operator===">="?e:i},hr=(i,e,r)=>{if(!i)return e;const s=_t(i.semver,e.semver,r);return s<0?i:s>0||e.operator==="<"&&i.operator==="<="?e:i};var Ds=Us;const yt=Ce,fr=ze,Ps=K,pr=Ur,Ms=Ae,Gs=Mn,js=kn,ks=Xn,Vs=qn,Xs=Yn,Hs=Jn,qs=ti,Ws=ii,Ks=J,Ys=ci,zs=hi,Zs=$t,Js=Ei,Qs=yi,eo=Je,to=Tt,ro=br,no=Fr,io=St,so=Nt,oo=Dr,ao=ji,co=Qe(),uo=Q(),lo=et,ho=ts,fo=ss,po=us,Eo=fs,go=Es,mo=Ot,yo=As,wo=Ss,Io=Os,xo=Cs,vo=Ds;var Ro={parse:Ms,valid:Gs,clean:js,inc:ks,diff:Vs,major:Xs,minor:Hs,patch:qs,prerelease:Ws,compare:Ks,rcompare:Ys,compareLoose:zs,compareBuild:Zs,sort:Js,rsort:Qs,gt:eo,lt:to,eq:ro,neq:no,gte:io,lte:so,cmp:oo,coerce:ao,Comparator:co,Range:uo,satisfies:lo,toComparators:ho,maxSatisfying:fo,minSatisfying:po,minVersion:Eo,validRange:go,outside:mo,gtr:yo,ltr:wo,intersects:Io,simplifyRange:xo,subset:vo,SemVer:Ps,re:yt.re,src:yt.src,tokens:yt.t,SEMVER_SPEC_VERSION:fr.SEMVER_SPEC_VERSION,RELEASE_TYPES:fr.RELEASE_TYPES,compareIdentifiers:pr.compareIdentifiers,rcompareIdentifiers:pr.rcompareIdentifiers};const dr=Ir(Ro);var q;(function(i){i.blue="blue",i.nanoS="nanoS",i.nanoSP="nanoSP",i.nanoX="nanoX",i.stax="stax"})(q||(q={}));const It={[q.blue]:{id:q.blue,productName:"Ledger Blue",productIdMM:0,legacyUsbProductId:0,usbOnly:!0,memorySize:480*1024,masks:[822083584,822149120],getBlockSize:i=>4*1024},[q.nanoS]:{id:q.nanoS,productName:"Ledger Nano S",productIdMM:16,legacyUsbProductId:1,usbOnly:!0,memorySize:320*1024,masks:[823132160],getBlockSize:i=>{var e;return dr.lt((e=dr.coerce(i))!==null&&e!==void 0?e:"","2.0.0")?4*1024:2*1024}},[q.nanoSP]:{id:q.nanoSP,productName:"Ledger Nano S Plus",productIdMM:80,legacyUsbProductId:5,usbOnly:!0,memorySize:1533*1024,masks:[856686592],getBlockSize:i=>32},[q.nanoX]:{id:q.nanoX,productName:"Ledger Nano X",productIdMM:64,legacyUsbProductId:4,usbOnly:!1,memorySize:2*1024*1024,masks:[855638016],getBlockSize:i=>4*1024,bluetoothSpec:[{serviceUuid:"13d63400-2c97-0004-0000-4c6564676572",notifyUuid:"13d63400-2c97-0004-0001-4c6564676572",writeUuid:"13d63400-2c97-0004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-0004-0003-4c6564676572"}]},[q.stax]:{id:q.stax,productName:"Ledger Stax",productIdMM:96,legacyUsbProductId:6,usbOnly:!1,memorySize:1533*1024,masks:[857735168],getBlockSize:i=>32,bluetoothSpec:[{serviceUuid:"13d63400-2c97-6004-0000-4c6564676572",notifyUuid:"13d63400-2c97-6004-0001-4c6564676572",writeUuid:"13d63400-2c97-6004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-6004-0003-4c6564676572"}]}};q.blue,q.nanoS,q.nanoSP,q.nanoX,q.stax;const Er=Object.values(It),Gr=11415,jr=i=>{const e=Er.find(a=>a.legacyUsbProductId===i);if(e)return e;const r=i>>8;return Er.find(a=>a.productIdMM===r)},Lo=[],gr={};for(const i in It){const e=It[i],{bluetoothSpec:r}=e;if(r)for(let s=0;sPromise.resolve(!!(window.navigator&&window.navigator.hid)),qe=()=>{const{hid:i}=navigator;if(!i)throw new fe("navigator.hid is not supported","HIDNotSupported");return i};function kr(){return ae(this,void 0,void 0,function*(){const i=yield qe().requestDevice({filters:Ao});return Array.isArray(i)?i:[i]})}function Ct(){return ae(this,void 0,void 0,function*(){return(yield qe().getDevices()).filter(e=>e.vendorId===Gr)})}function To(){return ae(this,void 0,void 0,function*(){const i=yield Ct();return i.length>0?i[0]:(yield kr())[0]})}class pe extends Lt{constructor(e){super(),this.channel=Math.floor(Math.random()*65535),this.packetSize=64,this.inputs=[],this.read=()=>this.inputs.length?Promise.resolve(this.inputs.shift()):new Promise(r=>{this.inputCallback=r}),this.onInputReport=r=>{const s=Buffer.from(r.data.buffer);this.inputCallback?(this.inputCallback(s),this.inputCallback=null):this.inputs.push(s)},this._disconnectEmitted=!1,this._emitDisconnect=r=>{this._disconnectEmitted||(this._disconnectEmitted=!0,this.emit("disconnect",r))},this.exchange=r=>ae(this,void 0,void 0,function*(){return yield this.exchangeAtomicImpl(()=>ae(this,void 0,void 0,function*(){const{channel:a,packetSize:l}=this;kt("apdu","=> "+r.toString("hex"));const h=Rn(a,l),c=h.makeBlocks(r);for(let g=0;g{throw a&&a.message&&a.message.includes("write")?(this._emitDisconnect(a),new En(a.message)):a})}),this.device=e,this.deviceModel=typeof e.productId=="number"?jr(e.productId):void 0,e.addEventListener("inputreport",this.onInputReport)}static request(){return ae(this,void 0,void 0,function*(){const[e]=yield kr();return pe.open(e)})}static openConnected(){return ae(this,void 0,void 0,function*(){const e=yield Ct();return e.length===0?null:pe.open(e[0])})}static open(e){return ae(this,void 0,void 0,function*(){yield e.open();const r=new pe(e),s=a=>{e===a.device&&(qe().removeEventListener("disconnect",s),r._emitDisconnect(new dn))};return qe().addEventListener("disconnect",s),r})}close(){return ae(this,void 0,void 0,function*(){yield this.exchangeBusyPromise,this.device.removeEventListener("inputreport",this.onInputReport),yield this.device.close()})}setScrambleKey(){}}pe.isSupported=$o;pe.list=Ct;pe.listen=i=>{let e=!1;To().then(s=>{if(!s)i.error(new Gt("Access denied to use Ledger device"));else if(!e){const a=typeof s.productId=="number"?jr(s.productId):void 0;i.next({type:"add",descriptor:s,deviceModel:a}),i.complete()}},s=>{i.error(new Gt(s.message))});function r(){e=!0}return{unsubscribe:r}};const Ne=224,So=1,No=2,Oo=3,Bo=4,_o=5,te=36864,ke=27013,mr=27750,Ve=27904,Co=1,Uo=2,bo=4,yr=8,wr=255;class Fo{constructor(e,r="l0v"){this.transport=void 0,this.transport=e,e.decorateAppAPIMethods(this,["getConfiguration","getPublicKey","getAddress","signMessage","signTransaction"],r)}getConfiguration(){return this.transport.send(Ne,So,0,0).then(e=>{if(M.Buffer.from(e.slice(e.length-2)).readUInt16BE(0)===te)return{configuration:e.slice()};throw new Error("Failed to get configuration")})}getPublicKey({account:e},r=!1){const s=M.Buffer.alloc(4);return s.writeUInt32BE(e),this.transport.send(Ne,No,r?1:0,0,s,[te]).then(a=>{if(M.Buffer.from(a.slice(a.length-2)).readUInt16BE(0)===te)return{publicKey:a.slice(1,33)};throw new Error("Failed to get public key")})}getAddress({account:e,contract:r}){const s=M.Buffer.alloc(5);return s.writeUInt32BE(e,0),s.writeUint8(r,4),this.transport.send(Ne,Bo,1,0,s,[te]).then(a=>{if(M.Buffer.from(a.slice(a.length-2)).readUInt16BE(0)===te)return{address:a.slice(1,33)};throw new Error("Failed to get address")})}signMessage({account:e,message:r,chainId:s}){let a=0;const l=[],h=M.Buffer.alloc(4);if(h.writeUInt32BE(e,0),typeof s=="number"){const E=M.Buffer.alloc(4);E.writeUInt32BE(s,0),a|=yr,l.push(E)}const c=[h,M.Buffer.alloc(1,a),...l,r],p=M.Buffer.concat(c);return this.transport.send(Ne,Oo,1,0,p,[te,ke,mr,Ve]).then(E=>{const g=M.Buffer.from(E.slice(E.length-2)).readUInt16BE(0);if(g===te)return{signature:E.slice(1,E.length-2)};throw g===ke?new Error("Transaction approval request was rejected"):g===Ve?new Error("Message signing is not supported"):new Error("Message signing not allowed. Have you enabled it in the app settings?")})}async signTransaction({account:e,originalWallet:r,wallet:s,message:a,chainId:l,context:h}){let c=0;const p=[],E=M.Buffer.alloc(5);E.writeUInt32BE(e,0),E.writeUint8(r,4);const g=M.Buffer.alloc(1);g.writeUInt8(h.decimals,0);let y=h.asset;h.asset.includes("-LP-")?y="LP":h.asset.length>8&&(y=h.asset.substring(0,6)+"..");const N=M.Buffer.from(y,"utf-8");if(typeof s=="number"&&s!==r&&(c|=Co,p.push(M.Buffer.alloc(1,s))),typeof h.workchainId=="number"&&(c|=Uo,p.push(M.Buffer.alloc(1,h.workchainId))),typeof h.address=="string"){if(h.address.length!==64)throw new Error("Invalid address format");c|=bo,p.push(M.Buffer.from(h.address,"hex"))}if(typeof l=="number"){const _=M.Buffer.alloc(4);_.writeUInt32BE(l,0),c|=yr,p.push(_)}const I=[E,g,M.Buffer.alloc(1,N.length),N,M.Buffer.alloc(1,c),...p,a.subarray(4)],v=M.Buffer.concat(I),k=[];for(let _=0;_{if(e&&e.data&&e.data.target==="LEDGER-IFRAME"){const{action:r,params:s}=e.data,a=`${r}-reply`;switch(r){case"ledger-get-configuration":await this.getConfiguration(a);break;case"ledger-get-public-key":await this.getPublicKey(a,s);break;case"ledger-get-address":await this.getAddress(a,s);break;case"ledger-sign-message":await this.signMessage(a,s);break;case"ledger-sign-transaction":await this.signTransaction(a,s);break;case"ledger-close-bridge":await this.cleanUp(a);break}}},!1)}sendMessageToExtension(e){window.parent.postMessage(e,"*")}async makeApp(){try{this.transport=await pe.create(),this.app=new Fo(this.transport)}catch(e){throw console.log("LEDGER:::CREATE APP ERROR",e),e}}async cleanUp(e){this.app=null,this.transport&&await this.transport.close(),e&&this.sendMessageToExtension({action:e,success:!0})}async getConfiguration(e){try{await this.makeApp();const r=await this.app.getConfiguration();this.sendMessageToExtension({action:e,success:!0,payload:r})}catch(r){const s=this.ledgerErrToMessage(r);this.sendMessageToExtension({action:e,success:!1,error:new Error(s.toString())})}finally{await this.cleanUp()}}async getPublicKey(e,r){try{await this.makeApp();const s=await this.app.getPublicKey(r);this.sendMessageToExtension({action:e,success:!0,payload:s})}catch(s){const a=this.ledgerErrToMessage(s);this.sendMessageToExtension({action:e,success:!1,error:new Error(a.toString())})}finally{await this.cleanUp()}}async getAddress(e,r){try{await this.makeApp();const s=await this.app.getAddress(r);this.sendMessageToExtension({action:e,success:!0,payload:s})}catch(s){const a=this.ledgerErrToMessage(s);this.sendMessageToExtension({action:e,success:!1,error:new Error(a.toString())})}finally{await this.cleanUp()}}async signMessage(e,r){try{await this.makeApp();const s=await this.app.signMessage(r);this.sendMessageToExtension({action:e,success:!0,payload:s})}catch(s){const a=this.ledgerErrToMessage(s);this.sendMessageToExtension({action:e,success:!1,error:new Error(a.toString())})}finally{await this.cleanUp()}}async signTransaction(e,r){try{await this.makeApp();const s=await this.app.signTransaction(r);this.sendMessageToExtension({action:e,success:!0,payload:s})}catch(s){const a=this.ledgerErrToMessage(s);this.sendMessageToExtension({action:e,success:!1,error:new Error(a.toString())})}finally{await this.cleanUp()}}ledgerErrToMessage(e){const r=c=>String(c.message||c).includes("0x6700"),s=c=>String(c.message||c).includes("0x6804"),a=c=>c.name&&c.name.includes("TransportOpenUserCancelled"),l=c=>c.message&&c.message.includes("Message signing is not supported"),h=c=>c.message&&c.message.includes("Transaction approval request was rejected");return r(e)?"LEDGER_WRONG_APP":s(e)?"LEDGER_LOCKED":h(e)?"TRANSACTION_REJECTED":l(e)?"SIGN_NON_SUPPORTED":a(e)&&e.message&&e.message.includes("Access denied to use Ledger device")?"USER_DENIED":a(e)&&e.message&&e.message.includes("Failed to execute 'requestDevice' on 'HID'")?"USER_CANCELLED":e.toString()}}(()=>{const e=new URLSearchParams(window.location.search).get("theme")||"default",r=document.querySelector(`[data-theme="${e}"]`);r.style.display=null;const s=new Do,a=r.querySelector('[data-action="pairing"]');a&&a.addEventListener("click",()=>s.getConfiguration());const l=r.querySelector('[data-action="back"]');l&&l.addEventListener("click",()=>s.cleanUp("ledger-bridge-back")),console.log(`EVER Wallet <=> Ledger Bridge initialized from ${window.location}!`)})(); diff --git a/docs/index-f8bd1d8c.js b/docs/index-f8bd1d8c.js deleted file mode 100644 index ec01ada..0000000 --- a/docs/index-f8bd1d8c.js +++ /dev/null @@ -1,7 +0,0 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))s(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const h of l.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&s(h)}).observe(document,{childList:!0,subtree:!0});function r(a){const l={};return a.integrity&&(l.integrity=a.integrity),a.referrerPolicy&&(l.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?l.credentials="include":a.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function s(a){if(a.ep)return;a.ep=!0;const l=r(a);fetch(a.href,l)}})();function mr(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var P={},He={};He.byteLength=Wr;He.toByteArray=Yr;He.fromByteArray=Zr;var re=[],Y=[],Hr=typeof Uint8Array<"u"?Uint8Array:Array,ct="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var ye=0,qr=ct.length;ye0)throw new Error("Invalid string. Length must be a multiple of 4");var r=i.indexOf("=");r===-1&&(r=e);var s=r===e?0:4-r%4;return[r,s]}function Wr(i){var e=yr(i),r=e[0],s=e[1];return(r+s)*3/4-s}function Kr(i,e,r){return(e+r)*3/4-r}function Yr(i){var e,r=yr(i),s=r[0],a=r[1],l=new Hr(Kr(i,s,a)),h=0,u=a>0?s-4:s,p;for(p=0;p>16&255,l[h++]=e>>8&255,l[h++]=e&255;return a===2&&(e=Y[i.charCodeAt(p)]<<2|Y[i.charCodeAt(p+1)]>>4,l[h++]=e&255),a===1&&(e=Y[i.charCodeAt(p)]<<10|Y[i.charCodeAt(p+1)]<<4|Y[i.charCodeAt(p+2)]>>2,l[h++]=e>>8&255,l[h++]=e&255),l}function zr(i){return re[i>>18&63]+re[i>>12&63]+re[i>>6&63]+re[i&63]}function Jr(i,e,r){for(var s,a=[],l=e;lu?u:h+l));return s===1?(e=i[r-1],a.push(re[e>>2]+re[e<<4&63]+"==")):s===2&&(e=(i[r-2]<<8)+i[r-1],a.push(re[e>>10]+re[e>>4&63]+re[e<<2&63]+"=")),a.join("")}var It={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */It.read=function(i,e,r,s,a){var l,h,u=a*8-s-1,p=(1<>1,m=-7,y=r?a-1:0,N=r?-1:1,I=i[e+y];for(y+=N,l=I&(1<<-m)-1,I>>=-m,m+=u;m>0;l=l*256+i[e+y],y+=N,m-=8);for(h=l&(1<<-m)-1,l>>=-m,m+=s;m>0;h=h*256+i[e+y],y+=N,m-=8);if(l===0)l=1-E;else{if(l===p)return h?NaN:(I?-1:1)*(1/0);h=h+Math.pow(2,s),l=l-E}return(I?-1:1)*h*Math.pow(2,l-s)};It.write=function(i,e,r,s,a,l){var h,u,p,E=l*8-a-1,m=(1<>1,N=a===23?Math.pow(2,-24)-Math.pow(2,-77):0,I=s?0:l-1,A=s?1:-1,M=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(u=isNaN(e)?1:0,h=m):(h=Math.floor(Math.log(e)/Math.LN2),e*(p=Math.pow(2,-h))<1&&(h--,p*=2),h+y>=1?e+=N/p:e+=N*Math.pow(2,1-y),e*p>=2&&(h++,p/=2),h+y>=m?(u=0,h=m):h+y>=1?(u=(e*p-1)*Math.pow(2,a),h=h+y):(u=e*Math.pow(2,y-1)*Math.pow(2,a),h=0));a>=8;i[r+I]=u&255,I+=A,u/=256,a-=8);for(h=h<0;i[r+I]=h&255,I+=A,h/=256,E-=8);i[r+I-A]|=M*128};/*! - * The buffer module from node.js, for the browser. - * - * @author Feross Aboukhadijeh - * @license MIT - */(function(i){const e=He,r=It,s=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;i.Buffer=u,i.SlowBuffer=k,i.INSPECT_MAX_BYTES=50;const a=2147483647;i.kMaxLength=a,u.TYPED_ARRAY_SUPPORT=l(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function l(){try{const o=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(o,t),o.foo()===42}catch{return!1}}Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}});function h(o){if(o>a)throw new RangeError('The value "'+o+'" is invalid for option "size"');const t=new Uint8Array(o);return Object.setPrototypeOf(t,u.prototype),t}function u(o,t,n){if(typeof o=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return y(o)}return p(o,t,n)}u.poolSize=8192;function p(o,t,n){if(typeof o=="string")return N(o,t);if(ArrayBuffer.isView(o))return A(o);if(o==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o);if(ee(o,ArrayBuffer)||o&&ee(o.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(ee(o,SharedArrayBuffer)||o&&ee(o.buffer,SharedArrayBuffer)))return M(o,t,n);if(typeof o=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const c=o.valueOf&&o.valueOf();if(c!=null&&c!==o)return u.from(c,t,n);const f=V(o);if(f)return f;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof o[Symbol.toPrimitive]=="function")return u.from(o[Symbol.toPrimitive]("string"),t,n);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof o)}u.from=function(o,t,n){return p(o,t,n)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function E(o){if(typeof o!="number")throw new TypeError('"size" argument must be of type number');if(o<0)throw new RangeError('The value "'+o+'" is invalid for option "size"')}function m(o,t,n){return E(o),o<=0?h(o):t!==void 0?typeof n=="string"?h(o).fill(t,n):h(o).fill(t):h(o)}u.alloc=function(o,t,n){return m(o,t,n)};function y(o){return E(o),h(o<0?0:K(o)|0)}u.allocUnsafe=function(o){return y(o)},u.allocUnsafeSlow=function(o){return y(o)};function N(o,t){if((typeof t!="string"||t==="")&&(t="utf8"),!u.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const n=Q(o,t)|0;let c=h(n);const f=c.write(o,t);return f!==n&&(c=c.slice(0,f)),c}function I(o){const t=o.length<0?0:K(o.length)|0,n=h(t);for(let c=0;c=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return o|0}function k(o){return+o!=o&&(o=0),u.alloc(+o)}u.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==u.prototype},u.compare=function(t,n){if(ee(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),ee(n,Uint8Array)&&(n=u.from(n,n.offset,n.byteLength)),!u.isBuffer(t)||!u.isBuffer(n))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===n)return 0;let c=t.length,f=n.length;for(let d=0,g=Math.min(c,f);df.length?(u.isBuffer(g)||(g=u.from(g)),g.copy(f,d)):Uint8Array.prototype.set.call(f,g,d);else if(u.isBuffer(g))g.copy(f,d);else throw new TypeError('"list" argument must be an Array of Buffers');d+=g.length}return f};function Q(o,t){if(u.isBuffer(o))return o.length;if(ArrayBuffer.isView(o)||ee(o,ArrayBuffer))return o.byteLength;if(typeof o!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof o);const n=o.length,c=arguments.length>2&&arguments[2]===!0;if(!c&&n===0)return 0;let f=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":return ot(o).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return n*2;case"hex":return n>>>1;case"base64":return bt(o).length;default:if(f)return c?-1:ot(o).length;t=(""+t).toLowerCase(),f=!0}}u.byteLength=Q;function Ze(o,t,n){let c=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((n===void 0||n>this.length)&&(n=this.length),n<=0)||(n>>>=0,t>>>=0,n<=t))return"";for(o||(o="utf8");;)switch(o){case"hex":return S(this,t,n);case"utf8":case"utf-8":return w(this,t,n);case"ascii":return $(this,t,n);case"latin1":case"binary":return v(this,t,n);case"base64":return x(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,n);default:if(c)throw new TypeError("Unknown encoding: "+o);o=(o+"").toLowerCase(),c=!0}}u.prototype._isBuffer=!0;function ne(o,t,n){const c=o[t];o[t]=o[n],o[n]=c}u.prototype.swap16=function(){const t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let n=0;nn&&(t+=" ... "),""},s&&(u.prototype[s]=u.prototype.inspect),u.prototype.compare=function(t,n,c,f,d){if(ee(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(n===void 0&&(n=0),c===void 0&&(c=t?t.length:0),f===void 0&&(f=0),d===void 0&&(d=this.length),n<0||c>t.length||f<0||d>this.length)throw new RangeError("out of range index");if(f>=d&&n>=c)return 0;if(f>=d)return-1;if(n>=c)return 1;if(n>>>=0,c>>>=0,f>>>=0,d>>>=0,this===t)return 0;let g=d-f,B=c-n;const G=Math.min(g,B),F=this.slice(f,d),j=t.slice(n,c);for(let b=0;b2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,at(n)&&(n=f?0:o.length-1),n<0&&(n=o.length+n),n>=o.length){if(f)return-1;n=o.length-1}else if(n<0)if(f)n=0;else return-1;if(typeof t=="string"&&(t=u.from(t,c)),u.isBuffer(t))return t.length===0?-1:Ue(o,t,n,c,f);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?f?Uint8Array.prototype.indexOf.call(o,t,n):Uint8Array.prototype.lastIndexOf.call(o,t,n):Ue(o,[t],n,c,f);throw new TypeError("val must be string, number or Buffer")}function Ue(o,t,n,c,f){let d=1,g=o.length,B=t.length;if(c!==void 0&&(c=String(c).toLowerCase(),c==="ucs2"||c==="ucs-2"||c==="utf16le"||c==="utf-16le")){if(o.length<2||t.length<2)return-1;d=2,g/=2,B/=2,n/=2}function G(j,b){return d===1?j[b]:j.readUInt16BE(b*d)}let F;if(f){let j=-1;for(F=n;Fg&&(n=g-B),F=n;F>=0;F--){let j=!0;for(let b=0;bf&&(c=f)):c=f;const d=t.length;c>d/2&&(c=d/2);let g;for(g=0;g>>0,isFinite(c)?(c=c>>>0,f===void 0&&(f="utf8")):(f=c,c=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const d=this.length-n;if((c===void 0||c>d)&&(c=d),t.length>0&&(c<0||n<0)||n>this.length)throw new RangeError("Attempt to write outside buffer bounds");f||(f="utf8");let g=!1;for(;;)switch(f){case"hex":return Qe(this,t,n,c);case"utf8":case"utf-8":return et(this,t,n,c);case"ascii":case"latin1":case"binary":return tt(this,t,n,c);case"base64":return rt(this,t,n,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return nt(this,t,n,c);default:if(g)throw new TypeError("Unknown encoding: "+f);f=(""+f).toLowerCase(),g=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function x(o,t,n){return t===0&&n===o.length?e.fromByteArray(o):e.fromByteArray(o.slice(t,n))}function w(o,t,n){n=Math.min(o.length,n);const c=[];let f=t;for(;f239?4:d>223?3:d>191?2:1;if(f+B<=n){let G,F,j,b;switch(B){case 1:d<128&&(g=d);break;case 2:G=o[f+1],(G&192)===128&&(b=(d&31)<<6|G&63,b>127&&(g=b));break;case 3:G=o[f+1],F=o[f+2],(G&192)===128&&(F&192)===128&&(b=(d&15)<<12|(G&63)<<6|F&63,b>2047&&(b<55296||b>57343)&&(g=b));break;case 4:G=o[f+1],F=o[f+2],j=o[f+3],(G&192)===128&&(F&192)===128&&(j&192)===128&&(b=(d&15)<<18|(G&63)<<12|(F&63)<<6|j&63,b>65535&&b<1114112&&(g=b))}}g===null?(g=65533,B=1):g>65535&&(g-=65536,c.push(g>>>10&1023|55296),g=56320|g&1023),c.push(g),f+=B}return L(c)}const T=4096;function L(o){const t=o.length;if(t<=T)return String.fromCharCode.apply(String,o);let n="",c=0;for(;cc)&&(n=c);let f="";for(let d=t;dc&&(t=c),n<0?(n+=c,n<0&&(n=0)):n>c&&(n=c),nn)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(t,n,c){t=t>>>0,n=n>>>0,c||R(t,n,this.length);let f=this[t],d=1,g=0;for(;++g>>0,n=n>>>0,c||R(t,n,this.length);let f=this[t+--n],d=1;for(;n>0&&(d*=256);)f+=this[t+--n]*d;return f},u.prototype.readUint8=u.prototype.readUInt8=function(t,n){return t=t>>>0,n||R(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,n){return t=t>>>0,n||R(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,n){return t=t>>>0,n||R(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,n){return t=t>>>0,n||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,n){return t=t>>>0,n||R(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=ue(function(t){t=t>>>0,me(t,"offset");const n=this[t],c=this[t+7];(n===void 0||c===void 0)&&Ae(t,this.length-8);const f=n+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,d=this[++t]+this[++t]*2**8+this[++t]*2**16+c*2**24;return BigInt(f)+(BigInt(d)<>>0,me(t,"offset");const n=this[t],c=this[t+7];(n===void 0||c===void 0)&&Ae(t,this.length-8);const f=n*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],d=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+c;return(BigInt(f)<>>0,n=n>>>0,c||R(t,n,this.length);let f=this[t],d=1,g=0;for(;++g=d&&(f-=Math.pow(2,8*n)),f},u.prototype.readIntBE=function(t,n,c){t=t>>>0,n=n>>>0,c||R(t,n,this.length);let f=n,d=1,g=this[t+--f];for(;f>0&&(d*=256);)g+=this[t+--f]*d;return d*=128,g>=d&&(g-=Math.pow(2,8*n)),g},u.prototype.readInt8=function(t,n){return t=t>>>0,n||R(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},u.prototype.readInt16LE=function(t,n){t=t>>>0,n||R(t,2,this.length);const c=this[t]|this[t+1]<<8;return c&32768?c|4294901760:c},u.prototype.readInt16BE=function(t,n){t=t>>>0,n||R(t,2,this.length);const c=this[t+1]|this[t]<<8;return c&32768?c|4294901760:c},u.prototype.readInt32LE=function(t,n){return t=t>>>0,n||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,n){return t=t>>>0,n||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=ue(function(t){t=t>>>0,me(t,"offset");const n=this[t],c=this[t+7];(n===void 0||c===void 0)&&Ae(t,this.length-8);const f=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(c<<24);return(BigInt(f)<>>0,me(t,"offset");const n=this[t],c=this[t+7];(n===void 0||c===void 0)&&Ae(t,this.length-8);const f=(n<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(f)<>>0,n||R(t,4,this.length),r.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,n){return t=t>>>0,n||R(t,4,this.length),r.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,n){return t=t>>>0,n||R(t,8,this.length),r.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,n){return t=t>>>0,n||R(t,8,this.length),r.read(this,t,!1,52,8)};function O(o,t,n,c,f,d){if(!u.isBuffer(o))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>f||to.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,n,c,f){if(t=+t,n=n>>>0,c=c>>>0,!f){const B=Math.pow(2,8*c)-1;O(this,t,n,c,B,0)}let d=1,g=0;for(this[n]=t&255;++g>>0,c=c>>>0,!f){const B=Math.pow(2,8*c)-1;O(this,t,n,c,B,0)}let d=c-1,g=1;for(this[n+d]=t&255;--d>=0&&(g*=256);)this[n+d]=t/g&255;return n+c},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,n,c){return t=+t,n=n>>>0,c||O(this,t,n,1,255,0),this[n]=t&255,n+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,n,c){return t=+t,n=n>>>0,c||O(this,t,n,2,65535,0),this[n]=t&255,this[n+1]=t>>>8,n+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,n,c){return t=+t,n=n>>>0,c||O(this,t,n,2,65535,0),this[n]=t>>>8,this[n+1]=t&255,n+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,n,c){return t=+t,n=n>>>0,c||O(this,t,n,4,4294967295,0),this[n+3]=t>>>24,this[n+2]=t>>>16,this[n+1]=t>>>8,this[n]=t&255,n+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,n,c){return t=+t,n=n>>>0,c||O(this,t,n,4,4294967295,0),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4};function q(o,t,n,c,f){Ct(t,c,f,o,n,7);let d=Number(t&BigInt(4294967295));o[n++]=d,d=d>>8,o[n++]=d,d=d>>8,o[n++]=d,d=d>>8,o[n++]=d;let g=Number(t>>BigInt(32)&BigInt(4294967295));return o[n++]=g,g=g>>8,o[n++]=g,g=g>>8,o[n++]=g,g=g>>8,o[n++]=g,n}function D(o,t,n,c,f){Ct(t,c,f,o,n,7);let d=Number(t&BigInt(4294967295));o[n+7]=d,d=d>>8,o[n+6]=d,d=d>>8,o[n+5]=d,d=d>>8,o[n+4]=d;let g=Number(t>>BigInt(32)&BigInt(4294967295));return o[n+3]=g,g=g>>8,o[n+2]=g,g=g>>8,o[n+1]=g,g=g>>8,o[n]=g,n+8}u.prototype.writeBigUInt64LE=ue(function(t,n=0){return q(this,t,n,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=ue(function(t,n=0){return D(this,t,n,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(t,n,c,f){if(t=+t,n=n>>>0,!f){const G=Math.pow(2,8*c-1);O(this,t,n,c,G-1,-G)}let d=0,g=1,B=0;for(this[n]=t&255;++d>0)-B&255;return n+c},u.prototype.writeIntBE=function(t,n,c,f){if(t=+t,n=n>>>0,!f){const G=Math.pow(2,8*c-1);O(this,t,n,c,G-1,-G)}let d=c-1,g=1,B=0;for(this[n+d]=t&255;--d>=0&&(g*=256);)t<0&&B===0&&this[n+d+1]!==0&&(B=1),this[n+d]=(t/g>>0)-B&255;return n+c},u.prototype.writeInt8=function(t,n,c){return t=+t,n=n>>>0,c||O(this,t,n,1,127,-128),t<0&&(t=255+t+1),this[n]=t&255,n+1},u.prototype.writeInt16LE=function(t,n,c){return t=+t,n=n>>>0,c||O(this,t,n,2,32767,-32768),this[n]=t&255,this[n+1]=t>>>8,n+2},u.prototype.writeInt16BE=function(t,n,c){return t=+t,n=n>>>0,c||O(this,t,n,2,32767,-32768),this[n]=t>>>8,this[n+1]=t&255,n+2},u.prototype.writeInt32LE=function(t,n,c){return t=+t,n=n>>>0,c||O(this,t,n,4,2147483647,-2147483648),this[n]=t&255,this[n+1]=t>>>8,this[n+2]=t>>>16,this[n+3]=t>>>24,n+4},u.prototype.writeInt32BE=function(t,n,c){return t=+t,n=n>>>0,c||O(this,t,n,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[n]=t>>>24,this[n+1]=t>>>16,this[n+2]=t>>>8,this[n+3]=t&255,n+4},u.prototype.writeBigInt64LE=ue(function(t,n=0){return q(this,t,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=ue(function(t,n=0){return D(this,t,n,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function ce(o,t,n,c,f,d){if(n+c>o.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function it(o,t,n,c,f){return t=+t,n=n>>>0,f||ce(o,t,n,4),r.write(o,t,n,c,23,4),n+4}u.prototype.writeFloatLE=function(t,n,c){return it(this,t,n,!0,c)},u.prototype.writeFloatBE=function(t,n,c){return it(this,t,n,!1,c)};function _t(o,t,n,c,f){return t=+t,n=n>>>0,f||ce(o,t,n,8),r.write(o,t,n,c,52,8),n+8}u.prototype.writeDoubleLE=function(t,n,c){return _t(this,t,n,!0,c)},u.prototype.writeDoubleBE=function(t,n,c){return _t(this,t,n,!1,c)},u.prototype.copy=function(t,n,c,f){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(c||(c=0),!f&&f!==0&&(f=this.length),n>=t.length&&(n=t.length),n||(n=0),f>0&&f=this.length)throw new RangeError("Index out of range");if(f<0)throw new RangeError("sourceEnd out of bounds");f>this.length&&(f=this.length),t.length-n>>0,c=c===void 0?this.length:c>>>0,t||(t=0);let d;if(typeof t=="number")for(d=n;d2**32?f=Ut(String(n)):typeof n=="bigint"&&(f=String(n),(n>BigInt(2)**BigInt(32)||n<-(BigInt(2)**BigInt(32)))&&(f=Ut(f)),f+="n"),c+=` It must be ${t}. Received ${f}`,c},RangeError);function Ut(o){let t="",n=o.length;const c=o[0]==="-"?1:0;for(;n>=c+4;n-=3)t=`_${o.slice(n-3,n)}${t}`;return`${o.slice(0,n)}${t}`}function Pr(o,t,n){me(t,"offset"),(o[t]===void 0||o[t+n]===void 0)&&Ae(t,o.length-(n+1))}function Ct(o,t,n,c,f,d){if(o>n||o3?t===0||t===BigInt(0)?B=`>= 0${g} and < 2${g} ** ${(d+1)*8}${g}`:B=`>= -(2${g} ** ${(d+1)*8-1}${g}) and < 2 ** ${(d+1)*8-1}${g}`:B=`>= ${t}${g} and <= ${n}${g}`,new ge.ERR_OUT_OF_RANGE("value",B,o)}Pr(c,f,d)}function me(o,t){if(typeof o!="number")throw new ge.ERR_INVALID_ARG_TYPE(t,"number",o)}function Ae(o,t,n){throw Math.floor(o)!==o?(me(o,n),new ge.ERR_OUT_OF_RANGE(n||"offset","an integer",o)):t<0?new ge.ERR_BUFFER_OUT_OF_BOUNDS:new ge.ERR_OUT_OF_RANGE(n||"offset",`>= ${n?1:0} and <= ${t}`,o)}const Mr=/[^+/0-9A-Za-z-_]/g;function Gr(o){if(o=o.split("=")[0],o=o.trim().replace(Mr,""),o.length<2)return"";for(;o.length%4!==0;)o=o+"=";return o}function ot(o,t){t=t||1/0;let n;const c=o.length;let f=null;const d=[];for(let g=0;g55295&&n<57344){if(!f){if(n>56319){(t-=3)>-1&&d.push(239,191,189);continue}else if(g+1===c){(t-=3)>-1&&d.push(239,191,189);continue}f=n;continue}if(n<56320){(t-=3)>-1&&d.push(239,191,189),f=n;continue}n=(f-55296<<10|n-56320)+65536}else f&&(t-=3)>-1&&d.push(239,191,189);if(f=null,n<128){if((t-=1)<0)break;d.push(n)}else if(n<2048){if((t-=2)<0)break;d.push(n>>6|192,n&63|128)}else if(n<65536){if((t-=3)<0)break;d.push(n>>12|224,n>>6&63|128,n&63|128)}else if(n<1114112){if((t-=4)<0)break;d.push(n>>18|240,n>>12&63|128,n>>6&63|128,n&63|128)}else throw new Error("Invalid code point")}return d}function jr(o){const t=[];for(let n=0;n>8,f=n%256,d.push(f),d.push(c);return d}function bt(o){return e.toByteArray(Gr(o))}function Ce(o,t,n,c){let f;for(f=0;f=t.length||f>=o.length);++f)t[f+n]=o[f];return f}function ee(o,t){return o instanceof t||o!=null&&o.constructor!=null&&o.constructor.name!=null&&o.constructor.name===t.name}function at(o){return o!==o}const Vr=function(){const o="0123456789abcdef",t=new Array(256);for(let n=0;n<16;++n){const c=n*16;for(let f=0;f<16;++f)t[c+f]=o[n]+o[f]}return t}();function ue(o){return typeof BigInt>"u"?Xr:o}function Xr(){throw new Error("BigInt not supported")}})(P);window.Buffer=P.Buffer;var xt={exports:{}},xe=typeof Reflect=="object"?Reflect:null,Ft=xe&&typeof xe.apply=="function"?xe.apply:function(e,r,s){return Function.prototype.apply.call(e,r,s)},ke;xe&&typeof xe.ownKeys=="function"?ke=xe.ownKeys:Object.getOwnPropertySymbols?ke=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:ke=function(e){return Object.getOwnPropertyNames(e)};function Qr(i){console&&console.warn&&console.warn(i)}var wr=Number.isNaN||function(e){return e!==e};function C(){C.init.call(this)}xt.exports=C;xt.exports.once=nn;C.EventEmitter=C;C.prototype._events=void 0;C.prototype._eventsCount=0;C.prototype._maxListeners=void 0;var Dt=10;function qe(i){if(typeof i!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof i)}Object.defineProperty(C,"defaultMaxListeners",{enumerable:!0,get:function(){return Dt},set:function(i){if(typeof i!="number"||i<0||wr(i))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+i+".");Dt=i}});C.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};C.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||wr(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Ir(i){return i._maxListeners===void 0?C.defaultMaxListeners:i._maxListeners}C.prototype.getMaxListeners=function(){return Ir(this)};C.prototype.emit=function(e){for(var r=[],s=1;s0&&(h=r[0]),h instanceof Error)throw h;var u=new Error("Unhandled error."+(h?" ("+h.message+")":""));throw u.context=h,u}var p=l[e];if(p===void 0)return!1;if(typeof p=="function")Ft(p,this,r);else for(var E=p.length,m=Lr(p,E),s=0;s0&&h.length>a&&!h.warned){h.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+h.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=i,u.type=e,u.count=h.length,Qr(u)}return i}C.prototype.addListener=function(e,r){return xr(this,e,r,!1)};C.prototype.on=C.prototype.addListener;C.prototype.prependListener=function(e,r){return xr(this,e,r,!0)};function en(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function vr(i,e,r){var s={fired:!1,wrapFn:void 0,target:i,type:e,listener:r},a=en.bind(s);return a.listener=r,s.wrapFn=a,a}C.prototype.once=function(e,r){return qe(r),this.on(e,vr(this,e,r)),this};C.prototype.prependOnceListener=function(e,r){return qe(r),this.prependListener(e,vr(this,e,r)),this};C.prototype.removeListener=function(e,r){var s,a,l,h,u;if(qe(r),a=this._events,a===void 0)return this;if(s=a[e],s===void 0)return this;if(s===r||s.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete a[e],a.removeListener&&this.emit("removeListener",e,s.listener||r));else if(typeof s!="function"){for(l=-1,h=s.length-1;h>=0;h--)if(s[h]===r||s[h].listener===r){u=s[h].listener,l=h;break}if(l<0)return this;l===0?s.shift():tn(s,l),s.length===1&&(a[e]=s[0]),a.removeListener!==void 0&&this.emit("removeListener",e,u||r)}return this};C.prototype.off=C.prototype.removeListener;C.prototype.removeAllListeners=function(e){var r,s,a;if(s=this._events,s===void 0)return this;if(s.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):s[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete s[e]),this;if(arguments.length===0){var l=Object.keys(s),h;for(a=0;a=0;a--)this.removeListener(e,r[a]);return this};function Rr(i,e,r){var s=i._events;if(s===void 0)return[];var a=s[e];return a===void 0?[]:typeof a=="function"?r?[a.listener||a]:[a]:r?rn(a):Lr(a,a.length)}C.prototype.listeners=function(e){return Rr(this,e,!0)};C.prototype.rawListeners=function(e){return Rr(this,e,!1)};C.listenerCount=function(i,e){return typeof i.listenerCount=="function"?i.listenerCount(e):Ar.call(i,e)};C.prototype.listenerCount=Ar;function Ar(i){var e=this._events;if(e!==void 0){var r=e[i];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}C.prototype.eventNames=function(){return this._eventsCount>0?ke(this._events):[]};function Lr(i,e){for(var r=new Array(e),s=0;s{class e extends Error{constructor(s,a,l){if(super(s||i,l),Object.setPrototypeOf(this,e.prototype),this.name=i,a)for(const h in a)this[h]=a[h];if(l&&cn(l)&&"cause"in l&&!("cause"in this)){const h=l.cause;this.cause=h,"stack"in h&&(this.stack=this.stack+` -CAUSE: `+h.stack)}}}return e};function cn(i){return typeof i=="object"}const un=Oe("LockedDeviceError"),ln=Oe("DisconnectedDevice"),hn=Oe("DisconnectedDeviceDuringOperation"),Pt=Oe("TransportOpenUserCancelled"),fn=Oe("TransportRaceCondition");var Mt;(function(i){i.Unknown="Unknown",i.LocationServicesDisabled="LocationServicesDisabled",i.LocationServicesUnauthorized="LocationServicesUnauthorized",i.BluetoothScanStartFailed="BluetoothScanStartFailed"})(Mt||(Mt={}));class he extends Error{constructor(e,r){const s="TransportError";super(e||s),this.name=s,this.message=e,this.stack=new Error(e).stack,this.id=r}}const Se={ACCESS_CONDITION_NOT_FULFILLED:38916,ALGORITHM_NOT_SUPPORTED:38020,CLA_NOT_SUPPORTED:28160,CODE_BLOCKED:38976,CODE_NOT_INITIALIZED:38914,COMMAND_INCOMPATIBLE_FILE_STRUCTURE:27009,CONDITIONS_OF_USE_NOT_SATISFIED:27013,CONTRADICTION_INVALIDATION:38928,CONTRADICTION_SECRET_CODE_STATUS:38920,CUSTOM_IMAGE_BOOTLOADER:26159,CUSTOM_IMAGE_EMPTY:26158,FILE_ALREADY_EXISTS:27273,FILE_NOT_FOUND:37892,GP_AUTH_FAILED:25344,HALTED:28586,INCONSISTENT_FILE:37896,INCORRECT_DATA:27264,INCORRECT_LENGTH:26368,INCORRECT_P1_P2:27392,INS_NOT_SUPPORTED:27904,DEVICE_NOT_ONBOARDED:27911,DEVICE_NOT_ONBOARDED_2:26129,INVALID_KCV:38021,INVALID_OFFSET:37890,LICENSING:28482,LOCKED_DEVICE:21781,MAX_VALUE_REACHED:38992,MEMORY_PROBLEM:37440,MISSING_CRITICAL_PARAMETER:26624,NO_EF_SELECTED:37888,NOT_ENOUGH_MEMORY_SPACE:27268,OK:36864,PIN_REMAINING_ATTEMPTS:25536,REFERENCED_DATA_NOT_FOUND:27272,SECURITY_STATUS_NOT_SATISFIED:27010,TECHNICAL_PROBLEM:28416,UNKNOWN_APDU:27906,USER_REFUSED_ON_DEVICE:21761,NOT_ENOUGH_SPACE:20738};function pn(i){switch(i){case 26368:return"Incorrect length";case 26624:return"Missing critical parameter";case 27010:return"Security not satisfied (dongle locked or have invalid access rights)";case 27013:return"Condition of use not satisfied (denied by the user?)";case 27264:return"Invalid data received";case 27392:return"Invalid parameter received";case 21781:return"Locked device"}if(28416<=i&&i<=28671)return"Internal error, please report"}function mt(i){const e=Object.keys(Se).find(l=>Se[l]===i)||"UNKNOWN_ERROR",r=pn(i)||e,s=i.toString(16),a=`Ledger device: ${r} (0x${s})`;if(i===Se.LOCKED_DEVICE)throw new un(a);this.name="TransportStatusError",this.message=a,this.stack=new Error(a).stack,this.statusCode=i,this.statusText=e}mt.prototype=new Error;var be=globalThis&&globalThis.__awaiter||function(i,e,r,s){function a(l){return l instanceof r?l:new r(function(h){h(l)})}return new(r||(r=Promise))(function(l,h){function u(m){try{E(s.next(m))}catch(y){h(y)}}function p(m){try{E(s.throw(m))}catch(y){h(y)}}function E(m){m.done?l(m.value):a(m.value).then(u,p)}E((s=s.apply(i,e||[])).next())})};class vt{constructor(){this.exchangeTimeout=3e4,this.unresponsiveTimeout=15e3,this.deviceModel=null,this._events=new an,this.send=(e,r,s,a,l=Buffer.alloc(0),h=[Se.OK])=>be(this,void 0,void 0,function*(){if(l.length>=256)throw new he("data.length exceed 256 bytes limit. Got: "+l.length,"DataLengthTooBig");const u=yield this.exchange(Buffer.concat([Buffer.from([e,r,s,a]),Buffer.from([l.length]),l])),p=u.readUInt16BE(u.length-2);if(!h.some(E=>E===p))throw new mt(p);return u}),this.exchangeAtomicImpl=e=>be(this,void 0,void 0,function*(){if(this.exchangeBusyPromise)throw new fn("An action was already pending on the Ledger device. Please deny or reconnect.");let r;const s=new Promise(h=>{r=h});this.exchangeBusyPromise=s;let a=!1;const l=setTimeout(()=>{a=!0,this.emit("unresponsive")},this.unresponsiveTimeout);try{const h=yield e();return a&&this.emit("responsive"),h}finally{clearTimeout(l),r&&r(),this.exchangeBusyPromise=null}}),this._appAPIlock=null}exchange(e){throw new Error("exchange not implemented")}exchangeBulk(e,r){let s=!1;const a=()=>{s=!0};return(()=>be(this,void 0,void 0,function*(){if(!s)for(const h of e){const u=yield this.exchange(h);if(s)return;const p=u.readUInt16BE(u.length-2);if(p!==Se.OK)throw new mt(p);r.next(u)}}))().then(()=>!s&&r.complete(),h=>!s&&r.error(h)),{unsubscribe:a}}setScrambleKey(e){}close(){return Promise.resolve()}on(e,r){this._events.on(e,r)}off(e,r){this._events.removeListener(e,r)}emit(e,...r){this._events.emit(e,...r)}setDebugMode(){console.warn("setDebugMode is deprecated. use @ledgerhq/logs instead. No logs are emitted in this anymore.")}setExchangeTimeout(e){this.exchangeTimeout=e}setExchangeUnresponsiveTimeout(e){this.unresponsiveTimeout=e}static create(e=3e3,r){return new Promise((s,a)=>{let l=!1;const h=this.listen({next:p=>{l=!0,h&&h.unsubscribe(),u&&clearTimeout(u),this.open(p.descriptor,e).then(s,a)},error:p=>{u&&clearTimeout(u),a(p)},complete:()=>{u&&clearTimeout(u),l||a(new he(this.ErrorMessage_NoDeviceFound,"NoDeviceFound"))}}),u=r?setTimeout(()=>{h.unsubscribe(),a(new he(this.ErrorMessage_ListenTimeout,"ListenTimeout"))},r):null})}decorateAppAPIMethods(e,r,s){for(const a of r)e[a]=this.decorateAppAPIMethod(a,e[a],e,s)}decorateAppAPIMethod(e,r,s,a){return(...l)=>be(this,void 0,void 0,function*(){const{_appAPIlock:h}=this;if(h)return Promise.reject(new he("Ledger Device is busy (lock "+h+")","TransportLocked"));try{return this._appAPIlock=e,this.setScrambleKey(a),yield r.apply(s,l)}finally{this._appAPIlock=null}})}}vt.ErrorMessage_ListenTimeout="No Ledger device found (timeout)";vt.ErrorMessage_NoDeviceFound="No Ledger device found";const Gt=5;function dn(i){const e=Buffer.alloc(2);return e.writeUInt16BE(i,0),e}const En={data:Buffer.alloc(0),dataLength:0,sequence:0},gn=(i,e)=>({makeBlocks(r){let s=Buffer.concat([dn(r.length),r]);const a=e-5,l=Math.ceil(s.length/a);s=Buffer.concat([s,Buffer.alloc(l*a-s.length+1).fill(0)]);const h=[];for(let u=0;ul&&(a=a.slice(0,l)),{data:a,dataLength:l,sequence:h}},getReducedResult(r){if(r&&r.dataLength===r.data.length)return r.data}});var yt={exports:{}};const mn="2.0.0",Tr=256,yn=Number.MAX_SAFE_INTEGER||9007199254740991,wn=16,In=Tr-6,xn=["major","premajor","minor","preminor","patch","prepatch","prerelease"];var We={MAX_LENGTH:Tr,MAX_SAFE_COMPONENT_LENGTH:wn,MAX_SAFE_BUILD_LENGTH:In,MAX_SAFE_INTEGER:yn,RELEASE_TYPES:xn,SEMVER_SPEC_VERSION:mn,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2};const vn=typeof process=="object"&&process.env&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...i)=>console.error("SEMVER",...i):()=>{};var Ke=vn;(function(i,e){const{MAX_SAFE_COMPONENT_LENGTH:r,MAX_SAFE_BUILD_LENGTH:s,MAX_LENGTH:a}=We,l=Ke;e=i.exports={};const h=e.re=[],u=e.safeRe=[],p=e.src=[],E=e.t={};let m=0;const y="[a-zA-Z0-9-]",N=[["\\s",1],["\\d",a],[y,s]],I=M=>{for(const[V,K]of N)M=M.split(`${V}*`).join(`${V}{0,${K}}`).split(`${V}+`).join(`${V}{1,${K}}`);return M},A=(M,V,K)=>{const k=I(V),Q=m++;l(M,Q,V),E[M]=Q,p[Q]=V,h[Q]=new RegExp(V,K?"g":void 0),u[Q]=new RegExp(k,K?"g":void 0)};A("NUMERICIDENTIFIER","0|[1-9]\\d*"),A("NUMERICIDENTIFIERLOOSE","\\d+"),A("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${y}*`),A("MAINVERSION",`(${p[E.NUMERICIDENTIFIER]})\\.(${p[E.NUMERICIDENTIFIER]})\\.(${p[E.NUMERICIDENTIFIER]})`),A("MAINVERSIONLOOSE",`(${p[E.NUMERICIDENTIFIERLOOSE]})\\.(${p[E.NUMERICIDENTIFIERLOOSE]})\\.(${p[E.NUMERICIDENTIFIERLOOSE]})`),A("PRERELEASEIDENTIFIER",`(?:${p[E.NUMERICIDENTIFIER]}|${p[E.NONNUMERICIDENTIFIER]})`),A("PRERELEASEIDENTIFIERLOOSE",`(?:${p[E.NUMERICIDENTIFIERLOOSE]}|${p[E.NONNUMERICIDENTIFIER]})`),A("PRERELEASE",`(?:-(${p[E.PRERELEASEIDENTIFIER]}(?:\\.${p[E.PRERELEASEIDENTIFIER]})*))`),A("PRERELEASELOOSE",`(?:-?(${p[E.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${p[E.PRERELEASEIDENTIFIERLOOSE]})*))`),A("BUILDIDENTIFIER",`${y}+`),A("BUILD",`(?:\\+(${p[E.BUILDIDENTIFIER]}(?:\\.${p[E.BUILDIDENTIFIER]})*))`),A("FULLPLAIN",`v?${p[E.MAINVERSION]}${p[E.PRERELEASE]}?${p[E.BUILD]}?`),A("FULL",`^${p[E.FULLPLAIN]}$`),A("LOOSEPLAIN",`[v=\\s]*${p[E.MAINVERSIONLOOSE]}${p[E.PRERELEASELOOSE]}?${p[E.BUILD]}?`),A("LOOSE",`^${p[E.LOOSEPLAIN]}$`),A("GTLT","((?:<|>)?=?)"),A("XRANGEIDENTIFIERLOOSE",`${p[E.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),A("XRANGEIDENTIFIER",`${p[E.NUMERICIDENTIFIER]}|x|X|\\*`),A("XRANGEPLAIN",`[v=\\s]*(${p[E.XRANGEIDENTIFIER]})(?:\\.(${p[E.XRANGEIDENTIFIER]})(?:\\.(${p[E.XRANGEIDENTIFIER]})(?:${p[E.PRERELEASE]})?${p[E.BUILD]}?)?)?`),A("XRANGEPLAINLOOSE",`[v=\\s]*(${p[E.XRANGEIDENTIFIERLOOSE]})(?:\\.(${p[E.XRANGEIDENTIFIERLOOSE]})(?:\\.(${p[E.XRANGEIDENTIFIERLOOSE]})(?:${p[E.PRERELEASELOOSE]})?${p[E.BUILD]}?)?)?`),A("XRANGE",`^${p[E.GTLT]}\\s*${p[E.XRANGEPLAIN]}$`),A("XRANGELOOSE",`^${p[E.GTLT]}\\s*${p[E.XRANGEPLAINLOOSE]}$`),A("COERCE",`(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?(?:$|[^\\d])`),A("COERCERTL",p[E.COERCE],!0),A("LONETILDE","(?:~>?)"),A("TILDETRIM",`(\\s*)${p[E.LONETILDE]}\\s+`,!0),e.tildeTrimReplace="$1~",A("TILDE",`^${p[E.LONETILDE]}${p[E.XRANGEPLAIN]}$`),A("TILDELOOSE",`^${p[E.LONETILDE]}${p[E.XRANGEPLAINLOOSE]}$`),A("LONECARET","(?:\\^)"),A("CARETTRIM",`(\\s*)${p[E.LONECARET]}\\s+`,!0),e.caretTrimReplace="$1^",A("CARET",`^${p[E.LONECARET]}${p[E.XRANGEPLAIN]}$`),A("CARETLOOSE",`^${p[E.LONECARET]}${p[E.XRANGEPLAINLOOSE]}$`),A("COMPARATORLOOSE",`^${p[E.GTLT]}\\s*(${p[E.LOOSEPLAIN]})$|^$`),A("COMPARATOR",`^${p[E.GTLT]}\\s*(${p[E.FULLPLAIN]})$|^$`),A("COMPARATORTRIM",`(\\s*)${p[E.GTLT]}\\s*(${p[E.LOOSEPLAIN]}|${p[E.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace="$1$2$3",A("HYPHENRANGE",`^\\s*(${p[E.XRANGEPLAIN]})\\s+-\\s+(${p[E.XRANGEPLAIN]})\\s*$`),A("HYPHENRANGELOOSE",`^\\s*(${p[E.XRANGEPLAINLOOSE]})\\s+-\\s+(${p[E.XRANGEPLAINLOOSE]})\\s*$`),A("STAR","(<|>)?=?\\s*\\*"),A("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),A("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")})(yt,yt.exports);var Be=yt.exports;const Rn=Object.freeze({loose:!0}),An=Object.freeze({}),Ln=i=>i?typeof i!="object"?Rn:i:An;var Rt=Ln;const jt=/^[0-9]+$/,Sr=(i,e)=>{const r=jt.test(i),s=jt.test(e);return r&&s&&(i=+i,e=+e),i===e?0:r&&!s?-1:s&&!r?1:iSr(e,i);var Nr={compareIdentifiers:Sr,rcompareIdentifiers:$n};const Fe=Ke,{MAX_LENGTH:kt,MAX_SAFE_INTEGER:De}=We,{safeRe:Vt,t:Xt}=Be,Tn=Rt,{compareIdentifiers:we}=Nr;let Sn=class te{constructor(e,r){if(r=Tn(r),e instanceof te){if(e.loose===!!r.loose&&e.includePrerelease===!!r.includePrerelease)return e;e=e.version}else if(typeof e!="string")throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`);if(e.length>kt)throw new TypeError(`version is longer than ${kt} characters`);Fe("SemVer",e,r),this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease;const s=e.trim().match(r.loose?Vt[Xt.LOOSE]:Vt[Xt.FULL]);if(!s)throw new TypeError(`Invalid Version: ${e}`);if(this.raw=e,this.major=+s[1],this.minor=+s[2],this.patch=+s[3],this.major>De||this.major<0)throw new TypeError("Invalid major version");if(this.minor>De||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>De||this.patch<0)throw new TypeError("Invalid patch version");s[4]?this.prerelease=s[4].split(".").map(a=>{if(/^[0-9]+$/.test(a)){const l=+a;if(l>=0&&l=0;)typeof this.prerelease[l]=="number"&&(this.prerelease[l]++,l=-2);if(l===-1){if(r===this.prerelease.join(".")&&s===!1)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(a)}}if(r){let l=[r,a];s===!1&&(l=[r]),we(this.prerelease[0],r)===0?isNaN(this.prerelease[1])&&(this.prerelease=l):this.prerelease=l}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}};var W=Sn;const Ht=W,Nn=(i,e,r=!1)=>{if(i instanceof Ht)return i;try{return new Ht(i,e)}catch(s){if(!r)return null;throw s}};var Re=Nn;const On=Re,Bn=(i,e)=>{const r=On(i,e);return r?r.version:null};var _n=Bn;const Un=Re,Cn=(i,e)=>{const r=Un(i.trim().replace(/^[=v]+/,""),e);return r?r.version:null};var bn=Cn;const qt=W,Fn=(i,e,r,s,a)=>{typeof r=="string"&&(a=s,s=r,r=void 0);try{return new qt(i instanceof qt?i.version:i,r).inc(e,s,a).version}catch{return null}};var Dn=Fn;const Wt=Re,Pn=(i,e)=>{const r=Wt(i,null,!0),s=Wt(e,null,!0),a=r.compare(s);if(a===0)return null;const l=a>0,h=l?r:s,u=l?s:r,p=!!h.prerelease.length;if(!!u.prerelease.length&&!p)return!u.patch&&!u.minor?"major":h.patch?"patch":h.minor?"minor":"major";const m=p?"pre":"";return r.major!==s.major?m+"major":r.minor!==s.minor?m+"minor":r.patch!==s.patch?m+"patch":"prerelease"};var Mn=Pn;const Gn=W,jn=(i,e)=>new Gn(i,e).major;var kn=jn;const Vn=W,Xn=(i,e)=>new Vn(i,e).minor;var Hn=Xn;const qn=W,Wn=(i,e)=>new qn(i,e).patch;var Kn=Wn;const Yn=Re,zn=(i,e)=>{const r=Yn(i,e);return r&&r.prerelease.length?r.prerelease:null};var Jn=zn;const Kt=W,Zn=(i,e,r)=>new Kt(i,r).compare(new Kt(e,r));var J=Zn;const Qn=J,ei=(i,e,r)=>Qn(e,i,r);var ti=ei;const ri=J,ni=(i,e)=>ri(i,e,!0);var ii=ni;const Yt=W,si=(i,e,r)=>{const s=new Yt(i,r),a=new Yt(e,r);return s.compare(a)||s.compareBuild(a)};var At=si;const oi=At,ai=(i,e)=>i.sort((r,s)=>oi(r,s,e));var ci=ai;const ui=At,li=(i,e)=>i.sort((r,s)=>ui(s,r,e));var hi=li;const fi=J,pi=(i,e,r)=>fi(i,e,r)>0;var Ye=pi;const di=J,Ei=(i,e,r)=>di(i,e,r)<0;var Lt=Ei;const gi=J,mi=(i,e,r)=>gi(i,e,r)===0;var Or=mi;const yi=J,wi=(i,e,r)=>yi(i,e,r)!==0;var Br=wi;const Ii=J,xi=(i,e,r)=>Ii(i,e,r)>=0;var $t=xi;const vi=J,Ri=(i,e,r)=>vi(i,e,r)<=0;var Tt=Ri;const Ai=Or,Li=Br,$i=Ye,Ti=$t,Si=Lt,Ni=Tt,Oi=(i,e,r,s)=>{switch(e){case"===":return typeof i=="object"&&(i=i.version),typeof r=="object"&&(r=r.version),i===r;case"!==":return typeof i=="object"&&(i=i.version),typeof r=="object"&&(r=r.version),i!==r;case"":case"=":case"==":return Ai(i,r,s);case"!=":return Li(i,r,s);case">":return $i(i,r,s);case">=":return Ti(i,r,s);case"<":return Si(i,r,s);case"<=":return Ni(i,r,s);default:throw new TypeError(`Invalid operator: ${e}`)}};var _r=Oi;const Bi=W,_i=Re,{safeRe:Pe,t:Me}=Be,Ui=(i,e)=>{if(i instanceof Bi)return i;if(typeof i=="number"&&(i=String(i)),typeof i!="string")return null;e=e||{};let r=null;if(!e.rtl)r=i.match(Pe[Me.COERCE]);else{let s;for(;(s=Pe[Me.COERCERTL].exec(i))&&(!r||r.index+r[0].length!==i.length);)(!r||s.index+s[0].length!==r.index+r[0].length)&&(r=s),Pe[Me.COERCERTL].lastIndex=s.index+s[1].length+s[2].length;Pe[Me.COERCERTL].lastIndex=-1}return r===null?null:_i(`${r[2]}.${r[3]||"0"}.${r[4]||"0"}`,e)};var Ci=Ui,ut,zt;function bi(){return zt||(zt=1,ut=function(i){i.prototype[Symbol.iterator]=function*(){for(let e=this.head;e;e=e.next)yield e.value}}),ut}var Fi=_;_.Node=Ee;_.create=_;function _(i){var e=this;if(e instanceof _||(e=new _),e.tail=null,e.head=null,e.length=0,i&&typeof i.forEach=="function")i.forEach(function(a){e.push(a)});else if(arguments.length>0)for(var r=0,s=arguments.length;r1)r=e;else if(this.head)s=this.head.next,r=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var a=0;s!==null;a++)r=i(r,s.value,a),s=s.next;return r};_.prototype.reduceReverse=function(i,e){var r,s=this.tail;if(arguments.length>1)r=e;else if(this.tail)s=this.tail.prev,r=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(var a=this.length-1;s!==null;a--)r=i(r,s.value,a),s=s.prev;return r};_.prototype.toArray=function(){for(var i=new Array(this.length),e=0,r=this.head;r!==null;e++)i[e]=r.value,r=r.next;return i};_.prototype.toArrayReverse=function(){for(var i=new Array(this.length),e=0,r=this.tail;r!==null;e++)i[e]=r.value,r=r.prev;return i};_.prototype.slice=function(i,e){e=e||this.length,e<0&&(e+=this.length),i=i||0,i<0&&(i+=this.length);var r=new _;if(ethis.length&&(e=this.length);for(var s=0,a=this.head;a!==null&&sthis.length&&(e=this.length);for(var s=this.length,a=this.tail;a!==null&&s>e;s--)a=a.prev;for(;a!==null&&s>i;s--,a=a.prev)r.push(a.value);return r};_.prototype.splice=function(i,e,...r){i>this.length&&(i=this.length-1),i<0&&(i=this.length+i);for(var s=0,a=this.head;a!==null&&s1;class ji{constructor(e){if(typeof e=="number"&&(e={max:e}),e||(e={}),e.max&&(typeof e.max!="number"||e.max<0))throw new TypeError("max must be a non-negative number");this[pe]=e.max||1/0;const r=e.length||lt;if(this[Ie]=typeof r!="function"?lt:r,this[Ne]=e.stale||!1,e.maxAge&&typeof e.maxAge!="number")throw new TypeError("maxAge must be a number");this[de]=e.maxAge||0,this[se]=e.dispose,this[Jt]=e.noDisposeOnSet||!1,this[Ur]=e.updateAgeOnGet||!1,this.reset()}set max(e){if(typeof e!="number"||e<0)throw new TypeError("max must be a non-negative number");this[pe]=e||1/0,Le(this)}get max(){return this[pe]}set allowStale(e){this[Ne]=!!e}get allowStale(){return this[Ne]}set maxAge(e){if(typeof e!="number")throw new TypeError("maxAge must be a non-negative number");this[de]=e,Le(this)}get maxAge(){return this[de]}set lengthCalculator(e){typeof e!="function"&&(e=lt),e!==this[Ie]&&(this[Ie]=e,this[oe]=0,this[X].forEach(r=>{r.length=this[Ie](r.value,r.key),this[oe]+=r.length})),Le(this)}get lengthCalculator(){return this[Ie]}get length(){return this[oe]}get itemCount(){return this[X].length}rforEach(e,r){r=r||this;for(let s=this[X].tail;s!==null;){const a=s.prev;Zt(this,e,s,r),s=a}}forEach(e,r){r=r||this;for(let s=this[X].head;s!==null;){const a=s.next;Zt(this,e,s,r),s=a}}keys(){return this[X].toArray().map(e=>e.key)}values(){return this[X].toArray().map(e=>e.value)}reset(){this[se]&&this[X]&&this[X].length&&this[X].forEach(e=>this[se](e.key,e.value)),this[z]=new Map,this[X]=new Gi,this[oe]=0}dump(){return this[X].map(e=>Ve(this,e)?!1:{k:e.key,v:e.value,e:e.now+(e.maxAge||0)}).toArray().filter(e=>e)}dumpLru(){return this[X]}set(e,r,s){if(s=s||this[de],s&&typeof s!="number")throw new TypeError("maxAge must be a number");const a=s?Date.now():0,l=this[Ie](r,e);if(this[z].has(e)){if(l>this[pe])return ve(this,this[z].get(e)),!1;const p=this[z].get(e).value;return this[se]&&(this[Jt]||this[se](e,p.value)),p.now=a,p.maxAge=s,p.value=r,this[oe]+=l-p.length,p.length=l,this.get(e),Le(this),!0}const h=new ki(e,r,l,a,s);return h.length>this[pe]?(this[se]&&this[se](e,r),!1):(this[oe]+=h.length,this[X].unshift(h),this[z].set(e,this[X].head),Le(this),!0)}has(e){if(!this[z].has(e))return!1;const r=this[z].get(e).value;return!Ve(this,r)}get(e){return ht(this,e,!0)}peek(e){return ht(this,e,!1)}pop(){const e=this[X].tail;return e?(ve(this,e),e.value):null}del(e){ve(this,this[z].get(e))}load(e){this.reset();const r=Date.now();for(let s=e.length-1;s>=0;s--){const a=e[s],l=a.e||0;if(l===0)this.set(a.k,a.v);else{const h=l-r;h>0&&this.set(a.k,a.v,h)}}}prune(){this[z].forEach((e,r)=>ht(this,r,!1))}}const ht=(i,e,r)=>{const s=i[z].get(e);if(s){const a=s.value;if(Ve(i,a)){if(ve(i,s),!i[Ne])return}else r&&(i[Ur]&&(s.value.now=Date.now()),i[X].unshiftNode(s));return a.value}},Ve=(i,e)=>{if(!e||!e.maxAge&&!i[de])return!1;const r=Date.now()-e.now;return e.maxAge?r>e.maxAge:i[de]&&r>i[de]},Le=i=>{if(i[oe]>i[pe])for(let e=i[X].tail;i[oe]>i[pe]&&e!==null;){const r=e.prev;ve(i,e),e=r}},ve=(i,e)=>{if(e){const r=e.value;i[se]&&i[se](r.key,r.value),i[oe]-=r.length,i[z].delete(r.key),i[X].removeNode(e)}};class ki{constructor(e,r,s,a,l){this.key=e,this.value=r,this.length=s,this.now=a,this.maxAge=l||0}}const Zt=(i,e,r,s)=>{let a=r.value;Ve(i,a)&&(ve(i,r),i[Ne]||(a=void 0)),a&&e.call(s,a.value,a.key,i)};var Vi=ji,ft,Qt;function Z(){if(Qt)return ft;Qt=1;class i{constructor(w,T){if(T=s(T),w instanceof i)return w.loose===!!T.loose&&w.includePrerelease===!!T.includePrerelease?w:new i(w.raw,T);if(w instanceof a)return this.raw=w.value,this.set=[[w]],this.format(),this;if(this.options=T,this.loose=!!T.loose,this.includePrerelease=!!T.includePrerelease,this.raw=w.trim().split(/\s+/).join(" "),this.set=this.raw.split("||").map(L=>this.parseRange(L.trim())).filter(L=>L.length),!this.set.length)throw new TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){const L=this.set[0];if(this.set=this.set.filter($=>!A($[0])),this.set.length===0)this.set=[L];else if(this.set.length>1){for(const $ of this.set)if($.length===1&&M($[0])){this.set=[$];break}}}this.format()}format(){return this.range=this.set.map(w=>w.join(" ").trim()).join("||").trim(),this.range}toString(){return this.range}parseRange(w){const L=((this.options.includePrerelease&&N)|(this.options.loose&&I))+":"+w,$=r.get(L);if($)return $;const v=this.options.loose,S=v?u[p.HYPHENRANGELOOSE]:u[p.HYPHENRANGE];w=w.replace(S,rt(this.options.includePrerelease)),l("hyphen replace",w),w=w.replace(u[p.COMPARATORTRIM],E),l("comparator trim",w),w=w.replace(u[p.TILDETRIM],m),l("tilde trim",w),w=w.replace(u[p.CARETTRIM],y),l("caret trim",w);let U=w.split(" ").map(D=>K(D,this.options)).join(" ").split(/\s+/).map(D=>tt(D,this.options));v&&(U=U.filter(D=>(l("loose invalid filter",D,this.options),!!D.match(u[p.COMPARATORLOOSE])))),l("range list",U);const R=new Map,O=U.map(D=>new a(D,this.options));for(const D of O){if(A(D))return[D];R.set(D.value,D)}R.size>1&&R.has("")&&R.delete("");const q=[...R.values()];return r.set(L,q),q}intersects(w,T){if(!(w instanceof i))throw new TypeError("a Range is required");return this.set.some(L=>V(L,T)&&w.set.some($=>V($,T)&&L.every(v=>$.every(S=>v.intersects(S,T)))))}test(w){if(!w)return!1;if(typeof w=="string")try{w=new h(w,this.options)}catch{return!1}for(let T=0;Tx.value==="<0.0.0-0",M=x=>x.value==="",V=(x,w)=>{let T=!0;const L=x.slice();let $=L.pop();for(;T&&L.length;)T=L.every(v=>$.intersects(v,w)),$=L.pop();return T},K=(x,w)=>(l("comp",x,w),x=ne(x,w),l("caret",x),x=Q(x,w),l("tildes",x),x=Ue(x,w),l("xrange",x),x=et(x,w),l("stars",x),x),k=x=>!x||x.toLowerCase()==="x"||x==="*",Q=(x,w)=>x.trim().split(/\s+/).map(T=>Ze(T,w)).join(" "),Ze=(x,w)=>{const T=w.loose?u[p.TILDELOOSE]:u[p.TILDE];return x.replace(T,(L,$,v,S,U)=>{l("tilde",x,L,$,v,S,U);let R;return k($)?R="":k(v)?R=`>=${$}.0.0 <${+$+1}.0.0-0`:k(S)?R=`>=${$}.${v}.0 <${$}.${+v+1}.0-0`:U?(l("replaceTilde pr",U),R=`>=${$}.${v}.${S}-${U} <${$}.${+v+1}.0-0`):R=`>=${$}.${v}.${S} <${$}.${+v+1}.0-0`,l("tilde return",R),R})},ne=(x,w)=>x.trim().split(/\s+/).map(T=>_e(T,w)).join(" "),_e=(x,w)=>{l("caret",x,w);const T=w.loose?u[p.CARETLOOSE]:u[p.CARET],L=w.includePrerelease?"-0":"";return x.replace(T,($,v,S,U,R)=>{l("caret",x,$,v,S,U,R);let O;return k(v)?O="":k(S)?O=`>=${v}.0.0${L} <${+v+1}.0.0-0`:k(U)?v==="0"?O=`>=${v}.${S}.0${L} <${v}.${+S+1}.0-0`:O=`>=${v}.${S}.0${L} <${+v+1}.0.0-0`:R?(l("replaceCaret pr",R),v==="0"?S==="0"?O=`>=${v}.${S}.${U}-${R} <${v}.${S}.${+U+1}-0`:O=`>=${v}.${S}.${U}-${R} <${v}.${+S+1}.0-0`:O=`>=${v}.${S}.${U}-${R} <${+v+1}.0.0-0`):(l("no pr"),v==="0"?S==="0"?O=`>=${v}.${S}.${U}${L} <${v}.${S}.${+U+1}-0`:O=`>=${v}.${S}.${U}${L} <${v}.${+S+1}.0-0`:O=`>=${v}.${S}.${U} <${+v+1}.0.0-0`),l("caret return",O),O})},Ue=(x,w)=>(l("replaceXRanges",x,w),x.split(/\s+/).map(T=>Qe(T,w)).join(" ")),Qe=(x,w)=>{x=x.trim();const T=w.loose?u[p.XRANGELOOSE]:u[p.XRANGE];return x.replace(T,(L,$,v,S,U,R)=>{l("xRange",x,L,$,v,S,U,R);const O=k(v),q=O||k(S),D=q||k(U),ce=D;return $==="="&&ce&&($=""),R=w.includePrerelease?"-0":"",O?$===">"||$==="<"?L="<0.0.0-0":L="*":$&&ce?(q&&(S=0),U=0,$===">"?($=">=",q?(v=+v+1,S=0,U=0):(S=+S+1,U=0)):$==="<="&&($="<",q?v=+v+1:S=+S+1),$==="<"&&(R="-0"),L=`${$+v}.${S}.${U}${R}`):q?L=`>=${v}.0.0${R} <${+v+1}.0.0-0`:D&&(L=`>=${v}.${S}.0${R} <${v}.${+S+1}.0-0`),l("xRange return",L),L})},et=(x,w)=>(l("replaceStars",x,w),x.trim().replace(u[p.STAR],"")),tt=(x,w)=>(l("replaceGTE0",x,w),x.trim().replace(u[w.includePrerelease?p.GTE0PRE:p.GTE0],"")),rt=x=>(w,T,L,$,v,S,U,R,O,q,D,ce,it)=>(k(L)?T="":k($)?T=`>=${L}.0.0${x?"-0":""}`:k(v)?T=`>=${L}.${$}.0${x?"-0":""}`:S?T=`>=${T}`:T=`>=${T}${x?"-0":""}`,k(O)?R="":k(q)?R=`<${+O+1}.0.0-0`:k(D)?R=`<${O}.${+q+1}.0-0`:ce?R=`<=${O}.${q}.${D}-${ce}`:x?R=`<${O}.${q}.${+D+1}-0`:R=`<=${R}`,`${T} ${R}`.trim()),nt=(x,w,T)=>{for(let L=0;L0){const $=x[L].semver;if($.major===w.major&&$.minor===w.minor&&$.patch===w.patch)return!0}return!1}return!0};return ft}var pt,er;function ze(){if(er)return pt;er=1;const i=Symbol("SemVer ANY");class e{static get ANY(){return i}constructor(m,y){if(y=r(y),m instanceof e){if(m.loose===!!y.loose)return m;m=m.value}m=m.trim().split(/\s+/).join(" "),h("comparator",m,y),this.options=y,this.loose=!!y.loose,this.parse(m),this.semver===i?this.value="":this.value=this.operator+this.semver.version,h("comp",this)}parse(m){const y=this.options.loose?s[a.COMPARATORLOOSE]:s[a.COMPARATOR],N=m.match(y);if(!N)throw new TypeError(`Invalid comparator: ${m}`);this.operator=N[1]!==void 0?N[1]:"",this.operator==="="&&(this.operator=""),N[2]?this.semver=new u(N[2],this.options.loose):this.semver=i}toString(){return this.value}test(m){if(h("Comparator.test",m,this.options.loose),this.semver===i||m===i)return!0;if(typeof m=="string")try{m=new u(m,this.options)}catch{return!1}return l(m,this.operator,this.semver,this.options)}intersects(m,y){if(!(m instanceof e))throw new TypeError("a Comparator is required");return this.operator===""?this.value===""?!0:new p(m.value,y).test(this.value):m.operator===""?m.value===""?!0:new p(this.value,y).test(m.semver):(y=r(y),y.includePrerelease&&(this.value==="<0.0.0-0"||m.value==="<0.0.0-0")||!y.includePrerelease&&(this.value.startsWith("<0.0.0")||m.value.startsWith("<0.0.0"))?!1:!!(this.operator.startsWith(">")&&m.operator.startsWith(">")||this.operator.startsWith("<")&&m.operator.startsWith("<")||this.semver.version===m.semver.version&&this.operator.includes("=")&&m.operator.includes("=")||l(this.semver,"<",m.semver,y)&&this.operator.startsWith(">")&&m.operator.startsWith("<")||l(this.semver,">",m.semver,y)&&this.operator.startsWith("<")&&m.operator.startsWith(">")))}}pt=e;const r=Rt,{safeRe:s,t:a}=Be,l=_r,h=Ke,u=W,p=Z();return pt}const Xi=Z(),Hi=(i,e,r)=>{try{e=new Xi(e,r)}catch{return!1}return e.test(i)};var Je=Hi;const qi=Z(),Wi=(i,e)=>new qi(i,e).set.map(r=>r.map(s=>s.value).join(" ").trim().split(" "));var Ki=Wi;const Yi=W,zi=Z(),Ji=(i,e,r)=>{let s=null,a=null,l=null;try{l=new zi(e,r)}catch{return null}return i.forEach(h=>{l.test(h)&&(!s||a.compare(h)===-1)&&(s=h,a=new Yi(s,r))}),s};var Zi=Ji;const Qi=W,es=Z(),ts=(i,e,r)=>{let s=null,a=null,l=null;try{l=new es(e,r)}catch{return null}return i.forEach(h=>{l.test(h)&&(!s||a.compare(h)===1)&&(s=h,a=new Qi(s,r))}),s};var rs=ts;const dt=W,ns=Z(),tr=Ye,is=(i,e)=>{i=new ns(i,e);let r=new dt("0.0.0");if(i.test(r)||(r=new dt("0.0.0-0"),i.test(r)))return r;r=null;for(let s=0;s{const u=new dt(h.semver.version);switch(h.operator){case">":u.prerelease.length===0?u.patch++:u.prerelease.push(0),u.raw=u.format();case"":case">=":(!l||tr(u,l))&&(l=u);break;case"<":case"<=":break;default:throw new Error(`Unexpected operation: ${h.operator}`)}}),l&&(!r||tr(r,l))&&(r=l)}return r&&i.test(r)?r:null};var ss=is;const os=Z(),as=(i,e)=>{try{return new os(i,e).range||"*"}catch{return null}};var cs=as;const us=W,Cr=ze(),{ANY:ls}=Cr,hs=Z(),fs=Je,rr=Ye,nr=Lt,ps=Tt,ds=$t,Es=(i,e,r,s)=>{i=new us(i,s),e=new hs(e,s);let a,l,h,u,p;switch(r){case">":a=rr,l=ps,h=nr,u=">",p=">=";break;case"<":a=nr,l=ds,h=rr,u="<",p="<=";break;default:throw new TypeError('Must provide a hilo val of "<" or ">"')}if(fs(i,e,s))return!1;for(let E=0;E{I.semver===ls&&(I=new Cr(">=0.0.0")),y=y||I,N=N||I,a(I.semver,y.semver,s)?y=I:h(I.semver,N.semver,s)&&(N=I)}),y.operator===u||y.operator===p||(!N.operator||N.operator===u)&&l(i,N.semver))return!1;if(N.operator===p&&h(i,N.semver))return!1}return!0};var St=Es;const gs=St,ms=(i,e,r)=>gs(i,e,">",r);var ys=ms;const ws=St,Is=(i,e,r)=>ws(i,e,"<",r);var xs=Is;const ir=Z(),vs=(i,e,r)=>(i=new ir(i,r),e=new ir(e,r),i.intersects(e,r));var Rs=vs;const As=Je,Ls=J;var $s=(i,e,r)=>{const s=[];let a=null,l=null;const h=i.sort((m,y)=>Ls(m,y,r));for(const m of h)As(m,e,r)?(l=m,a||(a=m)):(l&&s.push([a,l]),l=null,a=null);a&&s.push([a,null]);const u=[];for(const[m,y]of s)m===y?u.push(m):!y&&m===h[0]?u.push("*"):y?m===h[0]?u.push(`<=${y}`):u.push(`${m} - ${y}`):u.push(`>=${m}`);const p=u.join(" || "),E=typeof e.raw=="string"?e.raw:String(e);return p.length{if(i===e)return!0;i=new sr(i,r),e=new sr(e,r);let s=!1;e:for(const a of i.set){for(const l of e.set){const h=Ns(a,l,r);if(s=s||h!==null,h)continue e}if(s)return!1}return!0},Ss=[new Nt(">=0.0.0-0")],or=[new Nt(">=0.0.0")],Ns=(i,e,r)=>{if(i===e)return!0;if(i.length===1&&i[0].semver===Et){if(e.length===1&&e[0].semver===Et)return!0;r.includePrerelease?i=Ss:i=or}if(e.length===1&&e[0].semver===Et){if(r.includePrerelease)return!0;e=or}const s=new Set;let a,l;for(const I of i)I.operator===">"||I.operator===">="?a=ar(a,I,r):I.operator==="<"||I.operator==="<="?l=cr(l,I,r):s.add(I.semver);if(s.size>1)return null;let h;if(a&&l){if(h=Ot(a.semver,l.semver,r),h>0)return null;if(h===0&&(a.operator!==">="||l.operator!=="<="))return null}for(const I of s){if(a&&!$e(I,String(a),r)||l&&!$e(I,String(l),r))return null;for(const A of e)if(!$e(I,String(A),r))return!1;return!0}let u,p,E,m,y=l&&!r.includePrerelease&&l.semver.prerelease.length?l.semver:!1,N=a&&!r.includePrerelease&&a.semver.prerelease.length?a.semver:!1;y&&y.prerelease.length===1&&l.operator==="<"&&y.prerelease[0]===0&&(y=!1);for(const I of e){if(m=m||I.operator===">"||I.operator===">=",E=E||I.operator==="<"||I.operator==="<=",a){if(N&&I.semver.prerelease&&I.semver.prerelease.length&&I.semver.major===N.major&&I.semver.minor===N.minor&&I.semver.patch===N.patch&&(N=!1),I.operator===">"||I.operator===">="){if(u=ar(a,I,r),u===I&&u!==a)return!1}else if(a.operator===">="&&!$e(a.semver,String(I),r))return!1}if(l){if(y&&I.semver.prerelease&&I.semver.prerelease.length&&I.semver.major===y.major&&I.semver.minor===y.minor&&I.semver.patch===y.patch&&(y=!1),I.operator==="<"||I.operator==="<="){if(p=cr(l,I,r),p===I&&p!==l)return!1}else if(l.operator==="<="&&!$e(l.semver,String(I),r))return!1}if(!I.operator&&(l||a)&&h!==0)return!1}return!(a&&E&&!l&&h!==0||l&&m&&!a&&h!==0||N||y)},ar=(i,e,r)=>{if(!i)return e;const s=Ot(i.semver,e.semver,r);return s>0?i:s<0||e.operator===">"&&i.operator===">="?e:i},cr=(i,e,r)=>{if(!i)return e;const s=Ot(i.semver,e.semver,r);return s<0?i:s>0||e.operator==="<"&&i.operator==="<="?e:i};var Os=Ts;const gt=Be,ur=We,Bs=W,lr=Nr,_s=Re,Us=_n,Cs=bn,bs=Dn,Fs=Mn,Ds=kn,Ps=Hn,Ms=Kn,Gs=Jn,js=J,ks=ti,Vs=ii,Xs=At,Hs=ci,qs=hi,Ws=Ye,Ks=Lt,Ys=Or,zs=Br,Js=$t,Zs=Tt,Qs=_r,eo=Ci,to=ze(),ro=Z(),no=Je,io=Ki,so=Zi,oo=rs,ao=ss,co=cs,uo=St,lo=ys,ho=xs,fo=Rs,po=$s,Eo=Os;var go={parse:_s,valid:Us,clean:Cs,inc:bs,diff:Fs,major:Ds,minor:Ps,patch:Ms,prerelease:Gs,compare:js,rcompare:ks,compareLoose:Vs,compareBuild:Xs,sort:Hs,rsort:qs,gt:Ws,lt:Ks,eq:Ys,neq:zs,gte:Js,lte:Zs,cmp:Qs,coerce:eo,Comparator:to,Range:ro,satisfies:no,toComparators:io,maxSatisfying:so,minSatisfying:oo,minVersion:ao,validRange:co,outside:uo,gtr:lo,ltr:ho,intersects:fo,simplifyRange:po,subset:Eo,SemVer:Bs,re:gt.re,src:gt.src,tokens:gt.t,SEMVER_SPEC_VERSION:ur.SEMVER_SPEC_VERSION,RELEASE_TYPES:ur.RELEASE_TYPES,compareIdentifiers:lr.compareIdentifiers,rcompareIdentifiers:lr.rcompareIdentifiers};const hr=mr(go);var H;(function(i){i.blue="blue",i.nanoS="nanoS",i.nanoSP="nanoSP",i.nanoX="nanoX",i.stax="stax"})(H||(H={}));const wt={[H.blue]:{id:H.blue,productName:"Ledger Blue",productIdMM:0,legacyUsbProductId:0,usbOnly:!0,memorySize:480*1024,masks:[822083584,822149120],getBlockSize:i=>4*1024},[H.nanoS]:{id:H.nanoS,productName:"Ledger Nano S",productIdMM:16,legacyUsbProductId:1,usbOnly:!0,memorySize:320*1024,masks:[823132160],getBlockSize:i=>{var e;return hr.lt((e=hr.coerce(i))!==null&&e!==void 0?e:"","2.0.0")?4*1024:2*1024}},[H.nanoSP]:{id:H.nanoSP,productName:"Ledger Nano S Plus",productIdMM:80,legacyUsbProductId:5,usbOnly:!0,memorySize:1536*1024,masks:[856686592],getBlockSize:i=>32},[H.nanoX]:{id:H.nanoX,productName:"Ledger Nano X",productIdMM:64,legacyUsbProductId:4,usbOnly:!1,memorySize:2*1024*1024,masks:[855638016],getBlockSize:i=>4*1024,bluetoothSpec:[{serviceUuid:"13d63400-2c97-0004-0000-4c6564676572",notifyUuid:"13d63400-2c97-0004-0001-4c6564676572",writeUuid:"13d63400-2c97-0004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-0004-0003-4c6564676572"}]},[H.stax]:{id:H.stax,productName:"Ledger Stax",productIdMM:96,legacyUsbProductId:6,usbOnly:!1,memorySize:1536*1024,masks:[857735168],getBlockSize:i=>32,bluetoothSpec:[{serviceUuid:"13d63400-2c97-6004-0000-4c6564676572",notifyUuid:"13d63400-2c97-6004-0001-4c6564676572",writeUuid:"13d63400-2c97-6004-0002-4c6564676572",writeCmdUuid:"13d63400-2c97-6004-0003-4c6564676572"}]}};H.blue,H.nanoS,H.nanoSP,H.nanoX,H.stax;const fr=Object.values(wt),br=11415,Fr=i=>{const e=fr.find(a=>a.legacyUsbProductId===i);if(e)return e;const r=i>>8;return fr.find(a=>a.productIdMM===r)},mo=[],pr={};for(const i in wt){const e=wt[i],{bluetoothSpec:r}=e;if(r)for(let s=0;sPromise.resolve(!!(window.navigator&&window.navigator.hid)),Xe=()=>{const{hid:i}=navigator;if(!i)throw new he("navigator.hid is not supported","HIDNotSupported");return i};function Dr(){return ae(this,void 0,void 0,function*(){const i=yield Xe().requestDevice({filters:xo});return Array.isArray(i)?i:[i]})}function Bt(){return ae(this,void 0,void 0,function*(){return(yield Xe().getDevices()).filter(e=>e.vendorId===br)})}function Ro(){return ae(this,void 0,void 0,function*(){const i=yield Bt();return i.length>0?i[0]:(yield Dr())[0]})}class fe extends vt{constructor(e){super(),this.channel=Math.floor(Math.random()*65535),this.packetSize=64,this.inputs=[],this.read=()=>this.inputs.length?Promise.resolve(this.inputs.shift()):new Promise(r=>{this.inputCallback=r}),this.onInputReport=r=>{const s=Buffer.from(r.data.buffer);this.inputCallback?(this.inputCallback(s),this.inputCallback=null):this.inputs.push(s)},this._disconnectEmitted=!1,this._emitDisconnect=r=>{this._disconnectEmitted||(this._disconnectEmitted=!0,this.emit("disconnect",r))},this.exchange=r=>ae(this,void 0,void 0,function*(){return yield this.exchangeAtomicImpl(()=>ae(this,void 0,void 0,function*(){const{channel:a,packetSize:l}=this;dr("apdu","=> "+r.toString("hex"));const h=gn(a,l),u=h.makeBlocks(r);for(let m=0;m{throw a&&a.message&&a.message.includes("write")?(this._emitDisconnect(a),new hn(a.message)):a})}),this.device=e,this.deviceModel=typeof e.productId=="number"?Fr(e.productId):void 0,e.addEventListener("inputreport",this.onInputReport)}static request(){return ae(this,void 0,void 0,function*(){const[e]=yield Dr();return fe.open(e)})}static openConnected(){return ae(this,void 0,void 0,function*(){const e=yield Bt();return e.length===0?null:fe.open(e[0])})}static open(e){return ae(this,void 0,void 0,function*(){yield e.open();const r=new fe(e),s=a=>{e===a.device&&(Xe().removeEventListener("disconnect",s),r._emitDisconnect(new ln))};return Xe().addEventListener("disconnect",s),r})}close(){return ae(this,void 0,void 0,function*(){yield this.exchangeBusyPromise,this.device.removeEventListener("inputreport",this.onInputReport),yield this.device.close()})}setScrambleKey(){}}fe.isSupported=vo;fe.list=Bt;fe.listen=i=>{let e=!1;Ro().then(s=>{if(!s)i.error(new Pt("Access denied to use Ledger device"));else if(!e){const a=typeof s.productId=="number"?Fr(s.productId):void 0;i.next({type:"add",descriptor:s,deviceModel:a}),i.complete()}},s=>{i.error(new Pt(s.message))});function r(){e=!0}return{unsubscribe:r}};const Te=224,Ao=1,Lo=2,$o=3,To=4,So=5,ie=36864,Ge=27013,Er=27750,je=27904,No=1,Oo=2,Bo=4,gr=8;class _o{constructor(e,r="l0v"){this.transport=void 0,this.transport=e,e.decorateAppAPIMethods(this,["getConfiguration","getPublicKey","getAddress","signMessage","signTransaction"],r)}getConfiguration(){return this.transport.send(Te,Ao,0,0).then(e=>{if(P.Buffer.from(e.slice(e.length-2)).readUInt16BE(0)===ie)return{configuration:e.slice()};throw new Error("Failed to get configuration")})}getPublicKey({account:e},r=!1){const s=P.Buffer.alloc(4);return s.writeUInt32BE(e),this.transport.send(Te,Lo,r?1:0,0,s,[ie]).then(a=>{if(P.Buffer.from(a.slice(a.length-2)).readUInt16BE(0)===ie)return{publicKey:a.slice(1,33)};throw new Error("Failed to get public key")})}getAddress({account:e,contract:r}){const s=P.Buffer.alloc(5);return s.writeUInt32BE(e,0),s.writeUint8(r,4),this.transport.send(Te,To,1,0,s,[ie]).then(a=>{if(P.Buffer.from(a.slice(a.length-2)).readUInt16BE(0)===ie)return{address:a.slice(1,33)};throw new Error("Failed to get address")})}signMessage({account:e,message:r,chainId:s}){let a=0;const l=[],h=P.Buffer.alloc(4);if(h.writeUInt32BE(e,0),typeof s=="number"){const E=P.Buffer.alloc(4);E.writeUInt32BE(s,0),a|=gr,l.push(E)}const u=[h,P.Buffer.alloc(1,a),...l,r],p=P.Buffer.concat(u);return this.transport.send(Te,$o,1,0,p,[ie,Ge,Er,je]).then(E=>{const m=P.Buffer.from(E.slice(E.length-2)).readUInt16BE(0);if(m===ie)return{signature:E.slice(1,E.length-2)};throw m===Ge?new Error("Transaction approval request was rejected"):m===je?new Error("Message signing is not supported"):new Error("Message signing not allowed. Have you enabled it in the app settings?")})}signTransaction({account:e,originalWallet:r,wallet:s,message:a,chainId:l,context:h}){let u=0;const p=[],E=P.Buffer.alloc(5);E.writeUInt32BE(e,0),E.writeUint8(r,4);const m=P.Buffer.alloc(1);m.writeUInt8(h.decimals,0);let y=h.asset;h.asset.includes("-LP-")?y="LP":h.asset.length>8&&(y=h.asset.substring(0,6)+"..");const N=P.Buffer.from(y,"utf-8");if(typeof s=="number"&&s!==r&&(u|=No,p.push(P.Buffer.alloc(1,s))),typeof h.workchainId=="number"&&(u|=Oo,p.push(P.Buffer.alloc(1,h.workchainId))),typeof h.address=="string"){if(h.address.length!==64)throw new Error("Invalid address format");u|=Bo,p.push(P.Buffer.from(h.address,"hex"))}if(typeof l=="number"){const M=P.Buffer.alloc(4);M.writeUInt32BE(l,0),u|=gr,p.push(M)}const I=[E,m,P.Buffer.alloc(1,N.length),N,P.Buffer.alloc(1,u),...p,a.subarray(4)],A=P.Buffer.concat(I);return this.transport.send(Te,So,1,0,A,[ie,Ge,Er,je]).then(M=>{const V=P.Buffer.from(M.slice(M.length-2)).readUInt16BE(0);if(V===ie)return{signature:M.slice(1,M.length-2)};throw V===Ge?new Error("Transaction approval request was rejected"):V===je?new Error("Message signing is not supported"):new Error("Message signing not allowed. Have you enabled it in the app settings?")})}}class Uo{constructor(){this.addEventListeners()}addEventListeners(){window.addEventListener("message",async e=>{if(e&&e.data&&e.data.target==="LEDGER-IFRAME"){const{action:r,params:s}=e.data,a=`${r}-reply`;switch(r){case"ledger-get-configuration":await this.getConfiguration(a);break;case"ledger-get-public-key":await this.getPublicKey(a,s);break;case"ledger-get-address":await this.getAddress(a,s);break;case"ledger-sign-message":await this.signMessage(a,s);break;case"ledger-sign-transaction":await this.signTransaction(a,s);break;case"ledger-close-bridge":await this.cleanUp(a);break}}},!1)}sendMessageToExtension(e){window.parent.postMessage(e,"*")}async makeApp(){try{this.transport=await fe.create(),this.app=new _o(this.transport)}catch(e){throw console.log("LEDGER:::CREATE APP ERROR",e),e}}async cleanUp(e){this.app=null,this.transport&&await this.transport.close(),e&&this.sendMessageToExtension({action:e,success:!0})}async getConfiguration(e){try{await this.makeApp();const r=await this.app.getConfiguration();this.sendMessageToExtension({action:e,success:!0,payload:r})}catch(r){const s=this.ledgerErrToMessage(r);this.sendMessageToExtension({action:e,success:!1,error:new Error(s.toString())})}finally{await this.cleanUp()}}async getPublicKey(e,r){try{await this.makeApp();const s=await this.app.getPublicKey(r);this.sendMessageToExtension({action:e,success:!0,payload:s})}catch(s){const a=this.ledgerErrToMessage(s);this.sendMessageToExtension({action:e,success:!1,error:new Error(a.toString())})}finally{await this.cleanUp()}}async getAddress(e,r){try{await this.makeApp();const s=await this.app.getAddress(r);this.sendMessageToExtension({action:e,success:!0,payload:s})}catch(s){const a=this.ledgerErrToMessage(s);this.sendMessageToExtension({action:e,success:!1,error:new Error(a.toString())})}finally{await this.cleanUp()}}async signMessage(e,r){try{await this.makeApp();const s=await this.app.signMessage(r);this.sendMessageToExtension({action:e,success:!0,payload:s})}catch(s){const a=this.ledgerErrToMessage(s);this.sendMessageToExtension({action:e,success:!1,error:new Error(a.toString())})}finally{await this.cleanUp()}}async signTransaction(e,r){try{await this.makeApp();const s=await this.app.signTransaction(r);this.sendMessageToExtension({action:e,success:!0,payload:s})}catch(s){const a=this.ledgerErrToMessage(s);this.sendMessageToExtension({action:e,success:!1,error:new Error(a.toString())})}finally{await this.cleanUp()}}ledgerErrToMessage(e){const r=u=>String(u.message||u).includes("0x6700"),s=u=>String(u.message||u).includes("0x6804"),a=u=>u.name&&u.name.includes("TransportOpenUserCancelled"),l=u=>u.message&&u.message.includes("Message signing is not supported"),h=u=>u.message&&u.message.includes("Transaction approval request was rejected");return r(e)?"LEDGER_WRONG_APP":s(e)?"LEDGER_LOCKED":h(e)?"TRANSACTION_REJECTED":l(e)?"SIGN_NON_SUPPORTED":a(e)&&e.message&&e.message.includes("Access denied to use Ledger device")?"USER_DENIED":a(e)&&e.message&&e.message.includes("Failed to execute 'requestDevice' on 'HID'")?"USER_CANCELLED":e.toString()}}(()=>{const e=new URLSearchParams(window.location.search).get("theme")||"default",r=document.querySelector(`[data-theme="${e}"]`);r.style.display=null;const s=new Uo,a=r.querySelector('[data-action="pairing"]');a&&a.addEventListener("click",()=>s.getConfiguration());const l=r.querySelector('[data-action="back"]');l&&l.addEventListener("click",()=>s.cleanUp("ledger-bridge-back")),console.log(`EVER Wallet <=> Ledger Bridge initialized from ${window.location}!`)})(); diff --git a/docs/index.html b/docs/index.html index 4dcbe00..80e615f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2,7 +2,7 @@ Broxus < = > Ledger Bridge - + diff --git a/package-lock.json b/package-lock.json index 60f12a2..6da62bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,14 +9,14 @@ "version": "0.0.0", "license": "GNU GPL v3.0", "dependencies": { - "@ledgerhq/hw-transport": "^6.28.7", - "@ledgerhq/hw-transport-webhid": "^6.27.18", + "@ledgerhq/hw-transport": "^6.30.4", + "@ledgerhq/hw-transport-webhid": "^6.28.4", "buffer": "^6.0.3" }, "devDependencies": { - "@babel/eslint-parser": "^7.22.10", - "@vitejs/plugin-basic-ssl": "^1.0.1", - "eslint": "^8.47.0", + "@babel/eslint-parser": "^7.23.10", + "@vitejs/plugin-basic-ssl": "^1.1.0", + "eslint": "^8.57.0", "vite": "^4.4.9" } }, @@ -98,9 +98,9 @@ } }, "node_modules/@babel/eslint-parser": { - "version": "7.22.10", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.22.10.tgz", - "integrity": "sha512-0J8DNPRXQRLeR9rPaUMM3fA+RbixjnVLe/MRMYCkp3hzgsSuxCHQ8NN8xQG1wIHKJ4a1DTROTvFJdW+B5/eOsg==", + "version": "7.23.10", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.23.10.tgz", + "integrity": "sha512-3wSYDPZVnhseRnxRJH6ZVTNknBz76AEnyC+AYYhasjP3Yy23qz0ERR7Fcd2SHmYuSFJ2kY9gaaDd3vyqU09eSw==", "dev": true, "dependencies": { "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", @@ -859,9 +859,9 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", - "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", @@ -882,22 +882,22 @@ } }, "node_modules/@eslint/js": { - "version": "8.47.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.47.0.tgz", - "integrity": "sha512-P6omY1zv5MItm93kLM8s2vr1HICJH8v0dvddDhysbIuZ+vcjOHg5Zbkf1mTkcmi2JA9oBG2anOkRnW8WJTS8Og==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", + "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", - "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", + "version": "0.11.14", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^1.2.1", - "debug": "^4.1.1", + "@humanwhocodes/object-schema": "^2.0.2", + "debug": "^4.3.1", "minimatch": "^3.0.5" }, "engines": { @@ -918,9 +918,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", + "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "dev": true }, "node_modules/@jridgewell/gen-mapping": { @@ -976,20 +976,20 @@ } }, "node_modules/@ledgerhq/devices": { - "version": "8.0.6", - "resolved": "https://registry.npmjs.org/@ledgerhq/devices/-/devices-8.0.6.tgz", - "integrity": "sha512-KWA68krUD9pFp6bJAhTe2nurhku4HnS5LwtHnCXg8PB0DbzWt27PTKgVOCKO7TEdJ3wu4eVcgP5RQrap22pQHQ==", + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/@ledgerhq/devices/-/devices-8.2.1.tgz", + "integrity": "sha512-l/2I/Xzt7Z32OmGzoc/mUvaZivdn7Id/SO7hBTGpk7PtJTpBRxVAabP4GWEKCayGyOAcvTwoVxM0HMkNVfIzOQ==", "dependencies": { - "@ledgerhq/errors": "^6.13.1", - "@ledgerhq/logs": "^6.10.1", - "rxjs": "6", + "@ledgerhq/errors": "^6.16.2", + "@ledgerhq/logs": "^6.12.0", + "rxjs": "^7.8.1", "semver": "^7.3.5" } }, "node_modules/@ledgerhq/devices/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "dependencies": { "lru-cache": "^6.0.0" }, @@ -1001,35 +1001,36 @@ } }, "node_modules/@ledgerhq/errors": { - "version": "6.13.1", - "resolved": "https://registry.npmjs.org/@ledgerhq/errors/-/errors-6.13.1.tgz", - "integrity": "sha512-y5qOFiX7ILACF7GvCAB67S5nCABEP5rm8lxK66qKIBRApcLlTplbjUACDRfKQbAIwf0SJPuR31rtTKB92ykwKQ==" + "version": "6.16.2", + "resolved": "https://registry.npmjs.org/@ledgerhq/errors/-/errors-6.16.2.tgz", + "integrity": "sha512-jFpohaSW+p1Obp3NDT9QSByEtT3gtBZIjVNu8m25gnrH5zdtfPVlPwH6UiuS50s+2dHQyehV8hF+IfreKDWAZA==" }, "node_modules/@ledgerhq/hw-transport": { - "version": "6.28.7", - "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-6.28.7.tgz", - "integrity": "sha512-P6XWv/Blb3AvzNH/33ouqFvsUwjCsQN5iMTLuVJqxVKwj91QmdYZfYR9U9FB0gBKrIQ7BONUgTX/ko9EnDV6/g==", + "version": "6.30.4", + "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-6.30.4.tgz", + "integrity": "sha512-VBcVd7UG8HDrjWMoZI5rqBDz+PBxLHTIPZOGY/fdMoEUwaBbss0Z3MxuJanMyerlfaLqnBSVuL0blz7rOyagkw==", "dependencies": { - "@ledgerhq/devices": "^8.0.6", - "@ledgerhq/errors": "^6.13.1", + "@ledgerhq/devices": "^8.2.1", + "@ledgerhq/errors": "^6.16.2", + "@ledgerhq/logs": "^6.12.0", "events": "^3.3.0" } }, "node_modules/@ledgerhq/hw-transport-webhid": { - "version": "6.27.18", - "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport-webhid/-/hw-transport-webhid-6.27.18.tgz", - "integrity": "sha512-KhnQ4ETbY9y2nvJ/6JJI2dZzfvEcZacXGdTeL4eG29gJrZkOx45++q+L2TAhGPbLH2wYXKqsk63A061lrgSNSw==", + "version": "6.28.4", + "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport-webhid/-/hw-transport-webhid-6.28.4.tgz", + "integrity": "sha512-78lbSIcWp/lby4wlOjDb3YfvD5eCzozs7J12xvdqp2sU17qcGbwDUGyPsNApFUp8Qd5uUFNOy2ffV1w5B5XvFQ==", "dependencies": { - "@ledgerhq/devices": "^8.0.6", - "@ledgerhq/errors": "^6.13.1", - "@ledgerhq/hw-transport": "^6.28.7", - "@ledgerhq/logs": "^6.10.1" + "@ledgerhq/devices": "^8.2.1", + "@ledgerhq/errors": "^6.16.2", + "@ledgerhq/hw-transport": "^6.30.4", + "@ledgerhq/logs": "^6.12.0" } }, "node_modules/@ledgerhq/logs": { - "version": "6.10.1", - "resolved": "https://registry.npmjs.org/@ledgerhq/logs/-/logs-6.10.1.tgz", - "integrity": "sha512-z+ILK8Q3y+nfUl43ctCPuR4Y2bIxk/ooCQFwZxhtci1EhAtMDzMAx2W25qx8G1PPL9UUOdnUax19+F0OjXoj4w==" + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/@ledgerhq/logs/-/logs-6.12.0.tgz", + "integrity": "sha512-ExDoj1QV5eC6TEbMdLUMMk9cfvNKhhv5gXol4SmULRVCx/3iyCPhJ74nsb3S0Vb+/f+XujBEj3vQn5+cwS0fNA==" }, "node_modules/@nicolo-ribaudo/eslint-scope-5-internals": { "version": "5.1.1-v1", @@ -1083,22 +1084,28 @@ "optional": true, "peer": true }, + "node_modules/@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, "node_modules/@vitejs/plugin-basic-ssl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@vitejs/plugin-basic-ssl/-/plugin-basic-ssl-1.0.1.tgz", - "integrity": "sha512-pcub+YbFtFhaGRTo1832FQHQSHvMrlb43974e2eS8EKleR3p1cDdkJFPci1UhwkEf1J9Bz+wKBSzqpKp7nNj2A==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-basic-ssl/-/plugin-basic-ssl-1.1.0.tgz", + "integrity": "sha512-wO4Dk/rm8u7RNhOf95ZzcEmC9rYOncYgvq4z3duaJrCgjN8BxAnDVyndanfcJZ0O6XZzHz6Q0hTimxTg8Y9g/A==", "dev": true, "engines": { "node": ">=14.6.0" }, "peerDependencies": { - "vite": "^3.0.0 || ^4.0.0" + "vite": "^3.0.0 || ^4.0.0 || ^5.0.0" } }, "node_modules/acorn": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", - "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "dev": true, "bin": { "acorn": "bin/acorn" @@ -1438,18 +1445,19 @@ } }, "node_modules/eslint": { - "version": "8.47.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.47.0.tgz", - "integrity": "sha512-spUQWrdPt+pRVP1TTJLmfRNJJHHZryFmptzcafwSvHsceV81djHOdnEeDmkdotZyLNjDhrOasNK8nikkoG1O8Q==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", + "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "^8.47.0", - "@humanwhocodes/config-array": "^0.11.10", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.0", + "@humanwhocodes/config-array": "^0.11.14", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -1832,9 +1840,9 @@ } }, "node_modules/globals": { - "version": "13.21.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.21.0.tgz", - "integrity": "sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==", + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -1881,9 +1889,9 @@ ] }, "node_modules/ignore": { - "version": "5.2.4", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", - "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", "dev": true, "engines": { "node": ">= 4" @@ -2202,9 +2210,9 @@ } }, "node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "engines": { "node": ">=6" @@ -2289,14 +2297,11 @@ } }, "node_modules/rxjs": { - "version": "6.6.7", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", - "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", "dependencies": { - "tslib": "^1.9.0" - }, - "engines": { - "npm": ">=2.0.0" + "tslib": "^2.1.0" } }, "node_modules/semver": { @@ -2391,9 +2396,9 @@ } }, "node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "node_modules/type-check": { "version": "0.4.0", @@ -2609,9 +2614,9 @@ } }, "@babel/eslint-parser": { - "version": "7.22.10", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.22.10.tgz", - "integrity": "sha512-0J8DNPRXQRLeR9rPaUMM3fA+RbixjnVLe/MRMYCkp3hzgsSuxCHQ8NN8xQG1wIHKJ4a1DTROTvFJdW+B5/eOsg==", + "version": "7.23.10", + "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.23.10.tgz", + "integrity": "sha512-3wSYDPZVnhseRnxRJH6ZVTNknBz76AEnyC+AYYhasjP3Yy23qz0ERR7Fcd2SHmYuSFJ2kY9gaaDd3vyqU09eSw==", "dev": true, "requires": { "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", @@ -3080,9 +3085,9 @@ "dev": true }, "@eslint/eslintrc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", - "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "requires": { "ajv": "^6.12.4", @@ -3097,19 +3102,19 @@ } }, "@eslint/js": { - "version": "8.47.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.47.0.tgz", - "integrity": "sha512-P6omY1zv5MItm93kLM8s2vr1HICJH8v0dvddDhysbIuZ+vcjOHg5Zbkf1mTkcmi2JA9oBG2anOkRnW8WJTS8Og==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", + "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", "dev": true }, "@humanwhocodes/config-array": { - "version": "0.11.10", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.10.tgz", - "integrity": "sha512-KVVjQmNUepDVGXNuoRRdmmEjruj0KfiGSbS8LVc12LMsWDQzRXJ0qdhN8L8uUigKpfEHRhlaQFY0ib1tnUbNeQ==", + "version": "0.11.14", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", "dev": true, "requires": { - "@humanwhocodes/object-schema": "^1.2.1", - "debug": "^4.1.1", + "@humanwhocodes/object-schema": "^2.0.2", + "debug": "^4.3.1", "minimatch": "^3.0.5" } }, @@ -3120,9 +3125,9 @@ "dev": true }, "@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.2.tgz", + "integrity": "sha512-6EwiSjwWYP7pTckG6I5eyFANjPhmPjUX9JRLUSfNPC7FX7zK9gyZAfUEaECL6ALTpGX5AjnBq3C9XmVWPitNpw==", "dev": true }, "@jridgewell/gen-mapping": { @@ -3169,20 +3174,20 @@ } }, "@ledgerhq/devices": { - "version": "8.0.6", - "resolved": "https://registry.npmjs.org/@ledgerhq/devices/-/devices-8.0.6.tgz", - "integrity": "sha512-KWA68krUD9pFp6bJAhTe2nurhku4HnS5LwtHnCXg8PB0DbzWt27PTKgVOCKO7TEdJ3wu4eVcgP5RQrap22pQHQ==", + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/@ledgerhq/devices/-/devices-8.2.1.tgz", + "integrity": "sha512-l/2I/Xzt7Z32OmGzoc/mUvaZivdn7Id/SO7hBTGpk7PtJTpBRxVAabP4GWEKCayGyOAcvTwoVxM0HMkNVfIzOQ==", "requires": { - "@ledgerhq/errors": "^6.13.1", - "@ledgerhq/logs": "^6.10.1", - "rxjs": "6", + "@ledgerhq/errors": "^6.16.2", + "@ledgerhq/logs": "^6.12.0", + "rxjs": "^7.8.1", "semver": "^7.3.5" }, "dependencies": { "semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz", + "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==", "requires": { "lru-cache": "^6.0.0" } @@ -3190,35 +3195,36 @@ } }, "@ledgerhq/errors": { - "version": "6.13.1", - "resolved": "https://registry.npmjs.org/@ledgerhq/errors/-/errors-6.13.1.tgz", - "integrity": "sha512-y5qOFiX7ILACF7GvCAB67S5nCABEP5rm8lxK66qKIBRApcLlTplbjUACDRfKQbAIwf0SJPuR31rtTKB92ykwKQ==" + "version": "6.16.2", + "resolved": "https://registry.npmjs.org/@ledgerhq/errors/-/errors-6.16.2.tgz", + "integrity": "sha512-jFpohaSW+p1Obp3NDT9QSByEtT3gtBZIjVNu8m25gnrH5zdtfPVlPwH6UiuS50s+2dHQyehV8hF+IfreKDWAZA==" }, "@ledgerhq/hw-transport": { - "version": "6.28.7", - "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-6.28.7.tgz", - "integrity": "sha512-P6XWv/Blb3AvzNH/33ouqFvsUwjCsQN5iMTLuVJqxVKwj91QmdYZfYR9U9FB0gBKrIQ7BONUgTX/ko9EnDV6/g==", + "version": "6.30.4", + "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport/-/hw-transport-6.30.4.tgz", + "integrity": "sha512-VBcVd7UG8HDrjWMoZI5rqBDz+PBxLHTIPZOGY/fdMoEUwaBbss0Z3MxuJanMyerlfaLqnBSVuL0blz7rOyagkw==", "requires": { - "@ledgerhq/devices": "^8.0.6", - "@ledgerhq/errors": "^6.13.1", + "@ledgerhq/devices": "^8.2.1", + "@ledgerhq/errors": "^6.16.2", + "@ledgerhq/logs": "^6.12.0", "events": "^3.3.0" } }, "@ledgerhq/hw-transport-webhid": { - "version": "6.27.18", - "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport-webhid/-/hw-transport-webhid-6.27.18.tgz", - "integrity": "sha512-KhnQ4ETbY9y2nvJ/6JJI2dZzfvEcZacXGdTeL4eG29gJrZkOx45++q+L2TAhGPbLH2wYXKqsk63A061lrgSNSw==", + "version": "6.28.4", + "resolved": "https://registry.npmjs.org/@ledgerhq/hw-transport-webhid/-/hw-transport-webhid-6.28.4.tgz", + "integrity": "sha512-78lbSIcWp/lby4wlOjDb3YfvD5eCzozs7J12xvdqp2sU17qcGbwDUGyPsNApFUp8Qd5uUFNOy2ffV1w5B5XvFQ==", "requires": { - "@ledgerhq/devices": "^8.0.6", - "@ledgerhq/errors": "^6.13.1", - "@ledgerhq/hw-transport": "^6.28.7", - "@ledgerhq/logs": "^6.10.1" + "@ledgerhq/devices": "^8.2.1", + "@ledgerhq/errors": "^6.16.2", + "@ledgerhq/hw-transport": "^6.30.4", + "@ledgerhq/logs": "^6.12.0" } }, "@ledgerhq/logs": { - "version": "6.10.1", - "resolved": "https://registry.npmjs.org/@ledgerhq/logs/-/logs-6.10.1.tgz", - "integrity": "sha512-z+ILK8Q3y+nfUl43ctCPuR4Y2bIxk/ooCQFwZxhtci1EhAtMDzMAx2W25qx8G1PPL9UUOdnUax19+F0OjXoj4w==" + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/@ledgerhq/logs/-/logs-6.12.0.tgz", + "integrity": "sha512-ExDoj1QV5eC6TEbMdLUMMk9cfvNKhhv5gXol4SmULRVCx/3iyCPhJ74nsb3S0Vb+/f+XujBEj3vQn5+cwS0fNA==" }, "@nicolo-ribaudo/eslint-scope-5-internals": { "version": "5.1.1-v1", @@ -3263,17 +3269,23 @@ "optional": true, "peer": true }, + "@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, "@vitejs/plugin-basic-ssl": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@vitejs/plugin-basic-ssl/-/plugin-basic-ssl-1.0.1.tgz", - "integrity": "sha512-pcub+YbFtFhaGRTo1832FQHQSHvMrlb43974e2eS8EKleR3p1cDdkJFPci1UhwkEf1J9Bz+wKBSzqpKp7nNj2A==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-basic-ssl/-/plugin-basic-ssl-1.1.0.tgz", + "integrity": "sha512-wO4Dk/rm8u7RNhOf95ZzcEmC9rYOncYgvq4z3duaJrCgjN8BxAnDVyndanfcJZ0O6XZzHz6Q0hTimxTg8Y9g/A==", "dev": true, "requires": {} }, "acorn": { - "version": "8.10.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", - "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==", + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz", + "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==", "dev": true }, "acorn-jsx": { @@ -3496,18 +3508,19 @@ "dev": true }, "eslint": { - "version": "8.47.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.47.0.tgz", - "integrity": "sha512-spUQWrdPt+pRVP1TTJLmfRNJJHHZryFmptzcafwSvHsceV81djHOdnEeDmkdotZyLNjDhrOasNK8nikkoG1O8Q==", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", + "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", "dev": true, "requires": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.6.1", - "@eslint/eslintrc": "^2.1.2", - "@eslint/js": "^8.47.0", - "@humanwhocodes/config-array": "^0.11.10", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.0", + "@humanwhocodes/config-array": "^0.11.14", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", @@ -3786,9 +3799,9 @@ } }, "globals": { - "version": "13.21.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.21.0.tgz", - "integrity": "sha512-ybyme3s4yy/t/3s35bewwXKOf7cvzfreG2lH0lZl0JB7I4GxRP2ghxOK/Nb9EkRXdbBXZLfq/p/0W2JUONB/Gg==", + "version": "13.24.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.24.0.tgz", + "integrity": "sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -3812,9 +3825,9 @@ "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" }, "ignore": { - "version": "5.2.4", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", - "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", "dev": true }, "import-fresh": { @@ -4044,9 +4057,9 @@ "dev": true }, "punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true }, "queue-microtask": { @@ -4086,11 +4099,11 @@ } }, "rxjs": { - "version": "6.6.7", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz", - "integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==", + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", "requires": { - "tslib": "^1.9.0" + "tslib": "^2.1.0" } }, "semver": { @@ -4158,9 +4171,9 @@ "peer": true }, "tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, "type-check": { "version": "0.4.0", diff --git a/package.json b/package.json index dcea8f7..f31c9f4 100644 --- a/package.json +++ b/package.json @@ -10,14 +10,14 @@ "author": "", "license": "GNU GPL v3.0", "devDependencies": { - "@babel/eslint-parser": "^7.22.10", - "@vitejs/plugin-basic-ssl": "^1.0.1", - "eslint": "^8.47.0", + "@babel/eslint-parser": "^7.23.10", + "@vitejs/plugin-basic-ssl": "^1.1.0", + "eslint": "^8.57.0", "vite": "^4.4.9" }, "dependencies": { - "@ledgerhq/hw-transport": "^6.28.7", - "@ledgerhq/hw-transport-webhid": "^6.27.18", + "@ledgerhq/hw-transport": "^6.30.4", + "@ledgerhq/hw-transport-webhid": "^6.28.4", "buffer": "^6.0.3" } } diff --git a/src/js/ledger-app.js b/src/js/ledger-app.js index 94b3390..817c01e 100644 --- a/src/js/ledger-app.js +++ b/src/js/ledger-app.js @@ -14,9 +14,13 @@ const FLAG_WITH_WALLET_ID = 1 << 0 const FLAG_WITH_WORKCHAIN_ID = 1 << 1 const FLAG_WITH_ADDRESS = 1 << 2 const FLAG_WITH_CHAIN_ID = 1 << 3 +const MAX_CHUNK_SIZE = 255 export default class LedgerApp { constructor(transport, scrambleKey = 'l0v') { + /** + * @type {Transport} + */ this.transport = void 0 this.transport = transport transport.decorateAppAPIMethods( @@ -117,7 +121,7 @@ export default class LedgerApp { }) } - signTransaction({ account, originalWallet, wallet, message, chainId, context }) { + async signTransaction({ account, originalWallet, wallet, message, chainId, context }) { // params.account, params.originalWallet, params.wallet, params.message, params.context let metadata = 0 const optional = [] @@ -174,28 +178,53 @@ export default class LedgerApp { message.subarray(4), ] const apdus = Buffer.concat(buffer) + const slices = [] - return this.transport - .send(CLA, INS_SIGN_TRANSACTION, 0x01, 0x00, apdus, [ - SW_OK, - SW_CANCEL, - SW_NOT_ALLOWED, - SW_UNSUPPORTED, - ]) - .then((response) => { - const status = Buffer.from(response.slice(response.length - 2)).readUInt16BE(0) - if (status === SW_OK) { - const signature = response.slice(1, response.length - 2) - return {signature} - } else if (status === SW_CANCEL) { - throw new Error('Transaction approval request was rejected') - } else if (status === SW_UNSUPPORTED) { - throw new Error('Message signing is not supported') - } else { - throw new Error( - 'Message signing not allowed. Have you enabled it in the app settings?', - ) - } - }) + for (let i = 0; i < apdus.length; i += MAX_CHUNK_SIZE) { + slices.push( + apdus.slice(i, Math.min(apdus.length, i + MAX_CHUNK_SIZE)), + ) + } + + let response, status + + for (let i = 0; i < slices.length; i++) { + const slice = slices[i] + let p2 = 0x00 // single chunk + + if (slices.length !== 1) { + if (i === 0) { + p2 = 0x02 // first chunk + } else if (i === slices.length - 1) { + p2 = 0x01 // last chunk + } else { + p2 = 0x03 // intermediate chunk + } + } + + response = await this.transport + .send(CLA, INS_SIGN_TRANSACTION, 0x01, p2, slice, [ + SW_OK, + SW_CANCEL, + SW_NOT_ALLOWED, + SW_UNSUPPORTED, + ]) + status = Buffer.from(response.slice(response.length - 2)).readUInt16BE(0) + + if (status !== SW_OK) break + } + + if (status === SW_OK) { // 36864 + const signature = response.slice(1, response.length - 2) + return { signature } + } else if (status === SW_CANCEL) { + throw new Error('Transaction approval request was rejected') + } else if (status === SW_UNSUPPORTED) { + throw new Error('Message signing is not supported') + } else { + throw new Error( + 'Message signing not allowed. Have you enabled it in the app settings?', + ) + } } }