@blockcerts/blockcerts-verifier 1.64.0 → 1.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle-stats.html +1 -1
- package/dist/{EcdsaSd2023-C-1LsSqc-ObXBX61N.js → EcdsaSd2023-CFEOfg7w-mH0iTn_o.js} +5 -5
- package/dist/{EcdsaSecp256k1Signature2019-9eEnZ1FG-BmfqA6PL.js → EcdsaSecp256k1Signature2019-ubMolKKG--XgmQozH.js} +1 -1
- package/dist/{Ed25519Signature2020-BMcgU5hX-x_NYJtpB.js → Ed25519Signature2020-BZ-qRxuK-BYYEQJGi.js} +5 -5
- package/dist/{MerkleProof2017-CYhvkyFU-Dl5-uCC8.js → MerkleProof2017-8DlLs_7g-DQaM2JIJ.js} +1 -1
- package/dist/{MerkleProof2019-DvKX1MAC-ZkVAsaEc.js → MerkleProof2019-Cv-l9BBE-DWMqt_64.js} +1 -1
- package/dist/{checkCredentialSchemaConformity-BKqGaA0B-BD_kUjvp.js → checkCredentialSchemaConformity-jTrYEW-3-Dd-TT_aS.js} +1 -1
- package/dist/{controlVerificationMethod-CxlzFjkZ-PQqX7CMl.js → controlVerificationMethod-CXY1HfP3-B24OCl2R.js} +1 -1
- package/dist/{did-key-common.esm-BFTxB53c-CbGeVC_r.js → did-key-common.esm-B-c4r5DX-DkFupqKN.js} +3 -3
- package/dist/{did-key-ed25519.esm-De8G8Ym_-DucypQMo.js → did-key-ed25519.esm-BcBjidXA-DBqZ-FkQ.js} +1 -1
- package/dist/{did-key-secp256k1.esm-Bq_BYfMd-CQBo4Q3q.js → did-key-secp256k1.esm-6buyKG_l-BMESYfmC.js} +1 -1
- package/dist/{index-DJ38G5vv-CIHAiYCe.js → index-CUYLWUzw-Bvbn47Hw.js} +7 -7
- package/dist/{index-CXMZ9dwW-lR6I8M8V.js → index-D-CbTXp7-DPOLY-Lt.js} +1 -1
- package/dist/{index-SE5hL_nS--rUcmgx9.js → index-hjoL_SpB-ntvlvLOE.js} +5 -5
- package/dist/main.js +104 -104
- package/dist/{retrieveVerificationMethodPublicKey-8w3WQciA-sHmGZCdE.js → retrieveVerificationMethodPublicKey-DVFc1aT7-B_qGml2q.js} +1 -1
- package/package.json +2 -2
- /package/dist/{HashlinkVerifier-BtvQtMxp-dg5WNZnc.js → HashlinkVerifier-_iTrfpkJ-dg5WNZnc.js} +0 -0
- /package/dist/{checkRevocationStatusList2021-BUqNLYXm-XCu3zkCJ.js → checkRevocationStatusList2021-BnjtBDNQ-XCu3zkCJ.js} +0 -0
- /package/dist/{elliptic-ChFQ9Ngs-BRLTdj5Y.js → elliptic-C4nnFoxE-BRLTdj5Y.js} +0 -0
- /package/dist/{ensureNotRevoked-JuH4UdyO-DvMIgM4L.js → ensureNotRevoked-DWOMZyzg-DvMIgM4L.js} +0 -0
- /package/dist/{ensureValidIssuingKey-CVj5gBFJ-wu9SdYxL.js → ensureValidIssuingKey-CCMYu_4t-wu9SdYxL.js} +0 -0
- /package/dist/{index-BcM1LBSs-Dgus2xdV.js → index-DGqgobGj-Dgus2xdV.js} +0 -0
- /package/dist/{index-CZmdZxVn-C0eXpZGn.js → index-DO31KEg9-C0eXpZGn.js} +0 -0
- /package/dist/{jsonld-DSQP4wXm-C61cS9xX.js → jsonld-B5Vzncdv-C61cS9xX.js} +0 -0
- /package/dist/{sha256-4DF0Q3E2-C1PUWFZm.js → sha256-D1k1uYHq-C1PUWFZm.js} +0 -0
- /package/dist/{webcrypto.es-SQMaF2SJ-B87Lqr9a.js → webcrypto.es-DlDhx8-u-B87Lqr9a.js} +0 -0
- /package/dist/{x25519-KjRyLrTf-NSl6svWQ.js → x25519-BTjd7-6X-NSl6svWQ.js} +0 -0
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import{d as e,e as t}from"./index-
|
|
1
|
+
import{d as e,e as t}from"./index-hjoL_SpB-ntvlvLOE.js";import{d as r}from"./base64url-Cy03LJLt-vkTPfQOh.js";import{g as i}from"./main.js";import{r as n}from"./elliptic-C4nnFoxE-BRLTdj5Y.js";
|
|
2
2
|
/*!
|
|
3
3
|
* Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
|
|
4
4
|
*/
|
|
5
|
-
const c="ECDSA",u=!0,y="https://w3id.org/security/suites/ecdsa-2019/v1",
|
|
5
|
+
const c="ECDSA",u=!0,y="https://w3id.org/security/suites/ecdsa-2019/v1",o="https://w3id.org/security/multikey/v1",s="z",a=new Uint8Array([231,1]),l=new Uint8Array([128,36]),p=new Uint8Array([129,36]),w=new Uint8Array([130,36]),b=new Uint8Array([134,33]),f=new Uint8Array([134,38]),k=new Uint8Array([135,38]),K=new Uint8Array([136,38]),m="P-256",d="P-384",h="P-521",g="K-256",v="SHA-256",A="SHA-384",E="SHA-512",M=globalThis.crypto,U=globalThis.CryptoKey??M.CryptoKey;function C({curve:e}){if(e===m||e===g)return v;if(e===d)return A;if(e===h)return E;throw new TypeError(`Unsupported curve "${e}".`)}
|
|
6
6
|
/*!
|
|
7
7
|
* Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
|
|
8
|
-
*/function
|
|
8
|
+
*/function x({publicMultikey:e}){if(e[0]===l[0]&&e[1]===l[1])return m;if(e[0]===p[0]&&e[1]===p[1])return d;if(e[0]===w[0]&&e[1]===w[1])return h;if(e[0]===a[0]&&e[1]===a[1])return g;throw new TypeError("Unsupported public multikey header.")}function j({secretMultikey:e}){if(e[0]===f[0]&&e[1]===f[1])return m;if(e[0]===k[0]&&e[1]===k[1])return d;if(e[0]===K[0]&&e[1]===K[1])return h;if(e[0]===b[0]&&e[1]===b[1])return g;throw new TypeError("Unsupported secret multikey header.")}function T({curve:e}){if(e===m||e===g)return 32;if(e===d)return 48;if(e===h)return 66;throw new TypeError(`Unsupported curve "${e}".`)}var P=n(),D=i(P);
|
|
9
9
|
/*!
|
|
10
10
|
* Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
|
|
11
11
|
*/
|
|
12
|
-
const
|
|
12
|
+
const S=new Map([[m,{secret:new Uint8Array([48,103,2,1,0,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,4,77,48,75,2,1,1,4,32]),public:new Uint8Array([161,36,3,34,0])}],[d,{secret:new Uint8Array([48,129,132,2,1,0,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,4,109,48,107,2,1,1,4,48]),public:new Uint8Array([161,52,3,50,0])}],[h,{secret:new Uint8Array([48,129,170,2,1,0,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,35,4,129,146,48,129,143,2,1,1,4,66]),public:new Uint8Array([161,70,3,68,0])}],[g,{secret:new Uint8Array([48,129,132,2,1,0,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10,4,109,48,107,2,1,1,4,32]),public:new Uint8Array([161,68,3,66,0])}]]),$=new Map([[m,new Uint8Array([48,57,48,19,6,7,42,134,72,206,61,2,1,6,8,42,134,72,206,61,3,1,7,3,34,0])],[d,new Uint8Array([48,70,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,34,3,50,0])],[h,new Uint8Array([48,88,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,35,3,68,0])],[g,new Uint8Array([48,86,48,16,6,7,42,134,72,206,61,2,1,6,5,43,129,4,0,10,3,66,0])]]);function H(e){const t=new D.ec("secp256k1");return Uint8Array.from(t.keyFromPublic(e).getPublic(!1,"array"))}async function q({id:t,controller:r,secretKeyMultibase:i,publicKeyMultibase:n,keyAgreement:y=!1}){if(!n)throw new TypeError('The "publicKeyMultibase" property is required.');const o={id:t,controller:r};if(!n||"string"!=typeof n||n[0]!==s)throw new TypeError('"publicKeyMultibase" must be a multibase, base58-encoded string.');const a=e(n.slice(1)),l={name:y?"ECDH":c,namedCurve:x({publicMultikey:a})},p=function({publicMultikey:e}){const t=x({publicMultikey:e});let r=e.subarray(2);t===g&&(r=H(r));return function({curve:e,publicKey:t}){const r=$.get(e),i=new Uint8Array(r.length+t.length);let n=0;return i.set(r,n),n+=r.length,i.set(t,n),i}
|
|
13
13
|
/*!
|
|
14
14
|
* Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
|
|
15
|
-
*/({curve:t,publicKey:r})}({publicMultikey:a}),w=y?[]:["verify"];if(l.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-
|
|
15
|
+
*/({curve:t,publicKey:r})}({publicMultikey:a}),w=y?[]:["verify"];if(l.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-DlDhx8-u-B87Lqr9a.js"),t=new e;o.publicKey=await t.subtle.importKey("spki",p,l,u,w)}else o.publicKey=await M.subtle.importKey("spki",p,l,u,w);if(i){if("string"!=typeof i||i[0]!==s)throw new TypeError('"secretKeyMultibase" must be a multibase, base58-encoded string.');const t=e(i.slice(1));!function({secretMultikey:e,publicMultikey:t}){const r=x({publicMultikey:t}),i=j({secretMultikey:e});if(r!==i)throw new Error(`Public key curve ('${r}') does not match secret key curve ('${i}').`)}({secretMultikey:t,publicMultikey:a});const r=function({secretMultikey:e,publicMultikey:t}){const r=j({secretMultikey:e}),i=e.subarray(2),n=t.subarray(2);return function({curve:e,secretKey:t,publicKey:r}){const i=S.get(e);if(!i)throw new Error(`Unsupported curve "${e}".`);e===g&&(r=H(r));const n=new Uint8Array(i.secret.length+t.length+i.public.length+r.length);let c=0;return n.set(i.secret,c),c+=i.secret.length,n.set(t,c),c+=t.length,n.set(i.public,c),c+=i.public.length,n.set(r,c),n}({curve:r,secretKey:i,publicKey:n})}({secretMultikey:t,publicMultikey:a}),n=y?["deriveBits"]:["sign"];if(l.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-DlDhx8-u-B87Lqr9a.js"),t=new e;o.secretKey=await t.subtle.importKey("pkcs8",r,l,u,n)}else o.secretKey=await M.subtle.importKey("pkcs8",r,l,u,n)}return o}function B({jwk:e}={}){if("EC"!==e?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:i}=e,n=T({curve:i}),c=r(e.x),u=r(e.y),y=new Uint8Array(2+(n+1));!function({curve:e,buffer:t}){if(e===m)t[0]=l[0],t[1]=l[1];else if(e===d)t[0]=p[0],t[1]=p[1];else if(e===h)t[0]=w[0],t[1]=w[1];else{if(e!==g)throw new TypeError(`Unsupported curve "${e}".`);t[0]=a[0],t[1]=a[1]}}({curve:i,buffer:y});const o=u[u.length-1]%2==0;y[2]=o?2:3,y.set(c,y.length-c.length);return s+t(y)}function V({jwk:e}={}){if("EC"!==e?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:i}=e,n=T({curve:i}),c=r(e.d),u=new Uint8Array(2+n);!function({curve:e,buffer:t}){if(e===m)t[0]=f[0],t[1]=f[1];else if(e===d)t[0]=k[0],t[1]=k[1];else if(e===h)t[0]=K[0],t[1]=K[1];else{if(e!==g)throw new TypeError(`Unsupported curve "${e}".`);t[0]=b[0],t[1]=b[1]}}({curve:e.crv,buffer:u}),u.set(c,u.length-c.length);return s+t(u)}const J=new Set(["EcdsaSecp256r1VerificationKey2019","EcdsaSecp384r1VerificationKey2019","EcdsaSecp521r1VerificationKey2019","EcdsaSecp256k1VerificationKey2019"]);async function L({keyPair:e}){if(!J.has(e.type))throw new TypeError(`Unsupported key type "${e.type}".`);if(e["@context"]||(e["@context"]=y),!function({document:e,contextUrl:t}){const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)}
|
|
16
16
|
/*!
|
|
17
17
|
* Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
|
|
18
|
-
*/({document:e,contextUrl:y}))throw new TypeError(`Context not supported "${e["@context"]}".`);return{"@context":
|
|
18
|
+
*/({document:e,contextUrl:y}))throw new TypeError(`Context not supported "${e["@context"]}".`);return{"@context":o,id:e.id,type:"Multikey",controller:e.controller,publicKeyMultibase:e.publicKeyMultibase,secretKeyMultibase:e.secretKeyMultibase}}async function _(e,t={}){"boolean"==typeof t&&(t={keyAgreement:t});const{keyAgreement:r}=t;let i={...e};if("Multikey"!==i.type){if(i.publicKeyJwk)return async function({jwk:e,secretKey:t=!1}={}){const r={"@context":o,type:"Multikey",publicKeyMultibase:B({jwk:e})};t&&e.d&&(r.secretKeyMultibase=V({jwk:e}));const i=!e.key_ops||e.key_ops.includes("deriveBits");return _(r,i)}({jwk:i.publicKeyJwk,secretKey:!1});if(i.type)return i=await L({keyPair:i}),N({keyPair:i,keyAgreement:r})}return i.type||(i.type="Multikey"),i["@context"]||(i["@context"]=o),i.controller&&!i.id&&(i.id=`${e.controller}#${e.publicKeyMultibase}`),function(e){if(!e||"object"!=typeof e)throw new TypeError('"key" must be an object.');if("Multikey"!==e.type)throw new TypeError('"key" must be a Multikey with type "Multikey".');if(!(e["@context"]===o||Array.isArray(e["@context"])&&e["@context"].includes(o)))throw new TypeError(`"key" must be a Multikey with context "${o}".`)}(i),N({keyPair:i,keyAgreement:r})}async function F({keyPair:e,secretKey:t=!1}={}){e?.publicKey instanceof U||(e=await q(e));const r=t&&!!e.secretKey?e.secretKey:e.publicKey;let i;if(e.publicKey.algorithm.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-DlDhx8-u-B87Lqr9a.js"),t=new e;i=await t.subtle.exportKey("jwk",r)}else i=await M.subtle.exportKey("jwk",r);return i}async function N({keyPair:e,keyAgreement:t=!1}){e?.publicKey instanceof U||e.publicKey?.algorithm.namedCurve===g||(e=await q(e));const i=async({publicKey:t=!0,secretKey:i=!1,includeContext:n=!0,raw:c=!1}={})=>{if(c){const n=await F({keyPair:e,secretKey:i}),c={};return t&&(c.publicKey=function({jwk:e}={}){if("EC"!==e?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:t}=e,i=T({curve:t}),n=r(e.x),c=r(e.y),u=new Uint8Array(i+1),y=c[c.length-1]%2==0;return u[0]=y?2:3,u.set(n,u.length-n.length),u}({jwk:n})),i&&(c.secretKey=function({jwk:e}={}){if("EC"!==e?.kty)throw new TypeError('"jwk.kty" must be "EC".');const{crv:t}=e,i=T({curve:t}),n=r(e.d),c=new Uint8Array(i);return c.set(n,c.length-n.length),c}({jwk:n})),c}return async function({keyPair:e,secretKey:t,publicKey:r,includeContext:i}={}){if(!r&&!t)throw new TypeError('Export requires specifying either "publicKey" or "secretKey".');const n=t&&!!e.secretKey,c=n?e.secretKey:e.publicKey;let u;if(c.algorithm.namedCurve===g){const{Crypto:e}=await import("./webcrypto.es-DlDhx8-u-B87Lqr9a.js"),t=new e;u=await t.subtle.exportKey("jwk",c)}else u=await M.subtle.exportKey("jwk",c);const y={};return i&&(y["@context"]=o),y.id=e.id,y.type="Multikey",y.controller=e.controller,r&&(y.publicKeyMultibase=B({jwk:u})),n&&(y.secretKeyMultibase=V({jwk:u})),y}({keyPair:e,publicKey:t,secretKey:i,includeContext:n})},{publicKeyMultibase:n,secretKeyMultibase:u}=await i({publicKey:!0,secretKey:!0,includeContext:!0});return e={...e,publicKeyMultibase:n,secretKeyMultibase:u,keyAgreement:t,export:i,signer(){const{id:t,secretKey:r}=e;
|
|
19
19
|
/*!
|
|
20
20
|
* Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
|
|
21
21
|
*/
|
|
22
|
-
return function({id:e,secretKey:t}){if(!t)throw new Error('"secretKey" is required for signing.');const{namedCurve:r}=t.algorithm,i={name:c,hash:{name:C({curve:r})}};return{algorithm:r,id:e,async sign({data:e}={}){if(r===g){const{Crypto:r}=await import("./webcrypto.es-
|
|
22
|
+
return function({id:e,secretKey:t}){if(!t)throw new Error('"secretKey" is required for signing.');const{namedCurve:r}=t.algorithm,i={name:c,hash:{name:C({curve:r})}};return{algorithm:r,id:e,async sign({data:e}={}){if(r===g){const{Crypto:r}=await import("./webcrypto.es-DlDhx8-u-B87Lqr9a.js"),n=new r;return new Uint8Array(await n.subtle.sign(i,t,e))}return new Uint8Array(await M.subtle.sign(i,t,e))}}}({id:t,secretKey:r})},verifier(){const{id:t,publicKey:r}=e;return function({id:e,publicKey:t}){if(!t)throw new Error('"publicKey" is required for verifying.');const{namedCurve:r}=t.algorithm,i={name:c,hash:{name:C({curve:r})}};return{algorithm:r,id:e,async verify({data:e,signature:n}={}){if(r===g){const{Crypto:r}=await import("./webcrypto.es-DlDhx8-u-B87Lqr9a.js");return(new r).subtle.verify(i,t,n,e)}return M.subtle.verify(i,t,n,e)}}}({id:t,publicKey:r})},async deriveSecret({publicKey:t,remotePublicKey:r}={}){if(r&&t)throw new Error('Only one of "remotePublicKey" and "publicKey" must be given.');if(!e.keyAgreement){const e=Error('"keyAgreement" is not supported by this keypair.');throw e.name="NotSupportedError",e}return async function({localKeyPair:e,remoteKeyPair:t}){if(!e.secretKey){const e=Error('"secretKey" required to derive secret.');throw e.name="NotSupportedError",e}e=await q({...e,keyAgreement:!0}),t=await q({...t,keyAgreement:!0});const{namedCurve:r}=e.secretKey.algorithm,i=T({curve:r});if(r===g){const{Crypto:n}=await import("./webcrypto.es-DlDhx8-u-B87Lqr9a.js"),c=new n,u=await c.subtle.deriveBits({name:"ECDH",namedCurve:r,public:t.publicKey},e.secretKey,8*i);return new Uint8Array(u,0,i)}const n=await M.subtle.deriveBits({name:"ECDH",namedCurve:r,public:t.publicKey},e.secretKey,8*i);return new Uint8Array(n,0,i)}({localKeyPair:this,remoteKeyPair:r||t})}}}export{P as e,_ as f,F as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,B as t,u as r,x as n,i as o,y as i,p as s}from"./main.js";import{r as a,a as c,c as u,b as l,d as f}from"./elliptic-ChFQ9Ngs-BRLTdj5Y.js";var p,h,d,y,b,w,g,m,v,k=r(n),_=r(i),P={exports:{}};function E(){return p||(p=1,function(e,t){var r=c,n=r.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function i(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=i),i.prototype=Object.create(n.prototype),o(n,i),i.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},i.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=n(e);return void 0!==t?"string"==typeof r?o.fill(t,r):o.fill(t):o.fill(0),o},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}(P,P.exports)),P.exports}function S(){if(d)return h;d=1;class e extends Error{constructor(e){super(e||"This operation is not supported for this key type")}}return h=e}function K(){if(b)return y;b=1;class e extends Error{constructor(){super("This has not been implemented yet")}}return y=e}function A(){if(v)return m;v=1;const e=K();return m=class{constructor(e){this.params=e}fromPrivatePKCS1(t){throw new e}fromPrivatePKCS8(t){throw new e}fromPublicPKCS1(t){throw new e}fromPublicPKCS8(t){throw new e}fromPrivateBlk(t){throw new e}fromPublicBlk(t){throw new e}fromJwk(t){throw new e}toPrivatePKCS1(t){throw new e}toPrivatePKCS8(t){throw new e}toPublicPKCS1(t){throw new e}toPublicPKCS8(t){throw new e}toPrivateBlk(t){throw new e}toPublicBlk(t){throw new e}toPrivateJwk(t){throw new e}toPublicJwk(t){throw new e}static formatPem(e,t){return`-----BEGIN ${t} KEY-----\n`+e.match(/.{1,64}/g).join("\n")+`\n-----END ${t} KEY-----`}}}var x,C,B={},j={},U={};function I(){if(C)return x;C=1;var e,t=c,r=t.Buffer,n={};for(e in t)t.hasOwnProperty(e)&&"SlowBuffer"!==e&&"Buffer"!==e&&(n[e]=t[e]);var o=n.Buffer={};for(e in r)r.hasOwnProperty(e)&&"allocUnsafe"!==e&&"allocUnsafeSlow"!==e&&(o[e]=r[e]);if(n.Buffer.prototype=r.prototype,o.from&&o.from!==Uint8Array.from||(o.from=function(e,t,n){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return r(e,t,n)}),o.alloc||(o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var o=r(e);return t&&0!==t.length?"string"==typeof n?o.fill(t,n):o.fill(t):o.fill(0),o}),!n.kStringMaxLength)try{n.kStringMaxLength=s.binding("buffer").kStringMaxLength}catch(e){}return n.constants||(n.constants={MAX_LENGTH:n.kMaxLength},n.kStringMaxLength&&(n.constants.MAX_STRING_LENGTH=n.kStringMaxLength)),x=n}var T,q={};function N(){if(T)return q;T=1;const e=l();function t(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function r(e,t){this.path=e,this.rethrow(t)}return q.Reporter=t,t.prototype.isError=function(e){return e instanceof r},t.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},t.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},t.prototype.enterKey=function(e){return this._reporterState.path.push(e)},t.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},t.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},t.prototype.path=function(){return this._reporterState.path.join("/")},t.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},t.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},t.prototype.error=function(e){let t;const n=this._reporterState,o=e instanceof r;if(t=o?e:new r(n.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!n.options.partial)throw t;return o||n.errors.push(t),t},t.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},e(r,Error),r.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,r),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this},q}var z,O,R,D={};function V(){if(z)return D;z=1;const e=l(),t=N().Reporter,r=I().Buffer;function n(e,n){t.call(this,n),r.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function o(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return o.isEncoderBuffer(e)||(e=new o(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=r.byteLength(e);else{if(!r.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}return e(n,t),D.DecoderBuffer=n,n.isDecoderBuffer=function(e){if(e instanceof n)return!0;return"object"==typeof e&&r.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},n.prototype.save=function(){return{offset:this.offset,reporter:t.prototype.save.call(this)}},n.prototype.restore=function(e){const r=new n(this.base);return r.offset=e.offset,r.length=this.offset,this.offset=e.offset,t.prototype.restore.call(this,e.reporter),r},n.prototype.isEmpty=function(){return this.offset===this.length},n.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},n.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const r=new n(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},n.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},D.EncoderBuffer=o,o.isEncoderBuffer=function(e){if(e instanceof o)return!0;return"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},o.prototype.join=function(e,t){return e||(e=r.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(e,t),t+=r.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):r.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e},D}function L(){if(R)return O;R=1;const e=N().Reporter,t=V().EncoderBuffer,r=V().DecoderBuffer,n=f(),o=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],i=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(o);function s(e,t,r){const n={};this._baseState=n,n.name=r,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}O=s;const a=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];return s.prototype.clone=function(){const e=this._baseState,t={};a.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},s.prototype._wrap=function(){const e=this._baseState;i.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},s.prototype._init=function(e){const t=this._baseState;n(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),n.equal(t.children.length,1,"Root node can have only one child")},s.prototype._useArgs=function(e){const t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(n(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(n(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);const n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){s.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),o.forEach((function(e){s.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return n(null===t.tag),t.tag=e,this._useArgs(r),this}})),s.prototype.use=function(e){n(e);const t=this._baseState;return n(null===t.use),t.use=e,this},s.prototype.optional=function(){return this._baseState.optional=!0,this},s.prototype.def=function(e){const t=this._baseState;return n(null===t.default),t.default=e,t.optional=!0,this},s.prototype.explicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.explicit=e,this},s.prototype.implicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.implicit=e,this},s.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},s.prototype.key=function(e){const t=this._baseState;return n(null===t.key),t.key=e,this},s.prototype.any=function(){return this._baseState.any=!0,this},s.prototype.choice=function(e){const t=this._baseState;return n(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},s.prototype.contains=function(e){const t=this._baseState;return n(null===t.use),t.contains=e,this},s.prototype._decode=function(e,t){const n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));let o,i=n.default,s=!0,a=null;if(null!==n.key&&(a=e.enterKey(n.key)),n.optional){let r=null;if(null!==n.explicit?r=n.explicit:null!==n.implicit?r=n.implicit:null!==n.tag&&(r=n.tag),null!==r||n.any){if(s=this._peekTag(e,r,n.any),e.isError(s))return s}else{const r=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),s=!0}catch(e){s=!1}e.restore(r)}}if(n.obj&&s&&(o=e.enterObject()),s){if(null!==n.explicit){const t=this._decodeTag(e,n.explicit);if(e.isError(t))return t;e=t}const o=e.offset;if(null===n.use&&null===n.choice){let t;n.any&&(t=e.save());const r=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(r))return r;n.any?i=e.raw(t):e=r}if(t&&t.track&&null!==n.tag&&t.track(e.path(),o,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),n.any||(i=null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(r){r._decode(e,t)})),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){const o=new r(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(o,t)}}return n.obj&&s&&(i=e.leaveObject(o)),null===n.key||null===i&&!0!==s?null!==a&&e.exitKey(a):e.leaveKey(a,n.key,i),i},s.prototype._decodeGeneric=function(e,t,r){const n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},s.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),n(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},s.prototype._decodeChoice=function(e,t){const r=this._baseState;let n=null,o=!1;return Object.keys(r.choice).some((function(i){const s=e.save(),a=r.choice[i];try{const r=a._decode(e,t);if(e.isError(r))return!1;n={type:i,value:r},o=!0}catch(t){return e.restore(s),!1}return!0}),this),o?n:e.error("Choice not matched")},s.prototype._createEncoderBuffer=function(e){return new t(e,this.reporter)},s.prototype._encode=function(e,t,r){const n=this._baseState;if(null!==n.default&&n.default===e)return;const o=this._encodeValue(e,t,r);return void 0===o||this._skipDefault(o,t,r)?void 0:o},s.prototype._encodeValue=function(t,r,n){const o=this._baseState;if(null===o.parent)return o.children[0]._encode(t,r||new e);let i=null;if(this.reporter=r,o.optional&&void 0===t){if(null===o.default)return;t=o.default}let s=null,a=!1;if(o.any)i=this._createEncoderBuffer(t);else if(o.choice)i=this._encodeChoice(t,r);else if(o.contains)s=this._getUse(o.contains,n)._encode(t,r),a=!0;else if(o.children)s=o.children.map((function(e){if("null_"===e._baseState.tag)return e._encode(null,r,t);if(null===e._baseState.key)return r.error("Child should have a key");const n=r.enterKey(e._baseState.key);if("object"!=typeof t)return r.error("Child expected, but input is not object");const o=e._encode(t[e._baseState.key],r,t);return r.leaveKey(n),o}),this).filter((function(e){return e})),s=this._createEncoderBuffer(s);else if("seqof"===o.tag||"setof"===o.tag){if(!o.args||1!==o.args.length)return r.error("Too many args for : "+o.tag);if(!Array.isArray(t))return r.error("seqof/setof, but data is not Array");const e=this.clone();e._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(e){const n=this._baseState;return this._getUse(n.args[0],t)._encode(e,r)}),e))}else null!==o.use?i=this._getUse(o.use,n)._encode(t,r):(s=this._encodePrimitive(o.tag,t),a=!0);if(!o.any&&null===o.choice){const e=null!==o.implicit?o.implicit:o.tag,t=null===o.implicit?"universal":"context";null===e?null===o.use&&r.error("Tag could be omitted only for .use()"):null===o.use&&(i=this._encodeComposite(e,a,t,s))}return null!==o.explicit&&(i=this._encodeComposite(o.explicit,!1,"context",i)),i},s.prototype._encodeChoice=function(e,t){const r=this._baseState,o=r.choice[e.type];return o||n(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),o._encode(e.value,t)},s.prototype._encodePrimitive=function(e,t){const r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},s.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},s.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)},O}var M,J,$,F,Z,G,Y={};function H(){return M||(M=1,function(e){function t(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t}e.tagClass={0:"universal",1:"application",2:"context",3:"private"},e.tagClassByName=t(e.tagClass),e.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},e.tagByName=t(e.tag)}(Y)),Y}function X(){if($)return J;$=1;const e=l(),t=I().Buffer,r=L(),n=H();function o(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new i,this.tree._init(e.body)}function i(e){r.call(this,"der",e)}function s(e){return e<10?"0"+e:e}return J=o,o.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},e(i,r),i.prototype._encodeComposite=function(e,r,o,i){const s=function(e,t,r,o){let i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(n.tagByName.hasOwnProperty(e))i=n.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return o.error("Unknown tag: "+e);i=e}if(i>=31)return o.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=n.tagClassByName[r||"universal"]<<6,i}(e,r,o,this.reporter);if(i.length<128){const e=t.alloc(2);return e[0]=s,e[1]=i.length,this._createEncoderBuffer([e,i])}let a=1;for(let e=i.length;e>=256;e>>=8)a++;const c=t.alloc(2+a);c[0]=s,c[1]=128|a;for(let e=1+a,t=i.length;t>0;e--,t>>=8)c[e]=255&t;return this._createEncoderBuffer([c,i])},i.prototype._encodeStr=function(e,r){if("bitstr"===r)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===r){const r=t.alloc(2*e.length);for(let t=0;t<e.length;t++)r.writeUInt16BE(e.charCodeAt(t),2*t);return this._createEncoderBuffer(r)}return"numstr"===r?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===r?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(r)||"objDesc"===r?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+r+" unsupported")},i.prototype._encodeObjid=function(e,r,n){if("string"==typeof e){if(!r)return this.reporter.error("string objid given, but no values map found");if(!r.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=r[e].split(/[\s.]+/g);for(let t=0;t<e.length;t++)e[t]|=0}else if(Array.isArray(e)){e=e.slice();for(let t=0;t<e.length;t++)e[t]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!n){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let o=0;for(let t=0;t<e.length;t++){let r=e[t];for(o++;r>=128;r>>=7)o++}const i=t.alloc(o);let s=i.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(i[s--]=127&r;(r>>=7)>0;)i[s--]=128|127&r}return this._createEncoderBuffer(i)},i.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[s(n.getUTCFullYear()),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[s(n.getUTCFullYear()%100),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},i.prototype._encodeNull=function(){return this._createEncoderBuffer("")},i.prototype._encodeInt=function(e,r){if("string"==typeof e){if(!r)return this.reporter.error("String int or enum given, but no values map");if(!r.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=r[e]}if("number"!=typeof e&&!t.isBuffer(e)){const r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=t.from(r)}if(t.isBuffer(e)){let r=e.length;0===e.length&&r++;const n=t.alloc(r);return e.copy(n),0===e.length&&(n[0]=0),this._createEncoderBuffer(n)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let n=1;for(let t=e;t>=256;t>>=8)n++;const o=new Array(n);for(let t=o.length-1;t>=0;t--)o[t]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(t.from(o))},i.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},i.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},i.prototype._skipDefault=function(e,t,r){const n=this._baseState;let o;if(null===n.default)return!1;const i=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),i.length!==n.defaultBuffer.length)return!1;for(o=0;o<i.length;o++)if(i[o]!==n.defaultBuffer[o])return!1;return!0},J}function W(){return G||(G=1,function(e){const t=e;t.der=X(),t.pem=function(){if(Z)return F;Z=1;const e=l(),t=X();function r(e){t.call(this,e),this.enc="pem"}return e(r,t),F=r,r.prototype.encode=function(e,r){const n=t.prototype.encode.call(this,e).toString("base64"),o=["-----BEGIN "+r.label+"-----"];for(let e=0;e<n.length;e+=64)o.push(n.slice(e,e+64));return o.push("-----END "+r.label+"-----"),o.join("\n")},F}()}(U)),U}var Q,ee,te,re,ne,oe,ie={};function se(){if(ee)return Q;ee=1;const e=l(),t=u(),r=V().DecoderBuffer,n=L(),o=H();function i(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new s,this.tree._init(e.body)}function s(e){n.call(this,"der",e)}function a(e,t){let r=e.readUInt8(t);if(e.isError(r))return r;const n=o.tagClass[r>>6],i=!(32&r);if(31&~r)r&=31;else{let n=r;for(r=0;!(128&~n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}return{cls:n,primitive:i,tag:r,tagStr:o.tag[r]}}function c(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(!(128&n))return n;const o=127&n;if(o>4)return e.error("length octect is too long");n=0;for(let t=0;t<o;t++){n<<=8;const t=e.readUInt8(r);if(e.isError(t))return t;n|=t}return n}return Q=i,i.prototype.decode=function(e,t){return r.isDecoderBuffer(e)||(e=new r(e,t)),this.tree._decode(e,t)},e(s,n),s.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;const n=e.save(),o=a(e,'Failed to peek tag: "'+t+'"');return e.isError(o)?o:(e.restore(n),o.tag===t||o.tagStr===t||o.tagStr+"of"===t||r)},s.prototype._decodeTag=function(e,t,r){const n=a(e,'Failed to decode tag of "'+t+'"');if(e.isError(n))return n;let o=c(e,n.primitive,'Failed to get length of "'+t+'"');if(e.isError(o))return o;if(!r&&n.tag!==t&&n.tagStr!==t&&n.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(n.primitive||null!==o)return e.skip(o,'Failed to match body of: "'+t+'"');const i=e.save(),s=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(s)?s:(o=e.offset-i.offset,e.restore(i),e.skip(o,'Failed to match body of: "'+t+'"'))},s.prototype._skipUntilEnd=function(e,t){for(;;){const r=a(e,t);if(e.isError(r))return r;const n=c(e,r.primitive,t);if(e.isError(n))return n;let o;if(o=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(o))return o;if("end"===r.tagStr)break}},s.prototype._decodeList=function(e,t,r,n){const o=[];for(;!e.isEmpty();){const t=this._peekTag(e,"end");if(e.isError(t))return t;const i=r.decode(e,"der",n);if(e.isError(i)&&t)break;o.push(i)}return o},s.prototype._decodeStr=function(e,t){if("bitstr"===t){const t=e.readUInt8();return e.isError(t)?t:{unused:t,data:e.raw()}}if("bmpstr"===t){const t=e.raw();if(t.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");let r="";for(let e=0;e<t.length/2;e++)r+=String.fromCharCode(t.readUInt16BE(2*e));return r}if("numstr"===t){const t=e.raw().toString("ascii");return this._isNumstr(t)?t:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){const t=e.raw().toString("ascii");return this._isPrintstr(t)?t:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},s.prototype._decodeObjid=function(e,t,r){let n;const o=[];let i=0,s=0;for(;!e.isEmpty();)s=e.readUInt8(),i<<=7,i|=127&s,128&s||(o.push(i),i=0);128&s&&o.push(i);const a=o[0]/40|0,c=o[0]%40;if(n=r?o:[a,c].concat(o.slice(1)),t){let e=t[n.join(" ")];void 0===e&&(e=t[n.join(".")]),void 0!==e&&(n=e)}return n},s.prototype._decodeTime=function(e,t){const r=e.raw().toString();let n,o,i,s,a,c;if("gentime"===t)n=0|r.slice(0,4),o=0|r.slice(4,6),i=0|r.slice(6,8),s=0|r.slice(8,10),a=0|r.slice(10,12),c=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");n=0|r.slice(0,2),o=0|r.slice(2,4),i=0|r.slice(4,6),s=0|r.slice(6,8),a=0|r.slice(8,10),c=0|r.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,o-1,i,s,a,c,0)},s.prototype._decodeNull=function(){return null},s.prototype._decodeBool=function(e){const t=e.readUInt8();return e.isError(t)?t:0!==t},s.prototype._decodeInt=function(e,r){const n=e.raw();let o=new t(n);return r&&(o=r[o.toString(10)]||o),o},s.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree},Q}function ae(){return ne||(ne=1,function(e){const t=e;t.der=se(),t.pem=function(){if(re)return te;re=1;const e=l(),t=I().Buffer,r=se();function n(e){r.call(this,e),this.enc="pem"}return e(n,r),te=n,n.prototype.decode=function(e,n){const o=e.toString().split(/[\r\n]+/g),i=n.label.toUpperCase(),s=/^-----(BEGIN|END) ([^-]+)-----$/;let a=-1,c=-1;for(let e=0;e<o.length;e++){const t=o[e].match(s);if(null!==t&&t[2]===i){if(-1!==a){if("END"!==t[1])break;c=e;break}if("BEGIN"!==t[1])break;a=e}}if(-1===a||-1===c)throw new Error("PEM section not found for: "+i);const u=o.slice(a+1,c).join("");u.replace(/[^a-z0-9+/=]+/gi,"");const l=t.from(u,"base64");return r.prototype.decode.call(this,l,n)},te}()}(ie)),ie}var ce,ue={};var le,fe,pe={};function he(){return fe||(fe=1,function(){const e=B;e.bignum=u(),e.define=(oe||(oe=1,function(e){const t=W(),r=ae(),n=l();function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}e.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){const t=this.name;function r(e){this._initNamed(e,t)}return n(r,e),r.prototype._initNamed=function(t,r){e.call(this,t,r)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(r[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(t[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}}(j)),j).define,e.base=(ce||(ce=1,function(e){const t=e;t.Reporter=N().Reporter,t.DecoderBuffer=V().DecoderBuffer,t.EncoderBuffer=V().EncoderBuffer,t.Node=L()}(ue)),ue),e.constants=(le||(le=1,function(e){const t=e;t._reverse=function(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t},t.der=H()}(pe)),pe),e.decoders=ae(),e.encoders=W()}()),B}var de,ye,be,we,ge,me,ve,ke,_e,Pe,Ee,Se,Ke,Ae,xe,Ce,Be,je,Ue,Ie,Te,qe,Ne,ze,Oe,Re,De,Ve,Le,Me,Je,$e,Fe,Ze,Ge,Ye={exports:{}},He={},Xe={};function We(){if(ye)return He;ye=1,Object.defineProperty(He,"__esModule",{value:!0});var e=(de||(de=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.default=function(e){var r=e.length,n=r%4;if(!n)return e;var o=r,i=4-n,s=r+i,a=t.alloc(s);for(a.write(e);i--;)a.write("=",o++);return a.toString()}),Xe);function r(e,r){return void 0===r&&(r="utf8"),o(e)?i(e.toString("base64")):i(t.from(e,r).toString("base64"))}function n(t){return t=t.toString(),e.default(t).replace(/\-/g,"+").replace(/_/g,"/")}function i(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var s=r;return s.encode=r,s.decode=function(e,r){return void 0===r&&(r="utf8"),t.from(n(e),"base64").toString(r)},s.toBase64=n,s.fromBase64=i,s.toBuffer=function(e){return t.from(n(e),"base64")},He.default=s,He}function Qe(){return be||(be=1,(e=Ye).exports=We().default,e.exports.default=e.exports),Ye.exports;var e}function et(){if(ge)return we;ge=1;const e=he(),r=Qe();return we=class{static convert(n,o,i){if(!n)return;if(o===i)return n;let s;if("raw"===o||n instanceof t)s=n;else if("uint8_array"===o||Array.isArray(n))s=t.from(n);else if("hex"===o)s=t.from(n,"hex");else if("base64"===o)s=t.from(n,"base64");else if("base64url"===o)s=r.toBuffer(n);else{if("bn"!==o&&"bignum"!==o)throw new Error("Invalid fromType");s=t.from(this.pad(n.toString(16)),"hex")}if("raw"===i)return s;if("uint8_array"===i)return Array.from(s);if("hex"===i)return s.toString("hex");if("base64"===i)return s.toString("base64");if("base64url"===i)return r.fromBase64(s.toString("base64"));if("bn"===i||"bignum"===i)return new e.bignum(s);throw new Error("Invalid toType")}static pad(e){return e.length%2==1?`0${e}`:e}},we}function tt(){if(Oe)return ze;Oe=1;const e=new(function(){if(ve)return me;ve=1;const e=he();return me=class{constructor(){Object.defineProperty(this,"_registry",{value:{}})}get registry(){return this._registry}define(t,r){this._registry[t]=e.define(t,r(this))}normalize(e){return this.registry[e]}}}());return e.define("Version",_e?ke:(_e=1,ke=e=>function(){this.int({0:"two-prime",1:"multi"})})),e.define("OtherPrimeInfos",Ee?Pe:(Ee=1,Pe=e=>function(){this.seq().obj(this.key("ri").int(),this.key("di").int(),this.key("ti").int())})),e.define("AlgorithmIdentifier",Ke?Se:(Ke=1,Se=e=>function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())})),e.define("PrivateKeyInfo",(xe||(xe=1,Ae=e=>{let t=e.normalize("Version"),r=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("version").use(t),this.key("algorithm").use(r),this.key("privateKey").octstr())}}),Ae)),e.define("PublicKeyInfo",(Be||(Be=1,Ce=e=>{let t=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("algorithm").use(t),this.key("publicKey").bitstr())}}),Ce)),e.define("RSAPrivateKey",(Ue||(Ue=1,je=e=>{let t=e.normalize("Version"),r=e.normalize("OtherPrimeInfos");return function(){this.seq().obj(this.key("version").use(t),this.key("n").int(),this.key("e").int(),this.key("d").int(),this.key("p").int(),this.key("q").int(),this.key("dp").int(),this.key("dq").int(),this.key("qi").int(),this.key("other").optional().use(r))}}),je)),e.define("RSAPublicKey",Te?Ie:(Te=1,Ie=e=>function(){this.seq().obj(this.key("n").int(),this.key("e").int())})),e.define("ECPrivateKey",Ne?qe:(Ne=1,qe=e=>function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().choice({namedCurve:this.objid()}),this.key("publicKey").explicit(1).optional().bitstr())})),ze=e}function rt(){if(Fe)return $e;Fe=1;const e=g?w:(g=1,w=class{constructor(){this.registry=[],this.classes={}}find(e){return this.registry.find(e)}define(e,t){e.forEach((e=>{let{kty:r}=e;if(!r)throw new Error("Invalid type definition");this.classes[r]||(this.classes[r]=t),this.registry.push(e)}))}normalize(e,t,r){let n=this.classes[e],o=this.find((e=>e[t]===r));if(!n||!o)throw new Error("Invalid type");return new n(o)}}),r=function(){if(De)return Re;De=1;const e=A();S();const r=et(),n=tt();class o extends e{fromPrivatePKCS1(e){let t=n.normalize("RSAPrivateKey"),{n:o,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw"),d:r.convert(s,"bn","raw"),p:r.convert(a,"bn","raw"),q:r.convert(c,"bn","raw"),dp:r.convert(u,"bn","raw"),dq:r.convert(l,"bn","raw"),qi:r.convert(f,"bn","raw")}}fromPrivatePKCS8(e){let t=n.normalize("PrivateKeyInfo"),o=n.normalize("RSAPrivateKey"),i=t.decode(e,"der"),{n:s,e:a,d:c,p:u,q:l,dp:f,dq:p,qi:h}=o.decode(i.privateKey,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw"),d:r.convert(c,"bn","raw"),p:r.convert(u,"bn","raw"),q:r.convert(l,"bn","raw"),dp:r.convert(f,"bn","raw"),dq:r.convert(p,"bn","raw"),qi:r.convert(h,"bn","raw")}}fromPublicPKCS1(e){let t=n.normalize("RSAPublicKey"),{n:o,e:i}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw")}}fromPublicPKCS8(e){let t=n.normalize("PublicKeyInfo"),o=n.normalize("RSAPublicKey"),i=t.decode(e,"der"),{n:s,e:a}=o.decode(i.publicKey.data,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw")}}fromJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u,alg:l}=e;return{n:r.convert(t,"base64url","raw"),e:r.convert(n,"base64url","raw"),d:r.convert(o,"base64url","raw"),p:r.convert(i,"base64url","raw"),q:r.convert(s,"base64url","raw"),dp:r.convert(a,"base64url","raw"),dq:r.convert(c,"base64url","raw"),qi:r.convert(u,"base64url","raw")}}toPrivatePKCS1(e){let{n:t,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=e,{version:p}=this.params,h=n.normalize("RSAPrivateKey").encode({version:p,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn"),d:r.convert(s,"raw","bn"),p:r.convert(a,"raw","bn"),q:r.convert(c,"raw","bn"),dp:r.convert(u,"raw","bn"),dq:r.convert(l,"raw","bn"),qi:r.convert(f,"raw","bn")},"der").toString("base64");return o.formatPem(h,"RSA PRIVATE")}toPrivatePKCS8(e){let{n:i,e:s,d:a,p:c,q:u,dp:l,dq:f,qi:p}=e,{oid:h,algParameters:d,version:y}=this.params,b=n.normalize("PrivateKeyInfo"),w=n.normalize("RSAPrivateKey").encode({version:y,n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn"),d:r.convert(a,"raw","bn"),p:r.convert(c,"raw","bn"),q:r.convert(u,"raw","bn"),dp:r.convert(l,"raw","bn"),dq:r.convert(f,"raw","bn"),qi:r.convert(p,"raw","bn")},"der"),g=b.encode({version:y,algorithm:{algorithm:h.split("."),parameters:t.from(d,"hex")},privateKey:w},"der").toString("base64");return o.formatPem(g,"PRIVATE")}toPublicPKCS1(e){let{n:t,e:i}=e,{version:s}=this.params,a=n.normalize("RSAPublicKey").encode({version:s,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn")},"der").toString("base64");return o.formatPem(a,"RSA PUBLIC")}toPublicPKCS8(e){let{n:i,e:s}=e,{oid:a,algParameters:c}=this.params,u=n.normalize("PublicKeyInfo"),l=n.normalize("RSAPublicKey").encode({n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn")},"der"),f=u.encode({algorithm:{algorithm:a.split("."),parameters:t.from(c,"hex")},publicKey:{unused:0,data:l}},"der").toString("base64");return o.formatPem(f,"PUBLIC")}toPrivateJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u}=e,{kty:l}=this.params;return{kty:l,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url"),d:r.convert(o,"raw","base64url"),p:r.convert(i,"raw","base64url"),q:r.convert(s,"raw","base64url"),dp:r.convert(a,"raw","base64url"),dq:r.convert(c,"raw","base64url"),qi:r.convert(u,"raw","base64url")}}toPublicJwk(e){let{n:t,e:n}=e,{kty:o}=this.params;return{kty:o,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url")}}}return Re=o}(),n=function(){if(Le)return Ve;Le=1,he().bignum;const e=new(0,a().ec)("secp256k1"),r=A();S();const n=et(),o=tt();class i extends r{fromPrivatePKCS1(e){let t=o.normalize("ECPrivateKey").decode(e,"der"),{privateKey:r,publicKey:{data:s}}=t,a=n.convert(s,"raw","hex"),{x:c,y:u}=i.getPoint(a);return{d:r,x:c,y:u}}fromPrivatePKCS8(e){let t=o.normalize("PrivateKeyInfo"),r=o.normalize("ECPrivateKey"),s=t.decode(e,"der"),a=r.decode(s.privateKey,"der"),{privateKey:c,publicKey:{data:u}}=a,l=n.convert(u,"raw","hex"),{x:f,y:p}=i.getPoint(l);return{d:c,x:f,y:p}}fromPublicPKCS8(e){let t=o.normalize("PublicKeyInfo").decode(e,"der"),r=n.convert(t.publicKey.data,"raw","hex");return i.getPoint(r)}fromPrivateBlk(t){let r=e.keyFromPrivate(t,"hex"),o=r.getPublic();return{d:n.convert(r.priv,"bn","raw"),x:n.convert(o.getX(),"bn","raw"),y:n.convert(o.getY(),"bn","raw")}}fromPublicBlk(e){return i.getPoint(e)}fromJwk(e){let{d:t,x:r,y:o}=e;return{d:n.convert(t,"base64url","raw"),x:n.convert(r,"base64url","raw"),y:n.convert(o,"base64url","raw")}}toPrivatePKCS1(e){let{namedCurve:t,keyVersion:r}=this.params,{d:n,x:s,y:a}=e,c=o.normalize("ECPrivateKey"),u=i.makePoint(s,a),l=c.encode({version:r,privateKey:n,parameters:{type:"namedCurve",value:t.split(".")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"EC PRIVATE")}toPrivatePKCS8(e){let{oid:r,algParameters:n,keyVersion:s,infoVersion:a}=this.params,{d:c,x:u,y:l}=e,f=o.normalize("PrivateKeyInfo"),p=o.normalize("ECPrivateKey"),h=i.makePoint(u,l),d=p.encode({version:s,privateKey:c,publicKey:{unused:0,data:h}},"der"),y=f.encode({version:a,algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},privateKey:d},"der").toString("base64");return i.formatPem(y,"PRIVATE")}toPublicPKCS8(e){let{oid:r,algParameters:n}=this.params,{x:s,y:a}=e,c=o.normalize("PublicKeyInfo"),u=i.makePoint(s,a),l=c.encode({algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"PUBLIC")}toPrivateBlk(e){return e.d.toString("hex")}toPublicBlk(e){return n.convert(i.makePoint(e.x,e.y),"raw","hex")}toPrivateJwk(e){let{crv:t,kty:r}=this.params,{d:o,x:i,y:s}=e;return{kty:r,crv:t,d:n.convert(o,"raw","base64url"),x:n.convert(i,"raw","base64url"),y:n.convert(s,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:r}=this.params,{x:o,y:i}=e;return{kty:r,crv:t,x:n.convert(o,"raw","base64url"),y:n.convert(i,"raw","base64url")}}static getPoint(e){let t=e.slice(2,(e.length-2)/2+2),r=e.slice((e.length-2)/2+2);return{x:n.convert(t,"hex","raw"),y:n.convert(r,"hex","raw")}}static makePoint(e,r){let n=t.from("04","hex");return t.concat([n,e,r],n.length+e.length+r.length)}}return Ve=i}(),o=function(){if(Je)return Me;Je=1;const e=A(),r=et(),n=tt();class o extends e{fromPrivatePKCS8(e){const t=n.normalize("PrivateKeyInfo").decode(e,"der").privateKey.slice(2);return{d:t,x:this.publicKeyFromPrivate(t)}}fromPublicPKCS8(e){const t=n.normalize("PublicKeyInfo").decode(e,"der");return{x:r.convert(t.publicKey.data,"hex","raw")}}fromJwk(e){let{d:t,x:n}=e;return{d:r.convert(t,"base64url","raw"),x:r.convert(n,"base64url","raw")}}toPrivatePKCS8(e){let{oid:t,infoVersion:r}=this.params,{d:i}=e;const s=n.normalize("PrivateKeyInfo"),a=this.privateKeyPadding(i);let c=s.encode({version:r,algorithm:{algorithm:t.split(".")},privateKey:a},"der").toString("base64");return o.formatPem(c,"PRIVATE")}toPublicPKCS8(e){let{oid:t}=this.params,{x:i}=e,s=n.normalize("PublicKeyInfo").encode({algorithm:{algorithm:t.split(".")},publicKey:{unused:0,data:r.convert(i,"hex","raw")}},"der").toString("base64");return o.formatPem(s,"PUBLIC")}toPrivateJwk(e){let{crv:t,kty:n}=this.params,{d:o,x:i}=e;return{kty:n,crv:t,d:r.convert(o,"raw","base64url"),x:r.convert(i,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:n}=this.params,{x:o}=e;return{kty:n,crv:t,x:r.convert(o,"raw","base64url")}}privateKeyPadding(e){let r;if("Ed25519"!==this.params.crv)throw new Error(`${this.params.crv} is an invalid curve for EdDSA`);return r=t.from("0420","hex"),t.concat([r,e],r.length+e.length)}publicKeyFromPrivate(e){if("Ed25519"===this.params.crv){const r=new(0,a().eddsa)("ed25519");return t.from(r.keyFromSecret(e).getPublic())}throw new Error(`${this.params.crv} is an invalid curve for EdDSA`)}}return Me=o}(),i=new e;return i.define([{kty:"RSA",oid:"1.2.840.113549.1.1.1",algParameters:"0500",version:"two-prime"}],r),i.define([{kty:"EC",crv:"K-256",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.10",algParameters:"06052b8104000a",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-256",oid:"1.2.840.10045.2.1",namedCurve:"1.2.840.10045.3.1.7",algParameters:"06082a8648ce3d030107",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-384",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.34",algParameters:"06052b81040022",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-521",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.35",algParameters:"06052b81040023",keyVersion:1,infoVersion:"two-prime"}],n),i.define([{kty:"OKP",crv:"Ed25519",oid:"1.3.101.112",infoVersion:"two-prime"}],o),$e=i}var nt,ot,it,st,at,ct,ut=function(){if(Ge)return Ze;Ge=1;const e=S(),r=K(),n=rt(),o=tt(),i=RegExp("\r?\n","g");class s{constructor(t,r){if(!t)throw new e("key is required");if(!r)throw new e("options are required");let{kty:n,format:o,selector:i,crv:s,oid:a}=r;if(!r.kty)throw new e("options.kty is required");if(!r.format)throw new e("options.format is required");if(!r.selector)throw new e("options.selector is required");if(!r.crv&&!r.oid)throw new e("options.crv or options.oid is required");this.kty=n,this.format=o,this.selector=i,this.crv=s,this.oid=a,this.key=this.parseKey(t)}static from(r,a){if(!r)throw new e("key is required");if(!a)throw new e("format is required");if("jwk"===a){let t;if("string"==typeof r)try{t=JSON.parse(r)}catch(t){throw new e("key is not a valid JWK")}else"object"==typeof r&&(t=r);let o,{kty:i,crv:c}=t;if(!i)throw new e("kty is required for JWK");if("EC"===i&&!c)throw new e("crv is required for EC JWK");"RSA"===i&&(o=n.find((e=>e.kty===i)).oid);let u=t.d?"private":"public";return new s(t,{kty:i,crv:c,oid:o,format:a,selector:u})}if("pem"===a){if("string"!=typeof r)throw new e("key is not a valid PEM string");let c=r.split(i),u=c.splice(0,1);c.splice(c.length-1,1);let l,f,p=c.join(""),h=/^-----BEGIN ((RSA|EC) )?(PUBLIC|PRIVATE) KEY-----$/.exec(u),d=h?h[2]:void 0,y=h?h[3]:void 0,b=t.from(p,"base64");if(!y)throw new e("key is not a valid PEM string");if(d){if("RSA"===d)y="PRIVATE"===y?"private_pkcs1":"public_pkcs1",l=n.find((e=>e.kty===d)).oid;else if("EC"===d){let e;if("PRIVATE"===y){y="private_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}else if("PUBLIC"===y){y="public_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}let{parameters:{value:t}}=e;f=n.find((e=>e.namedCurve===t.join("."))).crv}}else{let t,r=o.normalize("PrivateKeyInfo"),i=o.normalize("PublicKeyInfo");"PRIVATE"===y?(y="private_pkcs8",t=r.decode(b,"der")):"PUBLIC"===y&&(y="public_pkcs8",t=i.decode(b,"der"));let{algorithm:{algorithm:s,parameters:a}}=t;s=s.join("."),a=a?a.toString("hex"):void 0;const c=n.find((e=>e.oid===s));if(d=c?c.kty:void 0,!d)throw new e(`${s} is not supported`);"RSA"===d||"OKP"===d?l=s:"EC"===d&&(f=n.find((e=>e.algParameters===a)).crv)}return new s(b,{kty:d,oid:l,crv:f,format:a,selector:y})}if("blk"===a)return new s(r,{kty:"EC",crv:"K-256",format:a,selector:r.length>64?"public":"private"});throw new e(`Invalid format ${a}`)}get alg(){let{kty:e,crv:t,oid:r}=this;if(!this.algorithm){if(t)Object.defineProperty(this,"algorithm",{value:n.normalize(e,"crv",t)});else{if(!r)throw new Error("Both crv and oid are undefined");Object.defineProperty(this,"algorithm",{value:n.normalize(e,"oid",r)})}if(!this.algorithm)throw new Error(`${this.crv||this.oid} is not implemented yet`)}return this.algorithm}parseKey(e){let{alg:t,format:r,selector:n}=this;if("pem"===r)switch(n){case"public_pkcs1":return t.fromPublicPKCS1(e);case"public_pkcs8":return t.fromPublicPKCS8(e);case"private_pkcs1":return t.fromPrivatePKCS1(e);case"private_pkcs8":return t.fromPrivatePKCS8(e);default:throw new Error("Invalid selector value")}if("jwk"===r)return t.fromJwk(e,n);if("blk"===r)switch(n){case"public":return t.fromPublicBlk(e);case"private":return t.fromPrivateBlk(e)}}toJwk(t){let{key:r,alg:n,selector:o}=this;switch(t){case"public":return n.toPublicJwk(r);case"private":if(o.includes("public"))throw new e("Cannot export a private key from a public key");return n.toPrivateJwk(r);default:throw new Error("Invalid key selector")}}toString(t="pem",n="public_pkcs8"){let{key:o,alg:i,selector:s}=this;if("pem"===t)switch(n){case"public_pkcs1":return i.toPublicPKCS1(o);case"public_pkcs8":return i.toPublicPKCS8(o);case"private_pkcs1":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS1(o);case"private_pkcs8":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS8(o);default:throw new Error("Invalid key selector")}else if("jwk"===t)switch(n){case"public":return JSON.stringify(i.toPublicJwk(o));case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return JSON.stringify(i.toPrivateJwk(o));default:throw new Error("Invalid key selector")}else if("blk"===t)switch(n){case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivateBlk(o);case"public":return i.toPublicBlk(o);default:throw new Error("Invalid key selector")}throw new r}}return Ze=s}(),lt=e(ut),ft=e(Qe());function pt(){if(st)return it;st=1;const e=new(0,a().ec)("secp256k1"),t=e.curve,r=t.n.constructor;function n(n){const o=n[0];switch(o){case 2:case 3:return 33!==n.length?null:function(n,o){let i=new r(o);if(i.cmp(t.p)>=0)return null;i=i.toRed(t.red);let s=i.redSqr().redIMul(i).redIAdd(t.b).redSqrt();return 3===n!==s.isOdd()&&(s=s.redNeg()),e.keyPair({pub:{x:i,y:s}})}(o,n.subarray(1,33));case 4:case 6:case 7:return 65!==n.length?null:function(n,o,i){let s=new r(o),a=new r(i);if(s.cmp(t.p)>=0||a.cmp(t.p)>=0)return null;if(s=s.toRed(t.red),a=a.toRed(t.red),(6===n||7===n)&&a.isOdd()!==(7===n))return null;const c=s.redSqr().redIMul(s);return a.redSqr().redISub(c.redIAdd(t.b)).isZero()?e.keyPair({pub:{x:s,y:a}}):null}(o,n.subarray(1,33),n.subarray(33,65));default:return null}}function o(e,t){const r=t.encode(null,33===e.length);for(let t=0;t<e.length;++t)e[t]=r[t]}return it={contextRandomize:()=>0,privateKeyVerify(e){const n=new r(e);return n.cmp(t.n)<0&&!n.isZero()?0:1},privateKeyNegate(e){const n=new r(e),o=t.n.sub(n).umod(t.n).toArrayLike(Uint8Array,"be",32);return e.set(o),0},privateKeyTweakAdd(e,n){const o=new r(n);if(o.cmp(t.n)>=0)return 1;if(o.iadd(new r(e)),o.cmp(t.n)>=0&&o.isub(t.n),o.isZero())return 1;const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},privateKeyTweakMul(e,n){let o=new r(n);if(o.cmp(t.n)>=0||o.isZero())return 1;o.imul(new r(e)),o.cmp(t.n)>=0&&(o=o.umod(t.n));const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},publicKeyVerify:e=>null===n(e)?1:0,publicKeyCreate(n,i){const s=new r(i);if(s.cmp(t.n)>=0||s.isZero())return 1;return o(n,e.keyFromPrivate(i).getPublic()),0},publicKeyConvert(e,t){const r=n(t);if(null===r)return 1;return o(e,r.getPublic()),0},publicKeyNegate(e,t){const r=n(t);if(null===r)return 1;const i=r.getPublic();return i.y=i.y.redNeg(),o(e,i),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e<t.length;++e)if(r[e]=n(t[e]),null===r[e])return 1;let i=r[0].getPublic();for(let e=1;e<r.length;++e)i=i.add(r[e].pub);return i.isInfinity()?2:(o(e,i),0)},publicKeyTweakAdd(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0)return 2;const c=a.getPublic().add(t.g.mul(s));return c.isInfinity()?2:(o(e,c),0)},publicKeyTweakMul(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0||s.isZero())return 2;return o(e,a.getPublic().mul(s)),0},signatureNormalize(n){const o=new r(n.subarray(0,32)),i=new r(n.subarray(32,64));return o.cmp(t.n)>=0||i.cmp(t.n)>=0?1:(1===i.cmp(e.nh)&&n.set(t.n.sub(i).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,n){const o=n.subarray(0,32),i=n.subarray(32,64);if(new r(o).cmp(t.n)>=0)return 1;if(new r(i).cmp(t.n)>=0)return 1;const{output:s}=e;let a=s.subarray(4,37);a[0]=0,a.set(o,1);let c=33,u=0;for(;c>1&&0===a[u]&&!(128&a[u+1]);--c,++u);if(a=a.subarray(u),128&a[0])return 1;if(c>1&&0===a[0]&&!(128&a[1]))return 1;let l=s.subarray(39,72);l[0]=0,l.set(i,1);let f=33,p=0;for(;f>1&&0===l[p]&&!(128&l[p+1]);--f,++p);return l=l.subarray(p),128&l[0]||f>1&&0===l[0]&&!(128&l[1])?1:(e.outputlen=6+c+f,s[0]=48,s[1]=e.outputlen-2,s[2]=2,s[3]=a.length,s.set(a,4),s[4+c]=2,s[5+c]=l.length,s.set(l,6+c),0)},signatureImport(e,n){if(n.length<8)return 1;if(n.length>72)return 1;if(48!==n[0])return 1;if(n[1]!==n.length-2)return 1;if(2!==n[2])return 1;const o=n[3];if(0===o)return 1;if(5+o>=n.length)return 1;if(2!==n[4+o])return 1;const i=n[5+o];if(0===i)return 1;if(6+o+i!==n.length)return 1;if(128&n[4])return 1;if(o>1&&0===n[4]&&!(128&n[5]))return 1;if(128&n[o+6])return 1;if(i>1&&0===n[o+6]&&!(128&n[o+7]))return 1;let s=n.subarray(4,4+o);if(33===s.length&&0===s[0]&&(s=s.subarray(1)),s.length>32)return 1;let a=n.subarray(6+o);if(33===a.length&&0===a[0]&&(a=a.slice(1)),a.length>32)throw new Error("S length is too long");let c=new r(s);c.cmp(t.n)>=0&&(c=new r(0));let u=new r(n.subarray(6+o));return u.cmp(t.n)>=0&&(u=new r(0)),e.set(c.toArrayLike(Uint8Array,"be",32),0),e.set(u.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(n,o,i,s,a){if(a){const e=a;a=t=>{const n=e(o,i,null,s,t);if(!(n instanceof Uint8Array&&32===n.length))throw new Error("This is the way");return new r(n)}}const c=new r(i);if(c.cmp(t.n)>=0||c.isZero())return 1;let u;try{u=e.sign(o,i,{canonical:!0,k:a,pers:s})}catch(e){return 1}return n.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),n.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),n.recid=u.recoveryParam,0},ecdsaVerify(o,i,s){const a={r:o.subarray(0,32),s:o.subarray(32,64)},c=new r(a.r),u=new r(a.s);if(c.cmp(t.n)>=0||u.cmp(t.n)>=0)return 1;if(1===u.cmp(e.nh)||c.isZero()||u.isZero())return 3;const l=n(s);if(null===l)return 2;const f=l.getPublic();return e.verify(i,a,f)?0:3},ecdsaRecover(n,i,s,a){const c={r:i.slice(0,32),s:i.slice(32,64)},u=new r(c.r),l=new r(c.s);if(u.cmp(t.n)>=0||l.cmp(t.n)>=0)return 1;if(u.isZero()||l.isZero())return 2;let f;try{f=e.recoverPubKey(a,c,s)}catch(e){return 2}return o(n,f),0},ecdh(o,i,s,a,c,u,l){const f=n(i);if(null===f)return 1;const p=new r(s);if(p.cmp(t.n)>=0||p.isZero())return 2;const h=f.getPublic().mul(p);if(void 0===c){const t=h.encode(null,!0),r=e.hash().update(t).digest();for(let e=0;e<32;++e)o[e]=r[e]}else{u||(u=new Uint8Array(32));const e=h.getX().toArray("be",32);for(let t=0;t<32;++t)u[t]=e[t];l||(l=new Uint8Array(32));const t=h.getY().toArray("be",32);for(let e=0;e<32;++e)l[e]=t[e];const r=c(u,l,a);if(!(r instanceof Uint8Array&&r.length===o.length))return 2;o.set(r)}return 0}}}var ht,dt,yt,bt,wt=(ct||(ct=1,at=function(){if(ot)return nt;ot=1;const e="Impossible case. Please create issue.",t="The tweak was out of range or the resulted private key is invalid",r="The tweak was out of range or equal to zero",n="Unknow error on context randomization",o="Private Key is invalid",i="Public Key could not be parsed",s="Public Key serialization error",a="The sum of the public keys is not valid",c="Signature could not be parsed",u="The nonce generation function failed, or the private key was invalid",l="Public key could not be recover",f="Scalar was invalid (zero or overflow)";function p(e,t){if(!e)throw new Error(t)}function h(e,t,r){if(p(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const n=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;p(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;p(t.length===r,n)}}function d(e){p("Boolean"===b(e),"Expected compressed to be a Boolean")}function y(e=e=>new Uint8Array(e),t){return"function"==typeof e&&(e=e(t)),h("output",e,t),e}function b(e){return Object.prototype.toString.call(e).slice(8,-1)}return nt=w=>({contextRandomize(e){if(p(null===e||e instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==e&&h("seed",e,32),1===w.contextRandomize(e))throw new Error(n)},privateKeyVerify:e=>(h("private key",e,32),0===w.privateKeyVerify(e)),privateKeyNegate(t){switch(h("private key",t,32),w.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(e)}},privateKeyTweakAdd(e,r){switch(h("private key",e,32),h("tweak",r,32),w.privateKeyTweakAdd(e,r)){case 0:return e;case 1:throw new Error(t)}},privateKeyTweakMul(e,t){switch(h("private key",e,32),h("tweak",t,32),w.privateKeyTweakMul(e,t)){case 0:return e;case 1:throw new Error(r)}},publicKeyVerify:e=>(h("public key",e,[33,65]),0===w.publicKeyVerify(e)),publicKeyCreate(e,t=!0,r){switch(h("private key",e,32),d(t),r=y(r,t?33:65),w.publicKeyCreate(r,e)){case 0:return r;case 1:throw new Error(o);case 2:throw new Error(s)}},publicKeyConvert(e,t=!0,r){switch(h("public key",e,[33,65]),d(t),r=y(r,t?33:65),w.publicKeyConvert(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(s)}},publicKeyNegate(t,r=!0,n){switch(h("public key",t,[33,65]),d(r),n=y(n,r?33:65),w.publicKeyNegate(n,t)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(e);case 3:throw new Error(s)}},publicKeyCombine(e,t=!0,r){p(Array.isArray(e),"Expected public keys to be an Array"),p(e.length>0,"Expected public keys array will have more than zero items");for(const t of e)h("public key",t,[33,65]);switch(d(t),r=y(r,t?33:65),w.publicKeyCombine(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(a);case 3:throw new Error(s)}},publicKeyTweakAdd(e,r,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",r,32),d(n),o=y(o,n?33:65),w.publicKeyTweakAdd(o,e,r)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(t)}},publicKeyTweakMul(e,t,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",t,32),d(n),o=y(o,n?33:65),w.publicKeyTweakMul(o,e,t)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(r)}},signatureNormalize(e){switch(h("signature",e,64),w.signatureNormalize(e)){case 0:return e;case 1:throw new Error(c)}},signatureExport(t,r){h("signature",t,64);const n={output:r=y(r,72),outputlen:72};switch(w.signatureExport(n,t)){case 0:return r.slice(0,n.outputlen);case 1:throw new Error(c);case 2:throw new Error(e)}},signatureImport(t,r){switch(h("signature",t),r=y(r,64),w.signatureImport(r,t)){case 0:return r;case 1:throw new Error(c);case 2:throw new Error(e)}},ecdsaSign(t,r,n={},o){h("message",t,32),h("private key",r,32),p("Object"===b(n),"Expected options to be an Object"),void 0!==n.data&&h("options.data",n.data),void 0!==n.noncefn&&p("Function"===b(n.noncefn),"Expected options.noncefn to be a Function");const i={signature:o=y(o,64),recid:null};switch(w.ecdsaSign(i,t,r,n.data,n.noncefn)){case 0:return i;case 1:throw new Error(u);case 2:throw new Error(e)}},ecdsaVerify(e,t,r){switch(h("signature",e,64),h("message",t,32),h("public key",r,[33,65]),w.ecdsaVerify(e,t,r)){case 0:return!0;case 3:return!1;case 1:throw new Error(c);case 2:throw new Error(i)}},ecdsaRecover(t,r,n,o=!0,i){switch(h("signature",t,64),p("Number"===b(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),h("message",n,32),d(o),i=y(i,o?33:65),w.ecdsaRecover(i,t,r,n)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(l);case 3:throw new Error(e)}},ecdh(e,t,r={},n){switch(h("public key",e,[33,65]),h("private key",t,32),p("Object"===b(r),"Expected options to be an Object"),void 0!==r.data&&h("options.data",r.data),void 0!==r.hashfn?(p("Function"===b(r.hashfn),"Expected options.hashfn to be a Function"),void 0!==r.xbuf&&h("options.xbuf",r.xbuf,32),void 0!==r.ybuf&&h("options.ybuf",r.ybuf,32),h("output",n)):n=y(n,32),w.ecdh(n,e,t,r.data,r.hashfn,r.xbuf,r.ybuf)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(f)}}}),nt}()(pt())),at),gt=e(wt);function mt(){if(bt)return yt;bt=1;const e=(dt||(dt=1,ht=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var o=e.charAt(n),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=n}var s=e.length,a=e.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,n=0,o=0;e[r]===a;)n++,r++;for(var i=(e.length-r)*c+1>>>0,u=new Uint8Array(i);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var f=0,p=i-1;(0!==l||f<o)&&-1!==p;p--,f++)l+=s*u[p]>>>0,u[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=f,r++}for(var h=i-o;h!==i&&0===u[h];)h++;for(var d=new Uint8Array(n+(i-h)),y=n;h!==i;)d[y++]=u[h++];return d}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var c=(i-o)*u+1>>>0,l=new Uint8Array(c);o!==i;){for(var f=t[o],p=0,h=c-1;(0!==f||p<n)&&-1!==h;h--,p++)f+=256*l[h]>>>0,l[h]=f%s>>>0,f=f/s>>>0;if(0!==f)throw new Error("Non-zero carry");n=p,o++}for(var d=c-n;d!==c&&0===l[d];)d++;for(var y=a.repeat(r);d<c;++d)y+=e.charAt(l[d]);return y},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}),ht);return yt=e("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}export{mt as a,_ as b,k as c,ft as d,wt as e,lt as k,E as r,gt as s};
|
|
1
|
+
import{g as e,B as t,u as r,x as n,i as o,y as i,p as s}from"./main.js";import{r as a,a as c,c as u,b as l,d as f}from"./elliptic-C4nnFoxE-BRLTdj5Y.js";var p,h,d,y,b,w,g,m,v,k=r(n),_=r(i),P={exports:{}};function E(){return p||(p=1,function(e,t){var r=c,n=r.Buffer;function o(e,t){for(var r in e)t[r]=e[r]}function i(e,t,r){return n(e,t,r)}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=i),i.prototype=Object.create(n.prototype),o(n,i),i.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return n(e,t,r)},i.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=n(e);return void 0!==t?"string"==typeof r?o.fill(t,r):o.fill(t):o.fill(0),o},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}}(P,P.exports)),P.exports}function S(){if(d)return h;d=1;class e extends Error{constructor(e){super(e||"This operation is not supported for this key type")}}return h=e}function K(){if(b)return y;b=1;class e extends Error{constructor(){super("This has not been implemented yet")}}return y=e}function A(){if(v)return m;v=1;const e=K();return m=class{constructor(e){this.params=e}fromPrivatePKCS1(t){throw new e}fromPrivatePKCS8(t){throw new e}fromPublicPKCS1(t){throw new e}fromPublicPKCS8(t){throw new e}fromPrivateBlk(t){throw new e}fromPublicBlk(t){throw new e}fromJwk(t){throw new e}toPrivatePKCS1(t){throw new e}toPrivatePKCS8(t){throw new e}toPublicPKCS1(t){throw new e}toPublicPKCS8(t){throw new e}toPrivateBlk(t){throw new e}toPublicBlk(t){throw new e}toPrivateJwk(t){throw new e}toPublicJwk(t){throw new e}static formatPem(e,t){return`-----BEGIN ${t} KEY-----\n`+e.match(/.{1,64}/g).join("\n")+`\n-----END ${t} KEY-----`}}}var x,C,B={},j={},U={};function I(){if(C)return x;C=1;var e,t=c,r=t.Buffer,n={};for(e in t)t.hasOwnProperty(e)&&"SlowBuffer"!==e&&"Buffer"!==e&&(n[e]=t[e]);var o=n.Buffer={};for(e in r)r.hasOwnProperty(e)&&"allocUnsafe"!==e&&"allocUnsafeSlow"!==e&&(o[e]=r[e]);if(n.Buffer.prototype=r.prototype,o.from&&o.from!==Uint8Array.from||(o.from=function(e,t,n){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return r(e,t,n)}),o.alloc||(o.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var o=r(e);return t&&0!==t.length?"string"==typeof n?o.fill(t,n):o.fill(t):o.fill(0),o}),!n.kStringMaxLength)try{n.kStringMaxLength=s.binding("buffer").kStringMaxLength}catch(e){}return n.constants||(n.constants={MAX_LENGTH:n.kMaxLength},n.kStringMaxLength&&(n.constants.MAX_STRING_LENGTH=n.kStringMaxLength)),x=n}var T,q={};function N(){if(T)return q;T=1;const e=l();function t(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function r(e,t){this.path=e,this.rethrow(t)}return q.Reporter=t,t.prototype.isError=function(e){return e instanceof r},t.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},t.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},t.prototype.enterKey=function(e){return this._reporterState.path.push(e)},t.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},t.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},t.prototype.path=function(){return this._reporterState.path.join("/")},t.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},t.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},t.prototype.error=function(e){let t;const n=this._reporterState,o=e instanceof r;if(t=o?e:new r(n.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!n.options.partial)throw t;return o||n.errors.push(t),t},t.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},e(r,Error),r.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,r),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this},q}var z,O,R,D={};function V(){if(z)return D;z=1;const e=l(),t=N().Reporter,r=I().Buffer;function n(e,n){t.call(this,n),r.isBuffer(e)?(this.base=e,this.offset=0,this.length=e.length):this.error("Input not Buffer")}function o(e,t){if(Array.isArray(e))this.length=0,this.value=e.map((function(e){return o.isEncoderBuffer(e)||(e=new o(e,t)),this.length+=e.length,e}),this);else if("number"==typeof e){if(!(0<=e&&e<=255))return t.error("non-byte EncoderBuffer value");this.value=e,this.length=1}else if("string"==typeof e)this.value=e,this.length=r.byteLength(e);else{if(!r.isBuffer(e))return t.error("Unsupported type: "+typeof e);this.value=e,this.length=e.length}}return e(n,t),D.DecoderBuffer=n,n.isDecoderBuffer=function(e){if(e instanceof n)return!0;return"object"==typeof e&&r.isBuffer(e.base)&&"DecoderBuffer"===e.constructor.name&&"number"==typeof e.offset&&"number"==typeof e.length&&"function"==typeof e.save&&"function"==typeof e.restore&&"function"==typeof e.isEmpty&&"function"==typeof e.readUInt8&&"function"==typeof e.skip&&"function"==typeof e.raw},n.prototype.save=function(){return{offset:this.offset,reporter:t.prototype.save.call(this)}},n.prototype.restore=function(e){const r=new n(this.base);return r.offset=e.offset,r.length=this.offset,this.offset=e.offset,t.prototype.restore.call(this,e.reporter),r},n.prototype.isEmpty=function(){return this.offset===this.length},n.prototype.readUInt8=function(e){return this.offset+1<=this.length?this.base.readUInt8(this.offset++,!0):this.error(e||"DecoderBuffer overrun")},n.prototype.skip=function(e,t){if(!(this.offset+e<=this.length))return this.error(t||"DecoderBuffer overrun");const r=new n(this.base);return r._reporterState=this._reporterState,r.offset=this.offset,r.length=this.offset+e,this.offset+=e,r},n.prototype.raw=function(e){return this.base.slice(e?e.offset:this.offset,this.length)},D.EncoderBuffer=o,o.isEncoderBuffer=function(e){if(e instanceof o)return!0;return"object"==typeof e&&"EncoderBuffer"===e.constructor.name&&"number"==typeof e.length&&"function"==typeof e.join},o.prototype.join=function(e,t){return e||(e=r.alloc(this.length)),t||(t=0),0===this.length||(Array.isArray(this.value)?this.value.forEach((function(r){r.join(e,t),t+=r.length})):("number"==typeof this.value?e[t]=this.value:"string"==typeof this.value?e.write(this.value,t):r.isBuffer(this.value)&&this.value.copy(e,t),t+=this.length)),e},D}function L(){if(R)return O;R=1;const e=N().Reporter,t=V().EncoderBuffer,r=V().DecoderBuffer,n=f(),o=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],i=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(o);function s(e,t,r){const n={};this._baseState=n,n.name=r,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}O=s;const a=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];return s.prototype.clone=function(){const e=this._baseState,t={};a.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},s.prototype._wrap=function(){const e=this._baseState;i.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},s.prototype._init=function(e){const t=this._baseState;n(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),n.equal(t.children.length,1,"Root node can have only one child")},s.prototype._useArgs=function(e){const t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(n(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(n(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);const n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){s.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),o.forEach((function(e){s.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return n(null===t.tag),t.tag=e,this._useArgs(r),this}})),s.prototype.use=function(e){n(e);const t=this._baseState;return n(null===t.use),t.use=e,this},s.prototype.optional=function(){return this._baseState.optional=!0,this},s.prototype.def=function(e){const t=this._baseState;return n(null===t.default),t.default=e,t.optional=!0,this},s.prototype.explicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.explicit=e,this},s.prototype.implicit=function(e){const t=this._baseState;return n(null===t.explicit&&null===t.implicit),t.implicit=e,this},s.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},s.prototype.key=function(e){const t=this._baseState;return n(null===t.key),t.key=e,this},s.prototype.any=function(){return this._baseState.any=!0,this},s.prototype.choice=function(e){const t=this._baseState;return n(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},s.prototype.contains=function(e){const t=this._baseState;return n(null===t.use),t.contains=e,this},s.prototype._decode=function(e,t){const n=this._baseState;if(null===n.parent)return e.wrapResult(n.children[0]._decode(e,t));let o,i=n.default,s=!0,a=null;if(null!==n.key&&(a=e.enterKey(n.key)),n.optional){let r=null;if(null!==n.explicit?r=n.explicit:null!==n.implicit?r=n.implicit:null!==n.tag&&(r=n.tag),null!==r||n.any){if(s=this._peekTag(e,r,n.any),e.isError(s))return s}else{const r=e.save();try{null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t),s=!0}catch(e){s=!1}e.restore(r)}}if(n.obj&&s&&(o=e.enterObject()),s){if(null!==n.explicit){const t=this._decodeTag(e,n.explicit);if(e.isError(t))return t;e=t}const o=e.offset;if(null===n.use&&null===n.choice){let t;n.any&&(t=e.save());const r=this._decodeTag(e,null!==n.implicit?n.implicit:n.tag,n.any);if(e.isError(r))return r;n.any?i=e.raw(t):e=r}if(t&&t.track&&null!==n.tag&&t.track(e.path(),o,e.length,"tagged"),t&&t.track&&null!==n.tag&&t.track(e.path(),e.offset,e.length,"content"),n.any||(i=null===n.choice?this._decodeGeneric(n.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(n.any||null!==n.choice||null===n.children||n.children.forEach((function(r){r._decode(e,t)})),n.contains&&("octstr"===n.tag||"bitstr"===n.tag)){const o=new r(i);i=this._getUse(n.contains,e._reporterState.obj)._decode(o,t)}}return n.obj&&s&&(i=e.leaveObject(o)),null===n.key||null===i&&!0!==s?null!==a&&e.exitKey(a):e.leaveKey(a,n.key,i),i},s.prototype._decodeGeneric=function(e,t,r){const n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},s.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),n(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},s.prototype._decodeChoice=function(e,t){const r=this._baseState;let n=null,o=!1;return Object.keys(r.choice).some((function(i){const s=e.save(),a=r.choice[i];try{const r=a._decode(e,t);if(e.isError(r))return!1;n={type:i,value:r},o=!0}catch(t){return e.restore(s),!1}return!0}),this),o?n:e.error("Choice not matched")},s.prototype._createEncoderBuffer=function(e){return new t(e,this.reporter)},s.prototype._encode=function(e,t,r){const n=this._baseState;if(null!==n.default&&n.default===e)return;const o=this._encodeValue(e,t,r);return void 0===o||this._skipDefault(o,t,r)?void 0:o},s.prototype._encodeValue=function(t,r,n){const o=this._baseState;if(null===o.parent)return o.children[0]._encode(t,r||new e);let i=null;if(this.reporter=r,o.optional&&void 0===t){if(null===o.default)return;t=o.default}let s=null,a=!1;if(o.any)i=this._createEncoderBuffer(t);else if(o.choice)i=this._encodeChoice(t,r);else if(o.contains)s=this._getUse(o.contains,n)._encode(t,r),a=!0;else if(o.children)s=o.children.map((function(e){if("null_"===e._baseState.tag)return e._encode(null,r,t);if(null===e._baseState.key)return r.error("Child should have a key");const n=r.enterKey(e._baseState.key);if("object"!=typeof t)return r.error("Child expected, but input is not object");const o=e._encode(t[e._baseState.key],r,t);return r.leaveKey(n),o}),this).filter((function(e){return e})),s=this._createEncoderBuffer(s);else if("seqof"===o.tag||"setof"===o.tag){if(!o.args||1!==o.args.length)return r.error("Too many args for : "+o.tag);if(!Array.isArray(t))return r.error("seqof/setof, but data is not Array");const e=this.clone();e._baseState.implicit=null,s=this._createEncoderBuffer(t.map((function(e){const n=this._baseState;return this._getUse(n.args[0],t)._encode(e,r)}),e))}else null!==o.use?i=this._getUse(o.use,n)._encode(t,r):(s=this._encodePrimitive(o.tag,t),a=!0);if(!o.any&&null===o.choice){const e=null!==o.implicit?o.implicit:o.tag,t=null===o.implicit?"universal":"context";null===e?null===o.use&&r.error("Tag could be omitted only for .use()"):null===o.use&&(i=this._encodeComposite(e,a,t,s))}return null!==o.explicit&&(i=this._encodeComposite(o.explicit,!1,"context",i)),i},s.prototype._encodeChoice=function(e,t){const r=this._baseState,o=r.choice[e.type];return o||n(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),o._encode(e.value,t)},s.prototype._encodePrimitive=function(e,t){const r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},s.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},s.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)},O}var M,J,$,F,Z,G,Y={};function H(){return M||(M=1,function(e){function t(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t}e.tagClass={0:"universal",1:"application",2:"context",3:"private"},e.tagClassByName=t(e.tagClass),e.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},e.tagByName=t(e.tag)}(Y)),Y}function X(){if($)return J;$=1;const e=l(),t=I().Buffer,r=L(),n=H();function o(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new i,this.tree._init(e.body)}function i(e){r.call(this,"der",e)}function s(e){return e<10?"0"+e:e}return J=o,o.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},e(i,r),i.prototype._encodeComposite=function(e,r,o,i){const s=function(e,t,r,o){let i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(n.tagByName.hasOwnProperty(e))i=n.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return o.error("Unknown tag: "+e);i=e}if(i>=31)return o.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=n.tagClassByName[r||"universal"]<<6,i}(e,r,o,this.reporter);if(i.length<128){const e=t.alloc(2);return e[0]=s,e[1]=i.length,this._createEncoderBuffer([e,i])}let a=1;for(let e=i.length;e>=256;e>>=8)a++;const c=t.alloc(2+a);c[0]=s,c[1]=128|a;for(let e=1+a,t=i.length;t>0;e--,t>>=8)c[e]=255&t;return this._createEncoderBuffer([c,i])},i.prototype._encodeStr=function(e,r){if("bitstr"===r)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===r){const r=t.alloc(2*e.length);for(let t=0;t<e.length;t++)r.writeUInt16BE(e.charCodeAt(t),2*t);return this._createEncoderBuffer(r)}return"numstr"===r?this._isNumstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: numstr supports only digits and space"):"printstr"===r?this._isPrintstr(e)?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: printstr supports only latin upper and lower case letters, digits, space, apostrophe, left and rigth parenthesis, plus sign, comma, hyphen, dot, slash, colon, equal sign, question mark"):/str$/.test(r)||"objDesc"===r?this._createEncoderBuffer(e):this.reporter.error("Encoding of string type: "+r+" unsupported")},i.prototype._encodeObjid=function(e,r,n){if("string"==typeof e){if(!r)return this.reporter.error("string objid given, but no values map found");if(!r.hasOwnProperty(e))return this.reporter.error("objid not found in values map");e=r[e].split(/[\s.]+/g);for(let t=0;t<e.length;t++)e[t]|=0}else if(Array.isArray(e)){e=e.slice();for(let t=0;t<e.length;t++)e[t]|=0}if(!Array.isArray(e))return this.reporter.error("objid() should be either array or string, got: "+JSON.stringify(e));if(!n){if(e[1]>=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let o=0;for(let t=0;t<e.length;t++){let r=e[t];for(o++;r>=128;r>>=7)o++}const i=t.alloc(o);let s=i.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(i[s--]=127&r;(r>>=7)>0;)i[s--]=128|127&r}return this._createEncoderBuffer(i)},i.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[s(n.getUTCFullYear()),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[s(n.getUTCFullYear()%100),s(n.getUTCMonth()+1),s(n.getUTCDate()),s(n.getUTCHours()),s(n.getUTCMinutes()),s(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},i.prototype._encodeNull=function(){return this._createEncoderBuffer("")},i.prototype._encodeInt=function(e,r){if("string"==typeof e){if(!r)return this.reporter.error("String int or enum given, but no values map");if(!r.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=r[e]}if("number"!=typeof e&&!t.isBuffer(e)){const r=e.toArray();!e.sign&&128&r[0]&&r.unshift(0),e=t.from(r)}if(t.isBuffer(e)){let r=e.length;0===e.length&&r++;const n=t.alloc(r);return e.copy(n),0===e.length&&(n[0]=0),this._createEncoderBuffer(n)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let n=1;for(let t=e;t>=256;t>>=8)n++;const o=new Array(n);for(let t=o.length-1;t>=0;t--)o[t]=255&e,e>>=8;return 128&o[0]&&o.unshift(0),this._createEncoderBuffer(t.from(o))},i.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},i.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},i.prototype._skipDefault=function(e,t,r){const n=this._baseState;let o;if(null===n.default)return!1;const i=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),i.length!==n.defaultBuffer.length)return!1;for(o=0;o<i.length;o++)if(i[o]!==n.defaultBuffer[o])return!1;return!0},J}function W(){return G||(G=1,function(e){const t=e;t.der=X(),t.pem=function(){if(Z)return F;Z=1;const e=l(),t=X();function r(e){t.call(this,e),this.enc="pem"}return e(r,t),F=r,r.prototype.encode=function(e,r){const n=t.prototype.encode.call(this,e).toString("base64"),o=["-----BEGIN "+r.label+"-----"];for(let e=0;e<n.length;e+=64)o.push(n.slice(e,e+64));return o.push("-----END "+r.label+"-----"),o.join("\n")},F}()}(U)),U}var Q,ee,te,re,ne,oe,ie={};function se(){if(ee)return Q;ee=1;const e=l(),t=u(),r=V().DecoderBuffer,n=L(),o=H();function i(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new s,this.tree._init(e.body)}function s(e){n.call(this,"der",e)}function a(e,t){let r=e.readUInt8(t);if(e.isError(r))return r;const n=o.tagClass[r>>6],i=!(32&r);if(31&~r)r&=31;else{let n=r;for(r=0;!(128&~n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}return{cls:n,primitive:i,tag:r,tagStr:o.tag[r]}}function c(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(!(128&n))return n;const o=127&n;if(o>4)return e.error("length octect is too long");n=0;for(let t=0;t<o;t++){n<<=8;const t=e.readUInt8(r);if(e.isError(t))return t;n|=t}return n}return Q=i,i.prototype.decode=function(e,t){return r.isDecoderBuffer(e)||(e=new r(e,t)),this.tree._decode(e,t)},e(s,n),s.prototype._peekTag=function(e,t,r){if(e.isEmpty())return!1;const n=e.save(),o=a(e,'Failed to peek tag: "'+t+'"');return e.isError(o)?o:(e.restore(n),o.tag===t||o.tagStr===t||o.tagStr+"of"===t||r)},s.prototype._decodeTag=function(e,t,r){const n=a(e,'Failed to decode tag of "'+t+'"');if(e.isError(n))return n;let o=c(e,n.primitive,'Failed to get length of "'+t+'"');if(e.isError(o))return o;if(!r&&n.tag!==t&&n.tagStr!==t&&n.tagStr+"of"!==t)return e.error('Failed to match tag: "'+t+'"');if(n.primitive||null!==o)return e.skip(o,'Failed to match body of: "'+t+'"');const i=e.save(),s=this._skipUntilEnd(e,'Failed to skip indefinite length body: "'+this.tag+'"');return e.isError(s)?s:(o=e.offset-i.offset,e.restore(i),e.skip(o,'Failed to match body of: "'+t+'"'))},s.prototype._skipUntilEnd=function(e,t){for(;;){const r=a(e,t);if(e.isError(r))return r;const n=c(e,r.primitive,t);if(e.isError(n))return n;let o;if(o=r.primitive||null!==n?e.skip(n):this._skipUntilEnd(e,t),e.isError(o))return o;if("end"===r.tagStr)break}},s.prototype._decodeList=function(e,t,r,n){const o=[];for(;!e.isEmpty();){const t=this._peekTag(e,"end");if(e.isError(t))return t;const i=r.decode(e,"der",n);if(e.isError(i)&&t)break;o.push(i)}return o},s.prototype._decodeStr=function(e,t){if("bitstr"===t){const t=e.readUInt8();return e.isError(t)?t:{unused:t,data:e.raw()}}if("bmpstr"===t){const t=e.raw();if(t.length%2==1)return e.error("Decoding of string type: bmpstr length mismatch");let r="";for(let e=0;e<t.length/2;e++)r+=String.fromCharCode(t.readUInt16BE(2*e));return r}if("numstr"===t){const t=e.raw().toString("ascii");return this._isNumstr(t)?t:e.error("Decoding of string type: numstr unsupported characters")}if("octstr"===t)return e.raw();if("objDesc"===t)return e.raw();if("printstr"===t){const t=e.raw().toString("ascii");return this._isPrintstr(t)?t:e.error("Decoding of string type: printstr unsupported characters")}return/str$/.test(t)?e.raw().toString():e.error("Decoding of string type: "+t+" unsupported")},s.prototype._decodeObjid=function(e,t,r){let n;const o=[];let i=0,s=0;for(;!e.isEmpty();)s=e.readUInt8(),i<<=7,i|=127&s,128&s||(o.push(i),i=0);128&s&&o.push(i);const a=o[0]/40|0,c=o[0]%40;if(n=r?o:[a,c].concat(o.slice(1)),t){let e=t[n.join(" ")];void 0===e&&(e=t[n.join(".")]),void 0!==e&&(n=e)}return n},s.prototype._decodeTime=function(e,t){const r=e.raw().toString();let n,o,i,s,a,c;if("gentime"===t)n=0|r.slice(0,4),o=0|r.slice(4,6),i=0|r.slice(6,8),s=0|r.slice(8,10),a=0|r.slice(10,12),c=0|r.slice(12,14);else{if("utctime"!==t)return e.error("Decoding "+t+" time is not supported yet");n=0|r.slice(0,2),o=0|r.slice(2,4),i=0|r.slice(4,6),s=0|r.slice(6,8),a=0|r.slice(8,10),c=0|r.slice(10,12),n=n<70?2e3+n:1900+n}return Date.UTC(n,o-1,i,s,a,c,0)},s.prototype._decodeNull=function(){return null},s.prototype._decodeBool=function(e){const t=e.readUInt8();return e.isError(t)?t:0!==t},s.prototype._decodeInt=function(e,r){const n=e.raw();let o=new t(n);return r&&(o=r[o.toString(10)]||o),o},s.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getDecoder("der").tree},Q}function ae(){return ne||(ne=1,function(e){const t=e;t.der=se(),t.pem=function(){if(re)return te;re=1;const e=l(),t=I().Buffer,r=se();function n(e){r.call(this,e),this.enc="pem"}return e(n,r),te=n,n.prototype.decode=function(e,n){const o=e.toString().split(/[\r\n]+/g),i=n.label.toUpperCase(),s=/^-----(BEGIN|END) ([^-]+)-----$/;let a=-1,c=-1;for(let e=0;e<o.length;e++){const t=o[e].match(s);if(null!==t&&t[2]===i){if(-1!==a){if("END"!==t[1])break;c=e;break}if("BEGIN"!==t[1])break;a=e}}if(-1===a||-1===c)throw new Error("PEM section not found for: "+i);const u=o.slice(a+1,c).join("");u.replace(/[^a-z0-9+/=]+/gi,"");const l=t.from(u,"base64");return r.prototype.decode.call(this,l,n)},te}()}(ie)),ie}var ce,ue={};var le,fe,pe={};function he(){return fe||(fe=1,function(){const e=B;e.bignum=u(),e.define=(oe||(oe=1,function(e){const t=W(),r=ae(),n=l();function o(e,t){this.name=e,this.body=t,this.decoders={},this.encoders={}}e.define=function(e,t){return new o(e,t)},o.prototype._createNamed=function(e){const t=this.name;function r(e){this._initNamed(e,t)}return n(r,e),r.prototype._initNamed=function(t,r){e.call(this,t,r)},new r(this)},o.prototype._getDecoder=function(e){return e=e||"der",this.decoders.hasOwnProperty(e)||(this.decoders[e]=this._createNamed(r[e])),this.decoders[e]},o.prototype.decode=function(e,t,r){return this._getDecoder(t).decode(e,r)},o.prototype._getEncoder=function(e){return e=e||"der",this.encoders.hasOwnProperty(e)||(this.encoders[e]=this._createNamed(t[e])),this.encoders[e]},o.prototype.encode=function(e,t,r){return this._getEncoder(t).encode(e,r)}}(j)),j).define,e.base=(ce||(ce=1,function(e){const t=e;t.Reporter=N().Reporter,t.DecoderBuffer=V().DecoderBuffer,t.EncoderBuffer=V().EncoderBuffer,t.Node=L()}(ue)),ue),e.constants=(le||(le=1,function(e){const t=e;t._reverse=function(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t},t.der=H()}(pe)),pe),e.decoders=ae(),e.encoders=W()}()),B}var de,ye,be,we,ge,me,ve,ke,_e,Pe,Ee,Se,Ke,Ae,xe,Ce,Be,je,Ue,Ie,Te,qe,Ne,ze,Oe,Re,De,Ve,Le,Me,Je,$e,Fe,Ze,Ge,Ye={exports:{}},He={},Xe={};function We(){if(ye)return He;ye=1,Object.defineProperty(He,"__esModule",{value:!0});var e=(de||(de=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.default=function(e){var r=e.length,n=r%4;if(!n)return e;var o=r,i=4-n,s=r+i,a=t.alloc(s);for(a.write(e);i--;)a.write("=",o++);return a.toString()}),Xe);function r(e,r){return void 0===r&&(r="utf8"),o(e)?i(e.toString("base64")):i(t.from(e,r).toString("base64"))}function n(t){return t=t.toString(),e.default(t).replace(/\-/g,"+").replace(/_/g,"/")}function i(e){return e.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}var s=r;return s.encode=r,s.decode=function(e,r){return void 0===r&&(r="utf8"),t.from(n(e),"base64").toString(r)},s.toBase64=n,s.fromBase64=i,s.toBuffer=function(e){return t.from(n(e),"base64")},He.default=s,He}function Qe(){return be||(be=1,(e=Ye).exports=We().default,e.exports.default=e.exports),Ye.exports;var e}function et(){if(ge)return we;ge=1;const e=he(),r=Qe();return we=class{static convert(n,o,i){if(!n)return;if(o===i)return n;let s;if("raw"===o||n instanceof t)s=n;else if("uint8_array"===o||Array.isArray(n))s=t.from(n);else if("hex"===o)s=t.from(n,"hex");else if("base64"===o)s=t.from(n,"base64");else if("base64url"===o)s=r.toBuffer(n);else{if("bn"!==o&&"bignum"!==o)throw new Error("Invalid fromType");s=t.from(this.pad(n.toString(16)),"hex")}if("raw"===i)return s;if("uint8_array"===i)return Array.from(s);if("hex"===i)return s.toString("hex");if("base64"===i)return s.toString("base64");if("base64url"===i)return r.fromBase64(s.toString("base64"));if("bn"===i||"bignum"===i)return new e.bignum(s);throw new Error("Invalid toType")}static pad(e){return e.length%2==1?`0${e}`:e}},we}function tt(){if(Oe)return ze;Oe=1;const e=new(function(){if(ve)return me;ve=1;const e=he();return me=class{constructor(){Object.defineProperty(this,"_registry",{value:{}})}get registry(){return this._registry}define(t,r){this._registry[t]=e.define(t,r(this))}normalize(e){return this.registry[e]}}}());return e.define("Version",_e?ke:(_e=1,ke=e=>function(){this.int({0:"two-prime",1:"multi"})})),e.define("OtherPrimeInfos",Ee?Pe:(Ee=1,Pe=e=>function(){this.seq().obj(this.key("ri").int(),this.key("di").int(),this.key("ti").int())})),e.define("AlgorithmIdentifier",Ke?Se:(Ke=1,Se=e=>function(){this.seq().obj(this.key("algorithm").objid(),this.key("parameters").optional().any())})),e.define("PrivateKeyInfo",(xe||(xe=1,Ae=e=>{let t=e.normalize("Version"),r=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("version").use(t),this.key("algorithm").use(r),this.key("privateKey").octstr())}}),Ae)),e.define("PublicKeyInfo",(Be||(Be=1,Ce=e=>{let t=e.normalize("AlgorithmIdentifier");return function(){this.seq().obj(this.key("algorithm").use(t),this.key("publicKey").bitstr())}}),Ce)),e.define("RSAPrivateKey",(Ue||(Ue=1,je=e=>{let t=e.normalize("Version"),r=e.normalize("OtherPrimeInfos");return function(){this.seq().obj(this.key("version").use(t),this.key("n").int(),this.key("e").int(),this.key("d").int(),this.key("p").int(),this.key("q").int(),this.key("dp").int(),this.key("dq").int(),this.key("qi").int(),this.key("other").optional().use(r))}}),je)),e.define("RSAPublicKey",Te?Ie:(Te=1,Ie=e=>function(){this.seq().obj(this.key("n").int(),this.key("e").int())})),e.define("ECPrivateKey",Ne?qe:(Ne=1,qe=e=>function(){this.seq().obj(this.key("version").int(),this.key("privateKey").octstr(),this.key("parameters").explicit(0).optional().choice({namedCurve:this.objid()}),this.key("publicKey").explicit(1).optional().bitstr())})),ze=e}function rt(){if(Fe)return $e;Fe=1;const e=g?w:(g=1,w=class{constructor(){this.registry=[],this.classes={}}find(e){return this.registry.find(e)}define(e,t){e.forEach((e=>{let{kty:r}=e;if(!r)throw new Error("Invalid type definition");this.classes[r]||(this.classes[r]=t),this.registry.push(e)}))}normalize(e,t,r){let n=this.classes[e],o=this.find((e=>e[t]===r));if(!n||!o)throw new Error("Invalid type");return new n(o)}}),r=function(){if(De)return Re;De=1;const e=A();S();const r=et(),n=tt();class o extends e{fromPrivatePKCS1(e){let t=n.normalize("RSAPrivateKey"),{n:o,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw"),d:r.convert(s,"bn","raw"),p:r.convert(a,"bn","raw"),q:r.convert(c,"bn","raw"),dp:r.convert(u,"bn","raw"),dq:r.convert(l,"bn","raw"),qi:r.convert(f,"bn","raw")}}fromPrivatePKCS8(e){let t=n.normalize("PrivateKeyInfo"),o=n.normalize("RSAPrivateKey"),i=t.decode(e,"der"),{n:s,e:a,d:c,p:u,q:l,dp:f,dq:p,qi:h}=o.decode(i.privateKey,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw"),d:r.convert(c,"bn","raw"),p:r.convert(u,"bn","raw"),q:r.convert(l,"bn","raw"),dp:r.convert(f,"bn","raw"),dq:r.convert(p,"bn","raw"),qi:r.convert(h,"bn","raw")}}fromPublicPKCS1(e){let t=n.normalize("RSAPublicKey"),{n:o,e:i}=t.decode(e,"der");return{n:r.convert(o,"bn","raw"),e:r.convert(i,"bn","raw")}}fromPublicPKCS8(e){let t=n.normalize("PublicKeyInfo"),o=n.normalize("RSAPublicKey"),i=t.decode(e,"der"),{n:s,e:a}=o.decode(i.publicKey.data,"der");return{n:r.convert(s,"bn","raw"),e:r.convert(a,"bn","raw")}}fromJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u,alg:l}=e;return{n:r.convert(t,"base64url","raw"),e:r.convert(n,"base64url","raw"),d:r.convert(o,"base64url","raw"),p:r.convert(i,"base64url","raw"),q:r.convert(s,"base64url","raw"),dp:r.convert(a,"base64url","raw"),dq:r.convert(c,"base64url","raw"),qi:r.convert(u,"base64url","raw")}}toPrivatePKCS1(e){let{n:t,e:i,d:s,p:a,q:c,dp:u,dq:l,qi:f}=e,{version:p}=this.params,h=n.normalize("RSAPrivateKey").encode({version:p,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn"),d:r.convert(s,"raw","bn"),p:r.convert(a,"raw","bn"),q:r.convert(c,"raw","bn"),dp:r.convert(u,"raw","bn"),dq:r.convert(l,"raw","bn"),qi:r.convert(f,"raw","bn")},"der").toString("base64");return o.formatPem(h,"RSA PRIVATE")}toPrivatePKCS8(e){let{n:i,e:s,d:a,p:c,q:u,dp:l,dq:f,qi:p}=e,{oid:h,algParameters:d,version:y}=this.params,b=n.normalize("PrivateKeyInfo"),w=n.normalize("RSAPrivateKey").encode({version:y,n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn"),d:r.convert(a,"raw","bn"),p:r.convert(c,"raw","bn"),q:r.convert(u,"raw","bn"),dp:r.convert(l,"raw","bn"),dq:r.convert(f,"raw","bn"),qi:r.convert(p,"raw","bn")},"der"),g=b.encode({version:y,algorithm:{algorithm:h.split("."),parameters:t.from(d,"hex")},privateKey:w},"der").toString("base64");return o.formatPem(g,"PRIVATE")}toPublicPKCS1(e){let{n:t,e:i}=e,{version:s}=this.params,a=n.normalize("RSAPublicKey").encode({version:s,n:r.convert(t,"raw","bn"),e:r.convert(i,"raw","bn")},"der").toString("base64");return o.formatPem(a,"RSA PUBLIC")}toPublicPKCS8(e){let{n:i,e:s}=e,{oid:a,algParameters:c}=this.params,u=n.normalize("PublicKeyInfo"),l=n.normalize("RSAPublicKey").encode({n:r.convert(i,"raw","bn"),e:r.convert(s,"raw","bn")},"der"),f=u.encode({algorithm:{algorithm:a.split("."),parameters:t.from(c,"hex")},publicKey:{unused:0,data:l}},"der").toString("base64");return o.formatPem(f,"PUBLIC")}toPrivateJwk(e){let{n:t,e:n,d:o,p:i,q:s,dp:a,dq:c,qi:u}=e,{kty:l}=this.params;return{kty:l,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url"),d:r.convert(o,"raw","base64url"),p:r.convert(i,"raw","base64url"),q:r.convert(s,"raw","base64url"),dp:r.convert(a,"raw","base64url"),dq:r.convert(c,"raw","base64url"),qi:r.convert(u,"raw","base64url")}}toPublicJwk(e){let{n:t,e:n}=e,{kty:o}=this.params;return{kty:o,n:r.convert(t,"raw","base64url"),e:r.convert(n,"raw","base64url")}}}return Re=o}(),n=function(){if(Le)return Ve;Le=1,he().bignum;const e=new(0,a().ec)("secp256k1"),r=A();S();const n=et(),o=tt();class i extends r{fromPrivatePKCS1(e){let t=o.normalize("ECPrivateKey").decode(e,"der"),{privateKey:r,publicKey:{data:s}}=t,a=n.convert(s,"raw","hex"),{x:c,y:u}=i.getPoint(a);return{d:r,x:c,y:u}}fromPrivatePKCS8(e){let t=o.normalize("PrivateKeyInfo"),r=o.normalize("ECPrivateKey"),s=t.decode(e,"der"),a=r.decode(s.privateKey,"der"),{privateKey:c,publicKey:{data:u}}=a,l=n.convert(u,"raw","hex"),{x:f,y:p}=i.getPoint(l);return{d:c,x:f,y:p}}fromPublicPKCS8(e){let t=o.normalize("PublicKeyInfo").decode(e,"der"),r=n.convert(t.publicKey.data,"raw","hex");return i.getPoint(r)}fromPrivateBlk(t){let r=e.keyFromPrivate(t,"hex"),o=r.getPublic();return{d:n.convert(r.priv,"bn","raw"),x:n.convert(o.getX(),"bn","raw"),y:n.convert(o.getY(),"bn","raw")}}fromPublicBlk(e){return i.getPoint(e)}fromJwk(e){let{d:t,x:r,y:o}=e;return{d:n.convert(t,"base64url","raw"),x:n.convert(r,"base64url","raw"),y:n.convert(o,"base64url","raw")}}toPrivatePKCS1(e){let{namedCurve:t,keyVersion:r}=this.params,{d:n,x:s,y:a}=e,c=o.normalize("ECPrivateKey"),u=i.makePoint(s,a),l=c.encode({version:r,privateKey:n,parameters:{type:"namedCurve",value:t.split(".")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"EC PRIVATE")}toPrivatePKCS8(e){let{oid:r,algParameters:n,keyVersion:s,infoVersion:a}=this.params,{d:c,x:u,y:l}=e,f=o.normalize("PrivateKeyInfo"),p=o.normalize("ECPrivateKey"),h=i.makePoint(u,l),d=p.encode({version:s,privateKey:c,publicKey:{unused:0,data:h}},"der"),y=f.encode({version:a,algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},privateKey:d},"der").toString("base64");return i.formatPem(y,"PRIVATE")}toPublicPKCS8(e){let{oid:r,algParameters:n}=this.params,{x:s,y:a}=e,c=o.normalize("PublicKeyInfo"),u=i.makePoint(s,a),l=c.encode({algorithm:{algorithm:r.split("."),parameters:t.from(n,"hex")},publicKey:{unused:0,data:u}},"der").toString("base64");return i.formatPem(l,"PUBLIC")}toPrivateBlk(e){return e.d.toString("hex")}toPublicBlk(e){return n.convert(i.makePoint(e.x,e.y),"raw","hex")}toPrivateJwk(e){let{crv:t,kty:r}=this.params,{d:o,x:i,y:s}=e;return{kty:r,crv:t,d:n.convert(o,"raw","base64url"),x:n.convert(i,"raw","base64url"),y:n.convert(s,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:r}=this.params,{x:o,y:i}=e;return{kty:r,crv:t,x:n.convert(o,"raw","base64url"),y:n.convert(i,"raw","base64url")}}static getPoint(e){let t=e.slice(2,(e.length-2)/2+2),r=e.slice((e.length-2)/2+2);return{x:n.convert(t,"hex","raw"),y:n.convert(r,"hex","raw")}}static makePoint(e,r){let n=t.from("04","hex");return t.concat([n,e,r],n.length+e.length+r.length)}}return Ve=i}(),o=function(){if(Je)return Me;Je=1;const e=A(),r=et(),n=tt();class o extends e{fromPrivatePKCS8(e){const t=n.normalize("PrivateKeyInfo").decode(e,"der").privateKey.slice(2);return{d:t,x:this.publicKeyFromPrivate(t)}}fromPublicPKCS8(e){const t=n.normalize("PublicKeyInfo").decode(e,"der");return{x:r.convert(t.publicKey.data,"hex","raw")}}fromJwk(e){let{d:t,x:n}=e;return{d:r.convert(t,"base64url","raw"),x:r.convert(n,"base64url","raw")}}toPrivatePKCS8(e){let{oid:t,infoVersion:r}=this.params,{d:i}=e;const s=n.normalize("PrivateKeyInfo"),a=this.privateKeyPadding(i);let c=s.encode({version:r,algorithm:{algorithm:t.split(".")},privateKey:a},"der").toString("base64");return o.formatPem(c,"PRIVATE")}toPublicPKCS8(e){let{oid:t}=this.params,{x:i}=e,s=n.normalize("PublicKeyInfo").encode({algorithm:{algorithm:t.split(".")},publicKey:{unused:0,data:r.convert(i,"hex","raw")}},"der").toString("base64");return o.formatPem(s,"PUBLIC")}toPrivateJwk(e){let{crv:t,kty:n}=this.params,{d:o,x:i}=e;return{kty:n,crv:t,d:r.convert(o,"raw","base64url"),x:r.convert(i,"raw","base64url")}}toPublicJwk(e){let{crv:t,kty:n}=this.params,{x:o}=e;return{kty:n,crv:t,x:r.convert(o,"raw","base64url")}}privateKeyPadding(e){let r;if("Ed25519"!==this.params.crv)throw new Error(`${this.params.crv} is an invalid curve for EdDSA`);return r=t.from("0420","hex"),t.concat([r,e],r.length+e.length)}publicKeyFromPrivate(e){if("Ed25519"===this.params.crv){const r=new(0,a().eddsa)("ed25519");return t.from(r.keyFromSecret(e).getPublic())}throw new Error(`${this.params.crv} is an invalid curve for EdDSA`)}}return Me=o}(),i=new e;return i.define([{kty:"RSA",oid:"1.2.840.113549.1.1.1",algParameters:"0500",version:"two-prime"}],r),i.define([{kty:"EC",crv:"K-256",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.10",algParameters:"06052b8104000a",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-256",oid:"1.2.840.10045.2.1",namedCurve:"1.2.840.10045.3.1.7",algParameters:"06082a8648ce3d030107",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-384",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.34",algParameters:"06052b81040022",keyVersion:1,infoVersion:"two-prime"},{kty:"EC",crv:"P-521",oid:"1.2.840.10045.2.1",namedCurve:"1.3.132.0.35",algParameters:"06052b81040023",keyVersion:1,infoVersion:"two-prime"}],n),i.define([{kty:"OKP",crv:"Ed25519",oid:"1.3.101.112",infoVersion:"two-prime"}],o),$e=i}var nt,ot,it,st,at,ct,ut=function(){if(Ge)return Ze;Ge=1;const e=S(),r=K(),n=rt(),o=tt(),i=RegExp("\r?\n","g");class s{constructor(t,r){if(!t)throw new e("key is required");if(!r)throw new e("options are required");let{kty:n,format:o,selector:i,crv:s,oid:a}=r;if(!r.kty)throw new e("options.kty is required");if(!r.format)throw new e("options.format is required");if(!r.selector)throw new e("options.selector is required");if(!r.crv&&!r.oid)throw new e("options.crv or options.oid is required");this.kty=n,this.format=o,this.selector=i,this.crv=s,this.oid=a,this.key=this.parseKey(t)}static from(r,a){if(!r)throw new e("key is required");if(!a)throw new e("format is required");if("jwk"===a){let t;if("string"==typeof r)try{t=JSON.parse(r)}catch(t){throw new e("key is not a valid JWK")}else"object"==typeof r&&(t=r);let o,{kty:i,crv:c}=t;if(!i)throw new e("kty is required for JWK");if("EC"===i&&!c)throw new e("crv is required for EC JWK");"RSA"===i&&(o=n.find((e=>e.kty===i)).oid);let u=t.d?"private":"public";return new s(t,{kty:i,crv:c,oid:o,format:a,selector:u})}if("pem"===a){if("string"!=typeof r)throw new e("key is not a valid PEM string");let c=r.split(i),u=c.splice(0,1);c.splice(c.length-1,1);let l,f,p=c.join(""),h=/^-----BEGIN ((RSA|EC) )?(PUBLIC|PRIVATE) KEY-----$/.exec(u),d=h?h[2]:void 0,y=h?h[3]:void 0,b=t.from(p,"base64");if(!y)throw new e("key is not a valid PEM string");if(d){if("RSA"===d)y="PRIVATE"===y?"private_pkcs1":"public_pkcs1",l=n.find((e=>e.kty===d)).oid;else if("EC"===d){let e;if("PRIVATE"===y){y="private_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}else if("PUBLIC"===y){y="public_pkcs1",e=o.normalize(`${d}PrivateKey`).decode(b,"der")}let{parameters:{value:t}}=e;f=n.find((e=>e.namedCurve===t.join("."))).crv}}else{let t,r=o.normalize("PrivateKeyInfo"),i=o.normalize("PublicKeyInfo");"PRIVATE"===y?(y="private_pkcs8",t=r.decode(b,"der")):"PUBLIC"===y&&(y="public_pkcs8",t=i.decode(b,"der"));let{algorithm:{algorithm:s,parameters:a}}=t;s=s.join("."),a=a?a.toString("hex"):void 0;const c=n.find((e=>e.oid===s));if(d=c?c.kty:void 0,!d)throw new e(`${s} is not supported`);"RSA"===d||"OKP"===d?l=s:"EC"===d&&(f=n.find((e=>e.algParameters===a)).crv)}return new s(b,{kty:d,oid:l,crv:f,format:a,selector:y})}if("blk"===a)return new s(r,{kty:"EC",crv:"K-256",format:a,selector:r.length>64?"public":"private"});throw new e(`Invalid format ${a}`)}get alg(){let{kty:e,crv:t,oid:r}=this;if(!this.algorithm){if(t)Object.defineProperty(this,"algorithm",{value:n.normalize(e,"crv",t)});else{if(!r)throw new Error("Both crv and oid are undefined");Object.defineProperty(this,"algorithm",{value:n.normalize(e,"oid",r)})}if(!this.algorithm)throw new Error(`${this.crv||this.oid} is not implemented yet`)}return this.algorithm}parseKey(e){let{alg:t,format:r,selector:n}=this;if("pem"===r)switch(n){case"public_pkcs1":return t.fromPublicPKCS1(e);case"public_pkcs8":return t.fromPublicPKCS8(e);case"private_pkcs1":return t.fromPrivatePKCS1(e);case"private_pkcs8":return t.fromPrivatePKCS8(e);default:throw new Error("Invalid selector value")}if("jwk"===r)return t.fromJwk(e,n);if("blk"===r)switch(n){case"public":return t.fromPublicBlk(e);case"private":return t.fromPrivateBlk(e)}}toJwk(t){let{key:r,alg:n,selector:o}=this;switch(t){case"public":return n.toPublicJwk(r);case"private":if(o.includes("public"))throw new e("Cannot export a private key from a public key");return n.toPrivateJwk(r);default:throw new Error("Invalid key selector")}}toString(t="pem",n="public_pkcs8"){let{key:o,alg:i,selector:s}=this;if("pem"===t)switch(n){case"public_pkcs1":return i.toPublicPKCS1(o);case"public_pkcs8":return i.toPublicPKCS8(o);case"private_pkcs1":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS1(o);case"private_pkcs8":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivatePKCS8(o);default:throw new Error("Invalid key selector")}else if("jwk"===t)switch(n){case"public":return JSON.stringify(i.toPublicJwk(o));case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return JSON.stringify(i.toPrivateJwk(o));default:throw new Error("Invalid key selector")}else if("blk"===t)switch(n){case"private":if(s.includes("public"))throw new e("Cannot export a private key from a public key");return i.toPrivateBlk(o);case"public":return i.toPublicBlk(o);default:throw new Error("Invalid key selector")}throw new r}}return Ze=s}(),lt=e(ut),ft=e(Qe());function pt(){if(st)return it;st=1;const e=new(0,a().ec)("secp256k1"),t=e.curve,r=t.n.constructor;function n(n){const o=n[0];switch(o){case 2:case 3:return 33!==n.length?null:function(n,o){let i=new r(o);if(i.cmp(t.p)>=0)return null;i=i.toRed(t.red);let s=i.redSqr().redIMul(i).redIAdd(t.b).redSqrt();return 3===n!==s.isOdd()&&(s=s.redNeg()),e.keyPair({pub:{x:i,y:s}})}(o,n.subarray(1,33));case 4:case 6:case 7:return 65!==n.length?null:function(n,o,i){let s=new r(o),a=new r(i);if(s.cmp(t.p)>=0||a.cmp(t.p)>=0)return null;if(s=s.toRed(t.red),a=a.toRed(t.red),(6===n||7===n)&&a.isOdd()!==(7===n))return null;const c=s.redSqr().redIMul(s);return a.redSqr().redISub(c.redIAdd(t.b)).isZero()?e.keyPair({pub:{x:s,y:a}}):null}(o,n.subarray(1,33),n.subarray(33,65));default:return null}}function o(e,t){const r=t.encode(null,33===e.length);for(let t=0;t<e.length;++t)e[t]=r[t]}return it={contextRandomize:()=>0,privateKeyVerify(e){const n=new r(e);return n.cmp(t.n)<0&&!n.isZero()?0:1},privateKeyNegate(e){const n=new r(e),o=t.n.sub(n).umod(t.n).toArrayLike(Uint8Array,"be",32);return e.set(o),0},privateKeyTweakAdd(e,n){const o=new r(n);if(o.cmp(t.n)>=0)return 1;if(o.iadd(new r(e)),o.cmp(t.n)>=0&&o.isub(t.n),o.isZero())return 1;const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},privateKeyTweakMul(e,n){let o=new r(n);if(o.cmp(t.n)>=0||o.isZero())return 1;o.imul(new r(e)),o.cmp(t.n)>=0&&(o=o.umod(t.n));const i=o.toArrayLike(Uint8Array,"be",32);return e.set(i),0},publicKeyVerify:e=>null===n(e)?1:0,publicKeyCreate(n,i){const s=new r(i);if(s.cmp(t.n)>=0||s.isZero())return 1;return o(n,e.keyFromPrivate(i).getPublic()),0},publicKeyConvert(e,t){const r=n(t);if(null===r)return 1;return o(e,r.getPublic()),0},publicKeyNegate(e,t){const r=n(t);if(null===r)return 1;const i=r.getPublic();return i.y=i.y.redNeg(),o(e,i),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e<t.length;++e)if(r[e]=n(t[e]),null===r[e])return 1;let i=r[0].getPublic();for(let e=1;e<r.length;++e)i=i.add(r[e].pub);return i.isInfinity()?2:(o(e,i),0)},publicKeyTweakAdd(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0)return 2;const c=a.getPublic().add(t.g.mul(s));return c.isInfinity()?2:(o(e,c),0)},publicKeyTweakMul(e,i,s){const a=n(i);if(null===a)return 1;if((s=new r(s)).cmp(t.n)>=0||s.isZero())return 2;return o(e,a.getPublic().mul(s)),0},signatureNormalize(n){const o=new r(n.subarray(0,32)),i=new r(n.subarray(32,64));return o.cmp(t.n)>=0||i.cmp(t.n)>=0?1:(1===i.cmp(e.nh)&&n.set(t.n.sub(i).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,n){const o=n.subarray(0,32),i=n.subarray(32,64);if(new r(o).cmp(t.n)>=0)return 1;if(new r(i).cmp(t.n)>=0)return 1;const{output:s}=e;let a=s.subarray(4,37);a[0]=0,a.set(o,1);let c=33,u=0;for(;c>1&&0===a[u]&&!(128&a[u+1]);--c,++u);if(a=a.subarray(u),128&a[0])return 1;if(c>1&&0===a[0]&&!(128&a[1]))return 1;let l=s.subarray(39,72);l[0]=0,l.set(i,1);let f=33,p=0;for(;f>1&&0===l[p]&&!(128&l[p+1]);--f,++p);return l=l.subarray(p),128&l[0]||f>1&&0===l[0]&&!(128&l[1])?1:(e.outputlen=6+c+f,s[0]=48,s[1]=e.outputlen-2,s[2]=2,s[3]=a.length,s.set(a,4),s[4+c]=2,s[5+c]=l.length,s.set(l,6+c),0)},signatureImport(e,n){if(n.length<8)return 1;if(n.length>72)return 1;if(48!==n[0])return 1;if(n[1]!==n.length-2)return 1;if(2!==n[2])return 1;const o=n[3];if(0===o)return 1;if(5+o>=n.length)return 1;if(2!==n[4+o])return 1;const i=n[5+o];if(0===i)return 1;if(6+o+i!==n.length)return 1;if(128&n[4])return 1;if(o>1&&0===n[4]&&!(128&n[5]))return 1;if(128&n[o+6])return 1;if(i>1&&0===n[o+6]&&!(128&n[o+7]))return 1;let s=n.subarray(4,4+o);if(33===s.length&&0===s[0]&&(s=s.subarray(1)),s.length>32)return 1;let a=n.subarray(6+o);if(33===a.length&&0===a[0]&&(a=a.slice(1)),a.length>32)throw new Error("S length is too long");let c=new r(s);c.cmp(t.n)>=0&&(c=new r(0));let u=new r(n.subarray(6+o));return u.cmp(t.n)>=0&&(u=new r(0)),e.set(c.toArrayLike(Uint8Array,"be",32),0),e.set(u.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(n,o,i,s,a){if(a){const e=a;a=t=>{const n=e(o,i,null,s,t);if(!(n instanceof Uint8Array&&32===n.length))throw new Error("This is the way");return new r(n)}}const c=new r(i);if(c.cmp(t.n)>=0||c.isZero())return 1;let u;try{u=e.sign(o,i,{canonical:!0,k:a,pers:s})}catch(e){return 1}return n.signature.set(u.r.toArrayLike(Uint8Array,"be",32),0),n.signature.set(u.s.toArrayLike(Uint8Array,"be",32),32),n.recid=u.recoveryParam,0},ecdsaVerify(o,i,s){const a={r:o.subarray(0,32),s:o.subarray(32,64)},c=new r(a.r),u=new r(a.s);if(c.cmp(t.n)>=0||u.cmp(t.n)>=0)return 1;if(1===u.cmp(e.nh)||c.isZero()||u.isZero())return 3;const l=n(s);if(null===l)return 2;const f=l.getPublic();return e.verify(i,a,f)?0:3},ecdsaRecover(n,i,s,a){const c={r:i.slice(0,32),s:i.slice(32,64)},u=new r(c.r),l=new r(c.s);if(u.cmp(t.n)>=0||l.cmp(t.n)>=0)return 1;if(u.isZero()||l.isZero())return 2;let f;try{f=e.recoverPubKey(a,c,s)}catch(e){return 2}return o(n,f),0},ecdh(o,i,s,a,c,u,l){const f=n(i);if(null===f)return 1;const p=new r(s);if(p.cmp(t.n)>=0||p.isZero())return 2;const h=f.getPublic().mul(p);if(void 0===c){const t=h.encode(null,!0),r=e.hash().update(t).digest();for(let e=0;e<32;++e)o[e]=r[e]}else{u||(u=new Uint8Array(32));const e=h.getX().toArray("be",32);for(let t=0;t<32;++t)u[t]=e[t];l||(l=new Uint8Array(32));const t=h.getY().toArray("be",32);for(let e=0;e<32;++e)l[e]=t[e];const r=c(u,l,a);if(!(r instanceof Uint8Array&&r.length===o.length))return 2;o.set(r)}return 0}}}var ht,dt,yt,bt,wt=(ct||(ct=1,at=function(){if(ot)return nt;ot=1;const e="Impossible case. Please create issue.",t="The tweak was out of range or the resulted private key is invalid",r="The tweak was out of range or equal to zero",n="Unknow error on context randomization",o="Private Key is invalid",i="Public Key could not be parsed",s="Public Key serialization error",a="The sum of the public keys is not valid",c="Signature could not be parsed",u="The nonce generation function failed, or the private key was invalid",l="Public key could not be recover",f="Scalar was invalid (zero or overflow)";function p(e,t){if(!e)throw new Error(t)}function h(e,t,r){if(p(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const n=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;p(r.includes(t.length),n)}else{const n=`Expected ${e} to be an Uint8Array with length ${r}`;p(t.length===r,n)}}function d(e){p("Boolean"===b(e),"Expected compressed to be a Boolean")}function y(e=e=>new Uint8Array(e),t){return"function"==typeof e&&(e=e(t)),h("output",e,t),e}function b(e){return Object.prototype.toString.call(e).slice(8,-1)}return nt=w=>({contextRandomize(e){if(p(null===e||e instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==e&&h("seed",e,32),1===w.contextRandomize(e))throw new Error(n)},privateKeyVerify:e=>(h("private key",e,32),0===w.privateKeyVerify(e)),privateKeyNegate(t){switch(h("private key",t,32),w.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(e)}},privateKeyTweakAdd(e,r){switch(h("private key",e,32),h("tweak",r,32),w.privateKeyTweakAdd(e,r)){case 0:return e;case 1:throw new Error(t)}},privateKeyTweakMul(e,t){switch(h("private key",e,32),h("tweak",t,32),w.privateKeyTweakMul(e,t)){case 0:return e;case 1:throw new Error(r)}},publicKeyVerify:e=>(h("public key",e,[33,65]),0===w.publicKeyVerify(e)),publicKeyCreate(e,t=!0,r){switch(h("private key",e,32),d(t),r=y(r,t?33:65),w.publicKeyCreate(r,e)){case 0:return r;case 1:throw new Error(o);case 2:throw new Error(s)}},publicKeyConvert(e,t=!0,r){switch(h("public key",e,[33,65]),d(t),r=y(r,t?33:65),w.publicKeyConvert(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(s)}},publicKeyNegate(t,r=!0,n){switch(h("public key",t,[33,65]),d(r),n=y(n,r?33:65),w.publicKeyNegate(n,t)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(e);case 3:throw new Error(s)}},publicKeyCombine(e,t=!0,r){p(Array.isArray(e),"Expected public keys to be an Array"),p(e.length>0,"Expected public keys array will have more than zero items");for(const t of e)h("public key",t,[33,65]);switch(d(t),r=y(r,t?33:65),w.publicKeyCombine(r,e)){case 0:return r;case 1:throw new Error(i);case 2:throw new Error(a);case 3:throw new Error(s)}},publicKeyTweakAdd(e,r,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",r,32),d(n),o=y(o,n?33:65),w.publicKeyTweakAdd(o,e,r)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(t)}},publicKeyTweakMul(e,t,n=!0,o){switch(h("public key",e,[33,65]),h("tweak",t,32),d(n),o=y(o,n?33:65),w.publicKeyTweakMul(o,e,t)){case 0:return o;case 1:throw new Error(i);case 2:throw new Error(r)}},signatureNormalize(e){switch(h("signature",e,64),w.signatureNormalize(e)){case 0:return e;case 1:throw new Error(c)}},signatureExport(t,r){h("signature",t,64);const n={output:r=y(r,72),outputlen:72};switch(w.signatureExport(n,t)){case 0:return r.slice(0,n.outputlen);case 1:throw new Error(c);case 2:throw new Error(e)}},signatureImport(t,r){switch(h("signature",t),r=y(r,64),w.signatureImport(r,t)){case 0:return r;case 1:throw new Error(c);case 2:throw new Error(e)}},ecdsaSign(t,r,n={},o){h("message",t,32),h("private key",r,32),p("Object"===b(n),"Expected options to be an Object"),void 0!==n.data&&h("options.data",n.data),void 0!==n.noncefn&&p("Function"===b(n.noncefn),"Expected options.noncefn to be a Function");const i={signature:o=y(o,64),recid:null};switch(w.ecdsaSign(i,t,r,n.data,n.noncefn)){case 0:return i;case 1:throw new Error(u);case 2:throw new Error(e)}},ecdsaVerify(e,t,r){switch(h("signature",e,64),h("message",t,32),h("public key",r,[33,65]),w.ecdsaVerify(e,t,r)){case 0:return!0;case 3:return!1;case 1:throw new Error(c);case 2:throw new Error(i)}},ecdsaRecover(t,r,n,o=!0,i){switch(h("signature",t,64),p("Number"===b(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),h("message",n,32),d(o),i=y(i,o?33:65),w.ecdsaRecover(i,t,r,n)){case 0:return i;case 1:throw new Error(c);case 2:throw new Error(l);case 3:throw new Error(e)}},ecdh(e,t,r={},n){switch(h("public key",e,[33,65]),h("private key",t,32),p("Object"===b(r),"Expected options to be an Object"),void 0!==r.data&&h("options.data",r.data),void 0!==r.hashfn?(p("Function"===b(r.hashfn),"Expected options.hashfn to be a Function"),void 0!==r.xbuf&&h("options.xbuf",r.xbuf,32),void 0!==r.ybuf&&h("options.ybuf",r.ybuf,32),h("output",n)):n=y(n,32),w.ecdh(n,e,t,r.data,r.hashfn,r.xbuf,r.ybuf)){case 0:return n;case 1:throw new Error(i);case 2:throw new Error(f)}}}),nt}()(pt())),at),gt=e(wt);function mt(){if(bt)return yt;bt=1;const e=(dt||(dt=1,ht=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var o=e.charAt(n),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=n}var s=e.length,a=e.charAt(0),c=Math.log(s)/Math.log(256),u=Math.log(256)/Math.log(s);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var r=0,n=0,o=0;e[r]===a;)n++,r++;for(var i=(e.length-r)*c+1>>>0,u=new Uint8Array(i);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var f=0,p=i-1;(0!==l||f<o)&&-1!==p;p--,f++)l+=s*u[p]>>>0,u[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=f,r++}for(var h=i-o;h!==i&&0===u[h];)h++;for(var d=new Uint8Array(n+(i-h)),y=n;h!==i;)d[y++]=u[h++];return d}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,o=0,i=t.length;o!==i&&0===t[o];)o++,r++;for(var c=(i-o)*u+1>>>0,l=new Uint8Array(c);o!==i;){for(var f=t[o],p=0,h=c-1;(0!==f||p<n)&&-1!==h;h--,p++)f+=256*l[h]>>>0,l[h]=f%s>>>0,f=f/s>>>0;if(0!==f)throw new Error("Non-zero carry");n=p,o++}for(var d=c-n;d!==c&&0===l[d];)d++;for(var y=a.repeat(r);d<c;++d)y+=e.charAt(l[d]);return y},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+s+" character")}}}),ht);return yt=e("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")}export{mt as a,_ as b,k as c,ft as d,wt as e,lt as k,E as r,gt as s};
|
|
@@ -1,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-B5Vzncdv-C61cS9xX.js";var i,a,s,c,p,u,d,f,l,h,y,m,w,g,v,T,E,x,b,S,L,_,C,M,U,O,R,K,A,D,N,P,V,I,j,k,X=(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,7 +14,7 @@ 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),
|
|
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),z=(a=X)&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a,Y=X.contexts,q=X.constants,$=X.CONTEXT,B=X.CONTEXT_URL,W=X.SECURITY_CONTEXT_V1_URL,F=X.SECURITY_CONTEXT_V2_URL,G=t(Object.freeze({__proto__:null,CONTEXT:$,CONTEXT_URL:B,SECURITY_CONTEXT_V1_URL:W,SECURITY_CONTEXT_V2_URL:F,constants:q,contexts:Y,default:z}));function J(){if(c)return s;c=1;const{constants:e}=G;return s={SECURITY_CONTEXT_URL:e.SECURITY_CONTEXT_V2_URL,SECURITY_CONTEXT_V1_URL:e.SECURITY_CONTEXT_V1_URL,SECURITY_CONTEXT_V2_URL:e.SECURITY_CONTEXT_V2_URL,SECURITY_PROOF_URL:"https://w3id.org/security#proof",SECURITY_SIGNATURE_URL:"https://w3id.org/security#signature"}}
|
|
18
18
|
/*!
|
|
19
19
|
* Copyright (c) 2017-2023 Digital Bazaar, Inc. All rights reserved.
|
|
20
20
|
*/function H(){if(u)return p;u=1;const e=J(),{contexts:t}=G;return p=new Map([[e.SECURITY_CONTEXT_V1_URL,t.get(e.SECURITY_CONTEXT_V1_URL)],[e.SECURITY_CONTEXT_V2_URL,t.get(e.SECURITY_CONTEXT_V2_URL)]])}
|
|
@@ -35,13 +35,13 @@ e.exports={SECURITY_CONTEXT_V1_URL:"https://w3id.org/security/v1",SECURITY_CONTE
|
|
|
35
35
|
*/function ne(){return O?U:(O=1,U=class{constructor({term:e,date:t,maxTimestampDelta:r=1/0}={}){if(void 0===e)throw new Error('"term" is required.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxTimestampDelta" must be a number.');if(this.term=e,void 0!==t&&(this.date=new Date(t),isNaN(this.date)))throw TypeError(`"date" "${t}" is not a valid date.`);this.maxTimestampDelta=r}async validate(e,{expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');try{if(this.maxTimestampDelta!==1/0){const t=(this.date||new Date).getTime(),r=1e3*this.maxTimestampDelta,o=new Date(e.created).getTime();if(!(o>=t-r&&o<=t+r))throw new Error("The proof's created timestamp is out of range.")}return{valid:!0}}catch(e){return{valid:!1,error:e}}}async update(e,{expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e.proofPurpose=this.term,e}async match(e,{expansionMap:t}){if(t)throw new Error('"expansionMap" not supported.');return e.proofPurpose===this.term}})}
|
|
36
36
|
/*!
|
|
37
37
|
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
38
|
-
*/function ie(){if(
|
|
38
|
+
*/function ie(){if(K)return R;K=1;const e=J(),t=n(),r=ne(),o="https://www.w3.org/ns/did/v1",i=["assertionMethod","authentication","capabilityInvocation","capabilityDelegation","keyAgreement","verificationMethod"];return R=class extends r{constructor({term:e,controller:t,date:r,maxTimestampDelta:o=1/0}={}){if(super({term:e,date:r,maxTimestampDelta:o}),void 0!==t){if("object"!=typeof t)throw new TypeError('"controller" must be an object.');this.controller=t}this._termDefinedByDIDContext=i.includes(e)}async validate(r,{verificationMethod:n,documentLoader:i,expansionMap:a}){try{const s=await super.validate(r,{verificationMethod:n,documentLoader:i,expansionMap:a});if(!s.valid)throw s.error;const{id:c}=n,{term:p,_termDefinedByDIDContext:u}=this;if(this.controller)s.controller=this.controller;else{const{controller:r}=n;let a;if(r)if("object"==typeof r)a=r.id;else{if("string"!=typeof r)throw new TypeError('"controller" must be a string representing a URL.');a=r}let{document:d}=await i(a);!(u&&d["@context"]===o||Array.isArray(d["@context"])&&d["@context"][0]===o)&&(d=await t.frame(d,{"@context":e.SECURITY_CONTEXT_URL,id:a,[p]:{"@embed":"@never",id:c}},{documentLoader:i,compactToRelative:!1,safe:!0})),s.controller=d}const d=t.getValues(s.controller,p);if(s.valid=d.some((e=>e===c||"object"==typeof e&&e.id===c)),!s.valid)throw new Error(`Verification method "${n.id}" not authorized by controller for proof purpose "${this.term}".`);return s}catch(e){return{valid:!1,error:e}}}},R}
|
|
39
39
|
/*!
|
|
40
40
|
* Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
|
|
41
|
-
*/function ae(){if(
|
|
41
|
+
*/function ae(){if(D)return A;D=1;const e=ie();return A=class extends e{constructor({term:e="assertionMethod",controller:t,date:r,maxTimestampDelta:o=1/0}={}){super({term:e,controller:t,date:r,maxTimestampDelta:o})}}}
|
|
42
42
|
/*!
|
|
43
43
|
* Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
|
|
44
|
-
*/function se(){if(
|
|
44
|
+
*/function se(){if(P)return N;P=1;const e=ie();return N=class extends e{constructor({term:e="authentication",controller:t,challenge:r,date:o,domain:n,maxTimestampDelta:i=1/0}={}){if(super({term:e,controller:t,date:o,maxTimestampDelta:i}),"string"!=typeof r)throw new TypeError('"challenge" must be a string.');if(void 0!==n&&"string"!=typeof n)throw new TypeError('"domain" must be a string.');this.challenge=r,this.domain=n}async validate(e,{verificationMethod:t,documentLoader:r,expansionMap:o}){try{if(e.challenge!==this.challenge)throw new Error(`The challenge is not as expected; challenge="${e.challenge}", expected="${this.challenge}"`);if(void 0!==this.domain&&e.domain!==this.domain)throw new Error(`The domain is not as expected; domain="${e.domain}", expected="${this.domain}"`);return super.validate(e,{verificationMethod:t,documentLoader:r,expansionMap:o})}catch(e){return{valid:!1,error:e}}}async update(e,{document:t,suite:r,documentLoader:o,expansionMap:n}){return(e=await super.update(e,{document:t,suite:r,documentLoader:o,expansionMap:n})).challenge=this.challenge,void 0!==this.domain&&(e.domain=this.domain),e}},N}
|
|
45
45
|
/*!
|
|
46
46
|
* Copyright (c) 2018 Digital Bazaar, Inc. All rights reserved.
|
|
47
47
|
*/var ce=function(){if(k)return j;k=1;const e={};j=e;const t=J();Object.assign(e,t);const r=ee(),o=function(){if(g)return w;g=1;class e extends Error{constructor(e){super("Verification error(s)."),this.name="VerificationError",this.errors=[].concat(e)}}return w=e}
|