@blockcerts/blockcerts-verifier 1.68.0 → 1.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle-stats.html +2229 -2122
- package/dist/{EcdsaSd2023-CJsktwwK-COovFO-E.js → EcdsaSd2023-DcsELLJj-DreWzXlX.js} +9 -9
- package/dist/EcdsaSecp256k1Signature2019-Cy1mIkjt-DJmj4ZAc.js +1 -0
- package/dist/{Ed25519Signature2020-D3owGts_-BB1fBq0Z.js → Ed25519Signature2020-B-CFC9WC-DJkVVmwk.js} +6 -6
- package/dist/{MerkleProof2017-BrDGNMx2-Ct7-Dmh5.js → MerkleProof2017-DqA3Y12J-D6qS7nCf.js} +1 -1
- package/dist/{MerkleProof2019-D70TTI_--BhNFm4-a.js → MerkleProof2019-B4HSvmJo-Cwc-hu-Y.js} +2 -2
- package/dist/checkCredentialSchemaConformity-ChaCRIqw-7U54o8BA.js +1 -0
- package/dist/controlVerificationMethod-qY02GU_H-B-4U8WJQ.js +1 -0
- package/dist/{did-key-common.esm-D_08iodm-FY3lD1HA.js → did-key-common.esm-nDfdwcKN-BTWid9-w.js} +3 -3
- package/dist/{did-key-ed25519.esm-Cah33z_9-CXstsY-H.js → did-key-ed25519.esm-DNra0jwE-CTwAEzy6.js} +1 -1
- package/dist/{did-key-secp256k1.esm-C27OwLgS-C9mjnb5S.js → did-key-secp256k1.esm-Dv1NXpDw-_M-qRy-N.js} +1 -1
- package/dist/{downloadPDF-XZlmMePj.js → downloadPDF-DQVfeIBI.js} +8 -8
- package/dist/{index-Bxtpkwnp-BkEvuYc3.js → index-BM3knvQR-D4vxi3Vi.js} +15 -15
- package/dist/{index-PZL1xHXK-CH1Nkb1O.js → index-Bi-O7G4n-Bgz40JYf.js} +7 -7
- package/dist/{index-Br-3L8ut-BI4gpx_q.js → index-ButIU7pZ-Djl5IfSw.js} +1 -1
- package/dist/{index.es-B13oYDrC.js → index.es-BqQdvz5C.js} +2 -2
- package/dist/main.js +112 -112
- package/dist/purify.es-DJj7iNgQ.js +2 -0
- package/dist/{retrieveVerificationMethodPublicKey-DMLSSemm-uQidviAv.js → retrieveVerificationMethodPublicKey-6-rH9LB2-DvFOhdlW.js} +1 -1
- package/dist/verifyIssuerProfile-DnjbDuXe-BVFzyjSL.js +1 -0
- package/dist/{webcrypto.es-CjDwtULr-D7dA51Yn.js → webcrypto.es-BxABHF-B-TCzLuarM.js} +1 -1
- package/package.json +4 -4
- package/dist/EcdsaSecp256k1Signature2019-hg62McNW-DMCKToe3.js +0 -1
- package/dist/checkCredentialSchemaConformity-D7h9tZ1Y-B0tA00kY.js +0 -1
- package/dist/controlVerificationMethod-DPnoI09o-D_Ktjb-C.js +0 -1
- package/dist/purify-hA3K4SAZ.js +0 -2
- /package/dist/{HashlinkVerifier-BE8mYTIj-dg5WNZnc.js → HashlinkVerifier-hQgVXluZ-dg5WNZnc.js} +0 -0
- /package/dist/{checkRevocationStatusList2021-CtVHNZ7k-XCu3zkCJ.js → checkRevocationStatusList2021-CPFaTtUR-XCu3zkCJ.js} +0 -0
- /package/dist/{elliptic-D7vAoLbk-DQmYEk-8.js → elliptic-D-ZnlFdt-DQmYEk-8.js} +0 -0
- /package/dist/{ensureNotRevoked-BEtBmERU-DvMIgM4L.js → ensureNotRevoked-D9FFjDJd-DvMIgM4L.js} +0 -0
- /package/dist/{ensureValidIssuingKey-BrJmJb4L-wu9SdYxL.js → ensureValidIssuingKey-Cz0isOdi-wu9SdYxL.js} +0 -0
- /package/dist/{index-BeIcTgye-C0eXpZGn.js → index-0q2-1l6i-C0eXpZGn.js} +0 -0
- /package/dist/{index-CQB1Suna-Dgus2xdV.js → index-ZJb8DPW9-Dgus2xdV.js} +0 -0
- /package/dist/{jsonld-D-rUqx_B-CQeQQNYP.js → jsonld-CQCA9cVk-CQeQQNYP.js} +0 -0
- /package/dist/{sha256-BIbQVOZh-C1PUWFZm.js → sha256-BIUNvBZY-C1PUWFZm.js} +0 -0
- /package/dist/{x25519-C5Qlh_Lh-NSl6svWQ.js → x25519-CEFq6uo8-NSl6svWQ.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,B as t,u as r,x as n,i as o,y as i,p as s}from"./main.js";import{r as a,a as c,c as u,b as l,d as f}from"./elliptic-D7vAoLbk-DQmYEk-8.js";var p,h,d,y,b,w,g,m,v,k=r(n),_=r(i),P={exports:{}};function E(){return p||(p=1,function(e,t){var r=c,n=r.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function i(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=i),i.prototype=Object.create(n.prototype),o(n,i),i.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},i.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=n(e);return void 0!==t?"string"==typeof r?o.fill(t,r):o.fill(t):o.fill(0),o},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}(P,P.exports)),P.exports}function S(){if(d)return h;d=1;class e extends Error{constructor(e){super(e||"This operation is not supported for this key type")}}return h=e}function K(){if(b)return y;b=1;class e extends Error{constructor(){super("This has not been implemented yet")}}return y=e}function A(){if(v)return m;v=1;const e=K();return m=class{constructor(e){this.params=e}fromPrivatePKCS1(t){throw new e}fromPrivatePKCS8(t){throw new e}fromPublicPKCS1(t){throw new e}fromPublicPKCS8(t){throw new e}fromPrivateBlk(t){throw new e}fromPublicBlk(t){throw new e}fromJwk(t){throw new e}toPrivatePKCS1(t){throw new e}toPrivatePKCS8(t){throw new e}toPublicPKCS1(t){throw new e}toPublicPKCS8(t){throw new e}toPrivateBlk(t){throw new e}toPublicBlk(t){throw new e}toPrivateJwk(t){throw new e}toPublicJwk(t){throw new e}static formatPem(e,t){return`-----BEGIN ${t} KEY-----\n`+e.match(/.{1,64}/g).join("\n")+`\n-----END ${t} KEY-----`}}}var x,C,B={},j={},U={};function I(){if(C)return x;C=1;var e,t=c,r=t.Buffer,n={};for(e in t)t.hasOwnProperty(e)&&"SlowBuffer"!==e&&"Buffer"!==e&&(n[e]=t[e]);var o=n.Buffer={};for(e in r)r.hasOwnProperty(e)&&"allocUnsafe"!==e&&"allocUnsafeSlow"!==e&&(o[e]=r[e]);if(n.Buffer.prototype=r.prototype,o.from&&o.from!==Uint8Array.from||(o.from=function(e,t,n){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return r(e,t,n)}),o.alloc||(o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var o=r(e);return t&&0!==t.length?"string"==typeof n?o.fill(t,n):o.fill(t):o.fill(0),o}),!n.kStringMaxLength)try{n.kStringMaxLength=s.binding("buffer").kStringMaxLength}catch(e){}return n.constants||(n.constants={MAX_LENGTH:n.kMaxLength},n.kStringMaxLength&&(n.constants.MAX_STRING_LENGTH=n.kStringMaxLength)),x=n}var T,q={};function N(){if(T)return q;T=1;const e=l();function t(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function r(e,t){this.path=e,this.rethrow(t)}return q.Reporter=t,t.prototype.isError=function(e){return e instanceof r},t.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},t.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},t.prototype.enterKey=function(e){return this._reporterState.path.push(e)},t.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},t.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},t.prototype.path=function(){return this._reporterState.path.join("/")},t.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},t.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},t.prototype.error=function(e){let t;const n=this._reporterState,o=e instanceof r;if(t=o?e:new r(n.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!n.options.partial)throw t;return o||n.errors.push(t),t},t.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},e(r,Error),r.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,r),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this},q}var z,O,R,D={};function V(){if(z)return D;z=1;const e=l(),t=N().Reporter,r=I().Buffer;function n(e,n){t.call(this,n),r.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function o(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return o.isEncoderBuffer(e)||(e=new o(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=r.byteLength(e);else{if(!r.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}return e(n,t),D.DecoderBuffer=n,n.isDecoderBuffer=function(e){if(e instanceof n)return!0;return"object"==typeof e&&r.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},n.prototype.save=function(){return{offset:this.offset,reporter:t.prototype.save.call(this)}},n.prototype.restore=function(e){const r=new n(this.base);return r.offset=e.offset,r.length=this.offset,this.offset=e.offset,t.prototype.restore.call(this,e.reporter),r},n.prototype.isEmpty=function(){return this.offset===this.length},n.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},n.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const r=new n(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},n.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},D.EncoderBuffer=o,o.isEncoderBuffer=function(e){if(e instanceof o)return!0;return"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},o.prototype.join=function(e,t){return e||(e=r.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(e,t),t+=r.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):r.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e},D}function L(){if(R)return O;R=1;const e=N().Reporter,t=V().EncoderBuffer,r=V().DecoderBuffer,n=f(),o=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],i=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(o);function s(e,t,r){const n={};this._baseState=n,n.name=r,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}O=s;const a=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];return s.prototype.clone=function(){const e=this._baseState,t={};a.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},s.prototype._wrap=function(){const e=this._baseState;i.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},s.prototype._init=function(e){const t=this._baseState;n(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),n.equal(t.children.length,1,"Root node can have only one child")},s.prototype._useArgs=function(e){const t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(n(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(n(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);const n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){s.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),o.forEach((function(e){s.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return n(null===t.tag),t.tag=e,this._useArgs(r),this}})),s.prototype.use=function(e){n(e);const t=this._baseState;return n(null===t.use),t.use=e,this},s.prototype.optional=function(){return this._baseState.optional=!0,this},s.prototype.def=function(e){const t=this._baseState;return n(null===t.default),t.default=e,t.optional=!0,this},s.prototype.explicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.explicit=e,this},s.prototype.implicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.implicit=e,this},s.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},s.prototype.key=function(e){const t=this._baseState;return n(null===t.key),t.key=e,this},s.prototype.any=function(){return this._baseState.any=!0,this},s.prototype.choice=function(e){const t=this._baseState;return n(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},s.prototype.contains=function(e){const t=this._baseState;return n(null===t.use),t.contains=e,this},s.prototype._decode=function(e,t){const n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));let o,i=n.default,s=!0,a=null;if(null!==n.key&&(a=e.enterKey(n.key)),n.optional){let r=null;if(null!==n.explicit?r=n.explicit:null!==n.implicit?r=n.implicit:null!==n.tag&&(r=n.tag),null!==r||n.any){if(s=this._peekTag(e,r,n.any),e.isError(s))return s}else{const r=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),s=!0}catch(e){s=!1}e.restore(r)}}if(n.obj&&s&&(o=e.enterObject()),s){if(null!==n.explicit){const t=this._decodeTag(e,n.explicit);if(e.isError(t))return t;e=t}const o=e.offset;if(null===n.use&&null===n.choice){let t;n.any&&(t=e.save());const r=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(r))return r;n.any?i=e.raw(t):e=r}if(t&&t.track&&null!==n.tag&&t.track(e.path(),o,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),n.any||(i=null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(r){r._decode(e,t)})),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){const o=new r(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(o,t)}}return n.obj&&s&&(i=e.leaveObject(o)),null===n.key||null===i&&!0!==s?null!==a&&e.exitKey(a):e.leaveKey(a,n.key,i),i},s.prototype._decodeGeneric=function(e,t,r){const n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},s.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),n(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},s.prototype._decodeChoice=function(e,t){const r=this._baseState;let n=null,o=!1;return Object.keys(r.choice).some((function(i){const s=e.save(),a=r.choice[i];try{const r=a._decode(e,t);if(e.isError(r))return!1;n={type:i,value:r},o=!0}catch(t){return e.restore(s),!1}return!0}),this),o?n:e.error("Choice not matched")},s.prototype._createEncoderBuffer=function(e){return new t(e,this.reporter)},s.prototype._encode=function(e,t,r){const n=this._baseState;if(null!==n.default&&n.default===e)return;const o=this._encodeValue(e,t,r);return void 0===o||this._skipDefault(o,t,r)?void 0:o},s.prototype._encodeValue=function(t,r,n){const o=this._baseState;if(null===o.parent)return o.children[0]._encode(t,r||new e);let i=null;if(this.reporter=r,o.optional&&void 0===t){if(null===o.default)return;t=o.default}let s=null,a=!1;if(o.any)i=this._createEncoderBuffer(t);else if(o.choice)i=this._encodeChoice(t,r);else if(o.contains)s=this._getUse(o.contains,n)._encode(t,r),a=!0;else if(o.children)s=o.children.map((function(e){if("null_"===e._baseState.tag)return e._encode(null,r,t);if(null===e._baseState.key)return r.error("Child should have a key");const n=r.enterKey(e._baseState.key);if("object"!=typeof t)return r.error("Child expected, but input is not object");const o=e._encode(t[e._baseState.key],r,t);return r.leaveKey(n),o}),this).filter((function(e){return e})),s=this._createEncoderBuffer(s);else if("seqof"===o.tag||"setof"===o.tag){if(!o.args||1!==o.args.length)return r.error("Too many args for : "+o.tag);if(!Array.isArray(t))return r.error("seqof/setof, but data is not Array");const e=this.clone();e._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(e){const n=this._baseState;return this._getUse(n.args[0],t)._encode(e,r)}),e))}else null!==o.use?i=this._getUse(o.use,n)._encode(t,r):(s=this._encodePrimitive(o.tag,t),a=!0);if(!o.any&&null===o.choice){const e=null!==o.implicit?o.implicit:o.tag,t=null===o.implicit?"universal":"context";null===e?null===o.use&&r.error("Tag could be omitted only for .use()"):null===o.use&&(i=this._encodeComposite(e,a,t,s))}return null!==o.explicit&&(i=this._encodeComposite(o.explicit,!1,"context",i)),i},s.prototype._encodeChoice=function(e,t){const r=this._baseState,o=r.choice[e.type];return o||n(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),o._encode(e.value,t)},s.prototype._encodePrimitive=function(e,t){const r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},s.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},s.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)},O}var M,J,$,F,Z,G,Y={};function H(){return M||(M=1,function(e){function t(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t}e.tagClass={0:"universal",1:"application",2:"context",3:"private"},e.tagClassByName=t(e.tagClass),e.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},e.tagByName=t(e.tag)}(Y)),Y}function X(){if($)return J;$=1;const e=l(),t=I().Buffer,r=L(),n=H();function o(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new i,this.tree._init(e.body)}function i(e){r.call(this,"der",e)}function s(e){return e<10?"0"+e:e}return J=o,o.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},e(i,r),i.prototype._encodeComposite=function(e,r,o,i){const s=function(e,t,r,o){let i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(n.tagByName.hasOwnProperty(e))i=n.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return o.error("Unknown tag: "+e);i=e}if(i>=31)return o.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=n.tagClassByName[r||"universal"]<<6,i}(e,r,o,this.reporter);if(i.length<128){const e=t.alloc(2);return e[0]=s,e[1]=i.length,this._createEncoderBuffer([e,i])}let a=1;for(let e=i.length;e>=256;e>>=8)a++;const c=t.alloc(2+a);c[0]=s,c[1]=128|a;for(let e=1+a,t=i.length;t>0;e--,t>>=8)c[e]=255&t;return this._createEncoderBuffer([c,i])},i.prototype._encodeStr=function(e,r){if("bitstr"===r)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===r){const r=t.alloc(2*e.length);for(let t=0;t<e.length;t++)r.writeUInt16BE(e.charCodeAt(t),2*t);return this._createEncoderBuffer(r)}return"numstr"===r?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===r?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(r)||"objDesc"===r?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+r+" unsupported")},i.prototype._encodeObjid=function(e,r,n){if("string"==typeof e){if(!r)return this.reporter.error("string objid given, but no values map found");if(!r.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=r[e].split(/[\s.]+/g);for(let t=0;t<e.length;t++)e[t]|=0}else if(Array.isArray(e)){e=e.slice();for(let t=0;t<e.length;t++)e[t]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!n){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let o=0;for(let t=0;t<e.length;t++){let r=e[t];for(o++;r>=128;r>>=7)o++}const i=t.alloc(o);let s=i.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(i[s--]=127&r;(r>>=7)>0;)i[s--]=128|127&r}return this._createEncoderBuffer(i)},i.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[s(n.getUTCFullYear()),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[s(n.getUTCFullYear()%100),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},i.prototype._encodeNull=function(){return this._createEncoderBuffer("")},i.prototype._encodeInt=function(e,r){if("string"==typeof e){if(!r)return this.reporter.error("String int or enum given, but no values map");if(!r.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=r[e]}if("number"!=typeof e&&!t.isBuffer(e)){const r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=t.from(r)}if(t.isBuffer(e)){let r=e.length;0===e.length&&r++;const n=t.alloc(r);return e.copy(n),0===e.length&&(n[0]=0),this._createEncoderBuffer(n)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let n=1;for(let t=e;t>=256;t>>=8)n++;const o=new Array(n);for(let t=o.length-1;t>=0;t--)o[t]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(t.from(o))},i.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},i.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},i.prototype._skipDefault=function(e,t,r){const n=this._baseState;let o;if(null===n.default)return!1;const i=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),i.length!==n.defaultBuffer.length)return!1;for(o=0;o<i.length;o++)if(i[o]!==n.defaultBuffer[o])return!1;return!0},J}function W(){return G||(G=1,function(e){const t=e;t.der=X(),t.pem=function(){if(Z)return F;Z=1;const e=l(),t=X();function r(e){t.call(this,e),this.enc="pem"}return e(r,t),F=r,r.prototype.encode=function(e,r){const n=t.prototype.encode.call(this,e).toString("base64"),o=["-----BEGIN "+r.label+"-----"];for(let e=0;e<n.length;e+=64)o.push(n.slice(e,e+64));return o.push("-----END "+r.label+"-----"),o.join("\n")},F}()}(U)),U}var Q,ee,te,re,ne,oe,ie={};function se(){if(ee)return Q;ee=1;const e=l(),t=u(),r=V().DecoderBuffer,n=L(),o=H();function i(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new s,this.tree._init(e.body)}function s(e){n.call(this,"der",e)}function a(e,t){let r=e.readUInt8(t);if(e.isError(r))return r;const n=o.tagClass[r>>6],i=!(32&r);if(31&~r)r&=31;else{let n=r;for(r=0;!(128&~n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}return{cls:n,primitive:i,tag:r,tagStr:o.tag[r]}}function c(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(!(128&n))return n;const o=127&n;if(o>4)return e.error("length octect is too long");n=0;for(let t=0;t<o;t++){n<<=8;const t=e.readUInt8(r);if(e.isError(t))return t;n|=t}return n}return Q=i,i.prototype.decode=function(e,t){return r.isDecoderBuffer(e)||(e=new r(e,t)),this.tree._decode(e,t)},e(s,n),s.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;const n=e.save(),o=a(e,'Failed to peek tag: "'+t+'"');return e.isError(o)?o:(e.restore(n),o.tag===t||o.tagStr===t||o.tagStr+"of"===t||r)},s.prototype._decodeTag=function(e,t,r){const n=a(e,'Failed to decode tag of "'+t+'"');if(e.isError(n))return n;let o=c(e,n.primitive,'Failed to get length of "'+t+'"');if(e.isError(o))return o;if(!r&&n.tag!==t&&n.tagStr!==t&&n.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(n.primitive||null!==o)return e.skip(o,'Failed to match body of: "'+t+'"');const i=e.save(),s=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(s)?s:(o=e.offset-i.offset,e.restore(i),e.skip(o,'Failed to match body of: "'+t+'"'))},s.prototype._skipUntilEnd=function(e,t){for(;;){const r=a(e,t);if(e.isError(r))return r;const n=c(e,r.primitive,t);if(e.isError(n))return n;let o;if(o=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(o))return o;if("end"===r.tagStr)break}},s.prototype._decodeList=function(e,t,r,n){const o=[];for(;!e.isEmpty();){const t=this._peekTag(e,"end");if(e.isError(t))return t;const i=r.decode(e,"der",n);if(e.isError(i)&&t)break;o.push(i)}return o},s.prototype._decodeStr=function(e,t){if("bitstr"===t){const t=e.readUInt8();return e.isError(t)?t:{unused:t,data:e.raw()}}if("bmpstr"===t){const t=e.raw();if(t.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");let r="";for(let e=0;e<t.length/2;e++)r+=String.fromCharCode(t.readUInt16BE(2*e));return r}if("numstr"===t){const t=e.raw().toString("ascii");return this._isNumstr(t)?t:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){const t=e.raw().toString("ascii");return this._isPrintstr(t)?t:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},s.prototype._decodeObjid=function(e,t,r){let n;const o=[];let i=0,s=0;for(;!e.isEmpty();)s=e.readUInt8(),i<<=7,i|=127&s,128&s||(o.push(i),i=0);128&s&&o.push(i);const a=o[0]/40|0,c=o[0]%40;if(n=r?o:[a,c].concat(o.slice(1)),t){let e=t[n.join(" ")];void 0===e&&(e=t[n.join(".")]),void 0!==e&&(n=e)}return n},s.prototype._decodeTime=function(e,t){const r=e.raw().toString();let n,o,i,s,a,c;if("gentime"===t)n=0|r.slice(0,4),o=0|r.slice(4,6),i=0|r.slice(6,8),s=0|r.slice(8,10),a=0|r.slice(10,12),c=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");n=0|r.slice(0,2),o=0|r.slice(2,4),i=0|r.slice(4,6),s=0|r.slice(6,8),a=0|r.slice(8,10),c=0|r.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,o-1,i,s,a,c,0)},s.prototype._decodeNull=function(){return null},s.prototype._decodeBool=function(e){const t=e.readUInt8();return e.isError(t)?t:0!==t},s.prototype._decodeInt=function(e,r){const n=e.raw();let o=new t(n);return r&&(o=r[o.toString(10)]||o),o},s.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree},Q}function ae(){return ne||(ne=1,function(e){const t=e;t.der=se(),t.pem=function(){if(re)return te;re=1;const e=l(),t=I().Buffer,r=se();function n(e){r.call(this,e),this.enc="pem"}return e(n,r),te=n,n.prototype.decode=function(e,n){const o=e.toString().split(/[\r\n]+/g),i=n.label.toUpperCase(),s=/^-----(BEGIN|END) ([^-]+)-----$/;let a=-1,c=-1;for(let e=0;e<o.length;e++){const t=o[e].match(s);if(null!==t&&t[2]===i){if(-1!==a){if("END"!==t[1])break;c=e;break}if("BEGIN"!==t[1])break;a=e}}if(-1===a||-1===c)throw new Error("PEM section not found for: "+i);const u=o.slice(a+1,c).join("");u.replace(/[^a-z0-9+/=]+/gi,"");const l=t.from(u,"base64");return r.prototype.decode.call(this,l,n)},te}()}(ie)),ie}var ce,ue={};var le,fe,pe={};function he(){return fe||(fe=1,function(){const e=B;e.bignum=u(),e.define=(oe||(oe=1,function(e){const t=W(),r=ae(),n=l();function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}e.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){const t=this.name;function r(e){this._initNamed(e,t)}return n(r,e),r.prototype._initNamed=function(t,r){e.call(this,t,r)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(r[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(t[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}}(j)),j).define,e.base=(ce||(ce=1,function(e){const t=e;t.Reporter=N().Reporter,t.DecoderBuffer=V().DecoderBuffer,t.EncoderBuffer=V().EncoderBuffer,t.Node=L()}(ue)),ue),e.constants=(le||(le=1,function(e){const t=e;t._reverse=function(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t},t.der=H()}(pe)),pe),e.decoders=ae(),e.encoders=W()}()),B}var de,ye,be,we,ge,me,ve,ke,_e,Pe,Ee,Se,Ke,Ae,xe,Ce,Be,je,Ue,Ie,Te,qe,Ne,ze,Oe,Re,De,Ve,Le,Me,Je,$e,Fe,Ze,Ge,Ye={exports:{}},He={},Xe={};function We(){if(ye)return He;ye=1,Object.defineProperty(He,"__esModule",{value:!0});var e=(de||(de=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.default=function(e){var r=e.length,n=r%4;if(!n)return e;var o=r,i=4-n,s=r+i,a=t.alloc(s);for(a.write(e);i--;)a.write("=",o++);return a.toString()}),Xe);function r(e,r){return void 0===r&&(r="utf8"),o(e)?i(e.toString("base64")):i(t.from(e,r).toString("base64"))}function n(t){return t=t.toString(),e.default(t).replace(/\-/g,"+").replace(/_/g,"/")}function i(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var s=r;return s.encode=r,s.decode=function(e,r){return void 0===r&&(r="utf8"),t.from(n(e),"base64").toString(r)},s.toBase64=n,s.fromBase64=i,s.toBuffer=function(e){return t.from(n(e),"base64")},He.default=s,He}function Qe(){return be||(be=1,(e=Ye).exports=We().default,e.exports.default=e.exports),Ye.exports;var e}function et(){if(ge)return we;ge=1;const e=he(),r=Qe();return we=class{static convert(n,o,i){if(!n)return;if(o===i)return n;let s;if("raw"===o||n instanceof t)s=n;else if("uint8_array"===o||Array.isArray(n))s=t.from(n);else if("hex"===o)s=t.from(n,"hex");else if("base64"===o)s=t.from(n,"base64");else if("base64url"===o)s=r.toBuffer(n);else{if("bn"!==o&&"bignum"!==o)throw new Error("Invalid fromType");s=t.from(this.pad(n.toString(16)),"hex")}if("raw"===i)return s;if("uint8_array"===i)return Array.from(s);if("hex"===i)return s.toString("hex");if("base64"===i)return s.toString("base64");if("base64url"===i)return r.fromBase64(s.toString("base64"));if("bn"===i||"bignum"===i)return new e.bignum(s);throw new Error("Invalid toType")}static pad(e){return e.length%2==1?`0${e}`:e}},we}function tt(){if(Oe)return ze;Oe=1;const e=new(function(){if(ve)return me;ve=1;const e=he();return me=class{constructor(){Object.defineProperty(this,"_registry",{value:{}})}get registry(){return this._registry}define(t,r){this._registry[t]=e.define(t,r(this))}normalize(e){return this.registry[e]}}}());return e.define("Version",_e?ke:(_e=1,ke=e=>function(){this.int({0:"two-prime",1:"multi"})})),e.define("OtherPrimeInfos",Ee?Pe:(Ee=1,Pe=e=>function(){this.seq().obj(this.key("ri").int(),this.key("di").int(),this.key("ti").int())})),e.define("AlgorithmIdentifier",Ke?Se:(Ke=1,Se=e=>function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())})),e.define("PrivateKeyInfo",(xe||(xe=1,Ae=e=>{let t=e.normalize("Version"),r=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("version").use(t),this.key("algorithm").use(r),this.key("privateKey").octstr())}}),Ae)),e.define("PublicKeyInfo",(Be||(Be=1,Ce=e=>{let t=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("algorithm").use(t),this.key("publicKey").bitstr())}}),Ce)),e.define("RSAPrivateKey",(Ue||(Ue=1,je=e=>{let t=e.normalize("Version"),r=e.normalize("OtherPrimeInfos");return function(){this.seq().obj(this.key("version").use(t),this.key("n").int(),this.key("e").int(),this.key("d").int(),this.key("p").int(),this.key("q").int(),this.key("dp").int(),this.key("dq").int(),this.key("qi").int(),this.key("other").optional().use(r))}}),je)),e.define("RSAPublicKey",Te?Ie:(Te=1,Ie=e=>function(){this.seq().obj(this.key("n").int(),this.key("e").int())})),e.define("ECPrivateKey",Ne?qe:(Ne=1,qe=e=>function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().choice({namedCurve:this.objid()}),this.key("publicKey").explicit(1).optional().bitstr())})),ze=e}function rt(){if(Fe)return $e;Fe=1;const e=g?w:(g=1,w=class{constructor(){this.registry=[],this.classes={}}find(e){return this.registry.find(e)}define(e,t){e.forEach((e=>{let{kty:r}=e;if(!r)throw new Error("Invalid type definition");this.classes[r]||(this.classes[r]=t),this.registry.push(e)}))}normalize(e,t,r){let n=this.classes[e],o=this.find((e=>e[t]===r));if(!n||!o)throw new Error("Invalid type");return new n(o)}}),r=function(){if(De)return Re;De=1;const e=A();S();const r=et(),n=tt();class o extends e{fromPrivatePKCS1(e){let t=n.normalize("RSAPrivateKey"),{n:o,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw"),d:r.convert(s,"bn","raw"),p:r.convert(a,"bn","raw"),q:r.convert(c,"bn","raw"),dp:r.convert(u,"bn","raw"),dq:r.convert(l,"bn","raw"),qi:r.convert(f,"bn","raw")}}fromPrivatePKCS8(e){let t=n.normalize("PrivateKeyInfo"),o=n.normalize("RSAPrivateKey"),i=t.decode(e,"der"),{n:s,e:a,d:c,p:u,q:l,dp:f,dq:p,qi:h}=o.decode(i.privateKey,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw"),d:r.convert(c,"bn","raw"),p:r.convert(u,"bn","raw"),q:r.convert(l,"bn","raw"),dp:r.convert(f,"bn","raw"),dq:r.convert(p,"bn","raw"),qi:r.convert(h,"bn","raw")}}fromPublicPKCS1(e){let t=n.normalize("RSAPublicKey"),{n:o,e:i}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw")}}fromPublicPKCS8(e){let t=n.normalize("PublicKeyInfo"),o=n.normalize("RSAPublicKey"),i=t.decode(e,"der"),{n:s,e:a}=o.decode(i.publicKey.data,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw")}}fromJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u,alg:l}=e;return{n:r.convert(t,"base64url","raw"),e:r.convert(n,"base64url","raw"),d:r.convert(o,"base64url","raw"),p:r.convert(i,"base64url","raw"),q:r.convert(s,"base64url","raw"),dp:r.convert(a,"base64url","raw"),dq:r.convert(c,"base64url","raw"),qi:r.convert(u,"base64url","raw")}}toPrivatePKCS1(e){let{n:t,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=e,{version:p}=this.params,h=n.normalize("RSAPrivateKey").encode({version:p,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn"),d:r.convert(s,"raw","bn"),p:r.convert(a,"raw","bn"),q:r.convert(c,"raw","bn"),dp:r.convert(u,"raw","bn"),dq:r.convert(l,"raw","bn"),qi:r.convert(f,"raw","bn")},"der").toString("base64");return o.formatPem(h,"RSA PRIVATE")}toPrivatePKCS8(e){let{n:i,e:s,d:a,p:c,q:u,dp:l,dq:f,qi:p}=e,{oid:h,algParameters:d,version:y}=this.params,b=n.normalize("PrivateKeyInfo"),w=n.normalize("RSAPrivateKey").encode({version:y,n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn"),d:r.convert(a,"raw","bn"),p:r.convert(c,"raw","bn"),q:r.convert(u,"raw","bn"),dp:r.convert(l,"raw","bn"),dq:r.convert(f,"raw","bn"),qi:r.convert(p,"raw","bn")},"der"),g=b.encode({version:y,algorithm:{algorithm:h.split("."),parameters:t.from(d,"hex")},privateKey:w},"der").toString("base64");return o.formatPem(g,"PRIVATE")}toPublicPKCS1(e){let{n:t,e:i}=e,{version:s}=this.params,a=n.normalize("RSAPublicKey").encode({version:s,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn")},"der").toString("base64");return o.formatPem(a,"RSA PUBLIC")}toPublicPKCS8(e){let{n:i,e:s}=e,{oid:a,algParameters:c}=this.params,u=n.normalize("PublicKeyInfo"),l=n.normalize("RSAPublicKey").encode({n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn")},"der"),f=u.encode({algorithm:{algorithm:a.split("."),parameters:t.from(c,"hex")},publicKey:{unused:0,data:l}},"der").toString("base64");return o.formatPem(f,"PUBLIC")}toPrivateJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u}=e,{kty:l}=this.params;return{kty:l,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url"),d:r.convert(o,"raw","base64url"),p:r.convert(i,"raw","base64url"),q:r.convert(s,"raw","base64url"),dp:r.convert(a,"raw","base64url"),dq:r.convert(c,"raw","base64url"),qi:r.convert(u,"raw","base64url")}}toPublicJwk(e){let{n:t,e:n}=e,{kty:o}=this.params;return{kty:o,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url")}}}return Re=o}(),n=function(){if(Le)return Ve;Le=1,he().bignum;const e=new(0,a().ec)("secp256k1"),r=A();S();const n=et(),o=tt();class i extends r{fromPrivatePKCS1(e){let t=o.normalize("ECPrivateKey").decode(e,"der"),{privateKey:r,publicKey:{data:s}}=t,a=n.convert(s,"raw","hex"),{x:c,y:u}=i.getPoint(a);return{d:r,x:c,y:u}}fromPrivatePKCS8(e){let t=o.normalize("PrivateKeyInfo"),r=o.normalize("ECPrivateKey"),s=t.decode(e,"der"),a=r.decode(s.privateKey,"der"),{privateKey:c,publicKey:{data:u}}=a,l=n.convert(u,"raw","hex"),{x:f,y:p}=i.getPoint(l);return{d:c,x:f,y:p}}fromPublicPKCS8(e){let t=o.normalize("PublicKeyInfo").decode(e,"der"),r=n.convert(t.publicKey.data,"raw","hex");return i.getPoint(r)}fromPrivateBlk(t){let r=e.keyFromPrivate(t,"hex"),o=r.getPublic();return{d:n.convert(r.priv,"bn","raw"),x:n.convert(o.getX(),"bn","raw"),y:n.convert(o.getY(),"bn","raw")}}fromPublicBlk(e){return i.getPoint(e)}fromJwk(e){let{d:t,x:r,y:o}=e;return{d:n.convert(t,"base64url","raw"),x:n.convert(r,"base64url","raw"),y:n.convert(o,"base64url","raw")}}toPrivatePKCS1(e){let{namedCurve:t,keyVersion:r}=this.params,{d:n,x:s,y:a}=e,c=o.normalize("ECPrivateKey"),u=i.makePoint(s,a),l=c.encode({version:r,privateKey:n,parameters:{type:"namedCurve",value:t.split(".")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"EC PRIVATE")}toPrivatePKCS8(e){let{oid:r,algParameters:n,keyVersion:s,infoVersion:a}=this.params,{d:c,x:u,y:l}=e,f=o.normalize("PrivateKeyInfo"),p=o.normalize("ECPrivateKey"),h=i.makePoint(u,l),d=p.encode({version:s,privateKey:c,publicKey:{unused:0,data:h}},"der"),y=f.encode({version:a,algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},privateKey:d},"der").toString("base64");return i.formatPem(y,"PRIVATE")}toPublicPKCS8(e){let{oid:r,algParameters:n}=this.params,{x:s,y:a}=e,c=o.normalize("PublicKeyInfo"),u=i.makePoint(s,a),l=c.encode({algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"PUBLIC")}toPrivateBlk(e){return e.d.toString("hex")}toPublicBlk(e){return n.convert(i.makePoint(e.x,e.y),"raw","hex")}toPrivateJwk(e){let{crv:t,kty:r}=this.params,{d:o,x:i,y:s}=e;return{kty:r,crv:t,d:n.convert(o,"raw","base64url"),x:n.convert(i,"raw","base64url"),y:n.convert(s,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:r}=this.params,{x:o,y:i}=e;return{kty:r,crv:t,x:n.convert(o,"raw","base64url"),y:n.convert(i,"raw","base64url")}}static getPoint(e){let t=e.slice(2,(e.length-2)/2+2),r=e.slice((e.length-2)/2+2);return{x:n.convert(t,"hex","raw"),y:n.convert(r,"hex","raw")}}static makePoint(e,r){let n=t.from("04","hex");return t.concat([n,e,r],n.length+e.length+r.length)}}return Ve=i}(),o=function(){if(Je)return Me;Je=1;const e=A(),r=et(),n=tt();class o extends e{fromPrivatePKCS8(e){const t=n.normalize("PrivateKeyInfo").decode(e,"der").privateKey.slice(2);return{d:t,x:this.publicKeyFromPrivate(t)}}fromPublicPKCS8(e){const t=n.normalize("PublicKeyInfo").decode(e,"der");return{x:r.convert(t.publicKey.data,"hex","raw")}}fromJwk(e){let{d:t,x:n}=e;return{d:r.convert(t,"base64url","raw"),x:r.convert(n,"base64url","raw")}}toPrivatePKCS8(e){let{oid:t,infoVersion:r}=this.params,{d:i}=e;const s=n.normalize("PrivateKeyInfo"),a=this.privateKeyPadding(i);let c=s.encode({version:r,algorithm:{algorithm:t.split(".")},privateKey:a},"der").toString("base64");return o.formatPem(c,"PRIVATE")}toPublicPKCS8(e){let{oid:t}=this.params,{x:i}=e,s=n.normalize("PublicKeyInfo").encode({algorithm:{algorithm:t.split(".")},publicKey:{unused:0,data:r.convert(i,"hex","raw")}},"der").toString("base64");return o.formatPem(s,"PUBLIC")}toPrivateJwk(e){let{crv:t,kty:n}=this.params,{d:o,x:i}=e;return{kty:n,crv:t,d:r.convert(o,"raw","base64url"),x:r.convert(i,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:n}=this.params,{x:o}=e;return{kty:n,crv:t,x:r.convert(o,"raw","base64url")}}privateKeyPadding(e){let r;if("Ed25519"!==this.params.crv)throw new Error(`${this.params.crv} is an invalid curve for EdDSA`);return r=t.from("0420","hex"),t.concat([r,e],r.length+e.length)}publicKeyFromPrivate(e){if("Ed25519"===this.params.crv){const r=new(0,a().eddsa)("ed25519");return t.from(r.keyFromSecret(e).getPublic())}throw new Error(`${this.params.crv} is an invalid curve for EdDSA`)}}return Me=o}(),i=new e;return i.define([{kty:"RSA",oid:"1.2.840.113549.1.1.1",algParameters:"0500",version:"two-prime"}],r),i.define([{kty:"EC",crv:"K-256",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.10",algParameters:"06052b8104000a",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-256",oid:"1.2.840.10045.2.1",namedCurve:"1.2.840.10045.3.1.7",algParameters:"06082a8648ce3d030107",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-384",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.34",algParameters:"06052b81040022",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-521",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.35",algParameters:"06052b81040023",keyVersion:1,infoVersion:"two-prime"}],n),i.define([{kty:"OKP",crv:"Ed25519",oid:"1.3.101.112",infoVersion:"two-prime"}],o),$e=i}var nt,ot,it,st,at,ct,ut=function(){if(Ge)return Ze;Ge=1;const e=S(),r=K(),n=rt(),o=tt(),i=RegExp("\r?\n","g");class s{constructor(t,r){if(!t)throw new e("key is required");if(!r)throw new e("options are required");let{kty:n,format:o,selector:i,crv:s,oid:a}=r;if(!r.kty)throw new e("options.kty is required");if(!r.format)throw new e("options.format is required");if(!r.selector)throw new e("options.selector is required");if(!r.crv&&!r.oid)throw new e("options.crv or options.oid is required");this.kty=n,this.format=o,this.selector=i,this.crv=s,this.oid=a,this.key=this.parseKey(t)}static from(r,a){if(!r)throw new e("key is required");if(!a)throw new e("format is required");if("jwk"===a){let t;if("string"==typeof r)try{t=JSON.parse(r)}catch(t){throw new e("key is not a valid JWK")}else"object"==typeof r&&(t=r);let o,{kty:i,crv:c}=t;if(!i)throw new e("kty is required for JWK");if("EC"===i&&!c)throw new e("crv is required for EC JWK");"RSA"===i&&(o=n.find((e=>e.kty===i)).oid);let u=t.d?"private":"public";return new s(t,{kty:i,crv:c,oid:o,format:a,selector:u})}if("pem"===a){if("string"!=typeof r)throw new e("key is not a valid PEM string");let c=r.split(i),u=c.splice(0,1);c.splice(c.length-1,1);let l,f,p=c.join(""),h=/^-----BEGIN ((RSA|EC) )?(PUBLIC|PRIVATE) KEY-----$/.exec(u),d=h?h[2]:void 0,y=h?h[3]:void 0,b=t.from(p,"base64");if(!y)throw new e("key is not a valid PEM string");if(d){if("RSA"===d)y="PRIVATE"===y?"private_pkcs1":"public_pkcs1",l=n.find((e=>e.kty===d)).oid;else if("EC"===d){let e;if("PRIVATE"===y){y="private_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}else if("PUBLIC"===y){y="public_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}let{parameters:{value:t}}=e;f=n.find((e=>e.namedCurve===t.join("."))).crv}}else{let t,r=o.normalize("PrivateKeyInfo"),i=o.normalize("PublicKeyInfo");"PRIVATE"===y?(y="private_pkcs8",t=r.decode(b,"der")):"PUBLIC"===y&&(y="public_pkcs8",t=i.decode(b,"der"));let{algorithm:{algorithm:s,parameters:a}}=t;s=s.join("."),a=a?a.toString("hex"):void 0;const c=n.find((e=>e.oid===s));if(d=c?c.kty:void 0,!d)throw new e(`${s} is not supported`);"RSA"===d||"OKP"===d?l=s:"EC"===d&&(f=n.find((e=>e.algParameters===a)).crv)}return new s(b,{kty:d,oid:l,crv:f,format:a,selector:y})}if("blk"===a)return new s(r,{kty:"EC",crv:"K-256",format:a,selector:r.length>64?"public":"private"});throw new e(`Invalid format ${a}`)}get alg(){let{kty:e,crv:t,oid:r}=this;if(!this.algorithm){if(t)Object.defineProperty(this,"algorithm",{value:n.normalize(e,"crv",t)});else{if(!r)throw new Error("Both crv and oid are undefined");Object.defineProperty(this,"algorithm",{value:n.normalize(e,"oid",r)})}if(!this.algorithm)throw new Error(`${this.crv||this.oid} is not implemented yet`)}return this.algorithm}parseKey(e){let{alg:t,format:r,selector:n}=this;if("pem"===r)switch(n){case"public_pkcs1":return t.fromPublicPKCS1(e);case"public_pkcs8":return t.fromPublicPKCS8(e);case"private_pkcs1":return t.fromPrivatePKCS1(e);case"private_pkcs8":return t.fromPrivatePKCS8(e);default:throw new Error("Invalid selector value")}if("jwk"===r)return t.fromJwk(e,n);if("blk"===r)switch(n){case"public":return t.fromPublicBlk(e);case"private":return t.fromPrivateBlk(e)}}toJwk(t){let{key:r,alg:n,selector:o}=this;switch(t){case"public":return n.toPublicJwk(r);case"private":if(o.includes("public"))throw new e("Cannot export a private key from a public key");return n.toPrivateJwk(r);default:throw new Error("Invalid key selector")}}toString(t="pem",n="public_pkcs8"){let{key:o,alg:i,selector:s}=this;if("pem"===t)switch(n){case"public_pkcs1":return i.toPublicPKCS1(o);case"public_pkcs8":return i.toPublicPKCS8(o);case"private_pkcs1":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS1(o);case"private_pkcs8":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS8(o);default:throw new Error("Invalid key selector")}else if("jwk"===t)switch(n){case"public":return JSON.stringify(i.toPublicJwk(o));case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return JSON.stringify(i.toPrivateJwk(o));default:throw new Error("Invalid key selector")}else if("blk"===t)switch(n){case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivateBlk(o);case"public":return i.toPublicBlk(o);default:throw new Error("Invalid key selector")}throw new r}}return Ze=s}(),lt=e(ut),ft=e(Qe());function pt(){if(st)return it;st=1;const e=new(0,a().ec)("secp256k1"),t=e.curve,r=t.n.constructor;function n(n){const o=n[0];switch(o){case 2:case 3:return 33!==n.length?null:function(n,o){let i=new r(o);if(i.cmp(t.p)>=0)return null;i=i.toRed(t.red);let s=i.redSqr().redIMul(i).redIAdd(t.b).redSqrt();return 3===n!==s.isOdd()&&(s=s.redNeg()),e.keyPair({pub:{x:i,y:s}})}(o,n.subarray(1,33));case 4:case 6:case 7:return 65!==n.length?null:function(n,o,i){let s=new r(o),a=new r(i);if(s.cmp(t.p)>=0||a.cmp(t.p)>=0)return null;if(s=s.toRed(t.red),a=a.toRed(t.red),(6===n||7===n)&&a.isOdd()!==(7===n))return null;const c=s.redSqr().redIMul(s);return a.redSqr().redISub(c.redIAdd(t.b)).isZero()?e.keyPair({pub:{x:s,y:a}}):null}(o,n.subarray(1,33),n.subarray(33,65));default:return null}}function o(e,t){const r=t.encode(null,33===e.length);for(let t=0;t<e.length;++t)e[t]=r[t]}return it={contextRandomize:()=>0,privateKeyVerify(e){const n=new r(e);return n.cmp(t.n)<0&&!n.isZero()?0:1},privateKeyNegate(e){const n=new r(e),o=t.n.sub(n).umod(t.n).toArrayLike(Uint8Array,"be",32);return e.set(o),0},privateKeyTweakAdd(e,n){const o=new r(n);if(o.cmp(t.n)>=0)return 1;if(o.iadd(new r(e)),o.cmp(t.n)>=0&&o.isub(t.n),o.isZero())return 1;const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},privateKeyTweakMul(e,n){let o=new r(n);if(o.cmp(t.n)>=0||o.isZero())return 1;o.imul(new r(e)),o.cmp(t.n)>=0&&(o=o.umod(t.n));const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},publicKeyVerify:e=>null===n(e)?1:0,publicKeyCreate(n,i){const s=new r(i);if(s.cmp(t.n)>=0||s.isZero())return 1;return o(n,e.keyFromPrivate(i).getPublic()),0},publicKeyConvert(e,t){const r=n(t);if(null===r)return 1;return o(e,r.getPublic()),0},publicKeyNegate(e,t){const r=n(t);if(null===r)return 1;const i=r.getPublic();return i.y=i.y.redNeg(),o(e,i),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e<t.length;++e)if(r[e]=n(t[e]),null===r[e])return 1;let i=r[0].getPublic();for(let e=1;e<r.length;++e)i=i.add(r[e].pub);return i.isInfinity()?2:(o(e,i),0)},publicKeyTweakAdd(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0)return 2;const c=a.getPublic().add(t.g.mul(s));return c.isInfinity()?2:(o(e,c),0)},publicKeyTweakMul(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0||s.isZero())return 2;return o(e,a.getPublic().mul(s)),0},signatureNormalize(n){const o=new r(n.subarray(0,32)),i=new r(n.subarray(32,64));return o.cmp(t.n)>=0||i.cmp(t.n)>=0?1:(1===i.cmp(e.nh)&&n.set(t.n.sub(i).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,n){const o=n.subarray(0,32),i=n.subarray(32,64);if(new r(o).cmp(t.n)>=0)return 1;if(new r(i).cmp(t.n)>=0)return 1;const{output:s}=e;let a=s.subarray(4,37);a[0]=0,a.set(o,1);let c=33,u=0;for(;c>1&&0===a[u]&&!(128&a[u+1]);--c,++u);if(a=a.subarray(u),128&a[0])return 1;if(c>1&&0===a[0]&&!(128&a[1]))return 1;let l=s.subarray(39,72);l[0]=0,l.set(i,1);let f=33,p=0;for(;f>1&&0===l[p]&&!(128&l[p+1]);--f,++p);return l=l.subarray(p),128&l[0]||f>1&&0===l[0]&&!(128&l[1])?1:(e.outputlen=6+c+f,s[0]=48,s[1]=e.outputlen-2,s[2]=2,s[3]=a.length,s.set(a,4),s[4+c]=2,s[5+c]=l.length,s.set(l,6+c),0)},signatureImport(e,n){if(n.length<8)return 1;if(n.length>72)return 1;if(48!==n[0])return 1;if(n[1]!==n.length-2)return 1;if(2!==n[2])return 1;const o=n[3];if(0===o)return 1;if(5+o>=n.length)return 1;if(2!==n[4+o])return 1;const i=n[5+o];if(0===i)return 1;if(6+o+i!==n.length)return 1;if(128&n[4])return 1;if(o>1&&0===n[4]&&!(128&n[5]))return 1;if(128&n[o+6])return 1;if(i>1&&0===n[o+6]&&!(128&n[o+7]))return 1;let s=n.subarray(4,4+o);if(33===s.length&&0===s[0]&&(s=s.subarray(1)),s.length>32)return 1;let a=n.subarray(6+o);if(33===a.length&&0===a[0]&&(a=a.slice(1)),a.length>32)throw new Error("S length is too long");let c=new r(s);c.cmp(t.n)>=0&&(c=new r(0));let u=new r(n.subarray(6+o));return u.cmp(t.n)>=0&&(u=new r(0)),e.set(c.toArrayLike(Uint8Array,"be",32),0),e.set(u.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(n,o,i,s,a){if(a){const e=a;a=t=>{const n=e(o,i,null,s,t);if(!(n instanceof Uint8Array&&32===n.length))throw new Error("This is the way");return new r(n)}}const c=new r(i);if(c.cmp(t.n)>=0||c.isZero())return 1;let u;try{u=e.sign(o,i,{canonical:!0,k:a,pers:s})}catch(e){return 1}return n.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),n.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),n.recid=u.recoveryParam,0},ecdsaVerify(o,i,s){const a={r:o.subarray(0,32),s:o.subarray(32,64)},c=new r(a.r),u=new r(a.s);if(c.cmp(t.n)>=0||u.cmp(t.n)>=0)return 1;if(1===u.cmp(e.nh)||c.isZero()||u.isZero())return 3;const l=n(s);if(null===l)return 2;const f=l.getPublic();return e.verify(i,a,f)?0:3},ecdsaRecover(n,i,s,a){const c={r:i.slice(0,32),s:i.slice(32,64)},u=new r(c.r),l=new r(c.s);if(u.cmp(t.n)>=0||l.cmp(t.n)>=0)return 1;if(u.isZero()||l.isZero())return 2;let f;try{f=e.recoverPubKey(a,c,s)}catch(e){return 2}return o(n,f),0},ecdh(o,i,s,a,c,u,l){const f=n(i);if(null===f)return 1;const p=new r(s);if(p.cmp(t.n)>=0||p.isZero())return 2;const h=f.getPublic().mul(p);if(void 0===c){const t=h.encode(null,!0),r=e.hash().update(t).digest();for(let e=0;e<32;++e)o[e]=r[e]}else{u||(u=new Uint8Array(32));const e=h.getX().toArray("be",32);for(let t=0;t<32;++t)u[t]=e[t];l||(l=new Uint8Array(32));const t=h.getY().toArray("be",32);for(let e=0;e<32;++e)l[e]=t[e];const r=c(u,l,a);if(!(r instanceof Uint8Array&&r.length===o.length))return 2;o.set(r)}return 0}}}var ht,dt,yt,bt,wt=(ct||(ct=1,at=function(){if(ot)return nt;ot=1;const e="Impossible case. Please create issue.",t="The tweak was out of range or the resulted private key is invalid",r="The tweak was out of range or equal to zero",n="Unknow error on context randomization",o="Private Key is invalid",i="Public Key could not be parsed",s="Public Key serialization error",a="The sum of the public keys is not valid",c="Signature could not be parsed",u="The nonce generation function failed, or the private key was invalid",l="Public key could not be recover",f="Scalar was invalid (zero or overflow)";function p(e,t){if(!e)throw new Error(t)}function h(e,t,r){if(p(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const n=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;p(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;p(t.length===r,n)}}function d(e){p("Boolean"===b(e),"Expected compressed to be a Boolean")}function y(e=e=>new Uint8Array(e),t){return"function"==typeof e&&(e=e(t)),h("output",e,t),e}function b(e){return Object.prototype.toString.call(e).slice(8,-1)}return nt=w=>({contextRandomize(e){if(p(null===e||e instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==e&&h("seed",e,32),1===w.contextRandomize(e))throw new Error(n)},privateKeyVerify:e=>(h("private key",e,32),0===w.privateKeyVerify(e)),privateKeyNegate(t){switch(h("private key",t,32),w.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(e)}},privateKeyTweakAdd(e,r){switch(h("private key",e,32),h("tweak",r,32),w.privateKeyTweakAdd(e,r)){case 0:return e;case 1:throw new Error(t)}},privateKeyTweakMul(e,t){switch(h("private key",e,32),h("tweak",t,32),w.privateKeyTweakMul(e,t)){case 0:return e;case 1:throw new Error(r)}},publicKeyVerify:e=>(h("public key",e,[33,65]),0===w.publicKeyVerify(e)),publicKeyCreate(e,t=!0,r){switch(h("private key",e,32),d(t),r=y(r,t?33:65),w.publicKeyCreate(r,e)){case 0:return r;case 1:throw new Error(o);case 2:throw new Error(s)}},publicKeyConvert(e,t=!0,r){switch(h("public key",e,[33,65]),d(t),r=y(r,t?33:65),w.publicKeyConvert(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(s)}},publicKeyNegate(t,r=!0,n){switch(h("public key",t,[33,65]),d(r),n=y(n,r?33:65),w.publicKeyNegate(n,t)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(e);case 3:throw new Error(s)}},publicKeyCombine(e,t=!0,r){p(Array.isArray(e),"Expected public keys to be an Array"),p(e.length>0,"Expected public keys array will have more than zero items");for(const t of e)h("public key",t,[33,65]);switch(d(t),r=y(r,t?33:65),w.publicKeyCombine(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(a);case 3:throw new Error(s)}},publicKeyTweakAdd(e,r,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",r,32),d(n),o=y(o,n?33:65),w.publicKeyTweakAdd(o,e,r)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(t)}},publicKeyTweakMul(e,t,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",t,32),d(n),o=y(o,n?33:65),w.publicKeyTweakMul(o,e,t)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(r)}},signatureNormalize(e){switch(h("signature",e,64),w.signatureNormalize(e)){case 0:return e;case 1:throw new Error(c)}},signatureExport(t,r){h("signature",t,64);const n={output:r=y(r,72),outputlen:72};switch(w.signatureExport(n,t)){case 0:return r.slice(0,n.outputlen);case 1:throw new Error(c);case 2:throw new Error(e)}},signatureImport(t,r){switch(h("signature",t),r=y(r,64),w.signatureImport(r,t)){case 0:return r;case 1:throw new Error(c);case 2:throw new Error(e)}},ecdsaSign(t,r,n={},o){h("message",t,32),h("private key",r,32),p("Object"===b(n),"Expected options to be an Object"),void 0!==n.data&&h("options.data",n.data),void 0!==n.noncefn&&p("Function"===b(n.noncefn),"Expected options.noncefn to be a Function");const i={signature:o=y(o,64),recid:null};switch(w.ecdsaSign(i,t,r,n.data,n.noncefn)){case 0:return i;case 1:throw new Error(u);case 2:throw new Error(e)}},ecdsaVerify(e,t,r){switch(h("signature",e,64),h("message",t,32),h("public key",r,[33,65]),w.ecdsaVerify(e,t,r)){case 0:return!0;case 3:return!1;case 1:throw new Error(c);case 2:throw new Error(i)}},ecdsaRecover(t,r,n,o=!0,i){switch(h("signature",t,64),p("Number"===b(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),h("message",n,32),d(o),i=y(i,o?33:65),w.ecdsaRecover(i,t,r,n)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(l);case 3:throw new Error(e)}},ecdh(e,t,r={},n){switch(h("public key",e,[33,65]),h("private key",t,32),p("Object"===b(r),"Expected options to be an Object"),void 0!==r.data&&h("options.data",r.data),void 0!==r.hashfn?(p("Function"===b(r.hashfn),"Expected options.hashfn to be a Function"),void 0!==r.xbuf&&h("options.xbuf",r.xbuf,32),void 0!==r.ybuf&&h("options.ybuf",r.ybuf,32),h("output",n)):n=y(n,32),w.ecdh(n,e,t,r.data,r.hashfn,r.xbuf,r.ybuf)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(f)}}}),nt}()(pt())),at),gt=e(wt);function mt(){if(bt)return yt;bt=1;const e=(dt||(dt=1,ht=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var o=e.charAt(n),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=n}var s=e.length,a=e.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,n=0,o=0;e[r]===a;)n++,r++;for(var i=(e.length-r)*c+1>>>0,u=new Uint8Array(i);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var f=0,p=i-1;(0!==l||f<o)&&-1!==p;p--,f++)l+=s*u[p]>>>0,u[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=f,r++}for(var h=i-o;h!==i&&0===u[h];)h++;for(var d=new Uint8Array(n+(i-h)),y=n;h!==i;)d[y++]=u[h++];return d}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var c=(i-o)*u+1>>>0,l=new Uint8Array(c);o!==i;){for(var f=t[o],p=0,h=c-1;(0!==f||p<n)&&-1!==h;h--,p++)f+=256*l[h]>>>0,l[h]=f%s>>>0,f=f/s>>>0;if(0!==f)throw new Error("Non-zero carry");n=p,o++}for(var d=c-n;d!==c&&0===l[d];)d++;for(var y=a.repeat(r);d<c;++d)y+=e.charAt(l[d]);return y},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}),ht);return yt=e("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}export{mt as a,_ as b,k as c,ft as d,wt as e,lt as k,E as r,gt as s};
|
|
1
|
+
import{g as e,B as t,u as r,x as n,i as o,y as i,p as s}from"./main.js";import{r as a,a as c,c as u,b as l,d as f}from"./elliptic-D-ZnlFdt-DQmYEk-8.js";var p,h,d,y,b,w,g,m,v,k=r(n),_=r(i),P={exports:{}};function E(){return p||(p=1,function(e,t){var r=c,n=r.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function i(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=i),i.prototype=Object.create(n.prototype),o(n,i),i.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},i.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=n(e);return void 0!==t?"string"==typeof r?o.fill(t,r):o.fill(t):o.fill(0),o},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}(P,P.exports)),P.exports}function S(){if(d)return h;d=1;class e extends Error{constructor(e){super(e||"This operation is not supported for this key type")}}return h=e}function K(){if(b)return y;b=1;class e extends Error{constructor(){super("This has not been implemented yet")}}return y=e}function A(){if(v)return m;v=1;const e=K();return m=class{constructor(e){this.params=e}fromPrivatePKCS1(t){throw new e}fromPrivatePKCS8(t){throw new e}fromPublicPKCS1(t){throw new e}fromPublicPKCS8(t){throw new e}fromPrivateBlk(t){throw new e}fromPublicBlk(t){throw new e}fromJwk(t){throw new e}toPrivatePKCS1(t){throw new e}toPrivatePKCS8(t){throw new e}toPublicPKCS1(t){throw new e}toPublicPKCS8(t){throw new e}toPrivateBlk(t){throw new e}toPublicBlk(t){throw new e}toPrivateJwk(t){throw new e}toPublicJwk(t){throw new e}static formatPem(e,t){return`-----BEGIN ${t} KEY-----\n`+e.match(/.{1,64}/g).join("\n")+`\n-----END ${t} KEY-----`}}}var x,C,B={},j={},U={};function I(){if(C)return x;C=1;var e,t=c,r=t.Buffer,n={};for(e in t)t.hasOwnProperty(e)&&"SlowBuffer"!==e&&"Buffer"!==e&&(n[e]=t[e]);var o=n.Buffer={};for(e in r)r.hasOwnProperty(e)&&"allocUnsafe"!==e&&"allocUnsafeSlow"!==e&&(o[e]=r[e]);if(n.Buffer.prototype=r.prototype,o.from&&o.from!==Uint8Array.from||(o.from=function(e,t,n){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return r(e,t,n)}),o.alloc||(o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var o=r(e);return t&&0!==t.length?"string"==typeof n?o.fill(t,n):o.fill(t):o.fill(0),o}),!n.kStringMaxLength)try{n.kStringMaxLength=s.binding("buffer").kStringMaxLength}catch(e){}return n.constants||(n.constants={MAX_LENGTH:n.kMaxLength},n.kStringMaxLength&&(n.constants.MAX_STRING_LENGTH=n.kStringMaxLength)),x=n}var T,q={};function N(){if(T)return q;T=1;const e=l();function t(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function r(e,t){this.path=e,this.rethrow(t)}return q.Reporter=t,t.prototype.isError=function(e){return e instanceof r},t.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},t.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},t.prototype.enterKey=function(e){return this._reporterState.path.push(e)},t.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},t.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},t.prototype.path=function(){return this._reporterState.path.join("/")},t.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},t.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},t.prototype.error=function(e){let t;const n=this._reporterState,o=e instanceof r;if(t=o?e:new r(n.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!n.options.partial)throw t;return o||n.errors.push(t),t},t.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},e(r,Error),r.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,r),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this},q}var z,O,R,D={};function V(){if(z)return D;z=1;const e=l(),t=N().Reporter,r=I().Buffer;function n(e,n){t.call(this,n),r.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function o(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return o.isEncoderBuffer(e)||(e=new o(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=r.byteLength(e);else{if(!r.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}return e(n,t),D.DecoderBuffer=n,n.isDecoderBuffer=function(e){if(e instanceof n)return!0;return"object"==typeof e&&r.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},n.prototype.save=function(){return{offset:this.offset,reporter:t.prototype.save.call(this)}},n.prototype.restore=function(e){const r=new n(this.base);return r.offset=e.offset,r.length=this.offset,this.offset=e.offset,t.prototype.restore.call(this,e.reporter),r},n.prototype.isEmpty=function(){return this.offset===this.length},n.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},n.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const r=new n(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},n.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},D.EncoderBuffer=o,o.isEncoderBuffer=function(e){if(e instanceof o)return!0;return"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},o.prototype.join=function(e,t){return e||(e=r.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(e,t),t+=r.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):r.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e},D}function L(){if(R)return O;R=1;const e=N().Reporter,t=V().EncoderBuffer,r=V().DecoderBuffer,n=f(),o=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],i=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(o);function s(e,t,r){const n={};this._baseState=n,n.name=r,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}O=s;const a=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];return s.prototype.clone=function(){const e=this._baseState,t={};a.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},s.prototype._wrap=function(){const e=this._baseState;i.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},s.prototype._init=function(e){const t=this._baseState;n(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),n.equal(t.children.length,1,"Root node can have only one child")},s.prototype._useArgs=function(e){const t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(n(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(n(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);const n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){s.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),o.forEach((function(e){s.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return n(null===t.tag),t.tag=e,this._useArgs(r),this}})),s.prototype.use=function(e){n(e);const t=this._baseState;return n(null===t.use),t.use=e,this},s.prototype.optional=function(){return this._baseState.optional=!0,this},s.prototype.def=function(e){const t=this._baseState;return n(null===t.default),t.default=e,t.optional=!0,this},s.prototype.explicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.explicit=e,this},s.prototype.implicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.implicit=e,this},s.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},s.prototype.key=function(e){const t=this._baseState;return n(null===t.key),t.key=e,this},s.prototype.any=function(){return this._baseState.any=!0,this},s.prototype.choice=function(e){const t=this._baseState;return n(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},s.prototype.contains=function(e){const t=this._baseState;return n(null===t.use),t.contains=e,this},s.prototype._decode=function(e,t){const n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));let o,i=n.default,s=!0,a=null;if(null!==n.key&&(a=e.enterKey(n.key)),n.optional){let r=null;if(null!==n.explicit?r=n.explicit:null!==n.implicit?r=n.implicit:null!==n.tag&&(r=n.tag),null!==r||n.any){if(s=this._peekTag(e,r,n.any),e.isError(s))return s}else{const r=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),s=!0}catch(e){s=!1}e.restore(r)}}if(n.obj&&s&&(o=e.enterObject()),s){if(null!==n.explicit){const t=this._decodeTag(e,n.explicit);if(e.isError(t))return t;e=t}const o=e.offset;if(null===n.use&&null===n.choice){let t;n.any&&(t=e.save());const r=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(r))return r;n.any?i=e.raw(t):e=r}if(t&&t.track&&null!==n.tag&&t.track(e.path(),o,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),n.any||(i=null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(r){r._decode(e,t)})),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){const o=new r(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(o,t)}}return n.obj&&s&&(i=e.leaveObject(o)),null===n.key||null===i&&!0!==s?null!==a&&e.exitKey(a):e.leaveKey(a,n.key,i),i},s.prototype._decodeGeneric=function(e,t,r){const n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},s.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),n(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},s.prototype._decodeChoice=function(e,t){const r=this._baseState;let n=null,o=!1;return Object.keys(r.choice).some((function(i){const s=e.save(),a=r.choice[i];try{const r=a._decode(e,t);if(e.isError(r))return!1;n={type:i,value:r},o=!0}catch(t){return e.restore(s),!1}return!0}),this),o?n:e.error("Choice not matched")},s.prototype._createEncoderBuffer=function(e){return new t(e,this.reporter)},s.prototype._encode=function(e,t,r){const n=this._baseState;if(null!==n.default&&n.default===e)return;const o=this._encodeValue(e,t,r);return void 0===o||this._skipDefault(o,t,r)?void 0:o},s.prototype._encodeValue=function(t,r,n){const o=this._baseState;if(null===o.parent)return o.children[0]._encode(t,r||new e);let i=null;if(this.reporter=r,o.optional&&void 0===t){if(null===o.default)return;t=o.default}let s=null,a=!1;if(o.any)i=this._createEncoderBuffer(t);else if(o.choice)i=this._encodeChoice(t,r);else if(o.contains)s=this._getUse(o.contains,n)._encode(t,r),a=!0;else if(o.children)s=o.children.map((function(e){if("null_"===e._baseState.tag)return e._encode(null,r,t);if(null===e._baseState.key)return r.error("Child should have a key");const n=r.enterKey(e._baseState.key);if("object"!=typeof t)return r.error("Child expected, but input is not object");const o=e._encode(t[e._baseState.key],r,t);return r.leaveKey(n),o}),this).filter((function(e){return e})),s=this._createEncoderBuffer(s);else if("seqof"===o.tag||"setof"===o.tag){if(!o.args||1!==o.args.length)return r.error("Too many args for : "+o.tag);if(!Array.isArray(t))return r.error("seqof/setof, but data is not Array");const e=this.clone();e._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(e){const n=this._baseState;return this._getUse(n.args[0],t)._encode(e,r)}),e))}else null!==o.use?i=this._getUse(o.use,n)._encode(t,r):(s=this._encodePrimitive(o.tag,t),a=!0);if(!o.any&&null===o.choice){const e=null!==o.implicit?o.implicit:o.tag,t=null===o.implicit?"universal":"context";null===e?null===o.use&&r.error("Tag could be omitted only for .use()"):null===o.use&&(i=this._encodeComposite(e,a,t,s))}return null!==o.explicit&&(i=this._encodeComposite(o.explicit,!1,"context",i)),i},s.prototype._encodeChoice=function(e,t){const r=this._baseState,o=r.choice[e.type];return o||n(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),o._encode(e.value,t)},s.prototype._encodePrimitive=function(e,t){const r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},s.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},s.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)},O}var M,J,$,F,Z,G,Y={};function H(){return M||(M=1,function(e){function t(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t}e.tagClass={0:"universal",1:"application",2:"context",3:"private"},e.tagClassByName=t(e.tagClass),e.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},e.tagByName=t(e.tag)}(Y)),Y}function X(){if($)return J;$=1;const e=l(),t=I().Buffer,r=L(),n=H();function o(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new i,this.tree._init(e.body)}function i(e){r.call(this,"der",e)}function s(e){return e<10?"0"+e:e}return J=o,o.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},e(i,r),i.prototype._encodeComposite=function(e,r,o,i){const s=function(e,t,r,o){let i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(n.tagByName.hasOwnProperty(e))i=n.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return o.error("Unknown tag: "+e);i=e}if(i>=31)return o.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=n.tagClassByName[r||"universal"]<<6,i}(e,r,o,this.reporter);if(i.length<128){const e=t.alloc(2);return e[0]=s,e[1]=i.length,this._createEncoderBuffer([e,i])}let a=1;for(let e=i.length;e>=256;e>>=8)a++;const c=t.alloc(2+a);c[0]=s,c[1]=128|a;for(let e=1+a,t=i.length;t>0;e--,t>>=8)c[e]=255&t;return this._createEncoderBuffer([c,i])},i.prototype._encodeStr=function(e,r){if("bitstr"===r)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===r){const r=t.alloc(2*e.length);for(let t=0;t<e.length;t++)r.writeUInt16BE(e.charCodeAt(t),2*t);return this._createEncoderBuffer(r)}return"numstr"===r?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===r?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(r)||"objDesc"===r?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+r+" unsupported")},i.prototype._encodeObjid=function(e,r,n){if("string"==typeof e){if(!r)return this.reporter.error("string objid given, but no values map found");if(!r.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=r[e].split(/[\s.]+/g);for(let t=0;t<e.length;t++)e[t]|=0}else if(Array.isArray(e)){e=e.slice();for(let t=0;t<e.length;t++)e[t]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!n){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let o=0;for(let t=0;t<e.length;t++){let r=e[t];for(o++;r>=128;r>>=7)o++}const i=t.alloc(o);let s=i.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(i[s--]=127&r;(r>>=7)>0;)i[s--]=128|127&r}return this._createEncoderBuffer(i)},i.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[s(n.getUTCFullYear()),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[s(n.getUTCFullYear()%100),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},i.prototype._encodeNull=function(){return this._createEncoderBuffer("")},i.prototype._encodeInt=function(e,r){if("string"==typeof e){if(!r)return this.reporter.error("String int or enum given, but no values map");if(!r.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=r[e]}if("number"!=typeof e&&!t.isBuffer(e)){const r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=t.from(r)}if(t.isBuffer(e)){let r=e.length;0===e.length&&r++;const n=t.alloc(r);return e.copy(n),0===e.length&&(n[0]=0),this._createEncoderBuffer(n)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let n=1;for(let t=e;t>=256;t>>=8)n++;const o=new Array(n);for(let t=o.length-1;t>=0;t--)o[t]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(t.from(o))},i.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},i.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},i.prototype._skipDefault=function(e,t,r){const n=this._baseState;let o;if(null===n.default)return!1;const i=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),i.length!==n.defaultBuffer.length)return!1;for(o=0;o<i.length;o++)if(i[o]!==n.defaultBuffer[o])return!1;return!0},J}function W(){return G||(G=1,function(e){const t=e;t.der=X(),t.pem=function(){if(Z)return F;Z=1;const e=l(),t=X();function r(e){t.call(this,e),this.enc="pem"}return e(r,t),F=r,r.prototype.encode=function(e,r){const n=t.prototype.encode.call(this,e).toString("base64"),o=["-----BEGIN "+r.label+"-----"];for(let e=0;e<n.length;e+=64)o.push(n.slice(e,e+64));return o.push("-----END "+r.label+"-----"),o.join("\n")},F}()}(U)),U}var Q,ee,te,re,ne,oe,ie={};function se(){if(ee)return Q;ee=1;const e=l(),t=u(),r=V().DecoderBuffer,n=L(),o=H();function i(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new s,this.tree._init(e.body)}function s(e){n.call(this,"der",e)}function a(e,t){let r=e.readUInt8(t);if(e.isError(r))return r;const n=o.tagClass[r>>6],i=!(32&r);if(31&~r)r&=31;else{let n=r;for(r=0;!(128&~n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}return{cls:n,primitive:i,tag:r,tagStr:o.tag[r]}}function c(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(!(128&n))return n;const o=127&n;if(o>4)return e.error("length octect is too long");n=0;for(let t=0;t<o;t++){n<<=8;const t=e.readUInt8(r);if(e.isError(t))return t;n|=t}return n}return Q=i,i.prototype.decode=function(e,t){return r.isDecoderBuffer(e)||(e=new r(e,t)),this.tree._decode(e,t)},e(s,n),s.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;const n=e.save(),o=a(e,'Failed to peek tag: "'+t+'"');return e.isError(o)?o:(e.restore(n),o.tag===t||o.tagStr===t||o.tagStr+"of"===t||r)},s.prototype._decodeTag=function(e,t,r){const n=a(e,'Failed to decode tag of "'+t+'"');if(e.isError(n))return n;let o=c(e,n.primitive,'Failed to get length of "'+t+'"');if(e.isError(o))return o;if(!r&&n.tag!==t&&n.tagStr!==t&&n.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(n.primitive||null!==o)return e.skip(o,'Failed to match body of: "'+t+'"');const i=e.save(),s=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(s)?s:(o=e.offset-i.offset,e.restore(i),e.skip(o,'Failed to match body of: "'+t+'"'))},s.prototype._skipUntilEnd=function(e,t){for(;;){const r=a(e,t);if(e.isError(r))return r;const n=c(e,r.primitive,t);if(e.isError(n))return n;let o;if(o=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(o))return o;if("end"===r.tagStr)break}},s.prototype._decodeList=function(e,t,r,n){const o=[];for(;!e.isEmpty();){const t=this._peekTag(e,"end");if(e.isError(t))return t;const i=r.decode(e,"der",n);if(e.isError(i)&&t)break;o.push(i)}return o},s.prototype._decodeStr=function(e,t){if("bitstr"===t){const t=e.readUInt8();return e.isError(t)?t:{unused:t,data:e.raw()}}if("bmpstr"===t){const t=e.raw();if(t.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");let r="";for(let e=0;e<t.length/2;e++)r+=String.fromCharCode(t.readUInt16BE(2*e));return r}if("numstr"===t){const t=e.raw().toString("ascii");return this._isNumstr(t)?t:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){const t=e.raw().toString("ascii");return this._isPrintstr(t)?t:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},s.prototype._decodeObjid=function(e,t,r){let n;const o=[];let i=0,s=0;for(;!e.isEmpty();)s=e.readUInt8(),i<<=7,i|=127&s,128&s||(o.push(i),i=0);128&s&&o.push(i);const a=o[0]/40|0,c=o[0]%40;if(n=r?o:[a,c].concat(o.slice(1)),t){let e=t[n.join(" ")];void 0===e&&(e=t[n.join(".")]),void 0!==e&&(n=e)}return n},s.prototype._decodeTime=function(e,t){const r=e.raw().toString();let n,o,i,s,a,c;if("gentime"===t)n=0|r.slice(0,4),o=0|r.slice(4,6),i=0|r.slice(6,8),s=0|r.slice(8,10),a=0|r.slice(10,12),c=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");n=0|r.slice(0,2),o=0|r.slice(2,4),i=0|r.slice(4,6),s=0|r.slice(6,8),a=0|r.slice(8,10),c=0|r.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,o-1,i,s,a,c,0)},s.prototype._decodeNull=function(){return null},s.prototype._decodeBool=function(e){const t=e.readUInt8();return e.isError(t)?t:0!==t},s.prototype._decodeInt=function(e,r){const n=e.raw();let o=new t(n);return r&&(o=r[o.toString(10)]||o),o},s.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree},Q}function ae(){return ne||(ne=1,function(e){const t=e;t.der=se(),t.pem=function(){if(re)return te;re=1;const e=l(),t=I().Buffer,r=se();function n(e){r.call(this,e),this.enc="pem"}return e(n,r),te=n,n.prototype.decode=function(e,n){const o=e.toString().split(/[\r\n]+/g),i=n.label.toUpperCase(),s=/^-----(BEGIN|END) ([^-]+)-----$/;let a=-1,c=-1;for(let e=0;e<o.length;e++){const t=o[e].match(s);if(null!==t&&t[2]===i){if(-1!==a){if("END"!==t[1])break;c=e;break}if("BEGIN"!==t[1])break;a=e}}if(-1===a||-1===c)throw new Error("PEM section not found for: "+i);const u=o.slice(a+1,c).join("");u.replace(/[^a-z0-9+/=]+/gi,"");const l=t.from(u,"base64");return r.prototype.decode.call(this,l,n)},te}()}(ie)),ie}var ce,ue={};var le,fe,pe={};function he(){return fe||(fe=1,function(){const e=B;e.bignum=u(),e.define=(oe||(oe=1,function(e){const t=W(),r=ae(),n=l();function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}e.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){const t=this.name;function r(e){this._initNamed(e,t)}return n(r,e),r.prototype._initNamed=function(t,r){e.call(this,t,r)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(r[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(t[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}}(j)),j).define,e.base=(ce||(ce=1,function(e){const t=e;t.Reporter=N().Reporter,t.DecoderBuffer=V().DecoderBuffer,t.EncoderBuffer=V().EncoderBuffer,t.Node=L()}(ue)),ue),e.constants=(le||(le=1,function(e){const t=e;t._reverse=function(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t},t.der=H()}(pe)),pe),e.decoders=ae(),e.encoders=W()}()),B}var de,ye,be,we,ge,me,ve,ke,_e,Pe,Ee,Se,Ke,Ae,xe,Ce,Be,je,Ue,Ie,Te,qe,Ne,ze,Oe,Re,De,Ve,Le,Me,Je,$e,Fe,Ze,Ge,Ye={exports:{}},He={},Xe={};function We(){if(ye)return He;ye=1,Object.defineProperty(He,"__esModule",{value:!0});var e=(de||(de=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.default=function(e){var r=e.length,n=r%4;if(!n)return e;var o=r,i=4-n,s=r+i,a=t.alloc(s);for(a.write(e);i--;)a.write("=",o++);return a.toString()}),Xe);function r(e,r){return void 0===r&&(r="utf8"),o(e)?i(e.toString("base64")):i(t.from(e,r).toString("base64"))}function n(t){return t=t.toString(),e.default(t).replace(/\-/g,"+").replace(/_/g,"/")}function i(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var s=r;return s.encode=r,s.decode=function(e,r){return void 0===r&&(r="utf8"),t.from(n(e),"base64").toString(r)},s.toBase64=n,s.fromBase64=i,s.toBuffer=function(e){return t.from(n(e),"base64")},He.default=s,He}function Qe(){return be||(be=1,(e=Ye).exports=We().default,e.exports.default=e.exports),Ye.exports;var e}function et(){if(ge)return we;ge=1;const e=he(),r=Qe();return we=class{static convert(n,o,i){if(!n)return;if(o===i)return n;let s;if("raw"===o||n instanceof t)s=n;else if("uint8_array"===o||Array.isArray(n))s=t.from(n);else if("hex"===o)s=t.from(n,"hex");else if("base64"===o)s=t.from(n,"base64");else if("base64url"===o)s=r.toBuffer(n);else{if("bn"!==o&&"bignum"!==o)throw new Error("Invalid fromType");s=t.from(this.pad(n.toString(16)),"hex")}if("raw"===i)return s;if("uint8_array"===i)return Array.from(s);if("hex"===i)return s.toString("hex");if("base64"===i)return s.toString("base64");if("base64url"===i)return r.fromBase64(s.toString("base64"));if("bn"===i||"bignum"===i)return new e.bignum(s);throw new Error("Invalid toType")}static pad(e){return e.length%2==1?`0${e}`:e}},we}function tt(){if(Oe)return ze;Oe=1;const e=new(function(){if(ve)return me;ve=1;const e=he();return me=class{constructor(){Object.defineProperty(this,"_registry",{value:{}})}get registry(){return this._registry}define(t,r){this._registry[t]=e.define(t,r(this))}normalize(e){return this.registry[e]}}}());return e.define("Version",_e?ke:(_e=1,ke=e=>function(){this.int({0:"two-prime",1:"multi"})})),e.define("OtherPrimeInfos",Ee?Pe:(Ee=1,Pe=e=>function(){this.seq().obj(this.key("ri").int(),this.key("di").int(),this.key("ti").int())})),e.define("AlgorithmIdentifier",Ke?Se:(Ke=1,Se=e=>function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())})),e.define("PrivateKeyInfo",(xe||(xe=1,Ae=e=>{let t=e.normalize("Version"),r=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("version").use(t),this.key("algorithm").use(r),this.key("privateKey").octstr())}}),Ae)),e.define("PublicKeyInfo",(Be||(Be=1,Ce=e=>{let t=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("algorithm").use(t),this.key("publicKey").bitstr())}}),Ce)),e.define("RSAPrivateKey",(Ue||(Ue=1,je=e=>{let t=e.normalize("Version"),r=e.normalize("OtherPrimeInfos");return function(){this.seq().obj(this.key("version").use(t),this.key("n").int(),this.key("e").int(),this.key("d").int(),this.key("p").int(),this.key("q").int(),this.key("dp").int(),this.key("dq").int(),this.key("qi").int(),this.key("other").optional().use(r))}}),je)),e.define("RSAPublicKey",Te?Ie:(Te=1,Ie=e=>function(){this.seq().obj(this.key("n").int(),this.key("e").int())})),e.define("ECPrivateKey",Ne?qe:(Ne=1,qe=e=>function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().choice({namedCurve:this.objid()}),this.key("publicKey").explicit(1).optional().bitstr())})),ze=e}function rt(){if(Fe)return $e;Fe=1;const e=g?w:(g=1,w=class{constructor(){this.registry=[],this.classes={}}find(e){return this.registry.find(e)}define(e,t){e.forEach((e=>{let{kty:r}=e;if(!r)throw new Error("Invalid type definition");this.classes[r]||(this.classes[r]=t),this.registry.push(e)}))}normalize(e,t,r){let n=this.classes[e],o=this.find((e=>e[t]===r));if(!n||!o)throw new Error("Invalid type");return new n(o)}}),r=function(){if(De)return Re;De=1;const e=A();S();const r=et(),n=tt();class o extends e{fromPrivatePKCS1(e){let t=n.normalize("RSAPrivateKey"),{n:o,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw"),d:r.convert(s,"bn","raw"),p:r.convert(a,"bn","raw"),q:r.convert(c,"bn","raw"),dp:r.convert(u,"bn","raw"),dq:r.convert(l,"bn","raw"),qi:r.convert(f,"bn","raw")}}fromPrivatePKCS8(e){let t=n.normalize("PrivateKeyInfo"),o=n.normalize("RSAPrivateKey"),i=t.decode(e,"der"),{n:s,e:a,d:c,p:u,q:l,dp:f,dq:p,qi:h}=o.decode(i.privateKey,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw"),d:r.convert(c,"bn","raw"),p:r.convert(u,"bn","raw"),q:r.convert(l,"bn","raw"),dp:r.convert(f,"bn","raw"),dq:r.convert(p,"bn","raw"),qi:r.convert(h,"bn","raw")}}fromPublicPKCS1(e){let t=n.normalize("RSAPublicKey"),{n:o,e:i}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw")}}fromPublicPKCS8(e){let t=n.normalize("PublicKeyInfo"),o=n.normalize("RSAPublicKey"),i=t.decode(e,"der"),{n:s,e:a}=o.decode(i.publicKey.data,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw")}}fromJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u,alg:l}=e;return{n:r.convert(t,"base64url","raw"),e:r.convert(n,"base64url","raw"),d:r.convert(o,"base64url","raw"),p:r.convert(i,"base64url","raw"),q:r.convert(s,"base64url","raw"),dp:r.convert(a,"base64url","raw"),dq:r.convert(c,"base64url","raw"),qi:r.convert(u,"base64url","raw")}}toPrivatePKCS1(e){let{n:t,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=e,{version:p}=this.params,h=n.normalize("RSAPrivateKey").encode({version:p,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn"),d:r.convert(s,"raw","bn"),p:r.convert(a,"raw","bn"),q:r.convert(c,"raw","bn"),dp:r.convert(u,"raw","bn"),dq:r.convert(l,"raw","bn"),qi:r.convert(f,"raw","bn")},"der").toString("base64");return o.formatPem(h,"RSA PRIVATE")}toPrivatePKCS8(e){let{n:i,e:s,d:a,p:c,q:u,dp:l,dq:f,qi:p}=e,{oid:h,algParameters:d,version:y}=this.params,b=n.normalize("PrivateKeyInfo"),w=n.normalize("RSAPrivateKey").encode({version:y,n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn"),d:r.convert(a,"raw","bn"),p:r.convert(c,"raw","bn"),q:r.convert(u,"raw","bn"),dp:r.convert(l,"raw","bn"),dq:r.convert(f,"raw","bn"),qi:r.convert(p,"raw","bn")},"der"),g=b.encode({version:y,algorithm:{algorithm:h.split("."),parameters:t.from(d,"hex")},privateKey:w},"der").toString("base64");return o.formatPem(g,"PRIVATE")}toPublicPKCS1(e){let{n:t,e:i}=e,{version:s}=this.params,a=n.normalize("RSAPublicKey").encode({version:s,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn")},"der").toString("base64");return o.formatPem(a,"RSA PUBLIC")}toPublicPKCS8(e){let{n:i,e:s}=e,{oid:a,algParameters:c}=this.params,u=n.normalize("PublicKeyInfo"),l=n.normalize("RSAPublicKey").encode({n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn")},"der"),f=u.encode({algorithm:{algorithm:a.split("."),parameters:t.from(c,"hex")},publicKey:{unused:0,data:l}},"der").toString("base64");return o.formatPem(f,"PUBLIC")}toPrivateJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u}=e,{kty:l}=this.params;return{kty:l,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url"),d:r.convert(o,"raw","base64url"),p:r.convert(i,"raw","base64url"),q:r.convert(s,"raw","base64url"),dp:r.convert(a,"raw","base64url"),dq:r.convert(c,"raw","base64url"),qi:r.convert(u,"raw","base64url")}}toPublicJwk(e){let{n:t,e:n}=e,{kty:o}=this.params;return{kty:o,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url")}}}return Re=o}(),n=function(){if(Le)return Ve;Le=1,he().bignum;const e=new(0,a().ec)("secp256k1"),r=A();S();const n=et(),o=tt();class i extends r{fromPrivatePKCS1(e){let t=o.normalize("ECPrivateKey").decode(e,"der"),{privateKey:r,publicKey:{data:s}}=t,a=n.convert(s,"raw","hex"),{x:c,y:u}=i.getPoint(a);return{d:r,x:c,y:u}}fromPrivatePKCS8(e){let t=o.normalize("PrivateKeyInfo"),r=o.normalize("ECPrivateKey"),s=t.decode(e,"der"),a=r.decode(s.privateKey,"der"),{privateKey:c,publicKey:{data:u}}=a,l=n.convert(u,"raw","hex"),{x:f,y:p}=i.getPoint(l);return{d:c,x:f,y:p}}fromPublicPKCS8(e){let t=o.normalize("PublicKeyInfo").decode(e,"der"),r=n.convert(t.publicKey.data,"raw","hex");return i.getPoint(r)}fromPrivateBlk(t){let r=e.keyFromPrivate(t,"hex"),o=r.getPublic();return{d:n.convert(r.priv,"bn","raw"),x:n.convert(o.getX(),"bn","raw"),y:n.convert(o.getY(),"bn","raw")}}fromPublicBlk(e){return i.getPoint(e)}fromJwk(e){let{d:t,x:r,y:o}=e;return{d:n.convert(t,"base64url","raw"),x:n.convert(r,"base64url","raw"),y:n.convert(o,"base64url","raw")}}toPrivatePKCS1(e){let{namedCurve:t,keyVersion:r}=this.params,{d:n,x:s,y:a}=e,c=o.normalize("ECPrivateKey"),u=i.makePoint(s,a),l=c.encode({version:r,privateKey:n,parameters:{type:"namedCurve",value:t.split(".")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"EC PRIVATE")}toPrivatePKCS8(e){let{oid:r,algParameters:n,keyVersion:s,infoVersion:a}=this.params,{d:c,x:u,y:l}=e,f=o.normalize("PrivateKeyInfo"),p=o.normalize("ECPrivateKey"),h=i.makePoint(u,l),d=p.encode({version:s,privateKey:c,publicKey:{unused:0,data:h}},"der"),y=f.encode({version:a,algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},privateKey:d},"der").toString("base64");return i.formatPem(y,"PRIVATE")}toPublicPKCS8(e){let{oid:r,algParameters:n}=this.params,{x:s,y:a}=e,c=o.normalize("PublicKeyInfo"),u=i.makePoint(s,a),l=c.encode({algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"PUBLIC")}toPrivateBlk(e){return e.d.toString("hex")}toPublicBlk(e){return n.convert(i.makePoint(e.x,e.y),"raw","hex")}toPrivateJwk(e){let{crv:t,kty:r}=this.params,{d:o,x:i,y:s}=e;return{kty:r,crv:t,d:n.convert(o,"raw","base64url"),x:n.convert(i,"raw","base64url"),y:n.convert(s,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:r}=this.params,{x:o,y:i}=e;return{kty:r,crv:t,x:n.convert(o,"raw","base64url"),y:n.convert(i,"raw","base64url")}}static getPoint(e){let t=e.slice(2,(e.length-2)/2+2),r=e.slice((e.length-2)/2+2);return{x:n.convert(t,"hex","raw"),y:n.convert(r,"hex","raw")}}static makePoint(e,r){let n=t.from("04","hex");return t.concat([n,e,r],n.length+e.length+r.length)}}return Ve=i}(),o=function(){if(Je)return Me;Je=1;const e=A(),r=et(),n=tt();class o extends e{fromPrivatePKCS8(e){const t=n.normalize("PrivateKeyInfo").decode(e,"der").privateKey.slice(2);return{d:t,x:this.publicKeyFromPrivate(t)}}fromPublicPKCS8(e){const t=n.normalize("PublicKeyInfo").decode(e,"der");return{x:r.convert(t.publicKey.data,"hex","raw")}}fromJwk(e){let{d:t,x:n}=e;return{d:r.convert(t,"base64url","raw"),x:r.convert(n,"base64url","raw")}}toPrivatePKCS8(e){let{oid:t,infoVersion:r}=this.params,{d:i}=e;const s=n.normalize("PrivateKeyInfo"),a=this.privateKeyPadding(i);let c=s.encode({version:r,algorithm:{algorithm:t.split(".")},privateKey:a},"der").toString("base64");return o.formatPem(c,"PRIVATE")}toPublicPKCS8(e){let{oid:t}=this.params,{x:i}=e,s=n.normalize("PublicKeyInfo").encode({algorithm:{algorithm:t.split(".")},publicKey:{unused:0,data:r.convert(i,"hex","raw")}},"der").toString("base64");return o.formatPem(s,"PUBLIC")}toPrivateJwk(e){let{crv:t,kty:n}=this.params,{d:o,x:i}=e;return{kty:n,crv:t,d:r.convert(o,"raw","base64url"),x:r.convert(i,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:n}=this.params,{x:o}=e;return{kty:n,crv:t,x:r.convert(o,"raw","base64url")}}privateKeyPadding(e){let r;if("Ed25519"!==this.params.crv)throw new Error(`${this.params.crv} is an invalid curve for EdDSA`);return r=t.from("0420","hex"),t.concat([r,e],r.length+e.length)}publicKeyFromPrivate(e){if("Ed25519"===this.params.crv){const r=new(0,a().eddsa)("ed25519");return t.from(r.keyFromSecret(e).getPublic())}throw new Error(`${this.params.crv} is an invalid curve for EdDSA`)}}return Me=o}(),i=new e;return i.define([{kty:"RSA",oid:"1.2.840.113549.1.1.1",algParameters:"0500",version:"two-prime"}],r),i.define([{kty:"EC",crv:"K-256",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.10",algParameters:"06052b8104000a",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-256",oid:"1.2.840.10045.2.1",namedCurve:"1.2.840.10045.3.1.7",algParameters:"06082a8648ce3d030107",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-384",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.34",algParameters:"06052b81040022",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-521",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.35",algParameters:"06052b81040023",keyVersion:1,infoVersion:"two-prime"}],n),i.define([{kty:"OKP",crv:"Ed25519",oid:"1.3.101.112",infoVersion:"two-prime"}],o),$e=i}var nt,ot,it,st,at,ct,ut=function(){if(Ge)return Ze;Ge=1;const e=S(),r=K(),n=rt(),o=tt(),i=RegExp("\r?\n","g");class s{constructor(t,r){if(!t)throw new e("key is required");if(!r)throw new e("options are required");let{kty:n,format:o,selector:i,crv:s,oid:a}=r;if(!r.kty)throw new e("options.kty is required");if(!r.format)throw new e("options.format is required");if(!r.selector)throw new e("options.selector is required");if(!r.crv&&!r.oid)throw new e("options.crv or options.oid is required");this.kty=n,this.format=o,this.selector=i,this.crv=s,this.oid=a,this.key=this.parseKey(t)}static from(r,a){if(!r)throw new e("key is required");if(!a)throw new e("format is required");if("jwk"===a){let t;if("string"==typeof r)try{t=JSON.parse(r)}catch(t){throw new e("key is not a valid JWK")}else"object"==typeof r&&(t=r);let o,{kty:i,crv:c}=t;if(!i)throw new e("kty is required for JWK");if("EC"===i&&!c)throw new e("crv is required for EC JWK");"RSA"===i&&(o=n.find((e=>e.kty===i)).oid);let u=t.d?"private":"public";return new s(t,{kty:i,crv:c,oid:o,format:a,selector:u})}if("pem"===a){if("string"!=typeof r)throw new e("key is not a valid PEM string");let c=r.split(i),u=c.splice(0,1);c.splice(c.length-1,1);let l,f,p=c.join(""),h=/^-----BEGIN ((RSA|EC) )?(PUBLIC|PRIVATE) KEY-----$/.exec(u),d=h?h[2]:void 0,y=h?h[3]:void 0,b=t.from(p,"base64");if(!y)throw new e("key is not a valid PEM string");if(d){if("RSA"===d)y="PRIVATE"===y?"private_pkcs1":"public_pkcs1",l=n.find((e=>e.kty===d)).oid;else if("EC"===d){let e;if("PRIVATE"===y){y="private_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}else if("PUBLIC"===y){y="public_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}let{parameters:{value:t}}=e;f=n.find((e=>e.namedCurve===t.join("."))).crv}}else{let t,r=o.normalize("PrivateKeyInfo"),i=o.normalize("PublicKeyInfo");"PRIVATE"===y?(y="private_pkcs8",t=r.decode(b,"der")):"PUBLIC"===y&&(y="public_pkcs8",t=i.decode(b,"der"));let{algorithm:{algorithm:s,parameters:a}}=t;s=s.join("."),a=a?a.toString("hex"):void 0;const c=n.find((e=>e.oid===s));if(d=c?c.kty:void 0,!d)throw new e(`${s} is not supported`);"RSA"===d||"OKP"===d?l=s:"EC"===d&&(f=n.find((e=>e.algParameters===a)).crv)}return new s(b,{kty:d,oid:l,crv:f,format:a,selector:y})}if("blk"===a)return new s(r,{kty:"EC",crv:"K-256",format:a,selector:r.length>64?"public":"private"});throw new e(`Invalid format ${a}`)}get alg(){let{kty:e,crv:t,oid:r}=this;if(!this.algorithm){if(t)Object.defineProperty(this,"algorithm",{value:n.normalize(e,"crv",t)});else{if(!r)throw new Error("Both crv and oid are undefined");Object.defineProperty(this,"algorithm",{value:n.normalize(e,"oid",r)})}if(!this.algorithm)throw new Error(`${this.crv||this.oid} is not implemented yet`)}return this.algorithm}parseKey(e){let{alg:t,format:r,selector:n}=this;if("pem"===r)switch(n){case"public_pkcs1":return t.fromPublicPKCS1(e);case"public_pkcs8":return t.fromPublicPKCS8(e);case"private_pkcs1":return t.fromPrivatePKCS1(e);case"private_pkcs8":return t.fromPrivatePKCS8(e);default:throw new Error("Invalid selector value")}if("jwk"===r)return t.fromJwk(e,n);if("blk"===r)switch(n){case"public":return t.fromPublicBlk(e);case"private":return t.fromPrivateBlk(e)}}toJwk(t){let{key:r,alg:n,selector:o}=this;switch(t){case"public":return n.toPublicJwk(r);case"private":if(o.includes("public"))throw new e("Cannot export a private key from a public key");return n.toPrivateJwk(r);default:throw new Error("Invalid key selector")}}toString(t="pem",n="public_pkcs8"){let{key:o,alg:i,selector:s}=this;if("pem"===t)switch(n){case"public_pkcs1":return i.toPublicPKCS1(o);case"public_pkcs8":return i.toPublicPKCS8(o);case"private_pkcs1":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS1(o);case"private_pkcs8":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS8(o);default:throw new Error("Invalid key selector")}else if("jwk"===t)switch(n){case"public":return JSON.stringify(i.toPublicJwk(o));case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return JSON.stringify(i.toPrivateJwk(o));default:throw new Error("Invalid key selector")}else if("blk"===t)switch(n){case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivateBlk(o);case"public":return i.toPublicBlk(o);default:throw new Error("Invalid key selector")}throw new r}}return Ze=s}(),lt=e(ut),ft=e(Qe());function pt(){if(st)return it;st=1;const e=new(0,a().ec)("secp256k1"),t=e.curve,r=t.n.constructor;function n(n){const o=n[0];switch(o){case 2:case 3:return 33!==n.length?null:function(n,o){let i=new r(o);if(i.cmp(t.p)>=0)return null;i=i.toRed(t.red);let s=i.redSqr().redIMul(i).redIAdd(t.b).redSqrt();return 3===n!==s.isOdd()&&(s=s.redNeg()),e.keyPair({pub:{x:i,y:s}})}(o,n.subarray(1,33));case 4:case 6:case 7:return 65!==n.length?null:function(n,o,i){let s=new r(o),a=new r(i);if(s.cmp(t.p)>=0||a.cmp(t.p)>=0)return null;if(s=s.toRed(t.red),a=a.toRed(t.red),(6===n||7===n)&&a.isOdd()!==(7===n))return null;const c=s.redSqr().redIMul(s);return a.redSqr().redISub(c.redIAdd(t.b)).isZero()?e.keyPair({pub:{x:s,y:a}}):null}(o,n.subarray(1,33),n.subarray(33,65));default:return null}}function o(e,t){const r=t.encode(null,33===e.length);for(let t=0;t<e.length;++t)e[t]=r[t]}return it={contextRandomize:()=>0,privateKeyVerify(e){const n=new r(e);return n.cmp(t.n)<0&&!n.isZero()?0:1},privateKeyNegate(e){const n=new r(e),o=t.n.sub(n).umod(t.n).toArrayLike(Uint8Array,"be",32);return e.set(o),0},privateKeyTweakAdd(e,n){const o=new r(n);if(o.cmp(t.n)>=0)return 1;if(o.iadd(new r(e)),o.cmp(t.n)>=0&&o.isub(t.n),o.isZero())return 1;const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},privateKeyTweakMul(e,n){let o=new r(n);if(o.cmp(t.n)>=0||o.isZero())return 1;o.imul(new r(e)),o.cmp(t.n)>=0&&(o=o.umod(t.n));const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},publicKeyVerify:e=>null===n(e)?1:0,publicKeyCreate(n,i){const s=new r(i);if(s.cmp(t.n)>=0||s.isZero())return 1;return o(n,e.keyFromPrivate(i).getPublic()),0},publicKeyConvert(e,t){const r=n(t);if(null===r)return 1;return o(e,r.getPublic()),0},publicKeyNegate(e,t){const r=n(t);if(null===r)return 1;const i=r.getPublic();return i.y=i.y.redNeg(),o(e,i),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e<t.length;++e)if(r[e]=n(t[e]),null===r[e])return 1;let i=r[0].getPublic();for(let e=1;e<r.length;++e)i=i.add(r[e].pub);return i.isInfinity()?2:(o(e,i),0)},publicKeyTweakAdd(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0)return 2;const c=a.getPublic().add(t.g.mul(s));return c.isInfinity()?2:(o(e,c),0)},publicKeyTweakMul(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0||s.isZero())return 2;return o(e,a.getPublic().mul(s)),0},signatureNormalize(n){const o=new r(n.subarray(0,32)),i=new r(n.subarray(32,64));return o.cmp(t.n)>=0||i.cmp(t.n)>=0?1:(1===i.cmp(e.nh)&&n.set(t.n.sub(i).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,n){const o=n.subarray(0,32),i=n.subarray(32,64);if(new r(o).cmp(t.n)>=0)return 1;if(new r(i).cmp(t.n)>=0)return 1;const{output:s}=e;let a=s.subarray(4,37);a[0]=0,a.set(o,1);let c=33,u=0;for(;c>1&&0===a[u]&&!(128&a[u+1]);--c,++u);if(a=a.subarray(u),128&a[0])return 1;if(c>1&&0===a[0]&&!(128&a[1]))return 1;let l=s.subarray(39,72);l[0]=0,l.set(i,1);let f=33,p=0;for(;f>1&&0===l[p]&&!(128&l[p+1]);--f,++p);return l=l.subarray(p),128&l[0]||f>1&&0===l[0]&&!(128&l[1])?1:(e.outputlen=6+c+f,s[0]=48,s[1]=e.outputlen-2,s[2]=2,s[3]=a.length,s.set(a,4),s[4+c]=2,s[5+c]=l.length,s.set(l,6+c),0)},signatureImport(e,n){if(n.length<8)return 1;if(n.length>72)return 1;if(48!==n[0])return 1;if(n[1]!==n.length-2)return 1;if(2!==n[2])return 1;const o=n[3];if(0===o)return 1;if(5+o>=n.length)return 1;if(2!==n[4+o])return 1;const i=n[5+o];if(0===i)return 1;if(6+o+i!==n.length)return 1;if(128&n[4])return 1;if(o>1&&0===n[4]&&!(128&n[5]))return 1;if(128&n[o+6])return 1;if(i>1&&0===n[o+6]&&!(128&n[o+7]))return 1;let s=n.subarray(4,4+o);if(33===s.length&&0===s[0]&&(s=s.subarray(1)),s.length>32)return 1;let a=n.subarray(6+o);if(33===a.length&&0===a[0]&&(a=a.slice(1)),a.length>32)throw new Error("S length is too long");let c=new r(s);c.cmp(t.n)>=0&&(c=new r(0));let u=new r(n.subarray(6+o));return u.cmp(t.n)>=0&&(u=new r(0)),e.set(c.toArrayLike(Uint8Array,"be",32),0),e.set(u.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(n,o,i,s,a){if(a){const e=a;a=t=>{const n=e(o,i,null,s,t);if(!(n instanceof Uint8Array&&32===n.length))throw new Error("This is the way");return new r(n)}}const c=new r(i);if(c.cmp(t.n)>=0||c.isZero())return 1;let u;try{u=e.sign(o,i,{canonical:!0,k:a,pers:s})}catch(e){return 1}return n.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),n.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),n.recid=u.recoveryParam,0},ecdsaVerify(o,i,s){const a={r:o.subarray(0,32),s:o.subarray(32,64)},c=new r(a.r),u=new r(a.s);if(c.cmp(t.n)>=0||u.cmp(t.n)>=0)return 1;if(1===u.cmp(e.nh)||c.isZero()||u.isZero())return 3;const l=n(s);if(null===l)return 2;const f=l.getPublic();return e.verify(i,a,f)?0:3},ecdsaRecover(n,i,s,a){const c={r:i.slice(0,32),s:i.slice(32,64)},u=new r(c.r),l=new r(c.s);if(u.cmp(t.n)>=0||l.cmp(t.n)>=0)return 1;if(u.isZero()||l.isZero())return 2;let f;try{f=e.recoverPubKey(a,c,s)}catch(e){return 2}return o(n,f),0},ecdh(o,i,s,a,c,u,l){const f=n(i);if(null===f)return 1;const p=new r(s);if(p.cmp(t.n)>=0||p.isZero())return 2;const h=f.getPublic().mul(p);if(void 0===c){const t=h.encode(null,!0),r=e.hash().update(t).digest();for(let e=0;e<32;++e)o[e]=r[e]}else{u||(u=new Uint8Array(32));const e=h.getX().toArray("be",32);for(let t=0;t<32;++t)u[t]=e[t];l||(l=new Uint8Array(32));const t=h.getY().toArray("be",32);for(let e=0;e<32;++e)l[e]=t[e];const r=c(u,l,a);if(!(r instanceof Uint8Array&&r.length===o.length))return 2;o.set(r)}return 0}}}var ht,dt,yt,bt,wt=(ct||(ct=1,at=function(){if(ot)return nt;ot=1;const e="Impossible case. Please create issue.",t="The tweak was out of range or the resulted private key is invalid",r="The tweak was out of range or equal to zero",n="Unknow error on context randomization",o="Private Key is invalid",i="Public Key could not be parsed",s="Public Key serialization error",a="The sum of the public keys is not valid",c="Signature could not be parsed",u="The nonce generation function failed, or the private key was invalid",l="Public key could not be recover",f="Scalar was invalid (zero or overflow)";function p(e,t){if(!e)throw new Error(t)}function h(e,t,r){if(p(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const n=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;p(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;p(t.length===r,n)}}function d(e){p("Boolean"===b(e),"Expected compressed to be a Boolean")}function y(e=e=>new Uint8Array(e),t){return"function"==typeof e&&(e=e(t)),h("output",e,t),e}function b(e){return Object.prototype.toString.call(e).slice(8,-1)}return nt=w=>({contextRandomize(e){if(p(null===e||e instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==e&&h("seed",e,32),1===w.contextRandomize(e))throw new Error(n)},privateKeyVerify:e=>(h("private key",e,32),0===w.privateKeyVerify(e)),privateKeyNegate(t){switch(h("private key",t,32),w.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(e)}},privateKeyTweakAdd(e,r){switch(h("private key",e,32),h("tweak",r,32),w.privateKeyTweakAdd(e,r)){case 0:return e;case 1:throw new Error(t)}},privateKeyTweakMul(e,t){switch(h("private key",e,32),h("tweak",t,32),w.privateKeyTweakMul(e,t)){case 0:return e;case 1:throw new Error(r)}},publicKeyVerify:e=>(h("public key",e,[33,65]),0===w.publicKeyVerify(e)),publicKeyCreate(e,t=!0,r){switch(h("private key",e,32),d(t),r=y(r,t?33:65),w.publicKeyCreate(r,e)){case 0:return r;case 1:throw new Error(o);case 2:throw new Error(s)}},publicKeyConvert(e,t=!0,r){switch(h("public key",e,[33,65]),d(t),r=y(r,t?33:65),w.publicKeyConvert(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(s)}},publicKeyNegate(t,r=!0,n){switch(h("public key",t,[33,65]),d(r),n=y(n,r?33:65),w.publicKeyNegate(n,t)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(e);case 3:throw new Error(s)}},publicKeyCombine(e,t=!0,r){p(Array.isArray(e),"Expected public keys to be an Array"),p(e.length>0,"Expected public keys array will have more than zero items");for(const t of e)h("public key",t,[33,65]);switch(d(t),r=y(r,t?33:65),w.publicKeyCombine(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(a);case 3:throw new Error(s)}},publicKeyTweakAdd(e,r,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",r,32),d(n),o=y(o,n?33:65),w.publicKeyTweakAdd(o,e,r)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(t)}},publicKeyTweakMul(e,t,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",t,32),d(n),o=y(o,n?33:65),w.publicKeyTweakMul(o,e,t)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(r)}},signatureNormalize(e){switch(h("signature",e,64),w.signatureNormalize(e)){case 0:return e;case 1:throw new Error(c)}},signatureExport(t,r){h("signature",t,64);const n={output:r=y(r,72),outputlen:72};switch(w.signatureExport(n,t)){case 0:return r.slice(0,n.outputlen);case 1:throw new Error(c);case 2:throw new Error(e)}},signatureImport(t,r){switch(h("signature",t),r=y(r,64),w.signatureImport(r,t)){case 0:return r;case 1:throw new Error(c);case 2:throw new Error(e)}},ecdsaSign(t,r,n={},o){h("message",t,32),h("private key",r,32),p("Object"===b(n),"Expected options to be an Object"),void 0!==n.data&&h("options.data",n.data),void 0!==n.noncefn&&p("Function"===b(n.noncefn),"Expected options.noncefn to be a Function");const i={signature:o=y(o,64),recid:null};switch(w.ecdsaSign(i,t,r,n.data,n.noncefn)){case 0:return i;case 1:throw new Error(u);case 2:throw new Error(e)}},ecdsaVerify(e,t,r){switch(h("signature",e,64),h("message",t,32),h("public key",r,[33,65]),w.ecdsaVerify(e,t,r)){case 0:return!0;case 3:return!1;case 1:throw new Error(c);case 2:throw new Error(i)}},ecdsaRecover(t,r,n,o=!0,i){switch(h("signature",t,64),p("Number"===b(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),h("message",n,32),d(o),i=y(i,o?33:65),w.ecdsaRecover(i,t,r,n)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(l);case 3:throw new Error(e)}},ecdh(e,t,r={},n){switch(h("public key",e,[33,65]),h("private key",t,32),p("Object"===b(r),"Expected options to be an Object"),void 0!==r.data&&h("options.data",r.data),void 0!==r.hashfn?(p("Function"===b(r.hashfn),"Expected options.hashfn to be a Function"),void 0!==r.xbuf&&h("options.xbuf",r.xbuf,32),void 0!==r.ybuf&&h("options.ybuf",r.ybuf,32),h("output",n)):n=y(n,32),w.ecdh(n,e,t,r.data,r.hashfn,r.xbuf,r.ybuf)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(f)}}}),nt}()(pt())),at),gt=e(wt);function mt(){if(bt)return yt;bt=1;const e=(dt||(dt=1,ht=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var o=e.charAt(n),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=n}var s=e.length,a=e.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,n=0,o=0;e[r]===a;)n++,r++;for(var i=(e.length-r)*c+1>>>0,u=new Uint8Array(i);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var f=0,p=i-1;(0!==l||f<o)&&-1!==p;p--,f++)l+=s*u[p]>>>0,u[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=f,r++}for(var h=i-o;h!==i&&0===u[h];)h++;for(var d=new Uint8Array(n+(i-h)),y=n;h!==i;)d[y++]=u[h++];return d}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var c=(i-o)*u+1>>>0,l=new Uint8Array(c);o!==i;){for(var f=t[o],p=0,h=c-1;(0!==f||p<n)&&-1!==h;h--,p++)f+=256*l[h]>>>0,l[h]=f%s>>>0,f=f/s>>>0;if(0!==f)throw new Error("Non-zero carry");n=p,o++}for(var d=c-n;d!==c&&0===l[d];)d++;for(var y=a.repeat(r);d<c;++d)y+=e.charAt(l[d]);return y},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}),ht);return yt=e("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}export{mt as a,_ as b,k as c,ft as d,wt as e,lt as k,E as r,gt as s};
|