@blockcerts/blockcerts-verifier 1.57.5 → 1.59.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.
Files changed (42) hide show
  1. package/bundle-stats.html +24 -20
  2. package/dist/EcdsaSecp256k1Signature2019-XwuS-fWx-n_8xXj1H.js +4 -0
  3. package/dist/Ed25519Signature2020-IJ4ybcbU-ii2PjWjh.js +52 -0
  4. package/dist/{HashlinkVerifier-40818bdd-tYZmELFg.js → HashlinkVerifier-wyKYZ83G-aKb9h_9G.js} +1 -1
  5. package/dist/{MerkleProof2017-ac8d147b-6wk-NtfB.js → MerkleProof2017-Ub6_JUVj-Z6jluDo2.js} +1 -1
  6. package/dist/MerkleProof2019-QUwyEIHd-9hBGmPq_.js +3 -0
  7. package/dist/base64url-qi3FT6uz-yv4mTXpu.js +4 -0
  8. package/dist/checkRevocationStatusList2021-d1qO1xnj-AIMXIqnZ.js +13 -0
  9. package/dist/controlVerificationMethod-6GJtYmqY-VwQyuM5o.js +1 -0
  10. package/dist/{did-key-common.esm-2e9ab4e3-X4avzjKx.js → did-key-common.esm-Fyh_U6fK-6hhnSYH5.js} +3 -3
  11. package/dist/{did-key-ed25519.esm-54d2cbca-E7NBXv8_.js → did-key-ed25519.esm-1lIlZtof-q2UR_X9G.js} +1 -1
  12. package/dist/did-key-secp256k1.esm-hA8kGTM0-5bW-jZai.js +1 -0
  13. package/dist/{downloadPDF-5Pw6AlBs.js → downloadPDF-6pZYEy3P.js} +8 -8
  14. package/dist/index-CZOUZnn4-Lnb5-WZi.js +5 -0
  15. package/dist/{index-6d4132ca-BtAgIaHS.js → index-MC635rre-r3wKwiyR.js} +2 -2
  16. package/dist/index.es-NoR6QQLP.js +56 -0
  17. package/dist/{jsonld-6909fb49-vaWL2Y4h.js → jsonld-CXlzLf4P-Wh4x173W.js} +1 -1
  18. package/dist/{jsonld-signatures-8ecbbaa2-MztjIc1c.js → jsonld-signatures-ooFWZVS--VI8BZQOv.js} +6 -6
  19. package/dist/main.js +110 -110
  20. package/dist/{purify-xGHUwWlQ.js → purify-05qYXQpp.js} +1 -1
  21. package/dist/tslib.es6-M1zqH4el-x9kNW1T_.js +1 -0
  22. package/dist/x25519-NtRELWAG-TIgip27e.js +1 -0
  23. package/package.json +5 -5
  24. package/dist/EcdsaSecp256k1Signature2019-01e33e56-_kD7OEMM.js +0 -4
  25. package/dist/Ed25519Signature2020-722d8d24-52XGswpx.js +0 -74
  26. package/dist/MerkleProof2019-6596bc5f-AOhD0MU2.js +0 -3
  27. package/dist/checkRevocationStatusList2021-904b13ff-HXtw_2Lc.js +0 -17
  28. package/dist/controlVerificationMethod-80d0e7f0-8ug9g49U.js +0 -1
  29. package/dist/did-key-secp256k1.esm-8a01b23c-iRA0puBs.js +0 -1
  30. package/dist/index-85f56501-xkysxAxC.js +0 -4
  31. package/dist/index-a93e1e88-w6XCMY1g.js +0 -1
  32. package/dist/index.es-YP2tdnLj.js +0 -56
  33. package/dist/tslib.es6-28b6776b-qWIKDnpX.js +0 -1
  34. package/dist/x25519-08f432f1-4TKeGPT6.js +0 -1
  35. /package/dist/{Suite-e65d26ad-e2QgHGhx.js → Suite-Bhitn5l3-e2QgHGhx.js} +0 -0
  36. /package/dist/{_commonjs-dynamic-modules-1e49c0dd-fkA6S-_a.js → _commonjs-dynamic-modules-F7P8sER7-fkA6S-_a.js} +0 -0
  37. /package/dist/{elliptic-a9d84078-BGmaMzNc.js → elliptic-il_lPAr--BGmaMzNc.js} +0 -0
  38. /package/dist/{ensureNotRevoked-2dc26afb-U5ByLE-t.js → ensureNotRevoked-2QGGtBqy-U5ByLE-t.js} +0 -0
  39. /package/dist/{ensureValidIssuingKey-b950fb8b-oM__XftS.js → ensureValidIssuingKey-zZEv5-cH-oM__XftS.js} +0 -0
  40. /package/dist/{index-0469d008-LwXIiw03.js → index-xsnp_Fid-LwXIiw03.js} +0 -0
  41. /package/dist/{pako.esm-7a9981ef-RAILONW0.js → pako.esm-jjCKMBM4-RAILONW0.js} +0 -0
  42. /package/dist/{sha256-71400caa-o9J6pXuo.js → sha256-wKeS8_4l-o9J6pXuo.js} +0 -0
@@ -1,74 +0,0 @@
1
- import{h as e,o as t,n as r,l as n,y as i,c as o,i as a}from"./main.js";import{j as s}from"./jsonld-signatures-8ecbbaa2-MztjIc1c.js";import{j as c}from"./jsonld-6909fb49-vaWL2Y4h.js";import{d as u,e as f}from"./index-85f56501-xkysxAxC.js";import{_ as p}from"./tslib.es6-28b6776b-qWIKDnpX.js";import{x as l,e as y}from"./x25519-08f432f1-4TKeGPT6.js";import{d as h}from"./index-a93e1e88-w6XCMY1g.js";import{S as d}from"./Suite-e65d26ad-e2QgHGhx.js";import"./_commonjs-dynamic-modules-1e49c0dd-fkA6S-_a.js";
2
- /*!
3
- * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
4
- */const w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",v=[62,-1,-1,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,63,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];function g(e){if(!(e instanceof Uint8Array||"string"==typeof e))throw new TypeError('"input" be a string or Uint8Array.');"string"==typeof e&&(e=(new TextEncoder).encode(e));let t,r,n,i="",o=0;for(;o<e.byteLength;)t=e[o++],r=e[o++],n=e[o++],i+=w.charAt(t>>2),i+=w.charAt((3&t)<<4|r>>4),isNaN(r)||(i+=w.charAt((15&r)<<2|n>>6),isNaN(n)||(i+=w.charAt(63&n)));return i}
5
- /*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
6
- const b=BigInt(0),m=BigInt(1),E=BigInt(2),K=BigInt(8),x=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),T=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:x,n:x,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),A=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),k=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742");const O=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),S=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),M=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),U=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class B{constructor(e,t,r,n){this.x=e,this.y=t,this.z=r,this.t=n}static fromAffine(e){if(!(e instanceof R))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return e.equals(R.ZERO)?B.ZERO:new B(e.x,e.y,m,Z(e.x*e.y))}static toAffineBatch(e){const t=function(e,t=T.P){const r=new Array(e.length),n=H(e.reduce(((e,n,i)=>n===b?e:(r[i]=e,Z(e*n,t))),m),t);return e.reduceRight(((e,n,i)=>n===b?e:(r[i]=Z(e*r[i],t),Z(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){L(e);const{x:t,y:r,z:n}=this,{x:i,y:o,z:a}=e,s=Z(t*a),c=Z(i*n),u=Z(r*a),f=Z(o*n);return s===c&&u===f}negate(){return new B(Z(-this.x),this.y,this.z,Z(-this.t))}double(){const{x:e,y:t,z:r}=this,{a:n}=T,i=Z(e*e),o=Z(t*t),a=Z(E*Z(r*r)),s=Z(n*i),c=e+t,u=Z(Z(c*c)-i-o),f=s+o,p=f-a,l=s-o,y=Z(u*p),h=Z(f*l),d=Z(u*l),w=Z(p*f);return new B(y,h,w,d)}add(e){L(e);const{x:t,y:r,z:n,t:i}=this,{x:o,y:a,z:s,t:c}=e,u=Z((r-t)*(a+o)),f=Z((r+t)*(a-o)),p=Z(f-u);if(p===b)return this.double();const l=Z(n*E*c),y=Z(i*E*s),h=y+l,d=f+u,w=y-l,v=Z(h*p),g=Z(d*w),m=Z(h*w),K=Z(p*d);return new B(v,g,K,m)}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(B.BASE)&&(t=R.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&&C.get(t);n||(n=this.precomputeWindow(r),t&&1!==r&&(n=B.normalizeZ(n),C.set(t,n)));let i=B.ZERO,o=B.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+=m);const p=r,l=r+Math.abs(a)-1,y=t%2!=0,h=a<0;0===a?o=o.add(P(y,n[p])):i=i.add(P(h,n[l]))}return B.normalizeZ([i,o])[0]}multiply(e,t){return this.wNAF(ne(e,T.l),t)}multiplyUnsafe(e){let t=ne(e,T.l,!1);const r=B.BASE,n=B.ZERO;if(t===b)return n;if(this.equals(n)||t===m)return this;if(this.equals(r))return this.wNAF(t);let i=n,o=this;for(;t>b;)t&m&&(i=i.add(o)),o=o.double(),t>>=m;return i}isSmallOrder(){return this.multiplyUnsafe(T.h).equals(B.ZERO)}isTorsionFree(){let e=this.multiplyUnsafe(T.l/E).double();return T.l%E&&(e=e.add(this)),e.equals(B.ZERO)}toAffine(e){const{x:t,y:r,z:n}=this,i=this.equals(B.ZERO);null==e&&(e=i?K:H(n));const o=Z(t*e),a=Z(r*e),s=Z(n*e);if(i)return R.ZERO;if(s!==m)throw new Error("invZ was invalid");return new R(o,a)}fromRistrettoBytes(){N()}toRistrettoBytes(){N()}fromRistrettoHash(){N()}}function P(e,t){const r=t.negate();return e?r:t}function L(e){if(!(e instanceof B))throw new TypeError("ExtendedPoint expected")}function _(e){if(!(e instanceof I))throw new TypeError("RistrettoPoint expected")}function N(){throw new Error("Legacy method: switch to RistrettoPoint")}B.BASE=new B(T.Gx,T.Gy,m,Z(T.Gx*T.Gy)),B.ZERO=new B(b,m,m,b);class I{constructor(e){this.ep=e}static calcElligatorRistrettoMap(e){const{d:t}=T,r=Z(k*e*e),n=Z((r+m)*M);let i=BigInt(-1);const o=Z((i-t*r)*Z(r+t));let{isValid:a,value:s}=Q(n,o),c=Z(s*e);z(c)||(c=Z(-c)),a||(s=c),a||(i=r);const u=Z(i*(r-m)*U-o),f=s*s,p=Z((s+s)*o),l=Z(u*O),y=Z(m-f),h=Z(m+f);return new B(Z(p*h),Z(y*l),Z(l*h),Z(p*y))}static hashToCurve(e){const t=$((e=re(e,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(t),n=$(e.slice(32,64)),i=this.calcElligatorRistrettoMap(n);return new I(r.add(i))}static fromHex(e){e=re(e,32);const{a:t,d:r}=T,n="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",i=$(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)||z(i))throw new Error(n);const o=Z(i*i),a=Z(m+t*o),s=Z(m-t*o),c=Z(a*a),u=Z(s*s),f=Z(t*r*c-u),{isValid:p,value:l}=ee(Z(f*u)),y=Z(l*s),h=Z(l*y*f);let d=Z((i+i)*y);z(d)&&(d=Z(-d));const w=Z(a*h),v=Z(d*w);if(!p||z(v)||w===b)throw new Error(n);return new I(new B(d,w,m,v))}toRawBytes(){let{x:e,y:t,z:r,t:n}=this.ep;const i=Z(Z(r+t)*Z(r-t)),o=Z(e*t),a=Z(o*o),{value:s}=ee(Z(i*a)),c=Z(s*i),u=Z(s*o),f=Z(c*u*n);let p;if(z(n*f)){let r=Z(t*k),n=Z(e*k);e=r,t=n,p=Z(c*S)}else p=u;z(e*f)&&(t=Z(-t));let l=Z((r-t)*p);return z(l)&&(l=Z(-l)),W(l)}toHex(){return X(this.toRawBytes())}toString(){return this.toHex()}equals(e){_(e);const t=this.ep,r=e.ep,n=Z(t.x*r.y)===Z(t.y*r.x),i=Z(t.y*r.y)===Z(t.x*r.x);return n||i}add(e){return _(e),new I(this.ep.add(e.ep))}subtract(e){return _(e),new I(this.ep.subtract(e.ep))}multiply(e){return new I(this.ep.multiply(e))}multiplyUnsafe(e){return new I(this.ep.multiplyUnsafe(e))}}I.BASE=new I(B.BASE),I.ZERO=new I(B.ZERO);const C=new WeakMap;class R{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,C.delete(this)}static fromHex(e,t=!0){const{d:r,P:n}=T,i=(e=re(e,32)).slice();i[31]=-129&e[31];const o=q(i);if(t&&o>=n)throw new Error("Expected 0 < hex < P");if(!t&&o>=A)throw new Error("Expected 0 < hex < 2**256");const a=Z(o*o),s=Z(a-m),c=Z(r*a+m);let{isValid:u,value:f}=Q(s,c);if(!u)throw new Error("Point.fromHex: invalid y coordinate");const p=(f&m)===m;return 0!=(128&e[31])!==p&&(f=Z(-f)),new R(f,o)}static async fromPrivateKey(e){return(await oe(e)).point}toRawBytes(){const e=W(this.y);return e[31]|=this.x&m?128:0,e}toHex(){return X(this.toRawBytes())}toX25519(){const{y:e}=this;return W(Z((m+e)*H(m-e)))}isTorsionFree(){return B.fromAffine(this).isTorsionFree()}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new R(Z(-this.x),this.y)}add(e){return B.fromAffine(this).add(B.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return B.fromAffine(this).multiply(e,this).toAffine()}}R.BASE=new R(T.Gx,T.Gy),R.ZERO=new R(b,m);class j{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromHex(e){const t=re(e,64),r=R.fromHex(t.slice(0,32),!1),n=q(t.slice(32,64));return new j(r,n)}assertValidity(){const{r:e,s:t}=this;if(!(e instanceof R))throw new Error("Expected Point instance");return ne(t,T.l,!1),this}toRawBytes(){const e=new Uint8Array(64);return e.set(this.r.toRawBytes()),e.set(W(this.s),32),e}toHex(){return X(this.toRawBytes())}}function V(...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 X(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 F(e){return D(e.toString(16).padStart(64,"0"))}function W(e){return F(e).reverse()}function z(e){return(Z(e)&m)===m}function q(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");return BigInt("0x"+X(Uint8Array.from(e).reverse()))}const G=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function $(e){return Z(q(e)&G)}function Z(e,t=T.P){const r=e%t;return r>=b?r:t+r}function H(e,t=T.P){if(e===b||t<=b)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=Z(e,t),n=t,i=b,o=m;for(;r!==b;){const e=n%r,t=i-o*(n/r);n=r,r=e,i=o,o=t}if(n!==m)throw new Error("invert: does not exist");return Z(i,t)}function Y(e,t){const{P:r}=T;let n=e;for(;t-- >b;)n*=n,n%=r;return n}function Q(e,t){const r=Z(t*t*t),n=function(e){const{P:t}=T,r=BigInt(5),n=BigInt(10),i=BigInt(20),o=BigInt(40),a=BigInt(80),s=e*e%t*e%t,c=Y(s,E)*s%t,u=Y(c,m)*e%t,f=Y(u,r)*u%t,p=Y(f,n)*f%t,l=Y(p,i)*p%t,y=Y(l,o)*l%t,h=Y(y,a)*y%t,d=Y(h,a)*y%t,w=Y(d,n)*f%t;return{pow_p_5_8:Y(w,E)*e%t,b2:s}}(e*Z(r*r*t)).pow_p_5_8;let i=Z(e*r*n);const o=Z(t*i*i),a=i,s=Z(i*k),c=o===e,u=o===Z(-e),f=o===Z(-e*k);return c&&(i=a),(u||f)&&(i=s),z(i)&&(i=Z(-i)),{isValid:c||u,value:i}}function ee(e){return Q(m,e)}function te(e){return Z(q(e),T.l)}function re(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 ne(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(b<e)return e}else if(b<=e)return e;throw new TypeError("Expected valid scalar: 0 < scalar < max")}let ie;async function oe(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=te(t),o=R.BASE.multiply(i),a=o.toRawBytes();return{head:t,prefix:n,scalar:i,point:o,pointBytes:a}}(await fe.sha512(function(e){if(32!==(e="bigint"==typeof e||"number"==typeof e?F(ne(e,A)):re(e)).length)throw new Error("Expected 32 bytes");return e}(e)))}async function ae(e){return(await oe(e)).pointBytes}async function se(e,t){e=re(e);const{prefix:r,scalar:n,pointBytes:i}=await oe(t),o=te(await fe.sha512(r,e)),a=R.BASE.multiply(o),s=Z(o+te(await fe.sha512(a.toRawBytes(),i,e))*n,T.l);return new j(a,s).toRawBytes()}async function ce(e,t,r){const{r:n,SB:i,msg:o,pub:a}=function(e,t,r){t=re(t),r instanceof R||(r=R.fromHex(r,!1));const{r:n,s:i}=e instanceof j?e.assertValidity():j.fromHex(e);return{r:n,s:i,SB:B.BASE.multiplyUnsafe(i),pub:r,msg:t}}(e,t,r),s=await fe.sha512(n.toRawBytes(),a.toRawBytes(),o);return function(e,t,r,n){const i=te(n),o=B.fromAffine(e).multiplyUnsafe(i);return B.fromAffine(t).add(o).subtract(r).multiplyUnsafe(T.h).equals(B.ZERO)}(a,n,i,s)}R.BASE._setWindowSize(8);const ue={node:i,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},fe={bytesToHex:X,hexToBytes:D,concatBytes:V,getExtendedPublicKey:oe,mod:Z,invert:H,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar:e=>{if((e=re(e)).length<40||e.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Z(q(e),T.l-m)+m},randomBytes:(e=32)=>{if(ue.web)return ue.web.getRandomValues(new Uint8Array(e));if(ue.node){const{randomBytes:t}=ue.node;return new Uint8Array(t(e).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>fe.randomBytes(32),sha512:async(...e)=>{const t=V(...e);if(ue.web){const e=await ue.web.subtle.digest("SHA-512",t.buffer);return new Uint8Array(e)}if(ue.node)return Uint8Array.from(ue.node.createHash("sha512").update(t).digest());throw new Error("The environment doesn't have sha512 function")},precompute(e=8,t=R.BASE){const r=t.equals(R.BASE)?t:new R(t.x,t.y);return r._setWindowSize(e),r.multiply(E),r},sha512Sync:void 0};Object.defineProperties(fe,{sha512Sync:{configurable:!1,get:()=>ie,set(e){ie||(ie=e)}}});
7
- /*!
8
- * Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.
9
- */
10
- const pe=self.crypto;if(!pe.getRandomValues)throw new Error('Browser does not provide "crypto.getRandomValues".');var le={async generateKeyPair(){const e=new Uint8Array(32);pe.getRandomValues(e);const t=await ye(e);return e.fill(0),t},generateKeyPairFromSeed:ye,sign:async(e,t)=>se(t,e.slice(0,32)),verify:async(e,t,r)=>ce(r,t,e),sha256digest:async({data:e})=>pe.subtle.digest("SHA-256",e)};async function ye(e){const t=await ae(e),r=new Uint8Array(64);return r.set(e),r.set(t,e.length),{publicKey:t,secretKey:r}}
11
- /*!
12
- * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
13
- */let he=class{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.")}}}};he.SUITE_CONTEXT="INVALID LDKeyPair CONTEXT";
14
- /*!
15
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
16
- */
17
- const de="Ed25519VerificationKey2020",we=new Uint8Array([237,1]),ve=new Uint8Array([128,38]);let ge=class e extends he{constructor(e={}){super(e),this.type=de;const{publicKeyMultibase:t,privateKeyMultibase:r}=e;if(!t)throw new TypeError('The "publicKeyMultibase" property is required.');if(!t||!be(t,we))throw new Error(`"publicKeyMultibase" has invalid header bytes: "${t}".`);if(r&&!be(r,ve))throw new Error('"privateKeyMultibase" has invalid header bytes.');this.publicKeyMultibase=t,this.privateKeyMultibase=r,this.controller&&!this.id&&(this.id=`${this.controller}#${this.fingerprint()}`)}static async from(t){return"Ed25519VerificationKey2018"===t.type?e.fromEd25519VerificationKey2018(t):"JsonWebKey2020"===t.type?e.fromJsonWebKey2020(t):new e(t)}static fromEd25519VerificationKey2018({keyPair:t}={}){const r=me(we,u(t.publicKeyBase58)),n=new e({id:t.id,controller:t.controller,publicKeyMultibase:r});return t.privateKeyBase58&&(n.privateKeyMultibase=me(ve,u(t.privateKeyBase58))),n}static fromJsonWebKey2020({id:t,type:r,controller:n,publicKeyJwk:i}={}){if("JsonWebKey2020"!==r)throw new TypeError(`Invalid key type: "${r}".`);if(!i)throw new TypeError('"publicKeyJwk" property is required.');const{kty:o,crv:a}=i;if("OKP"!==o)throw new TypeError('"kty" is required to be "OKP".');if("Ed25519"!==a)throw new TypeError('"crv" is required to be "Ed25519".');const{x:s}=i,c=me(we,function(e){let t=e.length;const r=t%4;if(1===r)throw new Error("Illegal base64 string.");let n=0;r>0&&(n=4-r,t+=n);const i=new Uint8Array(t/4*3-n);let o,a,s,c,u=0,f=0;for(;u<t;)o=v[e.charCodeAt(u++)-45],a=v[e.charCodeAt(u++)-45],i[f++]=o<<2|a>>4,u<e.length&&(s=v[e.charCodeAt(u++)-45],i[f++]=(15&a)<<4|s>>2,u<e.length&&(c=v[e.charCodeAt(u++)-45],i[f++]=(3&s)<<6|c));return i}(s));return e.from({id:t,controller:n,publicKeyMultibase:c})}static async generate({seed:t,...r}={}){let n;n=t?await le.generateKeyPairFromSeed(t):await le.generateKeyPair();const i=me(we,n.publicKey),o=me(ve,n.secretKey);return new e({publicKeyMultibase:i,privateKeyMultibase:o,...r})}static fromFingerprint({fingerprint:t}={}){return new e({publicKeyMultibase:t})}get _publicKeyBuffer(){if(!this.publicKeyMultibase)return;return u(this.publicKeyMultibase.substr(1)).slice(we.length)}get _privateKeyBuffer(){if(!this.privateKeyMultibase)return;return u(this.privateKeyMultibase.substr(1)).slice(ve.length)}fingerprint(){return this.publicKeyMultibase}export({publicKey:t=!1,privateKey:r=!1,includeContext:n=!1}={}){if(!t&&!r)throw new TypeError('Export requires specifying either "publicKey" or "privateKey".');const i={id:this.id,type:this.type};return n&&(i["@context"]=e.SUITE_CONTEXT),this.controller&&(i.controller=this.controller),t&&(i.publicKeyMultibase=this.publicKeyMultibase),r&&(i.privateKeyMultibase=this.privateKeyMultibase),this.revoked&&(i.revoked=this.revoked),i}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=g(this._publicKeyBuffer)),t&&(r.d=g(this._privateKeyBuffer)),r}async jwkThumbprint(){const e=`{"crv":"Ed25519","kty":"OKP","x":"${g(this._publicKeyBuffer)}"}`,t=(new TextEncoder).encode(e);return g(new Uint8Array(await le.sha256digest({data:t})))}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]===we[0]&&t[1]===we[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 le.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 le.verify(e,t,r)},id:this.id}}};function be(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 me(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),"z"+f(r)}ge.suite=de,ge.SUITE_CONTEXT="https://w3id.org/security/suites/ed25519-2020/v1";var Ee,Ke,xe=(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){
18
- /*!
19
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
20
- */
21
- 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){
22
- /*!
23
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
24
- */
25
- 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){
26
- /*!
27
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
28
- */
29
- 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){
30
- /*!
31
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
32
- */
33
- 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}}}}]))}(Ee={exports:{}},Ee.exports),Ee.exports),Te=(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;const Ae={};
34
- /*!
35
- * Copyright (c) 2019-2022 Digital Bazaar, Inc. All rights reserved.
36
- */
37
- const ke="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function Oe(e,t){return function(e,t,r){if(!(e instanceof Uint8Array))throw new TypeError('"input" must be a Uint8Array.');if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxline" must be a number.');if(0===e.length)return"";let n="",i=0;const o=t.length,a=t.charAt(0),s=[0];for(i=0;i<e.length;++i){let t=e[i];for(let e=0;e<s.length;++e)t+=s[e]<<8,s[e]=t%o,t=t/o|0;for(;t>0;)s.push(t%o),t=t/o|0}for(i=0;0===e[i]&&i<e.length-1;++i)n+=a;for(i=s.length-1;i>=0;--i)n+=t[s[i]];if(r){const e=new RegExp(".{1,"+r+"}","g");n=n.match(e).join("\r\n")}return n}(e,ke,t)}function Se(e){return function(e,t){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');if(0===e.length)return new Uint8Array;let r=Ae[t];if(!r){r=Ae[t]=[];for(let e=0;e<t.length;++e)r[t.charCodeAt(e)]=e}e=e.replace(/\s/g,"");const n=t.length,i=t.charAt(0),o=[0];for(let t=0;t<e.length;t++){const i=r[e.charCodeAt(t)];if(void 0===i)return;let a=i;for(let e=0;e<o.length;++e)a+=o[e]*n,o[e]=255&a,a>>=8;for(;a>0;)o.push(255&a),a>>=8}for(let t=0;e[t]===i&&t<e.length-1;++t)o.push(0);return new Uint8Array(o.reverse())}(e,ke)}
38
- /*!
39
- * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
40
- */const Me="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",Ue=[62,-1,-1,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,63,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];function Be(e){if(!(e instanceof Uint8Array||"string"==typeof e))throw new TypeError('"input" be a string or Uint8Array.');"string"==typeof e&&(e=(new TextEncoder).encode(e));let t,r,n,i="",o=0;for(;o<e.byteLength;)t=e[o++],r=e[o++],n=e[o++],i+=Me.charAt(t>>2),i+=Me.charAt((3&t)<<4|r>>4),isNaN(r)||(i+=Me.charAt((15&r)<<2|n>>6),isNaN(n)||(i+=Me.charAt(63&n)));return i}
41
- /*!
42
- * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
43
- */
44
- function Pe({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}}
45
- /*!
46
- * Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.
47
- */const Le=globalThis.crypto;if(!Le.getRandomValues)throw new Error('Browser does not provide "crypto.getRandomValues".');var _e={async generateKeyPair(){const e=new Uint8Array(32);Le.getRandomValues(e);const t=await Ne(e);return e.fill(0),t},generateKeyPairFromSeed:Ne,sign:async(e,t)=>se(t,e.slice(0,32)),verify:async(e,t,r)=>ce(r,t,e),sha256digest:async({data:e})=>Le.subtle.digest("SHA-256",e)};async function Ne(e){Pe({bytes:e,expectedLength:32});const t=await ae(e),r=new Uint8Array(64);return r.set(e),r.set(t,e.length),{publicKey:t,secretKey:r}}
48
- /*!
49
- * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
50
- */class Ie{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.")}}}}Ie.SUITE_CONTEXT="INVALID LDKeyPair CONTEXT";
51
- /*!
52
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
53
- */
54
- const Ce="Ed25519VerificationKey2020",Re=new Uint8Array([237,1]),je=new Uint8Array([128,38]);class Ve extends Ie{constructor(e={}){super(e),this.type=Ce;const{publicKeyMultibase:t,privateKeyMultibase:r}=e;if(!t)throw new TypeError('The "publicKeyMultibase" property is required.');if(!t||!Je(t,Re))throw new Error(`"publicKeyMultibase" has invalid header bytes: "${t}".`);if(r&&!Je(r,je))throw new Error('"privateKeyMultibase" has invalid header bytes.');this.publicKeyMultibase=t,this.privateKeyMultibase=r,this.controller&&!this.id&&(this.id=`${this.controller}#${this.fingerprint()}`),Pe({bytes:this._publicKeyBuffer,code:"invalidPublicKeyLength",expectedLength:32})}static async from(e){return"Ed25519VerificationKey2018"===e.type?Ve.fromEd25519VerificationKey2018(e):"JsonWebKey2020"===e.type?Ve.fromJsonWebKey2020(e):new Ve(e)}static fromEd25519VerificationKey2018({keyPair:e}={}){const t=Xe(Re,Se(e.publicKeyBase58)),r=new Ve({id:e.id,controller:e.controller,publicKeyMultibase:t});return e.privateKeyBase58&&(r.privateKeyMultibase=Xe(je,Se(e.privateKeyBase58))),r}static fromJsonWebKey2020({id:e,type:t,controller:r,publicKeyJwk:n}={}){if("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=Xe(Re,function(e){let t=e.length;const r=t%4;if(1===r)throw new Error("Illegal base64 string.");let n=0;r>0&&(n=4-r,t+=n);const i=new Uint8Array(t/4*3-n);let o,a,s,c,u=0,f=0;for(;u<t;)o=Ue[e.charCodeAt(u++)-45],a=Ue[e.charCodeAt(u++)-45],i[f++]=o<<2|a>>4,u<e.length&&(s=Ue[e.charCodeAt(u++)-45],i[f++]=(15&a)<<4|s>>2,u<e.length&&(c=Ue[e.charCodeAt(u++)-45],i[f++]=(3&s)<<6|c));return i}(a));return Ve.from({id:e,controller:r,publicKeyMultibase:s})}static async generate({seed:e,...t}={}){let r;r=e?await _e.generateKeyPairFromSeed(e):await _e.generateKeyPair();const n=Xe(Re,r.publicKey),i=Xe(je,r.secretKey);return new Ve({publicKeyMultibase:n,privateKeyMultibase:i,...t})}static fromFingerprint({fingerprint:e}={}){return new Ve({publicKeyMultibase:e})}get _publicKeyBuffer(){if(!this.publicKeyMultibase)return;return Se(this.publicKeyMultibase.substr(1)).slice(Re.length)}get _privateKeyBuffer(){if(!this.privateKeyMultibase)return;return Se(this.privateKeyMultibase.substr(1)).slice(je.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"]=Ve.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=Be(this._publicKeyBuffer)),t&&(r.d=Be(this._privateKeyBuffer)),r}async jwkThumbprint(){const e=`{"crv":"Ed25519","kty":"OKP","x":"${Be(this._publicKeyBuffer)}"}`,t=(new TextEncoder).encode(e);return Be(new Uint8Array(await _e.sha256digest({data:t})))}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=Se(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]===Re[0]&&t[1]===Re[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 _e.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 _e.verify(e,t,r)},id:this.id}}}function Je(e,t){if("string"!=typeof e||"z"!==e[0])return!1;const r=Se(e.slice(1));return t.every(((e,t)=>r[t]===e))}function Xe(e,t){const r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),"z"+Oe(r)}Ve.suite=Ce,Ve.SUITE_CONTEXT="https://w3id.org/security/suites/ed25519-2020/v1";var De=function(e,t){return e(t={exports:{}},t.exports),t.exports}((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){
55
- /*!
56
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
57
- */
58
- e.exports={"@context":{id:"@id",type:"@type","@protected":!0,proof:{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"},Ed25519VerificationKey2018:{"@id":"https://w3id.org/security#Ed25519VerificationKey2018","@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"},publicKeyBase58:{"@id":"https://w3id.org/security#publicKeyBase58"}}},Ed25519Signature2018:{"@id":"https://w3id.org/security#Ed25519Signature2018","@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"}}}}}},function(e,t,r){
59
- /*!
60
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
61
- */
62
- e.exports={CONTEXT_FILENAME:"ed25519-signature-2018-v1.jsonld",CONTEXT_URL:"https://w3id.org/security/suites/ed25519-2018/v1",CBORLD_CODEC_VALUE:19}},function(e,t,r){
63
- /*!
64
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
65
- */
66
- const n=r(0),i=r(1),{documentLoader:o}=r(3),{CONTEXT_URL:a,CBORLD_CODEC_VALUE:s}=i,c=new Map;c.set(a,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){
67
- /*!
68
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
69
- */
70
- 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}}}}]))})),Fe=function(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}(De);De.contexts,De.constants,De.CONTEXT,De.CONTEXT_URL,De.appContextMap,De.documentLoader;
71
- /*!
72
- * Copyright (c) 2020-2021 Digital Bazaar, Inc. All rights reserved.
73
- */
74
- const{suites:{LinkedDataSignature:We}}=s,ze=Te.constants.CONTEXT_URL,qe=Fe.constants.CONTEXT_URL;let Ge=class extends We{constructor({key:e,signer:t,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}={}){super({type:"Ed25519Signature2020",LDKeyClass:Ve,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"+Oe(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=Se(n.substr(1));let{verifier:o}=this;if(!o){o=(await this.LDKeyClass.from(t)).verifier()}return o.verify({data:e,signature:i})}async assertVerificationMethod({verificationMethod:e}){let t;if("Ed25519VerificationKey2020"===e.type)t=ze;else{if("Ed25519VerificationKey2018"!==e.type)throw new Error(`Unsupported key type "${e.type}".`);t=qe}if(!$e({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);return r="string"==typeof n?JSON.parse(n):n,await this.assertVerificationMethod({verificationMethod:r}),"Ed25519VerificationKey2018"===r.type&&(r=(await Ve.fromEd25519VerificationKey2018({keyPair:r})).export({publicKey:!0,includeContext:!0})),r}async matchProof({proof:e,document:t,purpose:r,documentLoader:n}){if(!$e({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 $e({document:e,contextUrl:t}){const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)}function Ze(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 He(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){Ze(o,n,i,a,s,"next",e)}function s(e){Ze(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Ye(){return Ye=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},Ye.apply(this,arguments)}Ge.CONTEXT_URL=ze,Ge.CONTEXT=Te.contexts.get(ze);var Qe=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 S(n||[]);return o._invoke=function(e,t,r){var n=p;return function(i,o){if(n===y)throw new Error("Generator is already running");if(n===h){if("throw"===i)throw o;return U()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=A(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===p)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=y;var c=f(e,t,r);if("normal"===c.type){if(n=r.done?h:l,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 p="suspendedStart",l="suspendedYield",y="executing",h="completed",d={};function w(){}function v(){}function g(){}var b={};b[o]=function(){return this};var m=Object.getPrototypeOf,E=m&&m(m(M([])));E&&E!==r&&n.call(E,o)&&(b=E);var K=g.prototype=w.prototype=Object.create(b);function x(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function r(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?t.resolve(p.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(p).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 A(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,A(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 k(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 O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function M(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:U}}function U(){return{value:t,done:!0}}return v.prototype=K.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(K),e},e.awrap=function(e){return{__await:e}},x(T.prototype),T.prototype[a]=function(){return this},e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},x(K),c(K,s,"Generator"),K[o]=function(){return this},K.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=M,S.prototype={constructor:S,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(O),!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),O(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;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:M(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 et(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),p=Math.log(256)/Math.log(c);function l(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 p=t[e.charCodeAt(r)];if(255===p)return;for(var l=0,y=a-1;(0!==p||l<i)&&-1!==y;y--,l++)p+=c*s[y]>>>0,s[y]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,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)*p+1>>>0,l=new Uint8Array(f);i!==s;){for(var y=t[i],h=0,d=f-1;(0!==y||h<n)&&-1!==d;d--,h++)y+=256*l[d]>>>0,l[d]=y%c>>>0,y=y/c>>>0;if(0!==y)throw new Error("Non-zero carry");n=h,i++}for(var w=f-n;w!==f&&0===l[w];)w++;for(var v=u.repeat(r);w<f;++w)v+=e.charAt(l[w]);return v},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+c+" character")}}}var tt,rt=et("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),nt=function(e){return o.from(e||"").toString("base64")},it=function(e){return nt(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},ot=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"+rt.encode(r);if("base64url"===t)return"u"+it(r);throw new Error("Unsupported encoding: "+t)},at=function(e){return Uint8Array.from(o.from(e.x,"base64"))},st={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.from(t.d,"base64"))}).privateKey);return{publicKey:r,privateKey:n}},X25519KeyAgreementKey2019:function(e){var t=rt.decode(e.publicKeyBase58),r=void 0;return e.privateKeyBase58&&(r=Uint8Array.from(rt.decode(e.privateKeyBase58))),{publicKey:t,privateKey:r}}},ct={JsonWebKey2020:function(e,t,r,n){var i={kty:"OKP",crv:"X25519",x:it(r)},o={id:e,type:"JsonWebKey2020",controller:t,publicKeyJwk:i};return n&&(o.privateKeyJwk=Ye({},i,{d:it(n)})),o},X25519KeyAgreementKey2019:function(e,t,r,n){var i={id:e,type:"X25519KeyAgreementKey2019",controller:t,publicKeyBase58:rt.encode(r)};return n&&(i.privateKeyBase58=rt.encode(n)),i}},ut=tt=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=He(Qe.mark((function e(t){var r,n;return Qe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,tt.from(t);case 2:return r=e.sent,n=r.publicKey,e.abrupt("return",ot(n));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.fromFingerprint=function(){var e=He(Qe.mark((function e(t){var r,n,i,o;return Qe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.fingerprint,236!==(n=rt.decode(r.substring(1)))[0]||1!==n[1]){e.next=12;break}return e.next=5,tt.from({id:"",controller:"",type:"X25519KeyAgreementKey2019",publicKeyBase58:rt.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=He(Qe.mark((function e(){return Qe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",ot(this.publicKey));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.export=function(){var e=He(Qe.mark((function e(t){return Qe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===t&&(t={privateKey:!1,type:"JsonWebKey2020"}),!ct[t.type]){e.next=3;break}return e.abrupt("return",ct[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=He(Qe.mark((function e(t){var r,n,i;return Qe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.publicKey,e.next=3,tt.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=l.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 ft(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 pt(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){ft(o,n,i,a,s,"next",e)}function s(e){ft(o,n,i,a,s,"throw",e)}a(void 0)}))}}function lt(){return lt=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},lt.apply(this,arguments)}ut.generate=function(){var e=He(Qe.mark((function e(t){var r,n,i,o,a;return Qe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.secureRandom,n=l.generateKeyPair({isAvailable:!0,randomBytes:r}),i=ot(n.publicKey),a=(o="did:key:"+i)+"#"+i,e.abrupt("return",new tt({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=He(Qe.mark((function e(t){var r,n,i;return Qe.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=st[t.type](t),n=r.publicKey,i=r.privateKey,e.abrupt("return",new tt({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=tt=p([h.staticImplements()],ut);var yt=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 S(n||[]);return o._invoke=function(e,t,r){var n=p;return function(i,o){if(n===y)throw new Error("Generator is already running");if(n===h){if("throw"===i)throw o;return U()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=A(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===p)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=y;var c=f(e,t,r);if("normal"===c.type){if(n=r.done?h:l,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 p="suspendedStart",l="suspendedYield",y="executing",h="completed",d={};function w(){}function v(){}function g(){}var b={};b[o]=function(){return this};var m=Object.getPrototypeOf,E=m&&m(m(M([])));E&&E!==r&&n.call(E,o)&&(b=E);var K=g.prototype=w.prototype=Object.create(b);function x(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function r(i,o,a,s){var c=f(e[i],e,o);if("throw"!==c.type){var u=c.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?t.resolve(p.__await).then((function(e){r("next",e,a,s)}),(function(e){r("throw",e,a,s)})):t.resolve(p).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 A(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,A(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 k(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 O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(k,this),this.reset(!0)}function M(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:U}}function U(){return{value:t,done:!0}}return v.prototype=K.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(K),e},e.awrap=function(e){return{__await:e}},x(T.prototype),T.prototype[a]=function(){return this},e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},x(K),c(K,s,"Generator"),K[o]=function(){return this},K.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=M,S.prototype={constructor:S,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(O),!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),O(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;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:M(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 ht(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),p=Math.log(256)/Math.log(c);function l(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 p=t[e.charCodeAt(r)];if(255===p)return;for(var l=0,y=a-1;(0!==p||l<i)&&-1!==y;y--,l++)p+=c*s[y]>>>0,s[y]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,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)*p+1>>>0,l=new Uint8Array(f);i!==s;){for(var y=t[i],h=0,d=f-1;(0!==y||h<n)&&-1!==d;d--,h++)y+=256*l[d]>>>0,l[d]=y%c>>>0,y=y/c>>>0;if(0!==y)throw new Error("Non-zero carry");n=h,i++}for(var w=f-n;w!==f&&0===l[w];)w++;for(var v=u.repeat(r);w<f;++w)v+=e.charAt(l[w]);return v},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+c+" character")}}}var dt,wt=ht("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),vt=function(e){return o.from(e||"").toString("base64")},gt=function(e){return vt(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},bt=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"+wt.encode(r);if("base64url"===t)return"u"+gt(r);throw new Error("Unsupported encoding: "+t)},mt=function(e){return Uint8Array.from(o.from(e.x,"base64"))},Et={JsonWebKey2020:function(e){var t,r=mt(e.publicKeyJwk),n=void 0;e.privateKeyJwk&&(n=(t=e.privateKeyJwk,{publicKey:mt(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=wt.decode(e.publicKeyBase58),r=void 0;return e.privateKeyBase58&&(r=Uint8Array.from(wt.decode(e.privateKeyBase58))),{publicKey:t,privateKey:r}}},Kt=function(e){if(!Et[e.type])throw new Error("Cannot import from unsupported type: "+JSON.stringify(e,null,2));return Et[e.type](e)},xt={JsonWebKey2020:function(e,t,r,n){var i={kty:"OKP",crv:"Ed25519",x:gt(r)},o={id:e,type:"JsonWebKey2020",controller:t,publicKeyJwk:i};return n&&(o.privateKeyJwk=lt({},i,{d:gt(n.slice(0,n.length/2))})),o},Ed25519VerificationKey2018:function(e,t,r,n){var i={id:e,type:"Ed25519VerificationKey2018",controller:t,publicKeyBase58:wt.encode(r)};return n&&(i.privateKeyBase58=wt.encode(n)),i}},Tt={EdDsa:{__proto__:null,signer:function(e){return{sign:function(t){return pt(yt.mark((function r(){var n;return yt.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=t.data,r.abrupt("return",y.sign(e,n));case 2:case"end":return r.stop()}}),r)})))()}}},verifier:function(e){return{verify:function(t){return pt(yt.mark((function r(){var n,i,o;return yt.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=t.data,i=t.signature,o=!1;try{o=y.verify(e,n,i)}catch(e){}return r.abrupt("return",o);case 4:case"end":return r.stop()}}),r)})))()}}}}},At=dt=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=pt(yt.mark((function e(t){var r,n;return yt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,dt.from(t);case 2:return r=e.sent,n=r.publicKey,e.abrupt("return",bt(n));case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.toX25519KeyPair=function(){var e=pt(yt.mark((function e(t){var r,n,i;return yt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=y.convertPublicKeyToX25519(t.publicKey),n=void 0,t.privateKey&&(n=y.convertSecretKeyToX25519(t.privateKey)),i=new ut({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=pt(yt.mark((function e(t){var r,n,i,o;return yt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.fingerprint,237!==(n=wt.decode(r.substring(1)))[0]||1!==n[1]){e.next=12;break}return e.next=5,dt.from({id:"",controller:"",type:"Ed25519VerificationKey2018",publicKeyBase58:wt.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=pt(yt.mark((function e(){return yt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",bt(this.publicKey));case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.export=function(){var e=pt(yt.mark((function e(t){return yt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===t&&(t={privateKey:!1,type:"JsonWebKey2020"}),!xt[t.type]){e.next=3;break}return e.abrupt("return",xt[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(Tt[e])return Tt[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(Tt[e])return Tt[e].verifier(this.publicKey);throw new Error("Unsupported suite type "+e)},t.getDerivedKeyPairs=function(){var e=pt(yt.mark((function e(){return yt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.t0=this,e.next=3,dt.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}();At.generate=function(){var e=pt(yt.mark((function e(t){var r,n,i,o,a;return yt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.secureRandom,n=y.generateKeyPair({isAvailable:!0,randomBytes:r}),i=bt(n.publicKey),a=(o="did:key:"+i)+"#"+i,e.abrupt("return",new dt({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)}}(),At.from=function(){var e=pt(yt.mark((function e(t){var r,n,i;return yt.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Kt(t),n=r.publicKey,i=r.privateKey,e.abrupt("return",new dt({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)}}(),At=dt=p([h.staticImplements()],At);const{purposes:{AssertionProofPurpose:kt}}=s;var Ot;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.checkDocumentSignature="checkDocumentSignature"}(Ot||(Ot={}));class St extends d{verificationProcess=[Ot.retrieveVerificationMethodPublicKey,Ot.checkDocumentSignature];documentToVerify;issuer;proof;type="Ed25519Signature2020";verificationKey;publicKey;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,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 At.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 e}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(Ot.retrieveVerificationMethodPublicKey,(async()=>{const e=this.issuer.didDocument.verificationMethod.find((e=>e.id===this.proof.verificationMethod));if(!e)throw new n(Ot.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");try{this.publicKey=e.publicKeyMultibase||await this.publicKeyJwkToString(e)}catch(e){console.error("ERROR retrieving Ed25519Signature2020 public key",e)}const t=await ge.from({...e});if(!t)throw new n(Ot.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(t.revoked)throw new n(Ot.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return t}),this.type)}async checkDocumentSignature(){await this.executeStep(Ot.checkDocumentSignature,(async()=>{const e=new Ge({key:this.verificationKey});e.date=new Date(Date.now()).toISOString();const t=await s.verify(this.retrieveInitialDocument(),{suite:e,purpose:new kt,documentLoader:this.generateDocumentLoader()});if(!t.verified)throw console.error(JSON.stringify(t,null,2)),new n(Ot.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed`);console.log("Credential Ed25519 signature successfully verified")}),this.type)}}export{St as default};