@blockcerts/blockcerts-verifier 1.59.1 → 1.60.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 (28) hide show
  1. package/bundle-stats.html +1 -1
  2. package/dist/{EcdsaSecp256k1Signature2019-XwuS-fWx-7dFfMy74.js → EcdsaSecp256k1Signature2019-JXyaAxSS-p7r9wTPV.js} +2 -2
  3. package/dist/{Ed25519Signature2020-IJ4ybcbU--hEL5-Pa.js → Ed25519Signature2020-PVto7akI-7D-o4uG8.js} +4 -4
  4. package/dist/{MerkleProof2017-Ub6_JUVj-x8awkeml.js → MerkleProof2017-v-cug_ka-8h-1uHue.js} +1 -1
  5. package/dist/MerkleProof2019-IxLr0Lr4-exvrsGAt.js +3 -0
  6. package/dist/checkRevocationStatusList2021-NUr7Ungd-8lPXcMzr.js +13 -0
  7. package/dist/controlVerificationMethod-Ai0yOkQs-GCeqYaBn.js +1 -0
  8. package/dist/{did-key-common.esm-Fyh_U6fK-cOLlHenk.js → did-key-common.esm-2wmtjYcU-BR_8p3eV.js} +3 -3
  9. package/dist/{did-key-ed25519.esm-1lIlZtof-Grj-JpU9.js → did-key-ed25519.esm-NX9dX9Vr-fZElVDYL.js} +1 -1
  10. package/dist/{did-key-secp256k1.esm-hA8kGTM0-G8ct6CwH.js → did-key-secp256k1.esm-FBi5sg1U-hK5l_sjP.js} +1 -1
  11. package/dist/{downloadPDF--IVgfc2I.js → downloadPDF-nmBhJVDh.js} +3 -3
  12. package/dist/{ensureNotRevoked-2QGGtBqy-t8Yk4QI-.js → ensureNotRevoked--X9grgJr-l9FjOXvf.js} +1 -1
  13. package/dist/{index-MC635rre-_DW5MUyk.js → index-o5NaLUcd-9ST97EHw.js} +2 -2
  14. package/dist/{index.es-dEKcVerc.js → index.es-wVskPDvK.js} +1 -1
  15. package/dist/{jsonld-signatures-ooFWZVS--ThP8ltUY.js → jsonld-signatures-mX3uMDo8-kWFWdwsD.js} +3 -3
  16. package/dist/main.js +122 -122
  17. package/dist/{purify-GC91XaSq.js → purify-W53PnvWj.js} +1 -1
  18. package/package.json +4 -4
  19. package/dist/MerkleProof2019-QUwyEIHd-iYt21yPG.js +0 -3
  20. package/dist/checkRevocationStatusList2021-d1qO1xnj-DH6pO-9Q.js +0 -13
  21. package/dist/controlVerificationMethod-6GJtYmqY-Ivo3O8nb.js +0 -1
  22. /package/dist/{HashlinkVerifier-wyKYZ83G-bzhltPG4.js → HashlinkVerifier-qOLUtyR6-bzhltPG4.js} +0 -0
  23. /package/dist/{elliptic-il_lPAr--VPyWJbY1.js → elliptic-xyZmv-oA-VPyWJbY1.js} +0 -0
  24. /package/dist/{ensureValidIssuingKey-zZEv5-cH-UoJe_Wnf.js → ensureValidIssuingKey-U4G_F_Hm-UoJe_Wnf.js} +0 -0
  25. /package/dist/{index-xsnp_Fid-o1HUYRUQ.js → index-aBVDu34R-o1HUYRUQ.js} +0 -0
  26. /package/dist/{jsonld-CXlzLf4P-ioHKtwiZ.js → jsonld-SAOezr4P-ioHKtwiZ.js} +0 -0
  27. /package/dist/{sha256-wKeS8_4l-9eo2gOQb.js → sha256-lGrd_b3t-9eo2gOQb.js} +0 -0
  28. /package/dist/{x25519-NtRELWAG-2RynHlmX.js → x25519-X8M7VOup-2RynHlmX.js} +0 -0
@@ -1,12 +1,12 @@
1
- import{d as t,h as e,f as r,V as n,q as i,B as o,i as a}from"./main.js";import{j as c}from"./jsonld-signatures-ooFWZVS--ThP8ltUY.js";import{j as s}from"./jsonld-CXlzLf4P-ioHKtwiZ.js";import{d as u,e as f}from"./index-CZOUZnn4-Lnb5-WZi.js";import{d as p,e as l}from"./base64url-qi3FT6uz-yv4mTXpu.js";import{_ as y}from"./tslib.es6-M1zqH4el-x9kNW1T_.js";import{x as h,e as d}from"./x25519-NtRELWAG-2RynHlmX.js";import{S as w}from"./Suite-Bhitn5l3-e2QgHGhx.js";import"./_commonjs-dynamic-modules-F7P8sER7-fkA6S-_a.js";
1
+ import{d as t,h as e,f as r,V as n,q as i,B as o,i as a}from"./main.js";import{j as c}from"./jsonld-signatures-mX3uMDo8-kWFWdwsD.js";import{j as s}from"./jsonld-SAOezr4P-ioHKtwiZ.js";import{d as u,e as f}from"./index-CZOUZnn4-Lnb5-WZi.js";import{d as p,e as l}from"./base64url-qi3FT6uz-yv4mTXpu.js";import{_ as y}from"./tslib.es6-M1zqH4el-x9kNW1T_.js";import{x as h,e as d}from"./x25519-X8M7VOup-2RynHlmX.js";import{S as w}from"./Suite-Bhitn5l3-e2QgHGhx.js";import"./_commonjs-dynamic-modules-F7P8sER7-fkA6S-_a.js";
2
2
  /*!
3
3
  * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
4
4
  */function v({bytes:t,expectedLength:e=32,code:r}){if(!(t instanceof Uint8Array))throw new TypeError('"bytes" must be a Uint8Array.');if(t.length!==e){const t=new Error(`"bytes" must be a ${e}-byte Uint8Array.`);throw t.name="DataError",r&&(t.code=r),t}}
5
- /*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const g=BigInt(0),m=BigInt(1),b=BigInt(2),x=BigInt(8),E=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),K=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:E,n:E,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),T=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),A=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742");const k=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),O=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),S=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),L=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class P{constructor(t,e,r,n){this.x=t,this.y=e,this.z=r,this.t=n}static fromAffine(t){if(!(t instanceof R))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return t.equals(R.ZERO)?P.ZERO:new P(t.x,t.y,m,Z(t.x*t.y))}static toAffineBatch(t){const e=function(t,e=K.P){const r=new Array(t.length),n=H(t.reduce(((t,n,i)=>n===g?t:(r[i]=t,Z(t*n,e))),m),e);return t.reduceRight(((t,n,i)=>n===g?t:(r[i]=Z(t*r[i],e),Z(t*n,e))),n),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return this.toAffineBatch(t).map(this.fromAffine)}equals(t){_(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:a}=t,c=Z(e*a),s=Z(i*n),u=Z(r*a),f=Z(o*n);return c===s&&u===f}negate(){return new P(Z(-this.x),this.y,this.z,Z(-this.t))}double(){const{x:t,y:e,z:r}=this,{a:n}=K,i=Z(t*t),o=Z(e*e),a=Z(b*Z(r*r)),c=Z(n*i),s=t+e,u=Z(Z(s*s)-i-o),f=c+o,p=f-a,l=c-o,y=Z(u*p),h=Z(f*l),d=Z(u*l),w=Z(p*f);return new P(y,h,w,d)}add(t){_(t);const{x:e,y:r,z:n,t:i}=this,{x:o,y:a,z:c,t:s}=t,u=Z((r-e)*(a+o)),f=Z((r+e)*(a-o)),p=Z(f-u);if(p===g)return this.double();const l=Z(n*b*s),y=Z(i*b*c),h=y+l,d=f+u,w=y-l,v=Z(h*p),m=Z(d*w),x=Z(h*w),E=Z(p*d);return new P(v,m,E,x)}subtract(t){return this.add(t.negate())}precomputeWindow(t){const e=1+256/t,r=[];let n=this,i=n;for(let o=0;o<e;o++){i=n,r.push(i);for(let e=1;e<2**(t-1);e++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(t,e){!e&&this.equals(P.BASE)&&(e=R.BASE);const r=e&&e._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=e&&I.get(e);n||(n=this.precomputeWindow(r),e&&1!==r&&(n=P.normalizeZ(n),I.set(e,n)));let i=P.ZERO,o=P.BASE;const a=1+256/r,c=2**(r-1),s=BigInt(2**r-1),u=2**r,f=BigInt(r);for(let e=0;e<a;e++){const r=e*c;let a=Number(t&s);t>>=f,a>c&&(a-=u,t+=m);const p=r,l=r+Math.abs(a)-1,y=e%2!=0,h=a<0;0===a?o=o.add(B(y,n[p])):i=i.add(B(h,n[l]))}return P.normalizeZ([i,o])[0]}multiply(t,e){return this.wNAF(rt(t,K.l),e)}multiplyUnsafe(t){let e=rt(t,K.l,!1);const r=P.BASE,n=P.ZERO;if(e===g)return n;if(this.equals(n)||e===m)return this;if(this.equals(r))return this.wNAF(e);let i=n,o=this;for(;e>g;)e&m&&(i=i.add(o)),o=o.double(),e>>=m;return i}isSmallOrder(){return this.multiplyUnsafe(K.h).equals(P.ZERO)}isTorsionFree(){let t=this.multiplyUnsafe(K.l/b).double();return K.l%b&&(t=t.add(this)),t.equals(P.ZERO)}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(P.ZERO);null==t&&(t=i?x:H(n));const o=Z(e*t),a=Z(r*t),c=Z(n*t);if(i)return R.ZERO;if(c!==m)throw new Error("invZ was invalid");return new R(o,a)}fromRistrettoBytes(){U()}toRistrettoBytes(){U()}fromRistrettoHash(){U()}}function B(t,e){const r=e.negate();return t?r:e}function _(t){if(!(t instanceof P))throw new TypeError("ExtendedPoint expected")}function M(t){if(!(t instanceof N))throw new TypeError("RistrettoPoint expected")}function U(){throw new Error("Legacy method: switch to RistrettoPoint")}P.BASE=new P(K.Gx,K.Gy,m,Z(K.Gx*K.Gy)),P.ZERO=new P(g,m,m,g);class N{constructor(t){this.ep=t}static calcElligatorRistrettoMap(t){const{d:e}=K,r=Z(A*t*t),n=Z((r+m)*S);let i=BigInt(-1);const o=Z((i-e*r)*Z(r+e));let{isValid:a,value:c}=Y(n,o),s=Z(c*t);F(s)||(s=Z(-s)),a||(c=s),a||(i=r);const u=Z(i*(r-m)*L-o),f=c*c,p=Z((c+c)*o),l=Z(u*k),y=Z(m-f),h=Z(m+f);return new P(Z(p*h),Z(y*l),Z(l*h),Z(p*y))}static hashToCurve(t){const e=q((t=et(t,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(e),n=q(t.slice(32,64)),i=this.calcElligatorRistrettoMap(n);return new N(r.add(i))}static fromHex(t){t=et(t,32);const{a:e,d:r}=K,n="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",i=q(t);if(!function(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}(z(i),t)||F(i))throw new Error(n);const o=Z(i*i),a=Z(m+e*o),c=Z(m-e*o),s=Z(a*a),u=Z(c*c),f=Z(e*r*s-u),{isValid:p,value:l}=Q(Z(f*u)),y=Z(l*c),h=Z(l*y*f);let d=Z((i+i)*y);F(d)&&(d=Z(-d));const w=Z(a*h),v=Z(d*w);if(!p||F(v)||w===g)throw new Error(n);return new N(new P(d,w,m,v))}toRawBytes(){let{x:t,y:e,z:r,t:n}=this.ep;const i=Z(Z(r+e)*Z(r-e)),o=Z(t*e),a=Z(o*o),{value:c}=Q(Z(i*a)),s=Z(c*i),u=Z(c*o),f=Z(s*u*n);let p;if(F(n*f)){let r=Z(e*A),n=Z(t*A);t=r,e=n,p=Z(s*O)}else p=u;F(t*f)&&(e=Z(-e));let l=Z((r-e)*p);return F(l)&&(l=Z(-l)),z(l)}toHex(){return X(this.toRawBytes())}toString(){return this.toHex()}equals(t){M(t);const e=this.ep,r=t.ep,n=Z(e.x*r.y)===Z(e.y*r.x),i=Z(e.y*r.y)===Z(e.x*r.x);return n||i}add(t){return M(t),new N(this.ep.add(t.ep))}subtract(t){return M(t),new N(this.ep.subtract(t.ep))}multiply(t){return new N(this.ep.multiply(t))}multiplyUnsafe(t){return new N(this.ep.multiplyUnsafe(t))}}N.BASE=new N(P.BASE),N.ZERO=new N(P.ZERO);const I=new WeakMap;class R{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,I.delete(this)}static fromHex(t,e=!0){const{d:r,P:n}=K,i=(t=et(t,32)).slice();i[31]=-129&t[31];const o=W(i);if(e&&o>=n)throw new Error("Expected 0 < hex < P");if(!e&&o>=T)throw new Error("Expected 0 < hex < 2**256");const a=Z(o*o),c=Z(a-m),s=Z(r*a+m);let{isValid:u,value:f}=Y(c,s);if(!u)throw new Error("Point.fromHex: invalid y coordinate");const p=(f&m)===m;return 0!=(128&t[31])!==p&&(f=Z(-f)),new R(f,o)}static async fromPrivateKey(t){return(await it(t)).point}toRawBytes(){const t=z(this.y);return t[31]|=this.x&m?128:0,t}toHex(){return X(this.toRawBytes())}toX25519(){const{y:t}=this;return z(Z((m+t)*H(m-t)))}isTorsionFree(){return P.fromAffine(this).isTorsionFree()}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new R(Z(-this.x),this.y)}add(t){return P.fromAffine(this).add(P.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return P.fromAffine(this).multiply(t,this).toAffine()}}R.BASE=new R(K.Gx,K.Gy),R.ZERO=new R(g,m);class j{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromHex(t){const e=et(t,64),r=R.fromHex(e.slice(0,32),!1),n=W(e.slice(32,64));return new j(r,n)}assertValidity(){const{r:t,s:e}=this;if(!(t instanceof R))throw new Error("Expected Point instance");return rt(e,K.l,!1),this}toRawBytes(){const t=new Uint8Array(64);return t.set(this.r.toRawBytes()),t.set(z(this.s),32),t}toHex(){return X(this.toRawBytes())}}function C(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Expected Uint8Array list");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}const V=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function X(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=V[t[r]];return e}function D(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){const n=2*r,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[r]=o}return e}function J(t){return D(t.toString(16).padStart(64,"0"))}function z(t){return J(t).reverse()}function F(t){return(Z(t)&m)===m}function W(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");return BigInt("0x"+X(Uint8Array.from(t).reverse()))}const G=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function q(t){return Z(W(t)&G)}function Z(t,e=K.P){const r=t%e;return r>=g?r:e+r}function H(t,e=K.P){if(t===g||e<=g)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Z(t,e),n=e,i=g,o=m;for(;r!==g;){const t=n%r,e=i-o*(n/r);n=r,r=t,i=o,o=e}if(n!==m)throw new Error("invert: does not exist");return Z(i,e)}function $(t,e){const{P:r}=K;let n=t;for(;e-- >g;)n*=n,n%=r;return n}function Y(t,e){const r=Z(e*e*e),n=function(t){const{P:e}=K,r=BigInt(5),n=BigInt(10),i=BigInt(20),o=BigInt(40),a=BigInt(80),c=t*t%e*t%e,s=$(c,b)*c%e,u=$(s,m)*t%e,f=$(u,r)*u%e,p=$(f,n)*f%e,l=$(p,i)*p%e,y=$(l,o)*l%e,h=$(y,a)*y%e,d=$(h,a)*y%e,w=$(d,n)*f%e;return{pow_p_5_8:$(w,b)*t%e,b2:c}}(t*Z(r*r*e)).pow_p_5_8;let i=Z(t*r*n);const o=Z(e*i*i),a=i,c=Z(i*A),s=o===t,u=o===Z(-t),f=o===Z(-t*A);return s&&(i=a),(u||f)&&(i=c),F(i)&&(i=Z(-i)),{isValid:s||u,value:i}}function Q(t){return Y(m,t)}function tt(t){return Z(W(t),K.l)}function et(t,e){const r=t instanceof Uint8Array?Uint8Array.from(t):D(t);if("number"==typeof e&&r.length!==e)throw new Error(`Expected ${e} bytes`);return r}function rt(t,e,r=!0){if(!e)throw new TypeError("Specify max value");if("number"==typeof t&&Number.isSafeInteger(t)&&(t=BigInt(t)),"bigint"==typeof t&&t<e)if(r){if(g<t)return t}else if(g<=t)return t;throw new TypeError("Expected valid scalar: 0 < scalar < max")}let nt;async function it(t){return function(t){const e=((r=t.slice(0,32))[0]&=248,r[31]&=127,r[31]|=64,r);var r;const n=t.slice(32,64),i=tt(e),o=R.BASE.multiply(i),a=o.toRawBytes();return{head:e,prefix:n,scalar:i,point:o,pointBytes:a}}(await ct.sha512(function(t){if(32!==(t="bigint"==typeof t||"number"==typeof t?J(rt(t,T)):et(t)).length)throw new Error("Expected 32 bytes");return t}(t)))}async function ot(t,e,r){const{r:n,SB:i,msg:o,pub:a}=function(t,e,r){e=et(e),r instanceof R||(r=R.fromHex(r,!1));const{r:n,s:i}=t instanceof j?t.assertValidity():j.fromHex(t);return{r:n,s:i,SB:P.BASE.multiplyUnsafe(i),pub:r,msg:e}}(t,e,r),c=await ct.sha512(n.toRawBytes(),a.toRawBytes(),o);return function(t,e,r,n){const i=tt(n),o=P.fromAffine(t).multiplyUnsafe(i);return P.fromAffine(e).add(o).subtract(r).multiplyUnsafe(K.h).equals(P.ZERO)}(a,n,i,c)}R.BASE._setWindowSize(8);const at={node:i,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},ct={bytesToHex:X,hexToBytes:D,concatBytes:C,getExtendedPublicKey:it,mod:Z,invert:H,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar:t=>{if((t=et(t)).length<40||t.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Z(W(t),K.l-m)+m},randomBytes:(t=32)=>{if(at.web)return at.web.getRandomValues(new Uint8Array(t));if(at.node){const{randomBytes:e}=at.node;return new Uint8Array(e(t).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>ct.randomBytes(32),sha512:async(...t)=>{const e=C(...t);if(at.web){const t=await at.web.subtle.digest("SHA-512",e.buffer);return new Uint8Array(t)}if(at.node)return Uint8Array.from(at.node.createHash("sha512").update(e).digest());throw new Error("The environment doesn't have sha512 function")},precompute(t=8,e=R.BASE){const r=e.equals(R.BASE)?e:new R(e.x,e.y);return r._setWindowSize(t),r.multiply(b),r},sha512Sync:void 0};Object.defineProperties(ct,{sha512Sync:{configurable:!1,get:()=>nt,set(t){nt||(nt=t)}}});
5
+ /*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */const g=BigInt(0),m=BigInt(1),b=BigInt(2),x=BigInt(8),E=BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),K=Object.freeze({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),P:BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l:E,n:E,h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960")}),T=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000"),A=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt("6853475219497561581579357271197624642482790079785650197046958215289687604742");const k=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),O=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),S=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),L=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class P{constructor(t,e,r,n){this.x=t,this.y=e,this.z=r,this.t=n}static fromAffine(t){if(!(t instanceof j))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return t.equals(j.ZERO)?P.ZERO:new P(t.x,t.y,m,Z(t.x*t.y))}static toAffineBatch(t){const e=function(t,e=K.P){const r=new Array(t.length),n=H(t.reduce(((t,n,i)=>n===g?t:(r[i]=t,Z(t*n,e))),m),e);return t.reduceRight(((t,n,i)=>n===g?t:(r[i]=Z(t*r[i],e),Z(t*n,e))),n),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return this.toAffineBatch(t).map(this.fromAffine)}equals(t){_(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:a}=t,c=Z(e*a),s=Z(i*n),u=Z(r*a),f=Z(o*n);return c===s&&u===f}negate(){return new P(Z(-this.x),this.y,this.z,Z(-this.t))}double(){const{x:t,y:e,z:r}=this,{a:n}=K,i=Z(t*t),o=Z(e*e),a=Z(b*Z(r*r)),c=Z(n*i),s=t+e,u=Z(Z(s*s)-i-o),f=c+o,p=f-a,l=c-o,y=Z(u*p),h=Z(f*l),d=Z(u*l),w=Z(p*f);return new P(y,h,w,d)}add(t){_(t);const{x:e,y:r,z:n,t:i}=this,{x:o,y:a,z:c,t:s}=t,u=Z((r-e)*(a+o)),f=Z((r+e)*(a-o)),p=Z(f-u);if(p===g)return this.double();const l=Z(n*b*s),y=Z(i*b*c),h=y+l,d=f+u,w=y-l,v=Z(h*p),m=Z(d*w),x=Z(h*w),E=Z(p*d);return new P(v,m,E,x)}subtract(t){return this.add(t.negate())}precomputeWindow(t){const e=1+256/t,r=[];let n=this,i=n;for(let o=0;o<e;o++){i=n,r.push(i);for(let e=1;e<2**(t-1);e++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(t,e){!e&&this.equals(P.BASE)&&(e=j.BASE);const r=e&&e._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=e&&I.get(e);n||(n=this.precomputeWindow(r),e&&1!==r&&(n=P.normalizeZ(n),I.set(e,n)));let i=P.ZERO,o=P.BASE;const a=1+256/r,c=2**(r-1),s=BigInt(2**r-1),u=2**r,f=BigInt(r);for(let e=0;e<a;e++){const r=e*c;let a=Number(t&s);t>>=f,a>c&&(a-=u,t+=m);const p=r,l=r+Math.abs(a)-1,y=e%2!=0,h=a<0;0===a?o=o.add(B(y,n[p])):i=i.add(B(h,n[l]))}return P.normalizeZ([i,o])[0]}multiply(t,e){return this.wNAF(rt(t,K.l),e)}multiplyUnsafe(t){let e=rt(t,K.l,!1);const r=P.BASE,n=P.ZERO;if(e===g)return n;if(this.equals(n)||e===m)return this;if(this.equals(r))return this.wNAF(e);let i=n,o=this;for(;e>g;)e&m&&(i=i.add(o)),o=o.double(),e>>=m;return i}isSmallOrder(){return this.multiplyUnsafe(K.h).equals(P.ZERO)}isTorsionFree(){let t=this.multiplyUnsafe(K.l/b).double();return K.l%b&&(t=t.add(this)),t.equals(P.ZERO)}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(P.ZERO);null==t&&(t=i?x:H(n));const o=Z(e*t),a=Z(r*t),c=Z(n*t);if(i)return j.ZERO;if(c!==m)throw new Error("invZ was invalid");return new j(o,a)}fromRistrettoBytes(){U()}toRistrettoBytes(){U()}fromRistrettoHash(){U()}}function B(t,e){const r=e.negate();return t?r:e}function _(t){if(!(t instanceof P))throw new TypeError("ExtendedPoint expected")}function M(t){if(!(t instanceof N))throw new TypeError("RistrettoPoint expected")}function U(){throw new Error("Legacy method: switch to RistrettoPoint")}P.BASE=new P(K.Gx,K.Gy,m,Z(K.Gx*K.Gy)),P.ZERO=new P(g,m,m,g);class N{constructor(t){this.ep=t}static calcElligatorRistrettoMap(t){const{d:e}=K,r=Z(A*t*t),n=Z((r+m)*S);let i=BigInt(-1);const o=Z((i-e*r)*Z(r+e));let{isValid:a,value:c}=Y(n,o),s=Z(c*t);F(s)||(s=Z(-s)),a||(c=s),a||(i=r);const u=Z(i*(r-m)*L-o),f=c*c,p=Z((c+c)*o),l=Z(u*k),y=Z(m-f),h=Z(m+f);return new P(Z(p*h),Z(y*l),Z(l*h),Z(p*y))}static hashToCurve(t){const e=G((t=et(t,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(e),n=G(t.slice(32,64)),i=this.calcElligatorRistrettoMap(n);return new N(r.add(i))}static fromHex(t){t=et(t,32);const{a:e,d:r}=K,n="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",i=G(t);if(!function(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}(z(i),t)||F(i))throw new Error(n);const o=Z(i*i),a=Z(m+e*o),c=Z(m-e*o),s=Z(a*a),u=Z(c*c),f=Z(e*r*s-u),{isValid:p,value:l}=Q(Z(f*u)),y=Z(l*c),h=Z(l*y*f);let d=Z((i+i)*y);F(d)&&(d=Z(-d));const w=Z(a*h),v=Z(d*w);if(!p||F(v)||w===g)throw new Error(n);return new N(new P(d,w,m,v))}toRawBytes(){let{x:t,y:e,z:r,t:n}=this.ep;const i=Z(Z(r+e)*Z(r-e)),o=Z(t*e),a=Z(o*o),{value:c}=Q(Z(i*a)),s=Z(c*i),u=Z(c*o),f=Z(s*u*n);let p;if(F(n*f)){let r=Z(e*A),n=Z(t*A);t=r,e=n,p=Z(s*O)}else p=u;F(t*f)&&(e=Z(-e));let l=Z((r-e)*p);return F(l)&&(l=Z(-l)),z(l)}toHex(){return X(this.toRawBytes())}toString(){return this.toHex()}equals(t){M(t);const e=this.ep,r=t.ep,n=Z(e.x*r.y)===Z(e.y*r.x),i=Z(e.y*r.y)===Z(e.x*r.x);return n||i}add(t){return M(t),new N(this.ep.add(t.ep))}subtract(t){return M(t),new N(this.ep.subtract(t.ep))}multiply(t){return new N(this.ep.multiply(t))}multiplyUnsafe(t){return new N(this.ep.multiplyUnsafe(t))}}N.BASE=new N(P.BASE),N.ZERO=new N(P.ZERO);const I=new WeakMap;class j{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,I.delete(this)}static fromHex(t,e=!0){const{d:r,P:n}=K,i=(t=et(t,32)).slice();i[31]=-129&t[31];const o=W(i);if(e&&o>=n)throw new Error("Expected 0 < hex < P");if(!e&&o>=T)throw new Error("Expected 0 < hex < 2**256");const a=Z(o*o),c=Z(a-m),s=Z(r*a+m);let{isValid:u,value:f}=Y(c,s);if(!u)throw new Error("Point.fromHex: invalid y coordinate");const p=(f&m)===m;return 0!=(128&t[31])!==p&&(f=Z(-f)),new j(f,o)}static async fromPrivateKey(t){return(await it(t)).point}toRawBytes(){const t=z(this.y);return t[31]|=this.x&m?128:0,t}toHex(){return X(this.toRawBytes())}toX25519(){const{y:t}=this;return z(Z((m+t)*H(m-t)))}isTorsionFree(){return P.fromAffine(this).isTorsionFree()}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new j(Z(-this.x),this.y)}add(t){return P.fromAffine(this).add(P.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return P.fromAffine(this).multiply(t,this).toAffine()}}j.BASE=new j(K.Gx,K.Gy),j.ZERO=new j(g,m);class R{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromHex(t){const e=et(t,64),r=j.fromHex(e.slice(0,32),!1),n=W(e.slice(32,64));return new R(r,n)}assertValidity(){const{r:t,s:e}=this;if(!(t instanceof j))throw new Error("Expected Point instance");return rt(e,K.l,!1),this}toRawBytes(){const t=new Uint8Array(64);return t.set(this.r.toRawBytes()),t.set(z(this.s),32),t}toHex(){return X(this.toRawBytes())}}function C(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Expected Uint8Array list");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}const V=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function X(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=V[t[r]];return e}function D(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){const n=2*r,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[r]=o}return e}function J(t){return D(t.toString(16).padStart(64,"0"))}function z(t){return J(t).reverse()}function F(t){return(Z(t)&m)===m}function W(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");return BigInt("0x"+X(Uint8Array.from(t).reverse()))}const q=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function G(t){return Z(W(t)&q)}function Z(t,e=K.P){const r=t%e;return r>=g?r:e+r}function H(t,e=K.P){if(t===g||e<=g)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Z(t,e),n=e,i=g,o=m;for(;r!==g;){const t=n%r,e=i-o*(n/r);n=r,r=t,i=o,o=e}if(n!==m)throw new Error("invert: does not exist");return Z(i,e)}function $(t,e){const{P:r}=K;let n=t;for(;e-- >g;)n*=n,n%=r;return n}function Y(t,e){const r=Z(e*e*e),n=function(t){const{P:e}=K,r=BigInt(5),n=BigInt(10),i=BigInt(20),o=BigInt(40),a=BigInt(80),c=t*t%e*t%e,s=$(c,b)*c%e,u=$(s,m)*t%e,f=$(u,r)*u%e,p=$(f,n)*f%e,l=$(p,i)*p%e,y=$(l,o)*l%e,h=$(y,a)*y%e,d=$(h,a)*y%e,w=$(d,n)*f%e;return{pow_p_5_8:$(w,b)*t%e,b2:c}}(t*Z(r*r*e)).pow_p_5_8;let i=Z(t*r*n);const o=Z(e*i*i),a=i,c=Z(i*A),s=o===t,u=o===Z(-t),f=o===Z(-t*A);return s&&(i=a),(u||f)&&(i=c),F(i)&&(i=Z(-i)),{isValid:s||u,value:i}}function Q(t){return Y(m,t)}function tt(t){return Z(W(t),K.l)}function et(t,e){const r=t instanceof Uint8Array?Uint8Array.from(t):D(t);if("number"==typeof e&&r.length!==e)throw new Error(`Expected ${e} bytes`);return r}function rt(t,e,r=!0){if(!e)throw new TypeError("Specify max value");if("number"==typeof t&&Number.isSafeInteger(t)&&(t=BigInt(t)),"bigint"==typeof t&&t<e)if(r){if(g<t)return t}else if(g<=t)return t;throw new TypeError("Expected valid scalar: 0 < scalar < max")}let nt;async function it(t){return function(t){const e=((r=t.slice(0,32))[0]&=248,r[31]&=127,r[31]|=64,r);var r;const n=t.slice(32,64),i=tt(e),o=j.BASE.multiply(i),a=o.toRawBytes();return{head:e,prefix:n,scalar:i,point:o,pointBytes:a}}(await ct.sha512(function(t){if(32!==(t="bigint"==typeof t||"number"==typeof t?J(rt(t,T)):et(t)).length)throw new Error("Expected 32 bytes");return t}(t)))}async function ot(t,e,r){const{r:n,SB:i,msg:o,pub:a}=function(t,e,r){e=et(e),r instanceof j||(r=j.fromHex(r,!1));const{r:n,s:i}=t instanceof R?t.assertValidity():R.fromHex(t);return{r:n,s:i,SB:P.BASE.multiplyUnsafe(i),pub:r,msg:e}}(t,e,r),c=await ct.sha512(n.toRawBytes(),a.toRawBytes(),o);return function(t,e,r,n){const i=tt(n),o=P.fromAffine(t).multiplyUnsafe(i);return P.fromAffine(e).add(o).subtract(r).multiplyUnsafe(K.h).equals(P.ZERO)}(a,n,i,c)}j.BASE._setWindowSize(8);const at={node:i,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},ct={bytesToHex:X,hexToBytes:D,concatBytes:C,getExtendedPublicKey:it,mod:Z,invert:H,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar:t=>{if((t=et(t)).length<40||t.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Z(W(t),K.l-m)+m},randomBytes:(t=32)=>{if(at.web)return at.web.getRandomValues(new Uint8Array(t));if(at.node){const{randomBytes:e}=at.node;return new Uint8Array(e(t).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>ct.randomBytes(32),sha512:async(...t)=>{const e=C(...t);if(at.web){const t=await at.web.subtle.digest("SHA-512",e.buffer);return new Uint8Array(t)}if(at.node)return Uint8Array.from(at.node.createHash("sha512").update(e).digest());throw new Error("The environment doesn't have sha512 function")},precompute(t=8,e=j.BASE){const r=e.equals(j.BASE)?e:new j(e.x,e.y);return r._setWindowSize(t),r.multiply(b),r},sha512Sync:void 0};Object.defineProperties(ct,{sha512Sync:{configurable:!1,get:()=>nt,set(t){nt||(nt=t)}}});
6
6
  /*!
7
7
  * Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.
8
8
  */
9
- const st=globalThis.crypto;if(!st.getRandomValues)throw new Error('Browser does not provide "crypto.getRandomValues".');var ut={async generateKeyPair(){const t=new Uint8Array(32);st.getRandomValues(t);const e=await ft(t);return t.fill(0),e},generateKeyPairFromSeed:ft,sign:async(t,e)=>async function(t,e){t=et(t);const{prefix:r,scalar:n,pointBytes:i}=await it(e),o=tt(await ct.sha512(r,t)),a=R.BASE.multiply(o),c=Z(o+tt(await ct.sha512(a.toRawBytes(),i,t))*n,K.l);return new j(a,c).toRawBytes()}(e,t.slice(0,32)),verify:async(t,e,r)=>ot(r,e,t),sha256digest:async({data:t})=>st.subtle.digest("SHA-256",t)};async function ft(t){v({bytes:t,expectedLength:32});const e=await async function(t){return(await it(t)).pointBytes}(t),r=new Uint8Array(64);return r.set(t),r.set(e,t.length),{publicKey:e,secretKey:r}}
9
+ const st=globalThis.crypto;if(!st.getRandomValues)throw new Error('Browser does not provide "crypto.getRandomValues".');var ut={async generateKeyPair(){const t=new Uint8Array(32);st.getRandomValues(t);const e=await ft(t);return t.fill(0),e},generateKeyPairFromSeed:ft,sign:async(t,e)=>async function(t,e){t=et(t);const{prefix:r,scalar:n,pointBytes:i}=await it(e),o=tt(await ct.sha512(r,t)),a=j.BASE.multiply(o),c=Z(o+tt(await ct.sha512(a.toRawBytes(),i,t))*n,K.l);return new R(a,c).toRawBytes()}(e,t.slice(0,32)),verify:async(t,e,r)=>ot(r,e,t),sha256digest:async({data:t})=>st.subtle.digest("SHA-256",t)};async function ft(t){v({bytes:t,expectedLength:32});const e=await async function(t){return(await it(t)).pointBytes}(t),r=new Uint8Array(64);return r.set(t),r.set(e,t.length),{publicKey:e,secretKey:r}}
10
10
  /*!
11
11
  * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
12
12
  */class pt{constructor({id:t,controller:e,revoked:r}={}){this.id=t,this.controller=e,this.revoked=r}static async generate(){throw new Error("Abstract method, must be implemented in subclass.")}static async fromKeyDocument({document:t,checkContext:e=!0,checkRevoked:r=!0}={}){if(!t)throw new TypeError('The "document" parameter is required.');if(e){if(![].concat(t["@context"]).includes(this.SUITE_CONTEXT))throw new Error('Key document does not contain required context "'+this.SUITE_CONTEXT+'".')}if(r&&t.revoked)throw new Error(`Key has been revoked since: "${t.revoked}".`);return this.from(t)}static async from(){throw new Error("Abstract method from() must be implemented in subclass.")}export({publicKey:t=!1,privateKey:e=!1}={}){if(!t&&!e)throw new Error('Export requires specifying either "publicKey" or "privateKey".');const r={id:this.id,type:this.type,controller:this.controller};return this.revoked&&(r.revoked=this.revoked),r}fingerprint(){throw new Error("Abstract method, must be implemented in subclass.")}verifyFingerprint(){throw new Error("Abstract method, must be implemented in subclass.")}signer(){return{async sign({}){throw new Error("Abstract method, must be implemented in subclass.")}}}verifier(){return{async verify({}){throw new Error("Abstract method, must be implemented in subclass.")}}}}pt.SUITE_CONTEXT="INVALID LDKeyPair CONTEXT";
@@ -49,4 +49,4 @@ const{CONTEXT_URL:n}=r(1),i=r(0);t.exports={documentLoader(t){if(t!==n)throw new
49
49
  /*!
50
50
  * Copyright (c) 2020-2021 Digital Bazaar, Inc. All rights reserved.
51
51
  */
52
- const{suites:{LinkedDataSignature:At}}=c,kt=Et.constants.CONTEXT_URL,Ot=Tt.constants.CONTEXT_URL;let St=class extends At{constructor({key:t,signer:e,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}={}){super({type:"Ed25519Signature2020",LDKeyClass:dt,contextUrl:kt,key:t,signer:e,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}),this.requiredKeyType="Ed25519VerificationKey2020"}async sign({verifyData:t,proof:e}){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:t});return e.proofValue="z"+f(r),e}async verifySignature({verifyData:t,verificationMethod:e,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 this.LDKeyClass.from(e)).verifier()}return o.verify({data:t,signature:i})}async assertVerificationMethod({verificationMethod:t}){let e;if("Ed25519VerificationKey2020"===t.type)e=kt;else{if("Ed25519VerificationKey2018"!==t.type)throw new Error(`Unsupported key type "${t.type}".`);e=Ot}if(!Lt({document:t,contextUrl:e}))throw new TypeError(`The verification method (key) must contain "${e}" context.`);if(void 0!==t.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:t,documentLoader:e}){if(this.key)return this.key.export({publicKey:!0});let{verificationMethod:r}=t;if("object"==typeof r&&(r=r.id),!r)throw new Error('No "verificationMethod" found in proof.');const{document:n}=await e(r);return r="string"==typeof n?JSON.parse(n):n,await this.assertVerificationMethod({verificationMethod:r}),"Ed25519VerificationKey2018"===r.type&&(r=(await dt.fromEd25519VerificationKey2018({keyPair:r})).export({publicKey:!0,includeContext:!0})),r}async matchProof({proof:t,document:e,purpose:r,documentLoader:n}){if(!Lt({document:e,contextUrl:kt}))return!1;if(!await super.matchProof({proof:t,document:e,purpose:r,documentLoader:n}))return!1;if(!this.key)return!0;const{verificationMethod:i}=t;return"object"==typeof i?i.id===this.key.id:i===this.key.id}};function Lt({document:t,contextUrl:e}){const r=t["@context"];return r===e||Array.isArray(r)&&r.includes(e)}St.CONTEXT_URL=kt,St.CONTEXT=Et.contexts.get(kt);var Pt,Bt,_t={exports:{}},Mt={};_t.exports=(Pt||(Pt=1,Bt=Mt,Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.staticImplements=function(){return function(t){}}),Mt);var Ut,Nt=_t.exports,It={exports:{}},Rt={};It.exports=(Ut||(Ut=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.staticImplements=function(){return function(t){}}}(Rt)),Rt);var jt=It.exports;function Ct(t,e,r,n,i,o,a){try{var c=t[o](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function Vt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Ct(o,n,i,a,c,"next",t)}function c(t){Ct(o,n,i,a,c,"throw",t)}a(void 0)}))}}function Xt(){return Xt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Xt.apply(this,arguments)}var Dt=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=e&&e.prototype instanceof w?e:w,o=Object.create(i.prototype),a=new S(n||[]);return o._invoke=function(t,e,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 P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var c=A(a,r);if(c){if(c===d)continue;return c}}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 s=f(t,e,r);if("normal"===s.type){if(n=r.done?h:l,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=h,r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p="suspendedStart",l="suspendedYield",y="executing",h="completed",d={};function w(){}function v(){}function g(){}var m={};m[o]=function(){return this};var b=Object.getPrototypeOf,x=b&&b(b(L([])));x&&x!==r&&n.call(x,o)&&(m=x);var E=g.prototype=w.prototype=Object.create(m);function K(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,c){var s=f(t[i],t,o);if("throw"!==s.type){var u=s.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function A(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,A(t,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,t.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[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function L(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:P}}function P(){return{value:e,done:!0}}return v.prototype=E.constructor=g,g.constructor=v,v.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},K(T.prototype),T.prototype[a]=function(){return this},t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new T(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},K(E),s(E,c,"Generator"),E[o]=function(){return this},E.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return c.type="throw",c.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){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(t,e){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"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function Jt(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),c=i.charCodeAt(0);if(255!==e[c])throw new TypeError(i+" is ambiguous");e[c]=n}var s=t.length,u=t.charAt(0),f=Math.log(s)/Math.log(256),p=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return o.alloc(0);var r=0;if(" "!==t[r]){for(var n=0,i=0;t[r]===u;)n++,r++;for(var a=(t.length-r)*f+1>>>0,c=new Uint8Array(a);t[r];){var p=e[t.charCodeAt(r)];if(255===p)return;for(var l=0,y=a-1;(0!==p||l<i)&&-1!==y;y--,l++)p+=s*c[y]>>>0,c[y]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,r++}if(" "!==t[r]){for(var h=a-i;h!==a&&0===c[h];)h++;var d=o.allocUnsafe(n+(a-h));d.fill(0,0,n);for(var w=n;h!==a;)d[w++]=c[h++];return d}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=o.from(e)),!a(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,c=e.length;i!==c&&0===e[i];)i++,r++;for(var f=(c-i)*p+1>>>0,l=new Uint8Array(f);i!==c;){for(var y=e[i],h=0,d=f-1;(0!==y||h<n)&&-1!==d;d--,h++)y+=256*l[d]>>>0,l[d]=y%s>>>0,y=y/s>>>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+=t.charAt(l[w]);return v},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}var zt,Ft=Jt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Wt=function(t){return o.from(t||"").toString("base64")},Gt=function(t){return Wt(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},qt=function(t,e){void 0===e&&(e="base58btc");var r=new Uint8Array(2+t.length);if(r[0]=236,r[1]=1,r.set(t,2),"base58btc"===e)return"z"+Ft.encode(r);if("base64url"===e)return"u"+Gt(r);throw new Error("Unsupported encoding: "+e)},Zt=function(t){return Uint8Array.from(o.from(t.x,"base64"))},Ht={JsonWebKey2020:function(t){var e,r=Zt(t.publicKeyJwk),n=void 0;t.privateKeyJwk&&(n=(e=t.privateKeyJwk,{publicKey:Zt(e),privateKey:Uint8Array.from(o.from(e.d,"base64"))}).privateKey);return{publicKey:r,privateKey:n}},X25519KeyAgreementKey2019:function(t){var e=Ft.decode(t.publicKeyBase58),r=void 0;return t.privateKeyBase58&&(r=Uint8Array.from(Ft.decode(t.privateKeyBase58))),{publicKey:e,privateKey:r}}},$t={JsonWebKey2020:function(t,e,r,n){var i={kty:"OKP",crv:"X25519",x:Gt(r)},o={id:t,type:"JsonWebKey2020",controller:e,publicKeyJwk:i};return n&&(o.privateKeyJwk=Xt({},i,{d:Gt(n)})),o},X25519KeyAgreementKey2019:function(t,e,r,n){var i={id:t,type:"X25519KeyAgreementKey2019",controller:e,publicKeyBase58:Ft.encode(r)};return n&&(i.privateKeyBase58=Ft.encode(n)),i}},Yt=zt=function(){function t(t){this.type="JsonWebKey2020",this.id=t.id,this.type=t.type||"JsonWebKey2020",this.controller=t.controller,this.publicKey=t.publicKey,this.privateKey=t.privateKey}t.fingerprintFromPublicKey=function(){var t=Vt(Dt.mark((function t(e){var r,n;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,zt.from(e);case 2:return r=t.sent,n=r.publicKey,t.abrupt("return",qt(n));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.fromFingerprint=function(){var t=Vt(Dt.mark((function t(e){var r,n,i,o;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.fingerprint,236!==(n=Ft.decode(r.substring(1)))[0]||1!==n[1]){t.next=12;break}return t.next=5,zt.from({id:"",controller:"",type:"X25519KeyAgreementKey2019",publicKeyBase58:Ft.encode(n.slice(2))});case 5:return i=t.sent,t.next=8,i.fingerprint();case 8:return o=t.sent,i.id="did:key:"+o+"#"+o,i.controller="did:key:"+o,t.abrupt("return",i);case 12:throw new Error("Unsupported fingerprint type: "+r);case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var e=t.prototype;return e.fingerprint=function(){var t=Vt(Dt.mark((function t(){return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",qt(this.publicKey));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.export=function(){var t=Vt(Dt.mark((function t(e){return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===e&&(e={privateKey:!1,type:"JsonWebKey2020"}),!$t[e.type]){t.next=3;break}return t.abrupt("return",$t[e.type](this.id,this.controller,this.publicKey,e.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(e));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.deriveSecret=function(){var t=Vt(Dt.mark((function t(e){var r,n,i;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.publicKey,t.next=3,zt.from(r);case 3:if(n=t.sent,this.privateKey){t.next=6;break}throw new Error("No private key available for deriveSecret");case 6:return i=h.sharedKey(this.privateKey,n.publicKey,!0),t.abrupt("return",i);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}();function Qt(t,e,r,n,i,o,a){try{var c=t[o](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Qt(o,n,i,a,c,"next",t)}function c(t){Qt(o,n,i,a,c,"throw",t)}a(void 0)}))}}function ee(){return ee=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},ee.apply(this,arguments)}Yt.generate=function(){var t=Vt(Dt.mark((function t(e){var r,n,i,o,a;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.secureRandom,n=h.generateKeyPair({isAvailable:!0,randomBytes:r}),i=qt(n.publicKey),a=(o="did:key:"+i)+"#"+i,t.abrupt("return",new zt({id:a,type:"JsonWebKey2020",controller:o,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),Yt.from=function(){var t=Vt(Dt.mark((function t(e){var r,n,i;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Ht[e.type](e),n=r.publicKey,i=r.privateKey,t.abrupt("return",new zt({id:e.id,type:e.type,controller:e.controller,publicKey:n,privateKey:i}));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),Yt=zt=y([jt.staticImplements()],Yt);var re=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=e&&e.prototype instanceof w?e:w,o=Object.create(i.prototype),a=new S(n||[]);return o._invoke=function(t,e,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 P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var c=A(a,r);if(c){if(c===d)continue;return c}}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 s=f(t,e,r);if("normal"===s.type){if(n=r.done?h:l,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=h,r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p="suspendedStart",l="suspendedYield",y="executing",h="completed",d={};function w(){}function v(){}function g(){}var m={};m[o]=function(){return this};var b=Object.getPrototypeOf,x=b&&b(b(L([])));x&&x!==r&&n.call(x,o)&&(m=x);var E=g.prototype=w.prototype=Object.create(m);function K(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,c){var s=f(t[i],t,o);if("throw"!==s.type){var u=s.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function A(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,A(t,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,t.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[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function L(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:P}}function P(){return{value:e,done:!0}}return v.prototype=E.constructor=g,g.constructor=v,v.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},K(T.prototype),T.prototype[a]=function(){return this},t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new T(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},K(E),s(E,c,"Generator"),E[o]=function(){return this},E.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return c.type="throw",c.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){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(t,e){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"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function ne(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),c=i.charCodeAt(0);if(255!==e[c])throw new TypeError(i+" is ambiguous");e[c]=n}var s=t.length,u=t.charAt(0),f=Math.log(s)/Math.log(256),p=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return o.alloc(0);var r=0;if(" "!==t[r]){for(var n=0,i=0;t[r]===u;)n++,r++;for(var a=(t.length-r)*f+1>>>0,c=new Uint8Array(a);t[r];){var p=e[t.charCodeAt(r)];if(255===p)return;for(var l=0,y=a-1;(0!==p||l<i)&&-1!==y;y--,l++)p+=s*c[y]>>>0,c[y]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,r++}if(" "!==t[r]){for(var h=a-i;h!==a&&0===c[h];)h++;var d=o.allocUnsafe(n+(a-h));d.fill(0,0,n);for(var w=n;h!==a;)d[w++]=c[h++];return d}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=o.from(e)),!a(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,c=e.length;i!==c&&0===e[i];)i++,r++;for(var f=(c-i)*p+1>>>0,l=new Uint8Array(f);i!==c;){for(var y=e[i],h=0,d=f-1;(0!==y||h<n)&&-1!==d;d--,h++)y+=256*l[d]>>>0,l[d]=y%s>>>0,y=y/s>>>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+=t.charAt(l[w]);return v},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}var ie,oe=ne("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),ae=function(t){return o.from(t||"").toString("base64")},ce=function(t){return ae(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},se=function(t,e){void 0===e&&(e="base58btc");var r=new Uint8Array(2+t.length);if(r[0]=237,r[1]=1,r.set(t,2),"base58btc"===e)return"z"+oe.encode(r);if("base64url"===e)return"u"+ce(r);throw new Error("Unsupported encoding: "+e)},ue=function(t){return Uint8Array.from(o.from(t.x,"base64"))},fe={JsonWebKey2020:function(t){var e,r=ue(t.publicKeyJwk),n=void 0;t.privateKeyJwk&&(n=(e=t.privateKeyJwk,{publicKey:ue(e),privateKey:Uint8Array.from(o.concat([o.from(e.d,"base64"),o.from(e.x,"base64")]))}).privateKey);return{publicKey:r,privateKey:n}},Ed25519VerificationKey2018:function(t){var e=oe.decode(t.publicKeyBase58),r=void 0;return t.privateKeyBase58&&(r=Uint8Array.from(oe.decode(t.privateKeyBase58))),{publicKey:e,privateKey:r}}},pe=function(t){if(!fe[t.type])throw new Error("Cannot import from unsupported type: "+JSON.stringify(t,null,2));return fe[t.type](t)},le={JsonWebKey2020:function(t,e,r,n){var i={kty:"OKP",crv:"Ed25519",x:ce(r)},o={id:t,type:"JsonWebKey2020",controller:e,publicKeyJwk:i};return n&&(o.privateKeyJwk=ee({},i,{d:ce(n.slice(0,n.length/2))})),o},Ed25519VerificationKey2018:function(t,e,r,n){var i={id:t,type:"Ed25519VerificationKey2018",controller:e,publicKeyBase58:oe.encode(r)};return n&&(i.privateKeyBase58=oe.encode(n)),i}},ye={EdDsa:{__proto__:null,signer:function(t){return{sign:function(e){return te(re.mark((function r(){var n;return re.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=e.data,r.abrupt("return",d.sign(t,n));case 2:case"end":return r.stop()}}),r)})))()}}},verifier:function(t){return{verify:function(e){return te(re.mark((function r(){var n,i,o;return re.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=e.data,i=e.signature,o=!1;try{o=d.verify(t,n,i)}catch(t){}return r.abrupt("return",o);case 4:case"end":return r.stop()}}),r)})))()}}}}},he=ie=function(){function t(t){this.type="JsonWebKey2020",this.id=t.id,this.type=t.type||"JsonWebKey2020",this.controller=t.controller,this.publicKey=t.publicKey,this.privateKey=t.privateKey}t.fingerprintFromPublicKey=function(){var t=te(re.mark((function t(e){var r,n;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie.from(e);case 2:return r=t.sent,n=r.publicKey,t.abrupt("return",se(n));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.toX25519KeyPair=function(){var t=te(re.mark((function t(e){var r,n,i;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=d.convertPublicKeyToX25519(e.publicKey),n=void 0,e.privateKey&&(n=d.convertSecretKeyToX25519(e.privateKey)),i=new Yt({id:"",type:"X25519KeyAgreementKey2019",controller:e.controller,publicKey:r,privateKey:n}),t.t0=e.controller+"#",t.next=7,i.fingerprint();case 7:return t.t1=t.sent,i.id=t.t0+t.t1,t.abrupt("return",i);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.fromFingerprint=function(){var t=te(re.mark((function t(e){var r,n,i,o;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.fingerprint,237!==(n=oe.decode(r.substring(1)))[0]||1!==n[1]){t.next=12;break}return t.next=5,ie.from({id:"",controller:"",type:"Ed25519VerificationKey2018",publicKeyBase58:oe.encode(n.slice(2))});case 5:return i=t.sent,t.next=8,i.fingerprint();case 8:return o=t.sent,i.id="did:key:"+o+"#"+o,i.controller="did:key:"+o,t.abrupt("return",i);case 12:throw new Error("Unsupported fingerprint type: "+r);case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var e=t.prototype;return e.fingerprint=function(){var t=te(re.mark((function t(){return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",se(this.publicKey));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.export=function(){var t=te(re.mark((function t(e){return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===e&&(e={privateKey:!1,type:"JsonWebKey2020"}),!le[e.type]){t.next=3;break}return t.abrupt("return",le[e.type](this.id,this.controller,this.publicKey,e.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(e));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.signer=function(t){if(void 0===t&&(t="EdDsa"),!this.privateKey)throw new Error("No private key to sign with.");if(ye[t])return ye[t].signer(this.privateKey);throw new Error("Unsupported suite type "+t)},e.verifier=function(t){if(void 0===t&&(t="EdDsa"),!this.publicKey)throw new Error("No public key to verify with.");if(ye[t])return ye[t].verifier(this.publicKey);throw new Error("Unsupported suite type "+t)},e.getDerivedKeyPairs=function(){var t=te(re.mark((function t(){return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,ie.toX25519KeyPair(this);case 3:return t.t1=t.sent,t.abrupt("return",[t.t0,t.t1]);case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}();he.generate=function(){var t=te(re.mark((function t(e){var r,n,i,o,a;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.secureRandom,n=d.generateKeyPair({isAvailable:!0,randomBytes:r}),i=se(n.publicKey),a=(o="did:key:"+i)+"#"+i,t.abrupt("return",new ie({id:a,type:"JsonWebKey2020",controller:o,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),he.from=function(){var t=te(re.mark((function t(e){var r,n,i;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=pe(e),n=r.publicKey,i=r.privateKey,t.abrupt("return",new ie({id:e.id,type:e.type,controller:e.controller,publicKey:n,privateKey:i}));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),he=ie=y([Nt.staticImplements()],he);const{purposes:{AssertionProofPurpose:de}}=c;var we;!function(t){t.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",t.checkDocumentSignature="checkDocumentSignature"}(we||(we={}));class ve extends w{verificationProcess=[we.retrieveVerificationMethodPublicKey,we.checkDocumentSignature];documentToVerify;issuer;proof;type="Ed25519Signature2020";verificationKey;publicKey;constructor(t){super(t),t.executeStep&&(this.executeStep=t.executeStep),this.documentToVerify=t.document,this.issuer=t.issuer,this.proof=t.proof,this.validateProofType()}async init(){}async verifyProof(){for(const t of this.verificationProcess){if(!this[t])return void console.error("verification logic for",t,"not implemented");await this[t]()}}async verifyIdentity(){}getProofVerificationSteps(e){return this.verificationProcess.map((r=>t.verifier.convertToVerificationSubsteps(e,r)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(t){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(t,e,r){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async publicKeyJwkToString(t){return await he.fingerprintFromPublicKey(t)}validateProofType(){const t=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(t!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${t}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){e[this.documentToVerify.issuer]=this.issuer.didDocument;return function(t){return t in e?{contextUrl:null,document:e[t],documentUrl:t}:s.documentLoader(t)}}retrieveInitialDocument(){const t=r(this.documentToVerify);if(Array.isArray(t.proof)){const e=t.proof.find((t=>t.type===this.type));delete t.proof,t.proof=e}return t}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(we.retrieveVerificationMethodPublicKey,(async()=>{const t=this.issuer.didDocument.verificationMethod.find((t=>t.id===this.proof.verificationMethod));if(!t)throw new n(we.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");try{this.publicKey=t.publicKeyMultibase??await this.publicKeyJwkToString(t)}catch(t){console.error("ERROR retrieving Ed25519Signature2020 public key",t)}const e=await dt.from({...t});if(!e)throw new n(we.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(e.revoked)throw new n(we.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return e}),this.type)}async checkDocumentSignature(){await this.executeStep(we.checkDocumentSignature,(async()=>{const t=new St({key:this.verificationKey});t.date=new Date(Date.now()).toISOString();const e=await c.verify(this.retrieveInitialDocument(),{suite:t,purpose:new de,documentLoader:this.generateDocumentLoader()});if(!e.verified)throw console.error(JSON.stringify(e,null,2)),new n(we.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed`);console.log("Credential Ed25519 signature successfully verified")}),this.type)}}export{ve as default};
52
+ const{suites:{LinkedDataSignature:At}}=c,kt=Et.constants.CONTEXT_URL,Ot=Tt.constants.CONTEXT_URL;let St=class extends At{constructor({key:t,signer:e,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}={}){super({type:"Ed25519Signature2020",LDKeyClass:dt,contextUrl:kt,key:t,signer:e,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}),this.requiredKeyType="Ed25519VerificationKey2020"}async sign({verifyData:t,proof:e}){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:t});return e.proofValue="z"+f(r),e}async verifySignature({verifyData:t,verificationMethod:e,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 this.LDKeyClass.from(e)).verifier()}return o.verify({data:t,signature:i})}async assertVerificationMethod({verificationMethod:t}){let e;if("Ed25519VerificationKey2020"===t.type)e=kt;else{if("Ed25519VerificationKey2018"!==t.type)throw new Error(`Unsupported key type "${t.type}".`);e=Ot}if(!Lt({document:t,contextUrl:e}))throw new TypeError(`The verification method (key) must contain "${e}" context.`);if(void 0!==t.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:t,documentLoader:e}){if(this.key)return this.key.export({publicKey:!0});let{verificationMethod:r}=t;if("object"==typeof r&&(r=r.id),!r)throw new Error('No "verificationMethod" found in proof.');const{document:n}=await e(r);return r="string"==typeof n?JSON.parse(n):n,await this.assertVerificationMethod({verificationMethod:r}),"Ed25519VerificationKey2018"===r.type&&(r=(await dt.fromEd25519VerificationKey2018({keyPair:r})).export({publicKey:!0,includeContext:!0})),r}async matchProof({proof:t,document:e,purpose:r,documentLoader:n}){if(!Lt({document:e,contextUrl:kt}))return!1;if(!await super.matchProof({proof:t,document:e,purpose:r,documentLoader:n}))return!1;if(!this.key)return!0;const{verificationMethod:i}=t;return"object"==typeof i?i.id===this.key.id:i===this.key.id}};function Lt({document:t,contextUrl:e}){const r=t["@context"];return r===e||Array.isArray(r)&&r.includes(e)}St.CONTEXT_URL=kt,St.CONTEXT=Et.contexts.get(kt);var Pt,Bt,_t={exports:{}},Mt={};_t.exports=(Pt||(Pt=1,Bt=Mt,Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.staticImplements=function(){return function(t){}}),Mt);var Ut,Nt=_t.exports,It={exports:{}},jt={};It.exports=(Ut||(Ut=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.staticImplements=function(){return function(t){}}}(jt)),jt);var Rt=It.exports;function Ct(t,e,r,n,i,o,a){try{var c=t[o](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function Vt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Ct(o,n,i,a,c,"next",t)}function c(t){Ct(o,n,i,a,c,"throw",t)}a(void 0)}))}}function Xt(){return Xt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Xt.apply(this,arguments)}var Dt=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=e&&e.prototype instanceof w?e:w,o=Object.create(i.prototype),a=new S(n||[]);return o._invoke=function(t,e,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 P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var c=A(a,r);if(c){if(c===d)continue;return c}}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 s=f(t,e,r);if("normal"===s.type){if(n=r.done?h:l,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=h,r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p="suspendedStart",l="suspendedYield",y="executing",h="completed",d={};function w(){}function v(){}function g(){}var m={};m[o]=function(){return this};var b=Object.getPrototypeOf,x=b&&b(b(L([])));x&&x!==r&&n.call(x,o)&&(m=x);var E=g.prototype=w.prototype=Object.create(m);function K(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,c){var s=f(t[i],t,o);if("throw"!==s.type){var u=s.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function A(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,A(t,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,t.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[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function L(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:P}}function P(){return{value:e,done:!0}}return v.prototype=E.constructor=g,g.constructor=v,v.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},K(T.prototype),T.prototype[a]=function(){return this},t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new T(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},K(E),s(E,c,"Generator"),E[o]=function(){return this},E.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return c.type="throw",c.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){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(t,e){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"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function Jt(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),c=i.charCodeAt(0);if(255!==e[c])throw new TypeError(i+" is ambiguous");e[c]=n}var s=t.length,u=t.charAt(0),f=Math.log(s)/Math.log(256),p=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return o.alloc(0);var r=0;if(" "!==t[r]){for(var n=0,i=0;t[r]===u;)n++,r++;for(var a=(t.length-r)*f+1>>>0,c=new Uint8Array(a);t[r];){var p=e[t.charCodeAt(r)];if(255===p)return;for(var l=0,y=a-1;(0!==p||l<i)&&-1!==y;y--,l++)p+=s*c[y]>>>0,c[y]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,r++}if(" "!==t[r]){for(var h=a-i;h!==a&&0===c[h];)h++;var d=o.allocUnsafe(n+(a-h));d.fill(0,0,n);for(var w=n;h!==a;)d[w++]=c[h++];return d}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=o.from(e)),!a(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,c=e.length;i!==c&&0===e[i];)i++,r++;for(var f=(c-i)*p+1>>>0,l=new Uint8Array(f);i!==c;){for(var y=e[i],h=0,d=f-1;(0!==y||h<n)&&-1!==d;d--,h++)y+=256*l[d]>>>0,l[d]=y%s>>>0,y=y/s>>>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+=t.charAt(l[w]);return v},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}var zt,Ft=Jt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Wt=function(t){return o.from(t||"").toString("base64")},qt=function(t){return Wt(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},Gt=function(t,e){void 0===e&&(e="base58btc");var r=new Uint8Array(2+t.length);if(r[0]=236,r[1]=1,r.set(t,2),"base58btc"===e)return"z"+Ft.encode(r);if("base64url"===e)return"u"+qt(r);throw new Error("Unsupported encoding: "+e)},Zt=function(t){return Uint8Array.from(o.from(t.x,"base64"))},Ht={JsonWebKey2020:function(t){var e,r=Zt(t.publicKeyJwk),n=void 0;t.privateKeyJwk&&(n=(e=t.privateKeyJwk,{publicKey:Zt(e),privateKey:Uint8Array.from(o.from(e.d,"base64"))}).privateKey);return{publicKey:r,privateKey:n}},X25519KeyAgreementKey2019:function(t){var e=Ft.decode(t.publicKeyBase58),r=void 0;return t.privateKeyBase58&&(r=Uint8Array.from(Ft.decode(t.privateKeyBase58))),{publicKey:e,privateKey:r}}},$t={JsonWebKey2020:function(t,e,r,n){var i={kty:"OKP",crv:"X25519",x:qt(r)},o={id:t,type:"JsonWebKey2020",controller:e,publicKeyJwk:i};return n&&(o.privateKeyJwk=Xt({},i,{d:qt(n)})),o},X25519KeyAgreementKey2019:function(t,e,r,n){var i={id:t,type:"X25519KeyAgreementKey2019",controller:e,publicKeyBase58:Ft.encode(r)};return n&&(i.privateKeyBase58=Ft.encode(n)),i}},Yt=zt=function(){function t(t){this.type="JsonWebKey2020",this.id=t.id,this.type=t.type||"JsonWebKey2020",this.controller=t.controller,this.publicKey=t.publicKey,this.privateKey=t.privateKey}t.fingerprintFromPublicKey=function(){var t=Vt(Dt.mark((function t(e){var r,n;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,zt.from(e);case 2:return r=t.sent,n=r.publicKey,t.abrupt("return",Gt(n));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.fromFingerprint=function(){var t=Vt(Dt.mark((function t(e){var r,n,i,o;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.fingerprint,236!==(n=Ft.decode(r.substring(1)))[0]||1!==n[1]){t.next=12;break}return t.next=5,zt.from({id:"",controller:"",type:"X25519KeyAgreementKey2019",publicKeyBase58:Ft.encode(n.slice(2))});case 5:return i=t.sent,t.next=8,i.fingerprint();case 8:return o=t.sent,i.id="did:key:"+o+"#"+o,i.controller="did:key:"+o,t.abrupt("return",i);case 12:throw new Error("Unsupported fingerprint type: "+r);case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var e=t.prototype;return e.fingerprint=function(){var t=Vt(Dt.mark((function t(){return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",Gt(this.publicKey));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.export=function(){var t=Vt(Dt.mark((function t(e){return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===e&&(e={privateKey:!1,type:"JsonWebKey2020"}),!$t[e.type]){t.next=3;break}return t.abrupt("return",$t[e.type](this.id,this.controller,this.publicKey,e.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(e));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.deriveSecret=function(){var t=Vt(Dt.mark((function t(e){var r,n,i;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.publicKey,t.next=3,zt.from(r);case 3:if(n=t.sent,this.privateKey){t.next=6;break}throw new Error("No private key available for deriveSecret");case 6:return i=h.sharedKey(this.privateKey,n.publicKey,!0),t.abrupt("return",i);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}();function Qt(t,e,r,n,i,o,a){try{var c=t[o](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Qt(o,n,i,a,c,"next",t)}function c(t){Qt(o,n,i,a,c,"throw",t)}a(void 0)}))}}function ee(){return ee=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},ee.apply(this,arguments)}Yt.generate=function(){var t=Vt(Dt.mark((function t(e){var r,n,i,o,a;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.secureRandom,n=h.generateKeyPair({isAvailable:!0,randomBytes:r}),i=Gt(n.publicKey),a=(o="did:key:"+i)+"#"+i,t.abrupt("return",new zt({id:a,type:"JsonWebKey2020",controller:o,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),Yt.from=function(){var t=Vt(Dt.mark((function t(e){var r,n,i;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Ht[e.type](e),n=r.publicKey,i=r.privateKey,t.abrupt("return",new zt({id:e.id,type:e.type,controller:e.controller,publicKey:n,privateKey:i}));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),Yt=zt=y([Rt.staticImplements()],Yt);var re=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=e&&e.prototype instanceof w?e:w,o=Object.create(i.prototype),a=new S(n||[]);return o._invoke=function(t,e,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 P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var c=A(a,r);if(c){if(c===d)continue;return c}}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 s=f(t,e,r);if("normal"===s.type){if(n=r.done?h:l,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=h,r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p="suspendedStart",l="suspendedYield",y="executing",h="completed",d={};function w(){}function v(){}function g(){}var m={};m[o]=function(){return this};var b=Object.getPrototypeOf,x=b&&b(b(L([])));x&&x!==r&&n.call(x,o)&&(m=x);var E=g.prototype=w.prototype=Object.create(m);function K(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,c){var s=f(t[i],t,o);if("throw"!==s.type){var u=s.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function A(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,A(t,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,t.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[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function L(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:P}}function P(){return{value:e,done:!0}}return v.prototype=E.constructor=g,g.constructor=v,v.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},K(T.prototype),T.prototype[a]=function(){return this},t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new T(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},K(E),s(E,c,"Generator"),E[o]=function(){return this},E.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return c.type="throw",c.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){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(t,e){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"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function ne(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),c=i.charCodeAt(0);if(255!==e[c])throw new TypeError(i+" is ambiguous");e[c]=n}var s=t.length,u=t.charAt(0),f=Math.log(s)/Math.log(256),p=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return o.alloc(0);var r=0;if(" "!==t[r]){for(var n=0,i=0;t[r]===u;)n++,r++;for(var a=(t.length-r)*f+1>>>0,c=new Uint8Array(a);t[r];){var p=e[t.charCodeAt(r)];if(255===p)return;for(var l=0,y=a-1;(0!==p||l<i)&&-1!==y;y--,l++)p+=s*c[y]>>>0,c[y]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,r++}if(" "!==t[r]){for(var h=a-i;h!==a&&0===c[h];)h++;var d=o.allocUnsafe(n+(a-h));d.fill(0,0,n);for(var w=n;h!==a;)d[w++]=c[h++];return d}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=o.from(e)),!a(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,c=e.length;i!==c&&0===e[i];)i++,r++;for(var f=(c-i)*p+1>>>0,l=new Uint8Array(f);i!==c;){for(var y=e[i],h=0,d=f-1;(0!==y||h<n)&&-1!==d;d--,h++)y+=256*l[d]>>>0,l[d]=y%s>>>0,y=y/s>>>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+=t.charAt(l[w]);return v},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}var ie,oe=ne("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),ae=function(t){return o.from(t||"").toString("base64")},ce=function(t){return ae(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},se=function(t,e){void 0===e&&(e="base58btc");var r=new Uint8Array(2+t.length);if(r[0]=237,r[1]=1,r.set(t,2),"base58btc"===e)return"z"+oe.encode(r);if("base64url"===e)return"u"+ce(r);throw new Error("Unsupported encoding: "+e)},ue=function(t){return Uint8Array.from(o.from(t.x,"base64"))},fe={JsonWebKey2020:function(t){var e,r=ue(t.publicKeyJwk),n=void 0;t.privateKeyJwk&&(n=(e=t.privateKeyJwk,{publicKey:ue(e),privateKey:Uint8Array.from(o.concat([o.from(e.d,"base64"),o.from(e.x,"base64")]))}).privateKey);return{publicKey:r,privateKey:n}},Ed25519VerificationKey2018:function(t){var e=oe.decode(t.publicKeyBase58),r=void 0;return t.privateKeyBase58&&(r=Uint8Array.from(oe.decode(t.privateKeyBase58))),{publicKey:e,privateKey:r}}},pe=function(t){if(!fe[t.type])throw new Error("Cannot import from unsupported type: "+JSON.stringify(t,null,2));return fe[t.type](t)},le={JsonWebKey2020:function(t,e,r,n){var i={kty:"OKP",crv:"Ed25519",x:ce(r)},o={id:t,type:"JsonWebKey2020",controller:e,publicKeyJwk:i};return n&&(o.privateKeyJwk=ee({},i,{d:ce(n.slice(0,n.length/2))})),o},Ed25519VerificationKey2018:function(t,e,r,n){var i={id:t,type:"Ed25519VerificationKey2018",controller:e,publicKeyBase58:oe.encode(r)};return n&&(i.privateKeyBase58=oe.encode(n)),i}},ye={EdDsa:{__proto__:null,signer:function(t){return{sign:function(e){return te(re.mark((function r(){var n;return re.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=e.data,r.abrupt("return",d.sign(t,n));case 2:case"end":return r.stop()}}),r)})))()}}},verifier:function(t){return{verify:function(e){return te(re.mark((function r(){var n,i,o;return re.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=e.data,i=e.signature,o=!1;try{o=d.verify(t,n,i)}catch(t){}return r.abrupt("return",o);case 4:case"end":return r.stop()}}),r)})))()}}}}},he=ie=function(){function t(t){this.type="JsonWebKey2020",this.id=t.id,this.type=t.type||"JsonWebKey2020",this.controller=t.controller,this.publicKey=t.publicKey,this.privateKey=t.privateKey}t.fingerprintFromPublicKey=function(){var t=te(re.mark((function t(e){var r,n;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie.from(e);case 2:return r=t.sent,n=r.publicKey,t.abrupt("return",se(n));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.toX25519KeyPair=function(){var t=te(re.mark((function t(e){var r,n,i;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=d.convertPublicKeyToX25519(e.publicKey),n=void 0,e.privateKey&&(n=d.convertSecretKeyToX25519(e.privateKey)),i=new Yt({id:"",type:"X25519KeyAgreementKey2019",controller:e.controller,publicKey:r,privateKey:n}),t.t0=e.controller+"#",t.next=7,i.fingerprint();case 7:return t.t1=t.sent,i.id=t.t0+t.t1,t.abrupt("return",i);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.fromFingerprint=function(){var t=te(re.mark((function t(e){var r,n,i,o;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.fingerprint,237!==(n=oe.decode(r.substring(1)))[0]||1!==n[1]){t.next=12;break}return t.next=5,ie.from({id:"",controller:"",type:"Ed25519VerificationKey2018",publicKeyBase58:oe.encode(n.slice(2))});case 5:return i=t.sent,t.next=8,i.fingerprint();case 8:return o=t.sent,i.id="did:key:"+o+"#"+o,i.controller="did:key:"+o,t.abrupt("return",i);case 12:throw new Error("Unsupported fingerprint type: "+r);case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var e=t.prototype;return e.fingerprint=function(){var t=te(re.mark((function t(){return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",se(this.publicKey));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.export=function(){var t=te(re.mark((function t(e){return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===e&&(e={privateKey:!1,type:"JsonWebKey2020"}),!le[e.type]){t.next=3;break}return t.abrupt("return",le[e.type](this.id,this.controller,this.publicKey,e.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(e));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.signer=function(t){if(void 0===t&&(t="EdDsa"),!this.privateKey)throw new Error("No private key to sign with.");if(ye[t])return ye[t].signer(this.privateKey);throw new Error("Unsupported suite type "+t)},e.verifier=function(t){if(void 0===t&&(t="EdDsa"),!this.publicKey)throw new Error("No public key to verify with.");if(ye[t])return ye[t].verifier(this.publicKey);throw new Error("Unsupported suite type "+t)},e.getDerivedKeyPairs=function(){var t=te(re.mark((function t(){return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,ie.toX25519KeyPair(this);case 3:return t.t1=t.sent,t.abrupt("return",[t.t0,t.t1]);case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}();he.generate=function(){var t=te(re.mark((function t(e){var r,n,i,o,a;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.secureRandom,n=d.generateKeyPair({isAvailable:!0,randomBytes:r}),i=se(n.publicKey),a=(o="did:key:"+i)+"#"+i,t.abrupt("return",new ie({id:a,type:"JsonWebKey2020",controller:o,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),he.from=function(){var t=te(re.mark((function t(e){var r,n,i;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=pe(e),n=r.publicKey,i=r.privateKey,t.abrupt("return",new ie({id:e.id,type:e.type,controller:e.controller,publicKey:n,privateKey:i}));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),he=ie=y([Nt.staticImplements()],he);const{purposes:{AssertionProofPurpose:de}}=c;var we;!function(t){t.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",t.checkDocumentSignature="checkDocumentSignature"}(we||(we={}));class ve extends w{verificationProcess=[we.retrieveVerificationMethodPublicKey,we.checkDocumentSignature];documentToVerify;issuer;proof;type="Ed25519Signature2020";verificationKey;publicKey;constructor(t){super(t),t.executeStep&&(this.executeStep=t.executeStep),this.documentToVerify=t.document,this.issuer=t.issuer,this.proof=t.proof,this.validateProofType()}async init(){}async verifyProof(){for(const t of this.verificationProcess){if(!this[t])return void console.error("verification logic for",t,"not implemented");await this[t]()}}async verifyIdentity(){}getProofVerificationSteps(e){return this.verificationProcess.map((r=>t.verifier.convertToVerificationSubsteps(e,r)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(t){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(t,e,r){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async publicKeyJwkToString(t){return await he.fingerprintFromPublicKey(t)}validateProofType(){const t=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(t!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${t}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){e[this.documentToVerify.issuer]=this.issuer.didDocument;return function(t){return t in e?{contextUrl:null,document:e[t],documentUrl:t}:s.documentLoader(t)}}retrieveInitialDocument(){const t=r(this.documentToVerify);if(Array.isArray(t.proof)){const e=t.proof.find((t=>t.type===this.type));delete t.proof,t.proof=e}return t}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(we.retrieveVerificationMethodPublicKey,(async()=>{const t=this.issuer.didDocument.verificationMethod.find((t=>t.id===this.proof.verificationMethod));if(!t)throw new n(we.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");try{this.publicKey=t.publicKeyMultibase??await this.publicKeyJwkToString(t)}catch(t){console.error("ERROR retrieving Ed25519Signature2020 public key",t)}const e=await dt.from({...t});if(!e)throw new n(we.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(e.revoked)throw new n(we.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return e}),this.type)}async checkDocumentSignature(){await this.executeStep(we.checkDocumentSignature,(async()=>{const t=new St({key:this.verificationKey});t.date=new Date(Date.now()).toISOString();const e=await c.verify(this.retrieveInitialDocument(),{suite:t,purpose:new de,documentLoader:this.generateDocumentLoader()});if(!e.verified)throw console.error(JSON.stringify(e,null,2)),new n(we.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed`);console.log("Credential Ed25519 signature successfully verified")}),this.type)}}export{ve as default};
@@ -1 +1 @@
1
- import{d as e,r as t,b as i,V as s,e as r,f as o,h as a}from"./main.js";import"./pako.esm-jjCKMBM4-RAILONW0.js";import{j as n}from"./jsonld-CXlzLf4P-ioHKtwiZ.js";import{s as c}from"./sha256-wKeS8_4l-9eo2gOQb.js";import{e as h}from"./ensureValidIssuingKey-zZEv5-cH-UoJe_Wnf.js";import"./index-xsnp_Fid-o1HUYRUQ.js";import{S as u}from"./Suite-Bhitn5l3-e2QgHGhx.js";function p(e){e=e.trim();const t=[];for(let i=0;i<e.length;i+=2)t.push(parseInt(e.substring(i,i+2),16));return t}function f(e){const t=o(e);return"proof"in t?function(e){const t=o(e);if(!Array.isArray(e.proof))return delete t.proof,t;const i=e.proof.find((e=>"ChainedProof2021"!==e.type));return t.proof=i,t}(t):("signature"in t&&delete t.signature,t)}async function l(e){e["@context"].find((e=>i(e)&&"@vocab"in e))||e["@context"].push({"@vocab":"http://fallback.org/"});const t=f(e),o={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return e in a?{contextUrl:null,document:a[e],documentUrl:e}:n.documentLoader(e)}};let h;try{h=await n.normalize(t,o)}catch(e){throw console.error(e),new s("computeLocalHash",r("errors","failedJsonLdNormalization"))}const u=function(e){const t=e.split("\n"),i=/<http:\/\/fallback\.org\/(.*)>/,s=t.map((e=>i.exec(e))).filter((e=>null!=e));if(s.length>0){const e=s.map((e=>e[1])).sort();return Array.from(new Set(e))}return null}(h);if(u)throw new s("computeLocalHash",`${r("errors","foundUnmappedFields")}: ${u.join(", ")}`);return c(function(e){const t=[];for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);s<128?t.push(s):s<2048?t.push(192|s>>6,128|63&s):s<55296||s>=57344?t.push(224|s>>12,128|s>>6&63,128|63&s):(i++,s=65536+((1023&s)<<10|1023&e.charCodeAt(i)),t.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|63&s))}return t}(h))}var d;!function(e){e.getTransactionId="getTransactionId",e.computeLocalHash="computeLocalHash",e.fetchRemoteHash="fetchRemoteHash",e.parseIssuerKeys="parseIssuerKeys",e.compareHashes="compareHashes",e.checkMerkleRoot="checkMerkleRoot",e.checkReceipt="checkReceipt",e.checkAuthenticity="checkAuthenticity"}(d||(d={}));class y extends u{verificationProcess=[d.getTransactionId,d.computeLocalHash,d.fetchRemoteHash,d.compareHashes,d.checkMerkleRoot,d.checkReceipt,d.parseIssuerKeys,d.checkAuthenticity];transactionId;localHash;documentToVerify;txData;chain;explorerAPIs;receipt;issuerPublicKeyList;issuer;proof;type="MerkleProof2017";constructor(t){super(t),t.executeStep&&(this.executeStep=t.executeStep),this.documentToVerify=t.document,this.explorerAPIs=t.explorerAPIs,this.issuer=t.issuer,this.proof=t.proof,this.validateProofType(),this.receipt=this.documentToVerify.signature,this.chain=e.certificates.getChain("",this.receipt),this.transactionId=e.certificates.getTransactionId(this.receipt),this.adaptVerificationProcessToChain()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map((i=>e.verifier.convertToVerificationSubsteps(t,i)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return e.chains.isMockChain(this.chain)?"This mock chain does not support issuing addresses":this.txData?this.txData.issuingAddress:void console.error("Trying to access issuing address when txData not available yet. Did you run the `verify` method yet?")}getIssuerName(){return this.issuer.name}getIssuerProfileDomain(){const e=new URL(this.getIssuerProfileUrl());return e?.hostname}getIssuerProfileUrl(){return this.issuer.id}getSigningDate(){return this.documentToVerify.issuedOn}getChain(){return this.chain}getReceipt(){return this.receipt}getTransactionIdString(){return e.certificates.getTransactionId(this.getReceipt())}getTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}getRawTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}validateProofType(){if(this.proof.type[0]!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${this.proof.type[0]}`)}adaptVerificationProcessToChain(){e.chains.isMockChain(this.chain)&&(t(this.verificationProcess,d.getTransactionId),t(this.verificationProcess,d.fetchRemoteHash),t(this.verificationProcess,d.parseIssuerKeys),t(this.verificationProcess,d.checkMerkleRoot),t(this.verificationProcess,d.checkAuthenticity))}async executeStep(e,t,i){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async getTransactionId(){await this.executeStep(d.getTransactionId,(()=>function(e){if("string"==typeof e&&e.length>0)return e;throw new s("getTransactionId",r("errors","isTransactionIdValid"))}(this.transactionId)),this.type)}async computeLocalHash(){this.localHash=await this.executeStep(d.computeLocalHash,(async()=>await l(this.documentToVerify)),this.type)}async fetchRemoteHash(){this.txData=await this.executeStep(d.fetchRemoteHash,(async()=>await e.verifier.lookForTx({transactionId:this.transactionId,chain:this.chain.code,explorerAPIs:this.explorerAPIs})),this.type)}async compareHashes(){await this.executeStep(d.compareHashes,(()=>function(e,t){if(e!==t)throw new s("compareHashes",r("errors","ensureHashesEqual"));return!0}(this.localHash,this.receipt.targetHash)),this.type)}async checkMerkleRoot(){await this.executeStep(d.checkMerkleRoot,(()=>function(e,t){if(e!==t)throw new s("checkMerkleRoot",r("errors","ensureMerkleRootEqual"));return!0}(this.receipt.merkleRoot,this.txData.remoteHash)),this.type)}async checkReceipt(){await this.executeStep(d.checkReceipt,(()=>{!function(e){let t=e.targetHash;const i=e.merkleRoot;try{const i=e.proof??e.path;if(i)for(const e in i){const r=i[e];let o;if(void 0!==r.left)o=p(`${r.left}${t}`),t=c(o);else{if(void 0===r.right)throw new s("checkReceipt","Trigger catch error.");o=p(`${t}${r.right}`),t=c(o)}}}catch(e){throw new s("checkReceipt",r("errors","ensureValidReceipt"))}if(t!==i)throw new s("checkReceipt",r("errors","invalidMerkleReceipt"))}(this.receipt)}),this.type)}async parseIssuerKeys(){this.issuerPublicKeyList=await this.executeStep(d.parseIssuerKeys,(()=>e.verifier.parseIssuerKeys(this.issuer)),this.type)}async checkAuthenticity(){await this.executeStep(d.checkAuthenticity,(()=>{h(this.issuerPublicKeyList,this.txData.issuingAddress,this.txData.time)}),this.type)}}export{y as default};
1
+ import{d as e,r as t,b as i,V as s,e as r,f as o,h as a}from"./main.js";import"./pako.esm-jjCKMBM4-RAILONW0.js";import{j as n}from"./jsonld-SAOezr4P-ioHKtwiZ.js";import{s as c}from"./sha256-lGrd_b3t-9eo2gOQb.js";import{e as h}from"./ensureValidIssuingKey-U4G_F_Hm-UoJe_Wnf.js";import"./index-aBVDu34R-o1HUYRUQ.js";import{S as u}from"./Suite-Bhitn5l3-e2QgHGhx.js";function p(e){e=e.trim();const t=[];for(let i=0;i<e.length;i+=2)t.push(parseInt(e.substring(i,i+2),16));return t}function f(e){const t=o(e);return"proof"in t?function(e){const t=o(e);if(!Array.isArray(e.proof))return delete t.proof,t;const i=e.proof.find((e=>"ChainedProof2021"!==e.type));return t.proof=i,t}(t):("signature"in t&&delete t.signature,t)}async function l(e){e["@context"].find((e=>i(e)&&"@vocab"in e))||e["@context"].push({"@vocab":"http://fallback.org/"});const t=f(e),o={algorithm:"URDNA2015",format:"application/nquads",documentLoader:function(e){return e in a?{contextUrl:null,document:a[e],documentUrl:e}:n.documentLoader(e)}};let h;try{h=await n.normalize(t,o)}catch(e){throw console.error(e),new s("computeLocalHash",r("errors","failedJsonLdNormalization"))}const u=function(e){const t=e.split("\n"),i=/<http:\/\/fallback\.org\/(.*)>/,s=t.map((e=>i.exec(e))).filter((e=>null!=e));if(s.length>0){const e=s.map((e=>e[1])).sort();return Array.from(new Set(e))}return null}(h);if(u)throw new s("computeLocalHash",`${r("errors","foundUnmappedFields")}: ${u.join(", ")}`);return c(function(e){const t=[];for(let i=0;i<e.length;i++){let s=e.charCodeAt(i);s<128?t.push(s):s<2048?t.push(192|s>>6,128|63&s):s<55296||s>=57344?t.push(224|s>>12,128|s>>6&63,128|63&s):(i++,s=65536+((1023&s)<<10|1023&e.charCodeAt(i)),t.push(240|s>>18,128|s>>12&63,128|s>>6&63,128|63&s))}return t}(h))}var d;!function(e){e.getTransactionId="getTransactionId",e.computeLocalHash="computeLocalHash",e.fetchRemoteHash="fetchRemoteHash",e.parseIssuerKeys="parseIssuerKeys",e.compareHashes="compareHashes",e.checkMerkleRoot="checkMerkleRoot",e.checkReceipt="checkReceipt",e.checkAuthenticity="checkAuthenticity"}(d||(d={}));class y extends u{verificationProcess=[d.getTransactionId,d.computeLocalHash,d.fetchRemoteHash,d.compareHashes,d.checkMerkleRoot,d.checkReceipt,d.parseIssuerKeys,d.checkAuthenticity];transactionId;localHash;documentToVerify;txData;chain;explorerAPIs;receipt;issuerPublicKeyList;issuer;proof;type="MerkleProof2017";constructor(t){super(t),t.executeStep&&(this.executeStep=t.executeStep),this.documentToVerify=t.document,this.explorerAPIs=t.explorerAPIs,this.issuer=t.issuer,this.proof=t.proof,this.validateProofType(),this.receipt=this.documentToVerify.signature,this.chain=e.certificates.getChain("",this.receipt),this.transactionId=e.certificates.getTransactionId(this.receipt),this.adaptVerificationProcessToChain()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(t){return this.verificationProcess.map((i=>e.verifier.convertToVerificationSubsteps(t,i)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return e.chains.isMockChain(this.chain)?"This mock chain does not support issuing addresses":this.txData?this.txData.issuingAddress:void console.error("Trying to access issuing address when txData not available yet. Did you run the `verify` method yet?")}getIssuerName(){return this.issuer.name}getIssuerProfileDomain(){const e=new URL(this.getIssuerProfileUrl());return e?.hostname}getIssuerProfileUrl(){return this.issuer.id}getSigningDate(){return this.documentToVerify.issuedOn}getChain(){return this.chain}getReceipt(){return this.receipt}getTransactionIdString(){return e.certificates.getTransactionId(this.getReceipt())}getTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).transactionLink}getRawTransactionLink(){return e.certificates.getTransactionLink(this.getTransactionIdString(),this.getChain()).rawTransactionLink}validateProofType(){if(this.proof.type[0]!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${this.proof.type[0]}`)}adaptVerificationProcessToChain(){e.chains.isMockChain(this.chain)&&(t(this.verificationProcess,d.getTransactionId),t(this.verificationProcess,d.fetchRemoteHash),t(this.verificationProcess,d.parseIssuerKeys),t(this.verificationProcess,d.checkMerkleRoot),t(this.verificationProcess,d.checkAuthenticity))}async executeStep(e,t,i){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async getTransactionId(){await this.executeStep(d.getTransactionId,(()=>function(e){if("string"==typeof e&&e.length>0)return e;throw new s("getTransactionId",r("errors","isTransactionIdValid"))}(this.transactionId)),this.type)}async computeLocalHash(){this.localHash=await this.executeStep(d.computeLocalHash,(async()=>await l(this.documentToVerify)),this.type)}async fetchRemoteHash(){this.txData=await this.executeStep(d.fetchRemoteHash,(async()=>await e.verifier.lookForTx({transactionId:this.transactionId,chain:this.chain.code,explorerAPIs:this.explorerAPIs})),this.type)}async compareHashes(){await this.executeStep(d.compareHashes,(()=>function(e,t){if(e!==t)throw new s("compareHashes",r("errors","ensureHashesEqual"));return!0}(this.localHash,this.receipt.targetHash)),this.type)}async checkMerkleRoot(){await this.executeStep(d.checkMerkleRoot,(()=>function(e,t){if(e!==t)throw new s("checkMerkleRoot",r("errors","ensureMerkleRootEqual"));return!0}(this.receipt.merkleRoot,this.txData.remoteHash)),this.type)}async checkReceipt(){await this.executeStep(d.checkReceipt,(()=>{!function(e){let t=e.targetHash;const i=e.merkleRoot;try{const i=e.proof??e.path;if(i)for(const e in i){const r=i[e];let o;if(void 0!==r.left)o=p(`${r.left}${t}`),t=c(o);else{if(void 0===r.right)throw new s("checkReceipt","Trigger catch error.");o=p(`${t}${r.right}`),t=c(o)}}}catch(e){throw new s("checkReceipt",r("errors","ensureValidReceipt"))}if(t!==i)throw new s("checkReceipt",r("errors","invalidMerkleReceipt"))}(this.receipt)}),this.type)}async parseIssuerKeys(){this.issuerPublicKeyList=await this.executeStep(d.parseIssuerKeys,(()=>e.verifier.parseIssuerKeys(this.issuer)),this.type)}async checkAuthenticity(){await this.executeStep(d.checkAuthenticity,(()=>{h(this.issuerPublicKeyList,this.txData.issuingAddress,this.txData.time)}),this.type)}}export{y as default};