UNPKG

@tkey/core

Version:
2 lines 450 kB
/*! For license information please see core.umd.min.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Core=t():e.Core=t()}(self,(()=>(()=>{var e={36:(e,t,r)=>{"use strict";r.d(t,{Vw:()=>f,Fc:()=>c,O8:()=>s,qv:()=>a,po:()=>u,ZJ:()=>d,DH:()=>o,ld:()=>h});const n="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;var i=r(6879);function o(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function s(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const a=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function c(e){for(let r=0;r<e.length;r++)e[r]=(t=e[r])<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255;var t}function d(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),(0,i.DO)(e),e}class f{clone(){return this._cloneInto()}}function h(e){const t=t=>e().update(d(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function u(e=32){if(n&&"function"==typeof n.getRandomValues)return n.getRandomValues(new Uint8Array(e));if(n&&"function"==typeof n.randomBytes)return n.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}},46:e=>{"use strict";var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise((function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}b(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&b(e,"error",t,{once:!0})}(e,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function c(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function d(e,t,r,n){var i,o,s,d;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(e))>0&&s.length>i&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=t,f.count=s.length,d=f,console&&console.warn&&console.warn(d)}return e}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=f.bind(n);return i.listener=r,n.wrapFn=i,i}function u(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):p(i,i.length)}function l(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function b(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function i(o){n.once&&e.removeEventListener(t,i),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(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},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[e];if(void 0===c)return!1;if("function"==typeof c)n(c,this,t);else{var d=c.length,f=p(c,d);for(r=0;r<d;++r)n(f[r],this,t)}return!0},o.prototype.addListener=function(e,t){return d(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return d(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,h(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,h(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,n,i,o,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return u(this,e,!0)},o.prototype.rawListeners=function(e){return u(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):l.call(e,t)},o.prototype.listenerCount=l,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}},110:(e,t,r)=>{"use strict";r.d(t,{So:()=>P});var n=r(6879),i=r(9964),o=r(36);const s=[],a=[],c=[],d=BigInt(0),f=BigInt(1),h=BigInt(2),u=BigInt(7),l=BigInt(256),p=BigInt(113);for(let e=0,t=f,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],s.push(2*(5*n+r)),a.push((e+1)*(e+2)/2%64);let i=d;for(let e=0;e<7;e++)t=(t<<f^(t>>u)*p)%l,t&h&&(i^=f<<(f<<BigInt(e))-f);c.push(i)}const[b,y]=(0,i.lD)(c,!0),m=(e,t,r)=>r>32?(0,i.WM)(e,t,r):(0,i.P5)(e,t,r),g=(e,t,r)=>r>32?(0,i.im)(e,t,r):(0,i.B4)(e,t,r);class v extends o.Vw{constructor(e,t,r,i=!1,s=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=i,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,n.Fe)(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,o.DH)(this.state)}keccak(){o.qv||(0,o.Fc)(this.state32),function(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const n=(t+8)%10,i=(t+2)%10,o=r[i],s=r[i+1],a=m(o,s,1)^r[n],c=g(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=c}let t=e[2],i=e[3];for(let r=0;r<24;r++){const n=a[r],o=m(t,i,n),c=g(t,i,n),d=s[r];t=e[d],i=e[d+1],e[d]=o,e[d+1]=c}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=b[n],e[1]^=y[n]}r.fill(0)}(this.state32,this.rounds),o.qv||(0,o.Fc)(this.state32),this.posOut=0,this.pos=0}update(e){(0,n.CC)(this);const{blockLen:t,state:r}=this,i=(e=(0,o.ZJ)(e)).length;for(let n=0;n<i;){const o=Math.min(t-this.pos,i-n);for(let t=0;t<o;t++)r[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:n}=this;e[r]^=t,128&t&&r===n-1&&this.keccak(),e[n-1]^=128,this.keccak()}writeInto(e){(0,n.CC)(this,!1),(0,n.DO)(e),this.finish();const t=this.state,{blockLen:r}=this;for(let n=0,i=e.length;n<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,n.Fe)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,n.Ht)(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return e||(e=new v(t,r,n,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}const w=(e,t,r)=>(0,o.ld)((()=>new v(t,e,r))),S=w(1,144,28),_=w(1,136,32),A=w(1,104,48),M=w(1,72,64);var E=r(9502);(0,E.RS)(S);const P=(()=>{const e=(0,E.RS)(_);return e.create=_.create,e})();(0,E.RS)(A),(0,E.RS)(M)},183:e=>{"use strict";e.exports={rE:"6.6.1"}},206:(e,t,r)=>{"use strict";var n=r(8212),i=r(2823),o=r(2768),s=r(5185);class a{constructor(e,t){n(this,"share",void 0),n(this,"shareIndex",void 0),this.share=new i(t,"hex"),this.shareIndex=new i(e,"hex")}static fromJSON(e){const{share:t,shareIndex:r}=e;return new a(r,t)}getPublicShare(){return new s(this.shareIndex,o.getPubKeyPoint(this.share))}toJSON(){return{share:this.share.toString("hex"),shareIndex:this.shareIndex.toString("hex")}}}e.exports=a},277:(e,t,r)=>{"use strict";var n=r(1874),i=r(2823),o=r(5615),s=r(5174),a=n.assert;function c(e){s.call(this,"short",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function d(e,t,r,n){s.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(t,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function f(e,t,r,n){s.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(t,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(c,s),e.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new i(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new i(e.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(t))?r=o[0]:(r=o[1],a(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map((function(e){return{a:new i(e.a,16),b:new i(e.b,16)}})):this._getEndoBasis(r)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:i.mont(e),r=new i(2).toRed(t).redInvm(),n=r.redNeg(),o=new i(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,r,n,o,s,a,c,d,f,h=this.n.ushrn(Math.floor(this.n.bitLength()/2)),u=e,l=this.n.clone(),p=new i(1),b=new i(0),y=new i(0),m=new i(1),g=0;0!==u.cmpn(0);){var v=l.div(u);d=l.sub(v.mul(u)),f=y.sub(v.mul(p));var w=m.sub(v.mul(b));if(!n&&d.cmp(h)<0)t=c.neg(),r=p,n=d.neg(),o=f;else if(n&&2==++g)break;c=d,l=u,u=d,y=p,p=f,m=b,b=w}s=d.neg(),a=f;var S=n.sqr().add(o.sqr());return s.sqr().add(a.sqr()).cmp(S)>=0&&(s=t,a=r),n.negative&&(n=n.neg(),o=o.neg()),s.negative&&(s=s.neg(),a=a.neg()),[{a:n,b:o},{a:s,b:a}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),s=i.mul(r.a),a=o.mul(n.a),c=i.mul(r.b),d=o.mul(n.b);return{k1:e.sub(s).sub(a),k2:c.add(d).neg()}},c.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(t&&!o||!t&&o)&&(n=n.redNeg()),this.point(e,n)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o<e.length;o++){var s=this._endoSplit(t[o]),a=e[o],c=a._getBeta();s.k1.negative&&(s.k1.ineg(),a=a.neg(!0)),s.k2.negative&&(s.k2.ineg(),c=c.neg(!0)),n[2*o]=a,n[2*o+1]=c,i[2*o]=s.k1,i[2*o+1]=s.k2}for(var d=this._wnafMulAdd(1,n,i,2*o,r),f=0;f<2*o;f++)n[f]=null,i[f]=null;return d},o(d,s.BasePoint),c.prototype.point=function(e,t,r){return new d(this,e,t,r)},c.prototype.pointFromJSON=function(e,t){return d.fromJSON(this,e,t)},d.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var r=this.curve,n=function(e){return r.point(e.x.redMul(r.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(n)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(n)}}}return t}},d.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},d.fromJSON=function(e,t,r){"string"==typeof t&&(t=JSON.parse(t));var n=e.point(t[0],t[1],r);if(!t[2])return n;function i(t){return e.point(t[0],t[1],r)}var o=t[2];return n.precomputed={beta:null,doubles:o.doubles&&{step:o.doubles.step,points:[n].concat(o.doubles.points.map(i))},naf:o.naf&&{wnd:o.naf.wnd,points:[n].concat(o.naf.points.map(i))}},n},d.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},d.prototype.isInfinity=function(){return this.inf},d.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},d.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,s)},d.prototype.getX=function(){return this.x.fromRed()},d.prototype.getY=function(){return this.y.fromRed()},d.prototype.mul=function(e){return e=new i(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},d.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},d.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},d.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},d.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},d.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(f,s.BasePoint),c.prototype.jpoint=function(e,t,r){return new f(this,e,t,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(r.redMul(this.z)),a=n.redSub(i),c=o.redSub(s);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var d=a.redSqr(),f=d.redMul(a),h=n.redMul(d),u=c.redSqr().redIAdd(f).redISub(h).redISub(h),l=c.redMul(h.redISub(u)).redISub(o.redMul(f)),p=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(u,l,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),s=r.redSub(n),a=i.redSub(o);if(0===s.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=s.redSqr(),d=c.redMul(s),f=r.redMul(c),h=a.redSqr().redIAdd(d).redISub(f).redISub(f),u=a.redMul(f.redISub(h)).redISub(i.redMul(d)),l=this.z.redMul(s);return this.curve.jpoint(h,u,l)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var r=this;for(t=0;t<e;t++)r=r.dbl();return r}var n=this.curve.a,i=this.curve.tinv,o=this.x,s=this.y,a=this.z,c=a.redSqr().redSqr(),d=s.redAdd(s);for(t=0;t<e;t++){var f=o.redSqr(),h=d.redSqr(),u=h.redSqr(),l=f.redAdd(f).redIAdd(f).redIAdd(n.redMul(c)),p=o.redMul(h),b=l.redSqr().redISub(p.redAdd(p)),y=p.redISub(b),m=l.redMul(y);m=m.redIAdd(m).redISub(u);var g=d.redMul(a);t+1<e&&(c=c.redMul(u)),o=b,a=g,d=m}return this.curve.jpoint(o,d.redMul(i),a)},f.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},f.prototype._zeroDbl=function(){var e,t,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n),c=a.redSqr().redISub(s).redISub(s),d=o.redIAdd(o);d=(d=d.redIAdd(d)).redIAdd(d),e=c,t=a.redMul(s.redISub(c)).redISub(d),r=this.y.redAdd(this.y)}else{var f=this.x.redSqr(),h=this.y.redSqr(),u=h.redSqr(),l=this.x.redAdd(h).redSqr().redISub(f).redISub(u);l=l.redIAdd(l);var p=f.redAdd(f).redIAdd(f),b=p.redSqr(),y=u.redIAdd(u);y=(y=y.redIAdd(y)).redIAdd(y),e=b.redISub(l).redISub(l),t=p.redMul(l.redISub(e)).redISub(y),r=(r=this.y.redMul(this.z)).redIAdd(r)}return this.curve.jpoint(e,t,r)},f.prototype._threeDbl=function(){var e,t,r;if(this.zOne){var n=this.x.redSqr(),i=this.y.redSqr(),o=i.redSqr(),s=this.x.redAdd(i).redSqr().redISub(n).redISub(o);s=s.redIAdd(s);var a=n.redAdd(n).redIAdd(n).redIAdd(this.curve.a),c=a.redSqr().redISub(s).redISub(s);e=c;var d=o.redIAdd(o);d=(d=d.redIAdd(d)).redIAdd(d),t=a.redMul(s.redISub(c)).redISub(d),r=this.y.redAdd(this.y)}else{var f=this.z.redSqr(),h=this.y.redSqr(),u=this.x.redMul(h),l=this.x.redSub(f).redMul(this.x.redAdd(f));l=l.redAdd(l).redIAdd(l);var p=u.redIAdd(u),b=(p=p.redIAdd(p)).redAdd(p);e=l.redSqr().redISub(b),r=this.y.redAdd(this.z).redSqr().redISub(h).redISub(f);var y=h.redSqr();y=(y=(y=y.redIAdd(y)).redIAdd(y)).redIAdd(y),t=l.redMul(p.redISub(e)).redISub(y)}return this.curve.jpoint(e,t,r)},f.prototype._dbl=function(){var e=this.curve.a,t=this.x,r=this.y,n=this.z,i=n.redSqr().redSqr(),o=t.redSqr(),s=r.redSqr(),a=o.redAdd(o).redIAdd(o).redIAdd(e.redMul(i)),c=t.redAdd(t),d=(c=c.redIAdd(c)).redMul(s),f=a.redSqr().redISub(d.redAdd(d)),h=d.redISub(f),u=s.redSqr();u=(u=(u=u.redIAdd(u)).redIAdd(u)).redIAdd(u);var l=a.redMul(h).redISub(u),p=r.redAdd(r).redMul(n);return this.curve.jpoint(f,l,p)},f.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr(),n=t.redSqr(),i=e.redAdd(e).redIAdd(e),o=i.redSqr(),s=this.x.redAdd(t).redSqr().redISub(e).redISub(n),a=(s=(s=(s=s.redIAdd(s)).redAdd(s).redIAdd(s)).redISub(o)).redSqr(),c=n.redIAdd(n);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var d=i.redIAdd(s).redSqr().redISub(o).redISub(a).redISub(c),f=t.redMul(d);f=(f=f.redIAdd(f)).redIAdd(f);var h=this.x.redMul(a).redISub(f);h=(h=h.redIAdd(h)).redIAdd(h);var u=this.y.redMul(d.redMul(c.redISub(d)).redISub(s.redMul(a)));u=(u=(u=u.redIAdd(u)).redIAdd(u)).redIAdd(u);var l=this.z.redAdd(s).redSqr().redISub(r).redISub(a);return this.curve.jpoint(h,u,l)},f.prototype.mul=function(e,t){return e=new i(e,t),this.curve._wnafMul(this,e)},f.prototype.eq=function(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),r=e.z.redSqr();if(0!==this.x.redMul(r).redISub(e.x.redMul(t)).cmpn(0))return!1;var n=t.redMul(this.z),i=r.redMul(e.z);return 0===this.y.redMul(i).redISub(e.y.redMul(n)).cmpn(0)},f.prototype.eqXToP=function(e){var t=this.z.redSqr(),r=e.toRed(this.curve.red).redMul(t);if(0===this.x.cmp(r))return!0;for(var n=e.clone(),i=this.curve.redN.redMul(t);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},f.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},335:(e,t,r)=>{"use strict";r.d(t,{A:()=>m});var n=r(8158),i=r(3890),o=r(3628),s=r(2823),a=r.n(s),c=r(3360),d=r(6122),f=r(888),h=r(6073),u=r(5965),l=r(3259),p=r(8935),b=r(1498),y=r(1048).hp;class m{constructor({enableOneKey:e=!1,clientId:t,network:r,serverTimeOffset:o=0,allowHost:s,legacyMetadataHost:a,keyType:d=i.PN.SECP256K1}){if((0,n.A)(this,"allowHost",void 0),(0,n.A)(this,"serverTimeOffset",void 0),(0,n.A)(this,"network",void 0),(0,n.A)(this,"clientId",void 0),(0,n.A)(this,"ec",void 0),(0,n.A)(this,"enableOneKey",void 0),(0,n.A)(this,"legacyMetadataHost",void 0),(0,n.A)(this,"keyType",i.PN.SECP256K1),!t)throw new Error("Please provide a valid clientId in constructor");if(!r)throw new Error("Please provide a valid network in constructor");if(d===i.PN.ED25519&&i.$o[r])throw new Error(`keyType: ${d} is not supported by ${r} network`);this.keyType=d,this.ec=new c.ec(this.keyType),this.serverTimeOffset=o||0,this.network=r,this.clientId=t,this.allowHost=s||`${i.Q2[r]}/api/allow`,this.enableOneKey=e,this.legacyMetadataHost=a||i.xE[r]}static enableLogging(e=!0){e?(f.A.enableAll(),d.$.logRequestTracing=!0):f.A.disableAll()}static setAPIKey(e){(0,o.Qv)(e)}static setEmbedHost(e){(0,o.KL)(e)}static setSessionTime(e){m.sessionTime=e}static isGetOrSetNonceError(e){return e instanceof h.l}static getPostboxKey(e){return"v1"===e.metadata.typeOfUser&&e.finalKeyData.privKey||e.postboxKeyData.privKey}async retrieveShares(e){const{verifier:t,verifierParams:r,idToken:n,nodePubkeys:o,indexes:s,endpoints:a,useDkg:c,extraParams:d={},checkCommitment:f=!0}=e;if(0===o.length)throw new Error("nodePubkeys param is required");if(o.length!==s.length)throw new Error("nodePubkeys length must be same as indexes length");if(o.length!==a.length)throw new Error("nodePubkeys length must be same as endpoints length");let h;if("boolean"==typeof c){if(!1===c&&i.$o[this.network])throw new Error(`useDkg cannot be false for legacy network; ${this.network}`);h=this.keyType!==i.PN.ED25519&&c}else h=this.keyType!==i.PN.ED25519;if(!h&&0===o.length)throw new Error("nodePubkeys param is required");return d.session_token_exp_second||(d.session_token_exp_second=m.sessionTime),(0,u.G)({legacyMetadataHost:this.legacyMetadataHost,serverTimeOffset:this.serverTimeOffset,enableOneKey:this.enableOneKey,ecCurve:this.ec,keyType:this.keyType,allowHost:this.allowHost,network:this.network,clientId:this.clientId,endpoints:a,indexes:s,verifier:t,verifierParams:r,idToken:n,useDkg:h,newImportedShares:[],overrideExistingKey:!1,nodePubkeys:o,extraParams:d,checkCommitment:f})}async getPublicAddress(e,t,{verifier:r,verifierId:n,extendedVerifierId:i,keyType:o}){f.A.info(t,{verifier:r,verifierId:n,extendedVerifierId:i});const s=null!=o?o:this.keyType;return this.getNewPublicAddress(e,{verifier:r,verifierId:n,extendedVerifierId:i,keyType:s},this.enableOneKey)}async importPrivateKey(e){const{nodeIndexes:t,newPrivateKey:r,verifier:n,verifierParams:o,idToken:s,nodePubkeys:a,endpoints:c,extraParams:d={},checkCommitment:f=!0}=e;if(i.$o[this.network])throw new Error(`importPrivateKey is not supported by legacy network; ${this.network}`);if(c.length!==t.length)throw new Error("length of endpoints array must be same as length of nodeIndexes array");let h;if(d.session_token_exp_second||(d.session_token_exp_second=m.sessionTime),this.keyType===i.PN.SECP256K1&&(h=y.from(r.padStart(64,"0"),"hex"),32!==h.length))throw new Error("Invalid private key length for given secp256k1 key");if(this.keyType===i.PN.ED25519&&(h=y.from(r.padStart(64,"0"),"hex"),32!==h.length))throw new Error("Invalid private key length for given ed25519 key");const p=await(0,l.qV)(this.ec,this.keyType,this.serverTimeOffset,t,a,h);if(this.keyType===i.PN.ED25519){const e=(0,l.Hu)(h),t=(0,l.Cn)(e.point),r=(0,l.Cn)(p[0].final_user_point);if(y.from(t).toString("hex")!==r.toString("hex"))throw new Error("invalid shares data for ed25519 key, public key is not matching after generating shares")}return(0,u.G)({legacyMetadataHost:this.legacyMetadataHost,serverTimeOffset:this.serverTimeOffset,enableOneKey:this.enableOneKey,ecCurve:this.ec,keyType:this.keyType,allowHost:this.allowHost,network:this.network,clientId:this.clientId,endpoints:c,indexes:t,verifier:n,verifierParams:o,idToken:s,useDkg:!1,overrideExistingKey:!0,newImportedShares:p,nodePubkeys:a,extraParams:d,checkCommitment:f})}async getUserTypeAndAddress(e,{verifier:t,verifierId:r,extendedVerifierId:n}){return this.getNewPublicAddress(e,{verifier:t,verifierId:r,extendedVerifierId:n},!0)}async getNewPublicAddress(e,{verifier:t,verifierId:r,extendedVerifierId:n,keyType:o},s){const c=null!=o?o:this.keyType,d=(0,p.tO)(c);if(c===i.PN.ED25519&&i.$o[this.network])throw new Error(`keyType: ${o} is not supported by ${this.network} network`);const f=await(0,u.Gj)({endpoints:e,network:this.network,verifier:t,verifierId:r,keyType:c,extendedVerifierId:n}),{errorResult:b,keyResult:y,nodeIndexes:m=[],serverTimeOffset:g}=f,v=this.serverTimeOffset||g,{nonceResult:w}=f;if(b&&JSON.stringify(b).toLowerCase().includes("verifier not supported"))throw new Error("Verifier not supported. Check if you: \n\n 1. Are on the right network (Torus testnet/mainnet) \n\n 2. Have setup a verifier on dashboard.web3auth.io?");if(b)throw new Error(`node results do not match at first lookup ${JSON.stringify(y||{})}, ${JSON.stringify(b||{})}`);if(null==y||!y.keys)throw new Error(`node results do not match at final lookup ${JSON.stringify(y||{})}, ${JSON.stringify(b||{})}`);if(!w&&!n&&!i.$o[this.network])throw new h.l("metadata nonce is missing in share response");const{pub_key_X:S,pub_key_Y:_}=y.keys[0];let A;const M=new(a())((null==w?void 0:w.nonce)||"0",16);let E,P;if(n)P=d.keyFromPublic({x:S,y:_}).getPublic(),E=P;else{if(i.$o[this.network])return this.formatLegacyPublicKeyData({isNewKey:y.is_new_key,enableOneKey:s,finalKeyResult:{keys:y.keys},serverTimeOffset:v});{const e=w;E=d.keyFromPublic({x:S,y:_}).getPublic(),P=d.keyFromPublic({x:S,y:_}).getPublic().add(d.keyFromPublic({x:e.pubNonce.x,y:e.pubNonce.y}).getPublic()),A={X:e.pubNonce.x,Y:e.pubNonce.y}}}if(!E)throw new Error("Unable to derive oAuthPubKey");const x=E.getX().toString(16,64),k=E.getY().toString(16,64),I=(0,l.qA)(c,E.getX(),E.getY());if(!P)throw new Error("Unable to derive finalPubKey");const O=P?P.getX().toString(16,64):"",T=P?P.getY().toString(16,64):"";return{oAuthKeyData:{walletAddress:I,X:x,Y:k},finalKeyData:{walletAddress:P?(0,l.qA)(c,P.getX(),P.getY()):"",X:O,Y:T},metadata:{pubNonce:A,nonce:M,upgraded:(null==w?void 0:w.upgraded)||!1,typeOfUser:"v2",serverTimeOffset:v},nodesData:{nodeIndexes:m}}}async formatLegacyPublicKeyData(e){var t;const{finalKeyResult:r,enableOneKey:n,isNewKey:i,serverTimeOffset:o,keyType:s}=e,c=null!=s?s:this.keyType,d=(0,p.tO)(c),{pub_key_X:f,pub_key_Y:u}=r.keys[0];let y,m,g,v,w;const S=d.keyFromPublic({x:f,y:u}).getPublic(),_=this.serverTimeOffset||o;if(n){try{y=await(0,b.Ri)(this.legacyMetadataHost,d,_,f,u,void 0,!i),m=new(a())(y.nonce||"0",16),v=y.typeOfUser}catch{throw new h.l}if("v1"===y.typeOfUser)m=await(0,b.yb)(this.legacyMetadataHost,{pub_key_X:f,pub_key_Y:u}),g=d.keyFromPublic({x:f,y:u}).getPublic().add(d.keyFromPrivate(m.toString(16,64),"hex").getPublic());else{if("v2"!==y.typeOfUser)throw new Error("getOrSetNonce should always return typeOfUser.");g=d.keyFromPublic({x:f,y:u}).getPublic().add(d.keyFromPublic({x:y.pubNonce.x,y:y.pubNonce.y}).getPublic()),w={X:y.pubNonce.x,Y:y.pubNonce.y}}}else v="v1",m=await(0,b.yb)(this.legacyMetadataHost,{pub_key_X:f,pub_key_Y:u}),g=d.keyFromPublic({x:f,y:u}).getPublic().add(d.keyFromPrivate(m.toString(16,64),"hex").getPublic());if(!S)throw new Error("Unable to derive oAuthPubKey");const A=S.getX().toString(16,64),M=S.getY().toString(16,64),E=(0,l.qA)(c,S.getX(),S.getY());if("v2"===v&&!g)throw new Error("Unable to derive finalPubKey");const P=g?g.getX().toString(16,64):"",x=g?g.getY().toString(16,64):"";return{oAuthKeyData:{walletAddress:E,X:A,Y:M},finalKeyData:{walletAddress:g?(0,l.qA)(c,g.getX(),g.getY()):"",X:P,Y:x},metadata:{pubNonce:w,nonce:m,upgraded:(null===(t=y)||void 0===t?void 0:t.upgraded)||!1,typeOfUser:v,serverTimeOffset:_},nodesData:{nodeIndexes:[]}}}}(0,n.A)(m,"sessionTime",86400)},461:(e,t,r)=>{"use strict";var n=r(7784),i=r(5615);function o(e,t){return 55296==(64512&e.charCodeAt(t))&&!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1))}function s(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function c(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i<e.length;i+=2)r.push(parseInt(e[i]+e[i+1],16))}else for(var n=0,i=0;i<e.length;i++){var s=e.charCodeAt(i);s<128?r[n++]=s:s<2048?(r[n++]=s>>6|192,r[n++]=63&s|128):o(e,i)?(s=65536+((1023&s)<<10)+(1023&e.charCodeAt(++i)),r[n++]=s>>18|240,r[n++]=s>>12&63|128,r[n++]=s>>6&63|128,r[n++]=63&s|128):(r[n++]=s>>12|224,r[n++]=s>>6&63|128,r[n++]=63&s|128)}else for(i=0;i<e.length;i++)r[i]=0|e[i];return r},t.toHex=function(e){for(var t="",r=0;r<e.length;r++)t+=a(e[r].toString(16));return t},t.htonl=s,t.toHex32=function(e,t){for(var r="",n=0;n<e.length;n++){var i=e[n];"little"===t&&(i=s(i)),r+=c(i.toString(16))}return r},t.zero2=a,t.zero8=c,t.join32=function(e,t,r,i){var o=r-t;n(o%4==0);for(var s=new Array(o/4),a=0,c=t;a<s.length;a++,c+=4){var d;d="big"===i?e[c]<<24|e[c+1]<<16|e[c+2]<<8|e[c+3]:e[c+3]<<24|e[c+2]<<16|e[c+1]<<8|e[c],s[a]=d>>>0}return s},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n<e.length;n++,i+=4){var o=e[n];"big"===t?(r[i]=o>>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<<t|e>>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,s=(o<n?1:0)+r+i;e[t]=s>>>0,e[t+1]=o},t.sum64_hi=function(e,t,r,n){return(t+n>>>0<t?1:0)+e+r>>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,o,s,a){var c=0,d=t;return c+=(d=d+n>>>0)<t?1:0,c+=(d=d+o>>>0)<o?1:0,e+r+i+s+(c+=(d=d+a>>>0)<a?1:0)>>>0},t.sum64_4_lo=function(e,t,r,n,i,o,s,a){return t+n+o+a>>>0},t.sum64_5_hi=function(e,t,r,n,i,o,s,a,c,d){var f=0,h=t;return f+=(h=h+n>>>0)<t?1:0,f+=(h=h+o>>>0)<o?1:0,f+=(h=h+a>>>0)<a?1:0,e+r+i+s+c+(f+=(h=h+d>>>0)<d?1:0)>>>0},t.sum64_5_lo=function(e,t,r,n,i,o,s,a,c,d){return t+n+o+a+d>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},527:(e,t,r)=>{"use strict";var n=r(1048).hp,i=r(3330);function o(e,t){return void 0===t&&(t="utf8"),n.isBuffer(e)?a(e.toString("base64")):a(n.from(e,t).toString("base64"))}function s(e){return e=e.toString(),i.default(e).replace(/\-/g,"+").replace(/_/g,"/")}function a(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var c=o;c.encode=o,c.decode=function(e,t){return void 0===t&&(t="utf8"),n.from(s(e),"base64").toString(t)},c.toBase64=s,c.fromBase64=a,c.toBuffer=function(e){return n.from(s(e),"base64")},t.default=c},528:(e,t,r)=>{"use strict";var n,i=r(9629),o=r(9838),s=r(9110),a=r(1155),c=r(4943),d=r(5731),f=r(3468),h=r(2140),u=r(8479),l=r(8449),p=r(8129),b=r(2387),y=r(5865),m=r(1319),g=r(6882),v=Function,w=function(e){try{return v('"use strict"; return ('+e+").constructor;")()}catch(e){}},S=r(9336),_=r(4940),A=function(){throw new f},M=S?function(){try{return A}catch(e){try{return S(arguments,"callee").get}catch(e){return A}}}():A,E=r(3558)(),P=r(6369),x=r(7345),k=r(7859),I=r(6095),O=r(4531),T={},C="undefined"!=typeof Uint8Array&&P?P(Uint8Array):n,R={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"%ArrayIteratorPrototype%":E&&P?P([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":T,"%AsyncGenerator%":T,"%AsyncGeneratorFunction%":T,"%AsyncIteratorPrototype%":T,"%Atomics%":"undefined"==typeof Atomics?n:Atomics,"%BigInt%":"undefined"==typeof BigInt?n:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?n:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":o,"%eval%":eval,"%EvalError%":s,"%Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?n:FinalizationRegistry,"%Function%":v,"%GeneratorFunction%":T,"%Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":E&&P?P(P([][Symbol.iterator]())):n,"%JSON%":"object"==typeof JSON?JSON:n,"%Map%":"undefined"==typeof Map?n:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&E&&P?P((new Map)[Symbol.iterator]()):n,"%Math%":Math,"%Number%":Number,"%Object%":i,"%Object.getOwnPropertyDescriptor%":S,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?n:Promise,"%Proxy%":"undefined"==typeof Proxy?n:Proxy,"%RangeError%":a,"%ReferenceError%":c,"%Reflect%":"undefined"==typeof Reflect?n:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?n:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&E&&P?P((new Set)[Symbol.iterator]()):n,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":E&&P?P(""[Symbol.iterator]()):n,"%Symbol%":E?Symbol:n,"%SyntaxError%":d,"%ThrowTypeError%":M,"%TypedArray%":C,"%TypeError%":f,"%Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"%URIError%":h,"%WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?n:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?n:WeakSet,"%Function.prototype.call%":O,"%Function.prototype.apply%":I,"%Object.defineProperty%":_,"%Object.getPrototypeOf%":x,"%Math.abs%":u,"%Math.floor%":l,"%Math.max%":p,"%Math.min%":b,"%Math.pow%":y,"%Math.round%":m,"%Math.sign%":g,"%Reflect.getPrototypeOf%":k};if(P)try{null.error}catch(e){var N=P(P(e));R["%Error.prototype%"]=N}var L=function e(t){var r;if("%AsyncFunction%"===t)r=w("async function () {}");else if("%GeneratorFunction%"===t)r=w("function* () {}");else if("%AsyncGeneratorFunction%"===t)r=w("async function* () {}");else if("%AsyncGenerator%"===t){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===t){var i=e("%AsyncGenerator%");i&&P&&(r=P(i.prototype))}return R[t]=r,r},B={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},U=r(9138),D=r(8554),F=U.call(O,Array.prototype.concat),K=U.call(I,Array.prototype.splice),j=U.call(O,String.prototype.replace),q=U.call(O,String.prototype.slice),$=U.call(O,RegExp.prototype.exec),z=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,H=/\\(\\)?/g,J=function(e,t){var r,n=e;if(D(B,n)&&(n="%"+(r=B[n])[0]+"%"),D(R,n)){var i=R[n];if(i===T&&(i=L(n)),void 0===i&&!t)throw new f("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new d("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new f("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new f('"allowMissing" argument must be a boolean');if(null===$(/^%?[^%]*%?$/,e))throw new d("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(e){var t=q(e,0,1),r=q(e,-1);if("%"===t&&"%"!==r)throw new d("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new d("invalid intrinsic syntax, expected opening `%`");var n=[];return j(e,z,(function(e,t,r,i){n[n.length]=r?j(i,H,"$1"):t||e})),n}(e),n=r.length>0?r[0]:"",i=J("%"+n+"%",t),o=i.name,s=i.value,a=!1,c=i.alias;c&&(n=c[0],K(r,F([0,1],c)));for(var h=1,u=!0;h<r.length;h+=1){var l=r[h],p=q(l,0,1),b=q(l,-1);if(('"'===p||"'"===p||"`"===p||'"'===b||"'"===b||"`"===b)&&p!==b)throw new d("property names with quotes must have matching quotes");if("constructor"!==l&&u||(a=!0),D(R,o="%"+(n+="."+l)+"%"))s=R[o];else if(null!=s){if(!(l in s)){if(!t)throw new f("base intrinsic for "+e+" exists, but the property is not available.");return}if(S&&h+1>=r.length){var y=S(s,l);s=(u=!!y)&&"get"in y&&!("originalValue"in y.get)?y.get:s[l]}else u=D(s,l),s=s[l];u&&!a&&(R[o]=s)}}return s}},536:(e,t,r)=>{"use strict";var n=r(461),i=r(2191),o=r(600),s=r(7784),a=n.sum32,c=n.sum32_4,d=n.sum32_5,f=o.ch32,h=o.maj32,u=o.s0_256,l=o.s1_256,p=o.g0_256,b=o.g1_256,y=i.BlockHash,m=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function g(){if(!(this instanceof g))return new g;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=m,this.W=new Array(64)}n.inherits(g,y),e.exports=g,g.blockSize=512,g.outSize=256,g.hmacStrength=192,g.padLength=64,g.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n<r.length;n++)r[n]=c(b(r[n-2]),r[n-7],p(r[n-15]),r[n-16]);var i=this.h[0],o=this.h[1],y=this.h[2],m=this.h[3],g=this.h[4],v=this.h[5],w=this.h[6],S=this.h[7];for(s(this.k.length===r.length),n=0;n<r.length;n++){var _=d(S,l(g),f(g,v,w),this.k[n],r[n]),A=a(u(i),h(i,o,y));S=w,w=v,v=g,g=a(m,_),m=y,y=o,o=i,i=a(_,A)}this.h[0]=a(this.h[0],i),this.h[1]=a(this.h[1],o),this.h[2]=a(this.h[2],y),this.h[3]=a(this.h[3],m),this.h[4]=a(this.h[4],g),this.h[5]=a(this.h[5],v),this.h[6]=a(this.h[6],w),this.h[7]=a(this.h[7],S)},g.prototype._digest=function(e){return"hex"===e?n.toHex32(this.h,"big"):n.split32(this.h,"big")}},600:(e,t,r)=>{"use strict";var n=r(461).rotr32;function i(e,t,r){return e&t^~e&r}function o(e,t,r){return e&t^e&r^t&r}function s(e,t,r){return e^t^r}t.ft_1=function(e,t,r,n){return 0===e?i(t,r,n):1===e||3===e?s(t,r,n):2===e?o(t,r,n):void 0},t.ch32=i,t.maj32=o,t.p32=s,t.s0_256=function(e){return n(e,2)^n(e,13)^n(e,22)},t.s1_256=function(e){return n(e,6)^n(e,11)^n(e,25)},t.g0_256=function(e){return n(e,7)^n(e,18)^e>>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},686:(e,t,r)=>{"use strict";var n=r(4940),i=r(5731),o=r(3468),s=r(9336);e.exports=function(e,t,r){if(!e||"object"!=typeof e&&"function"!=typeof e)throw new o("`obj` must be an object or a function`");if("string"!=typeof t&&"symbol"!=typeof t)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var a=arguments.length>3?arguments[3]:null,c=arguments.length>4?arguments[4]:null,d=arguments.length>5?arguments[5]:null,f=arguments.length>6&&arguments[6],h=!!s&&s(e,t);if(n)n(e,t,{configurable:null===d&&h?h.configurable:!d,enumerable:null===a&&h?h.enumerable:!a,value:r,writable:null===c&&h?h.writable:!c});else{if(!f&&(a||c||d))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=r}}},888:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var n=r(5880);const i=r.n(n)().getLogger("torus.js");i.disableAll()},968:e=>{"use strict";var t=Object.prototype.toString;e.exports=function(e){var r=t.call(e),n="[object Arguments]"===r;return n||(n="[object Array]"!==r&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===t.call(e.callee)),n}},1048:(e,t,r)=>{"use strict";const n=r(7991),i=r(9318),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.hp=c,t.IS=50;const s=2147483647;function a(e){if(e>s)throw new RangeError('The value "'+e+'" is invalid for option "size"');const t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(e,t,r){if("number"==typeof e){if("string"==typeof t)throw new TypeError('The "string" argument must be of type string. Received type number');return h(e)}return d(e,t,r)}function d(e,t,r){if("string"==typeof e)return function(e,t){if("string"==typeof t&&""!==t||(t="utf8"),!c.isEncoding(t))throw new TypeError("Unknown encoding: "+t);const r=0|b(e,t);let n=a(r);const i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}(e,t);if(ArrayBuffer.isView(e))return function(e){if(W(e,Uint8Array)){const t=new Uint8Array(e);return l(t.buffer,t.byteOffset,t.byteLength)}return u(e)}(e);if(null==e)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(W(e,ArrayBuffer)||e&&W(e.buffer,ArrayBuffer))return l(e,t,r);if("undefined"!=typeof SharedArrayBuffer&&(W(e,SharedArrayBuffer)||e&&W(e.buffer,SharedArrayBuffer)))return l(e,t,r);if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=e.valueOf&&e.valueOf();if(null!=n&&n!==e)return c.from(n,t,r);const i=function(e){if(c.isBuffer(e)){const t=0|p(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||V(e.length)?a(0):u(e):"Buffer"===e.type&&Array.isArray(e.data)?u(e.data):void 0}(e);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function f(e){if("number"!=typeof e)throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return f(e),a(e<0?0:0|p(e))}function u(e){const t=e.length<0?0:0|p(e.length),r=a(t);for(let n=0;n<t;n+=1)r[n]=255&e[n];return r}function l(e,t,r){if(t<0||e.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw new RangeErro