@blockcerts/blockcerts-verifier 1.71.1 → 1.72.1

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.
Files changed (52) hide show
  1. package/.husky/commit-msg +0 -3
  2. package/.husky/pre-commit +0 -3
  3. package/.husky/pre-push +0 -3
  4. package/bundle-stats.html +1 -1
  5. package/coverage/lcov-report/base.css +224 -0
  6. package/coverage/lcov-report/block-navigation.js +87 -0
  7. package/coverage/lcov-report/favicon.png +0 -0
  8. package/coverage/lcov-report/prettify.css +1 -0
  9. package/coverage/lcov-report/prettify.js +2 -0
  10. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  11. package/coverage/lcov-report/sorter.js +210 -0
  12. package/coverage/lcov.info +7034 -0
  13. package/dist/{DataIntegrityProof-elCNKq16-DBDuaDNt.js → DataIntegrityProof-CsicZNrL-BkSRjzkI.js} +1 -1
  14. package/dist/{EcdsaSd2023-B0XPAIp6-K61axvBA.js → EcdsaSd2023-DN9HBdgh-Bc0hVwTd.js} +4 -4
  15. package/dist/EcdsaSecp256k1Signature2019-C3F03t_M-DAJeMTpu.js +1 -0
  16. package/dist/{Ed25519Signature2020-BQsESRnS-TKZI_1AX.js → Ed25519Signature2020-CglkQLKN-CQ6lMzyG.js} +2 -2
  17. package/dist/{EddsaRdfc2022-DQKzWHK4-BILzDBp-.js → EddsaRdfc2022-CfoLi-PP-l7ITLQQT.js} +2 -2
  18. package/dist/{MerkleProof2017-CYM8CJHB-FYpMvld0.js → MerkleProof2017-B_EJmYja-CYd4dJc1.js} +1 -1
  19. package/dist/{MerkleProof2017-MZJbBTpc-Cwfnte6F.js → MerkleProof2017-k2qjvxCH-DrRpsLHG.js} +3 -3
  20. package/dist/{MerkleProof2019-BLrywo8h-Bo9rH2Eq.js → MerkleProof2019-B7t13hOo-D8n9YrUw.js} +1 -1
  21. package/dist/{checkCredentialSchemaConformity-CKNtOu_t-B9iaCRUE.js → checkCredentialSchemaConformity-BiggGGMP-Dx992E4t.js} +1 -1
  22. package/dist/{controlVerificationMethod-B4TgLED0-BGpxLjMq.js → controlVerificationMethod-Bh_-e0Fd-BUCC8ctY.js} +1 -1
  23. package/dist/{did-key-common.esm-BIftA62j-hVrUMxjy.js → did-key-common.esm-BELyYVSE-Cqrpf7cy.js} +3 -3
  24. package/dist/{did-key-ed25519.esm-Drn3Y7PF-CqD0ifNk.js → did-key-ed25519.esm-C3GUddDp-BJdBgNDg.js} +1 -1
  25. package/dist/{did-key-secp256k1.esm-DH-f3o5q-C66E7IxB.js → did-key-secp256k1.esm-D-R266jM-BTxlD5VW.js} +1 -1
  26. package/dist/{ed25519-key-pair.esm-DPOFpdJ2-BrwuS0Ia.js → ed25519-key-pair.esm-DQF2kkXh-XX5BXBcl.js} +3 -3
  27. package/dist/{elliptic-BYqApR8Y-CKp7atgR.js → elliptic-6I21PEnR-CsYseRX1.js} +1 -1
  28. package/dist/{ensureNotRevoked-gui-UMnE-o08xNOvL.js → ensureNotRevoked-DGZuNktg-B4uNuqLX.js} +1 -1
  29. package/dist/index-CK9Z4pAC.js +2 -0
  30. package/dist/{index-BgTFEYQ4-DMaz98iZ.js → index-DXh-XAic-B2gT500V.js} +5 -5
  31. package/dist/{index-lyuTDW_o-nyi7dklX.js → index-fQcSLZgh-DpptYyN8.js} +1 -1
  32. package/dist/{jsonld-signatures-BbILf-Q7-DTp6__ud.js → jsonld-signatures-BbHr1fSN-BSospRuX.js} +5 -5
  33. package/dist/{keyUtils-ExMI0fmg-NVOmd8LH.js → keyUtils-ue8EY3Op-DoHdKWgN.js} +1 -1
  34. package/dist/main.js +45 -45
  35. package/dist/{retrieveVerificationMethodPublicKey-C5Gafl1E-Lv4waRy7.js → retrieveVerificationMethodPublicKey-CLBY4G8P-CagFGnNt.js} +1 -1
  36. package/dist/verifyIssuerProfile-BaiZaU2c-Zcu1X0PY.js +1 -0
  37. package/package.json +9 -10
  38. package/vitest.config.ts +4 -1
  39. package/dist/EcdsaSecp256k1Signature2019-BHgoxmKI-DT2qHZod.js +0 -1
  40. package/dist/index-CEj3k9G6.js +0 -2
  41. package/dist/verifyIssuerProfile-DCJyz3ho-BwuCK9F3.js +0 -1
  42. /package/dist/{HashlinkVerifier-BsVlaml5-B4Niv2-b.js → HashlinkVerifier-CTG-OS14-B4Niv2-b.js} +0 -0
  43. /package/dist/{checkRevocationStatusList2021-CMAVXAVE-BEBD8TO8.js → checkRevocationStatusList2021-BDBFhnz6-BEBD8TO8.js} +0 -0
  44. /package/dist/{elliptic-4aZS_cwf-BpaNaVm0.js → elliptic-mDX7fQQx-BpaNaVm0.js} +0 -0
  45. /package/dist/{ensureNotRevoked-hGps0prO-DvMIgM4L.js → ensureNotRevoked-Dc6VA2bO-DvMIgM4L.js} +0 -0
  46. /package/dist/{ensureValidIssuingKey-BMVCi2T2-BdV46XBb.js → ensureValidIssuingKey-wTUvNuDH-BdV46XBb.js} +0 -0
  47. /package/dist/{index-CQYVZlSE-C0eXpZGn.js → index-BrurC4Vt-C0eXpZGn.js} +0 -0
  48. /package/dist/{index-BS134367-Dgus2xdV.js → index-Gr4i_Ned-Dgus2xdV.js} +0 -0
  49. /package/dist/{jsonld-B_Q2jvnp-BJ5uVeOU.js → jsonld-BAMY2WqE-BJ5uVeOU.js} +0 -0
  50. /package/dist/{sha256-u2xsd4MQ-C1PUWFZm.js → sha256-Bwge_vjI-C1PUWFZm.js} +0 -0
  51. /package/dist/{webcrypto.es-DpqeDikX-BnVhHKeM.js → webcrypto.es-DptGOl2T-BnVhHKeM.js} +0 -0
  52. /package/dist/{x25519-Kp6t9B5a-Dh8L0KYb.js → x25519-hG3WOzPe-Dh8L0KYb.js} +0 -0
@@ -1,4 +1,4 @@
1
- import{r as t,j as e}from"./jsonld-signatures-BbILf-Q7-DTp6__ud.js";import{e as r,d as o}from"./index-DZLKRa_V-D_IQzjvG.js";import{d as i}from"./base64url-Cy03LJLt-vkTPfQOh.js";var n=t();
1
+ import{r as t,j as e}from"./jsonld-signatures-BbHr1fSN-BSospRuX.js";import{e as r,d as o}from"./index-DZLKRa_V-D_IQzjvG.js";import{d as i}from"./base64url-Cy03LJLt-vkTPfQOh.js";var n=t();
2
2
  /*!
3
3
  * Copyright (c) 2022-2023 Digital Bazaar, Inc. All rights reserved.
4
4
  */const a=new RegExp("-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](.[0-9]+)?|(24:00:00(.0+)?))(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?"),s=t=>a.test(t),c=self&&(self.crypto||self.msCrypto);async function u({string:t}){const e=(new TextEncoder).encode(t);return new Uint8Array(await c.subtle.digest("SHA-256",e))}
@@ -1,4 +1,4 @@
1
- import{d as e,f as t,V as n}from"./main.js";import{j as r}from"./jsonld-signatures-BbILf-Q7-DTp6__ud.js";import{j as o}from"./jsonld-B_Q2jvnp-BJ5uVeOU.js";import{D as i,r as a}from"./DataIntegrityProof-elCNKq16-DBDuaDNt.js";import{d as s,e as u}from"./base64url-Cy03LJLt-vkTPfQOh.js";import{f as c}from"./index-BgTFEYQ4-DMaz98iZ.js";import{e as f}from"./index-DZLKRa_V-D_IQzjvG.js";import{S as l}from"./Suite-BmP2Qu19-D1ucdMDB.js";import"./pako.esm-BGRKTPxS-UdHShO7y.js";import"./sha256-u2xsd4MQ-C1PUWFZm.js";import"./index-BS134367-Dgus2xdV.js";import{r as d}from"./retrieveVerificationMethodPublicKey-C5Gafl1E-Lv4waRy7.js";import"./elliptic-4aZS_cwf-BpaNaVm0.js";
1
+ import{d as e,f as t,V as n}from"./main.js";import{j as r}from"./jsonld-signatures-BbHr1fSN-BSospRuX.js";import{j as o}from"./jsonld-BAMY2WqE-BJ5uVeOU.js";import{D as i,r as a}from"./DataIntegrityProof-CsicZNrL-BkSRjzkI.js";import{d as s,e as u}from"./base64url-Cy03LJLt-vkTPfQOh.js";import{f as c}from"./index-DXh-XAic-B2gT500V.js";import{e as f}from"./index-DZLKRa_V-D_IQzjvG.js";import{S as l}from"./Suite-BmP2Qu19-D1ucdMDB.js";import"./pako.esm-BGRKTPxS-UdHShO7y.js";import"./sha256-Bwge_vjI-C1PUWFZm.js";import"./index-Gr4i_Ned-Dgus2xdV.js";import{r as d}from"./retrieveVerificationMethodPublicKey-CLBY4G8P-CagFGnNt.js";import"./elliptic-mDX7fQQx-BpaNaVm0.js";
2
2
  /*!
3
3
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
4
4
  */
@@ -14,10 +14,10 @@ const h=globalThis.crypto;
14
14
  */async function g({document:e,labelMapFactoryFunction:t,options:n}={}){const{nquads:r}=await async function({document:e,nquads:t,labelMapFactoryFunction:n,options:r}={}){let o,i=new Map;o=e?await m(e,{...r,canonicalIdMap:i}):await m(t.join(""),{...r,inputFormat:"application/n-quads",canonicalIdMap:i});i=function(e){let t=!1,n=!1,r=!1;const o=new Map;for(const[i,a]of e){if(!t&&(t=!0,n=i.startsWith("_:"),r=a.startsWith("_:"),!n&&!r))return e;o.set(n?i.slice(2):i,r?a.slice(2):a)}return o}(i);const a=await n({canonicalIdMap:i}),s=new Map;for(const[e,t]of a)s.set(i.get(e),t);const u=(e,t,n)=>"_:"+s.get(n);return{nquads:o.split("\n").slice(0,-1).map((e=>e.replace(/(_:([^\s]+))/g,u)+"\n")).sort(),labelMap:a}}
15
15
  /*!
16
16
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
17
- */({document:e,labelMapFactoryFunction:t,options:n});return r}async function m(e,t){if(!t||"object"!=typeof t)throw new TypeError('"options" must be an object.');if(t={algorithm:"RDFC-1.0",format:"application/n-quads",base:null,safe:!0,...t},"string"!=typeof e){const n={rdfDirection:"i18n-datatype",...t,produceGeneralizedRdf:!1};delete n.format,e=await o.toRDF(e,n)}return a.canonize(e,t)}async function b({document:e,proof:t,options:n,hasher:r}={}){r||(r=p());const o=await async function({document:e,proof:t,options:n}={}){return delete(t={"@context":e["@context"],...t}).proofValue,m(t,n)}({document:e,proof:t,options:n});return r.hash(w(o))}const v=["string","number","bigint","symbol"],E=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function M(e){if(null===e)return"null";if(void 0===e)return"undefined";if(!0===e||!1===e)return"boolean";const t=typeof e;if(v.includes(t))return t;if("function"===t)return"Function";if(Array.isArray(e))return"Array";if(function(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}(e))return"Buffer";const n=function(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(E.includes(t))return t;return}(e);return n||"Object"}class ${constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}}$.uint=new $(0,"uint",!0),$.negint=new $(1,"negint",!0),$.bytes=new $(2,"bytes",!0),$.string=new $(3,"string",!0),$.array=new $(4,"array",!1),$.map=new $(5,"map",!1),$.tag=new $(6,"tag",!1),$.float=new $(7,"float",!0),$.false=new $(7,"false",!0),$.true=new $(7,"true",!0),$.null=new $(7,"null",!0),$.undefined=new $(7,"undefined",!0),$.break=new $(7,"break",!0);class A{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}}const S=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer,T=new TextDecoder,k=new TextEncoder;function j(e){return S&&globalThis.Buffer.isBuffer(e)}const I=S?(e,t,n)=>n-t>64?globalThis.Buffer.from(e.subarray(t,n)).toString("utf8"):x(e,t,n):(e,t,n)=>n-t>64?T.decode(e.subarray(t,n)):x(e,t,n),V=S?e=>e.length>64?globalThis.Buffer.from(e):U(e):e=>e.length>64?k.encode(e):U(e),B=S?(e,t,n)=>j(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n);function U(e){const t=[];let n=0;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);o<128?t[n++]=o:o<2048?(t[n++]=o>>6|192,t[n++]=63&o|128):55296==(64512&o)&&r+1<e.length&&56320==(64512&e.charCodeAt(r+1))?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++r)),t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=63&o|128):(t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=63&o|128)}return t}function x(e,t,n){const r=[];for(;t<n;){const o=e[t];let i=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=n){let n,r,s,u;switch(a){case 1:o<128&&(i=o);break;case 2:n=e[t+1],128==(192&n)&&(u=(31&o)<<6|63&n,u>127&&(i=u));break;case 3:n=e[t+1],r=e[t+2],128==(192&n)&&128==(192&r)&&(u=(15&o)<<12|(63&n)<<6|63&r,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:n=e[t+1],r=e[t+2],s=e[t+3],128==(192&n)&&128==(192&r)&&128==(192&s)&&(u=(15&o)<<18|(63&n)<<12|(63&r)<<6|63&s,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i),t+=a}return function(e){const t=e.length;if(t<=N)return String.fromCharCode.apply(String,e);let n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=N));return n}(r)}const N=4096;const P="CBOR decode error:",D="CBOR encode error:";function K(e,t,n){if(e.length-t<n)throw new Error(`${P} not enough data for type`)}const F=[24,256,65536,4294967296,BigInt("18446744073709551616")];function C(e,t,n){K(e,t,1);const r=e[t];if(!0===n.strict&&r<F[0])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return r}function z(e,t,n){K(e,t,2);const r=e[t]<<8|e[t+1];if(!0===n.strict&&r<F[1])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return r}function H(e,t,n){K(e,t,4);const r=16777216*e[t]+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(!0===n.strict&&r<F[2])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return r}function O(e,t,n){K(e,t,8);const r=16777216*e[t]+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=16777216*e[t+4]+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(r)<<BigInt(32))+BigInt(o);if(!0===n.strict&&i<F[3])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(!0===n.allowBigInt)return i;throw new Error(`${P} integers outside of the safe integer range are not supported`)}function _(e,t){return L(e,0,t.value)}function L(e,t,n){if(n<F[0]){const r=Number(n);e.push([t|r])}else if(n<F[1]){const r=Number(n);e.push([24|t,r])}else if(n<F[2]){const r=Number(n);e.push([25|t,r>>>8,255&r])}else if(n<F[3]){const r=Number(n);e.push([26|t,r>>>24&255,r>>>16&255,r>>>8&255,255&r])}else{const r=BigInt(n);if(!(r<F[4]))throw new Error(`${P} encountered BigInt larger than allowable range`);{const n=[27|t,0,0,0,0,0,0,0];let o=Number(r&BigInt(4294967295)),i=Number(r>>BigInt(32)&BigInt(4294967295));n[8]=255&o,o>>=8,n[7]=255&o,o>>=8,n[6]=255&o,o>>=8,n[5]=255&o,n[4]=255&i,i>>=8,n[3]=255&i,i>>=8,n[2]=255&i,i>>=8,n[1]=255&i,e.push(n)}}}_.encodedSize=function(e){return L.encodedSize(e.value)},L.encodedSize=function(e){return e<F[0]?1:e<F[1]?2:e<F[2]?3:e<F[3]?5:9},_.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};const R=BigInt(-1),G=BigInt(1);function q(e,t){const n=t.value,r="bigint"==typeof n?n*R-G:-1*n-1;L(e,t.type.majorEncoded,r)}function Q(e,t,n,r){K(e,t,n+r);const o=B(e,t+n,t+n+r);return new A($.bytes,o,n+r)}function W(e,t,n,r){return Q(e,t,1,n)}function J(e){return void 0===e.encodedBytes&&(e.encodedBytes=e.type===$.string?V(e.value):e.value),e.encodedBytes}function Z(e,t){const n=J(t);L(e,t.type.majorEncoded,n.length),e.push(n)}function X(e,t,n,r,o){const i=n+r;K(e,t,i);const a=new A($.string,I(e,t+n,t+i),i);return!0===o.retainStringBytes&&(a.byteValue=B(e,t+n,t+i)),a}function Y(e,t,n,r){return X(e,t,1,n,r)}q.encodedSize=function(e){const t=e.value,n="bigint"==typeof t?t*R-G:-1*t-1;return n<F[0]?1:n<F[1]?2:n<F[2]?3:n<F[3]?5:9},q.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0},Z.encodedSize=function(e){const t=J(e);return L.encodedSize(t.length)+t.length},Z.compareTokens=function(e,t){return n=J(e),r=J(t),n.length<r.length?-1:n.length>r.length?1:function(e,t){if(j(e)&&j(t))return e.compare(t);for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return 0}(n,r);var n,r};const ee=Z;function te(e,t,n,r){return new A($.array,r,n)}function ne(e,t,n,r){return te(0,0,1,n)}function re(e,t){L(e,$.array.majorEncoded,t.value)}function oe(e,t,n,r){return new A($.map,r,n)}function ie(e,t,n,r){return oe(0,0,1,n)}function ae(e,t){L(e,$.map.majorEncoded,t.value)}function se(e,t,n,r){return new A($.tag,n,1)}function ue(e,t){L(e,$.tag.majorEncoded,t.value)}re.compareTokens=_.compareTokens,re.encodedSize=function(e){return L.encodedSize(e.value)},ae.compareTokens=_.compareTokens,ae.encodedSize=function(e){return L.encodedSize(e.value)},ue.compareTokens=_.compareTokens,ue.encodedSize=function(e){return L.encodedSize(e.value)};function ce(e,t,n){if(n){if(!1===n.allowNaN&&Number.isNaN(e))throw new Error(`${P} NaN values are not supported`);if(!1===n.allowInfinity&&(e===1/0||e===-1/0))throw new Error(`${P} Infinity values are not supported`)}return new A($.float,e,t)}function fe(e,t,n){const r=t.value;if(!1===r)e.push([20|$.float.majorEncoded]);else if(!0===r)e.push([21|$.float.majorEncoded]);else if(null===r)e.push([22|$.float.majorEncoded]);else if(void 0===r)e.push([23|$.float.majorEncoded]);else{let t,i=!1;n&&!0===n.float64||(pe(r),t=ye(he,1),r===t||Number.isNaN(r)?(he[0]=249,e.push(he.slice(0,3)),i=!0):(we(r),t=ge(he,1),r===t&&(he[0]=250,e.push(he.slice(0,5)),i=!0))),i||(o=r,de.setFloat64(0,o,!1),t=me(he,1),he[0]=251,e.push(he.slice(0,9)))}var o}fe.encodedSize=function(e,t){const n=e.value;if(!1===n||!0===n||null==n)return 1;if(!t||!0!==t.float64){pe(n);let e=ye(he,1);if(n===e||Number.isNaN(n))return 3;if(we(n),e=ge(he,1),n===e)return 5}return 9};const le=new ArrayBuffer(9),de=new DataView(le,1),he=new Uint8Array(le,0);function pe(e){if(e===1/0)de.setUint16(0,31744,!1);else if(e===-1/0)de.setUint16(0,64512,!1);else if(Number.isNaN(e))de.setUint16(0,32256,!1);else{de.setFloat32(0,e);const t=de.getUint32(0),n=(2139095040&t)>>23,r=8388607&t;if(255===n)de.setUint16(0,31744,!1);else if(0===n)de.setUint16(0,(2147483648&e)>>16|r>>13,!1);else{const e=n-127;e<-24?de.setUint16(0,0):e<-14?de.setUint16(0,(2147483648&t)>>16|1<<24+e,!1):de.setUint16(0,(2147483648&t)>>16|e+15<<10|r>>13,!1)}}}function ye(e,t){if(e.length-t<2)throw new Error(`${P} not enough data for float16`);const n=(e[t]<<8)+e[t+1];if(31744===n)return 1/0;if(64512===n)return-1/0;if(32256===n)return NaN;const r=n>>10&31,o=1023&n;let i;return i=0===r?o*2**-24:31!==r?(o+1024)*2**(r-25):0===o?1/0:NaN,32768&n?-i:i}function we(e){de.setFloat32(0,e,!1)}function ge(e,t){if(e.length-t<4)throw new Error(`${P} not enough data for float32`);const n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function me(e,t){if(e.length-t<8)throw new Error(`${P} not enough data for float64`);const n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}function be(e,t,n){throw new Error(`${P} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function ve(e){return()=>{throw new Error(`${P} ${e}`)}}fe.compareTokens=_.compareTokens;const Ee=[];for(let e=0;e<=23;e++)Ee[e]=be;Ee[24]=function(e,t,n,r){return new A($.uint,C(e,t+1,r),2)},Ee[25]=function(e,t,n,r){return new A($.uint,z(e,t+1,r),3)},Ee[26]=function(e,t,n,r){return new A($.uint,H(e,t+1,r),5)},Ee[27]=function(e,t,n,r){return new A($.uint,O(e,t+1,r),9)},Ee[28]=be,Ee[29]=be,Ee[30]=be,Ee[31]=be;for(let e=32;e<=55;e++)Ee[e]=be;Ee[56]=function(e,t,n,r){return new A($.negint,-1-C(e,t+1,r),2)},Ee[57]=function(e,t,n,r){return new A($.negint,-1-z(e,t+1,r),3)},Ee[58]=function(e,t,n,r){return new A($.negint,-1-H(e,t+1,r),5)},Ee[59]=function(e,t,n,r){const o=O(e,t+1,r);if("bigint"!=typeof o){const e=-1-o;if(e>=Number.MIN_SAFE_INTEGER)return new A($.negint,e,9)}if(!0!==r.allowBigInt)throw new Error(`${P} integers outside of the safe integer range are not supported`);return new A($.negint,R-BigInt(o),9)},Ee[60]=be,Ee[61]=be,Ee[62]=be,Ee[63]=be;for(let e=64;e<=87;e++)Ee[e]=W;Ee[88]=function(e,t,n,r){return Q(e,t,2,C(e,t+1,r))},Ee[89]=function(e,t,n,r){return Q(e,t,3,z(e,t+1,r))},Ee[90]=function(e,t,n,r){return Q(e,t,5,H(e,t+1,r))},Ee[91]=function(e,t,n,r){const o=O(e,t+1,r);if("bigint"==typeof o)throw new Error(`${P} 64-bit integer bytes lengths not supported`);return Q(e,t,9,o)},Ee[92]=be,Ee[93]=be,Ee[94]=be,Ee[95]=ve("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)Ee[e]=Y;Ee[120]=function(e,t,n,r){return X(e,t,2,C(e,t+1,r),r)},Ee[121]=function(e,t,n,r){return X(e,t,3,z(e,t+1,r),r)},Ee[122]=function(e,t,n,r){return X(e,t,5,H(e,t+1,r),r)},Ee[123]=function(e,t,n,r){const o=O(e,t+1,r);if("bigint"==typeof o)throw new Error(`${P} 64-bit integer string lengths not supported`);return X(e,t,9,o,r)},Ee[124]=be,Ee[125]=be,Ee[126]=be,Ee[127]=ve("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)Ee[e]=ne;Ee[152]=function(e,t,n,r){return te(0,0,2,C(e,t+1,r))},Ee[153]=function(e,t,n,r){return te(0,0,3,z(e,t+1,r))},Ee[154]=function(e,t,n,r){return te(0,0,5,H(e,t+1,r))},Ee[155]=function(e,t,n,r){const o=O(e,t+1,r);if("bigint"==typeof o)throw new Error(`${P} 64-bit integer array lengths not supported`);return te(0,0,9,o)},Ee[156]=be,Ee[157]=be,Ee[158]=be,Ee[159]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${P} indefinite length items not allowed`);return te(0,0,1,1/0)};for(let e=160;e<=183;e++)Ee[e]=ie;Ee[184]=function(e,t,n,r){return oe(0,0,2,C(e,t+1,r))},Ee[185]=function(e,t,n,r){return oe(0,0,3,z(e,t+1,r))},Ee[186]=function(e,t,n,r){return oe(0,0,5,H(e,t+1,r))},Ee[187]=function(e,t,n,r){const o=O(e,t+1,r);if("bigint"==typeof o)throw new Error(`${P} 64-bit integer map lengths not supported`);return oe(0,0,9,o)},Ee[188]=be,Ee[189]=be,Ee[190]=be,Ee[191]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${P} indefinite length items not allowed`);return oe(0,0,1,1/0)};for(let e=192;e<=215;e++)Ee[e]=se;Ee[216]=function(e,t,n,r){return new A($.tag,C(e,t+1,r),2)},Ee[217]=function(e,t,n,r){return new A($.tag,z(e,t+1,r),3)},Ee[218]=function(e,t,n,r){return new A($.tag,H(e,t+1,r),5)},Ee[219]=function(e,t,n,r){return new A($.tag,O(e,t+1,r),9)},Ee[220]=be,Ee[221]=be,Ee[222]=be,Ee[223]=be;for(let e=224;e<=243;e++)Ee[e]=ve("simple values are not supported");Ee[244]=be,Ee[245]=be,Ee[246]=be,Ee[247]=function(e,t,n,r){if(!1===r.allowUndefined)throw new Error(`${P} undefined values are not supported`);return!0===r.coerceUndefinedToNull?new A($.null,null,1):new A($.undefined,void 0,1)},Ee[248]=ve("simple values are not supported"),Ee[249]=function(e,t,n,r){return ce(ye(e,t+1),3,r)},Ee[250]=function(e,t,n,r){return ce(ge(e,t+1),5,r)},Ee[251]=function(e,t,n,r){return ce(me(e,t+1),9,r)},Ee[252]=be,Ee[253]=be,Ee[254]=be,Ee[255]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${P} indefinite length items not allowed`);return new A($.break,void 0,1)};const Me=[];for(let e=0;e<24;e++)Me[e]=new A($.uint,e,1);for(let e=-1;e>=-24;e--)Me[31-e]=new A($.negint,e,1);Me[64]=new A($.bytes,new Uint8Array(0),1),Me[96]=new A($.string,"",1),Me[128]=new A($.array,0,1),Me[160]=new A($.map,0,1),Me[244]=new A($.false,!1,1),Me[245]=new A($.true,!0,1),Me[246]=new A($.null,null,1),function(){const e=[];e[$.uint.major]=_,e[$.negint.major]=q,e[$.bytes.major]=Z,e[$.string.major]=ee,e[$.array.major]=re,e[$.map.major]=ae,e[$.tag.major]=ue,e[$.float.major]=fe}();class $e{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do{if(t.obj===e)return!0}while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${D} object contains circular references`);return new $e(t,e)}}const Ae={null:new A($.null,null),undefined:new A($.undefined,void 0),true:new A($.true,!0),false:new A($.false,!1),emptyArray:new A($.array,0),emptyMap:new A($.map,0)},Se={number:(e,t,n,r)=>Number.isInteger(e)&&Number.isSafeInteger(e)?new A(e>=0?$.uint:$.negint,e):new A($.float,e),bigint:(e,t,n,r)=>e>=BigInt(0)?new A($.uint,e):new A($.negint,e),Uint8Array:(e,t,n,r)=>new A($.bytes,e),string:(e,t,n,r)=>new A($.string,e),boolean:(e,t,n,r)=>e?Ae.true:Ae.false,null:(e,t,n,r)=>Ae.null,undefined:(e,t,n,r)=>Ae.undefined,ArrayBuffer:(e,t,n,r)=>new A($.bytes,new Uint8Array(e)),DataView:(e,t,n,r)=>new A($.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Array(e,t,n,r){if(!e.length)return!0===n.addBreakTokens?[Ae.emptyArray,new A($.break)]:Ae.emptyArray;r=$e.createCheck(r,e);const o=[];let i=0;for(const t of e)o[i++]=Te(t,n,r);return n.addBreakTokens?[new A($.array,e.length),o,new A($.break)]:[new A($.array,e.length),o]},Object(e,t,n,r){const o="Object"!==t,i=o?e.keys():Object.keys(e),a=o?e.size:i.length;if(!a)return!0===n.addBreakTokens?[Ae.emptyMap,new A($.break)]:Ae.emptyMap;r=$e.createCheck(r,e);const s=[];let u=0;for(const t of i)s[u++]=[Te(t,n,r),Te(o?e.get(t):e[t],n,r)];return function(e,t){t.mapSorter&&e.sort(t.mapSorter)}(s,n),n.addBreakTokens?[new A($.map,a),s,new A($.break)]:[new A($.map,a),s]}};Se.Map=Se.Object,Se.Buffer=Se.Uint8Array;for(const e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Se[`${e}Array`]=Se.DataView;function Te(e,t={},n){const r=M(e),o=t&&t.typeEncoders&&t.typeEncoders[r]||Se[r];if("function"==typeof o){const i=o(e,r,t,n);if(null!=i)return i}const i=Se[r];if(!i)throw new Error(`${D} unsupported type: ${r}`);return i(e,r,t,n)}const ke={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};class je{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){const e=this.data[this._pos];let t=Me[e];if(void 0===t){const n=Ee[e];if(!n)throw new Error(`${P} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);const r=31&e;t=n(this.data,this._pos,r,this.options)}return this._pos+=t.encodedLength,t}}const Ie=Symbol.for("DONE"),Ve=Symbol.for("BREAK");function Be(e,t){if(e.done())return Ie;const n=e.next();if(n.type===$.break)return Ve;if(n.type.terminal)return n.value;if(n.type===$.array)return function(e,t,n){const r=[];for(let o=0;o<e.value;o++){const i=Be(t,n);if(i===Ve){if(e.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed array`)}if(i===Ie)throw new Error(`${P} found array but not enough entries (got ${o}, expected ${e.value})`);r[o]=i}return r}(n,e,t);if(n.type===$.map)return function(e,t,n){const r=!0===n.useMaps,o=r?void 0:{},i=r?new Map:void 0;for(let a=0;a<e.value;a++){const s=Be(t,n);if(s===Ve){if(e.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed map`)}if(s===Ie)throw new Error(`${P} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!0!==r&&"string"!=typeof s)throw new Error(`${P} non-string keys not supported (got ${typeof s})`);if(!0===n.rejectDuplicateMapKeys&&(r&&i.has(s)||!r&&s in o))throw new Error(`${P} found repeat map key "${s}"`);const u=Be(t,n);if(u===Ie)throw new Error(`${P} found map but not enough entries (got ${a} [no value], expected ${e.value})`);r?i.set(s,u):o[s]=u}return r?i:o}(n,e,t);if(n.type===$.tag){if(t.tags&&"function"==typeof t.tags[n.value]){const r=Be(e,t);return t.tags[n.value](r)}throw new Error(`${P} tag not supported (${n.value})`)}throw new Error("unsupported")}function Ue(e,t){const[n,r]=function(e,t){if(!(e instanceof Uint8Array))throw new Error(`${P} data to decode must be a Uint8Array`);const n=(t=Object.assign({},ke,t)).tokenizer||new je(e,t),r=Be(n,t);if(r===Ie)throw new Error(`${P} did not find any content to decode`);if(r===Ve)throw new Error(`${P} got unexpected break`);return[r,e.subarray(n.pos())]}(e,t);if(r.length>0)throw new Error(`${P} too many terminals, data makes no sense`);return n}
17
+ */({document:e,labelMapFactoryFunction:t,options:n});return r}async function m(e,t){if(!t||"object"!=typeof t)throw new TypeError('"options" must be an object.');if(t={algorithm:"RDFC-1.0",format:"application/n-quads",base:null,safe:!0,...t},"string"!=typeof e){const n={rdfDirection:"i18n-datatype",...t,produceGeneralizedRdf:!1};delete n.format,e=await o.toRDF(e,n)}return a.canonize(e,t)}async function b({document:e,proof:t,options:n,hasher:r}={}){r||(r=p());const o=await async function({document:e,proof:t,options:n}={}){return delete(t={"@context":e["@context"],...t}).proofValue,m(t,n)}({document:e,proof:t,options:n});return r.hash(w(o))}const v=["string","number","bigint","symbol"],E=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","HTMLElement","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];function M(e){if(null===e)return"null";if(void 0===e)return"undefined";if(!0===e||!1===e)return"boolean";const t=typeof e;if(v.includes(t))return t;if("function"===t)return"Function";if(Array.isArray(e))return"Array";if(function(e){return e&&e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer.call(null,e)}(e))return"Buffer";const n=function(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(E.includes(t))return t;return}(e);return n||"Object"}class ${constructor(e,t,n){this.major=e,this.majorEncoded=e<<5,this.name=t,this.terminal=n}toString(){return`Type[${this.major}].${this.name}`}compare(e){return this.major<e.major?-1:this.major>e.major?1:0}}$.uint=new $(0,"uint",!0),$.negint=new $(1,"negint",!0),$.bytes=new $(2,"bytes",!0),$.string=new $(3,"string",!0),$.array=new $(4,"array",!1),$.map=new $(5,"map",!1),$.tag=new $(6,"tag",!1),$.float=new $(7,"float",!0),$.false=new $(7,"false",!0),$.true=new $(7,"true",!0),$.null=new $(7,"null",!0),$.undefined=new $(7,"undefined",!0),$.break=new $(7,"break",!0);class A{constructor(e,t,n){this.type=e,this.value=t,this.encodedLength=n,this.encodedBytes=void 0,this.byteValue=void 0}toString(){return`Token[${this.type}].${this.value}`}}const S=globalThis.process&&!globalThis.process.browser&&globalThis.Buffer&&"function"==typeof globalThis.Buffer.isBuffer,k=new TextDecoder,T=new TextEncoder;function j(e){return S&&globalThis.Buffer.isBuffer(e)}const I=S?(e,t,n)=>n-t>64?globalThis.Buffer.from(e.subarray(t,n)).toString("utf8"):N(e,t,n):(e,t,n)=>n-t>64?k.decode(e.subarray(t,n)):N(e,t,n),V=S?e=>e.length>64?globalThis.Buffer.from(e):U(e):e=>e.length>64?T.encode(e):U(e),B=S?(e,t,n)=>j(e)?new Uint8Array(e.subarray(t,n)):e.slice(t,n):(e,t,n)=>e.slice(t,n);function U(e){const t=[];let n=0;for(let r=0;r<e.length;r++){let o=e.charCodeAt(r);o<128?t[n++]=o:o<2048?(t[n++]=o>>6|192,t[n++]=63&o|128):55296==(64512&o)&&r+1<e.length&&56320==(64512&e.charCodeAt(r+1))?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++r)),t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=63&o|128):(t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=63&o|128)}return t}function N(e,t,n){const r=[];for(;t<n;){const o=e[t];let i=null,a=o>239?4:o>223?3:o>191?2:1;if(t+a<=n){let n,r,s,u;switch(a){case 1:o<128&&(i=o);break;case 2:n=e[t+1],128==(192&n)&&(u=(31&o)<<6|63&n,u>127&&(i=u));break;case 3:n=e[t+1],r=e[t+2],128==(192&n)&&128==(192&r)&&(u=(15&o)<<12|(63&n)<<6|63&r,u>2047&&(u<55296||u>57343)&&(i=u));break;case 4:n=e[t+1],r=e[t+2],s=e[t+3],128==(192&n)&&128==(192&r)&&128==(192&s)&&(u=(15&o)<<18|(63&n)<<12|(63&r)<<6|63&s,u>65535&&u<1114112&&(i=u))}}null===i?(i=65533,a=1):i>65535&&(i-=65536,r.push(i>>>10&1023|55296),i=56320|1023&i),r.push(i),t+=a}return function(e){const t=e.length;if(t<=x)return String.fromCharCode.apply(String,e);let n="",r=0;for(;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=x));return n}(r)}const x=4096;const P="CBOR decode error:",D="CBOR encode error:";function K(e,t,n){if(e.length-t<n)throw new Error(`${P} not enough data for type`)}const F=[24,256,65536,4294967296,BigInt("18446744073709551616")];function C(e,t,n){K(e,t,1);const r=e[t];if(!0===n.strict&&r<F[0])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return r}function H(e,t,n){K(e,t,2);const r=e[t]<<8|e[t+1];if(!0===n.strict&&r<F[1])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return r}function z(e,t,n){K(e,t,4);const r=16777216*e[t]+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3];if(!0===n.strict&&r<F[2])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);return r}function L(e,t,n){K(e,t,8);const r=16777216*e[t]+(e[t+1]<<16)+(e[t+2]<<8)+e[t+3],o=16777216*e[t+4]+(e[t+5]<<16)+(e[t+6]<<8)+e[t+7],i=(BigInt(r)<<BigInt(32))+BigInt(o);if(!0===n.strict&&i<F[3])throw new Error(`${P} integer encoded in more bytes than necessary (strict decode)`);if(i<=Number.MAX_SAFE_INTEGER)return Number(i);if(!0===n.allowBigInt)return i;throw new Error(`${P} integers outside of the safe integer range are not supported`)}function O(e,t){return _(e,0,t.value)}function _(e,t,n){if(n<F[0]){const r=Number(n);e.push([t|r])}else if(n<F[1]){const r=Number(n);e.push([24|t,r])}else if(n<F[2]){const r=Number(n);e.push([25|t,r>>>8,255&r])}else if(n<F[3]){const r=Number(n);e.push([26|t,r>>>24&255,r>>>16&255,r>>>8&255,255&r])}else{const r=BigInt(n);if(!(r<F[4]))throw new Error(`${P} encountered BigInt larger than allowable range`);{const n=[27|t,0,0,0,0,0,0,0];let o=Number(r&BigInt(4294967295)),i=Number(r>>BigInt(32)&BigInt(4294967295));n[8]=255&o,o>>=8,n[7]=255&o,o>>=8,n[6]=255&o,o>>=8,n[5]=255&o,n[4]=255&i,i>>=8,n[3]=255&i,i>>=8,n[2]=255&i,i>>=8,n[1]=255&i,e.push(n)}}}O.encodedSize=function(e){return _.encodedSize(e.value)},_.encodedSize=function(e){return e<F[0]?1:e<F[1]?2:e<F[2]?3:e<F[3]?5:9},O.compareTokens=function(e,t){return e.value<t.value?-1:e.value>t.value?1:0};const R=BigInt(-1),G=BigInt(1);function q(e,t){const n=t.value,r="bigint"==typeof n?n*R-G:-1*n-1;_(e,t.type.majorEncoded,r)}function W(e,t,n,r){K(e,t,n+r);const o=B(e,t+n,t+n+r);return new A($.bytes,o,n+r)}function X(e,t,n,r){return W(e,t,1,n)}function J(e){return void 0===e.encodedBytes&&(e.encodedBytes=e.type===$.string?V(e.value):e.value),e.encodedBytes}function Q(e,t){const n=J(t);_(e,t.type.majorEncoded,n.length),e.push(n)}function Y(e,t,n,r,o){const i=n+r;K(e,t,i);const a=new A($.string,I(e,t+n,t+i),i);return!0===o.retainStringBytes&&(a.byteValue=B(e,t+n,t+i)),a}function Z(e,t,n,r){return Y(e,t,1,n,r)}q.encodedSize=function(e){const t=e.value,n="bigint"==typeof t?t*R-G:-1*t-1;return n<F[0]?1:n<F[1]?2:n<F[2]?3:n<F[3]?5:9},q.compareTokens=function(e,t){return e.value<t.value?1:e.value>t.value?-1:0},Q.encodedSize=function(e){const t=J(e);return _.encodedSize(t.length)+t.length},Q.compareTokens=function(e,t){return n=J(e),r=J(t),n.length<r.length?-1:n.length>r.length?1:function(e,t){if(j(e)&&j(t))return e.compare(t);for(let n=0;n<e.length;n++)if(e[n]!==t[n])return e[n]<t[n]?-1:1;return 0}(n,r);var n,r};const ee=Q;function te(e,t,n,r){return new A($.array,r,n)}function ne(e,t,n,r){return te(0,0,1,n)}function re(e,t){_(e,$.array.majorEncoded,t.value)}function oe(e,t,n,r){return new A($.map,r,n)}function ie(e,t,n,r){return oe(0,0,1,n)}function ae(e,t){_(e,$.map.majorEncoded,t.value)}function se(e,t,n,r){return new A($.tag,n,1)}function ue(e,t){_(e,$.tag.majorEncoded,t.value)}re.compareTokens=O.compareTokens,re.encodedSize=function(e){return _.encodedSize(e.value)},ae.compareTokens=O.compareTokens,ae.encodedSize=function(e){return _.encodedSize(e.value)},ue.compareTokens=O.compareTokens,ue.encodedSize=function(e){return _.encodedSize(e.value)};function ce(e,t,n){if(n){if(!1===n.allowNaN&&Number.isNaN(e))throw new Error(`${P} NaN values are not supported`);if(!1===n.allowInfinity&&(e===1/0||e===-1/0))throw new Error(`${P} Infinity values are not supported`)}return new A($.float,e,t)}function fe(e,t,n){const r=t.value;if(!1===r)e.push([20|$.float.majorEncoded]);else if(!0===r)e.push([21|$.float.majorEncoded]);else if(null===r)e.push([22|$.float.majorEncoded]);else if(void 0===r)e.push([23|$.float.majorEncoded]);else{let t,i=!1;n&&!0===n.float64||(pe(r),t=ye(he,1),r===t||Number.isNaN(r)?(he[0]=249,e.push(he.slice(0,3)),i=!0):(we(r),t=ge(he,1),r===t&&(he[0]=250,e.push(he.slice(0,5)),i=!0))),i||(o=r,de.setFloat64(0,o,!1),t=me(he,1),he[0]=251,e.push(he.slice(0,9)))}var o}fe.encodedSize=function(e,t){const n=e.value;if(!1===n||!0===n||null==n)return 1;if(!t||!0!==t.float64){pe(n);let e=ye(he,1);if(n===e||Number.isNaN(n))return 3;if(we(n),e=ge(he,1),n===e)return 5}return 9};const le=new ArrayBuffer(9),de=new DataView(le,1),he=new Uint8Array(le,0);function pe(e){if(e===1/0)de.setUint16(0,31744,!1);else if(e===-1/0)de.setUint16(0,64512,!1);else if(Number.isNaN(e))de.setUint16(0,32256,!1);else{de.setFloat32(0,e);const t=de.getUint32(0),n=(2139095040&t)>>23,r=8388607&t;if(255===n)de.setUint16(0,31744,!1);else if(0===n)de.setUint16(0,(2147483648&e)>>16|r>>13,!1);else{const e=n-127;e<-24?de.setUint16(0,0):e<-14?de.setUint16(0,(2147483648&t)>>16|1<<24+e,!1):de.setUint16(0,(2147483648&t)>>16|e+15<<10|r>>13,!1)}}}function ye(e,t){if(e.length-t<2)throw new Error(`${P} not enough data for float16`);const n=(e[t]<<8)+e[t+1];if(31744===n)return 1/0;if(64512===n)return-1/0;if(32256===n)return NaN;const r=n>>10&31,o=1023&n;let i;return i=0===r?o*2**-24:31!==r?(o+1024)*2**(r-25):0===o?1/0:NaN,32768&n?-i:i}function we(e){de.setFloat32(0,e,!1)}function ge(e,t){if(e.length-t<4)throw new Error(`${P} not enough data for float32`);const n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,4).getFloat32(0,!1)}function me(e,t){if(e.length-t<8)throw new Error(`${P} not enough data for float64`);const n=(e.byteOffset||0)+t;return new DataView(e.buffer,n,8).getFloat64(0,!1)}function be(e,t,n){throw new Error(`${P} encountered invalid minor (${n}) for major ${e[t]>>>5}`)}function ve(e){return()=>{throw new Error(`${P} ${e}`)}}fe.compareTokens=O.compareTokens;const Ee=[];for(let e=0;e<=23;e++)Ee[e]=be;Ee[24]=function(e,t,n,r){return new A($.uint,C(e,t+1,r),2)},Ee[25]=function(e,t,n,r){return new A($.uint,H(e,t+1,r),3)},Ee[26]=function(e,t,n,r){return new A($.uint,z(e,t+1,r),5)},Ee[27]=function(e,t,n,r){return new A($.uint,L(e,t+1,r),9)},Ee[28]=be,Ee[29]=be,Ee[30]=be,Ee[31]=be;for(let e=32;e<=55;e++)Ee[e]=be;Ee[56]=function(e,t,n,r){return new A($.negint,-1-C(e,t+1,r),2)},Ee[57]=function(e,t,n,r){return new A($.negint,-1-H(e,t+1,r),3)},Ee[58]=function(e,t,n,r){return new A($.negint,-1-z(e,t+1,r),5)},Ee[59]=function(e,t,n,r){const o=L(e,t+1,r);if("bigint"!=typeof o){const e=-1-o;if(e>=Number.MIN_SAFE_INTEGER)return new A($.negint,e,9)}if(!0!==r.allowBigInt)throw new Error(`${P} integers outside of the safe integer range are not supported`);return new A($.negint,R-BigInt(o),9)},Ee[60]=be,Ee[61]=be,Ee[62]=be,Ee[63]=be;for(let e=64;e<=87;e++)Ee[e]=X;Ee[88]=function(e,t,n,r){return W(e,t,2,C(e,t+1,r))},Ee[89]=function(e,t,n,r){return W(e,t,3,H(e,t+1,r))},Ee[90]=function(e,t,n,r){return W(e,t,5,z(e,t+1,r))},Ee[91]=function(e,t,n,r){const o=L(e,t+1,r);if("bigint"==typeof o)throw new Error(`${P} 64-bit integer bytes lengths not supported`);return W(e,t,9,o)},Ee[92]=be,Ee[93]=be,Ee[94]=be,Ee[95]=ve("indefinite length bytes/strings are not supported");for(let e=96;e<=119;e++)Ee[e]=Z;Ee[120]=function(e,t,n,r){return Y(e,t,2,C(e,t+1,r),r)},Ee[121]=function(e,t,n,r){return Y(e,t,3,H(e,t+1,r),r)},Ee[122]=function(e,t,n,r){return Y(e,t,5,z(e,t+1,r),r)},Ee[123]=function(e,t,n,r){const o=L(e,t+1,r);if("bigint"==typeof o)throw new Error(`${P} 64-bit integer string lengths not supported`);return Y(e,t,9,o,r)},Ee[124]=be,Ee[125]=be,Ee[126]=be,Ee[127]=ve("indefinite length bytes/strings are not supported");for(let e=128;e<=151;e++)Ee[e]=ne;Ee[152]=function(e,t,n,r){return te(0,0,2,C(e,t+1,r))},Ee[153]=function(e,t,n,r){return te(0,0,3,H(e,t+1,r))},Ee[154]=function(e,t,n,r){return te(0,0,5,z(e,t+1,r))},Ee[155]=function(e,t,n,r){const o=L(e,t+1,r);if("bigint"==typeof o)throw new Error(`${P} 64-bit integer array lengths not supported`);return te(0,0,9,o)},Ee[156]=be,Ee[157]=be,Ee[158]=be,Ee[159]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${P} indefinite length items not allowed`);return te(0,0,1,1/0)};for(let e=160;e<=183;e++)Ee[e]=ie;Ee[184]=function(e,t,n,r){return oe(0,0,2,C(e,t+1,r))},Ee[185]=function(e,t,n,r){return oe(0,0,3,H(e,t+1,r))},Ee[186]=function(e,t,n,r){return oe(0,0,5,z(e,t+1,r))},Ee[187]=function(e,t,n,r){const o=L(e,t+1,r);if("bigint"==typeof o)throw new Error(`${P} 64-bit integer map lengths not supported`);return oe(0,0,9,o)},Ee[188]=be,Ee[189]=be,Ee[190]=be,Ee[191]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${P} indefinite length items not allowed`);return oe(0,0,1,1/0)};for(let e=192;e<=215;e++)Ee[e]=se;Ee[216]=function(e,t,n,r){return new A($.tag,C(e,t+1,r),2)},Ee[217]=function(e,t,n,r){return new A($.tag,H(e,t+1,r),3)},Ee[218]=function(e,t,n,r){return new A($.tag,z(e,t+1,r),5)},Ee[219]=function(e,t,n,r){return new A($.tag,L(e,t+1,r),9)},Ee[220]=be,Ee[221]=be,Ee[222]=be,Ee[223]=be;for(let e=224;e<=243;e++)Ee[e]=ve("simple values are not supported");Ee[244]=be,Ee[245]=be,Ee[246]=be,Ee[247]=function(e,t,n,r){if(!1===r.allowUndefined)throw new Error(`${P} undefined values are not supported`);return!0===r.coerceUndefinedToNull?new A($.null,null,1):new A($.undefined,void 0,1)},Ee[248]=ve("simple values are not supported"),Ee[249]=function(e,t,n,r){return ce(ye(e,t+1),3,r)},Ee[250]=function(e,t,n,r){return ce(ge(e,t+1),5,r)},Ee[251]=function(e,t,n,r){return ce(me(e,t+1),9,r)},Ee[252]=be,Ee[253]=be,Ee[254]=be,Ee[255]=function(e,t,n,r){if(!1===r.allowIndefinite)throw new Error(`${P} indefinite length items not allowed`);return new A($.break,void 0,1)};const Me=[];for(let e=0;e<24;e++)Me[e]=new A($.uint,e,1);for(let e=-1;e>=-24;e--)Me[31-e]=new A($.negint,e,1);Me[64]=new A($.bytes,new Uint8Array(0),1),Me[96]=new A($.string,"",1),Me[128]=new A($.array,0,1),Me[160]=new A($.map,0,1),Me[244]=new A($.false,!1,1),Me[245]=new A($.true,!0,1),Me[246]=new A($.null,null,1),function(){const e=[];e[$.uint.major]=O,e[$.negint.major]=q,e[$.bytes.major]=Q,e[$.string.major]=ee,e[$.array.major]=re,e[$.map.major]=ae,e[$.tag.major]=ue,e[$.float.major]=fe}();class $e{constructor(e,t){this.obj=e,this.parent=t}includes(e){let t=this;do{if(t.obj===e)return!0}while(t=t.parent);return!1}static createCheck(e,t){if(e&&e.includes(t))throw new Error(`${D} object contains circular references`);return new $e(t,e)}}const Ae={null:new A($.null,null),undefined:new A($.undefined,void 0),true:new A($.true,!0),false:new A($.false,!1),emptyArray:new A($.array,0),emptyMap:new A($.map,0)},Se={number:(e,t,n,r)=>Number.isInteger(e)&&Number.isSafeInteger(e)?new A(e>=0?$.uint:$.negint,e):new A($.float,e),bigint:(e,t,n,r)=>e>=BigInt(0)?new A($.uint,e):new A($.negint,e),Uint8Array:(e,t,n,r)=>new A($.bytes,e),string:(e,t,n,r)=>new A($.string,e),boolean:(e,t,n,r)=>e?Ae.true:Ae.false,null:(e,t,n,r)=>Ae.null,undefined:(e,t,n,r)=>Ae.undefined,ArrayBuffer:(e,t,n,r)=>new A($.bytes,new Uint8Array(e)),DataView:(e,t,n,r)=>new A($.bytes,new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),Array(e,t,n,r){if(!e.length)return!0===n.addBreakTokens?[Ae.emptyArray,new A($.break)]:Ae.emptyArray;r=$e.createCheck(r,e);const o=[];let i=0;for(const t of e)o[i++]=ke(t,n,r);return n.addBreakTokens?[new A($.array,e.length),o,new A($.break)]:[new A($.array,e.length),o]},Object(e,t,n,r){const o="Object"!==t,i=o?e.keys():Object.keys(e),a=o?e.size:i.length;if(!a)return!0===n.addBreakTokens?[Ae.emptyMap,new A($.break)]:Ae.emptyMap;r=$e.createCheck(r,e);const s=[];let u=0;for(const t of i)s[u++]=[ke(t,n,r),ke(o?e.get(t):e[t],n,r)];return function(e,t){t.mapSorter&&e.sort(t.mapSorter)}(s,n),n.addBreakTokens?[new A($.map,a),s,new A($.break)]:[new A($.map,a),s]}};Se.Map=Se.Object,Se.Buffer=Se.Uint8Array;for(const e of"Uint8Clamped Uint16 Uint32 Int8 Int16 Int32 BigUint64 BigInt64 Float32 Float64".split(" "))Se[`${e}Array`]=Se.DataView;function ke(e,t={},n){const r=M(e),o=t&&t.typeEncoders&&t.typeEncoders[r]||Se[r];if("function"==typeof o){const i=o(e,r,t,n);if(null!=i)return i}const i=Se[r];if(!i)throw new Error(`${D} unsupported type: ${r}`);return i(e,r,t,n)}const Te={strict:!1,allowIndefinite:!0,allowUndefined:!0,allowBigInt:!0};class je{constructor(e,t={}){this._pos=0,this.data=e,this.options=t}pos(){return this._pos}done(){return this._pos>=this.data.length}next(){const e=this.data[this._pos];let t=Me[e];if(void 0===t){const n=Ee[e];if(!n)throw new Error(`${P} no decoder for major type ${e>>>5} (byte 0x${e.toString(16).padStart(2,"0")})`);const r=31&e;t=n(this.data,this._pos,r,this.options)}return this._pos+=t.encodedLength,t}}const Ie=Symbol.for("DONE"),Ve=Symbol.for("BREAK");function Be(e,t){if(e.done())return Ie;const n=e.next();if(n.type===$.break)return Ve;if(n.type.terminal)return n.value;if(n.type===$.array)return function(e,t,n){const r=[];for(let o=0;o<e.value;o++){const i=Be(t,n);if(i===Ve){if(e.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed array`)}if(i===Ie)throw new Error(`${P} found array but not enough entries (got ${o}, expected ${e.value})`);r[o]=i}return r}(n,e,t);if(n.type===$.map)return function(e,t,n){const r=!0===n.useMaps,o=r?void 0:{},i=r?new Map:void 0;for(let a=0;a<e.value;a++){const s=Be(t,n);if(s===Ve){if(e.value===1/0)break;throw new Error(`${P} got unexpected break to lengthed map`)}if(s===Ie)throw new Error(`${P} found map but not enough entries (got ${a} [no key], expected ${e.value})`);if(!0!==r&&"string"!=typeof s)throw new Error(`${P} non-string keys not supported (got ${typeof s})`);if(!0===n.rejectDuplicateMapKeys&&(r&&i.has(s)||!r&&s in o))throw new Error(`${P} found repeat map key "${s}"`);const u=Be(t,n);if(u===Ie)throw new Error(`${P} found map but not enough entries (got ${a} [no value], expected ${e.value})`);r?i.set(s,u):o[s]=u}return r?i:o}(n,e,t);if(n.type===$.tag){if(t.tags&&"function"==typeof t.tags[n.value]){const r=Be(e,t);return t.tags[n.value](r)}throw new Error(`${P} tag not supported (${n.value})`)}throw new Error("unsupported")}function Ue(e,t){const[n,r]=function(e,t){if(!(e instanceof Uint8Array))throw new Error(`${P} data to decode must be a Uint8Array`);const n=(t=Object.assign({},Te,t)).tokenizer||new je(e,t),r=Be(n,t);if(r===Ie)throw new Error(`${P} did not find any content to decode`);if(r===Ve)throw new Error(`${P} got unexpected break`);return[r,e.subarray(n.pos())]}(e,t);if(r.length>0)throw new Error(`${P} too many terminals, data makes no sense`);return n}
18
18
  /*!
19
19
  * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
20
- */const xe=new Uint8Array([217,93,1]),Ne=[];function Pe({proof:e}={}){try{if("string"!=typeof e?.proofValue)throw new TypeError('"proof.proofValue" must be a string.');if("u"!==e.proofValue[0])throw new Error("Only base64url multibase encoding is supported.");const t=s(e.proofValue.slice(1));if(!function(e,t){for(let n=0;n<t.length;++n)if(e[n]!==t[n])return!1;return!0}(t,xe))throw new TypeError('"proof.proofValue" must be a derived proof.');const n=t.subarray(xe.length),[r,o,i,a,c]=Ue(n,{useMaps:!0,tags:Ne}),f=function(e){const t=new Map;for(const[n,r]of e.entries())t.set(`c14n${n}`,`u${u(r)}`);return t}(a),l={baseSignature:r,publicKey:o,signatures:i,labelMap:f,mandatoryIndexes:c};return function({baseSignature:e,publicKey:t,signatures:n,labelMap:r,mandatoryIndexes:o}){if(!(e instanceof Uint8Array&&64===e.length))throw new TypeError('"baseSignature" must be a Uint8Array of length 64.');if(!(t instanceof Uint8Array&&35===t.length))throw new TypeError('"publicKey" must be a Uint8Array of length 35.');if(!Array.isArray(n)||!n.every((e=>e instanceof Uint8Array)))throw new TypeError('"signatures" must be an array of Uint8Arrays.');if(!(r instanceof Map&&[...r.entries()].every((([e,t])=>"string"==typeof e&&"string"==typeof t))))throw new TypeError('"labelMap" must be a Map of strings to strings.');if(!Array.isArray(o)||!o.every(Number.isInteger))throw new TypeError('"mandatoryIndexes" must be an array of integers.')}(l),l}catch(e){const t=new TypeError('The proof does not include a valid "proofValue" property.');throw t.cause=e,t}}function De({proofHash:e,publicKey:t,mandatoryHash:n}={}){!function({proofHash:e,publicKey:t,mandatoryHash:n}){if(!(e instanceof Uint8Array&&32===e.length))throw new TypeError('"proofHash" must be a Uint8Array of length 32.');if(!(t instanceof Uint8Array&&35===t.length))throw new TypeError('"publicKey" must be a Uint8Array of length 35.');if(!(n instanceof Uint8Array&&32===n.length))throw new TypeError('"mandatoryHash" must be a Uint8Array of length 32.')}({proofHash:e,publicKey:t,mandatoryHash:n});return function(e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.length),0));let n=0;for(const r of e)t.set(r,n),n+=r.length;return t}([e,t,n])}Ne[64]=function(e){return e}
20
+ */const Ne=new Uint8Array([217,93,1]),xe=[];function Pe({proof:e}={}){try{if("string"!=typeof e?.proofValue)throw new TypeError('"proof.proofValue" must be a string.');if("u"!==e.proofValue[0])throw new Error("Only base64url multibase encoding is supported.");const t=s(e.proofValue.slice(1));if(!function(e,t){for(let n=0;n<t.length;++n)if(e[n]!==t[n])return!1;return!0}(t,Ne))throw new TypeError('"proof.proofValue" must be a derived proof.');const n=t.subarray(Ne.length),[r,o,i,a,c]=Ue(n,{useMaps:!0,tags:xe}),f=function(e){const t=new Map;for(const[n,r]of e.entries())t.set(`c14n${n}`,`u${u(r)}`);return t}(a),l={baseSignature:r,publicKey:o,signatures:i,labelMap:f,mandatoryIndexes:c};return function({baseSignature:e,publicKey:t,signatures:n,labelMap:r,mandatoryIndexes:o}){if(!(e instanceof Uint8Array&&64===e.length))throw new TypeError('"baseSignature" must be a Uint8Array of length 64.');if(!(t instanceof Uint8Array&&35===t.length))throw new TypeError('"publicKey" must be a Uint8Array of length 35.');if(!Array.isArray(n)||!n.every((e=>e instanceof Uint8Array)))throw new TypeError('"signatures" must be an array of Uint8Arrays.');if(!(r instanceof Map&&[...r.entries()].every((([e,t])=>"string"==typeof e&&"string"==typeof t))))throw new TypeError('"labelMap" must be a Map of strings to strings.');if(!Array.isArray(o)||!o.every(Number.isInteger))throw new TypeError('"mandatoryIndexes" must be an array of integers.')}(l),l}catch(e){const t=new TypeError('The proof does not include a valid "proofValue" property.');throw t.cause=e,t}}function De({proofHash:e,publicKey:t,mandatoryHash:n}={}){!function({proofHash:e,publicKey:t,mandatoryHash:n}){if(!(e instanceof Uint8Array&&32===e.length))throw new TypeError('"proofHash" must be a Uint8Array of length 32.');if(!(t instanceof Uint8Array&&35===t.length))throw new TypeError('"publicKey" must be a Uint8Array of length 35.');if(!(n instanceof Uint8Array&&32===n.length))throw new TypeError('"mandatoryHash" must be a Uint8Array of length 32.')}({proofHash:e,publicKey:t,mandatoryHash:n});return function(e){const t=new Uint8Array(e.reduce(((e,t)=>e+t.length),0));let n=0;for(const r of e)t.set(r,n),n+=r.length;return t}([e,t,n])}xe[64]=function(e){return e}
21
21
  /*!
22
22
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
23
23
  */;const Ke="ecdsa-sd-2023";
@@ -27,4 +27,4 @@ const h=globalThis.crypto;
27
27
  /*!
28
28
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
29
29
  */
30
- function Fe({requiredAlgorithm:e="P-256"}={}){return{name:Ke,requiredAlgorithm:e,createVerifier:Ce,createVerifyData:ze}}async function Ce({verificationMethod:e}){const t=(await c(e)).verifier();return{algorithm:t.algorithm,id:t.id,verify:async({data:e})=>async function({verifier:e,data:t}={}){const{baseSignature:n,proofHash:r,publicKey:o,signatures:i,nonMandatory:a,mandatoryHash:s}=t,u="z"+f(o),l=await c({publicKeyMultibase:u});if(i.length!==a.length)throw new Error(`Signature count (${i.length}) does not match non-mandatory message count (${a.length}).`);const{verify:d}=l.verifier();if((await Promise.all(i.map(((e,t)=>d({data:w(a[t]),signature:e}))))).some((e=>!e)))return!1;const h=await De({proofHash:r,publicKey:o,mandatoryHash:s});return e.verify({data:h,signature:n})}({verifier:t,data:e})}}async function ze({cryptosuite:e,document:t,proof:n,documentLoader:r}){if(e?.name!==Ke)throw new TypeError(`"cryptosuite.name" must be "${Ke}".`);const o={documentLoader:r},i=b({document:t,proof:n,options:o}).catch((e=>e)),{baseSignature:a,publicKey:s,signatures:u,labelMap:c,mandatoryIndexes:f}=await Pe({proof:n}),l=await function({labelMap:e}={}){return async({canonicalIdMap:t})=>{const n=new Map;for(const[r,o]of t)n.set(r,e.get(o));return n}}({labelMap:c}),d=await g({document:t,labelMapFactoryFunction:l,options:o}),h=[],y=[];for(const[e,t]of d.entries())f.includes(e)?h.push(t):y.push(t);const{mandatoryHash:m}=await async function({mandatory:e,hasher:t}={}){return t||(t=p()),{mandatoryHash:await t.hash(w(e.join("")))}}({mandatory:h}),v=await i;if(v instanceof Error)throw v;return{baseSignature:a,proofHash:v,publicKey:s,signatures:u,nonMandatory:y,mandatoryHash:m}}const{purposes:{AssertionProofPurpose:He,AuthenticationProofPurpose:Oe}}=r;var _e;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(_e||(_e={}));class Le extends l{verificationProcess=[_e.retrieveVerificationMethodPublicKey,_e.ensureVerificationMethodValidity,_e.checkDocumentSignature];documentToVerify;issuer;proof;type="EcdsaSd2023";cryptosuite="ecdsa-sd-2023";publicKey;verificationKey;verificationMethod;proofPurpose;challenge;domain;proofPurposeMap;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,this.proofPurpose=e.proofPurpose??"assertionMethod",this.challenge=e.proofChallenge??"",this.domain=e.proofDomain,this.proofPurposeMap={authentication:Oe,assertionMethod:He},this.validateProofType()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map((n=>e.verifier.convertToVerificationSubsteps(t,n)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(e){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(e,t,n){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}validateProofType(){const e=this.proof.type;if("DataIntegrityProof"!==e){if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}else{const e=this.proof.cryptosuite;if(!e)throw new Error(`Malformed proof passed. With DataIntegrityProof a cryptosuite must be defined. Expected: ${this.cryptosuite}`);if(e!==this.cryptosuite)throw new Error(`Incompatible proof cryptosuite passed. Expected: ${this.cryptosuite}, Got: ${e}`)}}generateDocumentLoader(e=[]){e.forEach((e=>{t[e.url]=e.value})),t[this.documentToVerify.issuer]=this.getTargetVerificationMethodContainer();return function(e){return e in t?{contextUrl:null,document:t[e],documentUrl:e}:o.documentLoader(e)}}getErrorMessage(e){return e.error.errors[0].message}getTargetVerificationMethodContainer(){if(this.issuer.didDocument){if(this.findVerificationMethod(this.issuer.didDocument.verificationMethod,this.issuer.didDocument.id))return this.issuer.didDocument}const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,t){return e.find((e=>e.id===this.proof.verificationMethod||t+e.id===this.proof.verificationMethod))??null}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(_e.retrieveVerificationMethodPublicKey,(async()=>{if(this.verificationMethod=d(this.getTargetVerificationMethodContainer(),this.proof.verificationMethod),!this.verificationMethod)throw new n(_e.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(this.verificationMethod.revoked)throw new n(_e.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return this.verificationMethod}),this.type)}async ensureVerificationMethodValidity(){await this.executeStep(_e.ensureVerificationMethodValidity,(async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new n(_e.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new n(_e.ensureVerificationMethodValidity,"The verification key has been revoked")}),this.type)}async checkDocumentSignature(){await this.executeStep(_e.checkDocumentSignature,(async()=>{const e=new i({cryptosuite:Fe({requiredAlgorithm:"K-256"})}),t=this.documentToVerify.proof.verificationMethod;"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const o=await r.verify(this.documentToVerify,{suite:e,purpose:new this.proofPurposeMap[this.proofPurpose]({controller:this.getTargetVerificationMethodContainer(),challenge:this.challenge,domain:this.domain}),documentLoader:this.generateDocumentLoader([{url:t,value:this.verificationKey}])});if(!o.verified)throw console.error(JSON.stringify(o,null,2)),new n(_e.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(o)}`);console.log(`Credential ${this.type} signature successfully verified`)}),this.type)}}export{Le as default};
30
+ function Fe({requiredAlgorithm:e="P-256"}={}){return{name:Ke,requiredAlgorithm:e,createVerifier:Ce,createVerifyData:He}}async function Ce({verificationMethod:e}){const t=(await c(e)).verifier();return{algorithm:t.algorithm,id:t.id,verify:async({data:e})=>async function({verifier:e,data:t}={}){const{baseSignature:n,proofHash:r,publicKey:o,signatures:i,nonMandatory:a,mandatoryHash:s}=t,u="z"+f(o),l=await c({publicKeyMultibase:u});if(i.length!==a.length)throw new Error(`Signature count (${i.length}) does not match non-mandatory message count (${a.length}).`);const{verify:d}=l.verifier();if((await Promise.all(i.map(((e,t)=>d({data:w(a[t]),signature:e}))))).some((e=>!e)))return!1;const h=await De({proofHash:r,publicKey:o,mandatoryHash:s});return e.verify({data:h,signature:n})}({verifier:t,data:e})}}async function He({cryptosuite:e,document:t,proof:n,documentLoader:r}){if(e?.name!==Ke)throw new TypeError(`"cryptosuite.name" must be "${Ke}".`);const o={documentLoader:r},i=b({document:t,proof:n,options:o}).catch((e=>e)),{baseSignature:a,publicKey:s,signatures:u,labelMap:c,mandatoryIndexes:f}=await Pe({proof:n}),l=await function({labelMap:e}={}){return async({canonicalIdMap:t})=>{const n=new Map;for(const[r,o]of t)n.set(r,e.get(o));return n}}({labelMap:c}),d=await g({document:t,labelMapFactoryFunction:l,options:o}),h=[],y=[];for(const[e,t]of d.entries())f.includes(e)?h.push(t):y.push(t);const{mandatoryHash:m}=await async function({mandatory:e,hasher:t}={}){return t||(t=p()),{mandatoryHash:await t.hash(w(e.join("")))}}({mandatory:h}),v=await i;if(v instanceof Error)throw v;return{baseSignature:a,proofHash:v,publicKey:s,signatures:u,nonMandatory:y,mandatoryHash:m}}const{purposes:{AssertionProofPurpose:ze,AuthenticationProofPurpose:Le}}=r;var Oe;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(Oe||(Oe={}));class _e extends l{verificationProcess=[Oe.retrieveVerificationMethodPublicKey,Oe.ensureVerificationMethodValidity,Oe.checkDocumentSignature];documentToVerify;issuer;proof;type="EcdsaSd2023";cryptosuite="ecdsa-sd-2023";publicKey;verificationKey;verificationMethod;proofPurpose;challenge;domain;proofPurposeMap;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,this.proofPurpose=e.proofPurpose??"assertionMethod",this.challenge=e.proofChallenge??"",this.domain=e.proofDomain,this.proofPurposeMap={authentication:Le,assertionMethod:ze},this.validateProofType()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map((n=>e.verifier.convertToVerificationSubsteps(t,n)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(e){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(e,t,n){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}validateProofType(){const e=this.proof.type;if("DataIntegrityProof"!==e){if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}else{const e=this.proof.cryptosuite;if(!e)throw new Error(`Malformed proof passed. With DataIntegrityProof a cryptosuite must be defined. Expected: ${this.cryptosuite}`);if(e!==this.cryptosuite)throw new Error(`Incompatible proof cryptosuite passed. Expected: ${this.cryptosuite}, Got: ${e}`)}}generateDocumentLoader(e=[]){e.forEach((e=>{t[e.url]=e.value})),t[this.documentToVerify.issuer]=this.getTargetVerificationMethodContainer();return function(e){return e in t?{contextUrl:null,document:t[e],documentUrl:e}:o.documentLoader(e)}}getErrorMessage(e){return e.error.errors[0].message}getTargetVerificationMethodContainer(){if(this.issuer.didDocument){if(this.findVerificationMethod(this.issuer.didDocument.verificationMethod,this.issuer.didDocument.id))return this.issuer.didDocument}const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,t){return e.find((e=>e.id===this.proof.verificationMethod||t+e.id===this.proof.verificationMethod))??null}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(Oe.retrieveVerificationMethodPublicKey,(async()=>{if(this.verificationMethod=d(this.getTargetVerificationMethodContainer(),this.proof.verificationMethod),!this.verificationMethod)throw new n(Oe.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(this.verificationMethod.revoked)throw new n(Oe.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return this.verificationMethod}),this.type)}async ensureVerificationMethodValidity(){await this.executeStep(Oe.ensureVerificationMethodValidity,(async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new n(Oe.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new n(Oe.ensureVerificationMethodValidity,"The verification key has been revoked")}),this.type)}async checkDocumentSignature(){await this.executeStep(Oe.checkDocumentSignature,(async()=>{const e=new i({cryptosuite:Fe({requiredAlgorithm:"K-256"})}),t=this.documentToVerify.proof.verificationMethod;"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const o=await r.verify(this.documentToVerify,{suite:e,purpose:new this.proofPurposeMap[this.proofPurpose]({controller:this.getTargetVerificationMethodContainer(),challenge:this.challenge,domain:this.domain}),documentLoader:this.generateDocumentLoader([{url:t,value:this.verificationKey}])});if(!o.verified)throw console.error(JSON.stringify(o,null,2)),new n(Oe.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(o)}`);console.log(`Credential ${this.type} signature successfully verified`)}),this.type)}}export{_e as default};
@@ -0,0 +1 @@
1
+ import{d as t,f as e,e as r,V as n,g as i,B as o,m as a,q as s,s as u,t as f,p as c,u as h}from"./main.js";import{j as l}from"./jsonld-signatures-BbHr1fSN-BSospRuX.js";import{j as d}from"./jsonld-BAMY2WqE-BJ5uVeOU.js";import{c as p,b as y,r as b,a as g}from"./index-fQcSLZgh-DpptYyN8.js";import{b as _,a as w}from"./elliptic-mDX7fQQx-BpaNaVm0.js";import{e as v}from"./elliptic-6I21PEnR-CsYseRX1.js";import{d as m,e as S}from"./index-DZLKRa_V-D_IQzjvG.js";import{S as E}from"./Suite-BmP2Qu19-D1ucdMDB.js";import{p as A,a as k}from"./keyUtils-ue8EY3Op-DoHdKWgN.js";import"./pako.esm-BGRKTPxS-UdHShO7y.js";import"./sha256-Bwge_vjI-C1PUWFZm.js";import"./index-Gr4i_Ned-Dgus2xdV.js";import{r as R}from"./retrieveVerificationMethodPublicKey-CLBY4G8P-CagFGnNt.js";import"./base64url-Cy03LJLt-vkTPfQOh.js";var P,M,T,O,j,x,I={exports:{}},B=s(h);function L(){return M?P:(M=1,P=B.EventEmitter)}function D(){if(O)return T;function t(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function e(e){for(var n=1;n<arguments.length;n++){var i=null!=arguments[n]?arguments[n]:{};n%2?t(Object(i),!0).forEach((function(t){r(e,t,i[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(i,t))}))}return e}function r(t,e,r){return(e=i(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function n(t,e,r){return e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function i(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:String(e)}O=1;var o=w.Buffer,a=g.inspect,s=a&&a.custom||"inspect";return T=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}return n(t,[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return o.alloc(0);for(var e,r,n,i=o.allocUnsafe(t>>>0),a=this.head,s=0;a;)e=a.data,r=i,n=s,o.prototype.copy.call(e,r,n),s+=a.data.length,a=a.next;return i}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0===(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=o.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,a=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,a),0===(t-=a)){a===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(a));break}++n}return this.length-=n,e}},{key:s,value:function(t,r){return a(this,e(e({},r),{},{depth:0,customInspect:!1}))}}]),t}()}function C(){if(x)return j;function t(t,n){r(t,n),e(t)}function e(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function r(t,e){t.emit("error",e)}return x=1,j={destroy:function(n,i){var o=this,a=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return a||s?(i?i(n):n&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,f(r,this,n)):f(r,this,n)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(n||null,(function(r){!i&&r?o._writableState?o._writableState.errorEmitted?f(e,o):(o._writableState.errorEmitted=!0,f(t,o,r)):f(t,o,r):i?(f(e,o),i(r)):f(e,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}}var U,N,K,F,V,W,q,H,G,$={};function z(){if(U)return $;U=1;var t={};function e(e,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=e,t[e]=i}function r(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}return e("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),e("ERR_INVALID_ARG_TYPE",(function(t,e,n){var i,o,a;if("string"==typeof e&&(o="not ",e.substr(0,o.length)===o)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}(t," argument"))a="The ".concat(t," ").concat(i," ").concat(r(e,"type"));else{var s=function(t,e,r){return"number"!=typeof r&&(r=0),!(r+e.length>t.length)&&-1!==t.indexOf(e,r)}(t,".")?"property":"argument";a='The "'.concat(t,'" ').concat(s," ").concat(i," ").concat(r(e,"type"))}return a+=". Received type ".concat(typeof n)}),TypeError),e("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),e("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),e("ERR_STREAM_PREMATURE_CLOSE","Premature close"),e("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),e("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),e("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),e("ERR_STREAM_WRITE_AFTER_END","write after end"),e("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),e("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),e("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),$.codes=t,$}function J(){if(K)return N;K=1;var t=z().codes.ERR_INVALID_OPT_VALUE;return N={getHighWaterMark:function(e,r,n,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(r,i,n);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new t(i?n:"highWaterMark",o);return Math.floor(o)}return e.objectMode?16:16384}}}function Y(){if(V)return F;function t(t){try{if(!a.localStorage)return!1}catch(t){return!1}var e=a.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}return V=1,F=function(e,r){if(t("noDeprecation"))return e;var n=!1;return function(){if(!n){if(t("throwDeprecation"))throw new Error(r);t("traceDeprecation")?console.trace(r):console.warn(r),n=!0}return e.apply(this,arguments)}},F}function X(){if(q)return W;function t(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var n=t.entry;t.entry=null;for(;n;){var i=n.callback;e.pendingcb--,i(r),n=n.next}e.corkedRequestsFree.next=t}(e,t)}}var e;q=1,W=k,k.WritableState=A;var r={deprecate:Y()},n=L(),i=w.Buffer,o=(void 0!==a?a:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var s,u=C(),c=J().getHighWaterMark,h=z().codes,l=h.ERR_INVALID_ARG_TYPE,d=h.ERR_METHOD_NOT_IMPLEMENTED,p=h.ERR_MULTIPLE_CALLBACK,y=h.ERR_STREAM_CANNOT_PIPE,b=h.ERR_STREAM_DESTROYED,g=h.ERR_STREAM_NULL_VALUES,v=h.ERR_STREAM_WRITE_AFTER_END,m=h.ERR_UNKNOWN_ENCODING,S=u.errorOrDestroy;function E(){}function A(r,n,i){e=e||Q(),r=r||{},"boolean"!=typeof i&&(i=n instanceof e),this.objectMode=!!r.objectMode,i&&(this.objectMode=this.objectMode||!!r.writableObjectMode),this.highWaterMark=c(this,r,"writableHighWaterMark",i),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var o=!1===r.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=r.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if("function"!=typeof i)throw new p;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?(f(i,n),f(j,t,e),t._writableState.errorEmitted=!0,S(t,n)):(i(n),t._writableState.errorEmitted=!0,S(t,n),j(t,e))}(t,r,n,e,i);else{var o=T(r)||t.destroyed;o||r.corked||r.bufferProcessing||!r.bufferedRequest||M(t,r),n?f(P,t,r,o,i):P(t,r,o,i)}}(n,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==r.emitClose,this.autoDestroy=!!r.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new t(this)}function k(t){var r=this instanceof(e=e||Q());if(!r&&!s.call(k,this))return new k(t);this._writableState=new A(t,this,r),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),n.call(this)}function R(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new b("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function P(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),j(t,e)}function M(e,r){r.bufferProcessing=!0;var n=r.bufferedRequest;if(e._writev&&n&&n.next){var i=r.bufferedRequestCount,o=new Array(i),a=r.corkedRequestsFree;a.entry=n;for(var s=0,u=!0;n;)o[s]=n,n.isBuf||(u=!1),n=n.next,s+=1;o.allBuffers=u,R(e,r,!0,r.length,o,"",a.finish),r.pendingcb++,r.lastBufferedRequest=null,a.next?(r.corkedRequestsFree=a.next,a.next=null):r.corkedRequestsFree=new t(r),r.bufferedRequestCount=0}else{for(;n;){var f=n.chunk,c=n.encoding,h=n.callback;if(R(e,r,!1,r.objectMode?1:f.length,f,c,h),n=n.next,r.bufferedRequestCount--,r.writing)break}null===n&&(r.lastBufferedRequest=null)}r.bufferedRequest=n,r.bufferProcessing=!1}function T(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function O(t,e){t._final((function(r){e.pendingcb--,r&&S(t,r),e.prefinished=!0,t.emit("prefinish"),j(t,e)}))}function j(t,e){var r=T(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,f(O,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}return _()(k,n),A.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(A.prototype,"buffer",{get:r.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(s=Function.prototype[Symbol.hasInstance],Object.defineProperty(k,Symbol.hasInstance,{value:function(t){return!!s.call(this,t)||this===k&&(t&&t._writableState instanceof A)}})):s=function(t){return t instanceof this},k.prototype.pipe=function(){S(this,new y)},k.prototype.write=function(t,e,r){var n,a=this._writableState,s=!1,u=!a.objectMode&&(n=t,i.isBuffer(n)||n instanceof o);return u&&!i.isBuffer(t)&&(t=function(t){return i.from(t)}(t)),"function"==typeof e&&(r=e,e=null),u?e="buffer":e||(e=a.defaultEncoding),"function"!=typeof r&&(r=E),a.ending?function(t,e){var r=new v;S(t,r),f(e,r)}(this,r):(u||function(t,e,r,n){var i;return null===r?i=new g:"string"==typeof r||e.objectMode||(i=new l("chunk",["string","Buffer"],r)),!i||(S(t,i),f(n,i),!1)}(this,a,t,r))&&(a.pendingcb++,s=function(t,e,r,n,o,a){if(!r){var s=function(t,e,r){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=i.from(e,r));return e}(e,n,o);n!==s&&(r=!0,o="buffer",n=s)}var u=e.objectMode?1:n.length;e.length+=u;var f=e.length<e.highWaterMark;f||(e.needDrain=!0);if(e.writing||e.corked){var c=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:o,isBuf:r,callback:a,next:null},c?c.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else R(t,e,!1,u,n,o,a);return f}(this,a,u,t,e,r)),s},k.prototype.cork=function(){this._writableState.corked++},k.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||M(this,t))},k.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new m(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new d("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,j(t,e),r&&(e.finished?f(r):t.once("finish",r));e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=u.destroy,k.prototype._undestroy=u.undestroy,k.prototype._destroy=function(t,e){e(t)},W}function Q(){if(G)return H;G=1;var t=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};H=a;var e=kt(),r=X();_()(a,e);for(var n=t(r.prototype),i=0;i<n.length;i++){var o=n[i];a.prototype[o]||(a.prototype[o]=r.prototype[o])}function a(t){if(!(this instanceof a))return new a(t);e.call(this,t),r.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",s)))}function s(){this._writableState.ended||f(u,this)}function u(t){t.end()}return Object.defineProperty(a.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(a.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(a.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(a.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}}),H}var Z,tt,et,rt,nt,it,ot,at,st,ut,ft,ct,ht,lt,dt,pt,yt,bt,gt,_t,wt,vt,mt={};function St(){if(Z)return mt;Z=1;var t=y().Buffer,e=t.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(r){var n;switch(this.encoding=function(r){var n=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(r);if("string"!=typeof n&&(t.isEncoding===e||!e(r)))throw new Error("Unknown encoding: "+r);return n||r}(r),this.encoding){case"utf16le":this.text=o,this.end=a,n=4;break;case"utf8":this.fillLast=i,n=4;break;case"base64":this.text=s,this.end=u,n=3;break;default:return this.write=f,void(this.end=c)}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(n)}function n(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function i(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function o(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function a(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function s(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function u(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function f(t){return t.toString(this.encoding)}function c(t){return t&&t.length?this.write(t):""}return mt.StringDecoder=r,r.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},r.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},r.prototype.text=function(t,e){var r=function(t,e,r){var i=e.length-1;if(i<r)return 0;var o=n(e[i]);if(o>=0)return o>0&&(t.lastNeed=o-1),o;if(--i<r||-2===o)return 0;if(o=n(e[i]),o>=0)return o>0&&(t.lastNeed=o-2),o;if(--i<r||-2===o)return 0;if(o=n(e[i]),o>=0)return o>0&&(2===o?o=0:t.lastNeed=o-3),o;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var i=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,i),t.toString("utf8",e,i)},r.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length},mt}function Et(){if(et)return tt;et=1;var t=z().codes.ERR_STREAM_PREMATURE_CLOSE;function e(){}return tt=function r(n,i,o){if("function"==typeof i)return r(n,null,i);i||(i={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||e);var a=i.readable||!1!==i.readable&&n.readable,s=i.writable||!1!==i.writable&&n.writable,u=function(){n.writable||c()},f=n._writableState&&n._writableState.finished,c=function(){s=!1,f=!0,a||o.call(n)},h=n._readableState&&n._readableState.endEmitted,l=function(){a=!1,h=!0,s||o.call(n)},d=function(t){o.call(n,t)},p=function(){var e;return a&&!h?(n._readableState&&n._readableState.ended||(e=new t),o.call(n,e)):s&&!f?(n._writableState&&n._writableState.ended||(e=new t),o.call(n,e)):void 0},y=function(){n.req.on("finish",c)};return!function(t){return t.setHeader&&"function"==typeof t.abort}(n)?s&&!n._writableState&&(n.on("end",u),n.on("close",u)):(n.on("complete",c),n.on("abort",p),n.req?y():n.on("request",y)),n.on("end",l),n.on("finish",c),!1!==i.error&&n.on("error",d),n.on("close",p),function(){n.removeListener("complete",c),n.removeListener("abort",p),n.removeListener("request",y),n.req&&n.req.removeListener("finish",c),n.removeListener("end",u),n.removeListener("close",u),n.removeListener("finish",c),n.removeListener("end",l),n.removeListener("error",d),n.removeListener("close",p)}},tt}function At(){if(nt)return rt;var t;function e(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}nt=1;var r=Et(),n=Symbol("lastResolve"),i=Symbol("lastReject"),o=Symbol("error"),a=Symbol("ended"),s=Symbol("lastPromise"),u=Symbol("handlePromise"),c=Symbol("stream");function h(t,e){return{value:t,done:e}}function l(t){var e=t[n];if(null!==e){var r=t[c].read();null!==r&&(t[s]=null,t[n]=null,t[i]=null,e(h(r,!1)))}}function d(t){f(l,t)}var p=Object.getPrototypeOf((function(){})),y=Object.setPrototypeOf((e(t={get stream(){return this[c]},next:function(){var t=this,e=this[o];if(null!==e)return Promise.reject(e);if(this[a])return Promise.resolve(h(void 0,!0));if(this[c].destroyed)return new Promise((function(e,r){f((function(){t[o]?r(t[o]):e(h(void 0,!0))}))}));var r,n=this[s];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[a]?r(h(void 0,!0)):e[u](r,n)}),n)}}(n,this));else{var i=this[c].read();if(null!==i)return Promise.resolve(h(i,!1));r=new Promise(this[u])}return this[s]=r,r}},Symbol.asyncIterator,(function(){return this})),e(t,"return",(function(){var t=this;return new Promise((function(e,r){t[c].destroy(null,(function(t){t?r(t):e(h(void 0,!0))}))}))})),t),p);return rt=function(t){var f,l=Object.create(y,(e(f={},c,{value:t,writable:!0}),e(f,n,{value:null,writable:!0}),e(f,i,{value:null,writable:!0}),e(f,o,{value:null,writable:!0}),e(f,a,{value:t._readableState.endEmitted,writable:!0}),e(f,u,{value:function(t,e){var r=l[c].read();r?(l[s]=null,l[n]=null,l[i]=null,t(h(r,!1))):(l[n]=t,l[i]=e)},writable:!0}),f));return l[s]=null,r(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=l[i];return null!==e&&(l[s]=null,l[n]=null,l[i]=null,e(t)),void(l[o]=t)}var r=l[n];null!==r&&(l[s]=null,l[n]=null,l[i]=null,r(h(void 0,!0))),l[a]=!0})),t.on("readable",d.bind(null,l)),l}}function kt(){if(st)return at;var t;st=1,at=P,P.ReadableState=R,B.EventEmitter;var e=function(t,e){return t.listeners(e).length},r=L(),n=w.Buffer,i=(void 0!==a?a:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){};var o,s=g;o=s&&s.debuglog?s.debuglog("stream"):function(){};var u,h,l,d=D(),p=C(),y=J().getHighWaterMark,b=z().codes,v=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,S=b.ERR_METHOD_NOT_IMPLEMENTED,E=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;_()(P,r);var A=p.errorOrDestroy,k=["error","close","destroy","pause","resume"];function R(e,r,n){t=t||Q(),e=e||{},"boolean"!=typeof n&&(n=r instanceof t),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=y(this,e,"readableHighWaterMark",n),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(u||(u=St().StringDecoder),this.decoder=new u(e.encoding),this.encoding=e.encoding)}function P(e){if(t=t||Q(),!(this instanceof P))return new P(e);var n=this instanceof t;this._readableState=new R(e,this,n),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),r.call(this)}function M(t,e,r,a,s){o("readableAddChunk",e);var u,f=t._readableState;if(null===e)f.reading=!1,function(t,e){if(o("onEofChunk"),e.ended)return;if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?x(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,I(t)))}(t,f);else if(s||(u=function(t,e){var r;o=e,n.isBuffer(o)||o instanceof i||"string"==typeof e||void 0===e||t.objectMode||(r=new v("chunk",["string","Buffer","Uint8Array"],e));var o;return r}(f,e)),u)A(t,u);else if(f.objectMode||e&&e.length>0)if("string"==typeof e||f.objectMode||Object.getPrototypeOf(e)===n.prototype||(e=function(t){return n.from(t)}(e)),a)f.endEmitted?A(t,new E):T(t,f,e,!0);else if(f.ended)A(t,new m);else{if(f.destroyed)return!1;f.reading=!1,f.decoder&&!r?(e=f.decoder.write(e),f.objectMode||0!==e.length?T(t,f,e,!1):U(t,f)):T(t,f,e,!1)}else a||(f.reading=!1,U(t,f));return!f.ended&&(f.length<f.highWaterMark||0===f.length)}function T(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&x(t)),U(t,e)}Object.defineProperty(P.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),P.prototype.destroy=p.destroy,P.prototype._undestroy=p.undestroy,P.prototype._destroy=function(t,e){e(t)},P.prototype.push=function(t,e){var r,i=this._readableState;return i.objectMode?r=!0:"string"==typeof t&&((e=e||i.defaultEncoding)!==i.encoding&&(t=n.from(t,e),e=""),r=!0),M(this,t,e,!1,r)},P.prototype.unshift=function(t){return M(this,t,null,!0,!1)},P.prototype.isPaused=function(){return!1===this._readableState.flowing},P.prototype.setEncoding=function(t){u||(u=St().StringDecoder);var e=new u(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,n="";null!==r;)n+=e.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==n&&this._readableState.buffer.push(n),this._readableState.length=n.length,this};var O=1073741824;function j(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=O?t=O:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,f(I,t))}function I(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,W(t)}function U(t,e){e.readingMore||(e.readingMore=!0,f(N,t,e))}function N(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function K(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function F(t){o("readable nexttick read 0"),t.read(0)}function V(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),W(t),e.flowing&&!e.reading&&t.read(0)}function W(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function q(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function H(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,f(G,e,t))}function G(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function $(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}return P.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?H(this):x(this),null;if(0===(t=j(t,e))&&e.ended)return 0===e.length&&H(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=j(r,e))),null===(n=t>0?q(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&H(this)),null!==n&&this.emit("data",n),n},P.prototype._read=function(t){A(this,new S("_read()"))},P.prototype.pipe=function(t,r){var n=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=t;break;case 1:i.pipes=[i.pipes,t];break;default:i.pipes.push(t)}i.pipesCount+=1,o("pipe count=%d opts=%j",i.pipesCount,r);var a=(!r||!1!==r.end)&&t!==c.stdout&&t!==c.stderr?u:g;function s(e,r){o("onunpipe"),e===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,o("cleanup"),t.removeListener("close",y),t.removeListener("finish",b),t.removeListener("drain",h),t.removeListener("error",p),t.removeListener("unpipe",s),n.removeListener("end",u),n.removeListener("end",g),n.removeListener("data",d),l=!0,!i.awaitDrain||t._writableState&&!t._writableState.needDrain||h())}function u(){o("onend"),t.end()}i.endEmitted?f(a):n.once("end",a),t.on("unpipe",s);var h=function(t){return function(){var r=t._readableState;o("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,0===r.awaitDrain&&e(t,"data")&&(r.flowing=!0,W(t))}}(n);t.on("drain",h);var l=!1;function d(e){o("ondata");var r=t.write(e);o("dest.write",r),!1===r&&((1===i.pipesCount&&i.pipes===t||i.pipesCount>1&&-1!==$(i.pipes,t))&&!l&&(o("false write response, pause",i.awaitDrain),i.awaitDrain++),n.pause())}function p(r){o("onerror",r),g(),t.removeListener("error",p),0===e(t,"error")&&A(t,r)}function y(){t.removeListener("finish",b),g()}function b(){o("onfinish"),t.removeListener("close",y),g()}function g(){o("unpipe"),n.unpipe(t)}return n.on("data",d),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",p),t.once("close",y),t.once("finish",b),t.emit("pipe",n),i.flowing||(o("pipe resume"),n.resume()),t},P.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var a=$(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},P.prototype.on=function(t,e){var n=r.prototype.on.call(this,t,e),i=this._readableState;return"data"===t?(i.readableListening=this.listenerCount("readable")>0,!1!==i.flowing&&this.resume()):"readable"===t&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,o("on readable",i.length,i.reading),i.length?x(this):i.reading||f(F,this))),n},P.prototype.addListener=P.prototype.on,P.prototype.removeListener=function(t,e){var n=r.prototype.removeListener.call(this,t,e);return"readable"===t&&f(K,this),n},P.prototype.removeAllListeners=function(t){var e=r.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||f(K,this),e},P.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,f(V,t,e))}(this,t)),t.paused=!1,this},P.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},P.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",(function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){(o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var a=0;a<k.length;a++)t.on(k[a],this.emit.bind(this,k[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(P.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=At()),h(this)}),Object.defineProperty(P.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(P.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(P.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),P._fromList=q,Object.defineProperty(P.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(P.from=function(t,e){return void 0===l&&(l=ot?it:(ot=1,it=function(){throw new Error("Readable.from is not available in the browser")})),l(P,t,e)}),at}function Rt(){if(ft)return ut;ft=1,ut=s;var t=z().codes,e=t.ERR_METHOD_NOT_IMPLEMENTED,r=t.ERR_MULTIPLE_CALLBACK,n=t.ERR_TRANSFORM_ALREADY_TRANSFORMING,i=t.ERR_TRANSFORM_WITH_LENGTH_0,o=Q();function a(t,e){var n=this._transformState;n.transforming=!1;var i=n.writecb;if(null===i)return this.emit("error",new r);n.writechunk=null,n.writecb=null,null!=e&&this.push(e),i(t);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function s(t){if(!(this instanceof s))return new s(t);o.call(this,t),this._transformState={afterTransform:a.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",u)}function u(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?f(this,null,null):this._flush((function(e,r){f(t,e,r)}))}function f(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new i;if(t._transformState.transforming)throw new n;return t.push(null)}return _()(s,o),s.prototype.push=function(t,e){return this._transformState.needTransform=!1,o.prototype.push.call(this,t,e)},s.prototype._transform=function(t,r,n){n(new e("_transform()"))},s.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},s.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},s.prototype._destroy=function(t,e){o.prototype._destroy.call(this,t,(function(t){e(t)}))},ut}function Pt(){if(dt)return lt;var t;dt=1;var e=z().codes,r=e.ERR_MISSING_ARGS,n=e.ERR_STREAM_DESTROYED;function i(t){if(t)throw t}function o(t){t()}function a(t,e){return t.pipe(e)}return lt=function(){for(var e=arguments.length,s=new Array(e),u=0;u<e;u++)s[u]=arguments[u];var f,c=function(t){return t.length?"function"!=typeof t[t.length-1]?i:t.pop():i}(s);if(Array.isArray(s[0])&&(s=s[0]),s.length<2)throw new r("streams");var h=s.map((function(e,r){var i=r<s.length-1;return function(e,r,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var a=!1;e.on("close",(function(){a=!0})),void 0===t&&(t=Et()),t(e,{readable:r,writable:i},(function(t){if(t)return o(t);a=!0,o()}));var s=!1;return function(t){if(!a&&!s)return s=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void o(t||new n("pipe"))}}(e,i,r>0,(function(t){f||(f=t),t&&h.forEach(o),i||(h.forEach(o),c(f))}))}));return s.reduce(a)},lt}function Mt(){return pt||(pt=1,t=I.exports,(t=I.exports=kt()).Stream=t,t.Readable=t,t.Writable=X(),t.Duplex=Q(),t.Transform=Rt(),t.PassThrough=function(){if(ht)return ct;ht=1,ct=e;var t=Rt();function e(r){if(!(this instanceof e))return new e(r);t.call(this,r)}return _()(e,t),e.prototype._transform=function(t,e,r){r(null,t)},ct}(),t.finished=Et(),t.pipeline=Pt()),I.exports;var t}function Tt(){if(bt)return yt;bt=1;var t=y().Buffer,e=Mt().Transform;function r(r){e.call(this),this._block=t.allocUnsafe(r),this._blockSize=r,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}return _()(r,e),r.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},r.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},r.prototype.update=function(e,r){if(function(e,r){if(!t.isBuffer(e)&&"string"!=typeof e)throw new TypeError(r+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");t.isBuffer(e)||(e=t.from(e,r));for(var n=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)n[o++]=e[i++];this._update(),this._blockOffset=0}for(;i<e.length;)n[this._blockOffset++]=e[i++];for(var a=0,s=8*e.length;s>0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},r.prototype._update=function(){throw new Error("_update is not implemented")},r.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},r.prototype._digest=function(){throw new Error("_digest is not implemented")},yt=r}var Ot,jt,xt,It,Bt,Lt,Dt,Ct,Ut,Nt,Kt,Ft,Vt,Wt,qt,Ht,Gt,$t,zt,Jt,Yt,Xt,Qt,Zt,te,ee,re,ne,ie,oe,ae,se,ue,fe,ce,he,le,de,pe,ye,be,ge,_e,we,ve,me,Se,Ee,Ae,ke,Re,Pe,Me,Te,Oe,je,xe,Ie,Be,Le,De,Ce,Ue,Ne,Ke,Fe,Ve,We,qe,He,Ge,$e,ze,Je,Ye,Xe,Qe,Ze,tr,er,rr={exports:{}};function nr(){return It?xt:(It=1,xt=TypeError)}function ir(){return Lt?Bt:(Lt=1,Bt=Object)}function or(){return Ct?Dt:(Ct=1,Dt=Error)}function ar(){return Nt?Ut:(Nt=1,Ut=EvalError)}function sr(){return Ft?Kt:(Ft=1,Kt=RangeError)}function ur(){return Wt?Vt:(Wt=1,Vt=ReferenceError)}function fr(){return Ht?qt:(Ht=1,qt=SyntaxError)}function cr(){return $t?Gt:($t=1,Gt=URIError)}function hr(){return Jt?zt:(Jt=1,zt=Math.abs)}function lr(){return Xt?Yt:(Xt=1,Yt=Math.floor)}function dr(){return Zt?Qt:(Zt=1,Qt=Math.max)}function pr(){return ee?te:(ee=1,te=Math.min)}function yr(){return ne?re:(ne=1,re=Math.pow)}function br(){return oe?ie:(oe=1,ie=Math.round)}function gr(){return se?ae:(se=1,ae=Number.isNaN||function(t){return t!=t})}function _r(){if(fe)return ue;fe=1;var t=gr();return ue=function(e){return t(e)||0===e?e:e<0?-1:1}}function wr(){return he?ce:(he=1,ce=Object.getOwnPropertyDescriptor)}function vr(){if(de)return le;de=1;var t=wr();if(t)try{t([],"length")}catch(e){t=null}return le=t}function mr(){if(ye)return pe;ye=1;var t=Object.defineProperty||!1;if(t)try{t({},"a",{value:1})}catch(e){t=!1}return pe=t}function Sr(){return ge?be:(ge=1,be=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(var n in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var i=Object.getOwnPropertySymbols(t);if(1!==i.length||i[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var o=Object.getOwnPropertyDescriptor(t,e);if(42!==o.value||!0!==o.enumerable)return!1}return!0})}function Er(){if(we)return _e;we=1;var t="undefined"!=typeof Symbol&&Symbol,e=Sr();return _e=function(){return"function"==typeof t&&("function"==typeof Symbol&&("symbol"==typeof t("foo")&&("symbol"==typeof Symbol("bar")&&e())))}}function Ar(){return me?ve:(me=1,ve="undefined"!=typeof Reflect&&Reflect.getPrototypeOf||null)}function kr(){return Ee?Se:(Ee=1,Se=ir().getPrototypeOf||null)}function Rr(){if(ke)return Ae;ke=1;var t=Object.prototype.toString,e=Math.max,r=function(t,e){for(var r=[],n=0;n<t.length;n+=1)r[n]=t[n];for(var i=0;i<e.length;i+=1)r[i+t.length]=e[i];return r};return Ae=function(n){var i=this;if("function"!=typeof i||"[object Function]"!==t.apply(i))throw new TypeError("Function.prototype.bind called on incompatible "+i);for(var o,a=function(t,e){for(var r=[],n=e,i=0;n<t.length;n+=1,i+=1)r[i]=t[n];return r}(arguments,1),s=e(0,i.length-a.length),u=[],f=0;f<s;f++)u[f]="$"+f;if(o=Function("binder","return function ("+function(t,e){for(var r="",n=0;n<t.length;n+=1)r+=t[n],n+1<t.length&&(r+=e);return r}(u,",")+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof o){var t=i.apply(this,r(a,arguments));return Object(t)===t?t:this}return i.apply(n,r(a,arguments))})),i.prototype){var c=function(){};c.prototype=i.prototype,o.prototype=new c,c.prototype=null}return o},Ae}function Pr(){if(Pe)return Re;Pe=1;var t=Rr();return Re=Function.prototype.bind||t}function Mr(){return Te?Me:(Te=1,Me=Function.prototype.call)}function Tr(){return je?Oe:(je=1,Oe=Function.prototype.apply)}function Or(){if(Le)return Be;Le=1;var t=Pr(),e=Tr(),r=Mr(),n=Ie?xe:(Ie=1,xe="undefined"!=typeof Reflect&&Reflect&&Reflect.apply);return Be=n||t.call(r,e)}function jr(){if(Ce)return De;Ce=1;var t=Pr(),e=nr(),r=Mr(),n=Or();return De=function(i){if(i.length<1||"function"!=typeof i[0])throw new e("a function is required");return n(t,r,i)}}function xr(){if(Ne)return Ue;Ne=1;var t,e=jr(),r=vr();try{t=[].__proto__===Array.prototype}catch(t){if(!t||"object"!=typeof t||!("code"in t)||"ERR_PROTO_ACCESS"!==t.code)throw t}var n=!!t&&r&&r(Object.prototype,"__proto__"),i=Object,o=i.getPrototypeOf;return Ue=n&&"function"==typeof n.get?e([n.get]):"function"==typeof o&&function(t){return o(null==t?t:i(t))}}function Ir(){if(Fe)return Ke;Fe=1;var t=Ar(),e=kr(),r=xr();return Ke=t?function(e){return t(e)}:e?function(t){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("getProto: not an object");return e(t)}:r?function(t){return r(t)}:null}function Br(){if(We)return Ve;We=1;var t=Function.prototype.call,e=Object.prototype.hasOwnProperty,r=Pr();return Ve=r.call(t,e)}function Lr(){if(He)return qe;var t;He=1;var e=ir(),r=or(),n=ar(),i=sr(),o=ur(),a=fr(),s=nr(),u=cr(),f=hr(),c=lr(),h=dr(),l=pr(),d=yr(),p=br(),y=_r(),b=Function,g=function(t){try{return b('"use strict"; return ('+t+").constructor;")()}catch(t){}},_=vr(),w=mr(),v=function(){throw new s},m=_?function(){try{return v}catch(t){try{return _(arguments,"callee").get}catch(t){return v}}}():v,S=Er()(),E=Ir(),A=kr(),k=Ar(),R=Tr(),P=Mr(),M={},T="undefined"!=typeof Uint8Array&&E?E(Uint8Array):t,O={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?t:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?t:ArrayBuffer,"%ArrayIteratorPrototype%":S&&E?E([][Symbol.iterator]()):t,"%AsyncFromSyncIteratorPrototype%":t,"%AsyncFunction%":M,"%AsyncGenerator%":M,"%AsyncGeneratorFunction%":M,"%AsyncIteratorPrototype%":M,"%Atomics%":"undefined"==typeof Atomics?t:Atomics,"%BigInt%":"undefined"==typeof BigInt?t:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?t:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?t:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?t:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":r,"%eval%":eval,"%EvalError%":n,"%Float16Array%":"undefined"==typeof Float16Array?t:Float16Array,"%Float32Array%":"undefined"==typeof Float32Array?t:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?t:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?t:FinalizationRegistry,"%Function%":b,"%GeneratorFunction%":M,"%Int8Array%":"undefined"==typeof Int8Array?t:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?t:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?t:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":S&&E?E(E([][Symbol.iterator]())):t,"%JSON%":"object"==typeof JSON?JSON:t,"%Map%":"undefined"==typeof Map?t:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&S&&E?E((new Map)[Symbol.iterator]()):t,"%Math%":Math,"%Number%":Number,"%Object%":e,"%Object.getOwnPropertyDescriptor%":_,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?t:Promise,"%Proxy%":"undefined"==typeof Proxy?t:Proxy,"%RangeError%":i,"%ReferenceError%":o,"%Reflect%":"undefined"==typeof Reflect?t:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?t:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&S&&E?E((new Set)[Symbol.iterator]()):t,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?t:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":S&&E?E(""[Symbol.iterator]()):t,"%Symbol%":S?Symbol:t,"%SyntaxError%":a,"%ThrowTypeError%":m,"%TypedArray%":T,"%TypeError%":s,"%Uint8Array%":"undefined"==typeof Uint8Array?t:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?t:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?t:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?t:Uint32Array,"%URIError%":u,"%WeakMap%":"undefined"==typeof WeakMap?t:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?t:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?t:WeakSet,"%Function.prototype.call%":P,"%Function.prototype.apply%":R,"%Object.defineProperty%":w,"%Object.getPrototypeOf%":A,"%Math.abs%":f,"%Math.floor%":c,"%Math.max%":h,"%Math.min%":l,"%Math.pow%":d,"%Math.round%":p,"%Math.sign%":y,"%Reflect.getPrototypeOf%":k};if(E)try{null.error}catch(t){var j=E(E(t));O["%Error.prototype%"]=j}var x=function t(e){var r;if("%AsyncFunction%"===e)r=g("async function () {}");else if("%GeneratorFunction%"===e)r=g("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=g("async function* () {}");else if("%AsyncGenerator%"===e){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===e){var i=t("%AsyncGenerator%");i&&E&&(r=E(i.prototype))}return O[e]=r,r},I={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},B=Pr(),L=Br(),D=B.call(P,Array.prototype.concat),C=B.call(R,Array.prototype.splice),U=B.call(P,String.prototype.replace),N=B.call(P,String.prototype.slice),K=B.call(P,RegExp.prototype.exec),F=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,V=/\\(\\)?/g,W=function(t,e){var r,n=t;if(L(I,n)&&(n="%"+(r=I[n])[0]+"%"),L(O,n)){var i=O[n];if(i===M&&(i=x(n)),void 0===i&&!e)throw new s("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new a("intrinsic "+t+" does not exist!")};return qe=function(t,e){if("string"!=typeof t||0===t.length)throw new s("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new s('"allowMissing" argument must be a boolean');if(null===K(/^%?[^%]*%?$/,t))throw new a("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=N(t,0,1),r=N(t,-1);if("%"===e&&"%"!==r)throw new a("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new a("invalid intrinsic syntax, expected opening `%`");var n=[];return U(t,F,(function(t,e,r,i){n[n.length]=r?U(i,V,"$1"):e||t})),n}(t),n=r.length>0?r[0]:"",i=W("%"+n+"%",e),o=i.name,u=i.value,f=!1,c=i.alias;c&&(n=c[0],C(r,D([0,1],c)));for(var h=1,l=!0;h<r.length;h+=1){var d=r[h],p=N(d,0,1),y=N(d,-1);if(('"'===p||"'"===p||"`"===p||'"'===y||"'"===y||"`"===y)&&p!==y)throw new a("property names with quotes must have matching quotes");if("constructor"!==d&&l||(f=!0),L(O,o="%"+(n+="."+d)+"%"))u=O[o];else if(null!=u){if(!(d in u)){if(!e)throw new s("base intrinsic for "+t+" exists, but the property is not available.");return}if(_&&h+1>=r.length){var b=_(u,d);u=(l=!!b)&&"get"in b&&!("originalValue"in b.get)?b.get:u[d]}else l=L(u,d),u=u[d];l&&!f&&(O[o]=u)}}return u},qe}function Dr(){if($e)return Ge;$e=1;var t=Lr(),e=jr(),r=e([t("%String.prototype.indexOf%")]);return Ge=function(n,i){var o=t(n,!!i);return"function"==typeof o&&r(n,".prototype.")>-1?e([o]):o}}function Cr(){if(Je)return ze;Je=1;var t,e,r=Function.prototype.toString,n="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof n&&"function"==typeof Object.defineProperty)try{t=Object.defineProperty({},"length",{get:function(){throw e}}),e={},n((function(){throw 42}),null,t)}catch(t){t!==e&&(n=null)}else n=null;var i=/^\s*class\b/,o=function(t){try{var e=r.call(t);return i.test(e)}catch(t){return!1}},a=function(t){try{return!o(t)&&(r.call(t),!0)}catch(t){return!1}},s=Object.prototype.toString,u="function"==typeof Symbol&&!!Symbol.toStringTag,f=!(0 in[,]),c=function(){return!1};if("object"==typeof document){var h=document.all;s.call(h)===s.call(document.all)&&(c=function(t){if((f||!t)&&(void 0===t||"object"==typeof t))try{var e=s.call(t);return("[object HTMLAllCollection]"===e||"[object HTML document.all class]"===e||"[object HTMLCollection]"===e||"[object Object]"===e)&&null==t("")}catch(t){}return!1})}return ze=n?function(r){if(c(r))return!0;if(!r)return!1;if("function"!=typeof r&&"object"!=typeof r)return!1;try{n(r,null,t)}catch(t){if(t!==e)return!1}return!o(r)&&a(r)}:function(t){if(c(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if(u)return a(t);if(o(t))return!1;var e=s.call(t);return!("[object Function]"!==e&&"[object GeneratorFunction]"!==e&&!/^\[object HTML/.test(e))&&a(t)}}function Ur(){if(Xe)return Ye;Xe=1;var t=Cr(),e=Object.prototype.toString,r=Object.prototype.hasOwnProperty;return Ye=function(n,i,o){if(!t(i))throw new TypeError("iterator must be a function");var a,s;arguments.length>=3&&(a=o),s=n,"[object Array]"===e.call(s)?function(t,e,n){for(var i=0,o=t.length;i<o;i++)r.call(t,i)&&(null==n?e(t[i],i,t):e.call(n,t[i],i,t))}(n,i,a):"string"==typeof n?function(t,e,r){for(var n=0,i=t.length;n<i;n++)null==r?e(t.charAt(n),n,t):e.call(r,t.charAt(n),n,t)}(n,i,a):function(t,e,n){for(var i in t)r.call(t,i)&&(null==n?e(t[i],i,t):e.call(n,t[i],i,t))}(n,i,a)},Ye}function Nr(){return Ze?Qe:(Ze=1,Qe=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"])}function Kr(){if(er)return tr;er=1;var t=Nr(),e="undefined"==typeof globalThis?a:globalThis;return tr=function(){for(var r=[],n=0;n<t.length;n++)"function"==typeof e[t[n]]&&(r[r.length]=t[n]);return r}}var Fr,Vr,Wr,qr,Hr,Gr,$r,zr,Jr,Yr,Xr,Qr,Zr,tn,en,rn,nn,on,an,sn,un,fn,cn,hn,ln,dn,pn,yn,bn,gn,_n,wn,vn,mn,Sn={exports:{}};function En(){if(Vr)return Fr;Vr=1;var t=mr(),e=fr(),r=nr(),n=vr();return Fr=function(i,o,a){if(!i||"object"!=typeof i&&"function"!=typeof i)throw new r("`obj` must be an object or a function`");if("string"!=typeof o&&"symbol"!=typeof o)throw new r("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new r("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new r("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new r("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new r("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,f=arguments.length>5?arguments[5]:null,c=arguments.length>6&&arguments[6],h=!!n&&n(i,o);if(t)t(i,o,{configurable:null===f&&h?h.configurable:!f,enumerable:null===s&&h?h.enumerable:!s,value:a,writable:null===u&&h?h.writable:!u});else{if(!c&&(s||u||f))throw new e("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");i[o]=a}},Fr}function An(){if(qr)return Wr;qr=1;var t=mr(),e=function(){return!!t};return e.hasArrayLengthDefineBug=function(){if(!t)return null;try{return 1!==t([],"length",{value:1}).length}catch(t){return!0}},Wr=e}function kn(){if(Gr)return Hr;Gr=1;var t=Lr(),e=En(),r=An()(),n=vr(),i=nr(),o=t("%Math.floor%");return Hr=function(t,a){if("function"!=typeof t)throw new i("`fn` is not a function");if("number"!=typeof a||a<0||a>4294967295||o(a)!==a)throw new i("`length` must be a positive 32-bit integer");var s=arguments.length>2&&!!arguments[2],u=!0,f=!0;if("length"in t&&n){var c=n(t,"length");c&&!c.configurable&&(u=!1),c&&!c.writable&&(f=!1)}return(u||f||!s)&&(r?e(t,"length",a,!0,!0):e(t,"length",a)),t},Hr}function Rn(){if(zr)return $r;zr=1;var t=Pr(),e=Tr(),r=Or();return $r=function(){return r(t,e,arguments)},$r}function Pn(){return Jr||(Jr=1,function(t){var e=kn(),r=mr(),n=jr(),i=Rn();t.exports=function(t){var r=n(arguments),i=t.length-(arguments.length-1);return e(r,1+(i>0?i:0),!0)},r?r(t.exports,"apply",{value:i}):t.exports.apply=i}(Sn)),Sn.exports}function Mn(){if(Zr)return Qr;Zr=1;var t=Ur(),e=Kr(),r=Pn(),n=Dr(),i=vr(),o=Ir(),s=n("Object.prototype.toString"),u=function(){if(Xr)return Yr;Xr=1;var t=Sr();return Yr=function(){return t()&&!!Symbol.toStringTag}}()(),f="undefined"==typeof globalThis?a:globalThis,c=e(),h=n("String.prototype.slice"),l=n("Array.prototype.indexOf",!0)||function(t,e){for(var r=0;r<t.length;r+=1)if(t[r]===e)return r;return-1},d={__proto__:null};t(c,u&&i&&o?function(t){var e=new f[t];if(Symbol.toStringTag in e&&o){var n=o(e),a=i(n,Symbol.toStringTag);if(!a&&n){var s=o(n);a=i(s,Symbol.toStringTag)}d["$"+t]=r(a.get)}}:function(t){var e=new f[t],n=e.slice||e.set;n&&(d["$"+t]=r(n))});return Qr=function(e){if(!e||"object"!=typeof e)return!1;if(!u){var r=h(s(e),8,-1);return l(c,r)>-1?r:"Object"===r&&function(e){var r=!1;return t(d,(function(t,n){if(!r)try{t(e),r=h(n,1)}catch(t){}})),r}(e)}return i?function(e){var r=!1;return t(d,(function(t,n){if(!r)try{"$"+t(e)===n&&(r=h(n,1))}catch(t){}})),r}(e):null}}function Tn(){if(en)return tn;en=1;var t=Mn();return tn=function(e){return!!t(e)}}function On(){if(nn)return rn;nn=1;var t=nr(),e=Dr()("TypedArray.prototype.buffer",!0),r=Tn();return rn=e||function(e){if(!r(e))throw new t("Not a Typed Array");return e.buffer}}function jn(){if(an)return on;an=1;var t=y().Buffer,e=function(){if(jt)return Ot;jt=1;var t={}.toString;return Ot=Array.isArray||function(e){return"[object Array]"==t.call(e)}}(),r=On(),n=ArrayBuffer.isView||function(t){try{return r(t),!0}catch(t){return!1}},i="undefined"!=typeof Uint8Array,o="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array,a=o&&(t.prototype instanceof Uint8Array||t.TYPED_ARRAY_SUPPORT);return on=function(r,s){if(r instanceof t)return r;if("string"==typeof r)return t.from(r,s);if(o&&n(r)){if(0===r.byteLength)return t.alloc(0);if(a){var u=t.from(r.buffer,r.byteOffset,r.byteLength);if(u.byteLength===r.byteLength)return u}var f=r instanceof Uint8Array?r:new Uint8Array(r.buffer,r.byteOffset,r.byteLength),c=t.from(f);if(c.length===r.byteLength)return c}if(i&&r instanceof Uint8Array)return t.from(r);var h=e(r);if(h)for(var l=0;l<r.length;l+=1){var d=r[l];if("number"!=typeof d||d<0||d>255||~~d!==d)throw new RangeError("Array items must be numbers in the range 0-255.")}if(h||t.isBuffer(r)&&r.constructor&&"function"==typeof r.constructor.isBuffer&&r.constructor.isBuffer(r))return t.from(r);throw new TypeError('The "data" argument must be a string, an Array, a Buffer, a Uint8Array, or a DataView.')}}function xn(){if(un)return sn;un=1;var t=y().Buffer,e=jn();function r(e,r){this._block=t.alloc(e),this._finalSize=r,this._blockSize=e,this._len=0}return r.prototype.update=function(t,r){t=e(t,r||"utf8");for(var n=this._block,i=this._blockSize,o=t.length,a=this._len,s=0;s<o;){for(var u=a%i,f=Math.min(o-s,i-u),c=0;c<f;c++)n[u+c]=t[s+c];s+=f,(a+=f)%i==0&&this._update(n)}return this._len+=o,this},r.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},r.prototype._update=function(){throw new Error("_update must be implemented by subclass")},sn=r}function In(){if(pn)return dn;pn=1;var t=_(),e=xn(),r=y().Buffer,n=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],i=new Array(64);function o(){this.init(),this._w=i,e.call(this,64,56)}function a(t,e,r){return r^t&(e^r)}function s(t,e,r){return t&e|r&(t|e)}function u(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function f(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function c(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}return t(o,e),o.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},o.prototype._update=function(t){for(var e,r=this._w,i=0|this._a,o=0|this._b,h=0|this._c,l=0|this._d,d=0|this._e,p=0|this._f,y=0|this._g,b=0|this._h,g=0;g<16;++g)r[g]=t.readInt32BE(4*g);for(;g<64;++g)r[g]=0|(((e=r[g-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[g-7]+c(r[g-15])+r[g-16];for(var _=0;_<64;++_){var w=b+f(d)+a(d,p,y)+n[_]+r[_]|0,v=u(i)+s(i,o,h)|0;b=y,y=p,p=d,d=l+w|0,l=h,h=o,o=i,i=w+v|0}this._a=i+this._a|0,this._b=o+this._b|0,this._c=h+this._c|0,this._d=l+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=y+this._g|0,this._h=b+this._h|0},o.prototype._hash=function(){var t=r.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},dn=o}function Bn(){if(_n)return gn;_n=1;var t=_(),e=xn(),r=y().Buffer,n=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],i=new Array(160);function o(){this.init(),this._w=i,e.call(this,128,112)}function a(t,e,r){return r^t&(e^r)}function s(t,e,r){return t&e|r&(t|e)}function u(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function f(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function c(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function h(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function l(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function d(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function p(t,e){return t>>>0<e>>>0?1:0}return t(o,e),o.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},o.prototype._update=function(t){for(var e=this._w,r=0|this._ah,i=0|this._bh,o=0|this._ch,y=0|this._dh,b=0|this._eh,g=0|this._fh,_=0|this._gh,w=0|this._hh,v=0|this._al,m=0|this._bl,S=0|this._cl,E=0|this._dl,A=0|this._el,k=0|this._fl,R=0|this._gl,P=0|this._hl,M=0;M<32;M+=2)e[M]=t.readInt32BE(4*M),e[M+1]=t.readInt32BE(4*M+4);for(;M<160;M+=2){var T=e[M-30],O=e[M-30+1],j=c(T,O),x=h(O,T),I=l(T=e[M-4],O=e[M-4+1]),B=d(O,T),L=e[M-14],D=e[M-14+1],C=e[M-32],U=e[M-32+1],N=x+D|0,K=j+L+p(N,x)|0;K=(K=K+I+p(N=N+B|0,B)|0)+C+p(N=N+U|0,U)|0,e[M]=K,e[M+1]=N}for(var F=0;F<160;F+=2){K=e[F],N=e[F+1];var V=s(r,i,o),W=s(v,m,S),q=u(r,v),H=u(v,r),G=f(b,A),$=f(A,b),z=n[F],J=n[F+1],Y=a(b,g,_),X=a(A,k,R),Q=P+$|0,Z=w+G+p(Q,P)|0;Z=(Z=(Z=Z+Y+p(Q=Q+X|0,X)|0)+z+p(Q=Q+J|0,J)|0)+K+p(Q=Q+N|0,N)|0;var tt=H+W|0,et=q+V+p(tt,H)|0;w=_,P=R,_=g,R=k,g=b,k=A,b=y+Z+p(A=E+Q|0,E)|0,y=o,E=S,o=i,S=m,i=r,m=v,r=Z+et+p(v=Q+tt|0,Q)|0}this._al=this._al+v|0,this._bl=this._bl+m|0,this._cl=this._cl+S|0,this._dl=this._dl+E|0,this._el=this._el+A|0,this._fl=this._fl+k|0,this._gl=this._gl+R|0,this._hl=this._hl+P|0,this._ah=this._ah+r+p(this._al,v)|0,this._bh=this._bh+i+p(this._bl,m)|0,this._ch=this._ch+o+p(this._cl,S)|0,this._dh=this._dh+y+p(this._dl,E)|0,this._eh=this._eh+b+p(this._el,A)|0,this._fh=this._fh+g+p(this._fl,k)|0,this._gh=this._gh+_+p(this._gl,R)|0,this._hh=this._hh+w+p(this._hl,P)|0},o.prototype._hash=function(){var t=r.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},gn=o}function Ln(){return mn||(mn=1,(t=rr).exports=function(e){var r=e.toLowerCase(),n=t.exports[r];if(!n)throw new Error(r+" is not supported (we accept pull requests)");return new n},t.exports.sha=function(){if(cn)return fn;cn=1;var t=_(),e=xn(),r=y().Buffer,n=[1518500249,1859775393,-1894007588,-899497514],i=new Array(80);function o(){this.init(),this._w=i,e.call(this,64,56)}function a(t){return t<<30|t>>>2}function s(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}return t(o,e),o.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},o.prototype._update=function(t){for(var e,r=this._w,i=0|this._a,o=0|this._b,u=0|this._c,f=0|this._d,c=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var l=0;l<80;++l){var d=~~(l/20),p=0|((e=i)<<5|e>>>27)+s(d,o,u,f)+c+r[l]+n[d];c=f,f=u,u=a(o),o=i,i=p}this._a=i+this._a|0,this._b=o+this._b|0,this._c=u+this._c|0,this._d=f+this._d|0,this._e=c+this._e|0},o.prototype._hash=function(){var t=r.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},fn=o}(),t.exports.sha1=function(){if(ln)return hn;ln=1;var t=_(),e=xn(),r=y().Buffer,n=[1518500249,1859775393,-1894007588,-899497514],i=new Array(80);function o(){this.init(),this._w=i,e.call(this,64,56)}function a(t){return t<<5|t>>>27}function s(t){return t<<30|t>>>2}function u(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}return t(o,e),o.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},o.prototype._update=function(t){for(var e,r=this._w,i=0|this._a,o=0|this._b,f=0|this._c,c=0|this._d,h=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=(e=r[l-3]^r[l-8]^r[l-14]^r[l-16])<<1|e>>>31;for(var d=0;d<80;++d){var p=~~(d/20),y=a(i)+u(p,o,f,c)+h+r[d]+n[p]|0;h=c,c=f,f=s(o),o=i,i=y}this._a=i+this._a|0,this._b=o+this._b|0,this._c=f+this._c|0,this._d=c+this._d|0,this._e=h+this._e|0},o.prototype._hash=function(){var t=r.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},hn=o}(),t.exports.sha224=function(){if(bn)return yn;bn=1;var t=_(),e=In(),r=xn(),n=y().Buffer,i=new Array(64);function o(){this.init(),this._w=i,r.call(this,64,56)}return t(o,e),o.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},o.prototype._hash=function(){var t=n.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},yn=o}(),t.exports.sha256=In(),t.exports.sha384=function(){if(vn)return wn;vn=1;var t=_(),e=Bn(),r=xn(),n=y().Buffer,i=new Array(160);function o(){this.init(),this._w=i,r.call(this,128,112)}return t(o,e),o.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},o.prototype._hash=function(){var t=n.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},wn=o}(),t.exports.sha512=Bn()),rr.exports;var t}var Dn,Cn,Un,Nn,Kn=s(u);function Fn(){if(Cn)return Dn;Cn=1;var t=y().Buffer,e=b.Transform,r=Kn.StringDecoder;function n(t){e.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}_()(n,e);var i="undefined"!=typeof Uint8Array,o="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&ArrayBuffer.isView&&(t.prototype instanceof Uint8Array||t.TYPED_ARRAY_SUPPORT);return n.prototype.update=function(e,r,n){var a=function(e,r){if(e instanceof t)return e;if("string"==typeof e)return t.from(e,r);if(o&&ArrayBuffer.isView(e)){if(0===e.byteLength)return t.alloc(0);var n=t.from(e.buffer,e.byteOffset,e.byteLength);if(n.byteLength===e.byteLength)return n}if(i&&e instanceof Uint8Array)return t.from(e);if(t.isBuffer(e)&&e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e))return t.from(e);throw new TypeError('The "data" argument must be of type string or an instance of Buffer, TypedArray, or DataView.')}(e,r),s=this._update(a);return this.hashMode?this:(n&&(s=this._toString(s,n)),s)},n.prototype.setAutoPadding=function(){},n.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},n.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},n.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},n.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},n.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},n.prototype._finalOrDigest=function(e){var r=this.__final()||t.alloc(0);return e&&(r=this._toString(r,e,!0)),r},n.prototype._toString=function(t,e,n){if(this._decoder||(this._decoder=new r(e),this._encoding=e),this._encoding!==e)throw new Error("can’t switch encodings");var i=this._decoder.write(t);return n&&(i+=this._decoder.end()),i},Dn=n}var Vn,Wn=function(){if(Nn)return Un;Nn=1;var t=_(),e=function(){if(_t)return gt;_t=1;var t=_(),e=Tt(),r=y().Buffer,n=new Array(16);function i(){e.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function o(t,e){return t<<e|t>>>32-e}function a(t,e,r,n,i,a,s){return o(t+(e&r|~e&n)+i+a|0,s)+e|0}function s(t,e,r,n,i,a,s){return o(t+(e&n|r&~n)+i+a|0,s)+e|0}function u(t,e,r,n,i,a,s){return o(t+(e^r^n)+i+a|0,s)+e|0}function f(t,e,r,n,i,a,s){return o(t+(r^(e|~n))+i+a|0,s)+e|0}return t(i,e),i.prototype._update=function(){for(var t=n,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var r=this._a,i=this._b,o=this._c,c=this._d;r=a(r,i,o,c,t[0],3614090360,7),c=a(c,r,i,o,t[1],3905402710,12),o=a(o,c,r,i,t[2],606105819,17),i=a(i,o,c,r,t[3],3250441966,22),r=a(r,i,o,c,t[4],4118548399,7),c=a(c,r,i,o,t[5],1200080426,12),o=a(o,c,r,i,t[6],2821735955,17),i=a(i,o,c,r,t[7],4249261313,22),r=a(r,i,o,c,t[8],1770035416,7),c=a(c,r,i,o,t[9],2336552879,12),o=a(o,c,r,i,t[10],4294925233,17),i=a(i,o,c,r,t[11],2304563134,22),r=a(r,i,o,c,t[12],1804603682,7),c=a(c,r,i,o,t[13],4254626195,12),o=a(o,c,r,i,t[14],2792965006,17),r=s(r,i=a(i,o,c,r,t[15],1236535329,22),o,c,t[1],4129170786,5),c=s(c,r,i,o,t[6],3225465664,9),o=s(o,c,r,i,t[11],643717713,14),i=s(i,o,c,r,t[0],3921069994,20),r=s(r,i,o,c,t[5],3593408605,5),c=s(c,r,i,o,t[10],38016083,9),o=s(o,c,r,i,t[15],3634488961,14),i=s(i,o,c,r,t[4],3889429448,20),r=s(r,i,o,c,t[9],568446438,5),c=s(c,r,i,o,t[14],3275163606,9),o=s(o,c,r,i,t[3],4107603335,14),i=s(i,o,c,r,t[8],1163531501,20),r=s(r,i,o,c,t[13],2850285829,5),c=s(c,r,i,o,t[2],4243563512,9),o=s(o,c,r,i,t[7],1735328473,14),r=u(r,i=s(i,o,c,r,t[12],2368359562,20),o,c,t[5],4294588738,4),c=u(c,r,i,o,t[8],2272392833,11),o=u(o,c,r,i,t[11],1839030562,16),i=u(i,o,c,r,t[14],4259657740,23),r=u(r,i,o,c,t[1],2763975236,4),c=u(c,r,i,o,t[4],1272893353,11),o=u(o,c,r,i,t[7],4139469664,16),i=u(i,o,c,r,t[10],3200236656,23),r=u(r,i,o,c,t[13],681279174,4),c=u(c,r,i,o,t[0],3936430074,11),o=u(o,c,r,i,t[3],3572445317,16),i=u(i,o,c,r,t[6],76029189,23),r=u(r,i,o,c,t[9],3654602809,4),c=u(c,r,i,o,t[12],3873151461,11),o=u(o,c,r,i,t[15],530742520,16),r=f(r,i=u(i,o,c,r,t[2],3299628645,23),o,c,t[0],4096336452,6),c=f(c,r,i,o,t[7],1126891415,10),o=f(o,c,r,i,t[14],2878612391,15),i=f(i,o,c,r,t[5],4237533241,21),r=f(r,i,o,c,t[12],1700485571,6),c=f(c,r,i,o,t[3],2399980690,10),o=f(o,c,r,i,t[10],4293915773,15),i=f(i,o,c,r,t[1],2240044497,21),r=f(r,i,o,c,t[8],1873313359,6),c=f(c,r,i,o,t[15],4264355552,10),o=f(o,c,r,i,t[6],2734768916,15),i=f(i,o,c,r,t[13],1309151649,21),r=f(r,i,o,c,t[4],4149444226,6),c=f(c,r,i,o,t[11],3174756917,10),o=f(o,c,r,i,t[2],718787259,15),i=f(i,o,c,r,t[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+i|0,this._c=this._c+o|0,this._d=this._d+c|0},i.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=r.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t},gt=i}(),r=function(){if(vt)return wt;vt=1;var t=w.Buffer,e=_(),r=Tt(),n=new Array(16),i=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],o=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],a=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],s=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],u=[0,1518500249,1859775393,2400959708,2840853838],f=[1352829926,1548603684,1836072691,2053994217,0];function c(){r.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function h(t,e){return t<<e|t>>>32-e}function l(t,e,r,n,i,o,a,s){return h(t+(e^r^n)+o+a|0,s)+i|0}function d(t,e,r,n,i,o,a,s){return h(t+(e&r|~e&n)+o+a|0,s)+i|0}function p(t,e,r,n,i,o,a,s){return h(t+((e|~r)^n)+o+a|0,s)+i|0}function y(t,e,r,n,i,o,a,s){return h(t+(e&n|r&~n)+o+a|0,s)+i|0}function b(t,e,r,n,i,o,a,s){return h(t+(e^(r|~n))+o+a|0,s)+i|0}return e(c,r),c.prototype._update=function(){for(var t=n,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,c=0|this._b,g=0|this._c,_=0|this._d,w=0|this._e,v=0|this._a,m=0|this._b,S=0|this._c,E=0|this._d,A=0|this._e,k=0;k<80;k+=1){var R,P;k<16?(R=l(r,c,g,_,w,t[i[k]],u[0],a[k]),P=b(v,m,S,E,A,t[o[k]],f[0],s[k])):k<32?(R=d(r,c,g,_,w,t[i[k]],u[1],a[k]),P=y(v,m,S,E,A,t[o[k]],f[1],s[k])):k<48?(R=p(r,c,g,_,w,t[i[k]],u[2],a[k]),P=p(v,m,S,E,A,t[o[k]],f[2],s[k])):k<64?(R=y(r,c,g,_,w,t[i[k]],u[3],a[k]),P=d(v,m,S,E,A,t[o[k]],f[3],s[k])):(R=b(r,c,g,_,w,t[i[k]],u[4],a[k]),P=l(v,m,S,E,A,t[o[k]],f[4],s[k])),r=w,w=_,_=h(g,10),g=c,c=R,v=A,A=E,E=h(S,10),S=m,m=P}var M=this._b+g+E|0;this._b=this._c+_+A|0,this._c=this._d+w+v|0,this._d=this._e+r+m|0,this._e=this._a+c+S|0,this._a=M},c.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=t.alloc?t.alloc(20):new t(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},wt=c}(),n=Ln(),i=Fn();function o(t){i.call(this,"digest"),this._hash=t}return t(o,i),o.prototype._update=function(t){this._hash.update(t)},o.prototype._final=function(){return this._hash.digest()},Un=function(t){return"md5"===(t=t.toLowerCase())?new e:"rmd160"===t||"ripemd160"===t?new r:new o(n(t))}}(),qn=i(Wn),Hn={exports:{}};var Gn,$n,zn,Jn,Yn,Xn,Qn=function(){if(Vn)return Hn.exports;Vn=1;var t=65536,e=4294967295,r=y().Buffer,n=a.crypto||a.msCrypto;return n&&n.getRandomValues?Hn.exports=function(i,o){if(i>e)throw new RangeError("requested too many random bytes");var a=r.allocUnsafe(i);if(i>0)if(i>t)for(var s=0;s<i;s+=t)n.getRandomValues(a.slice(s,s+t));else n.getRandomValues(a);if("function"==typeof o)return f((function(){o(null,a)}));return a}:Hn.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")},Hn.exports}(),Zn=i(Qn);var ti=function(){if(Xn)return Yn;Xn=1;const{CryptoLD:t}=($n||($n=1,Gn={CryptoLD:class{constructor({suites:t}={}){this.suites=t||new Map}use(t){this.suites.set(t.suite,t)}async generate(t={}){return this._suiteForType(t).generate(t)}async from(t={}){const e=this._suiteForType(t);return t["@context"]?e.fromKeyDocument({document:t}):e.from(t)}async fromKeyDocument({document:t,checkContext:e=!0,checkRevoked:r=!0}={}){if(!t)throw new TypeError('The "document" parameter is required.');return this._suiteForType(t).fromKeyDocument({document:t,checkContext:e,checkRevoked:r})}async fromKeyId({id:t,documentLoader:e,checkContext:r=!0,checkRevoked:n=!0}={}){if(!t)throw new TypeError('The "id" parameter is required.');if(!e)throw new TypeError('The "documentLoader" parameter is required.');let i;try{if(({document:i}=await e(t)),!i)throw new Error('The "documentLoader" function must return a "document" object.')}catch(t){const e=new Error("Error fetching document: "+t.message);throw e.cause=t,e}const o=i.type;if(!o)throw new Error("Key suite type not found in fetched document.");const a=this.suites.get(o);if(!a)throw new Error(`Support for suite "${o}" is not installed.`);return a.fromKeyDocument({document:i,checkContext:r,checkRevoked:n})}_installed({type:t}){return this.suites.has(t)}_suiteForType(t){const e=t&&t.type;if(!e)throw new TypeError("Missing key type.");if(!this._installed({type:e}))throw new Error(`Support for key type "${e}" is not installed.`);return this.suites.get(e)}}}),Gn),{LDKeyPair:e}=function(){if(Jn)return zn;Jn=1;class t{constructor({id:t,controller:e,revoked:r}={}){this.id=t,this.controller=e,this.revoked=r}static async generate(){throw new Error("Abstract method, must be implemented in subclass.")}static async fromKeyDocument({document:t,checkContext:e=!0,checkRevoked:r=!0}={}){if(!t)throw new TypeError('The "document" parameter is required.');if(e&&![].concat(t["@context"]).includes(this.SUITE_CONTEXT))throw new Error('Key document does not contain required context "'+this.SUITE_CONTEXT+'".');if(r&&t.revoked)throw new Error(`Key has been revoked since: "${t.revoked}".`);return this.from(t)}static async from(){throw new Error("Abstract method from() must be implemented in subclass.")}export({publicKey:t=!1,privateKey:e=!1}={}){if(!t&&!e)throw new Error('Export requires specifying either "publicKey" or "privateKey".');const r={id:this.id,type:this.type,controller:this.controller};return this.revoked&&(r.revoked=this.revoked),r}fingerprint(){throw new Error("Abstract method, must be implemented in subclass.")}verifyFingerprint(){throw new Error("Abstract method, must be implemented in subclass.")}signer(){return{async sign({}){throw new Error("Abstract method, must be implemented in subclass.")}}}verifier(){return{async verify({}){throw new Error("Abstract method, must be implemented in subclass.")}}}}return t.SUITE_CONTEXT="INVALID LDKeyPair CONTEXT",zn={LDKeyPair:t}}();return Yn={CryptoLD:t,LDKeyPair:e}}(),ei=i(ti);const ri="EcdsaSecp256k1VerificationKey2019",ni=t=>qn("sha256").update(t).digest();class ii extends ei.LDKeyPair{constructor({publicKeyBase58:t,privateKeyBase58:e,...r}){if(super(r),this.type=void 0,this.publicKeyBase58=void 0,this.privateKeyBase58=void 0,e&&!t){const t=v.publicKeyCreate(m(e));this.publicKeyBase58=S(t)}else this.publicKeyBase58=t;if(this.type=ri,this.privateKeyBase58=e,!this.publicKeyBase58)throw new TypeError('The "publicKeyBase58" property is required.')}static from(t){if(t.publicKeyHex||t.privateKeyHex){const{publicKeyHex:e,privateKeyHex:r,...n}=t;return new ii({...n,publicKeyBase58:e?S(o.from(e,"hex")):void 0,privateKeyBase58:r?S(o.from(r,"hex")):void 0})}return new ii(t)}static async generate({seed:t,compressed:e,...r}){if(t&&!v.privateKeyVerify(t))throw new Error("Provided seed is not a valid private key");let n=t;for(;void 0===n||!v.privateKeyVerify(n);)n=new Uint8Array(Zn(32));const i=v.publicKeyCreate(n,e);return new ii({publicKeyBase58:S(i),privateKeyBase58:S(n),...r})}export({publicKey:t=!1,privateKey:e=!1,includeContext:r=!1}={}){if(!t&&!e)throw new TypeError('export requires specifying either "publicKey" or "privateKey".');if(e&&!this.privateKeyBase58)throw new TypeError("No privateKey to export.");if(t&&!this.publicKeyBase58)throw new TypeError("No publicKey to export.");const n={type:this.type,id:this.id,controller:this.controller,revoked:this.revoked};return r&&(n["@context"]=ii.SUITE_CONTEXT),e&&(n.privateKeyBase58=this.privateKeyBase58),t&&(n.publicKeyBase58=this.publicKeyBase58),n}signer(){const{privateKeyBase58:t}=this;return t?{async sign({data:e}){const r=p.encode(JSON.stringify({alg:"ES256K",b64:!1,crit:["b64"]})),n=o.from(e.buffer,e.byteOffset,e.length),i=ni(o.from(o.concat([o.from(`${r}.`,"utf8"),o.from(n.buffer,n.byteOffset,n.length)]))),{signature:a}=v.ecdsaSign(i,m(t));return`${r}..${p.encode(o.from(a))}`},id:this.id}:{async sign(){throw new Error("No private key to sign with.")},id:this.id}}verifier(){const{publicKeyBase58:t}=this;return t?{async verify({data:e,signature:r}){if(r.indexOf("..")<0)return!1;const[n,i]=r.split(".."),a=JSON.parse(p.decode(n));if("ES256K"!==a.alg||!1!==a.b64||!a.crit||!a.crit.length||"b64"!==a.crit[0])return!1;const s=o.from(e.buffer,e.byteOffset,e.length),u=ni(o.from(o.concat([o.from(`${n}.`,"utf8"),o.from(s.buffer,s.byteOffset,s.length)])));let f;try{f=v.ecdsaVerify(o.from(p.decode(i,"hex"),"hex"),u,m(t))}catch(t){f=!1}return f},id:this.id}:{async verify(){throw new Error("No public key to verify against")},id:this.id}}}ii.suite=ri,ii.SUITE_CONTEXT="https://ns.did.ai/suites/secp256k1-2019/v1";const oi="https://ns.did.ai/suites/secp256k1-2019/v1",ai="https://www.w3.org/ns/credentials/v2",si=({document:t,contextUrl:e})=>{const r=t["@context"];return Array.isArray(r)?e.some((t=>r.includes(t))):e.includes(r)},ui=({document:t})=>{const e=si({document:t,contextUrl:[oi,"https://w3id.org/security/suites/secp256k1-2019/v1"]}),r=si({document:t,contextUrl:["https://www.w3.org/2018/credentials/v1"]}),n=si({document:t,contextUrl:[ai]}),i=si({document:t,contextUrl:["https://w3id.org/security/v2"]});return e&&r?(console.warn("Warning: The secp256k1-2019/v1 and credentials/v1 contexts are incompatible."),console.warn("For VCs using EcdsaSecp256k1Signature2019 suite, using the credentials/v1 context is sufficient."),!1):!e&&n?(console.warn("This library does not (yet) follow the Data Integrity Proof format."),console.warn("When using the credentials/v2 context, consumers need to specify the secp256k1-2019/v1 context."),!1):e&&i?(console.warn("Warning: The secp256k1-2019/v1 and security/v2 contexts are incompatible."),console.warn("For VCs using EcdsaSecp256k1Signature2019 suite, using the security/v2 context is sufficient."),!1):e||r||i};let fi=class extends l.suites.LinkedDataSignature{constructor(t={}){super({type:"EcdsaSecp256k1Signature2019",LDKeyClass:ii,contextUrl:oi,...t}),this.requiredKeyType=void 0,this.requiredKeyType="EcdsaSecp256k1VerificationKey2019"}async sign({verifyData:t,proof:e}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");return{...e,jws:await this.signer.sign({data:t})}}async verifySignature({verifyData:t,verificationMethod:e,proof:r}){const{jws:n}=r;if(!n||"string"!=typeof n)throw new TypeError('The proof does not include a valid "jws" property.');let{verifier:i}=this;if(!i){i=(await this.LDKeyClass.from(e)).verifier()}return i.verify({data:t,signature:n})}async assertVerificationMethod({verificationMethod:t}){if(!ui({document:t}))throw new TypeError(`The verification method (key) must contain "${this.contextUrl}".`);if(!d.hasValue(t,"type",this.requiredKeyType))throw new Error(`Invalid key type. Key type must be "${this.requiredKeyType}".`);if(void 0!==t.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:t,documentLoader:e}){if(this.key)return this.key.export({publicKey:!0});const r="object"==typeof t.verificationMethod?t.verificationMethod.id:t.verificationMethod;if(!r)throw new Error('No "verificationMethod" found in proof.');const n=await d.frame(r,{"@context":this.contextUrl,"@embed":"@always",id:r},{documentLoader:e,compactToRelative:!1});if(!n)throw new Error(`Verification method ${r} not found.`);if(void 0!==n.revoked)throw new Error("The verification method has been revoked.");return await this.assertVerificationMethod({verificationMethod:n}),n}async matchProof({proof:t,document:e,purpose:r,documentLoader:n,expansionMap:i}){if(!ui({document:e}))return!1;if(!await super.matchProof({proof:t,document:e,purpose:r,documentLoader:n,expansionMap:i}))return!1;if(!this.key)return!0;const{verificationMethod:o}=t,a="object"==typeof o?o.id:o;return this.isVerificationMethodMatchingKeyId(a)}ensureSuiteContext({document:t,addSuiteContext:e}){ui({document:t})&&!si({document:t,contextUrl:[ai]})||super.ensureSuiteContext({document:t,addSuiteContext:e})}isVerificationMethodMatchingKeyId(t){return t===this.key.id||t===`${this.key.controller}${this.key.id}`}};fi.CONTEXT_URL=oi,fi.CONTEXT={"@context":{id:"@id",type:"@type","@protected":!0,proof:{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"},EcdsaSecp256k1VerificationKey2019:{"@id":"https://w3id.org/security#EcdsaSecp256k1VerificationKey2019","@context":{"@protected":!0,id:"@id",type:"@type",controller:{"@id":"https://w3id.org/security#controller","@type":"@id"},revoked:{"@id":"https://w3id.org/security#revoked","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},blockchainAccountId:{"@id":"https://w3id.org/security#blockchainAccountId"},publicKeyJwk:{"@id":"https://w3id.org/security#publicKeyJwk","@type":"@json"},publicKeyBase58:{"@id":"https://w3id.org/security#publicKeyBase58"},publicKeyMultibase:{"@id":"https://w3id.org/security#publicKeyMultibase","@type":"https://w3id.org/security#multibase"}}},EcdsaSecp256k1Signature2019:{"@id":"https://w3id.org/security#EcdsaSecp256k1Signature2019","@context":{"@protected":!0,id:"@id",type:"@type",challenge:"https://w3id.org/security#challenge",created:{"@id":"http://purl.org/dc/terms/created","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},domain:"https://w3id.org/security#domain",expires:{"@id":"https://w3id.org/security#expiration","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},nonce:"https://w3id.org/security#nonce",proofPurpose:{"@id":"https://w3id.org/security#proofPurpose","@type":"@vocab","@context":{"@protected":!0,id:"@id",type:"@type",assertionMethod:{"@id":"https://w3id.org/security#assertionMethod","@type":"@id","@container":"@set"},authentication:{"@id":"https://w3id.org/security#authenticationMethod","@type":"@id","@container":"@set"},capabilityInvocation:{"@id":"https://w3id.org/security#capabilityInvocationMethod","@type":"@id","@container":"@set"},capabilityDelegation:{"@id":"https://w3id.org/security#capabilityDelegationMethod","@type":"@id","@container":"@set"},keyAgreement:{"@id":"https://w3id.org/security#keyAgreementMethod","@type":"@id","@container":"@set"}}},jws:{"@id":"https://w3id.org/security#jws"},verificationMethod:{"@id":"https://w3id.org/security#verificationMethod","@type":"@id"}}}}};const{purposes:{AssertionProofPurpose:ci,AuthenticationProofPurpose:hi}}=l;var li;!function(t){t.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",t.ensureVerificationMethodValidity="ensureVerificationMethodValidity",t.checkDocumentSignature="checkDocumentSignature"}(li||(li={}));class di extends E{verificationProcess=[li.retrieveVerificationMethodPublicKey,li.ensureVerificationMethodValidity,li.checkDocumentSignature];documentToVerify;issuer;proof;type="EcdsaSecp256k1Signature2019";verificationKey;verificationMethod;publicKey;proofPurpose;challenge;domain;proofPurposeMap;constructor(t){super(t),t.executeStep&&(this.executeStep=t.executeStep),this.documentToVerify=t.document,this.issuer=t.issuer,this.proof=t.proof,this.proofPurpose=t.proofPurpose??"assertionMethod",this.challenge=t.proofChallenge??"",this.domain=t.proofDomain,this.proofPurposeMap={authentication:hi,assertionMethod:ci},this.validateProofType()}async init(){}async verifyProof(){for(const t of this.verificationProcess){if(!this[t])return void console.error("verification logic for",t,"not implemented");await this[t]()}}async verifyIdentity(){}getProofVerificationSteps(e){return this.verificationProcess.map((r=>t.verifier.convertToVerificationSubsteps(e,r)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(t){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(t,e,r){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}validateProofType(){const t=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(t!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${t}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){e[this.documentToVerify.issuer]=this.getTargetVerificationMethodContainer();return function(t){return t in e?{contextUrl:null,document:e[t],documentUrl:t}:d.documentLoader(t)}}retrieveInitialDocument(){const t=r(this.documentToVerify);if(Array.isArray(t.proof)){const e=t.proof.find((t=>t.type===this.type));delete t.proof,t.proof=e}return t}getTargetVerificationMethodContainer(){if(this.issuer.didDocument){if(this.findVerificationMethod(this.issuer.didDocument.verificationMethod,this.issuer.didDocument.id))return this.issuer.didDocument}const t={...this.issuer};return delete t.didDocument,t}findVerificationMethod(t,e){return t.find((t=>t.id===this.proof.verificationMethod||e+t.id===this.proof.verificationMethod))??null}getErrorMessage(t){return t.error.errors[0].message}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(li.retrieveVerificationMethodPublicKey,(async()=>{if(this.verificationMethod=R(this.getTargetVerificationMethodContainer(),this.proof.verificationMethod),this.verificationMethod.publicKeyJwk&&!this.verificationMethod.publicKeyBase58){const t=A(this.verificationMethod.publicKeyJwk);this.verificationMethod.publicKeyBase58=k(t),this.documentToVerify["@context"].includes("https://www.w3.org/ns/credentials/v2")&&!this.documentToVerify["@context"].includes("https://w3id.org/security/suites/secp256k1-2019/v1")&&this.documentToVerify["@context"].push("https://w3id.org/security/suites/secp256k1-2019/v1")}this.publicKey=this.verificationMethod.publicKeyBase58;const t=ii.from({...this.verificationMethod});if(!t)throw new n(li.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(t.revoked)throw new n(li.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return t}),this.type)}async ensureVerificationMethodValidity(){await this.executeStep(li.ensureVerificationMethodValidity,(async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new n(li.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new n(li.ensureVerificationMethodValidity,"The verification key has been revoked")}),this.type)}async checkDocumentSignature(){await this.executeStep(li.checkDocumentSignature,(async()=>{const t=new fi({key:this.verificationKey});t.date=new Date(Date.now()).toISOString(),"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const e=await l.verify(this.retrieveInitialDocument(),{suite:t,purpose:new this.proofPurposeMap[this.proofPurpose]({controller:this.getTargetVerificationMethodContainer(),challenge:this.challenge,domain:this.domain}),documentLoader:this.generateDocumentLoader()});if(!e.verified)throw console.error(JSON.stringify(e,null,2)),new n(li.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(e)}`);console.log("Credential Secp256k1 signature successfully verified")}),this.type)}}export{di as default};
@@ -1,4 +1,4 @@
1
- import{d as e,f as t,e as i,V as r}from"./main.js";import{j as o}from"./jsonld-signatures-BbILf-Q7-DTp6__ud.js";import{j as n}from"./jsonld-B_Q2jvnp-BJ5uVeOU.js";import{d as s,e as a}from"./index-DZLKRa_V-D_IQzjvG.js";import{d as c,e as u}from"./base64url-Cy03LJLt-vkTPfQOh.js";import{E as d,f as p,v as y,s as h,g as f}from"./ed25519-key-pair.esm-DPOFpdJ2-BrwuS0Ia.js";import{S as l}from"./Suite-BmP2Qu19-D1ucdMDB.js";import"./tslib.es6--gQC4x5c-CmLYFWVC.js";import"./x25519-Kp6t9B5a-Dh8L0KYb.js";import"./_commonjs-dynamic-modules-COweQ1RR-BHR_E30J.js";
1
+ import{d as e,f as t,e as i,V as r}from"./main.js";import{j as o}from"./jsonld-signatures-BbHr1fSN-BSospRuX.js";import{j as n}from"./jsonld-BAMY2WqE-BJ5uVeOU.js";import{d as s,e as a}from"./index-DZLKRa_V-D_IQzjvG.js";import{d as c,e as u}from"./base64url-Cy03LJLt-vkTPfQOh.js";import{E as d,f as p,v as y,s as h,g as f}from"./ed25519-key-pair.esm-DQF2kkXh-XX5BXBcl.js";import{S as l}from"./Suite-BmP2Qu19-D1ucdMDB.js";import"./tslib.es6--gQC4x5c-CmLYFWVC.js";import"./x25519-hG3WOzPe-Dh8L0KYb.js";import"./_commonjs-dynamic-modules-COweQ1RR-BHR_E30J.js";
2
2
  /*!
3
3
  * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
4
4
  */function w({bytes:e,expectedLength:t=32,code:i}){if(!(e instanceof Uint8Array))throw new TypeError('"bytes" must be a Uint8Array.');if(e.length!==t){const e=new Error(`"bytes" must be a ${t}-byte Uint8Array.`);throw e.name="DataError",i&&(e.code=i),e}}
@@ -31,4 +31,4 @@ const{CONTEXT_URL:r}=i(1),o=i(0);e.exports={documentLoader(e){if(e!==r)throw new
31
31
  /*!
32
32
  * Copyright (c) 2020-2024 Digital Bazaar, Inc. All rights reserved.
33
33
  */
34
- const{suites:{LinkedDataSignature:O}}=o,L=C.constants.CONTEXT_URL;let D=class extends O{constructor({key:e,signer:t,verifier:i,proof:r,date:o,useNativeCanonize:n,canonizeOptions:s}={}){super({type:"Ed25519Signature2020",LDKeyClass:T,contextUrl:L,key:e,signer:t,verifier:i,proof:r,date:o,useNativeCanonize:n,canonizeOptions:s}),this.requiredKeyType="Ed25519VerificationKey2020"}async sign({verifyData:e,proof:t}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");const i=await this.signer.sign({data:e});return t.proofValue="z"+a(i),t}async verifySignature({verifyData:e,verificationMethod:t,proof:i}){const{proofValue:r}=i;if(!r||"string"!=typeof r)throw new TypeError('The proof does not include a valid "proofValue" property.');if("z"!==r[0])throw new Error("Only base58btc multibase encoding is supported.");const o=s(r.substr(1));let{verifier:n}=this;if(!n){n=(await p(t)).verifier()}return n.verify({data:e,signature:o})}async assertVerificationMethod({verificationMethod:e}){let t;if("Ed25519VerificationKey2020"!==e.type)throw new Error(`Unsupported key type "${e.type}".`);if(t=L,!_({document:e,contextUrl:t}))throw new TypeError(`The verification method (key) must contain "${t}" context.`);if(void 0!==e.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:e,documentLoader:t}){if(this.key)return this.key.export({publicKey:!0});let{verificationMethod:i}=e;if("object"==typeof i&&(i=i.id),!i)throw new Error('No "verificationMethod" found in proof.');const{document:r}=await t(i);i="string"==typeof r?JSON.parse(r):r;const o=await p(i);return i={...await o.export({publicKey:!0,includeContext:!0}),"@context":L,type:"Ed25519VerificationKey2020"},await this.assertVerificationMethod({verificationMethod:i}),i}async matchProof({proof:e,document:t,purpose:i,documentLoader:r}){if(!_({document:t,contextUrl:L}))return!1;if(!await super.matchProof({proof:e,document:t,purpose:i,documentLoader:r}))return!1;if(!this.key)return!0;const{verificationMethod:o}=e;return"object"==typeof o?o.id===this.key.id:o===this.key.id}};function _({document:e,contextUrl:t}){const i=e["@context"];return i===t||Array.isArray(i)&&i.includes(t)}D.CONTEXT_URL=L,D.CONTEXT=C.contexts.get(L);const{purposes:{AssertionProofPurpose:U,AuthenticationProofPurpose:j}}=o;var A;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(A||(A={}));class J extends l{verificationProcess=[A.retrieveVerificationMethodPublicKey,A.ensureVerificationMethodValidity,A.checkDocumentSignature];documentToVerify;issuer;proof;type="Ed25519Signature2020";verificationKey;verificationMethod;publicKey;proofPurpose;challenge;domain;proofPurposeMap;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,this.proofPurpose=e.proofPurpose??"assertionMethod",this.challenge=e.proofChallenge??"",this.domain=e.proofDomain,this.proofPurposeMap={authentication:j,assertionMethod:U},this.validateProofType()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map((i=>e.verifier.convertToVerificationSubsteps(t,i)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(e){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(e,t,i){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async publicKeyJwkToString(e){return await d.fingerprintFromPublicKey(e)}validateProofType(){const e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){t[this.documentToVerify.issuer]=this.issuer.didDocument;return function(e){return e in t?{contextUrl:null,document:t[e],documentUrl:e}:n.documentLoader(e)}}retrieveInitialDocument(){const e=i(this.documentToVerify);if(Array.isArray(e.proof)){const t=e.proof.find((e=>e.type===this.type));delete e.proof,e.proof=t}return delete e.didDocument,e}getTargetVerificationMethodContainer(){if(this.issuer.didDocument){if(this.findVerificationMethod(this.issuer.didDocument.verificationMethod,this.issuer.didDocument.id))return this.issuer.didDocument}const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,t){return e.find((e=>e.id===this.proof.verificationMethod||t+e.id===this.proof.verificationMethod))??null}getErrorMessage(e){return e.error.errors[0].message}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(A.retrieveVerificationMethodPublicKey,(async()=>{const e=this.getTargetVerificationMethodContainer();if(!e)throw new r(A.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");if(this.verificationMethod=this.findVerificationMethod(e.verificationMethod,e.id),!this.verificationMethod)throw new r(A.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");try{this.publicKey=this.verificationMethod.publicKeyMultibase??await this.publicKeyJwkToString(this.verificationMethod)}catch(e){console.error("ERROR retrieving Ed25519Signature2020 public key",e)}const t=await T.from({...this.verificationMethod});if(!t)throw new r(A.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(t.revoked)throw new r(A.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return t}),this.type)}async ensureVerificationMethodValidity(){await this.executeStep(A.ensureVerificationMethodValidity,(async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new r(A.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new r(A.ensureVerificationMethodValidity,"The verification key has been revoked")}),this.type)}async checkDocumentSignature(){await this.executeStep(A.checkDocumentSignature,(async()=>{const e=new D({key:this.verificationKey});e.date=new Date(Date.now()).toISOString(),"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const t=await o.verify(this.retrieveInitialDocument(),{suite:e,purpose:new this.proofPurposeMap[this.proofPurpose]({controller:this.getTargetVerificationMethodContainer(),challenge:this.challenge,domain:this.domain}),documentLoader:this.generateDocumentLoader()});if(!t.verified)throw console.error(JSON.stringify(t,null,2)),new r(A.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(t)}`);console.log("Credential Ed25519 signature successfully verified")}),this.type)}}export{J as default};
34
+ const{suites:{LinkedDataSignature:O}}=o,D=C.constants.CONTEXT_URL;let L=class extends O{constructor({key:e,signer:t,verifier:i,proof:r,date:o,useNativeCanonize:n,canonizeOptions:s}={}){super({type:"Ed25519Signature2020",LDKeyClass:T,contextUrl:D,key:e,signer:t,verifier:i,proof:r,date:o,useNativeCanonize:n,canonizeOptions:s}),this.requiredKeyType="Ed25519VerificationKey2020"}async sign({verifyData:e,proof:t}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");const i=await this.signer.sign({data:e});return t.proofValue="z"+a(i),t}async verifySignature({verifyData:e,verificationMethod:t,proof:i}){const{proofValue:r}=i;if(!r||"string"!=typeof r)throw new TypeError('The proof does not include a valid "proofValue" property.');if("z"!==r[0])throw new Error("Only base58btc multibase encoding is supported.");const o=s(r.substr(1));let{verifier:n}=this;if(!n){n=(await p(t)).verifier()}return n.verify({data:e,signature:o})}async assertVerificationMethod({verificationMethod:e}){let t;if("Ed25519VerificationKey2020"!==e.type)throw new Error(`Unsupported key type "${e.type}".`);if(t=D,!_({document:e,contextUrl:t}))throw new TypeError(`The verification method (key) must contain "${t}" context.`);if(void 0!==e.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:e,documentLoader:t}){if(this.key)return this.key.export({publicKey:!0});let{verificationMethod:i}=e;if("object"==typeof i&&(i=i.id),!i)throw new Error('No "verificationMethod" found in proof.');const{document:r}=await t(i);i="string"==typeof r?JSON.parse(r):r;const o=await p(i);return i={...await o.export({publicKey:!0,includeContext:!0}),"@context":D,type:"Ed25519VerificationKey2020"},await this.assertVerificationMethod({verificationMethod:i}),i}async matchProof({proof:e,document:t,purpose:i,documentLoader:r}){if(!_({document:t,contextUrl:D}))return!1;if(!await super.matchProof({proof:e,document:t,purpose:i,documentLoader:r}))return!1;if(!this.key)return!0;const{verificationMethod:o}=e;return"object"==typeof o?o.id===this.key.id:o===this.key.id}};function _({document:e,contextUrl:t}){const i=e["@context"];return i===t||Array.isArray(i)&&i.includes(t)}L.CONTEXT_URL=D,L.CONTEXT=C.contexts.get(D);const{purposes:{AssertionProofPurpose:U,AuthenticationProofPurpose:A}}=o;var j;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(j||(j={}));class J extends l{verificationProcess=[j.retrieveVerificationMethodPublicKey,j.ensureVerificationMethodValidity,j.checkDocumentSignature];documentToVerify;issuer;proof;type="Ed25519Signature2020";verificationKey;verificationMethod;publicKey;proofPurpose;challenge;domain;proofPurposeMap;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,this.proofPurpose=e.proofPurpose??"assertionMethod",this.challenge=e.proofChallenge??"",this.domain=e.proofDomain,this.proofPurposeMap={authentication:A,assertionMethod:U},this.validateProofType()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map((i=>e.verifier.convertToVerificationSubsteps(t,i)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(e){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(e,t,i){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async publicKeyJwkToString(e){return await d.fingerprintFromPublicKey(e)}validateProofType(){const e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){t[this.documentToVerify.issuer]=this.issuer.didDocument;return function(e){return e in t?{contextUrl:null,document:t[e],documentUrl:e}:n.documentLoader(e)}}retrieveInitialDocument(){const e=i(this.documentToVerify);if(Array.isArray(e.proof)){const t=e.proof.find((e=>e.type===this.type));delete e.proof,e.proof=t}return delete e.didDocument,e}getTargetVerificationMethodContainer(){if(this.issuer.didDocument){if(this.findVerificationMethod(this.issuer.didDocument.verificationMethod,this.issuer.didDocument.id))return this.issuer.didDocument}const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,t){return e.find((e=>e.id===this.proof.verificationMethod||t+e.id===this.proof.verificationMethod))??null}getErrorMessage(e){return e.error.errors[0].message}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(j.retrieveVerificationMethodPublicKey,(async()=>{const e=this.getTargetVerificationMethodContainer();if(!e)throw new r(j.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");if(this.verificationMethod=this.findVerificationMethod(e.verificationMethod,e.id),!this.verificationMethod)throw new r(j.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");try{this.publicKey=this.verificationMethod.publicKeyMultibase??await this.publicKeyJwkToString(this.verificationMethod)}catch(e){console.error("ERROR retrieving Ed25519Signature2020 public key",e)}const t=await T.from({...this.verificationMethod});if(!t)throw new r(j.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(t.revoked)throw new r(j.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return t}),this.type)}async ensureVerificationMethodValidity(){await this.executeStep(j.ensureVerificationMethodValidity,(async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new r(j.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new r(j.ensureVerificationMethodValidity,"The verification key has been revoked")}),this.type)}async checkDocumentSignature(){await this.executeStep(j.checkDocumentSignature,(async()=>{const e=new L({key:this.verificationKey});e.date=new Date(Date.now()).toISOString(),"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const t=await o.verify(this.retrieveInitialDocument(),{suite:e,purpose:new this.proofPurposeMap[this.proofPurpose]({controller:this.getTargetVerificationMethodContainer(),challenge:this.challenge,domain:this.domain}),documentLoader:this.generateDocumentLoader()});if(!t.verified)throw console.error(JSON.stringify(t,null,2)),new r(j.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(t)}`);console.log("Credential Ed25519 signature successfully verified")}),this.type)}}export{J as default};
@@ -1,4 +1,4 @@
1
- import{d as e,f as i,V as t}from"./main.js";import{D as o,r}from"./DataIntegrityProof-elCNKq16-DBDuaDNt.js";import{j as n}from"./jsonld-B_Q2jvnp-BJ5uVeOU.js";import{E as s,f as a}from"./ed25519-key-pair.esm-DPOFpdJ2-BrwuS0Ia.js";import{j as c}from"./jsonld-signatures-BbILf-Q7-DTp6__ud.js";import{S as d}from"./Suite-BmP2Qu19-D1ucdMDB.js";import{j as h}from"./keyUtils-ExMI0fmg-NVOmd8LH.js";import"./tslib.es6--gQC4x5c-CmLYFWVC.js";import"./x25519-Kp6t9B5a-Dh8L0KYb.js";import"./elliptic-BYqApR8Y-CKp7atgR.js";import"./index-DZLKRa_V-D_IQzjvG.js";import"./base64url-Cy03LJLt-vkTPfQOh.js";import"./_commonjs-dynamic-modules-COweQ1RR-BHR_E30J.js";import"./elliptic-4aZS_cwf-BpaNaVm0.js";
1
+ import{d as e,f as i,V as t}from"./main.js";import{D as o,r}from"./DataIntegrityProof-CsicZNrL-BkSRjzkI.js";import{j as n}from"./jsonld-BAMY2WqE-BJ5uVeOU.js";import{E as s,f as a}from"./ed25519-key-pair.esm-DQF2kkXh-XX5BXBcl.js";import{j as c}from"./jsonld-signatures-BbHr1fSN-BSospRuX.js";import{S as h}from"./Suite-BmP2Qu19-D1ucdMDB.js";import{j as d}from"./keyUtils-ue8EY3Op-DoHdKWgN.js";import"./tslib.es6--gQC4x5c-CmLYFWVC.js";import"./x25519-hG3WOzPe-Dh8L0KYb.js";import"./elliptic-6I21PEnR-CsYseRX1.js";import"./index-DZLKRa_V-D_IQzjvG.js";import"./base64url-Cy03LJLt-vkTPfQOh.js";import"./_commonjs-dynamic-modules-COweQ1RR-BHR_E30J.js";import"./elliptic-mDX7fQQx-BpaNaVm0.js";
2
2
  /*!
3
3
  * Copyright (c) 2023-2024 Digital Bazaar, Inc. All rights reserved.
4
4
  */
@@ -11,4 +11,4 @@ const f={canonize:async function(e,i){i={algorithm:"RDFC-1.0",format:"applicatio
11
11
  */,createVerifier:async function({verificationMethod:e}){return(await a(e)).verifier()},name:"eddsa-rdfc-2022",requiredAlgorithm:"Ed25519"},{purposes:{AssertionProofPurpose:u,AuthenticationProofPurpose:p}}=c;
12
12
  /*!
13
13
  * Copyright (c) 2023 Digital Bazaar, Inc. All rights reserved.
14
- */var l;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(l||(l={}));class y extends d{verificationProcess=[l.retrieveVerificationMethodPublicKey,l.ensureVerificationMethodValidity,l.checkDocumentSignature];documentToVerify;issuer;proof;type="EddsaRdfc2022";cryptosuite="eddsa-rdfc-2022";verificationKey;verificationMethod;publicKey;proofPurpose;challenge;domain;proofPurposeMap;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,this.proofPurpose=e.proofPurpose??"assertionMethod",this.challenge=e.proofChallenge??"",this.domain=e.proofDomain,this.proofPurposeMap={authentication:p,assertionMethod:u},this.validateProofType()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(i){return this.verificationProcess.map((t=>e.verifier.convertToVerificationSubsteps(i,t)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(e){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(e,i,t){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async publicKeyJwkToString(e){return await s.fingerprintFromPublicKey(e)}validateProofType(){const e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if("DataIntegrityProof"!==e){if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}else{const e=this.proof.cryptosuite;if(!e)throw new Error(`Malformed proof passed. With DataIntegrityProof a cryptosuite must be defined. Expected: ${this.cryptosuite}`);if(e!==this.cryptosuite)throw new Error(`Incompatible proof cryptosuite passed. Expected: ${this.cryptosuite}, Got: ${e}`)}}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){i[this.documentToVerify.issuer]=this.issuer.didDocument,i[this.proof.verificationMethod]=this.getMultikeyRepresentation();return function(e){return e in i?{contextUrl:null,document:i[e],documentUrl:e}:n.documentLoader(e)}}getErrorMessage(e){return e.error.errors[0].message}getTargetVerificationMethodContainer(){if(this.issuer.didDocument){if(this.findVerificationMethod(this.issuer.didDocument.verificationMethod,this.issuer.didDocument.id))return this.issuer.didDocument}const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,i){return e.find((e=>e.id===this.proof.verificationMethod||i+e.id===this.proof.verificationMethod))??null}getMultikeyRepresentation(){return{"@context":"https://w3id.org/security/multikey/v1",type:"Multikey",publicKeyMultibase:h(this.verificationMethod.publicKeyJwk),id:"string"==typeof this.verificationMethod.id?this.verificationMethod.id:void 0,controller:"string"==typeof this.verificationMethod.controller?this.verificationMethod.controller:void 0}}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(l.retrieveVerificationMethodPublicKey,(async()=>{const e=this.getTargetVerificationMethodContainer();if(!e)throw new t(l.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");if(this.verificationMethod=this.findVerificationMethod(e.verificationMethod,e.id),!this.verificationMethod)throw new t(l.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");try{this.publicKey=this.verificationMethod.publicKeyMultibase??await this.publicKeyJwkToString(this.verificationMethod)}catch(e){console.error("ERROR retrieving Ed25519Signature2020 public key",e)}const i=await a({...this.verificationMethod});if(!i)throw new t(l.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(i.revoked)throw new t(l.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return i}),this.type)}async ensureVerificationMethodValidity(){await this.executeStep(l.ensureVerificationMethodValidity,(async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new t(l.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new t(l.ensureVerificationMethodValidity,"The verification key has been revoked")}),this.type)}async checkDocumentSignature(){await this.executeStep(l.checkDocumentSignature,(async()=>{const e=new o({cryptosuite:f}),i=await c.verify(this.documentToVerify,{suite:e,purpose:new this.proofPurposeMap[this.proofPurpose]({controller:this.getTargetVerificationMethodContainer(),challenge:this.challenge,domain:this.domain}),documentLoader:this.generateDocumentLoader()});if(!i.verified)throw console.error(JSON.stringify(i,null,2)),new t(l.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(i)}`);console.log("Credential EddsaRdfc2022 signature successfully verified")}),this.type)}}export{y as default};
14
+ */var l;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(l||(l={}));class y extends h{verificationProcess=[l.retrieveVerificationMethodPublicKey,l.ensureVerificationMethodValidity,l.checkDocumentSignature];documentToVerify;issuer;proof;type="EddsaRdfc2022";cryptosuite="eddsa-rdfc-2022";verificationKey;verificationMethod;publicKey;proofPurpose;challenge;domain;proofPurposeMap;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,this.proofPurpose=e.proofPurpose??"assertionMethod",this.challenge=e.proofChallenge??"",this.domain=e.proofDomain,this.proofPurposeMap={authentication:p,assertionMethod:u},this.validateProofType()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(i){return this.verificationProcess.map((t=>e.verifier.convertToVerificationSubsteps(i,t)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(e){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(e,i,t){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async publicKeyJwkToString(e){return await s.fingerprintFromPublicKey(e)}validateProofType(){const e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if("DataIntegrityProof"!==e){if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}else{const e=this.proof.cryptosuite;if(!e)throw new Error(`Malformed proof passed. With DataIntegrityProof a cryptosuite must be defined. Expected: ${this.cryptosuite}`);if(e!==this.cryptosuite)throw new Error(`Incompatible proof cryptosuite passed. Expected: ${this.cryptosuite}, Got: ${e}`)}}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){i[this.documentToVerify.issuer]=this.issuer.didDocument,i[this.proof.verificationMethod]=this.getMultikeyRepresentation();return function(e){return e in i?{contextUrl:null,document:i[e],documentUrl:e}:n.documentLoader(e)}}getErrorMessage(e){return e.error.errors[0].message}getTargetVerificationMethodContainer(){if(this.issuer.didDocument){if(this.findVerificationMethod(this.issuer.didDocument.verificationMethod,this.issuer.didDocument.id))return this.issuer.didDocument}const e={...this.issuer};return delete e.didDocument,e}findVerificationMethod(e,i){return e.find((e=>e.id===this.proof.verificationMethod||i+e.id===this.proof.verificationMethod))??null}getMultikeyRepresentation(){return{"@context":"https://w3id.org/security/multikey/v1",type:"Multikey",publicKeyMultibase:d(this.verificationMethod.publicKeyJwk),id:"string"==typeof this.verificationMethod.id?this.verificationMethod.id:void 0,controller:"string"==typeof this.verificationMethod.controller?this.verificationMethod.controller:void 0}}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(l.retrieveVerificationMethodPublicKey,(async()=>{const e=this.getTargetVerificationMethodContainer();if(!e)throw new t(l.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");if(this.verificationMethod=this.findVerificationMethod(e.verificationMethod,e.id),!this.verificationMethod)throw new t(l.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");try{this.publicKey=this.verificationMethod.publicKeyMultibase??await this.publicKeyJwkToString(this.verificationMethod)}catch(e){console.error("ERROR retrieving Ed25519Signature2020 public key",e)}const i=await a({...this.verificationMethod});if(!i)throw new t(l.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(i.revoked)throw new t(l.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return i}),this.type)}async ensureVerificationMethodValidity(){await this.executeStep(l.ensureVerificationMethodValidity,(async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new t(l.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new t(l.ensureVerificationMethodValidity,"The verification key has been revoked")}),this.type)}async checkDocumentSignature(){await this.executeStep(l.checkDocumentSignature,(async()=>{const e=new o({cryptosuite:f}),i=await c.verify(this.documentToVerify,{suite:e,purpose:new this.proofPurposeMap[this.proofPurpose]({controller:this.getTargetVerificationMethodContainer(),challenge:this.challenge,domain:this.domain}),documentLoader:this.generateDocumentLoader()});if(!i.verified)throw console.error(JSON.stringify(i,null,2)),new t(l.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(i)}`);console.log("Credential EddsaRdfc2022 signature successfully verified")}),this.type)}}export{y as default};
@@ -1 +1 @@
1
- import{d as e,r as t,V as i,a as s,b as r,e as o,f as a}from"./main.js";import"./pako.esm-BGRKTPxS-UdHShO7y.js";import{j as n}from"./jsonld-B_Q2jvnp-BJ5uVeOU.js";import{s as c}from"./sha256-u2xsd4MQ-C1PUWFZm.js";import{e as h}from"./ensureValidIssuingKey-BMVCi2T2-BdV46XBb.js";import"./index-BS134367-Dgus2xdV.js";import{S as u}from"./Suite-BmP2Qu19-D1ucdMDB.js";function p(e){e=e.trim();const t=[];for(let i=0;i<e.length;i+=2)t.push(parseInt(e.substring(i,i+2),16));return t}function f(e){const t=o(e);return"proof"in t?function(e){const t=o(e);if(!Array.isArray(e.proof))return delete t.proof,t;const i=e.proof.find((e=>"ChainedProof2021"!==e.type));return t.proof=i,t}(t):("signature"in t&&delete t.signature,t)}async function l(e){e["@context"].find((e=>r(e)&&"@vocab"in e))||e["@context"].push({"@vocab":"http://fallback.org/"});const t=f(e),o={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return e in a?{contextUrl:null,document:a[e],documentUrl:e}:n.documentLoader(e)}};let h;try{h=await n.normalize(t,o)}catch(e){throw console.error(e),new i("computeLocalHash",s("errors","failedJsonLdNormalization"))}const u=function(e){const t=e.split("\n"),i=/<http:\/\/fallback\.org\/(.*)>/,s=t.map((e=>i.exec(e))).filter((e=>null!=e));if(s.length>0){const e=s.map((e=>e[1])).sort();return Array.from(new Set(e))}return null}(h);if(u)throw new i("computeLocalHash",`${s("errors","foundUnmappedFields")}: ${u.join(", ")}`);return c(function(e){const t=[];for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);s<128?t.push(s):s<2048?t.push(192|s>>6,128|63&s):s<55296||s>=57344?t.push(224|s>>12,128|s>>6&63,128|63&s):(i++,s=65536+((1023&s)<<10|1023&e.charCodeAt(i)),t.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|63&s))}return t}(h))}var d;!function(e){e.getTransactionId="getTransactionId",e.computeLocalHash="computeLocalHash",e.fetchRemoteHash="fetchRemoteHash",e.parseIssuerKeys="parseIssuerKeys",e.compareHashes="compareHashes",e.checkMerkleRoot="checkMerkleRoot",e.checkReceipt="checkReceipt",e.checkAuthenticity="checkAuthenticity"}(d||(d={}));class y extends u{verificationProcess=[d.getTransactionId,d.computeLocalHash,d.fetchRemoteHash,d.compareHashes,d.checkMerkleRoot,d.checkReceipt,d.parseIssuerKeys,d.checkAuthenticity];transactionId;localHash;documentToVerify;txData;chain;explorerAPIs;receipt;issuerPublicKeyList;issuer;proof;type="MerkleProof2017";constructor(t){super(t),t.executeStep&&(this.executeStep=t.executeStep),this.documentToVerify=t.document,this.explorerAPIs=t.explorerAPIs,this.issuer=t.issuer,this.proof=t.proof,this.validateProofType(),this.receipt=this.documentToVerify.signature,this.chain=e.certificates.getChain("",this.receipt),this.transactionId=e.certificates.getTransactionId(this.receipt),this.adaptVerificationProcessToChain()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map((i=>e.verifier.convertToVerificationSubsteps(t,i)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return e.chains.isMockChain(this.chain)?"This mock chain does not support issuing addresses":this.txData?this.txData.issuingAddress:void console.error("Trying to access issuing address when txData not available yet. Did you run the `verify` method yet?")}getIssuerName(){return this.issuer.name}getIssuerProfileDomain(){const e=new URL(this.getIssuerProfileUrl());return e?.hostname}getIssuerProfileUrl(){return this.issuer.id}getSigningDate(){return this.documentToVerify.issuedOn}getChain(){return this.chain}getReceipt(){return this.receipt}getTransactionIdString(){return e.certificates.getTransactionId(this.getReceipt())}getTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}getRawTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}validateProofType(){if(this.proof.type[0]!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${this.proof.type[0]}`)}adaptVerificationProcessToChain(){e.chains.isMockChain(this.chain)&&(t(this.verificationProcess,d.getTransactionId),t(this.verificationProcess,d.fetchRemoteHash),t(this.verificationProcess,d.parseIssuerKeys),t(this.verificationProcess,d.checkMerkleRoot),t(this.verificationProcess,d.checkAuthenticity))}async executeStep(e,t,i){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async getTransactionId(){await this.executeStep(d.getTransactionId,(()=>function(e){if("string"==typeof e&&e.length>0)return e;throw new i("getTransactionId",s("errors","isTransactionIdValid"))}(this.transactionId)),this.type)}async computeLocalHash(){this.localHash=await this.executeStep(d.computeLocalHash,(async()=>await l(this.documentToVerify)),this.type)}async fetchRemoteHash(){this.txData=await this.executeStep(d.fetchRemoteHash,(async()=>await e.verifier.lookForTx({transactionId:this.transactionId,chain:this.chain.code,explorerAPIs:this.explorerAPIs})),this.type)}async compareHashes(){await this.executeStep(d.compareHashes,(()=>function(e,t){if(e!==t)throw new i("compareHashes",s("errors","ensureHashesEqual"));return!0}(this.localHash,this.receipt.targetHash)),this.type)}async checkMerkleRoot(){await this.executeStep(d.checkMerkleRoot,(()=>function(e,t){if(e!==t)throw new i("checkMerkleRoot",s("errors","ensureMerkleRootEqual"));return!0}(this.receipt.merkleRoot,this.txData.remoteHash)),this.type)}async checkReceipt(){await this.executeStep(d.checkReceipt,(()=>{!function(e){let t=e.targetHash;const r=e.merkleRoot;try{const s=e.proof??e.path;if(s)for(const e in s){const r=s[e];let o;if(void 0!==r.left)o=p(`${r.left}${t}`),t=c(o);else{if(void 0===r.right)throw new i("checkReceipt","Trigger catch error.");o=p(`${t}${r.right}`),t=c(o)}}}catch(e){throw new i("checkReceipt",s("errors","ensureValidReceipt"))}if(t!==r)throw new i("checkReceipt",s("errors","invalidMerkleReceipt"))}(this.receipt)}),this.type)}async parseIssuerKeys(){this.issuerPublicKeyList=await this.executeStep(d.parseIssuerKeys,(()=>e.verifier.parseIssuerKeys(this.issuer)),this.type)}async checkAuthenticity(){await this.executeStep(d.checkAuthenticity,(()=>{h(this.issuerPublicKeyList,this.txData.issuingAddress,this.txData.time)}),this.type)}}export{y as default};
1
+ import{d as e,r as t,V as i,a as s,b as r,e as o,f as a}from"./main.js";import"./pako.esm-BGRKTPxS-UdHShO7y.js";import{j as n}from"./jsonld-BAMY2WqE-BJ5uVeOU.js";import{s as c}from"./sha256-Bwge_vjI-C1PUWFZm.js";import{e as h}from"./ensureValidIssuingKey-wTUvNuDH-BdV46XBb.js";import"./index-Gr4i_Ned-Dgus2xdV.js";import{S as u}from"./Suite-BmP2Qu19-D1ucdMDB.js";function p(e){e=e.trim();const t=[];for(let i=0;i<e.length;i+=2)t.push(parseInt(e.substring(i,i+2),16));return t}function f(e){const t=o(e);return"proof"in t?function(e){const t=o(e);if(!Array.isArray(e.proof))return delete t.proof,t;const i=e.proof.find((e=>"ChainedProof2021"!==e.type));return t.proof=i,t}(t):("signature"in t&&delete t.signature,t)}async function l(e){e["@context"].find((e=>r(e)&&"@vocab"in e))||e["@context"].push({"@vocab":"http://fallback.org/"});const t=f(e),o={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return e in a?{contextUrl:null,document:a[e],documentUrl:e}:n.documentLoader(e)}};let h;try{h=await n.normalize(t,o)}catch(e){throw console.error(e),new i("computeLocalHash",s("errors","failedJsonLdNormalization"))}const u=function(e){const t=e.split("\n"),i=/<http:\/\/fallback\.org\/(.*)>/,s=t.map((e=>i.exec(e))).filter((e=>null!=e));if(s.length>0){const e=s.map((e=>e[1])).sort();return Array.from(new Set(e))}return null}(h);if(u)throw new i("computeLocalHash",`${s("errors","foundUnmappedFields")}: ${u.join(", ")}`);return c(function(e){const t=[];for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);s<128?t.push(s):s<2048?t.push(192|s>>6,128|63&s):s<55296||s>=57344?t.push(224|s>>12,128|s>>6&63,128|63&s):(i++,s=65536+((1023&s)<<10|1023&e.charCodeAt(i)),t.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|63&s))}return t}(h))}var d;!function(e){e.getTransactionId="getTransactionId",e.computeLocalHash="computeLocalHash",e.fetchRemoteHash="fetchRemoteHash",e.parseIssuerKeys="parseIssuerKeys",e.compareHashes="compareHashes",e.checkMerkleRoot="checkMerkleRoot",e.checkReceipt="checkReceipt",e.checkAuthenticity="checkAuthenticity"}(d||(d={}));class y extends u{verificationProcess=[d.getTransactionId,d.computeLocalHash,d.fetchRemoteHash,d.compareHashes,d.checkMerkleRoot,d.checkReceipt,d.parseIssuerKeys,d.checkAuthenticity];transactionId;localHash;documentToVerify;txData;chain;explorerAPIs;receipt;issuerPublicKeyList;issuer;proof;type="MerkleProof2017";constructor(t){super(t),t.executeStep&&(this.executeStep=t.executeStep),this.documentToVerify=t.document,this.explorerAPIs=t.explorerAPIs,this.issuer=t.issuer,this.proof=t.proof,this.validateProofType(),this.receipt=this.documentToVerify.signature,this.chain=e.certificates.getChain("",this.receipt),this.transactionId=e.certificates.getTransactionId(this.receipt),this.adaptVerificationProcessToChain()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map((i=>e.verifier.convertToVerificationSubsteps(t,i)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return e.chains.isMockChain(this.chain)?"This mock chain does not support issuing addresses":this.txData?this.txData.issuingAddress:void console.error("Trying to access issuing address when txData not available yet. Did you run the `verify` method yet?")}getIssuerName(){return this.issuer.name}getIssuerProfileDomain(){const e=new URL(this.getIssuerProfileUrl());return e?.hostname}getIssuerProfileUrl(){return this.issuer.id}getSigningDate(){return this.documentToVerify.issuedOn}getChain(){return this.chain}getReceipt(){return this.receipt}getTransactionIdString(){return e.certificates.getTransactionId(this.getReceipt())}getTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}getRawTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}validateProofType(){if(this.proof.type[0]!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${this.proof.type[0]}`)}adaptVerificationProcessToChain(){e.chains.isMockChain(this.chain)&&(t(this.verificationProcess,d.getTransactionId),t(this.verificationProcess,d.fetchRemoteHash),t(this.verificationProcess,d.parseIssuerKeys),t(this.verificationProcess,d.checkMerkleRoot),t(this.verificationProcess,d.checkAuthenticity))}async executeStep(e,t,i){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async getTransactionId(){await this.executeStep(d.getTransactionId,(()=>function(e){if("string"==typeof e&&e.length>0)return e;throw new i("getTransactionId",s("errors","isTransactionIdValid"))}(this.transactionId)),this.type)}async computeLocalHash(){this.localHash=await this.executeStep(d.computeLocalHash,(async()=>await l(this.documentToVerify)),this.type)}async fetchRemoteHash(){this.txData=await this.executeStep(d.fetchRemoteHash,(async()=>await e.verifier.lookForTx({transactionId:this.transactionId,chain:this.chain.code,explorerAPIs:this.explorerAPIs})),this.type)}async compareHashes(){await this.executeStep(d.compareHashes,(()=>function(e,t){if(e!==t)throw new i("compareHashes",s("errors","ensureHashesEqual"));return!0}(this.localHash,this.receipt.targetHash)),this.type)}async checkMerkleRoot(){await this.executeStep(d.checkMerkleRoot,(()=>function(e,t){if(e!==t)throw new i("checkMerkleRoot",s("errors","ensureMerkleRootEqual"));return!0}(this.receipt.merkleRoot,this.txData.remoteHash)),this.type)}async checkReceipt(){await this.executeStep(d.checkReceipt,(()=>{!function(e){let t=e.targetHash;const r=e.merkleRoot;try{const s=e.proof??e.path;if(s)for(const e in s){const r=s[e];let o;if(void 0!==r.left)o=p(`${r.left}${t}`),t=c(o);else{if(void 0===r.right)throw new i("checkReceipt","Trigger catch error.");o=p(`${t}${r.right}`),t=c(o)}}}catch(e){throw new i("checkReceipt",s("errors","ensureValidReceipt"))}if(t!==r)throw new i("checkReceipt",s("errors","invalidMerkleReceipt"))}(this.receipt)}),this.type)}async parseIssuerKeys(){this.issuerPublicKeyList=await this.executeStep(d.parseIssuerKeys,(()=>e.verifier.parseIssuerKeys(this.issuer)),this.type)}async checkAuthenticity(){await this.executeStep(d.checkAuthenticity,(()=>{h(this.issuerPublicKeyList,this.txData.issuingAddress,this.txData.time)}),this.type)}}export{y as default};