@blockcerts/blockcerts-verifier 1.62.1 → 1.62.2
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 +2 -2
- package/dist/EcdsaSd2023-jnIXPui8-Ecil79Z6.js +36 -0
- package/dist/EcdsaSecp256k1Signature2019-CBV4BwnM-C2qGlq2W.js +4 -0
- package/dist/{Ed25519Signature2020-ksyyWByQ-DJfkuzPo.js → Ed25519Signature2020-MQoWd113-PNuci9U2.js} +4 -4
- package/dist/{HashlinkVerifier-DsOipQXP-BdYYAALa.js → HashlinkVerifier-DykIKn5i-CYewU55u.js} +3 -3
- package/dist/{MerkleProof2017-DJkEKNm5-DslQLgIV.js → MerkleProof2017-Cy_nkz4C-gnoFFWMW.js} +1 -1
- package/dist/{MerkleProof2017-MZJbBTpc-B7HRJzRg.js → MerkleProof2017-MZJbBTpc-CeZmtqCh.js} +3 -3
- package/dist/MerkleProof2019-DpwH-snR-ClzVR6uC.js +3 -0
- package/dist/checkCredentialSchemaConformity-DOGmtCq0-CnEpCN-s.js +1 -0
- package/dist/{checkRevocationStatusList2021-gJ08HuL8-BycWMYXc.js → checkRevocationStatusList2021-CNtaPjVp-XCu3zkCJ.js} +1 -1
- package/dist/{controlVerificationMethod-1mtI3EJp-wABQpqsl.js → controlVerificationMethod-BxseSDWK-Ghg2o_Hj.js} +1 -1
- package/dist/{did-key-common.esm-C8caUy6x-CUGnGiom.js → did-key-common.esm-C42sQiXe-DN5hgDGM.js} +3 -3
- package/dist/{did-key-ed25519.esm-CmW3tWKP-Y6ZSpFNY.js → did-key-ed25519.esm-CO7qImeZ-BR5JRBUU.js} +1 -1
- package/dist/did-key-secp256k1.esm-BblZ1xRe-4Ak_uTKC.js +1 -0
- package/dist/downloadPDF-XZlmMePj.js +346 -0
- package/dist/elliptic-6eMlPaPZ-CGOSt2J1.js +1 -0
- package/dist/{ensureNotRevoked-gui-UMnE-CENgoep9.js → ensureNotRevoked-gui-UMnE-DnVNmhNy.js} +1 -1
- package/dist/index-C-APorIs.js +2 -0
- package/dist/index-Dzjg2qbR-DK7tzt5T.js +22 -0
- package/dist/{jsonld-signatures-BGggIvjB-DXkWdXeB.js → index-VOqA2-xz-CKqwdkuf.js} +14 -10
- package/dist/index-WN144sZ6-DKm58evR.js +3 -0
- package/dist/index.es-B13oYDrC.js +56 -0
- package/dist/{jsonld-Cm7t2ORw-D_C9ciG_.js → jsonld-BpvX3DRL-qZrjsUmJ.js} +3 -3
- package/dist/main.js +109 -109
- package/dist/pako.esm-DnD5dZGi-Bw1vqMku.js +2 -0
- package/dist/purify-hA3K4SAZ.js +2 -0
- package/dist/retrieveVerificationMethodPublicKey-fVSjg83n-B4VhVtVk.js +1 -0
- package/dist/webcrypto.es-DQnPRx8R-BJSH271h.js +41 -0
- package/package.json +8 -7
- package/dist/EcdsaSecp256k1Signature2019-D8D2kh2C-D_9G-pvc.js +0 -4
- package/dist/MerkleProof2019-CNv70A45-NTmYz6kF.js +0 -3
- package/dist/checkCredentialSchemaConformity-DTqaxENC-DVWS3_Eh.js +0 -1
- package/dist/did-key-secp256k1.esm-DzS1X49n-DBt648mN.js +0 -1
- package/dist/downloadPDF-B1DL4u2a.js +0 -346
- package/dist/elliptic-Bnve3wuI-D-NH8siB.js +0 -1
- package/dist/index-CfIOMbD1.js +0 -2
- package/dist/index-DCloIN9Y-xgvZvTQb.js +0 -3
- package/dist/index-DUjMpuQT-ZifknGWx.js +0 -5
- package/dist/index.es-D8QzgW47.js +0 -56
- package/dist/pako.esm-DnD5dZGi-HambcU-w.js +0 -2
- package/dist/purify-C5H8D62I.js +0 -2
- /package/dist/{ensureNotRevoked-4-MbmLBE-DvMIgM4L.js → ensureNotRevoked-D9_PlMpD-DvMIgM4L.js} +0 -0
- /package/dist/{ensureValidIssuingKey-Chj896Xe-frafTbMl.js → ensureValidIssuingKey-C7MTkDyV-frafTbMl.js} +0 -0
- /package/dist/{index-RPby1iUS-CHN5LgUq.js → index-BZds3Ljo-CHN5LgUq.js} +0 -0
- /package/dist/{index-BcoFZOIG-Dgus2xdV.js → index-CWugL4dz-Dgus2xdV.js} +0 -0
- /package/dist/{sha256-BU_-grHj-BYFBxJ7m.js → sha256-D_qJpPFT-BYFBxJ7m.js} +0 -0
- /package/dist/{x25519-BmUS3FQ1-DcUk09rC.js → x25519-Dm-l65ld-DcUk09rC.js} +0 -0
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{p as e,V as t,d as r,u as n,x as o,B as i,i as s,g as a,y as c}from"./main.js";import{b as u}from"./index-BcoFZOIG-Dgus2xdV.js";import{b as l,r as f,i as p,m as d,e as h}from"./elliptic-Bnve3wuI-D-NH8siB.js";function y(e,n){if(!e.verificationMethod)return void console.warn("No verification method found in the issuer document. This will likely become a requirement in the near future");const o=n.split("#")[1],i=e.verificationMethod.find((e=>e.id===`#${o}`||e.id===n));if(!i)throw new t("retrieveVerificationMethodPublicKey",`${u} - ${r.i18n.getText("errors","retrieveVerificationMethodPublicKey")}`);return i}var b=n(o),w=n(c),m={exports:{}};
|
|
2
|
-
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
3
|
-
!function(e,t){var r=f,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)}}(m,m.exports);var g=m.exports;var v=class extends Error{constructor(e){super(e||"This operation is not supported for this key type")}};var k=class extends Error{constructor(){super("This has not been implemented yet")}};var _=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)}};const P=k;var E,S=class{constructor(e){this.params=e}fromPrivatePKCS1(e){throw new P}fromPrivatePKCS8(e){throw new P}fromPublicPKCS1(e){throw new P}fromPublicPKCS8(e){throw new P}fromPrivateBlk(e){throw new P}fromPublicBlk(e){throw new P}fromJwk(e){throw new P}toPrivatePKCS1(e){throw new P}toPrivatePKCS8(e){throw new P}toPublicPKCS1(e){throw new P}toPublicPKCS8(e){throw new P}toPrivateBlk(e){throw new P}toPublicBlk(e){throw new P}toPrivateJwk(e){throw new P}toPublicJwk(e){throw new P}static formatPem(e,t){return`-----BEGIN ${t} KEY-----\n`+e.match(/.{1,64}/g).join("\n")+`\n-----END ${t} KEY-----`}},K={},A={},x={},C=f,B=C.Buffer,j={};for(E in C)C.hasOwnProperty(E)&&"SlowBuffer"!==E&&"Buffer"!==E&&(j[E]=C[E]);var I=j.Buffer={};for(E in B)B.hasOwnProperty(E)&&"allocUnsafe"!==E&&"allocUnsafeSlow"!==E&&(I[E]=B[E]);if(j.Buffer.prototype=B.prototype,I.from&&I.from!==Uint8Array.from||(I.from=function(e,t,r){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 B(e,t,r)}),I.alloc||(I.alloc=function(e,t,r){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 n=B(e);return t&&0!==t.length?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n}),!j.kStringMaxLength)try{j.kStringMaxLength=e.binding("buffer").kStringMaxLength}catch(e){}j.constants||(j.constants={MAX_LENGTH:j.kMaxLength},j.kStringMaxLength&&(j.constants.MAX_STRING_LENGTH=j.kStringMaxLength));var U=j,T={};const q=p;function N(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function O(e,t){this.path=e,this.rethrow(t)}T.Reporter=N,N.prototype.isError=function(e){return e instanceof O},N.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},N.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},N.prototype.enterKey=function(e){return this._reporterState.path.push(e)},N.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},N.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},N.prototype.path=function(){return this._reporterState.path.join("/")},N.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},N.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},N.prototype.error=function(e){let t;const r=this._reporterState,n=e instanceof O;if(t=n?e:new O(r.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},N.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},q(O,Error),O.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,O),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this};var z={};const R=p,D=T.Reporter,V=U.Buffer;function M(e,t){D.call(this,t),V.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function L(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return L.isEncoderBuffer(e)||(e=new L(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=V.byteLength(e);else{if(!V.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}R(M,D),z.DecoderBuffer=M,M.isDecoderBuffer=function(e){if(e instanceof M)return!0;return"object"==typeof e&&V.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},M.prototype.save=function(){return{offset:this.offset,reporter:D.prototype.save.call(this)}},M.prototype.restore=function(e){const t=new M(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,D.prototype.restore.call(this,e.reporter),t},M.prototype.isEmpty=function(){return this.offset===this.length},M.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},M.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const r=new M(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},M.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},z.EncoderBuffer=L,L.isEncoderBuffer=function(e){if(e instanceof L)return!0;return"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},L.prototype.join=function(e,t){return e||(e=V.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):V.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e};const J=T.Reporter,$=z.EncoderBuffer,F=z.DecoderBuffer,Z=d,G=["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"],Y=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(G);function H(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())}var X=H;const W=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];H.prototype.clone=function(){const e=this._baseState,t={};W.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},H.prototype._wrap=function(){const e=this._baseState;Y.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},H.prototype._init=function(e){const t=this._baseState;Z(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),Z.equal(t.children.length,1,"Root node can have only one child")},H.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&&(Z(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(Z(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){H.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),G.forEach((function(e){H.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return Z(null===t.tag),t.tag=e,this._useArgs(r),this}})),H.prototype.use=function(e){Z(e);const t=this._baseState;return Z(null===t.use),t.use=e,this},H.prototype.optional=function(){return this._baseState.optional=!0,this},H.prototype.def=function(e){const t=this._baseState;return Z(null===t.default),t.default=e,t.optional=!0,this},H.prototype.explicit=function(e){const t=this._baseState;return Z(null===t.explicit&&null===t.implicit),t.explicit=e,this},H.prototype.implicit=function(e){const t=this._baseState;return Z(null===t.explicit&&null===t.implicit),t.implicit=e,this},H.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},H.prototype.key=function(e){const t=this._baseState;return Z(null===t.key),t.key=e,this},H.prototype.any=function(){return this._baseState.any=!0,this},H.prototype.choice=function(e){const t=this._baseState;return Z(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},H.prototype.contains=function(e){const t=this._baseState;return Z(null===t.use),t.contains=e,this},H.prototype._decode=function(e,t){const r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));let n,o=r.default,i=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){let n=null;if(null!==r.explicit?n=r.explicit:null!==r.implicit?n=r.implicit:null!==r.tag&&(n=r.tag),null!==n||r.any){if(i=this._peekTag(e,n,r.any),e.isError(i))return i}else{const n=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),i=!0}catch(e){i=!1}e.restore(n)}}if(r.obj&&i&&(n=e.enterObject()),i){if(null!==r.explicit){const t=this._decodeTag(e,r.explicit);if(e.isError(t))return t;e=t}const n=e.offset;if(null===r.use&&null===r.choice){let t;r.any&&(t=e.save());const n=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(n))return n;r.any?o=e.raw(t):e=n}if(t&&t.track&&null!==r.tag&&t.track(e.path(),n,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),r.any||(o=null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t)),e.isError(o))return o;if(r.any||null!==r.choice||null===r.children||r.children.forEach((function(r){r._decode(e,t)})),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){const n=new F(o);o=this._getUse(r.contains,e._reporterState.obj)._decode(n,t)}}return r.obj&&i&&(o=e.leaveObject(n)),null===r.key||null===o&&!0!==i?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,o),o},H.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)},H.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),Z(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},H.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")},H.prototype._createEncoderBuffer=function(e){return new $(e,this.reporter)},H.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},H.prototype._encodeValue=function(e,t,r){const n=this._baseState;if(null===n.parent)return n.children[0]._encode(e,t||new J);let o=null;if(this.reporter=t,n.optional&&void 0===e){if(null===n.default)return;e=n.default}let i=null,s=!1;if(n.any)o=this._createEncoderBuffer(e);else if(n.choice)o=this._encodeChoice(e,t);else if(n.contains)i=this._getUse(n.contains,r)._encode(e,t),s=!0;else if(n.children)i=n.children.map((function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");const n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");const o=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),o}),this).filter((function(e){return e})),i=this._createEncoderBuffer(i);else if("seqof"===n.tag||"setof"===n.tag){if(!n.args||1!==n.args.length)return t.error("Too many args for : "+n.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");const r=this.clone();r._baseState.implicit=null,i=this._createEncoderBuffer(e.map((function(r){const n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)}),r))}else null!==n.use?o=this._getUse(n.use,r)._encode(e,t):(i=this._encodePrimitive(n.tag,e),s=!0);if(!n.any&&null===n.choice){const e=null!==n.implicit?n.implicit:n.tag,r=null===n.implicit?"universal":"context";null===e?null===n.use&&t.error("Tag could be omitted only for .use()"):null===n.use&&(o=this._encodeComposite(e,s,r,i))}return null!==n.explicit&&(o=this._encodeComposite(n.explicit,!1,"context",o)),o},H.prototype._encodeChoice=function(e,t){const r=this._baseState,n=r.choice[e.type];return n||Z(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},H.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)},H.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},H.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)};var Q={};!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)}(Q);const ee=p,te=U.Buffer,re=X,ne=Q;function oe(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new se,this.tree._init(e.body)}var ie=oe;function se(e){re.call(this,"der",e)}function ae(e){return e<10?"0"+e:e}oe.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},ee(se,re),se.prototype._encodeComposite=function(e,t,r,n){const o=function(e,t,r,n){let o;"seqof"===e?e="seq":"setof"===e&&(e="set");if(ne.tagByName.hasOwnProperty(e))o=ne.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return n.error("Unknown tag: "+e);o=e}if(o>=31)return n.error("Multi-octet tag encoding unsupported");t||(o|=32);return o|=ne.tagClassByName[r||"universal"]<<6,o}(e,t,r,this.reporter);if(n.length<128){const e=te.alloc(2);return e[0]=o,e[1]=n.length,this._createEncoderBuffer([e,n])}let i=1;for(let e=n.length;e>=256;e>>=8)i++;const s=te.alloc(2+i);s[0]=o,s[1]=128|i;for(let e=1+i,t=n.length;t>0;e--,t>>=8)s[e]=255&t;return this._createEncoderBuffer([s,n])},se.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=te.alloc(2*e.length);for(let r=0;r<e.length;r++)t.writeUInt16BE(e.charCodeAt(r),2*r);return this._createEncoderBuffer(t)}return"numstr"===t?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===t?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(t)||"objDesc"===t?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+t+" unsupported")},se.prototype._encodeObjid=function(e,t,r){if("string"==typeof e){if(!t)return this.reporter.error("string objid given, but no values map found");if(!t.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=t[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(!r){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let n=0;for(let t=0;t<e.length;t++){let r=e[t];for(n++;r>=128;r>>=7)n++}const o=te.alloc(n);let i=o.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(o[i--]=127&r;(r>>=7)>0;)o[i--]=128|127&r}return this._createEncoderBuffer(o)},se.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[ae(n.getUTCFullYear()),ae(n.getUTCMonth()+1),ae(n.getUTCDate()),ae(n.getUTCHours()),ae(n.getUTCMinutes()),ae(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[ae(n.getUTCFullYear()%100),ae(n.getUTCMonth()+1),ae(n.getUTCDate()),ae(n.getUTCHours()),ae(n.getUTCMinutes()),ae(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},se.prototype._encodeNull=function(){return this._createEncoderBuffer("")},se.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!te.isBuffer(e)){const t=e.toArray();!e.sign&&128&t[0]&&t.unshift(0),e=te.from(t)}if(te.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=te.alloc(t);return e.copy(r),0===e.length&&(r[0]=0),this._createEncoderBuffer(r)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let r=1;for(let t=e;t>=256;t>>=8)r++;const n=new Array(r);for(let t=n.length-1;t>=0;t--)n[t]=255&e,e>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(te.from(n))},se.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},se.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},se.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};const ce=ie;function ue(e){ce.call(this,e),this.enc="pem"}p(ue,ce);var le=ue;ue.prototype.encode=function(e,t){const r=ce.prototype.encode.call(this,e).toString("base64"),n=["-----BEGIN "+t.label+"-----"];for(let e=0;e<r.length;e+=64)n.push(r.slice(e,e+64));return n.push("-----END "+t.label+"-----"),n.join("\n")},function(e){const t=e;t.der=ie,t.pem=le}(x);var fe={};const pe=p,de=l,he=z.DecoderBuffer,ye=X,be=Q;function we(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new ge,this.tree._init(e.body)}var me=we;function ge(e){ye.call(this,"der",e)}function ve(e,t){let r=e.readUInt8(t);if(e.isError(r))return r;const n=be.tagClass[r>>6],o=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:o,tag:r,tagStr:be.tag[r]}}function ke(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(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}we.prototype.decode=function(e,t){return he.isDecoderBuffer(e)||(e=new he(e,t)),this.tree._decode(e,t)},pe(ge,ye),ge.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;const n=e.save(),o=ve(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)},ge.prototype._decodeTag=function(e,t,r){const n=ve(e,'Failed to decode tag of "'+t+'"');if(e.isError(n))return n;let o=ke(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+'"'))},ge.prototype._skipUntilEnd=function(e,t){for(;;){const r=ve(e,t);if(e.isError(r))return r;const n=ke(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}},ge.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},ge.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")},ge.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,0==(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},ge.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)},ge.prototype._decodeNull=function(){return null},ge.prototype._decodeBool=function(e){const t=e.readUInt8();return e.isError(t)?t:0!==t},ge.prototype._decodeInt=function(e,t){const r=e.raw();let n=new de(r);return t&&(n=t[n.toString(10)]||n),n},ge.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree};const _e=p,Pe=U.Buffer,Ee=me;function Se(e){Ee.call(this,e),this.enc="pem"}_e(Se,Ee);var Ke=Se;Se.prototype.decode=function(e,t){const r=e.toString().split(/[\r\n]+/g),n=t.label.toUpperCase(),o=/^-----(BEGIN|END) ([^-]+)-----$/;let i=-1,s=-1;for(let e=0;e<r.length;e++){const t=r[e].match(o);if(null!==t&&t[2]===n){if(-1!==i){if("END"!==t[1])break;s=e;break}if("BEGIN"!==t[1])break;i=e}}if(-1===i||-1===s)throw new Error("PEM section not found for: "+n);const a=r.slice(i+1,s).join("");a.replace(/[^a-z0-9+/=]+/gi,"");const c=Pe.from(a,"base64");return Ee.prototype.decode.call(this,c,t)},function(e){const t=e;t.der=me,t.pem=Ke}(fe),function(e){const t=x,r=fe,n=p;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)}}(A);var Ae={};!function(e){const t=Ae;t.Reporter=T.Reporter,t.DecoderBuffer=z.DecoderBuffer,t.EncoderBuffer=z.EncoderBuffer,t.Node=X}();var xe={};!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=Q}(xe),function(e){const t=K;t.bignum=l,t.define=A.define,t.base=Ae,t.constants=xe,t.decoders=fe,t.encoders=x}();var Ce={exports:{}},Be={},je={};Object.defineProperty(je,"__esModule",{value:!0}),je.default=function(e){var t=e.length,r=t%4;if(!r)return e;var n=t,o=4-r,s=t+o,a=i.alloc(s);for(a.write(e);o--;)a.write("=",n++);return a.toString()},Object.defineProperty(Be,"__esModule",{value:!0});var Ie=je;function Ue(e,t){return void 0===t&&(t="utf8"),s(e)?qe(e.toString("base64")):qe(i.from(e,t).toString("base64"))}function Te(e){return e=e.toString(),Ie.default(e).replace(/\-/g,"+").replace(/_/g,"/")}function qe(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var Ne,Oe=Ue;Oe.encode=Ue,Oe.decode=function(e,t){return void 0===t&&(t="utf8"),i.from(Te(e),"base64").toString(t)},Oe.toBase64=Te,Oe.fromBase64=qe,Oe.toBuffer=function(e){return i.from(Te(e),"base64")},Be.default=Oe,(Ne=Ce).exports=Be.default,Ne.exports.default=Ne.exports;var ze=Ce.exports,Re=a(ze);const De=K,Ve=ze;var Me=class{static convert(e,t,r){if(!e)return;if(t===r)return e;let n;if("raw"===t||e instanceof i)n=e;else if("uint8_array"===t||Array.isArray(e))n=i.from(e);else if("hex"===t)n=i.from(e,"hex");else if("base64"===t)n=i.from(e,"base64");else if("base64url"===t)n=Ve.toBuffer(e);else{if("bn"!==t&&"bignum"!==t)throw new Error("Invalid fromType");n=i.from(this.pad(e.toString(16)),"hex")}if("raw"===r)return n;if("uint8_array"===r)return Array.from(n);if("hex"===r)return n.toString("hex");if("base64"===r)return n.toString("base64");if("base64url"===r)return Ve.fromBase64(n.toString("base64"));if("bn"===r||"bignum"===r)return new De.bignum(n);throw new Error("Invalid toType")}static pad(e){return e.length%2==1?`0${e}`:e}};const Le=K;const Je=new class{constructor(){Object.defineProperty(this,"_registry",{value:{}})}get registry(){return this._registry}define(e,t){this._registry[e]=Le.define(e,t(this))}normalize(e){return this.registry[e]}};Je.define("Version",(e=>function(){this.int({0:"two-prime",1:"multi"})})),Je.define("OtherPrimeInfos",(e=>function(){this.seq().obj(this.key("ri").int(),this.key("di").int(),this.key("ti").int())})),Je.define("AlgorithmIdentifier",(e=>function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())})),Je.define("PrivateKeyInfo",(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())}})),Je.define("PublicKeyInfo",(e=>{let t=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("algorithm").use(t),this.key("publicKey").bitstr())}})),Je.define("RSAPrivateKey",(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.define("RSAPublicKey",(e=>function(){this.seq().obj(this.key("n").int(),this.key("e").int())})),Je.define("ECPrivateKey",(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())}));var $e=Je;const Fe=S,Ze=Me,Ge=$e;var Ye=class e extends Fe{fromPrivatePKCS1(e){let t=Ge.normalize("RSAPrivateKey"),{n:r,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u}=t.decode(e,"der");return{n:Ze.convert(r,"bn","raw"),e:Ze.convert(n,"bn","raw"),d:Ze.convert(o,"bn","raw"),p:Ze.convert(i,"bn","raw"),q:Ze.convert(s,"bn","raw"),dp:Ze.convert(a,"bn","raw"),dq:Ze.convert(c,"bn","raw"),qi:Ze.convert(u,"bn","raw")}}fromPrivatePKCS8(e){let t=Ge.normalize("PrivateKeyInfo"),r=Ge.normalize("RSAPrivateKey"),n=t.decode(e,"der"),{n:o,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=r.decode(n.privateKey,"der");return{n:Ze.convert(o,"bn","raw"),e:Ze.convert(i,"bn","raw"),d:Ze.convert(s,"bn","raw"),p:Ze.convert(a,"bn","raw"),q:Ze.convert(c,"bn","raw"),dp:Ze.convert(u,"bn","raw"),dq:Ze.convert(l,"bn","raw"),qi:Ze.convert(f,"bn","raw")}}fromPublicPKCS1(e){let t=Ge.normalize("RSAPublicKey"),{n:r,e:n}=t.decode(e,"der");return{n:Ze.convert(r,"bn","raw"),e:Ze.convert(n,"bn","raw")}}fromPublicPKCS8(e){let t=Ge.normalize("PublicKeyInfo"),r=Ge.normalize("RSAPublicKey"),n=t.decode(e,"der"),{n:o,e:i}=r.decode(n.publicKey.data,"der");return{n:Ze.convert(o,"bn","raw"),e:Ze.convert(i,"bn","raw")}}fromJwk(e){let{n:t,e:r,d:n,p:o,q:i,dp:s,dq:a,qi:c,alg:u}=e;return{n:Ze.convert(t,"base64url","raw"),e:Ze.convert(r,"base64url","raw"),d:Ze.convert(n,"base64url","raw"),p:Ze.convert(o,"base64url","raw"),q:Ze.convert(i,"base64url","raw"),dp:Ze.convert(s,"base64url","raw"),dq:Ze.convert(a,"base64url","raw"),qi:Ze.convert(c,"base64url","raw")}}toPrivatePKCS1(t){let{n:r,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u}=t,{version:l}=this.params,f=Ge.normalize("RSAPrivateKey").encode({version:l,n:Ze.convert(r,"raw","bn"),e:Ze.convert(n,"raw","bn"),d:Ze.convert(o,"raw","bn"),p:Ze.convert(i,"raw","bn"),q:Ze.convert(s,"raw","bn"),dp:Ze.convert(a,"raw","bn"),dq:Ze.convert(c,"raw","bn"),qi:Ze.convert(u,"raw","bn")},"der").toString("base64");return e.formatPem(f,"RSA PRIVATE")}toPrivatePKCS8(t){let{n:r,e:n,d:o,p:s,q:a,dp:c,dq:u,qi:l}=t,{oid:f,algParameters:p,version:d}=this.params,h=Ge.normalize("PrivateKeyInfo"),y=Ge.normalize("RSAPrivateKey").encode({version:d,n:Ze.convert(r,"raw","bn"),e:Ze.convert(n,"raw","bn"),d:Ze.convert(o,"raw","bn"),p:Ze.convert(s,"raw","bn"),q:Ze.convert(a,"raw","bn"),dp:Ze.convert(c,"raw","bn"),dq:Ze.convert(u,"raw","bn"),qi:Ze.convert(l,"raw","bn")},"der"),b=h.encode({version:d,algorithm:{algorithm:f.split("."),parameters:i.from(p,"hex")},privateKey:y},"der").toString("base64");return e.formatPem(b,"PRIVATE")}toPublicPKCS1(t){let{n:r,e:n}=t,{version:o}=this.params,i=Ge.normalize("RSAPublicKey").encode({version:o,n:Ze.convert(r,"raw","bn"),e:Ze.convert(n,"raw","bn")},"der").toString("base64");return e.formatPem(i,"RSA PUBLIC")}toPublicPKCS8(t){let{n:r,e:n}=t,{oid:o,algParameters:s}=this.params,a=Ge.normalize("PublicKeyInfo"),c=Ge.normalize("RSAPublicKey").encode({n:Ze.convert(r,"raw","bn"),e:Ze.convert(n,"raw","bn")},"der"),u=a.encode({algorithm:{algorithm:o.split("."),parameters:i.from(s,"hex")},publicKey:{unused:0,data:c}},"der").toString("base64");return e.formatPem(u,"PUBLIC")}toPrivateJwk(e){let{n:t,e:r,d:n,p:o,q:i,dp:s,dq:a,qi:c}=e,{kty:u}=this.params;return{kty:u,n:Ze.convert(t,"raw","base64url"),e:Ze.convert(r,"raw","base64url"),d:Ze.convert(n,"raw","base64url"),p:Ze.convert(o,"raw","base64url"),q:Ze.convert(i,"raw","base64url"),dp:Ze.convert(s,"raw","base64url"),dq:Ze.convert(a,"raw","base64url"),qi:Ze.convert(c,"raw","base64url")}}toPublicJwk(e){let{n:t,e:r}=e,{kty:n}=this.params;return{kty:n,n:Ze.convert(t,"raw","base64url"),e:Ze.convert(r,"raw","base64url")}}};const He=new(0,h.ec)("secp256k1"),Xe=S,We=Me,Qe=$e;var et=class e extends Xe{fromPrivatePKCS1(t){let r=Qe.normalize("ECPrivateKey").decode(t,"der"),{privateKey:n,publicKey:{data:o}}=r,i=We.convert(o,"raw","hex"),{x:s,y:a}=e.getPoint(i);return{d:n,x:s,y:a}}fromPrivatePKCS8(t){let r=Qe.normalize("PrivateKeyInfo"),n=Qe.normalize("ECPrivateKey"),o=r.decode(t,"der"),i=n.decode(o.privateKey,"der"),{privateKey:s,publicKey:{data:a}}=i,c=We.convert(a,"raw","hex"),{x:u,y:l}=e.getPoint(c);return{d:s,x:u,y:l}}fromPublicPKCS8(t){let r=Qe.normalize("PublicKeyInfo").decode(t,"der"),n=We.convert(r.publicKey.data,"raw","hex");return e.getPoint(n)}fromPrivateBlk(e){let t=He.keyFromPrivate(e,"hex"),r=t.getPublic();return{d:We.convert(t.priv,"bn","raw"),x:We.convert(r.getX(),"bn","raw"),y:We.convert(r.getY(),"bn","raw")}}fromPublicBlk(t){return e.getPoint(t)}fromJwk(e){let{d:t,x:r,y:n}=e;return{d:We.convert(t,"base64url","raw"),x:We.convert(r,"base64url","raw"),y:We.convert(n,"base64url","raw")}}toPrivatePKCS1(t){let{namedCurve:r,keyVersion:n}=this.params,{d:o,x:i,y:s}=t,a=Qe.normalize("ECPrivateKey"),c=e.makePoint(i,s),u=a.encode({version:n,privateKey:o,parameters:{type:"namedCurve",value:r.split(".")},publicKey:{unused:0,data:c}},"der").toString("base64");return e.formatPem(u,"EC PRIVATE")}toPrivatePKCS8(t){let{oid:r,algParameters:n,keyVersion:o,infoVersion:s}=this.params,{d:a,x:c,y:u}=t,l=Qe.normalize("PrivateKeyInfo"),f=Qe.normalize("ECPrivateKey"),p=e.makePoint(c,u),d=f.encode({version:o,privateKey:a,publicKey:{unused:0,data:p}},"der"),h=l.encode({version:s,algorithm:{algorithm:r.split("."),parameters:i.from(n,"hex")},privateKey:d},"der").toString("base64");return e.formatPem(h,"PRIVATE")}toPublicPKCS8(t){let{oid:r,algParameters:n}=this.params,{x:o,y:s}=t,a=Qe.normalize("PublicKeyInfo"),c=e.makePoint(o,s),u=a.encode({algorithm:{algorithm:r.split("."),parameters:i.from(n,"hex")},publicKey:{unused:0,data:c}},"der").toString("base64");return e.formatPem(u,"PUBLIC")}toPrivateBlk(e){return e.d.toString("hex")}toPublicBlk(t){return We.convert(e.makePoint(t.x,t.y),"raw","hex")}toPrivateJwk(e){let{crv:t,kty:r}=this.params,{d:n,x:o,y:i}=e;return{kty:r,crv:t,d:We.convert(n,"raw","base64url"),x:We.convert(o,"raw","base64url"),y:We.convert(i,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:r}=this.params,{x:n,y:o}=e;return{kty:r,crv:t,x:We.convert(n,"raw","base64url"),y:We.convert(o,"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:We.convert(t,"hex","raw"),y:We.convert(r,"hex","raw")}}static makePoint(e,t){let r=i.from("04","hex");return i.concat([r,e,t],r.length+e.length+t.length)}};const tt=S,rt=Me,nt=$e;var ot=class e extends tt{fromPrivatePKCS8(e){const t=nt.normalize("PrivateKeyInfo").decode(e,"der").privateKey.slice(2);return{d:t,x:this.publicKeyFromPrivate(t)}}fromPublicPKCS8(e){const t=nt.normalize("PublicKeyInfo").decode(e,"der");return{x:rt.convert(t.publicKey.data,"hex","raw")}}fromJwk(e){let{d:t,x:r}=e;return{d:rt.convert(t,"base64url","raw"),x:rt.convert(r,"base64url","raw")}}toPrivatePKCS8(t){let{oid:r,infoVersion:n}=this.params,{d:o}=t;const i=nt.normalize("PrivateKeyInfo"),s=this.privateKeyPadding(o);let a=i.encode({version:n,algorithm:{algorithm:r.split(".")},privateKey:s},"der").toString("base64");return e.formatPem(a,"PRIVATE")}toPublicPKCS8(t){let{oid:r}=this.params,{x:n}=t,o=nt.normalize("PublicKeyInfo").encode({algorithm:{algorithm:r.split(".")},publicKey:{unused:0,data:rt.convert(n,"hex","raw")}},"der").toString("base64");return e.formatPem(o,"PUBLIC")}toPrivateJwk(e){let{crv:t,kty:r}=this.params,{d:n,x:o}=e;return{kty:r,crv:t,d:rt.convert(n,"raw","base64url"),x:rt.convert(o,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:r}=this.params,{x:n}=e;return{kty:r,crv:t,x:rt.convert(n,"raw","base64url")}}privateKeyPadding(e){let t;if("Ed25519"!==this.params.crv)throw new Error(`${this.params.crv} is an invalid curve for EdDSA`);return t=i.from("0420","hex"),i.concat([t,e],t.length+e.length)}publicKeyFromPrivate(e){if("Ed25519"===this.params.crv){const t=new(0,h.eddsa)("ed25519");return i.from(t.keyFromSecret(e).getPublic())}throw new Error(`${this.params.crv} is an invalid curve for EdDSA`)}};const it=Ye,st=et,at=ot,ct=new _;ct.define([{kty:"RSA",oid:"1.2.840.113549.1.1.1",algParameters:"0500",version:"two-prime"}],it),ct.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"}],st),ct.define([{kty:"OKP",crv:"Ed25519",oid:"1.3.101.112",infoVersion:"two-prime"}],at);const ut=v,lt=k,ft=ct,pt=$e,dt=RegExp("\r?\n","g");class ht{constructor(e,t){if(!e)throw new ut("key is required");if(!t)throw new ut("options are required");let{kty:r,format:n,selector:o,crv:i,oid:s}=t;if(!t.kty)throw new ut("options.kty is required");if(!t.format)throw new ut("options.format is required");if(!t.selector)throw new ut("options.selector is required");if(!t.crv&&!t.oid)throw new ut("options.crv or options.oid is required");this.kty=r,this.format=n,this.selector=o,this.crv=i,this.oid=s,this.key=this.parseKey(e)}static from(e,t){if(!e)throw new ut("key is required");if(!t)throw new ut("format is required");if("jwk"===t){let r;if("string"==typeof e)try{r=JSON.parse(e)}catch(e){throw new ut("key is not a valid JWK")}else"object"==typeof e&&(r=e);let n,{kty:o,crv:i}=r;if(!o)throw new ut("kty is required for JWK");if("EC"===o&&!i)throw new ut("crv is required for EC JWK");"RSA"===o&&(n=ft.find((e=>e.kty===o)).oid);let s=r.d?"private":"public";return new ht(r,{kty:o,crv:i,oid:n,format:t,selector:s})}if("pem"===t){if("string"!=typeof e)throw new ut("key is not a valid PEM string");let r=e.split(dt),n=r.splice(0,1);r.splice(r.length-1,1);let o,s,a=r.join(""),c=/^-----BEGIN ((RSA|EC) )?(PUBLIC|PRIVATE) KEY-----$/.exec(n),u=c?c[2]:void 0,l=c?c[3]:void 0,f=i.from(a,"base64");if(!l)throw new ut("key is not a valid PEM string");if(u){if("RSA"===u)l="PRIVATE"===l?"private_pkcs1":"public_pkcs1",o=ft.find((e=>e.kty===u)).oid;else if("EC"===u){let e;if("PRIVATE"===l){l="private_pkcs1",e=pt.normalize(`${u}PrivateKey`).decode(f,"der")}else if("PUBLIC"===l){l="public_pkcs1",e=pt.normalize(`${u}PrivateKey`).decode(f,"der")}let{parameters:{value:t}}=e;s=ft.find((e=>e.namedCurve===t.join("."))).crv}}else{let e,t=pt.normalize("PrivateKeyInfo"),r=pt.normalize("PublicKeyInfo");"PRIVATE"===l?(l="private_pkcs8",e=t.decode(f,"der")):"PUBLIC"===l&&(l="public_pkcs8",e=r.decode(f,"der"));let{algorithm:{algorithm:n,parameters:i}}=e;n=n.join("."),i=i?i.toString("hex"):void 0;const a=ft.find((e=>e.oid===n));if(u=a?a.kty:void 0,!u)throw new ut(`${n} is not supported`);"RSA"===u||"OKP"===u?o=n:"EC"===u&&(s=ft.find((e=>e.algParameters===i)).crv)}return new ht(f,{kty:u,oid:o,crv:s,format:t,selector:l})}if("blk"===t)return new ht(e,{kty:"EC",crv:"K-256",format:t,selector:e.length>64?"public":"private"});throw new ut(`Invalid format ${t}`)}get alg(){let{kty:e,crv:t,oid:r}=this;if(!this.algorithm){if(t)Object.defineProperty(this,"algorithm",{value:ft.normalize(e,"crv",t)});else{if(!r)throw new Error("Both crv and oid are undefined");Object.defineProperty(this,"algorithm",{value:ft.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(e){let{key:t,alg:r,selector:n}=this;switch(e){case"public":return r.toPublicJwk(t);case"private":if(n.includes("public"))throw new ut("Cannot export a private key from a public key");return r.toPrivateJwk(t);default:throw new Error("Invalid key selector")}}toString(e="pem",t="public_pkcs8"){let{key:r,alg:n,selector:o}=this;if("pem"===e)switch(t){case"public_pkcs1":return n.toPublicPKCS1(r);case"public_pkcs8":return n.toPublicPKCS8(r);case"private_pkcs1":if(o.includes("public"))throw new ut("Cannot export a private key from a public key");return n.toPrivatePKCS1(r);case"private_pkcs8":if(o.includes("public"))throw new ut("Cannot export a private key from a public key");return n.toPrivatePKCS8(r);default:throw new Error("Invalid key selector")}else if("jwk"===e)switch(t){case"public":return JSON.stringify(n.toPublicJwk(r));case"private":if(o.includes("public"))throw new ut("Cannot export a private key from a public key");return JSON.stringify(n.toPrivateJwk(r));default:throw new Error("Invalid key selector")}else if("blk"===e)switch(t){case"private":if(o.includes("public"))throw new ut("Cannot export a private key from a public key");return n.toPrivateBlk(r);case"public":return n.toPublicBlk(r);default:throw new Error("Invalid key selector")}throw new lt}}var yt=a(ht);const bt="Impossible case. Please create issue.",wt="The tweak was out of range or the resulted private key is invalid",mt="The tweak was out of range or equal to zero",gt="Unknow error on context randomization",vt="Private Key is invalid",kt="Public Key could not be parsed",_t="Public Key serialization error",Pt="The sum of the public keys is not valid",Et="Signature could not be parsed",St="The nonce generation function failed, or the private key was invalid",Kt="Public key could not be recover",At="Scalar was invalid (zero or overflow)";function xt(e,t){if(!e)throw new Error(t)}function Ct(e,t,r){if(xt(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(", ")}]`;xt(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;xt(t.length===r,n)}}function Bt(e){xt("Boolean"===It(e),"Expected compressed to be a Boolean")}function jt(e=(e=>new Uint8Array(e)),t){return"function"==typeof e&&(e=e(t)),Ct("output",e,t),e}function It(e){return Object.prototype.toString.call(e).slice(8,-1)}const Ut=new(0,h.ec)("secp256k1"),Tt=Ut.curve,qt=Tt.n.constructor;function Nt(e){const t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){let r=new qt(t);if(r.cmp(Tt.p)>=0)return null;r=r.toRed(Tt.red);let n=r.redSqr().redIMul(r).redIAdd(Tt.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),Ut.keyPair({pub:{x:r,y:n}})}(t,e.subarray(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){let n=new qt(t),o=new qt(r);if(n.cmp(Tt.p)>=0||o.cmp(Tt.p)>=0)return null;if(n=n.toRed(Tt.red),o=o.toRed(Tt.red),(6===e||7===e)&&o.isOdd()!==(7===e))return null;const i=n.redSqr().redIMul(n);return o.redSqr().redISub(i.redIAdd(Tt.b)).isZero()?Ut.keyPair({pub:{x:n,y:o}}):null}(t,e.subarray(1,33),e.subarray(33,65));default:return null}}function Ot(e,t){const r=t.encode(null,33===e.length);for(let t=0;t<e.length;++t)e[t]=r[t]}var zt=(e=>({contextRandomize(t){if(xt(null===t||t instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==t&&Ct("seed",t,32),1===e.contextRandomize(t))throw new Error(gt)},privateKeyVerify:t=>(Ct("private key",t,32),0===e.privateKeyVerify(t)),privateKeyNegate(t){switch(Ct("private key",t,32),e.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(bt)}},privateKeyTweakAdd(t,r){switch(Ct("private key",t,32),Ct("tweak",r,32),e.privateKeyTweakAdd(t,r)){case 0:return t;case 1:throw new Error(wt)}},privateKeyTweakMul(t,r){switch(Ct("private key",t,32),Ct("tweak",r,32),e.privateKeyTweakMul(t,r)){case 0:return t;case 1:throw new Error(mt)}},publicKeyVerify:t=>(Ct("public key",t,[33,65]),0===e.publicKeyVerify(t)),publicKeyCreate(t,r=!0,n){switch(Ct("private key",t,32),Bt(r),n=jt(n,r?33:65),e.publicKeyCreate(n,t)){case 0:return n;case 1:throw new Error(vt);case 2:throw new Error(_t)}},publicKeyConvert(t,r=!0,n){switch(Ct("public key",t,[33,65]),Bt(r),n=jt(n,r?33:65),e.publicKeyConvert(n,t)){case 0:return n;case 1:throw new Error(kt);case 2:throw new Error(_t)}},publicKeyNegate(t,r=!0,n){switch(Ct("public key",t,[33,65]),Bt(r),n=jt(n,r?33:65),e.publicKeyNegate(n,t)){case 0:return n;case 1:throw new Error(kt);case 2:throw new Error(bt);case 3:throw new Error(_t)}},publicKeyCombine(t,r=!0,n){xt(Array.isArray(t),"Expected public keys to be an Array"),xt(t.length>0,"Expected public keys array will have more than zero items");for(const e of t)Ct("public key",e,[33,65]);switch(Bt(r),n=jt(n,r?33:65),e.publicKeyCombine(n,t)){case 0:return n;case 1:throw new Error(kt);case 2:throw new Error(Pt);case 3:throw new Error(_t)}},publicKeyTweakAdd(t,r,n=!0,o){switch(Ct("public key",t,[33,65]),Ct("tweak",r,32),Bt(n),o=jt(o,n?33:65),e.publicKeyTweakAdd(o,t,r)){case 0:return o;case 1:throw new Error(kt);case 2:throw new Error(wt)}},publicKeyTweakMul(t,r,n=!0,o){switch(Ct("public key",t,[33,65]),Ct("tweak",r,32),Bt(n),o=jt(o,n?33:65),e.publicKeyTweakMul(o,t,r)){case 0:return o;case 1:throw new Error(kt);case 2:throw new Error(mt)}},signatureNormalize(t){switch(Ct("signature",t,64),e.signatureNormalize(t)){case 0:return t;case 1:throw new Error(Et)}},signatureExport(t,r){Ct("signature",t,64);const n={output:r=jt(r,72),outputlen:72};switch(e.signatureExport(n,t)){case 0:return r.slice(0,n.outputlen);case 1:throw new Error(Et);case 2:throw new Error(bt)}},signatureImport(t,r){switch(Ct("signature",t),r=jt(r,64),e.signatureImport(r,t)){case 0:return r;case 1:throw new Error(Et);case 2:throw new Error(bt)}},ecdsaSign(t,r,n={},o){Ct("message",t,32),Ct("private key",r,32),xt("Object"===It(n),"Expected options to be an Object"),void 0!==n.data&&Ct("options.data",n.data),void 0!==n.noncefn&&xt("Function"===It(n.noncefn),"Expected options.noncefn to be a Function");const i={signature:o=jt(o,64),recid:null};switch(e.ecdsaSign(i,t,r,n.data,n.noncefn)){case 0:return i;case 1:throw new Error(St);case 2:throw new Error(bt)}},ecdsaVerify(t,r,n){switch(Ct("signature",t,64),Ct("message",r,32),Ct("public key",n,[33,65]),e.ecdsaVerify(t,r,n)){case 0:return!0;case 3:return!1;case 1:throw new Error(Et);case 2:throw new Error(kt)}},ecdsaRecover(t,r,n,o=!0,i){switch(Ct("signature",t,64),xt("Number"===It(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),Ct("message",n,32),Bt(o),i=jt(i,o?33:65),e.ecdsaRecover(i,t,r,n)){case 0:return i;case 1:throw new Error(Et);case 2:throw new Error(Kt);case 3:throw new Error(bt)}},ecdh(t,r,n={},o){switch(Ct("public key",t,[33,65]),Ct("private key",r,32),xt("Object"===It(n),"Expected options to be an Object"),void 0!==n.data&&Ct("options.data",n.data),void 0!==n.hashfn?(xt("Function"===It(n.hashfn),"Expected options.hashfn to be a Function"),void 0!==n.xbuf&&Ct("options.xbuf",n.xbuf,32),void 0!==n.ybuf&&Ct("options.ybuf",n.ybuf,32),Ct("output",o)):o=jt(o,32),e.ecdh(o,t,r,n.data,n.hashfn,n.xbuf,n.ybuf)){case 0:return o;case 1:throw new Error(kt);case 2:throw new Error(At)}}}))({contextRandomize:()=>0,privateKeyVerify(e){const t=new qt(e);return t.cmp(Tt.n)<0&&!t.isZero()?0:1},privateKeyNegate(e){const t=new qt(e),r=Tt.n.sub(t).umod(Tt.n).toArrayLike(Uint8Array,"be",32);return e.set(r),0},privateKeyTweakAdd(e,t){const r=new qt(t);if(r.cmp(Tt.n)>=0)return 1;if(r.iadd(new qt(e)),r.cmp(Tt.n)>=0&&r.isub(Tt.n),r.isZero())return 1;const n=r.toArrayLike(Uint8Array,"be",32);return e.set(n),0},privateKeyTweakMul(e,t){let r=new qt(t);if(r.cmp(Tt.n)>=0||r.isZero())return 1;r.imul(new qt(e)),r.cmp(Tt.n)>=0&&(r=r.umod(Tt.n));const n=r.toArrayLike(Uint8Array,"be",32);return e.set(n),0},publicKeyVerify:e=>null===Nt(e)?1:0,publicKeyCreate(e,t){const r=new qt(t);if(r.cmp(Tt.n)>=0||r.isZero())return 1;return Ot(e,Ut.keyFromPrivate(t).getPublic()),0},publicKeyConvert(e,t){const r=Nt(t);if(null===r)return 1;return Ot(e,r.getPublic()),0},publicKeyNegate(e,t){const r=Nt(t);if(null===r)return 1;const n=r.getPublic();return n.y=n.y.redNeg(),Ot(e,n),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e<t.length;++e)if(r[e]=Nt(t[e]),null===r[e])return 1;let n=r[0].getPublic();for(let e=1;e<r.length;++e)n=n.add(r[e].pub);return n.isInfinity()?2:(Ot(e,n),0)},publicKeyTweakAdd(e,t,r){const n=Nt(t);if(null===n)return 1;if((r=new qt(r)).cmp(Tt.n)>=0)return 2;const o=n.getPublic().add(Tt.g.mul(r));return o.isInfinity()?2:(Ot(e,o),0)},publicKeyTweakMul(e,t,r){const n=Nt(t);if(null===n)return 1;if((r=new qt(r)).cmp(Tt.n)>=0||r.isZero())return 2;return Ot(e,n.getPublic().mul(r)),0},signatureNormalize(e){const t=new qt(e.subarray(0,32)),r=new qt(e.subarray(32,64));return t.cmp(Tt.n)>=0||r.cmp(Tt.n)>=0?1:(1===r.cmp(Ut.nh)&&e.set(Tt.n.sub(r).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,t){const r=t.subarray(0,32),n=t.subarray(32,64);if(new qt(r).cmp(Tt.n)>=0)return 1;if(new qt(n).cmp(Tt.n)>=0)return 1;const{output:o}=e;let i=o.subarray(4,37);i[0]=0,i.set(r,1);let s=33,a=0;for(;s>1&&0===i[a]&&!(128&i[a+1]);--s,++a);if(i=i.subarray(a),128&i[0])return 1;if(s>1&&0===i[0]&&!(128&i[1]))return 1;let c=o.subarray(39,72);c[0]=0,c.set(n,1);let u=33,l=0;for(;u>1&&0===c[l]&&!(128&c[l+1]);--u,++l);return c=c.subarray(l),128&c[0]||u>1&&0===c[0]&&!(128&c[1])?1:(e.outputlen=6+s+u,o[0]=48,o[1]=e.outputlen-2,o[2]=2,o[3]=i.length,o.set(i,4),o[4+s]=2,o[5+s]=c.length,o.set(c,6+s),0)},signatureImport(e,t){if(t.length<8)return 1;if(t.length>72)return 1;if(48!==t[0])return 1;if(t[1]!==t.length-2)return 1;if(2!==t[2])return 1;const r=t[3];if(0===r)return 1;if(5+r>=t.length)return 1;if(2!==t[4+r])return 1;const n=t[5+r];if(0===n)return 1;if(6+r+n!==t.length)return 1;if(128&t[4])return 1;if(r>1&&0===t[4]&&!(128&t[5]))return 1;if(128&t[r+6])return 1;if(n>1&&0===t[r+6]&&!(128&t[r+7]))return 1;let o=t.subarray(4,4+r);if(33===o.length&&0===o[0]&&(o=o.subarray(1)),o.length>32)return 1;let i=t.subarray(6+r);if(33===i.length&&0===i[0]&&(i=i.slice(1)),i.length>32)throw new Error("S length is too long");let s=new qt(o);s.cmp(Tt.n)>=0&&(s=new qt(0));let a=new qt(t.subarray(6+r));return a.cmp(Tt.n)>=0&&(a=new qt(0)),e.set(s.toArrayLike(Uint8Array,"be",32),0),e.set(a.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(e,t,r,n,o){if(o){const e=o;o=o=>{const i=e(t,r,null,n,o);if(!(i instanceof Uint8Array&&32===i.length))throw new Error("This is the way");return new qt(i)}}const i=new qt(r);if(i.cmp(Tt.n)>=0||i.isZero())return 1;let s;try{s=Ut.sign(t,r,{canonical:!0,k:o,pers:n})}catch(e){return 1}return e.signature.set(s.r.toArrayLike(Uint8Array,"be",32),0),e.signature.set(s.s.toArrayLike(Uint8Array,"be",32),32),e.recid=s.recoveryParam,0},ecdsaVerify(e,t,r){const n={r:e.subarray(0,32),s:e.subarray(32,64)},o=new qt(n.r),i=new qt(n.s);if(o.cmp(Tt.n)>=0||i.cmp(Tt.n)>=0)return 1;if(1===i.cmp(Ut.nh)||o.isZero()||i.isZero())return 3;const s=Nt(r);if(null===s)return 2;const a=s.getPublic();return Ut.verify(t,n,a)?0:3},ecdsaRecover(e,t,r,n){const o={r:t.slice(0,32),s:t.slice(32,64)},i=new qt(o.r),s=new qt(o.s);if(i.cmp(Tt.n)>=0||s.cmp(Tt.n)>=0)return 1;if(i.isZero()||s.isZero())return 2;let a;try{a=Ut.recoverPubKey(n,o,r)}catch(e){return 2}return Ot(e,a),0},ecdh(e,t,r,n,o,i,s){const a=Nt(t);if(null===a)return 1;const c=new qt(r);if(c.cmp(Tt.n)>=0||c.isZero())return 2;const u=a.getPublic().mul(c);if(void 0===o){const t=u.encode(null,!0),r=Ut.hash().update(t).digest();for(let t=0;t<32;++t)e[t]=r[t]}else{i||(i=new Uint8Array(32));const t=u.getX().toArray("be",32);for(let e=0;e<32;++e)i[e]=t[e];s||(s=new Uint8Array(32));const r=u.getY().toArray("be",32);for(let e=0;e<32;++e)s[e]=r[e];const a=o(i,s,n);if(!(a instanceof Uint8Array&&a.length===e.length))return 2;e.set(a)}return 0}}),Rt=a(zt);var Dt=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 d=i-o;d!==i&&0===u[d];)d++;for(var h=new Uint8Array(n+(i-d)),y=n;d!==i;)h[y++]=u[d++];return h}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,d=c-1;(0!==f||p<n)&&-1!==d;d--,p++)f+=256*l[d]>>>0,l[d]=f%s>>>0,f=f/s>>>0;if(0!==f)throw new Error("Non-zero carry");n=p,o++}for(var h=c-n;h!==c&&0===l[h];)h++;for(var y=a.repeat(r);h<c;++h)y+=e.charAt(l[h]);return y},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+s+" character")}}};var Vt=Dt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Mt=a(Vt);export{w as a,b,Rt as c,Vt as d,zt as e,Re as f,Mt as g,yt as k,y as r,g as s};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const t={};
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
4
|
-
*/
|
|
5
|
-
const r="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function e(t,e){return function(t,r,e){if(!(t instanceof Uint8Array))throw new TypeError('"input" must be a Uint8Array.');if("string"!=typeof r)throw new TypeError('"alphabet" must be a string.');if(void 0!==e&&"number"!=typeof e)throw new TypeError('"maxline" must be a number.');if(0===t.length)return"";let n="",o=0;const i=r.length,f=r.charAt(0),h=[0];for(o=0;o<t.length;++o){let r=t[o];for(let t=0;t<h.length;++t)r+=h[t]<<8,h[t]=r%i,r=r/i|0;for(;r>0;)h.push(r%i),r=r/i|0}for(o=0;0===t[o]&&o<t.length-1;++o)n+=f;for(o=h.length-1;o>=0;--o)n+=r[h[o]];if(e){const t=new RegExp(".{1,"+e+"}","g");n=n.match(t).join("\r\n")}return n}(t,r,e)}function n(e){return function(r,e){if("string"!=typeof r)throw new TypeError('"input" must be a string.');if("string"!=typeof e)throw new TypeError('"alphabet" must be a string.');if(0===r.length)return new Uint8Array;let n=t[e];if(!n){n=t[e]=[];for(let t=0;t<e.length;++t)n[e.charCodeAt(t)]=t}r=r.replace(/\s/g,"");const o=e.length,i=e.charAt(0),f=[0];for(let t=0;t<r.length;t++){const e=n[r.charCodeAt(t)];if(void 0===e)return;let i=e;for(let t=0;t<f.length;++t)i+=f[t]*o,f[t]=255&i,i>>=8;for(;i>0;)f.push(255&i),i>>=8}for(let t=0;r[t]===i&&t<r.length-1;++t)f.push(0);return new Uint8Array(f.reverse())}(e,r)}export{n as d,e};
|