@blockcerts/blockcerts-verifier 1.70.1 → 1.71.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle-stats.html +13 -13
- package/dist/DataIntegrityProof-elCNKq16-DBDuaDNt.js +7 -0
- package/dist/EcdsaSd2023-B0XPAIp6-K61axvBA.js +30 -0
- package/dist/EcdsaSecp256k1Signature2019-BHgoxmKI-DT2qHZod.js +1 -0
- package/dist/Ed25519Signature2020-BQsESRnS-TKZI_1AX.js +34 -0
- package/dist/EddsaRdfc2022-DQKzWHK4-BILzDBp-.js +14 -0
- package/dist/{HashlinkVerifier-mEn5oMxx-0x0OtiE4.js → HashlinkVerifier-BsVlaml5-B4Niv2-b.js} +2 -2
- package/dist/{MerkleProof2017-Cgbk--lC-CKvOfXrT.js → MerkleProof2017-CYM8CJHB-FYpMvld0.js} +1 -1
- package/dist/MerkleProof2019-BLrywo8h-Bo9rH2Eq.js +13 -0
- package/dist/{checkCredentialSchemaConformity-CuuMYTl6-DqE6I7JD.js → checkCredentialSchemaConformity-CKNtOu_t-B9iaCRUE.js} +1 -1
- package/dist/{controlVerificationMethod-C87jwGUr-CpVyq-8H.js → controlVerificationMethod-B4TgLED0-BGpxLjMq.js} +1 -1
- package/dist/{did-key-common.esm-D1RQn0yL-kJBnihy7.js → did-key-common.esm-BIftA62j-hVrUMxjy.js} +3 -3
- package/dist/{did-key-ed25519.esm-0v03exJh-COIOTeQ5.js → did-key-ed25519.esm-Drn3Y7PF-CqD0ifNk.js} +1 -1
- package/dist/{did-key-secp256k1.esm-Cs0ZCHjg-B35GrJww.js → did-key-secp256k1.esm-DH-f3o5q-C66E7IxB.js} +1 -1
- package/dist/{downloadPDF-CWa3ZYVl.js → downloadPDF-eGAsbwF0.js} +1 -1
- package/dist/ed25519-key-pair.esm-DPOFpdJ2-BrwuS0Ia.js +25 -0
- package/dist/{elliptic-HXNc7riQ-DrFZxkx3.js → elliptic-4aZS_cwf-BpaNaVm0.js} +1 -1
- package/dist/elliptic-BYqApR8Y-CKp7atgR.js +1 -0
- package/dist/{index-BJkS6Wwm-C8oVP6LM.js → index-BgTFEYQ4-DMaz98iZ.js} +7 -7
- package/dist/index-lyuTDW_o-nyi7dklX.js +1 -0
- package/dist/{index.es-kH7iskh8.js → index.es-B7xY76Pb.js} +2 -2
- package/dist/{jsonld-CMQE_cGn-899pOqB6.js → jsonld-B_Q2jvnp-BJ5uVeOU.js} +1 -1
- package/dist/{jsonld-signatures-ZtLxJmqT-B0W14Jb0.js → jsonld-signatures-BbILf-Q7-DTp6__ud.js} +1 -1
- package/dist/keyUtils-ExMI0fmg-NVOmd8LH.js +1 -0
- package/dist/main.js +116 -116
- package/dist/{retrieveVerificationMethodPublicKey-nmb3CCVx-DA6ovQri.js → retrieveVerificationMethodPublicKey-C5Gafl1E-Lv4waRy7.js} +1 -1
- package/dist/verifyIssuerProfile-DCJyz3ho-BwuCK9F3.js +1 -0
- package/dist/{x25519-CbZcE2Ac-NSl6svWQ.js → x25519-Kp6t9B5a-Dh8L0KYb.js} +1 -1
- package/package.json +4 -4
- package/dist/EcdsaSd2023-BDSl7Ei2-BKyD2rP9.js +0 -35
- package/dist/EcdsaSecp256k1Signature2019-Bk8_LQ8c-BqdRm-Jv.js +0 -1
- package/dist/Ed25519Signature2020-fyWut63D-R9eZ2oN0.js +0 -58
- package/dist/MerkleProof2019-Dhsn349H-DFyc-5gT.js +0 -3
- package/dist/elliptic-CRAl7yyq-DbLzV4aB.js +0 -1
- package/dist/verifyIssuerProfile-CYqfuwV1-DeQqsjiM.js +0 -1
- /package/dist/{checkRevocationStatusList2021-UjTyRcl_-BEBD8TO8.js → checkRevocationStatusList2021-CMAVXAVE-BEBD8TO8.js} +0 -0
- /package/dist/{ensureNotRevoked-CdrYFvh7-DvMIgM4L.js → ensureNotRevoked-hGps0prO-DvMIgM4L.js} +0 -0
- /package/dist/{ensureValidIssuingKey-n3jD_OlE-BdV46XBb.js → ensureValidIssuingKey-BMVCi2T2-BdV46XBb.js} +0 -0
- /package/dist/{index-BcfLkJHS-Dgus2xdV.js → index-BS134367-Dgus2xdV.js} +0 -0
- /package/dist/{index-DYND9Svl-C0eXpZGn.js → index-CQYVZlSE-C0eXpZGn.js} +0 -0
- /package/dist/{sha256-CN3v2fAD-C1PUWFZm.js → sha256-u2xsd4MQ-C1PUWFZm.js} +0 -0
- /package/dist/{webcrypto.es-hNUMWa8--BnVhHKeM.js → webcrypto.es-DpqeDikX-BnVhHKeM.js} +0 -0
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import{d as e,f as t,e as r,V as n,q as i,B as o,i as a}from"./main.js";import{j as s}from"./jsonld-signatures-ZtLxJmqT-B0W14Jb0.js";import{j as c}from"./jsonld-CMQE_cGn-899pOqB6.js";import{d as u,e as f}from"./index-DZLKRa_V-D_IQzjvG.js";import{d as l,e as y}from"./base64url-Cy03LJLt-vkTPfQOh.js";import{_ as p}from"./tslib.es6--gQC4x5c-CmLYFWVC.js";import{e as h,x as d}from"./x25519-CbZcE2Ac-NSl6svWQ.js";import{S as w}from"./Suite-BmP2Qu19-D1ucdMDB.js";import"./_commonjs-dynamic-modules-COweQ1RR-BHR_E30J.js";
|
|
2
|
-
/*!
|
|
3
|
-
* Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
|
|
4
|
-
*/function v({bytes:e,expectedLength:t=32,code:r}){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",r&&(e.code=r),e}}
|
|
5
|
-
/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const g=BigInt(0),b=BigInt(1),m=BigInt(2),K=BigInt(8),x=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),E=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:x,n:x,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),k=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),M=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742");const T=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),A=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),P=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),B=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class S{constructor(e,t,r,n){this.x=e,this.y=t,this.z=r,this.t=n}static fromAffine(e){if(!(e instanceof I))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(I.ZERO)?S.ZERO:new S(e.x,e.y,b,$(e.x*e.y))}static toAffineBatch(e){const t=function(e,t=E.P){const r=new Array(e.length),n=Z(e.reduce(((e,n,i)=>n===g?e:(r[i]=e,$(e*n,t))),b),t);return e.reduceRight(((e,n,i)=>n===g?e:(r[i]=$(e*r[i],t),$(e*n,t))),n),r}(e.map((e=>e.z)));return e.map(((e,r)=>e.toAffine(t[r])))}static normalizeZ(e){return this.toAffineBatch(e).map(this.fromAffine)}equals(e){U(e);const{x:t,y:r,z:n}=this,{x:i,y:o,z:a}=e,s=$(t*a),c=$(i*n),u=$(r*a),f=$(o*n);return s===c&&u===f}negate(){return new S($(-this.x),this.y,this.z,$(-this.t))}double(){const{x:e,y:t,z:r}=this,{a:n}=E,i=$(e*e),o=$(t*t),a=$(m*$(r*r)),s=$(n*i),c=e+t,u=$($(c*c)-i-o),f=s+o,l=f-a,y=s-o,p=$(u*l),h=$(f*y),d=$(u*y),w=$(l*f);return new S(p,h,w,d)}add(e){U(e);const{x:t,y:r,z:n,t:i}=this,{x:o,y:a,z:s,t:c}=e,u=$((r-t)*(a+o)),f=$((r+t)*(a-o)),l=$(f-u);if(l===g)return this.double();const y=$(n*m*c),p=$(i*m*s),h=p+y,d=f+u,w=p-y,v=$(h*l),b=$(d*w),K=$(h*w),x=$(l*d);return new S(v,b,x,K)}subtract(e){return this.add(e.negate())}precomputeWindow(e){const t=1+256/e,r=[];let n=this,i=n;for(let o=0;o<t;o++){i=n,r.push(i);for(let t=1;t<2**(e-1);t++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(e,t){!t&&this.equals(S.BASE)&&(t=I.BASE);const r=t&&t._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=t&&V.get(t);n||(n=this.precomputeWindow(r),t&&1!==r&&(n=S.normalizeZ(n),V.set(t,n)));let i=S.ZERO,o=S.BASE;const a=1+256/r,s=2**(r-1),c=BigInt(2**r-1),u=2**r,f=BigInt(r);for(let t=0;t<a;t++){const r=t*s;let a=Number(e&c);e>>=f,a>s&&(a-=u,e+=b);const l=r,y=r+Math.abs(a)-1,p=t%2!=0,h=a<0;0===a?o=o.add(O(p,n[l])):i=i.add(O(h,n[y]))}return S.normalizeZ([i,o])[0]}multiply(e,t){return this.wNAF(re(e,E.l),t)}multiplyUnsafe(e){let t=re(e,E.l,!1);const r=S.BASE,n=S.ZERO;if(t===g)return n;if(this.equals(n)||t===b)return this;if(this.equals(r))return this.wNAF(t);let i=n,o=this;for(;t>g;)t&b&&(i=i.add(o)),o=o.double(),t>>=b;return i}isSmallOrder(){return this.multiplyUnsafe(E.h).equals(S.ZERO)}isTorsionFree(){let e=this.multiplyUnsafe(E.l/m).double();return E.l%m&&(e=e.add(this)),e.equals(S.ZERO)}toAffine(e){const{x:t,y:r,z:n}=this,i=this.equals(S.ZERO);null==e&&(e=i?K:Z(n));const o=$(t*e),a=$(r*e),s=$(n*e);if(i)return I.ZERO;if(s!==b)throw new Error("invZ was invalid");return new I(o,a)}fromRistrettoBytes(){_()}toRistrettoBytes(){_()}fromRistrettoHash(){_()}}function O(e,t){const r=t.negate();return e?r:t}function U(e){if(!(e instanceof S))throw new TypeError("ExtendedPoint expected")}function L(e){if(!(e instanceof j))throw new TypeError("RistrettoPoint expected")}function _(){throw new Error("Legacy method: switch to RistrettoPoint")}S.BASE=new S(E.Gx,E.Gy,b,$(E.Gx*E.Gy)),S.ZERO=new S(g,b,b,g);class j{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){const{d:t}=E,r=$(M*e*e),n=$((r+b)*P);let i=BigInt(-1);const o=$((i-t*r)*$(r+t));let{isValid:a,value:s}=Q(n,o),c=$(s*e);F(c)||(c=$(-c)),a||(s=c),a||(i=r);const u=$(i*(r-b)*B-o),f=s*s,l=$((s+s)*o),y=$(u*T),p=$(b-f),h=$(b+f);return new S($(l*h),$(p*y),$(y*h),$(l*p))}static hashToCurve(e){const t=G((e=te(e,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(t),n=G(e.slice(32,64)),i=this.calcElligatorRistrettoMap(n);return new j(r.add(i))}static fromHex(e){e=te(e,32);const{a:t,d:r}=E,n="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",i=G(e);if(!function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}(W(i),e)||F(i))throw new Error(n);const o=$(i*i),a=$(b+t*o),s=$(b-t*o),c=$(a*a),u=$(s*s),f=$(t*r*c-u),{isValid:l,value:y}=Y($(f*u)),p=$(y*s),h=$(y*p*f);let d=$((i+i)*p);F(d)&&(d=$(-d));const w=$(a*h),v=$(d*w);if(!l||F(v)||w===g)throw new Error(n);return new j(new S(d,w,b,v))}toRawBytes(){let{x:e,y:t,z:r,t:n}=this.ep;const i=$($(r+t)*$(r-t)),o=$(e*t),a=$(o*o),{value:s}=Y($(i*a)),c=$(s*i),u=$(s*o),f=$(c*u*n);let l;if(F(n*f)){let r=$(t*M),n=$(e*M);e=r,t=n,l=$(c*A)}else l=u;F(e*f)&&(t=$(-t));let y=$((r-t)*l);return F(y)&&(y=$(-y)),W(y)}toHex(){return C(this.toRawBytes())}toString(){return this.toHex()}equals(e){L(e);const t=this.ep,r=e.ep,n=$(t.x*r.y)===$(t.y*r.x),i=$(t.y*r.y)===$(t.x*r.x);return n||i}add(e){return L(e),new j(this.ep.add(e.ep))}subtract(e){return L(e),new j(this.ep.subtract(e.ep))}multiply(e){return new j(this.ep.multiply(e))}multiplyUnsafe(e){return new j(this.ep.multiplyUnsafe(e))}}j.BASE=new j(S.BASE),j.ZERO=new j(S.ZERO);const V=new WeakMap;class I{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,V.delete(this)}static fromHex(e,t=!0){const{d:r,P:n}=E,i=(e=te(e,32)).slice();i[31]=-129&e[31];const o=X(i);if(t&&o>=n)throw new Error("Expected 0 < hex < P");if(!t&&o>=k)throw new Error("Expected 0 < hex < 2**256");const a=$(o*o),s=$(a-b),c=$(r*a+b);let{isValid:u,value:f}=Q(s,c);if(!u)throw new Error("Point.fromHex: invalid y coordinate");const l=(f&b)===b;return!!(128&e[31])!==l&&(f=$(-f)),new I(f,o)}static async fromPrivateKey(e){return(await ie(e)).point}toRawBytes(){const e=W(this.y);return e[31]|=this.x&b?128:0,e}toHex(){return C(this.toRawBytes())}toX25519(){const{y:e}=this;return W($((b+e)*Z(b-e)))}isTorsionFree(){return S.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new I($(-this.x),this.y)}add(e){return S.fromAffine(this).add(S.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return S.fromAffine(this).multiply(e,this).toAffine()}}I.BASE=new I(E.Gx,E.Gy),I.ZERO=new I(g,b);class R{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=te(e,64),r=I.fromHex(t.slice(0,32),!1),n=X(t.slice(32,64));return new R(r,n)}assertValidity(){const{r:e,s:t}=this;if(!(e instanceof I))throw new Error("Expected Point instance");return re(t,E.l,!1),this}toRawBytes(){const e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(W(this.s),32),e}toHex(){return C(this.toRawBytes())}}function N(...e){if(!e.every((e=>e instanceof Uint8Array)))throw new Error("Expected Uint8Array list");if(1===e.length)return e[0];const t=e.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}return r}const J=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function C(e){if(!(e instanceof Uint8Array))throw new Error("Uint8Array expected");let t="";for(let r=0;r<e.length;r++)t+=J[e[r]];return t}function D(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);if(e.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const t=new Uint8Array(e.length/2);for(let r=0;r<t.length;r++){const n=2*r,i=e.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t}function z(e){return D(e.toString(16).padStart(64,"0"))}function W(e){return z(e).reverse()}function F(e){return($(e)&b)===b}function X(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");return BigInt("0x"+C(Uint8Array.from(e).reverse()))}const q=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function G(e){return $(X(e)&q)}function $(e,t=E.P){const r=e%t;return r>=g?r:t+r}function Z(e,t=E.P){if(e===g||t<=g)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=$(e,t),n=t,i=g,o=b;for(;r!==g;){const e=n%r,t=i-o*(n/r);n=r,r=e,i=o,o=t}if(n!==b)throw new Error("invert: does not exist");return $(i,t)}function H(e,t){const{P:r}=E;let n=e;for(;t-- >g;)n*=n,n%=r;return n}function Q(e,t){const r=$(t*t*t),n=function(e){const{P:t}=E,r=BigInt(5),n=BigInt(10),i=BigInt(20),o=BigInt(40),a=BigInt(80),s=e*e%t*e%t,c=H(s,m)*s%t,u=H(c,b)*e%t,f=H(u,r)*u%t,l=H(f,n)*f%t,y=H(l,i)*l%t,p=H(y,o)*y%t,h=H(p,a)*p%t,d=H(h,a)*p%t,w=H(d,n)*f%t;return{pow_p_5_8:H(w,m)*e%t,b2:s}}(e*$(r*r*t)).pow_p_5_8;let i=$(e*r*n);const o=$(t*i*i),a=i,s=$(i*M),c=o===e,u=o===$(-e),f=o===$(-e*M);return c&&(i=a),(u||f)&&(i=s),F(i)&&(i=$(-i)),{isValid:c||u,value:i}}function Y(e){return Q(b,e)}function ee(e){return $(X(e),E.l)}function te(e,t){const r=e instanceof Uint8Array?Uint8Array.from(e):D(e);if("number"==typeof t&&r.length!==t)throw new Error(`Expected ${t} bytes`);return r}function re(e,t,r=!0){if(!t)throw new TypeError("Specify max value");if("number"==typeof e&&Number.isSafeInteger(e)&&(e=BigInt(e)),"bigint"==typeof e&&e<t)if(r){if(g<e)return e}else if(g<=e)return e;throw new TypeError("Expected valid scalar: 0 < scalar < max")}let ne;async function ie(e){return function(e){const t=((r=e.slice(0,32))[0]&=248,r[31]&=127,r[31]|=64,r);var r;const n=e.slice(32,64),i=ee(t),o=I.BASE.multiply(i),a=o.toRawBytes();return{head:t,prefix:n,scalar:i,point:o,pointBytes:a}}(await ce.sha512(function(e){if(32!==(e="bigint"==typeof e||"number"==typeof e?z(re(e,k)):te(e)).length)throw new Error("Expected 32 bytes");return e}(e)))}async function oe(e,t){e=te(e);const{prefix:r,scalar:n,pointBytes:i}=await ie(t),o=ee(await ce.sha512(r,e)),a=I.BASE.multiply(o),s=$(o+ee(await ce.sha512(a.toRawBytes(),i,e))*n,E.l);return new R(a,s).toRawBytes()}async function ae(e,t,r){const{r:n,SB:i,msg:o,pub:a}=function(e,t,r){t=te(t),r instanceof I||(r=I.fromHex(r,!1));const{r:n,s:i}=e instanceof R?e.assertValidity():R.fromHex(e);return{r:n,s:i,SB:S.BASE.multiplyUnsafe(i),pub:r,msg:t}}(e,t,r),s=await ce.sha512(n.toRawBytes(),a.toRawBytes(),o);return function(e,t,r,n){const i=ee(n),o=S.fromAffine(e).multiplyUnsafe(i);return S.fromAffine(t).add(o).subtract(r).multiplyUnsafe(E.h).equals(S.ZERO)}(a,n,i,s)}I.BASE._setWindowSize(8);const se={node:i,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},ce={bytesToHex:C,hexToBytes:D,concatBytes:N,getExtendedPublicKey:ie,mod:$,invert:Z,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar:e=>{if((e=te(e)).length<40||e.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return $(X(e),E.l-b)+b},randomBytes:(e=32)=>{if(se.web)return se.web.getRandomValues(new Uint8Array(e));if(se.node){const{randomBytes:t}=se.node;return new Uint8Array(t(e).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>ce.randomBytes(32),sha512:async(...e)=>{const t=N(...e);if(se.web){const e=await se.web.subtle.digest("SHA-512",t.buffer);return new Uint8Array(e)}if(se.node)return Uint8Array.from(se.node.createHash("sha512").update(t).digest());throw new Error("The environment doesn't have sha512 function")},precompute(e=8,t=I.BASE){const r=t.equals(I.BASE)?t:new I(t.x,t.y);return r._setWindowSize(e),r.multiply(m),r},sha512Sync:void 0};Object.defineProperties(ce,{sha512Sync:{configurable:!1,get:()=>ne,set(e){ne||(ne=e)}}});
|
|
6
|
-
/*!
|
|
7
|
-
* Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.
|
|
8
|
-
*/
|
|
9
|
-
const ue=globalThis.crypto;if(!ue.getRandomValues)throw new Error('Browser does not provide "crypto.getRandomValues".');var fe={async generateKeyPair(){const e=new Uint8Array(32);ue.getRandomValues(e);const t=await le(e);return e.fill(0),t},generateKeyPairFromSeed:le,sign:async(e,t)=>oe(t,e.slice(0,32)),verify:async(e,t,r)=>ae(r,t,e),sha256digest:async({data:e})=>ue.subtle.digest("SHA-256",e)};async function le(e){v({bytes:e,expectedLength:32});const t=await async function(e){return(await ie(e)).pointBytes}(e),r=new Uint8Array(64);return r.set(e),r.set(t,e.length),{publicKey:t,secretKey:r}}
|
|
10
|
-
/*!
|
|
11
|
-
* Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
|
|
12
|
-
*/class ye{constructor({id:e,controller:t,revoked:r}={}){this.id=e,this.controller=t,this.revoked=r}static async generate(){throw new Error("Abstract method, must be implemented in subclass.")}static async fromKeyDocument({document:e,checkContext:t=!0,checkRevoked:r=!0}={}){if(!e)throw new TypeError('The "document" parameter is required.');if(t){if(![].concat(e["@context"]).includes(this.SUITE_CONTEXT))throw new Error('Key document does not contain required context "'+this.SUITE_CONTEXT+'".')}if(r&&e.revoked)throw new Error(`Key has been revoked since: "${e.revoked}".`);return this.from(e)}static async from(){throw new Error("Abstract method from() must be implemented in subclass.")}export({publicKey:e=!1,privateKey:t=!1}={}){if(!e&&!t)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.")}}}}ye.SUITE_CONTEXT="INVALID LDKeyPair CONTEXT";
|
|
13
|
-
/*!
|
|
14
|
-
* Copyright (c) 2021-2024 Digital Bazaar, Inc. All rights reserved.
|
|
15
|
-
*/
|
|
16
|
-
const pe="Ed25519VerificationKey2020",he=new Uint8Array([237,1]),de=new Uint8Array([128,38]);class we extends ye{constructor(e={}){super(e),this.type=pe;const{publicKeyMultibase:t,privateKeyMultibase:r}=e;if(!t)throw new TypeError('The "publicKeyMultibase" property is required.');if(!t||!ve(t,he))throw new Error(`"publicKeyMultibase" has invalid header bytes: "${t}".`);if(r&&!ve(r,de))throw new Error('"privateKeyMultibase" has invalid header bytes.');this.publicKeyMultibase=t,this.privateKeyMultibase=r,this.controller&&!this.id&&(this.id=`${this.controller}#${this.fingerprint()}`),v({bytes:this._publicKeyBuffer,code:"invalidPublicKeyLength",expectedLength:32})}static async from(e){return"Ed25519VerificationKey2018"===e.type?we.fromEd25519VerificationKey2018(e):"JsonWebKey"===e.type||"JsonWebKey2020"===e.type?we.fromJsonWebKey(e):new we(e)}static fromEd25519VerificationKey2018({keyPair:e}={}){const t=ge(he,u(e.publicKeyBase58)),r=new we({id:e.id,controller:e.controller,publicKeyMultibase:t});return e.privateKeyBase58&&(r.privateKeyMultibase=ge(de,u(e.privateKeyBase58))),r}static fromJsonWebKey2020({id:e,type:t,controller:r,publicKeyJwk:n}={}){if("JsonWebKey2020"!==t)throw new TypeError(`Invalid key type: "${t}".`);return we.fromJsonWebKey({id:e,type:t,controller:r,publicKeyJwk:n})}static fromJsonWebKey({id:e,type:t,controller:r,publicKeyJwk:n}={}){if("JsonWebKey"!==t&&"JsonWebKey2020"!==t)throw new TypeError(`Invalid key type: "${t}".`);if(!n)throw new TypeError('"publicKeyJwk" property is required.');const{kty:i,crv:o}=n;if("OKP"!==i)throw new TypeError('"kty" is required to be "OKP".');if("Ed25519"!==o)throw new TypeError('"crv" is required to be "Ed25519".');const{x:a}=n,s=ge(he,l(a));return we.from({id:e,controller:r,publicKeyMultibase:s})}static async generate({seed:e,...t}={}){let r;r=e?await fe.generateKeyPairFromSeed(e):await fe.generateKeyPair();const n=ge(he,r.publicKey),i=ge(de,r.secretKey);return new we({publicKeyMultibase:n,privateKeyMultibase:i,...t})}static fromFingerprint({fingerprint:e}={}){return new we({publicKeyMultibase:e})}get _publicKeyBuffer(){if(!this.publicKeyMultibase)return;return u(this.publicKeyMultibase.substr(1)).slice(he.length)}get _privateKeyBuffer(){if(!this.privateKeyMultibase)return;return u(this.privateKeyMultibase.substr(1)).slice(de.length)}fingerprint(){return this.publicKeyMultibase}export({publicKey:e=!1,privateKey:t=!1,includeContext:r=!1}={}){if(!e&&!t)throw new TypeError('Export requires specifying either "publicKey" or "privateKey".');const n={id:this.id,type:this.type};return r&&(n["@context"]=we.SUITE_CONTEXT),this.controller&&(n.controller=this.controller),e&&(n.publicKeyMultibase=this.publicKeyMultibase),t&&(n.privateKeyMultibase=this.privateKeyMultibase),this.revoked&&(n.revoked=this.revoked),n}toJwk({publicKey:e=!0,privateKey:t=!1}={}){if(!e&&!t)throw TypeError('Either a "publicKey" or a "privateKey" is required.');const r={crv:"Ed25519",kty:"OKP"};return e&&(r.x=y(this._publicKeyBuffer)),t&&(r.d=y(this._privateKeyBuffer)),r}async jwkThumbprint(){const e=`{"crv":"Ed25519","kty":"OKP","x":"${y(this._publicKeyBuffer)}"}`,t=(new TextEncoder).encode(e);return y(new Uint8Array(await fe.sha256digest({data:t})))}async toJsonWebKey(){return{"@context":"https://w3id.org/security/jwk/v1",id:this.controller+"#"+await this.jwkThumbprint(),type:"JsonWebKey",controller:this.controller,publicKeyJwk:this.toJwk({publicKey:!0})}}async toJsonWebKey2020(){return{"@context":"https://w3id.org/security/jws/v1",id:this.controller+"#"+await this.jwkThumbprint(),type:"JsonWebKey2020",controller:this.controller,publicKeyJwk:this.toJwk({publicKey:!0})}}verifyFingerprint({fingerprint:e}={}){if("string"!=typeof e||"z"!==e[0])return{error:new Error('"fingerprint" must be a multibase encoded string.'),valid:!1};let t;try{if(t=u(e.substr(1)),!t)throw new TypeError("Invalid encoding of fingerprint.")}catch(e){return{error:e,valid:!1}}const r=function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}(this._publicKeyBuffer,t.slice(2)),n=t[0]===he[0]&&t[1]===he[1]&&r;return n?{valid:n}:{error:new Error("The fingerprint does not match the public key."),valid:!1}}signer(){const e=this._privateKeyBuffer;return{async sign({data:t}){if(!e)throw new Error("A private key is not available for signing.");return fe.sign(e,t)},id:this.id}}verifier(){const e=this._publicKeyBuffer;return{async verify({data:t,signature:r}){if(!e)throw new Error("A public key is not available for verifying.");return fe.verify(e,t,r)},id:this.id}}}function ve(e,t){if("string"!=typeof e||"z"!==e[0])return!1;const r=u(e.slice(1));return t.every(((e,t)=>r[t]===e))}function ge(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),"z"+f(r)}we.suite=pe,we.SUITE_CONTEXT="https://w3id.org/security/suites/ed25519-2020/v1";var be,me,Ke,xe=(be=function(e,t){!function(e,t){for(var r in t)e[r]=t[r]}(t,function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){
|
|
17
|
-
/*!
|
|
18
|
-
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
19
|
-
*/
|
|
20
|
-
e.exports={"@context":{id:"@id",type:"@type","@protected":!0,proof:{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"},Ed25519VerificationKey2020:{"@id":"https://w3id.org/security#Ed25519VerificationKey2020","@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"},publicKeyMultibase:{"@id":"https://w3id.org/security#publicKeyMultibase","@type":"https://w3id.org/security#multibase"}}},Ed25519Signature2020:{"@id":"https://w3id.org/security#Ed25519Signature2020","@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"}}},proofValue:{"@id":"https://w3id.org/security#proofValue","@type":"https://w3id.org/security#multibase"},verificationMethod:{"@id":"https://w3id.org/security#verificationMethod","@type":"@id"}}}}}},function(e,t,r){
|
|
21
|
-
/*!
|
|
22
|
-
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
23
|
-
*/
|
|
24
|
-
e.exports={CONTEXT_FILENAME:"ed25519-signature-2020-v1.jsonld",CONTEXT_URL:"https://w3id.org/security/suites/ed25519-2020/v1",CBORLD_CODEC_VALUE:20}},function(e,t,r){
|
|
25
|
-
/*!
|
|
26
|
-
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
27
|
-
*/
|
|
28
|
-
const n=r(0),i=r(1),{documentLoader:o}=r(3),{CONTEXT_URL:a,CBORLD_CODEC_VALUE:s}=i,c=new Map;c.set(i.CONTEXT_URL,n);const u=new Map;u.set(a,s),e.exports={constants:i,contexts:c,appContextMap:u,documentLoader:o,CONTEXT_URL:a,CONTEXT:n}},function(e,t,r){
|
|
29
|
-
/*!
|
|
30
|
-
* Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
|
|
31
|
-
*/
|
|
32
|
-
const{CONTEXT_URL:n}=r(1),i=r(0);e.exports={documentLoader(e){if(e!==n)throw new Error(`Loading document "${e}" is not allowed.`);return{contextUrl:null,document:i,documentUrl:e}}}}]))},be(me={exports:{}},me.exports),me.exports),Ee=(Ke=xe)&&Ke.__esModule&&Object.prototype.hasOwnProperty.call(Ke,"default")?Ke.default:Ke;xe.contexts,xe.constants,xe.CONTEXT,xe.CONTEXT_URL,xe.appContextMap,xe.documentLoader;if(!globalThis.crypto.getRandomValues)throw new Error('Browser does not provide "crypto.getRandomValues".');
|
|
33
|
-
/*!
|
|
34
|
-
* Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
|
|
35
|
-
*/
|
|
36
|
-
const ke="Ed25519";function Me({id:e,secretKey:t}){if(!t)throw new Error("A secret key is not available for signing.");return{algorithm:ke,id:e,sign:async({data:e})=>async function(e,t){return oe(t,e.slice(0,32))}(t,e)}}function Te({id:e,publicKey:t}){if(!t)throw new Error("A public key is not available for verifying.");return{algorithm:ke,id:e,verify:async({data:e,signature:r})=>async function(e,t,r){return ae(r,t,e)}(t,e,r)}}
|
|
37
|
-
/*!
|
|
38
|
-
* Copyright (c) 2022-2024 Digital Bazaar, Inc. All rights reserved.
|
|
39
|
-
*/const Ae=new Uint8Array([237,1]),Pe=new Uint8Array([128,38]),Be="https://w3id.org/security/multikey/v1",Se=32,Oe=32;
|
|
40
|
-
/*!
|
|
41
|
-
* Copyright (c) 2020-2024 Digital Bazaar, Inc. All rights reserved.
|
|
42
|
-
*/
|
|
43
|
-
function Ue({keyPair:e}){const t={};return e.publicKey&&(t.publicKeyMultibase=Le(Ae,e.publicKey)),e.secretKey&&(t.secretKeyMultibase=Le(Pe,e.secretKey)),t}function Le(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),"z"+f(r)}
|
|
44
|
-
/*!
|
|
45
|
-
* Copyright (c) 2022-2024 Digital Bazaar, Inc. All rights reserved.
|
|
46
|
-
*/async function _e({keyPair:e,secretKey:t,publicKey:r,includeContext:n,canonicalize:i=!1}={}){if(!r&&!t)throw new TypeError('Export requires specifying either "publicKey" or "secretKey".');const o=t&&!!e.secretKey,a={};return n&&(a["@context"]=Be),a.id=e.id,a.type="Multikey",a.controller=e.controller,r&&(a.publicKeyMultibase=function({publicKey:e}={}){if(e.length!==Se)throw new Error(`Invalid public key size (${e.length}); expected 32.`);const{publicKeyMultibase:t}=Ue({keyPair:{publicKey:e}});return t}(e)),o&&(a.secretKeyMultibase=function({secretKey:e,canonicalize:t=!1}={}){if(e.length!==Oe){if(64!==e.length)throw new Error(`Invalid secret key size (${e.length}); expected 32.`);t&&(e=e.subarray(0,Oe))}const{secretKeyMultibase:r}=Ue({keyPair:{secretKey:e}});return r}
|
|
47
|
-
/*!
|
|
48
|
-
* Copyright (c) 2022-2024 Digital Bazaar, Inc. All rights reserved.
|
|
49
|
-
*/({...e,canonicalize:i})),e.revoked&&(a.revoked=e.revoked),a}async function je({id:e,controller:t,secretKeyMultibase:r,publicKeyMultibase:n,revoked:i}){if(!n)throw new TypeError('The "publicKeyMultibase" property is required.');const{publicKey:o,secretKey:a}=function({publicKeyMultibase:e,secretKeyMultibase:t}){if(!e||"string"!=typeof e||"z"!==e[0])throw new Error('"publicKeyMultibase" must be a multibase, base58-encoded string.');const r=u(e.substr(1)).slice(Ae.length);let n;if(t){if("string"!=typeof t||"z"!==t[0])throw new Error('"secretKeyMultibase" must be a multibase, base58-encoded string.');n=u(t.substr(1)).slice(Pe.length)}return{publicKey:r,secretKey:n}}({publicKeyMultibase:n,secretKeyMultibase:r});return t&&!e&&(e=`${t}#${n}`),{id:e,controller:t,publicKey:o,secretKey:a,publicKeyMultibase:n,secretKeyMultibase:r,revoked:i}}function Ve({jwk:e}={}){const t=function({jwk:e}={}){const{kty:t,crv:r,x:n}=e;if("OKP"!==t)throw new TypeError('"jwk.kty" must be "OKP".');if("Ed25519"!==r)throw new TypeError('"jwk.crv" must be "Ed25519".');if("string"!=typeof n)throw new TypeError('"jwk.x" must be a string.');const i=l(e.x);if(i.length!==Se)throw new Error(`Invalid public key size (${i.length}); expected 32.`);return i}({jwk:e}),{publicKeyMultibase:r}=Ue({keyPair:{publicKey:t}});return r}function Ie({jwk:e}={}){const t=function({jwk:e}={}){const{kty:t,crv:r,d:n}=e;if("OKP"!==t)throw new TypeError('"jwk.kty" must be "OKP".');if("Ed25519"!==r)throw new TypeError('"jwk.crv" must be "Ed25519".');if("string"!=typeof n)throw new TypeError('"jwk.d" must be a string.');const i=Uint8Array.from(l(e.d));if(i.length!==Oe)throw new Error(`Invalid secret key size (${i.length}); expected 32.`);return i}({jwk:e}),{secretKeyMultibase:r}=Ue({keyPair:{secretKey:t}});return r}const Re=new Map([["Ed25519VerificationKey2020",{contextUrl:"https://w3id.org/security/suites/ed25519-2020/v1",translationFn:async function({keyPair:e}){return{...e,type:"Multikey","@context":Be,secretKeyMultibase:e.privateKeyMultibase}}}],["Ed25519VerificationKey2018",{contextUrl:"https://w3id.org/security/suites/ed25519-2018/v1",translationFn:async function({keyPair:e}){const t={publicKey:u(e.publicKeyBase58),secretKey:void 0};e.privateKeyBase58&&(t.secretKey=u(e.privateKeyBase58));const{publicKeyMultibase:r,secretKeyMultibase:n}=Ue({keyPair:t});return{"@context":Be,id:e.id,type:"Multikey",controller:e.controller,revoked:e.revoked,publicKeyMultibase:r,secretKeyMultibase:n}}
|
|
50
|
-
/*!
|
|
51
|
-
* Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
|
|
52
|
-
*/}]]);async function Ne({keyPair:e}){const t=Re.get(e.type);if(!t)throw new Error(`Unsupported key type "${e.type}".`);const{contextUrl:r,translationFn:n}=t;if(e["@context"]||(e["@context"]=r),!function({document:e,contextUrl:t}){const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)}
|
|
53
|
-
/*!
|
|
54
|
-
* Copyright (c) 2020-2023 Digital Bazaar, Inc. All rights reserved.
|
|
55
|
-
*/({document:e,contextUrl:r}))throw new Error(`Context not supported "${e["@context"]}".`);return n({keyPair:e})}async function Je(e){let t={...e};if("Multikey"!==t.type){if(t.publicKeyJwk){let e,r;return"JsonWebKey"!==t.type&&"JsonWebKey2020"!==t.type||({id:e,controller:r}=t),async function({jwk:e,secretKey:t=!1,id:r,controller:n}={}){const i={"@context":Be,type:"Multikey",publicKeyMultibase:Ve({jwk:e})};"string"==typeof r&&(i.id=r);"string"==typeof n&&(i.controller=n);t&&e.d&&(i.secretKeyMultibase=Ie({jwk:e}));return Je(i)}({jwk:t.publicKeyJwk,secretKey:!1,id:e,controller:r})}if(t.type)return t=await Ne({keyPair:t}),Ce({keyPair:t})}return t.type||(t.type="Multikey"),t["@context"]||(t["@context"]=Be),function(e){if(!e||"object"!=typeof e)throw new TypeError('"key" must be an object.');if("Multikey"!==e.type)throw new Error('"key" must be a Multikey with type "Multikey".');if(!(e["@context"]===Be||Array.isArray(e["@context"])&&e["@context"].includes(Be)))throw new TypeError(`"key" must be a Multikey with context "${Be}".`)}
|
|
56
|
-
/*!
|
|
57
|
-
* Copyright (c) 2020-2024 Digital Bazaar, Inc. All rights reserved.
|
|
58
|
-
*/(t),Ce({keyPair:t})}async function Ce({keyPair:e}){return e.publicKey||(e=await je(e)),e={...e,async export({publicKey:t=!0,secretKey:r=!1,includeContext:n=!0,raw:i=!1,canonicalize:o=!1}={}){if(i){const{publicKey:t,secretKey:r}=e,n={};return t&&(n.publicKey=t.slice()),r&&(o&&r.length>Oe?n.secretKey=r.subarray(0,Oe).slice():n.secretKey=r),n}return _e({keyPair:e,publicKey:t,secretKey:r,includeContext:n,canonicalize:o})},signer(){const{id:t,secretKey:r}=e;return Me({id:t,secretKey:r})},verifier(){const{id:t,publicKey:r}=e;return Te({id:t,publicKey:r})}}}const{suites:{LinkedDataSignature:De}}=s,ze=Ee.constants.CONTEXT_URL;let We=class extends De{constructor({key:e,signer:t,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}={}){super({type:"Ed25519Signature2020",LDKeyClass:we,contextUrl:ze,key:e,signer:t,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}),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 r=await this.signer.sign({data:e});return t.proofValue="z"+f(r),t}async verifySignature({verifyData:e,verificationMethod:t,proof:r}){const{proofValue:n}=r;if(!n||"string"!=typeof n)throw new TypeError('The proof does not include a valid "proofValue" property.');if("z"!==n[0])throw new Error("Only base58btc multibase encoding is supported.");const i=u(n.substr(1));let{verifier:o}=this;if(!o){o=(await Je(t)).verifier()}return o.verify({data:e,signature:i})}async assertVerificationMethod({verificationMethod:e}){let t;if("Ed25519VerificationKey2020"!==e.type)throw new Error(`Unsupported key type "${e.type}".`);if(t=ze,!Fe({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:r}=e;if("object"==typeof r&&(r=r.id),!r)throw new Error('No "verificationMethod" found in proof.');const{document:n}=await t(r);r="string"==typeof n?JSON.parse(n):n;const i=await Je(r);return r={...await i.export({publicKey:!0,includeContext:!0}),"@context":ze,type:"Ed25519VerificationKey2020"},await this.assertVerificationMethod({verificationMethod:r}),r}async matchProof({proof:e,document:t,purpose:r,documentLoader:n}){if(!Fe({document:t,contextUrl:ze}))return!1;if(!await super.matchProof({proof:e,document:t,purpose:r,documentLoader:n}))return!1;if(!this.key)return!0;const{verificationMethod:i}=e;return"object"==typeof i?i.id===this.key.id:i===this.key.id}};function Fe({document:e,contextUrl:t}){const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)}We.CONTEXT_URL=ze,We.CONTEXT=Ee.contexts.get(ze);var Xe,qe,Ge={exports:{}},$e={};var Ze,He,Qe,Ye=(qe||(qe=1,Ge.exports=(Xe||(Xe=1,Ze=$e,Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.staticImplements=function(){return function(e){}}),$e)),Ge.exports),et={exports:{}},tt={};var rt=(Qe||(Qe=1,et.exports=(He||(He=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.staticImplements=function(){return function(e){}}}(tt)),tt)),et.exports);function nt(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function it(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){nt(o,n,i,a,s,"next",e)}function s(e){nt(o,n,i,a,s,"throw",e)}a(void 0)}))}}function ot(){return ot=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ot.apply(this,arguments)}var at=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=t&&t.prototype instanceof w?t:w,o=Object.create(i.prototype),a=new P(n||[]);return o._invoke=function(e,t,r){var n=l;return function(i,o){if(n===p)throw new Error("Generator is already running");if(n===h){if("throw"===i)throw o;return S()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=M(a,r);if(s){if(s===d)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var c=f(e,t,r);if("normal"===c.type){if(n=r.done?h:y,c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=h,r.method="throw",r.arg=c.arg)}}}(e,r,a),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l="suspendedStart",y="suspendedYield",p="executing",h="completed",d={};function w(){}function v(){}function g(){}var b={};b[o]=function(){return this};var m=Object.getPrototypeOf,K=m&&m(m(B([])));K&&K!==r&&n.call(K,o)&&(b=K);var x=g.prototype=w.prototype=Object.create(b);function E(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function r(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return r("throw",e,a,s)}))}s(c.arg)}var i;this._invoke=function(e,n){function o(){return new t((function(t,i){r(e,n,t,i)}))}return i=i?i.then(o,o):o()}}function M(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,M(e,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=f(n,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function B(e){if(e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:S}}function S(){return{value:t,done:!0}}return v.prototype=x.constructor=g,g.constructor=v,v.displayName=c(g,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,c(e,s,"GeneratorFunction")),e.prototype=Object.create(x),e},e.awrap=function(e){return{__await:e}},E(k.prototype),k.prototype[a]=function(){return this},e.AsyncIterator=k,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new k(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},E(x),c(x,s,"Generator"),x[o]=function(){return this},x.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=B,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:B(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),d}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function st(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var i=e.charAt(n),s=i.charCodeAt(0);if(255!==t[s])throw new TypeError(i+" is ambiguous");t[s]=n}var c=e.length,u=e.charAt(0),f=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function y(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return o.alloc(0);var r=0;if(" "!==e[r]){for(var n=0,i=0;e[r]===u;)n++,r++;for(var a=(e.length-r)*f+1>>>0,s=new Uint8Array(a);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var y=0,p=a-1;(0!==l||y<i)&&-1!==p;p--,y++)l+=c*s[p]>>>0,s[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=y,r++}if(" "!==e[r]){for(var h=a-i;h!==a&&0===s[h];)h++;var d=o.allocUnsafe(n+(a-h));d.fill(0,0,n);for(var w=n;h!==a;)d[w++]=s[h++];return d}}}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=o.from(t)),!a(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var f=(s-i)*l+1>>>0,y=new Uint8Array(f);i!==s;){for(var p=t[i],h=0,d=f-1;(0!==p||h<n)&&-1!==d;d--,h++)p+=256*y[d]>>>0,y[d]=p%c>>>0,p=p/c>>>0;if(0!==p)throw new Error("Non-zero carry");n=h,i++}for(var w=f-n;w!==f&&0===y[w];)w++;for(var v=u.repeat(r);w<f;++w)v+=e.charAt(y[w]);return v},decodeUnsafe:y,decode:function(e){var t=y(e);if(t)return t;throw new Error("Non-base"+c+" character")}}}var ct,ut=st("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),ft=function(e){return o.from(e||"").toString("base64")},lt=function(e){return ft(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},yt=function(e,t){void 0===t&&(t="base58btc");var r=new Uint8Array(2+e.length);if(r[0]=236,r[1]=1,r.set(e,2),"base58btc"===t)return"z"+ut.encode(r);if("base64url"===t)return"u"+lt(r);throw new Error("Unsupported encoding: "+t)},pt=function(e){return Uint8Array.from(o.from(e.x,"base64"))},ht={JsonWebKey2020:function(e){var t,r=pt(e.publicKeyJwk),n=void 0;e.privateKeyJwk&&(n=(t=e.privateKeyJwk,{publicKey:pt(t),privateKey:Uint8Array.from(o.from(t.d,"base64"))}).privateKey);return{publicKey:r,privateKey:n}},X25519KeyAgreementKey2019:function(e){var t=ut.decode(e.publicKeyBase58),r=void 0;return e.privateKeyBase58&&(r=Uint8Array.from(ut.decode(e.privateKeyBase58))),{publicKey:t,privateKey:r}}},dt={JsonWebKey2020:function(e,t,r,n){var i={kty:"OKP",crv:"X25519",x:lt(r)},o={id:e,type:"JsonWebKey2020",controller:t,publicKeyJwk:i};return n&&(o.privateKeyJwk=ot({},i,{d:lt(n)})),o},X25519KeyAgreementKey2019:function(e,t,r,n){var i={id:e,type:"X25519KeyAgreementKey2019",controller:t,publicKeyBase58:ut.encode(r)};return n&&(i.privateKeyBase58=ut.encode(n)),i}},wt=ct=function(){function e(e){this.type="JsonWebKey2020",this.id=e.id,this.type=e.type||"JsonWebKey2020",this.controller=e.controller,this.publicKey=e.publicKey,this.privateKey=e.privateKey}e.fingerprintFromPublicKey=function(){var e=it(at.mark((function e(t){var r,n;return at.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ct.from(t);case 2:return r=e.sent,n=r.publicKey,e.abrupt("return",yt(n));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.fromFingerprint=function(){var e=it(at.mark((function e(t){var r,n,i,o;return at.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.fingerprint,236!==(n=ut.decode(r.substring(1)))[0]||1!==n[1]){e.next=12;break}return e.next=5,ct.from({id:"",controller:"",type:"X25519KeyAgreementKey2019",publicKeyBase58:ut.encode(n.slice(2))});case 5:return i=e.sent,e.next=8,i.fingerprint();case 8:return o=e.sent,i.id="did:key:"+o+"#"+o,i.controller="did:key:"+o,e.abrupt("return",i);case 12:throw new Error("Unsupported fingerprint type: "+r);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();var t=e.prototype;return t.fingerprint=function(){var e=it(at.mark((function e(){return at.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",yt(this.publicKey));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.export=function(){var e=it(at.mark((function e(t){return at.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===t&&(t={privateKey:!1,type:"JsonWebKey2020"}),!dt[t.type]){e.next=3;break}return e.abrupt("return",dt[t.type](this.id,this.controller,this.publicKey,t.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(t));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.deriveSecret=function(){var e=it(at.mark((function e(t){var r,n,i;return at.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.publicKey,e.next=3,ct.from(r);case 3:if(n=e.sent,this.privateKey){e.next=6;break}throw new Error("No private key available for deriveSecret");case 6:return i=d.sharedKey(this.privateKey,n.publicKey,!0),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}();function vt(e,t,r,n,i,o,a){try{var s=e[o](a),c=s.value}catch(e){return void r(e)}s.done?t(c):Promise.resolve(c).then(n,i)}function gt(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){vt(o,n,i,a,s,"next",e)}function s(e){vt(o,n,i,a,s,"throw",e)}a(void 0)}))}}function bt(){return bt=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},bt.apply(this,arguments)}wt.generate=function(){var e=it(at.mark((function e(t){var r,n,i,o,a;return at.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.secureRandom,n=d.generateKeyPair({isAvailable:!0,randomBytes:r}),i=yt(n.publicKey),a=(o="did:key:"+i)+"#"+i,e.abrupt("return",new ct({id:a,type:"JsonWebKey2020",controller:o,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),wt.from=function(){var e=it(at.mark((function e(t){var r,n,i;return at.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=ht[t.type](t),n=r.publicKey,i=r.privateKey,e.abrupt("return",new ct({id:t.id,type:t.type,controller:t.controller,publicKey:n,privateKey:i}));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),wt=ct=p([rt.staticImplements()],wt);var mt=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=t&&t.prototype instanceof w?t:w,o=Object.create(i.prototype),a=new P(n||[]);return o._invoke=function(e,t,r){var n=l;return function(i,o){if(n===p)throw new Error("Generator is already running");if(n===h){if("throw"===i)throw o;return S()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=M(a,r);if(s){if(s===d)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var c=f(e,t,r);if("normal"===c.type){if(n=r.done?h:y,c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=h,r.method="throw",r.arg=c.arg)}}}(e,r,a),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l="suspendedStart",y="suspendedYield",p="executing",h="completed",d={};function w(){}function v(){}function g(){}var b={};b[o]=function(){return this};var m=Object.getPrototypeOf,K=m&&m(m(B([])));K&&K!==r&&n.call(K,o)&&(b=K);var x=g.prototype=w.prototype=Object.create(b);function E(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function k(e,t){function r(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(l).then((function(e){u.value=e,a(u)}),(function(e){return r("throw",e,a,s)}))}s(c.arg)}var i;this._invoke=function(e,n){function o(){return new t((function(t,i){r(e,n,t,i)}))}return i=i?i.then(o,o):o()}}function M(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,M(e,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=f(n,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var o=i.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function T(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function P(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(T,this),this.reset(!0)}function B(e){if(e){var r=e[o];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,a=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return a.next=a}}return{next:S}}function S(){return{value:t,done:!0}}return v.prototype=x.constructor=g,g.constructor=v,v.displayName=c(g,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,c(e,s,"GeneratorFunction")),e.prototype=Object.create(x),e},e.awrap=function(e){return{__await:e}},E(k.prototype),k.prototype[a]=function(){return this},e.AsyncIterator=k,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new k(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},E(x),c(x,s,"Generator"),x[o]=function(){return this},x.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=B,P.prototype={constructor:P,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(A),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;A(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:B(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),d}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}}));function Kt(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var i=e.charAt(n),s=i.charCodeAt(0);if(255!==t[s])throw new TypeError(i+" is ambiguous");t[s]=n}var c=e.length,u=e.charAt(0),f=Math.log(c)/Math.log(256),l=Math.log(256)/Math.log(c);function y(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return o.alloc(0);var r=0;if(" "!==e[r]){for(var n=0,i=0;e[r]===u;)n++,r++;for(var a=(e.length-r)*f+1>>>0,s=new Uint8Array(a);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var y=0,p=a-1;(0!==l||y<i)&&-1!==p;p--,y++)l+=c*s[p]>>>0,s[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=y,r++}if(" "!==e[r]){for(var h=a-i;h!==a&&0===s[h];)h++;var d=o.allocUnsafe(n+(a-h));d.fill(0,0,n);for(var w=n;h!==a;)d[w++]=s[h++];return d}}}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=o.from(t)),!a(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var f=(s-i)*l+1>>>0,y=new Uint8Array(f);i!==s;){for(var p=t[i],h=0,d=f-1;(0!==p||h<n)&&-1!==d;d--,h++)p+=256*y[d]>>>0,y[d]=p%c>>>0,p=p/c>>>0;if(0!==p)throw new Error("Non-zero carry");n=h,i++}for(var w=f-n;w!==f&&0===y[w];)w++;for(var v=u.repeat(r);w<f;++w)v+=e.charAt(y[w]);return v},decodeUnsafe:y,decode:function(e){var t=y(e);if(t)return t;throw new Error("Non-base"+c+" character")}}}var xt,Et=Kt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),kt=function(e){return o.from(e||"").toString("base64")},Mt=function(e){return kt(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},Tt=function(e,t){void 0===t&&(t="base58btc");var r=new Uint8Array(2+e.length);if(r[0]=237,r[1]=1,r.set(e,2),"base58btc"===t)return"z"+Et.encode(r);if("base64url"===t)return"u"+Mt(r);throw new Error("Unsupported encoding: "+t)},At=function(e){return Uint8Array.from(o.from(e.x,"base64"))},Pt={JsonWebKey2020:function(e){var t,r=At(e.publicKeyJwk),n=void 0;e.privateKeyJwk&&(n=(t=e.privateKeyJwk,{publicKey:At(t),privateKey:Uint8Array.from(o.concat([o.from(t.d,"base64"),o.from(t.x,"base64")]))}).privateKey);return{publicKey:r,privateKey:n}},Ed25519VerificationKey2018:function(e){var t=Et.decode(e.publicKeyBase58),r=void 0;return e.privateKeyBase58&&(r=Uint8Array.from(Et.decode(e.privateKeyBase58))),{publicKey:t,privateKey:r}}},Bt=function(e){if(!Pt[e.type])throw new Error("Cannot import from unsupported type: "+JSON.stringify(e,null,2));return Pt[e.type](e)},St={JsonWebKey2020:function(e,t,r,n){var i={kty:"OKP",crv:"Ed25519",x:Mt(r)},o={id:e,type:"JsonWebKey2020",controller:t,publicKeyJwk:i};return n&&(o.privateKeyJwk=bt({},i,{d:Mt(n.slice(0,n.length/2))})),o},Ed25519VerificationKey2018:function(e,t,r,n){var i={id:e,type:"Ed25519VerificationKey2018",controller:t,publicKeyBase58:Et.encode(r)};return n&&(i.privateKeyBase58=Et.encode(n)),i}},Ot={EdDsa:{__proto__:null,signer:function(e){return{sign:function(t){return gt(mt.mark((function r(){var n;return mt.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=t.data,r.abrupt("return",h.sign(e,n));case 2:case"end":return r.stop()}}),r)})))()}}},verifier:function(e){return{verify:function(t){return gt(mt.mark((function r(){var n,i,o;return mt.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=t.data,i=t.signature,o=!1;try{o=h.verify(e,n,i)}catch(e){}return r.abrupt("return",o);case 4:case"end":return r.stop()}}),r)})))()}}}}},Ut=xt=function(){function e(e){this.type="JsonWebKey2020",this.id=e.id,this.type=e.type||"JsonWebKey2020",this.controller=e.controller,this.publicKey=e.publicKey,this.privateKey=e.privateKey}e.fingerprintFromPublicKey=function(){var e=gt(mt.mark((function e(t){var r,n;return mt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,xt.from(t);case 2:return r=e.sent,n=r.publicKey,e.abrupt("return",Tt(n));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.toX25519KeyPair=function(){var e=gt(mt.mark((function e(t){var r,n,i;return mt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=h.convertPublicKeyToX25519(t.publicKey),n=void 0,t.privateKey&&(n=h.convertSecretKeyToX25519(t.privateKey)),i=new wt({id:"",type:"X25519KeyAgreementKey2019",controller:t.controller,publicKey:r,privateKey:n}),e.t0=t.controller+"#",e.next=7,i.fingerprint();case 7:return e.t1=e.sent,i.id=e.t0+e.t1,e.abrupt("return",i);case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.fromFingerprint=function(){var e=gt(mt.mark((function e(t){var r,n,i,o;return mt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.fingerprint,237!==(n=Et.decode(r.substring(1)))[0]||1!==n[1]){e.next=12;break}return e.next=5,xt.from({id:"",controller:"",type:"Ed25519VerificationKey2018",publicKeyBase58:Et.encode(n.slice(2))});case 5:return i=e.sent,e.next=8,i.fingerprint();case 8:return o=e.sent,i.id="did:key:"+o+"#"+o,i.controller="did:key:"+o,e.abrupt("return",i);case 12:throw new Error("Unsupported fingerprint type: "+r);case 13:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();var t=e.prototype;return t.fingerprint=function(){var e=gt(mt.mark((function e(){return mt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Tt(this.publicKey));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.export=function(){var e=gt(mt.mark((function e(t){return mt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===t&&(t={privateKey:!1,type:"JsonWebKey2020"}),!St[t.type]){e.next=3;break}return e.abrupt("return",St[t.type](this.id,this.controller,this.publicKey,t.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(t));case 4:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.signer=function(e){if(void 0===e&&(e="EdDsa"),!this.privateKey)throw new Error("No private key to sign with.");if(Ot[e])return Ot[e].signer(this.privateKey);throw new Error("Unsupported suite type "+e)},t.verifier=function(e){if(void 0===e&&(e="EdDsa"),!this.publicKey)throw new Error("No public key to verify with.");if(Ot[e])return Ot[e].verifier(this.publicKey);throw new Error("Unsupported suite type "+e)},t.getDerivedKeyPairs=function(){var e=gt(mt.mark((function e(){return mt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,xt.toX25519KeyPair(this);case 3:return e.t1=e.sent,e.abrupt("return",[e.t0,e.t1]);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}();Ut.generate=function(){var e=gt(mt.mark((function e(t){var r,n,i,o,a;return mt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.secureRandom,n=h.generateKeyPair({isAvailable:!0,randomBytes:r}),i=Tt(n.publicKey),a=(o="did:key:"+i)+"#"+i,e.abrupt("return",new xt({id:a,type:"JsonWebKey2020",controller:o,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ut.from=function(){var e=gt(mt.mark((function e(t){var r,n,i;return mt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Bt(t),n=r.publicKey,i=r.privateKey,e.abrupt("return",new xt({id:t.id,type:t.type,controller:t.controller,publicKey:n,privateKey:i}));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ut=xt=p([Ye.staticImplements()],Ut);const{purposes:{AssertionProofPurpose:Lt,AuthenticationProofPurpose:_t}}=s;var jt;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.ensureVerificationMethodValidity="ensureVerificationMethodValidity",e.checkDocumentSignature="checkDocumentSignature"}(jt||(jt={}));class Vt extends w{verificationProcess=[jt.retrieveVerificationMethodPublicKey,jt.ensureVerificationMethodValidity,jt.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:_t,assertionMethod:Lt},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((r=>e.verifier.convertToVerificationSubsteps(t,r)))}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,r){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async publicKeyJwkToString(e){return await Ut.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}:c.documentLoader(e)}}retrieveInitialDocument(){const e=r(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(jt.retrieveVerificationMethodPublicKey,(async()=>{const e=this.getTargetVerificationMethodContainer();if(!e)throw new n(jt.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 n(jt.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 we.from({...this.verificationMethod});if(!t)throw new n(jt.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(t.revoked)throw new n(jt.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return t}),this.type)}async ensureVerificationMethodValidity(){await this.executeStep(jt.ensureVerificationMethodValidity,(async()=>{if(this.verificationMethod.expires){if(new Date(this.verificationMethod.expires).getTime()<Date.now())throw new n(jt.ensureVerificationMethodValidity,"The verification key has expired")}if(this.verificationMethod.revoked)throw new n(jt.ensureVerificationMethodValidity,"The verification key has been revoked")}),this.type)}async checkDocumentSignature(){await this.executeStep(jt.checkDocumentSignature,(async()=>{const e=new We({key:this.verificationKey});e.date=new Date(Date.now()).toISOString(),"authentication"!==this.proofPurpose||this.proof.challenge||(this.proof.challenge="");const t=await s.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 n(jt.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed: ${this.getErrorMessage(t)}`);console.log("Credential Ed25519 signature successfully verified")}),this.type)}}export{Vt as default};
|