@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,4 +1,4 @@
|
|
|
1
|
-
import{g as e,u as t,B as r,i as o}from"./main.js";import{a as n}from"./jsonld-
|
|
1
|
+
import{g as e,u as t,B as r,i as o}from"./main.js";import{a as n}from"./jsonld-BpvX3DRL-qZrjsUmJ.js";var i,a,s=(function(e,t){!function(e,t){for(var r in t)e[r]=t[r]}(t,function(e){var t={};function r(o){if(t[o])return t[o].exports;var n=t[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(o,n,function(t){return e[t]}.bind(null,n));return o},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){
|
|
2
2
|
/*!
|
|
3
3
|
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
4
4
|
*/
|
|
@@ -14,31 +14,31 @@ e.exports={"@context":[{"@version":1.1},"https://w3id.org/security/v1",{AesKeyWr
|
|
|
14
14
|
/*!
|
|
15
15
|
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
16
16
|
*/
|
|
17
|
-
e.exports={SECURITY_CONTEXT_V1_URL:"https://w3id.org/security/v1",SECURITY_CONTEXT_V2_URL:"https://w3id.org/security/v2",CONTEXT_URL:"https://w3id.org/security/v2"}}]))}(i={exports:{}},i.exports),i.exports),c=(a=s)&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a,p=s.contexts,d=s.constants,u=s.CONTEXT,f=s.CONTEXT_URL,l=s.SECURITY_CONTEXT_V1_URL,h=s.SECURITY_CONTEXT_V2_URL,
|
|
17
|
+
e.exports={SECURITY_CONTEXT_V1_URL:"https://w3id.org/security/v1",SECURITY_CONTEXT_V2_URL:"https://w3id.org/security/v2",CONTEXT_URL:"https://w3id.org/security/v2"}}]))}(i={exports:{}},i.exports),i.exports),c=(a=s)&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a,p=s.contexts,d=s.constants,u=s.CONTEXT,f=s.CONTEXT_URL,l=s.SECURITY_CONTEXT_V1_URL,h=s.SECURITY_CONTEXT_V2_URL,y=t(Object.freeze({__proto__:null,CONTEXT:u,CONTEXT_URL:f,SECURITY_CONTEXT_V1_URL:l,SECURITY_CONTEXT_V2_URL:h,constants:d,contexts:p,default:c}));
|
|
18
18
|
/*!
|
|
19
19
|
* Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.
|
|
20
20
|
*/
|
|
21
|
-
const{constants:
|
|
21
|
+
const{constants:m}=y;var w={SECURITY_CONTEXT_URL:m.SECURITY_CONTEXT_V2_URL,SECURITY_CONTEXT_V1_URL:m.SECURITY_CONTEXT_V1_URL,SECURITY_CONTEXT_V2_URL:m.SECURITY_CONTEXT_V2_URL,SECURITY_PROOF_URL:"https://w3id.org/security#proof",SECURITY_SIGNATURE_URL:"https://w3id.org/security#signature"};
|
|
22
22
|
/*!
|
|
23
23
|
* Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.
|
|
24
|
-
*/const
|
|
24
|
+
*/const g=w,{contexts:v}=y;
|
|
25
25
|
/*!
|
|
26
26
|
* Copyright (c) 2018-2021 Digital Bazaar, Inc. All rights reserved.
|
|
27
27
|
*/
|
|
28
|
-
const T=new Map([[
|
|
28
|
+
const T=new Map([[g.SECURITY_CONTEXT_V1_URL,v.get(g.SECURITY_CONTEXT_V1_URL)],[g.SECURITY_CONTEXT_V2_URL,v.get(g.SECURITY_CONTEXT_V2_URL)]]),E={};var x=E;E.extendContextLoader=e=>async t=>{const r=T.get(t);return void 0!==r?{contextUrl:null,documentUrl:t,document:r,tag:"static"}:e(t)},E.strictDocumentLoader=E.extendContextLoader((e=>{throw new Error(`${e} not found.`)}));class b extends Error{constructor(e){super(b._prepareSuperMessage(e)),Object.defineProperty(this,"name",{value:"NonError",configurable:!0,writable:!0}),Error.captureStackTrace&&Error.captureStackTrace(this,b)}static _prepareSuperMessage(e){try{return JSON.stringify(e)}catch{return String(e)}}}const S=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],L=Symbol(".toJSON called"),_=({from:e,seen:t,to_:n,forceEnumerable:i,maxDepth:a,depth:s})=>{const c=n||(Array.isArray(e)?[]:{});if(t.push(e),s>=a)return c;if("function"==typeof e.toJSON&&!0!==e[L])return(e=>{e[L]=!0;const t=e.toJSON();return delete e[L],t})(e);for(const[n,p]of Object.entries(e))"function"==typeof r&&o(p)?c[n]="[object Buffer]":"function"!=typeof p&&(p&&"object"==typeof p?t.includes(e[n])?c[n]="[Circular]":(s++,c[n]=_({from:e[n],seen:t.slice(),forceEnumerable:i,maxDepth:a,depth:s})):c[n]=p);for(const{property:t,enumerable:r}of S)"string"==typeof e[t]&&Object.defineProperty(c,t,{value:e[t],enumerable:!!i||r,configurable:!0,writable:!0});return c};var C={serializeError:(e,t={})=>{const{maxDepth:r=Number.POSITIVE_INFINITY}=t;return"object"==typeof e&&null!==e?_({from:e,seen:[],forceEnumerable:!0,maxDepth:r,depth:0}):"function"==typeof e?`[Function: ${e.name||"anonymous"}]`:e},deserializeError:(e,t={})=>{const{maxDepth:r=Number.POSITIVE_INFINITY}=t;if(e instanceof Error)return e;if("object"==typeof e&&null!==e&&!Array.isArray(e)){const t=new Error;return _({from:e,seen:[],to_:t,maxDepth:r,depth:0}),t}return new b(e)}};
|
|
29
29
|
/*!
|
|
30
30
|
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
31
|
-
*/const M=w,
|
|
31
|
+
*/const M=w,U=n,{extendContextLoader:R,strictDocumentLoader:O}=x,{serializeError:D}=C;function K({document:e}){let t;t=U.getValues(e,"proof");const r=e["@context"]||M.SECURITY_CONTEXT_URL;return t=t.map((e=>({"@context":r,...e}))),t}function A(e){Object.defineProperty(e,"toJSON",{value:function(){return D(this)},configurable:!0,writable:!0})}var N=class extends Error{constructor(e){super("Verification error(s)."),this.name="VerificationError",this.errors=[].concat(e)}},P=class{constructor({type:e}={}){if("string"!=typeof e)throw new TypeError('A LinkedDataProof must have a "type".');this.type=e}async createProof({}){throw new Error('"createProof" must be implemented in a derived class.')}async derive({}){throw new Error('"deriveProof" must be implemented in a derived class.')}async verifyProof({}){throw new Error('"verifyProof" must be implemented in a derived class.')}async matchProof({proof:e}){return e.type===this.type}};
|
|
32
32
|
/*!
|
|
33
33
|
* Copyright (c) 2018-2023 Digital Bazaar, Inc. All rights reserved.
|
|
34
34
|
*/const V={};var I=V;V.w3cDate=e=>{null==e?e=new Date:"number"!=typeof e&&"string"!=typeof e||(e=new Date(e));const t=e.toISOString();return t.substr(0,t.length-5)+"Z"},V.concat=(e,t)=>{const r=new Uint8Array(e.length+t.length);return r.set(e,0),r.set(t,e.length),r};const j=self&&(self.crypto||self.msCrypto);var k={async sha256digest({string:e}){const t=(new TextEncoder).encode(e);return new Uint8Array(await j.subtle.digest("SHA-256",t))}};
|
|
35
35
|
/*!
|
|
36
36
|
* Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.
|
|
37
|
-
*/const X=w,Y=n,z=I,{sha256digest:q}=k,$=
|
|
37
|
+
*/const X=w,Y=n,z=I,{sha256digest:q}=k,$=P;
|
|
38
38
|
/*!
|
|
39
39
|
* Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
|
|
40
40
|
*/
|
|
41
|
-
const B={};var W=B;B.suites={LinkedDataProof:
|
|
41
|
+
const B={};var W=B;B.suites={LinkedDataProof:P,LinkedDataSignature:class extends ${constructor({type:e,proof:t,LDKeyClass:r,date:o,key:n,signer:i,verifier:a,useNativeCanonize:s,canonizeOptions:c,contextUrl:p}={}){super({type:e}),this.LDKeyClass=r,this.contextUrl=p,this.proof=t;const d=function({key:e,signer:t,verifier:r}){const o={};if(e){if(o.key=e,o.verificationMethod=e.id,"function"==typeof e.signer&&(o.signer=e.signer()),"function"==typeof e.verifier&&(o.verifier=e.verifier()),!o.signer&&!o.verifier)throw new TypeError('The "key" parameter must contain a "signer" or "verifier" method.')}else o.verificationMethod=t&&t.id||r&&r.id,o.signer=t,o.verifier=r;if(o.signer&&"function"!=typeof o.signer.sign)throw new TypeError("A signer API has not been specified.");if(o.verifier&&"function"!=typeof o.verifier.verify)throw new TypeError("A verifier API has not been specified.");return o}({key:n,signer:i,verifier:a});if(this.verificationMethod=d.verificationMethod,this.key=d.key,this.signer=d.signer,this.verifier=d.verifier,this.canonizeOptions=c,o&&(this.date=new Date(o),isNaN(this.date)))throw TypeError(`"date" "${o}" is not a valid date.`);this.useNativeCanonize=s,this._hashCache=null}async createProof({document:e,purpose:t,proofSet:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');let i;i=this.proof?{...this.proof}:{},i.type=this.type;let a=this.date;void 0===i.created&&void 0===a&&(a=new Date),a&&"string"!=typeof a&&(a=z.w3cDate(a)),a&&(i.created=a),i.verificationMethod=this.verificationMethod,i=await this.updateProof({document:e,proof:i,proofSet:r,purpose:t,documentLoader:o}),i=await t.update(i,{document:e,suite:this,documentLoader:o});const s=await this.createVerifyData({document:e,proof:i,proofSet:r,documentLoader:o});return i=await this.sign({verifyData:s,document:e,proof:i,documentLoader:o}),i}async updateProof({proof:e,expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e}async verifyProof({proof:e,document:t,proofSet:r,documentLoader:o,expansionMap:n}){if(n)throw new Error('"expansionMap" not supported.');try{const i=await this.createVerifyData({document:t,proof:e,proofSet:r,documentLoader:o,expansionMap:n}),a=await this.getVerificationMethod({proof:e,document:t,documentLoader:o,expansionMap:n});if(!await this.verifySignature({verifyData:i,verificationMethod:a,document:t,proof:e,documentLoader:o,expansionMap:n}))throw new Error("Invalid signature.");return{verified:!0,verificationMethod:a}}catch(e){return{verified:!1,error:e}}}async canonize(e,{documentLoader:t,expansionMap:r,skipExpansion:o}){if(r)throw new Error('"expansionMap" not supported.');return Y.canonize(e,{algorithm:"URDNA2015",base:null,format:"application/n-quads",documentLoader:t,safe:!0,skipExpansion:o,useNative:this.useNativeCanonize,...this.canonizeOptions})}async canonizeProof(e,{document:t,documentLoader:r,expansionMap:o}){if(o)throw new Error('"expansionMap" not supported.');return delete(e={"@context":t["@context"]||X.SECURITY_CONTEXT_URL,...e}).jws,delete e.signatureValue,delete e.proofValue,this.canonize(e,{documentLoader:r,expansionMap:o,skipExpansion:!1,...this.canonizeOptions})}async createVerifyData({document:e,proof:t,documentLoader:r,expansionMap:o}){if(o)throw new Error('"expansionMap" not supported.');let n;const{_hashCache:i}=this;i&&i.document===e?n=i.hash:this._hashCache={document:e,hash:n=this.canonize(e,{documentLoader:r,expansionMap:o}).then((e=>q({string:e})))};const[a,s]=await Promise.all([this.canonizeProof(t,{document:e,documentLoader:r,expansionMap:o}).then((e=>q({string:e}))),n]);return z.concat(a,s)}async derive(){throw new Error("Must be implemented by a derived class.")}async getVerificationMethod({proof:e,documentLoader:t}){let{verificationMethod:r}=e;if("object"==typeof r&&(r=r.id),!r)throw new Error('No "verificationMethod" found in proof.');const o=await Y.frame(r,{"@context":X.SECURITY_CONTEXT_URL,"@embed":"@always",id:r},{documentLoader:t,compactToRelative:!1,safe:!0});if(!o)throw new Error(`Verification method ${r} not found.`);if(void 0!==o.revoked)throw new Error("The verification method has been revoked.");return o}async sign(){throw new Error("Must be implemented by a derived class.")}async verifySignature(){throw new Error("Must be implemented by a derived class.")}ensureSuiteContext({document:e,addSuiteContext:t}){const{contextUrl:r}=this;if(function({document:e,contextUrl:t}){const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)}({document:e,contextUrl:r}))return;if(!t)throw new TypeError(`The document to be signed must contain this suite's @context, "${r}".`);const o=e["@context"]||[];e["@context"]=Array.isArray(o)?[...o,r]:[o,r]}}};
|
|
42
42
|
/*!
|
|
43
43
|
* Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
|
|
44
44
|
*/
|
|
@@ -60,7 +60,11 @@ const oe={};var ne=oe;oe.purposes={AssertionProofPurpose:class extends te{constr
|
|
|
60
60
|
/*!
|
|
61
61
|
* Copyright (c) 2010-2023 Digital Bazaar, Inc. All rights reserved.
|
|
62
62
|
*/
|
|
63
|
-
const ie={};var ae=ie;const se=w;Object.assign(ie,se);const ce=class{async add(e,{suite:t,purpose:r,documentLoader:o}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!r)throw new TypeError('"options.purpose" is required.');o=o?R(o):
|
|
63
|
+
const ie={};var ae=ie;const se=w;Object.assign(ie,se);const ce=class{async add(e,{suite:t,purpose:r,documentLoader:o}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!r)throw new TypeError('"options.purpose" is required.');o=o?R(o):O;const n={...e};delete n.proof;const i=K({document:e}),a=await t.createProof({document:n,purpose:r,proofSet:i,documentLoader:o});return U.addValue(e,"proof",a),e}async derive(e,{suite:t,purpose:r,documentLoader:o}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!r)throw new TypeError('"options.purpose" is required.');o=o?R(o):O;const n={...e};delete n.proof;const i=K({document:e});return await t.derive({document:n,purpose:r,proofSet:i,documentLoader:o})}async verify(e,{suite:t,purpose:r,documentLoader:o}={}){if(!t)throw new TypeError('"options.suite" is required.');if(!r)throw new TypeError('"options.purpose" is required.');const n=Array.isArray(t)?t:[t];if(0===n.length)throw new TypeError("At least one suite is required.");o=o?R(o):O;try{const t=K({document:e={...e}});if(0===t.length)throw new Error("No matching proofs found in the given document.");delete e.proof;const i=await async function({document:e,suites:t,proofSet:r,purpose:o,documentLoader:n}){const i=Array.isArray(o)?o:[o],a=new Map,s=new Map,c=new Map;if(await Promise.all(i.map((o=>async function({purposeToProofs:e,proofToSuite:t,purpose:r,proofSet:o,suites:n,suiteMatchQueue:i,document:a,documentLoader:s}){for(const c of o){if(!await r.match(c,{document:a,documentLoader:s}))continue;let o=!1;for(const e of n){let r=i.get(e);r||i.set(e,r=new Map);let n=r.get(c);if(n||(n=e.matchProof({proof:c,document:a,documentLoader:s}),r.set(c,n)),await n){o=!0,t.set(c,e);break}}if(o){const t=e.get(r);t?t.push(c):e.set(r,[c])}}}
|
|
64
64
|
/*!
|
|
65
65
|
* Copyright (c) 2020 Digital Bazaar, Inc. All rights reserved.
|
|
66
|
-
*/({purposeToProofs:a,proofToSuite:s,purpose:o,proofSet:r,suites:t,suiteMatchQueue:c,document:e,documentLoader:n})))),a.size<i.length)return[];const p=new Map;return await Promise.all([...s.entries()].map((async([t,o])=>{let i;try{let a;const s={validate:async(e,{verificationMethod:t})=>(a=t,{valid:!0})},{verified:c,verificationMethod:p,error:d}=await o.verifyProof({proof:t,document:e,purpose:s,proofSet:r,documentLoader:n});a||(a=p),i={proof:t,verified:c,verificationMethod:a,error:d}}catch(e){i={proof:t,verified:!1,error:e}}i.error&&
|
|
66
|
+
*/({purposeToProofs:a,proofToSuite:s,purpose:o,proofSet:r,suites:t,suiteMatchQueue:c,document:e,documentLoader:n})))),a.size<i.length)return[];const p=new Map;return await Promise.all([...s.entries()].map((async([t,o])=>{let i;try{let a;const s={validate:async(e,{verificationMethod:t})=>(a=t,{valid:!0})},{verified:c,verificationMethod:p,error:d}=await o.verifyProof({proof:t,document:e,purpose:s,proofSet:r,documentLoader:n});a||(a=p),i={proof:t,verified:c,verificationMethod:a,error:d}}catch(e){i={proof:t,verified:!1,error:e}}i.error&&A(i.error),p.set(t,i)}))),await Promise.all([...a.entries()].map((async([t,r])=>{for(const o of r){const r=p.get(o);if(!r.verified)continue;const{verificationMethod:i}=r,a=s.get(o);let c;try{c=await t.validate(o,{document:e,suite:a,verificationMethod:i,documentLoader:n})}catch(e){c={valid:!1,error:e}}r.purposeResult?Array.isArray(r.purposeResult)?r.purposeResult.push(c):r.purposeResult=[r.purposeResult,c]:r.purposeResult=c,c.valid||(A(c.error),r.error||(r.verified=!1,r.error=c.error))}}))),[...p.values()]}({document:e,suites:n,proofSet:t,purpose:r,documentLoader:o});if(0===i.length){const e=new Error("Did not verify any proofs; insufficient proofs matched the acceptable suite(s) and required purpose(s).");throw e.name="NotFoundError",e}const a=i.some((e=>e.verified));if(!a){const e=[].concat(...i.filter((e=>e.error)).map((e=>e.error))),t={verified:a,results:i};return e.length>0&&(t.error=e),t}return{verified:a,results:i}}catch(e){return A(e),{verified:!1,error:e}}}},pe=N;ie.derive=async function(e,{suite:t,purpose:r,documentLoader:o,addSuiteContext:n=!0}={}){if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');t.ensureSuiteContext({document:e,addSuiteContext:n});try{return await(new ce).derive(e,{suite:t,purpose:r,documentLoader:o})}catch(e){if(!o&&"jsonld.InvalidUrl"===e.name){const{details:{url:t}}=e,r=new Error(`A URL "${t}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "derive".`);throw r.cause=e,r}throw e}},ie.sign=async function(e,{suite:t,purpose:r,documentLoader:o,expansionMap:n,addSuiteContext:i=!0}={}){if(n)throw new Error('"expansionMap" not supported.');if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');t.ensureSuiteContext({document:e,addSuiteContext:i});try{return await(new ce).add(e,{suite:t,purpose:r,documentLoader:o})}catch(e){if(!o&&"jsonld.InvalidUrl"===e.name){const{details:{url:t}}=e,r=new Error(`A URL "${t}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "sign".`);throw r.cause=e,r}throw e}},ie.verify=async function(e,{suite:t,purpose:r,documentLoader:o,expansionMap:n}={}){if(n)throw new Error('"expansionMap" not supported.');if("object"!=typeof e)throw new TypeError('The "document" parameter must be an object.');const i=await(new ce).verify(e,{suite:t,purpose:r,documentLoader:o}),{error:a}=i;if(a)if(o||"jsonld.InvalidUrl"!==a.name)i.error=new pe(a);else{const{details:{url:e}}=a,t=new Error(`A URL "${e}" could not be fetched; you need to pass "documentLoader" or resolve the URL before calling "verify".`);i.error=new pe(t)}return i},ie.suites=W.suites,ie.purposes=ne.purposes,Object.assign(ie,x);var de=e(ae);const ue={};
|
|
67
|
+
/*!
|
|
68
|
+
* Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
|
|
69
|
+
*/
|
|
70
|
+
const fe="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function le(e,t){return function(e,t){if(!(e instanceof Uint8Array))throw new TypeError('"input" must be a Uint8Array.');if(0===e.length)return"";let r="",o=0;const n=t.length,i=t.charAt(0),a=[0];for(o=0;o<e.length;++o){let t=e[o];for(let e=0;e<a.length;++e)t+=a[e]<<8,a[e]=t%n,t=t/n|0;for(;t>0;)a.push(t%n),t=t/n|0}for(o=0;0===e[o]&&o<e.length-1;++o)r+=i;for(o=a.length-1;o>=0;--o)r+=t[a[o]];return r}(e,fe)}function he(e){return function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if(0===e.length)return new Uint8Array;let r=ue[t];if(!r){r=ue[t]=[];for(let e=0;e<t.length;++e)r[t.charCodeAt(e)]=e}e=e.replace(/\s/g,"");const o=t.length,n=t.charAt(0),i=[0];for(let t=0;t<e.length;t++){const n=r[e.charCodeAt(t)];if(void 0===n)return;let a=n;for(let e=0;e<i.length;++e)a+=i[e]*o,i[e]=255&a,a>>=8;for(;a>0;)i.push(255&a),a>>=8}for(let t=0;e[t]===n&&t<e.length-1;++t)i.push(0);return new Uint8Array(i.reverse())}(e,fe)}export{he as d,le as e,de as j};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{p as e,u as t,x as r,B as n,i as o,g as i,y as s}from"./main.js";import{b as a,e as c,r as u,i as l,m as f}from"./elliptic-6eMlPaPZ-CGOSt2J1.js";var p=t(r),h=t(s),d={exports:{}};
|
|
2
|
+
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
3
|
+
!function(e,t){var r=u,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)}}(d,d.exports);var y=d.exports;var b=class extends Error{constructor(e){super(e||"This operation is not supported for this key type")}};var w=class extends Error{constructor(){super("This has not been implemented yet")}};var g=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 m=w;var v,k=class{constructor(e){this.params=e}fromPrivatePKCS1(e){throw new m}fromPrivatePKCS8(e){throw new m}fromPublicPKCS1(e){throw new m}fromPublicPKCS8(e){throw new m}fromPrivateBlk(e){throw new m}fromPublicBlk(e){throw new m}fromJwk(e){throw new m}toPrivatePKCS1(e){throw new m}toPrivatePKCS8(e){throw new m}toPublicPKCS1(e){throw new m}toPublicPKCS8(e){throw new m}toPrivateBlk(e){throw new m}toPublicBlk(e){throw new m}toPrivateJwk(e){throw new m}toPublicJwk(e){throw new m}static formatPem(e,t){return`-----BEGIN ${t} KEY-----\n`+e.match(/.{1,64}/g).join("\n")+`\n-----END ${t} KEY-----`}},_={},P={},E={},S=u,K=S.Buffer,A={};for(v in S)S.hasOwnProperty(v)&&"SlowBuffer"!==v&&"Buffer"!==v&&(A[v]=S[v]);var x=A.Buffer={};for(v in K)K.hasOwnProperty(v)&&"allocUnsafe"!==v&&"allocUnsafeSlow"!==v&&(x[v]=K[v]);if(A.Buffer.prototype=K.prototype,x.from&&x.from!==Uint8Array.from||(x.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 K(e,t,r)}),x.alloc||(x.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=K(e);return t&&0!==t.length?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n}),!A.kStringMaxLength)try{A.kStringMaxLength=e.binding("buffer").kStringMaxLength}catch(e){}A.constants||(A.constants={MAX_LENGTH:A.kMaxLength},A.kStringMaxLength&&(A.constants.MAX_STRING_LENGTH=A.kStringMaxLength));var C=A,B={};const j=l;function U(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function I(e,t){this.path=e,this.rethrow(t)}B.Reporter=U,U.prototype.isError=function(e){return e instanceof I},U.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},U.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},U.prototype.enterKey=function(e){return this._reporterState.path.push(e)},U.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},U.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},U.prototype.path=function(){return this._reporterState.path.join("/")},U.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},U.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},U.prototype.error=function(e){let t;const r=this._reporterState,n=e instanceof I;if(t=n?e:new I(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},U.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},j(I,Error),I.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,I),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this};var T={};const q=l,N=B.Reporter,z=C.Buffer;function O(e,t){N.call(this,t),z.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function R(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return R.isEncoderBuffer(e)||(e=new R(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=z.byteLength(e);else{if(!z.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}q(O,N),T.DecoderBuffer=O,O.isDecoderBuffer=function(e){if(e instanceof O)return!0;return"object"==typeof e&&z.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},O.prototype.save=function(){return{offset:this.offset,reporter:N.prototype.save.call(this)}},O.prototype.restore=function(e){const t=new O(this.base);return t.offset=e.offset,t.length=this.offset,this.offset=e.offset,N.prototype.restore.call(this,e.reporter),t},O.prototype.isEmpty=function(){return this.offset===this.length},O.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},O.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const r=new O(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},O.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},T.EncoderBuffer=R,R.isEncoderBuffer=function(e){if(e instanceof R)return!0;return"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},R.prototype.join=function(e,t){return e||(e=z.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):z.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e};const D=B.Reporter,V=T.EncoderBuffer,M=T.DecoderBuffer,L=f,J=["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"],$=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(J);function F(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 Z=F;const G=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];F.prototype.clone=function(){const e=this._baseState,t={};G.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},F.prototype._wrap=function(){const e=this._baseState;$.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},F.prototype._init=function(e){const t=this._baseState;L(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),L.equal(t.children.length,1,"Root node can have only one child")},F.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&&(L(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(L(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){F.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),J.forEach((function(e){F.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return L(null===t.tag),t.tag=e,this._useArgs(r),this}})),F.prototype.use=function(e){L(e);const t=this._baseState;return L(null===t.use),t.use=e,this},F.prototype.optional=function(){return this._baseState.optional=!0,this},F.prototype.def=function(e){const t=this._baseState;return L(null===t.default),t.default=e,t.optional=!0,this},F.prototype.explicit=function(e){const t=this._baseState;return L(null===t.explicit&&null===t.implicit),t.explicit=e,this},F.prototype.implicit=function(e){const t=this._baseState;return L(null===t.explicit&&null===t.implicit),t.implicit=e,this},F.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},F.prototype.key=function(e){const t=this._baseState;return L(null===t.key),t.key=e,this},F.prototype.any=function(){return this._baseState.any=!0,this},F.prototype.choice=function(e){const t=this._baseState;return L(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},F.prototype.contains=function(e){const t=this._baseState;return L(null===t.use),t.contains=e,this},F.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 M(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},F.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)},F.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),L(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},F.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")},F.prototype._createEncoderBuffer=function(e){return new V(e,this.reporter)},F.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},F.prototype._encodeValue=function(e,t,r){const n=this._baseState;if(null===n.parent)return n.children[0]._encode(e,t||new D);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},F.prototype._encodeChoice=function(e,t){const r=this._baseState,n=r.choice[e.type];return n||L(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},F.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)},F.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},F.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)};var Y={};!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);const H=l,X=C.Buffer,W=Z,Q=Y;function ee(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new re,this.tree._init(e.body)}var te=ee;function re(e){W.call(this,"der",e)}function ne(e){return e<10?"0"+e:e}ee.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},H(re,W),re.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(Q.tagByName.hasOwnProperty(e))o=Q.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|=Q.tagClassByName[r||"universal"]<<6,o}(e,t,r,this.reporter);if(n.length<128){const e=X.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=X.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])},re.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=X.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")},re.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=X.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)},re.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[ne(n.getUTCFullYear()),ne(n.getUTCMonth()+1),ne(n.getUTCDate()),ne(n.getUTCHours()),ne(n.getUTCMinutes()),ne(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[ne(n.getUTCFullYear()%100),ne(n.getUTCMonth()+1),ne(n.getUTCDate()),ne(n.getUTCHours()),ne(n.getUTCMinutes()),ne(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},re.prototype._encodeNull=function(){return this._createEncoderBuffer("")},re.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&&!X.isBuffer(e)){const t=e.toArray();!e.sign&&128&t[0]&&t.unshift(0),e=X.from(t)}if(X.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=X.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(X.from(n))},re.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},re.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},re.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 oe=te;function ie(e){oe.call(this,e),this.enc="pem"}l(ie,oe);var se=ie;ie.prototype.encode=function(e,t){const r=oe.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=te,t.pem=se}(E);var ae={};const ce=l,ue=a,le=T.DecoderBuffer,fe=Z,pe=Y;function he(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new ye,this.tree._init(e.body)}var de=he;function ye(e){fe.call(this,"der",e)}function be(e,t){let r=e.readUInt8(t);if(e.isError(r))return r;const n=pe.tagClass[r>>6],o=!(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:o,tag:r,tagStr:pe.tag[r]}}function we(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}he.prototype.decode=function(e,t){return le.isDecoderBuffer(e)||(e=new le(e,t)),this.tree._decode(e,t)},ce(ye,fe),ye.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;const n=e.save(),o=be(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)},ye.prototype._decodeTag=function(e,t,r){const n=be(e,'Failed to decode tag of "'+t+'"');if(e.isError(n))return n;let o=we(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+'"'))},ye.prototype._skipUntilEnd=function(e,t){for(;;){const r=be(e,t);if(e.isError(r))return r;const n=we(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}},ye.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},ye.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")},ye.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},ye.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)},ye.prototype._decodeNull=function(){return null},ye.prototype._decodeBool=function(e){const t=e.readUInt8();return e.isError(t)?t:0!==t},ye.prototype._decodeInt=function(e,t){const r=e.raw();let n=new ue(r);return t&&(n=t[n.toString(10)]||n),n},ye.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree};const ge=l,me=C.Buffer,ve=de;function ke(e){ve.call(this,e),this.enc="pem"}ge(ke,ve);var _e=ke;ke.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=me.from(a,"base64");return ve.prototype.decode.call(this,c,t)},function(e){const t=e;t.der=de,t.pem=_e}(ae),function(e){const t=E,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)}}(P);var Pe={};!function(){const e=Pe;e.Reporter=B.Reporter,e.DecoderBuffer=T.DecoderBuffer,e.EncoderBuffer=T.EncoderBuffer,e.Node=Z}();var Ee={};!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=Y}(Ee),function(){const e=_;e.bignum=a,e.define=P.define,e.base=Pe,e.constants=Ee,e.decoders=ae,e.encoders=E}();var Se={exports:{}},Ke={},Ae={};Object.defineProperty(Ae,"__esModule",{value:!0}),Ae.default=function(e){var t=e.length,r=t%4;if(!r)return e;var o=t,i=4-r,s=t+i,a=n.alloc(s);for(a.write(e);i--;)a.write("=",o++);return a.toString()},Object.defineProperty(Ke,"__esModule",{value:!0});var xe=Ae;function Ce(e,t){return void 0===t&&(t="utf8"),o(e)?je(e.toString("base64")):je(n.from(e,t).toString("base64"))}function Be(e){return e=e.toString(),xe.default(e).replace(/\-/g,"+").replace(/_/g,"/")}function je(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var Ue,Ie=Ce;Ie.encode=Ce,Ie.decode=function(e,t){return void 0===t&&(t="utf8"),n.from(Be(e),"base64").toString(t)},Ie.toBase64=Be,Ie.fromBase64=je,Ie.toBuffer=function(e){return n.from(Be(e),"base64")},Ke.default=Ie,(Ue=Se).exports=Ke.default,Ue.exports.default=Ue.exports;var Te=Se.exports,qe=i(Te);const Ne=_,ze=Te;var Oe=class{static convert(e,t,r){if(!e)return;if(t===r)return e;let o;if("raw"===t||e instanceof n)o=e;else if("uint8_array"===t||Array.isArray(e))o=n.from(e);else if("hex"===t)o=n.from(e,"hex");else if("base64"===t)o=n.from(e,"base64");else if("base64url"===t)o=ze.toBuffer(e);else{if("bn"!==t&&"bignum"!==t)throw new Error("Invalid fromType");o=n.from(this.pad(e.toString(16)),"hex")}if("raw"===r)return o;if("uint8_array"===r)return Array.from(o);if("hex"===r)return o.toString("hex");if("base64"===r)return o.toString("base64");if("base64url"===r)return ze.fromBase64(o.toString("base64"));if("bn"===r||"bignum"===r)return new Ne.bignum(o);throw new Error("Invalid toType")}static pad(e){return e.length%2==1?`0${e}`:e}};const Re=_;const De=new class{constructor(){Object.defineProperty(this,"_registry",{value:{}})}get registry(){return this._registry}define(e,t){this._registry[e]=Re.define(e,t(this))}normalize(e){return this.registry[e]}};De.define("Version",(e=>function(){this.int({0:"two-prime",1:"multi"})})),De.define("OtherPrimeInfos",(e=>function(){this.seq().obj(this.key("ri").int(),this.key("di").int(),this.key("ti").int())})),De.define("AlgorithmIdentifier",(e=>function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())})),De.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())}})),De.define("PublicKeyInfo",(e=>{let t=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("algorithm").use(t),this.key("publicKey").bitstr())}})),De.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))}})),De.define("RSAPublicKey",(e=>function(){this.seq().obj(this.key("n").int(),this.key("e").int())})),De.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 Ve=De;const Me=k,Le=Oe,Je=Ve;var $e=class e extends Me{fromPrivatePKCS1(e){let t=Je.normalize("RSAPrivateKey"),{n:r,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u}=t.decode(e,"der");return{n:Le.convert(r,"bn","raw"),e:Le.convert(n,"bn","raw"),d:Le.convert(o,"bn","raw"),p:Le.convert(i,"bn","raw"),q:Le.convert(s,"bn","raw"),dp:Le.convert(a,"bn","raw"),dq:Le.convert(c,"bn","raw"),qi:Le.convert(u,"bn","raw")}}fromPrivatePKCS8(e){let t=Je.normalize("PrivateKeyInfo"),r=Je.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:Le.convert(o,"bn","raw"),e:Le.convert(i,"bn","raw"),d:Le.convert(s,"bn","raw"),p:Le.convert(a,"bn","raw"),q:Le.convert(c,"bn","raw"),dp:Le.convert(u,"bn","raw"),dq:Le.convert(l,"bn","raw"),qi:Le.convert(f,"bn","raw")}}fromPublicPKCS1(e){let t=Je.normalize("RSAPublicKey"),{n:r,e:n}=t.decode(e,"der");return{n:Le.convert(r,"bn","raw"),e:Le.convert(n,"bn","raw")}}fromPublicPKCS8(e){let t=Je.normalize("PublicKeyInfo"),r=Je.normalize("RSAPublicKey"),n=t.decode(e,"der"),{n:o,e:i}=r.decode(n.publicKey.data,"der");return{n:Le.convert(o,"bn","raw"),e:Le.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:Le.convert(t,"base64url","raw"),e:Le.convert(r,"base64url","raw"),d:Le.convert(n,"base64url","raw"),p:Le.convert(o,"base64url","raw"),q:Le.convert(i,"base64url","raw"),dp:Le.convert(s,"base64url","raw"),dq:Le.convert(a,"base64url","raw"),qi:Le.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=Je.normalize("RSAPrivateKey").encode({version:l,n:Le.convert(r,"raw","bn"),e:Le.convert(n,"raw","bn"),d:Le.convert(o,"raw","bn"),p:Le.convert(i,"raw","bn"),q:Le.convert(s,"raw","bn"),dp:Le.convert(a,"raw","bn"),dq:Le.convert(c,"raw","bn"),qi:Le.convert(u,"raw","bn")},"der").toString("base64");return e.formatPem(f,"RSA PRIVATE")}toPrivatePKCS8(t){let{n:r,e:o,d:i,p:s,q:a,dp:c,dq:u,qi:l}=t,{oid:f,algParameters:p,version:h}=this.params,d=Je.normalize("PrivateKeyInfo"),y=Je.normalize("RSAPrivateKey").encode({version:h,n:Le.convert(r,"raw","bn"),e:Le.convert(o,"raw","bn"),d:Le.convert(i,"raw","bn"),p:Le.convert(s,"raw","bn"),q:Le.convert(a,"raw","bn"),dp:Le.convert(c,"raw","bn"),dq:Le.convert(u,"raw","bn"),qi:Le.convert(l,"raw","bn")},"der"),b=d.encode({version:h,algorithm:{algorithm:f.split("."),parameters:n.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=Je.normalize("RSAPublicKey").encode({version:o,n:Le.convert(r,"raw","bn"),e:Le.convert(n,"raw","bn")},"der").toString("base64");return e.formatPem(i,"RSA PUBLIC")}toPublicPKCS8(t){let{n:r,e:o}=t,{oid:i,algParameters:s}=this.params,a=Je.normalize("PublicKeyInfo"),c=Je.normalize("RSAPublicKey").encode({n:Le.convert(r,"raw","bn"),e:Le.convert(o,"raw","bn")},"der"),u=a.encode({algorithm:{algorithm:i.split("."),parameters:n.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:Le.convert(t,"raw","base64url"),e:Le.convert(r,"raw","base64url"),d:Le.convert(n,"raw","base64url"),p:Le.convert(o,"raw","base64url"),q:Le.convert(i,"raw","base64url"),dp:Le.convert(s,"raw","base64url"),dq:Le.convert(a,"raw","base64url"),qi:Le.convert(c,"raw","base64url")}}toPublicJwk(e){let{n:t,e:r}=e,{kty:n}=this.params;return{kty:n,n:Le.convert(t,"raw","base64url"),e:Le.convert(r,"raw","base64url")}}};const Fe=new(0,c.ec)("secp256k1"),Ze=k,Ge=Oe,Ye=Ve;var He=class e extends Ze{fromPrivatePKCS1(t){let r=Ye.normalize("ECPrivateKey").decode(t,"der"),{privateKey:n,publicKey:{data:o}}=r,i=Ge.convert(o,"raw","hex"),{x:s,y:a}=e.getPoint(i);return{d:n,x:s,y:a}}fromPrivatePKCS8(t){let r=Ye.normalize("PrivateKeyInfo"),n=Ye.normalize("ECPrivateKey"),o=r.decode(t,"der"),i=n.decode(o.privateKey,"der"),{privateKey:s,publicKey:{data:a}}=i,c=Ge.convert(a,"raw","hex"),{x:u,y:l}=e.getPoint(c);return{d:s,x:u,y:l}}fromPublicPKCS8(t){let r=Ye.normalize("PublicKeyInfo").decode(t,"der"),n=Ge.convert(r.publicKey.data,"raw","hex");return e.getPoint(n)}fromPrivateBlk(e){let t=Fe.keyFromPrivate(e,"hex"),r=t.getPublic();return{d:Ge.convert(t.priv,"bn","raw"),x:Ge.convert(r.getX(),"bn","raw"),y:Ge.convert(r.getY(),"bn","raw")}}fromPublicBlk(t){return e.getPoint(t)}fromJwk(e){let{d:t,x:r,y:n}=e;return{d:Ge.convert(t,"base64url","raw"),x:Ge.convert(r,"base64url","raw"),y:Ge.convert(n,"base64url","raw")}}toPrivatePKCS1(t){let{namedCurve:r,keyVersion:n}=this.params,{d:o,x:i,y:s}=t,a=Ye.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:o,keyVersion:i,infoVersion:s}=this.params,{d:a,x:c,y:u}=t,l=Ye.normalize("PrivateKeyInfo"),f=Ye.normalize("ECPrivateKey"),p=e.makePoint(c,u),h=f.encode({version:i,privateKey:a,publicKey:{unused:0,data:p}},"der"),d=l.encode({version:s,algorithm:{algorithm:r.split("."),parameters:n.from(o,"hex")},privateKey:h},"der").toString("base64");return e.formatPem(d,"PRIVATE")}toPublicPKCS8(t){let{oid:r,algParameters:o}=this.params,{x:i,y:s}=t,a=Ye.normalize("PublicKeyInfo"),c=e.makePoint(i,s),u=a.encode({algorithm:{algorithm:r.split("."),parameters:n.from(o,"hex")},publicKey:{unused:0,data:c}},"der").toString("base64");return e.formatPem(u,"PUBLIC")}toPrivateBlk(e){return e.d.toString("hex")}toPublicBlk(t){return Ge.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:Ge.convert(n,"raw","base64url"),x:Ge.convert(o,"raw","base64url"),y:Ge.convert(i,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:r}=this.params,{x:n,y:o}=e;return{kty:r,crv:t,x:Ge.convert(n,"raw","base64url"),y:Ge.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:Ge.convert(t,"hex","raw"),y:Ge.convert(r,"hex","raw")}}static makePoint(e,t){let r=n.from("04","hex");return n.concat([r,e,t],r.length+e.length+t.length)}};const Xe=k,We=Oe,Qe=Ve;var et=class e extends Xe{fromPrivatePKCS8(e){const t=Qe.normalize("PrivateKeyInfo").decode(e,"der").privateKey.slice(2);return{d:t,x:this.publicKeyFromPrivate(t)}}fromPublicPKCS8(e){const t=Qe.normalize("PublicKeyInfo").decode(e,"der");return{x:We.convert(t.publicKey.data,"hex","raw")}}fromJwk(e){let{d:t,x:r}=e;return{d:We.convert(t,"base64url","raw"),x:We.convert(r,"base64url","raw")}}toPrivatePKCS8(t){let{oid:r,infoVersion:n}=this.params,{d:o}=t;const i=Qe.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=Qe.normalize("PublicKeyInfo").encode({algorithm:{algorithm:r.split(".")},publicKey:{unused:0,data:We.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:We.convert(n,"raw","base64url"),x:We.convert(o,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:r}=this.params,{x:n}=e;return{kty:r,crv:t,x:We.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=n.from("0420","hex"),n.concat([t,e],t.length+e.length)}publicKeyFromPrivate(e){if("Ed25519"===this.params.crv){const t=new(0,c.eddsa)("ed25519");return n.from(t.keyFromSecret(e).getPublic())}throw new Error(`${this.params.crv} is an invalid curve for EdDSA`)}};const tt=$e,rt=He,nt=et,ot=new g;ot.define([{kty:"RSA",oid:"1.2.840.113549.1.1.1",algParameters:"0500",version:"two-prime"}],tt),ot.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"}],rt),ot.define([{kty:"OKP",crv:"Ed25519",oid:"1.3.101.112",infoVersion:"two-prime"}],nt);const it=b,st=w,at=ot,ct=Ve,ut=RegExp("\r?\n","g");class lt{constructor(e,t){if(!e)throw new it("key is required");if(!t)throw new it("options are required");let{kty:r,format:n,selector:o,crv:i,oid:s}=t;if(!t.kty)throw new it("options.kty is required");if(!t.format)throw new it("options.format is required");if(!t.selector)throw new it("options.selector is required");if(!t.crv&&!t.oid)throw new it("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 it("key is required");if(!t)throw new it("format is required");if("jwk"===t){let r;if("string"==typeof e)try{r=JSON.parse(e)}catch(e){throw new it("key is not a valid JWK")}else"object"==typeof e&&(r=e);let n,{kty:o,crv:i}=r;if(!o)throw new it("kty is required for JWK");if("EC"===o&&!i)throw new it("crv is required for EC JWK");"RSA"===o&&(n=at.find((e=>e.kty===o)).oid);let s=r.d?"private":"public";return new lt(r,{kty:o,crv:i,oid:n,format:t,selector:s})}if("pem"===t){if("string"!=typeof e)throw new it("key is not a valid PEM string");let r=e.split(ut),o=r.splice(0,1);r.splice(r.length-1,1);let i,s,a=r.join(""),c=/^-----BEGIN ((RSA|EC) )?(PUBLIC|PRIVATE) KEY-----$/.exec(o),u=c?c[2]:void 0,l=c?c[3]:void 0,f=n.from(a,"base64");if(!l)throw new it("key is not a valid PEM string");if(u){if("RSA"===u)l="PRIVATE"===l?"private_pkcs1":"public_pkcs1",i=at.find((e=>e.kty===u)).oid;else if("EC"===u){let e;if("PRIVATE"===l){l="private_pkcs1",e=ct.normalize(`${u}PrivateKey`).decode(f,"der")}else if("PUBLIC"===l){l="public_pkcs1",e=ct.normalize(`${u}PrivateKey`).decode(f,"der")}let{parameters:{value:t}}=e;s=at.find((e=>e.namedCurve===t.join("."))).crv}}else{let e,t=ct.normalize("PrivateKeyInfo"),r=ct.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:o}}=e;n=n.join("."),o=o?o.toString("hex"):void 0;const a=at.find((e=>e.oid===n));if(u=a?a.kty:void 0,!u)throw new it(`${n} is not supported`);"RSA"===u||"OKP"===u?i=n:"EC"===u&&(s=at.find((e=>e.algParameters===o)).crv)}return new lt(f,{kty:u,oid:i,crv:s,format:t,selector:l})}if("blk"===t)return new lt(e,{kty:"EC",crv:"K-256",format:t,selector:e.length>64?"public":"private"});throw new it(`Invalid format ${t}`)}get alg(){let{kty:e,crv:t,oid:r}=this;if(!this.algorithm){if(t)Object.defineProperty(this,"algorithm",{value:at.normalize(e,"crv",t)});else{if(!r)throw new Error("Both crv and oid are undefined");Object.defineProperty(this,"algorithm",{value:at.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 it("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 it("Cannot export a private key from a public key");return n.toPrivatePKCS1(r);case"private_pkcs8":if(o.includes("public"))throw new it("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 it("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 it("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 st}}var ft=i(lt);const pt="Impossible case. Please create issue.",ht="The tweak was out of range or the resulted private key is invalid",dt="The tweak was out of range or equal to zero",yt="Unknow error on context randomization",bt="Private Key is invalid",wt="Public Key could not be parsed",gt="Public Key serialization error",mt="The sum of the public keys is not valid",vt="Signature could not be parsed",kt="The nonce generation function failed, or the private key was invalid",_t="Public key could not be recover",Pt="Scalar was invalid (zero or overflow)";function Et(e,t){if(!e)throw new Error(t)}function St(e,t,r){if(Et(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(", ")}]`;Et(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;Et(t.length===r,n)}}function Kt(e){Et("Boolean"===xt(e),"Expected compressed to be a Boolean")}function At(e=e=>new Uint8Array(e),t){return"function"==typeof e&&(e=e(t)),St("output",e,t),e}function xt(e){return Object.prototype.toString.call(e).slice(8,-1)}const Ct=new(0,c.ec)("secp256k1"),Bt=Ct.curve,jt=Bt.n.constructor;function Ut(e){const t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){let r=new jt(t);if(r.cmp(Bt.p)>=0)return null;r=r.toRed(Bt.red);let n=r.redSqr().redIMul(r).redIAdd(Bt.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),Ct.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 jt(t),o=new jt(r);if(n.cmp(Bt.p)>=0||o.cmp(Bt.p)>=0)return null;if(n=n.toRed(Bt.red),o=o.toRed(Bt.red),(6===e||7===e)&&o.isOdd()!==(7===e))return null;const i=n.redSqr().redIMul(n);return o.redSqr().redISub(i.redIAdd(Bt.b)).isZero()?Ct.keyPair({pub:{x:n,y:o}}):null}(t,e.subarray(1,33),e.subarray(33,65));default:return null}}function It(e,t){const r=t.encode(null,33===e.length);for(let t=0;t<e.length;++t)e[t]=r[t]}var Tt=(e=>({contextRandomize(t){if(Et(null===t||t instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==t&&St("seed",t,32),1===e.contextRandomize(t))throw new Error(yt)},privateKeyVerify:t=>(St("private key",t,32),0===e.privateKeyVerify(t)),privateKeyNegate(t){switch(St("private key",t,32),e.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(pt)}},privateKeyTweakAdd(t,r){switch(St("private key",t,32),St("tweak",r,32),e.privateKeyTweakAdd(t,r)){case 0:return t;case 1:throw new Error(ht)}},privateKeyTweakMul(t,r){switch(St("private key",t,32),St("tweak",r,32),e.privateKeyTweakMul(t,r)){case 0:return t;case 1:throw new Error(dt)}},publicKeyVerify:t=>(St("public key",t,[33,65]),0===e.publicKeyVerify(t)),publicKeyCreate(t,r=!0,n){switch(St("private key",t,32),Kt(r),n=At(n,r?33:65),e.publicKeyCreate(n,t)){case 0:return n;case 1:throw new Error(bt);case 2:throw new Error(gt)}},publicKeyConvert(t,r=!0,n){switch(St("public key",t,[33,65]),Kt(r),n=At(n,r?33:65),e.publicKeyConvert(n,t)){case 0:return n;case 1:throw new Error(wt);case 2:throw new Error(gt)}},publicKeyNegate(t,r=!0,n){switch(St("public key",t,[33,65]),Kt(r),n=At(n,r?33:65),e.publicKeyNegate(n,t)){case 0:return n;case 1:throw new Error(wt);case 2:throw new Error(pt);case 3:throw new Error(gt)}},publicKeyCombine(t,r=!0,n){Et(Array.isArray(t),"Expected public keys to be an Array"),Et(t.length>0,"Expected public keys array will have more than zero items");for(const e of t)St("public key",e,[33,65]);switch(Kt(r),n=At(n,r?33:65),e.publicKeyCombine(n,t)){case 0:return n;case 1:throw new Error(wt);case 2:throw new Error(mt);case 3:throw new Error(gt)}},publicKeyTweakAdd(t,r,n=!0,o){switch(St("public key",t,[33,65]),St("tweak",r,32),Kt(n),o=At(o,n?33:65),e.publicKeyTweakAdd(o,t,r)){case 0:return o;case 1:throw new Error(wt);case 2:throw new Error(ht)}},publicKeyTweakMul(t,r,n=!0,o){switch(St("public key",t,[33,65]),St("tweak",r,32),Kt(n),o=At(o,n?33:65),e.publicKeyTweakMul(o,t,r)){case 0:return o;case 1:throw new Error(wt);case 2:throw new Error(dt)}},signatureNormalize(t){switch(St("signature",t,64),e.signatureNormalize(t)){case 0:return t;case 1:throw new Error(vt)}},signatureExport(t,r){St("signature",t,64);const n={output:r=At(r,72),outputlen:72};switch(e.signatureExport(n,t)){case 0:return r.slice(0,n.outputlen);case 1:throw new Error(vt);case 2:throw new Error(pt)}},signatureImport(t,r){switch(St("signature",t),r=At(r,64),e.signatureImport(r,t)){case 0:return r;case 1:throw new Error(vt);case 2:throw new Error(pt)}},ecdsaSign(t,r,n={},o){St("message",t,32),St("private key",r,32),Et("Object"===xt(n),"Expected options to be an Object"),void 0!==n.data&&St("options.data",n.data),void 0!==n.noncefn&&Et("Function"===xt(n.noncefn),"Expected options.noncefn to be a Function");const i={signature:o=At(o,64),recid:null};switch(e.ecdsaSign(i,t,r,n.data,n.noncefn)){case 0:return i;case 1:throw new Error(kt);case 2:throw new Error(pt)}},ecdsaVerify(t,r,n){switch(St("signature",t,64),St("message",r,32),St("public key",n,[33,65]),e.ecdsaVerify(t,r,n)){case 0:return!0;case 3:return!1;case 1:throw new Error(vt);case 2:throw new Error(wt)}},ecdsaRecover(t,r,n,o=!0,i){switch(St("signature",t,64),Et("Number"===xt(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),St("message",n,32),Kt(o),i=At(i,o?33:65),e.ecdsaRecover(i,t,r,n)){case 0:return i;case 1:throw new Error(vt);case 2:throw new Error(_t);case 3:throw new Error(pt)}},ecdh(t,r,n={},o){switch(St("public key",t,[33,65]),St("private key",r,32),Et("Object"===xt(n),"Expected options to be an Object"),void 0!==n.data&&St("options.data",n.data),void 0!==n.hashfn?(Et("Function"===xt(n.hashfn),"Expected options.hashfn to be a Function"),void 0!==n.xbuf&&St("options.xbuf",n.xbuf,32),void 0!==n.ybuf&&St("options.ybuf",n.ybuf,32),St("output",o)):o=At(o,32),e.ecdh(o,t,r,n.data,n.hashfn,n.xbuf,n.ybuf)){case 0:return o;case 1:throw new Error(wt);case 2:throw new Error(Pt)}}}))({contextRandomize:()=>0,privateKeyVerify(e){const t=new jt(e);return t.cmp(Bt.n)<0&&!t.isZero()?0:1},privateKeyNegate(e){const t=new jt(e),r=Bt.n.sub(t).umod(Bt.n).toArrayLike(Uint8Array,"be",32);return e.set(r),0},privateKeyTweakAdd(e,t){const r=new jt(t);if(r.cmp(Bt.n)>=0)return 1;if(r.iadd(new jt(e)),r.cmp(Bt.n)>=0&&r.isub(Bt.n),r.isZero())return 1;const n=r.toArrayLike(Uint8Array,"be",32);return e.set(n),0},privateKeyTweakMul(e,t){let r=new jt(t);if(r.cmp(Bt.n)>=0||r.isZero())return 1;r.imul(new jt(e)),r.cmp(Bt.n)>=0&&(r=r.umod(Bt.n));const n=r.toArrayLike(Uint8Array,"be",32);return e.set(n),0},publicKeyVerify:e=>null===Ut(e)?1:0,publicKeyCreate(e,t){const r=new jt(t);if(r.cmp(Bt.n)>=0||r.isZero())return 1;return It(e,Ct.keyFromPrivate(t).getPublic()),0},publicKeyConvert(e,t){const r=Ut(t);if(null===r)return 1;return It(e,r.getPublic()),0},publicKeyNegate(e,t){const r=Ut(t);if(null===r)return 1;const n=r.getPublic();return n.y=n.y.redNeg(),It(e,n),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e<t.length;++e)if(r[e]=Ut(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:(It(e,n),0)},publicKeyTweakAdd(e,t,r){const n=Ut(t);if(null===n)return 1;if((r=new jt(r)).cmp(Bt.n)>=0)return 2;const o=n.getPublic().add(Bt.g.mul(r));return o.isInfinity()?2:(It(e,o),0)},publicKeyTweakMul(e,t,r){const n=Ut(t);if(null===n)return 1;if((r=new jt(r)).cmp(Bt.n)>=0||r.isZero())return 2;return It(e,n.getPublic().mul(r)),0},signatureNormalize(e){const t=new jt(e.subarray(0,32)),r=new jt(e.subarray(32,64));return t.cmp(Bt.n)>=0||r.cmp(Bt.n)>=0?1:(1===r.cmp(Ct.nh)&&e.set(Bt.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 jt(r).cmp(Bt.n)>=0)return 1;if(new jt(n).cmp(Bt.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 jt(o);s.cmp(Bt.n)>=0&&(s=new jt(0));let a=new jt(t.subarray(6+r));return a.cmp(Bt.n)>=0&&(a=new jt(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 jt(i)}}const i=new jt(r);if(i.cmp(Bt.n)>=0||i.isZero())return 1;let s;try{s=Ct.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 jt(n.r),i=new jt(n.s);if(o.cmp(Bt.n)>=0||i.cmp(Bt.n)>=0)return 1;if(1===i.cmp(Ct.nh)||o.isZero()||i.isZero())return 3;const s=Ut(r);if(null===s)return 2;const a=s.getPublic();return Ct.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 jt(o.r),s=new jt(o.s);if(i.cmp(Bt.n)>=0||s.cmp(Bt.n)>=0)return 1;if(i.isZero()||s.isZero())return 2;let a;try{a=Ct.recoverPubKey(n,o,r)}catch(e){return 2}return It(e,a),0},ecdh(e,t,r,n,o,i,s){const a=Ut(t);if(null===a)return 1;const c=new jt(r);if(c.cmp(Bt.n)>=0||c.isZero())return 2;const u=a.getPublic().mul(c);if(void 0===o){const t=u.encode(null,!0),r=Ct.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}}),qt=i(Tt);var Nt=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")}}};var zt=Nt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Ot=i(zt);export{p as a,qt as b,zt as c,qe as d,Tt as e,Ot as f,ft as k,h as r,y as s};
|