@blockcerts/blockcerts-verifier 1.62.2 → 1.64.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 (45) hide show
  1. package/bundle-stats.html +1 -1
  2. package/dist/{EcdsaSd2023-jnIXPui8-Ecil79Z6.js → EcdsaSd2023-C-1LsSqc-ObXBX61N.js} +8 -8
  3. package/dist/EcdsaSecp256k1Signature2019-9eEnZ1FG-BmfqA6PL.js +1 -0
  4. package/dist/Ed25519Signature2020-BMcgU5hX-x_NYJtpB.js +52 -0
  5. package/dist/HashlinkVerifier-BtvQtMxp-dg5WNZnc.js +11 -0
  6. package/dist/{MerkleProof2017-Cy_nkz4C-gnoFFWMW.js → MerkleProof2017-CYhvkyFU-Dl5-uCC8.js} +1 -1
  7. package/dist/MerkleProof2019-DvKX1MAC-ZkVAsaEc.js +3 -0
  8. package/dist/checkCredentialSchemaConformity-BKqGaA0B-BD_kUjvp.js +1 -0
  9. package/dist/{controlVerificationMethod-BxseSDWK-Ghg2o_Hj.js → controlVerificationMethod-CxlzFjkZ-PQqX7CMl.js} +1 -1
  10. package/dist/did-key-common.esm-BFTxB53c-CbGeVC_r.js +9 -0
  11. package/dist/did-key-ed25519.esm-De8G8Ym_-DucypQMo.js +1 -0
  12. package/dist/did-key-secp256k1.esm-Bq_BYfMd-CQBo4Q3q.js +1 -0
  13. package/dist/elliptic-ChFQ9Ngs-BRLTdj5Y.js +1 -0
  14. package/dist/{ensureValidIssuingKey-C7MTkDyV-frafTbMl.js → ensureValidIssuingKey-CVj5gBFJ-wu9SdYxL.js} +1 -1
  15. package/dist/index-CXMZ9dwW-lR6I8M8V.js +1 -0
  16. package/dist/index-CZmdZxVn-C0eXpZGn.js +1 -0
  17. package/dist/index-DJ38G5vv-CIHAiYCe.js +22 -0
  18. package/dist/index-SE5hL_nS--rUcmgx9.js +60 -0
  19. package/dist/jsonld-DSQP4wXm-C61cS9xX.js +33 -0
  20. package/dist/main.js +122 -119
  21. package/dist/{retrieveVerificationMethodPublicKey-fVSjg83n-B4VhVtVk.js → retrieveVerificationMethodPublicKey-8w3WQciA-sHmGZCdE.js} +1 -1
  22. package/dist/sha256-4DF0Q3E2-C1PUWFZm.js +1 -0
  23. package/dist/webcrypto.es-SQMaF2SJ-B87Lqr9a.js +40 -0
  24. package/dist/x25519-KjRyLrTf-NSl6svWQ.js +1 -0
  25. package/package.json +2 -2
  26. package/dist/EcdsaSecp256k1Signature2019-CBV4BwnM-C2qGlq2W.js +0 -4
  27. package/dist/Ed25519Signature2020-MQoWd113-PNuci9U2.js +0 -52
  28. package/dist/HashlinkVerifier-DykIKn5i-CYewU55u.js +0 -11
  29. package/dist/MerkleProof2019-DpwH-snR-ClzVR6uC.js +0 -3
  30. package/dist/checkCredentialSchemaConformity-DOGmtCq0-CnEpCN-s.js +0 -1
  31. package/dist/did-key-common.esm-C42sQiXe-DN5hgDGM.js +0 -9
  32. package/dist/did-key-ed25519.esm-CO7qImeZ-BR5JRBUU.js +0 -1
  33. package/dist/did-key-secp256k1.esm-BblZ1xRe-4Ak_uTKC.js +0 -1
  34. package/dist/elliptic-6eMlPaPZ-CGOSt2J1.js +0 -1
  35. package/dist/index-BZds3Ljo-CHN5LgUq.js +0 -1
  36. package/dist/index-Dzjg2qbR-DK7tzt5T.js +0 -22
  37. package/dist/index-VOqA2-xz-CKqwdkuf.js +0 -70
  38. package/dist/index-WN144sZ6-DKm58evR.js +0 -3
  39. package/dist/jsonld-BpvX3DRL-qZrjsUmJ.js +0 -75
  40. package/dist/sha256-D_qJpPFT-BYFBxJ7m.js +0 -1
  41. package/dist/webcrypto.es-DQnPRx8R-BJSH271h.js +0 -41
  42. package/dist/x25519-Dm-l65ld-DcUk09rC.js +0 -1
  43. /package/dist/{checkRevocationStatusList2021-CNtaPjVp-XCu3zkCJ.js → checkRevocationStatusList2021-BUqNLYXm-XCu3zkCJ.js} +0 -0
  44. /package/dist/{ensureNotRevoked-D9_PlMpD-DvMIgM4L.js → ensureNotRevoked-JuH4UdyO-DvMIgM4L.js} +0 -0
  45. /package/dist/{index-CWugL4dz-Dgus2xdV.js → index-BcM1LBSs-Dgus2xdV.js} +0 -0
@@ -1,4 +0,0 @@
1
- import{a as t,t as e,p as i,B as r,d as n,h as o,f as s,V as a,u as h,v as u,w as c,g as l}from"./main.js";import{d as f,e as d,j as p}from"./index-VOqA2-xz-CKqwdkuf.js";import{j as _}from"./jsonld-BpvX3DRL-qZrjsUmJ.js";import{s as y,a as b,e as g,d as w,r as v,k as m,b as S,f as E}from"./index-WN144sZ6-DKm58evR.js";import{r as k,i as R}from"./elliptic-6eMlPaPZ-CGOSt2J1.js";import{S as T}from"./Suite-B7Vy9AuU-D1ucdMDB.js";import"./pako.esm-DnD5dZGi-Bw1vqMku.js";import"./sha256-D_qJpPFT-BYFBxJ7m.js";import"./index-CWugL4dz-Dgus2xdV.js";import{r as M}from"./retrieveVerificationMethodPublicKey-fVSjg83n-B4VhVtVk.js";var x,L,D={exports:{}},O={},I=h(u),B=I.EventEmitter;function C(t,e){A(t,e),P(t)}function P(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function A(t,e){t.emit("error",e)}var K={destroy:function(t,i){var r=this,n=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return n||o?(i?i(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,e(A,this,t)):e(A,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!i&&t?r._writableState?r._writableState.errorEmitted?e(P,r):(r._writableState.errorEmitted=!0,e(C,r,t)):e(C,r,t):i?(e(P,r),i(t)):e(P,r)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(t,e){var i=t._readableState,r=t._writableState;i&&i.autoDestroy||r&&r.autoDestroy?t.destroy(e):t.emit("error",e)}},j={};var N={};function U(t,e,i){i||(i=Error);var r=function(t){var i,r;function n(i,r,n){return t.call(this,function(t,i,r){return"string"==typeof e?e:e(t,i,r)}(i,r,n))||this}return r=t,(i=n).prototype=Object.create(r.prototype),i.prototype.constructor=i,i.__proto__=r,n}(i);r.prototype.name=i.name,r.prototype.code=t,N[t]=r}function V(t,e){if(Array.isArray(t)){var i=t.length;return t=t.map((function(t){return String(t)})),i>2?"one of ".concat(e," ").concat(t.slice(0,i-1).join(", "),", or ")+t[i-1]:2===i?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}U("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),U("ERR_INVALID_ARG_TYPE",(function(t,e,i){var r,n,o;if("string"==typeof e&&(n="not ",e.substr(0,n.length)===n)?(r="must not be",e=e.replace(/^not /,"")):r="must be",function(t,e,i){return(void 0===i||i>t.length)&&(i=t.length),t.substring(i-e.length,i)===e}(t," argument"))o="The ".concat(t," ").concat(r," ").concat(V(e,"type"));else{var s=function(t,e,i){return"number"!=typeof i&&(i=0),!(i+e.length>t.length)&&-1!==t.indexOf(e,i)}(t,".")?"property":"argument";o='The "'.concat(t,'" ').concat(s," ").concat(r," ").concat(V(e,"type"))}return o+=". Received type ".concat(typeof i)}),TypeError),U("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),U("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),U("ERR_STREAM_PREMATURE_CLOSE","Premature close"),U("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),U("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),U("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),U("ERR_STREAM_WRITE_AFTER_END","write after end"),U("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),U("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),U("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),j.codes=N;var q=j.codes.ERR_INVALID_OPT_VALUE;var W,F={getHighWaterMark:function(t,e,i,r){var n=function(t,e,i){return null!=t.highWaterMark?t.highWaterMark:e?t[i]:null}(e,r,i);if(null!=n){if(!isFinite(n)||Math.floor(n)!==n||n<0)throw new q(r?i:"highWaterMark",n);return Math.floor(n)}return t.objectMode?16:16384}},H={};function z(){if(W)return H;W=1;var t=y.Buffer,e=t.isEncoding||function(t){switch((t=""+t)&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function i(i){var r;switch(this.encoding=function(i){var r=function(t){if(!t)return"utf8";for(var e;;)switch(t){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(i);if("string"!=typeof r&&(t.isEncoding===e||!e(i)))throw new Error("Unknown encoding: "+i);return r||i}(i),this.encoding){case"utf16le":this.text=o,this.end=s,r=4;break;case"utf8":this.fillLast=n,r=4;break;case"base64":this.text=a,this.end=h,r=3;break;default:return this.write=u,void(this.end=c)}this.lastNeed=0,this.lastTotal=0,this.lastChar=t.allocUnsafe(r)}function r(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function n(t){var e=this.lastTotal-this.lastNeed,i=function(t,e){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==i?i:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function o(t,e){if((t.length-e)%2==0){var i=t.toString("utf16le",e);if(i){var r=i.charCodeAt(i.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],i.slice(0,-1)}return i}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function s(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var i=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,i)}return e}function a(t,e){var i=(t.length-e)%3;return 0===i?t.toString("base64",e):(this.lastNeed=3-i,this.lastTotal=3,1===i?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-i))}function h(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function u(t){return t.toString(this.encoding)}function c(t){return t&&t.length?this.write(t):""}return H.StringDecoder=i,i.prototype.write=function(t){if(0===t.length)return"";var e,i;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";i=this.lastNeed,this.lastNeed=0}else i=0;return i<t.length?e?e+this.text(t,i):this.text(t,i):e||""},i.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},i.prototype.text=function(t,e){var i=function(t,e,i){var n=e.length-1;if(n<i)return 0;var o=r(e[n]);if(o>=0)return o>0&&(t.lastNeed=o-1),o;if(--n<i||-2===o)return 0;if(o=r(e[n]),o>=0)return o>0&&(t.lastNeed=o-2),o;if(--n<i||-2===o)return 0;if(o=r(e[n]),o>=0)return o>0&&(2===o?o=0:t.lastNeed=o-3),o;return 0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=i;var n=t.length-(i-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},i.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length},H}var $=j.codes.ERR_STREAM_PREMATURE_CLOSE;function X(){}var G,J,Y,Z,Q=function t(e,i,r){if("function"==typeof i)return t(e,null,i);i||(i={}),r=function(t){var e=!1;return function(){if(!e){e=!0;for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];t.apply(this,r)}}}(r||X);var n=i.readable||!1!==i.readable&&e.readable,o=i.writable||!1!==i.writable&&e.writable,s=function(){e.writable||h()},a=e._writableState&&e._writableState.finished,h=function(){o=!1,a=!0,n||r.call(e)},u=e._readableState&&e._readableState.endEmitted,c=function(){n=!1,u=!0,o||r.call(e)},l=function(t){r.call(e,t)},f=function(){var t;return n&&!u?(e._readableState&&e._readableState.ended||(t=new $),r.call(e,t)):o&&!a?(e._writableState&&e._writableState.ended||(t=new $),r.call(e,t)):void 0},d=function(){e.req.on("finish",h)};return!function(t){return t.setHeader&&"function"==typeof t.abort}(e)?o&&!e._writableState&&(e.on("end",s),e.on("close",s)):(e.on("complete",h),e.on("abort",f),e.req?d():e.on("request",d)),e.on("end",c),e.on("finish",h),!1!==i.error&&e.on("error",l),e.on("close",f),function(){e.removeListener("complete",h),e.removeListener("abort",f),e.removeListener("request",d),e.req&&e.req.removeListener("finish",h),e.removeListener("end",s),e.removeListener("close",s),e.removeListener("finish",h),e.removeListener("end",c),e.removeListener("error",l),e.removeListener("close",f)}};function tt(){if(J)return G;var t;function i(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}J=1;var r=Q,n=Symbol("lastResolve"),o=Symbol("lastReject"),s=Symbol("error"),a=Symbol("ended"),h=Symbol("lastPromise"),u=Symbol("handlePromise"),c=Symbol("stream");function l(t,e){return{value:t,done:e}}function f(t){var e=t[n];if(null!==e){var i=t[c].read();null!==i&&(t[h]=null,t[n]=null,t[o]=null,e(l(i,!1)))}}function d(t){e(f,t)}var p=Object.getPrototypeOf((function(){})),_=Object.setPrototypeOf((i(t={get stream(){return this[c]},next:function(){var t=this,i=this[s];if(null!==i)return Promise.reject(i);if(this[a])return Promise.resolve(l(void 0,!0));if(this[c].destroyed)return new Promise((function(i,r){e((function(){t[s]?r(t[s]):i(l(void 0,!0))}))}));var r,n=this[h];if(n)r=new Promise(function(t,e){return function(i,r){t.then((function(){e[a]?i(l(void 0,!0)):e[u](i,r)}),r)}}(n,this));else{var o=this[c].read();if(null!==o)return Promise.resolve(l(o,!1));r=new Promise(this[u])}return this[h]=r,r}},Symbol.asyncIterator,(function(){return this})),i(t,"return",(function(){var t=this;return new Promise((function(e,i){t[c].destroy(null,(function(t){t?i(t):e(l(void 0,!0))}))}))})),t),p);return G=function(t){var e,f=Object.create(_,(i(e={},c,{value:t,writable:!0}),i(e,n,{value:null,writable:!0}),i(e,o,{value:null,writable:!0}),i(e,s,{value:null,writable:!0}),i(e,a,{value:t._readableState.endEmitted,writable:!0}),i(e,u,{value:function(t,e){var i=f[c].read();i?(f[h]=null,f[n]=null,f[o]=null,t(l(i,!1))):(f[n]=t,f[o]=e)},writable:!0}),e));return f[h]=null,r(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=f[o];return null!==e&&(f[h]=null,f[n]=null,f[o]=null,e(t)),void(f[s]=t)}var i=f[n];null!==i&&(f[h]=null,f[n]=null,f[o]=null,i(l(void 0,!0))),f[a]=!0})),t.on("readable",d.bind(null,f)),f}}const et=O;et.Readable=St,St.ReadableState=mt,I.EventEmitter;var it=function(t,e){return t.listeners(e).length},rt=B,nt=k.Buffer,ot=t.Uint8Array||function(){};var st,at=v;st=at&&at.debuglog?at.debuglog("stream"):function(){};var ht,ut,ct,lt=function(){if(L)return x;function t(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,r)}return i}function e(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function i(t,e,i){return e&&function(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,e),t}L=1;var r=k.Buffer,n=v.inspect,o=n&&n.custom||"inspect";return x=function(){function s(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,s),this.head=null,this.tail=null,this.length=0}return i(s,[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,i=""+e.data;e=e.next;)i+=t+e.data;return i}},{key:"concat",value:function(t){if(0===this.length)return r.alloc(0);for(var e,i,n,o=r.allocUnsafe(t>>>0),s=this.head,a=0;s;)e=s.data,i=o,n=a,r.prototype.copy.call(e,i,n),a+=s.data.length,s=s.next;return o}},{key:"consume",value:function(t,e){var i;return t<this.head.data.length?(i=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):i=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),i}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,i=1,r=e.data;for(t-=r.length;e=e.next;){var n=e.data,o=t>n.length?n.length:t;if(o===n.length?r+=n:r+=n.slice(0,t),0===(t-=o)){o===n.length?(++i,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=n.slice(o));break}++i}return this.length-=i,r}},{key:"_getBuffer",value:function(t){var e=r.allocUnsafe(t),i=this.head,n=1;for(i.data.copy(e),t-=i.data.length;i=i.next;){var o=i.data,s=t>o.length?o.length:t;if(o.copy(e,e.length-t,0,s),0===(t-=s)){s===o.length?(++n,i.next?this.head=i.next:this.head=this.tail=null):(this.head=i,i.data=o.slice(s));break}++n}return this.length-=n,e}},{key:o,value:function(i,r){return n(this,function(i){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?t(Object(n),!0).forEach((function(t){e(i,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(n)):t(Object(n)).forEach((function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(n,t))}))}return i}({},r,{depth:0,customInspect:!1}))}}]),s}(),x}(),ft=K,dt=F.getHighWaterMark,pt=j.codes,_t=pt.ERR_INVALID_ARG_TYPE,yt=pt.ERR_STREAM_PUSH_AFTER_EOF,bt=pt.ERR_METHOD_NOT_IMPLEMENTED,gt=pt.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;R(St,rt);var wt=ft.errorOrDestroy,vt=["error","close","destroy","pause","resume"];function mt(t,e,i){t=t||{},"boolean"!=typeof i&&(i=e instanceof et.Duplex),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=dt(this,t,"readableHighWaterMark",i),this.buffer=new lt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(ht||(ht=z().StringDecoder),this.decoder=new ht(t.encoding),this.encoding=t.encoding)}function St(t){if(!(this instanceof St))return new St(t);var e=this instanceof et.Duplex;this._readableState=new mt(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),rt.call(this)}function Et(t,e,i,r,n){st("readableAddChunk",e);var o,s=t._readableState;if(null===e)s.reading=!1,function(t,e){if(st("onEofChunk"),e.ended)return;if(e.decoder){var i=e.decoder.end();i&&i.length&&(e.buffer.push(i),e.length+=e.objectMode?1:i.length)}e.ended=!0,e.sync?Mt(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,xt(t)))}(t,s);else if(n||(o=function(t,e){var i;r=e,nt.isBuffer(r)||r instanceof ot||"string"==typeof e||void 0===e||t.objectMode||(i=new _t("chunk",["string","Buffer","Uint8Array"],e));var r;return i}(s,e)),o)wt(t,o);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===nt.prototype||(e=function(t){return nt.from(t)}(e)),r)s.endEmitted?wt(t,new gt):kt(t,s,e,!0);else if(s.ended)wt(t,new yt);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!i?(e=s.decoder.write(e),s.objectMode||0!==e.length?kt(t,s,e,!1):Lt(t,s)):kt(t,s,e,!1)}else r||(s.reading=!1,Lt(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function kt(t,e,i,r){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",i)):(e.length+=e.objectMode?1:i.length,r?e.buffer.unshift(i):e.buffer.push(i),e.needReadable&&Mt(t)),Lt(t,e)}Object.defineProperty(St.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),St.prototype.destroy=ft.destroy,St.prototype._undestroy=ft.undestroy,St.prototype._destroy=function(t,e){e(t)},St.prototype.push=function(t,e){var i,r=this._readableState;return r.objectMode?i=!0:"string"==typeof t&&((e=e||r.defaultEncoding)!==r.encoding&&(t=nt.from(t,e),e=""),i=!0),Et(this,t,e,!1,i)},St.prototype.unshift=function(t){return Et(this,t,null,!0,!1)},St.prototype.isPaused=function(){return!1===this._readableState.flowing},St.prototype.setEncoding=function(t){ht||(ht=z().StringDecoder);var e=new ht(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var i=this._readableState.buffer.head,r="";null!==i;)r+=e.write(i.data),i=i.next;return this._readableState.buffer.clear(),""!==r&&this._readableState.buffer.push(r),this._readableState.length=r.length,this};var Rt=1073741824;function Tt(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=Rt?t=Rt:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function Mt(t){var i=t._readableState;st("emitReadable",i.needReadable,i.emittedReadable),i.needReadable=!1,i.emittedReadable||(st("emitReadable",i.flowing),i.emittedReadable=!0,e(xt,t))}function xt(t){var e=t._readableState;st("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,Ct(t)}function Lt(t,i){i.readingMore||(i.readingMore=!0,e(Dt,t,i))}function Dt(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var i=e.length;if(st("maybeReadMore read 0"),t.read(0),i===e.length)break}e.readingMore=!1}function Ot(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function It(t){st("readable nexttick read 0"),t.read(0)}function Bt(t,e){st("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),Ct(t),e.flowing&&!e.reading&&t.read(0)}function Ct(t){var e=t._readableState;for(st("flow",e.flowing);e.flowing&&null!==t.read(););}function Pt(t,e){return 0===e.length?null:(e.objectMode?i=e.buffer.shift():!t||t>=e.length?(i=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):i=e.buffer.consume(t,e.decoder),i);var i}function At(t){var i=t._readableState;st("endReadable",i.endEmitted),i.endEmitted||(i.ended=!0,e(Kt,i,t))}function Kt(t,e){if(st("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var i=e._writableState;(!i||i.autoDestroy&&i.finished)&&e.destroy()}}function jt(t,e){for(var i=0,r=t.length;i<r;i++)if(t[i]===e)return i;return-1}St.prototype.read=function(t){st("read",t),t=parseInt(t,10);var e=this._readableState,i=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return st("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?At(this):Mt(this),null;if(0===(t=Tt(t,e))&&e.ended)return 0===e.length&&At(this),null;var r,n=e.needReadable;return st("need readable",n),(0===e.length||e.length-t<e.highWaterMark)&&st("length less than watermark",n=!0),e.ended||e.reading?st("reading or ended",n=!1):n&&(st("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=Tt(i,e))),null===(r=t>0?Pt(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),i!==t&&e.ended&&At(this)),null!==r&&this.emit("data",r),r},St.prototype._read=function(t){wt(this,new bt("_read()"))},St.prototype.pipe=function(t,r){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=t;break;case 1:o.pipes=[o.pipes,t];break;default:o.pipes.push(t)}o.pipesCount+=1,st("pipe count=%d opts=%j",o.pipesCount,r);var s=(!r||!1!==r.end)&&t!==i.stdout&&t!==i.stderr?h:_;function a(e,i){st("onunpipe"),e===n&&i&&!1===i.hasUnpiped&&(i.hasUnpiped=!0,st("cleanup"),t.removeListener("close",d),t.removeListener("finish",p),t.removeListener("drain",u),t.removeListener("error",f),t.removeListener("unpipe",a),n.removeListener("end",h),n.removeListener("end",_),n.removeListener("data",l),c=!0,!o.awaitDrain||t._writableState&&!t._writableState.needDrain||u())}function h(){st("onend"),t.end()}o.endEmitted?e(s):n.once("end",s),t.on("unpipe",a);var u=function(t){return function(){var e=t._readableState;st("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&it(t,"data")&&(e.flowing=!0,Ct(t))}}(n);t.on("drain",u);var c=!1;function l(e){st("ondata");var i=t.write(e);st("dest.write",i),!1===i&&((1===o.pipesCount&&o.pipes===t||o.pipesCount>1&&-1!==jt(o.pipes,t))&&!c&&(st("false write response, pause",o.awaitDrain),o.awaitDrain++),n.pause())}function f(e){st("onerror",e),_(),t.removeListener("error",f),0===it(t,"error")&&wt(t,e)}function d(){t.removeListener("finish",p),_()}function p(){st("onfinish"),t.removeListener("close",d),_()}function _(){st("unpipe"),n.unpipe(t)}return n.on("data",l),function(t,e,i){if("function"==typeof t.prependListener)return t.prependListener(e,i);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(i):t._events[e]=[i,t._events[e]]:t.on(e,i)}(t,"error",f),t.once("close",d),t.once("finish",p),t.emit("pipe",n),o.flowing||(st("pipe resume"),n.resume()),t},St.prototype.unpipe=function(t){var e=this._readableState,i={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,i)),this;if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<n;o++)r[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=jt(e.pipes,t);return-1===s||(e.pipes.splice(s,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,i)),this},St.prototype.on=function(t,i){var r=rt.prototype.on.call(this,t,i),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,st("on readable",n.length,n.reading),n.length?Mt(this):n.reading||e(It,this))),r},St.prototype.addListener=St.prototype.on,St.prototype.removeListener=function(t,i){var r=rt.prototype.removeListener.call(this,t,i);return"readable"===t&&e(Ot,this),r},St.prototype.removeAllListeners=function(t){var i=rt.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||e(Ot,this),i},St.prototype.resume=function(){var t=this._readableState;return t.flowing||(st("resume"),t.flowing=!t.readableListening,function(t,i){i.resumeScheduled||(i.resumeScheduled=!0,e(Bt,t,i))}(this,t)),t.paused=!1,this},St.prototype.pause=function(){return st("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(st("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},St.prototype.wrap=function(t){var e=this,i=this._readableState,r=!1;for(var n in t.on("end",(function(){if(st("wrapped end"),i.decoder&&!i.ended){var t=i.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(n){(st("wrapped data"),i.decoder&&(n=i.decoder.write(n)),i.objectMode&&null==n)||(i.objectMode||n&&n.length)&&(e.push(n)||(r=!0,t.pause()))})),t)void 0===this[n]&&"function"==typeof t[n]&&(this[n]=function(e){return function(){return t[e].apply(t,arguments)}}(n));for(var o=0;o<vt.length;o++)t.on(vt[o],this.emit.bind(this,vt[o]));return this._read=function(e){st("wrapped _read",e),r&&(r=!1,t.resume())},this},"function"==typeof Symbol&&(St.prototype[Symbol.asyncIterator]=function(){return void 0===ut&&(ut=tt()),ut(this)}),Object.defineProperty(St.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(St.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(St.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),St._fromList=Pt,Object.defineProperty(St.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(St.from=function(t,e){return void 0===ct&&(ct=Z?Y:(Z=1,Y=function(){throw new Error("Readable.from is not available in the browser")})),ct(St,t,e)});var Nt=function(t,e){if(Ut("noDeprecation"))return t;var i=!1;return function(){if(!i){if(Ut("throwDeprecation"))throw new Error(e);Ut("traceDeprecation")?console.trace(e):console.warn(e),i=!0}return t.apply(this,arguments)}};function Ut(e){try{if(!t.localStorage)return!1}catch(t){return!1}var i=t.localStorage[e];return null!=i&&"true"===String(i).toLowerCase()}const Vt=O;function qt(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,i){var r=t.entry;t.entry=null;for(;r;){var n=r.callback;e.pendingcb--,n(i),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}Vt.Writable=he,he.WritableState=ae;var Wt={deprecate:Nt},Ft=B,Ht=k.Buffer,zt=t.Uint8Array||function(){};var $t,Xt=K,Gt=F.getHighWaterMark,Jt=j.codes,Yt=Jt.ERR_INVALID_ARG_TYPE,Zt=Jt.ERR_METHOD_NOT_IMPLEMENTED,Qt=Jt.ERR_MULTIPLE_CALLBACK,te=Jt.ERR_STREAM_CANNOT_PIPE,ee=Jt.ERR_STREAM_DESTROYED,ie=Jt.ERR_STREAM_NULL_VALUES,re=Jt.ERR_STREAM_WRITE_AFTER_END,ne=Jt.ERR_UNKNOWN_ENCODING,oe=Xt.errorOrDestroy;function se(){}function ae(t,i,r){t=t||{},"boolean"!=typeof r&&(r=i instanceof Vt.Duplex),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=Gt(this,t,"writableHighWaterMark",r),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=!1===t.decodeStrings;this.decodeStrings=!n,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,i){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new Qt;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),i)!function(t,i,r,n,o){--i.pendingcb,r?(e(o,n),e(pe,t,i),t._writableState.errorEmitted=!0,oe(t,n)):(o(n),t._writableState.errorEmitted=!0,oe(t,n),pe(t,i))}(t,r,n,i,o);else{var s=fe(r)||t.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||le(t,r),n?e(ce,t,r,s,o):ce(t,r,s,o)}}(i,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new qt(this)}function he(t){var e=this instanceof Vt.Duplex;if(!e&&!$t.call(he,this))return new he(t);this._writableState=new ae(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),Ft.call(this)}function ue(t,e,i,r,n,o,s){e.writelen=r,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new ee("write")):i?t._writev(n,e.onwrite):t._write(n,o,e.onwrite),e.sync=!1}function ce(t,e,i,r){i||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,r(),pe(t,e)}function le(t,e){e.bufferProcessing=!0;var i=e.bufferedRequest;if(t._writev&&i&&i.next){var r=e.bufferedRequestCount,n=new Array(r),o=e.corkedRequestsFree;o.entry=i;for(var s=0,a=!0;i;)n[s]=i,i.isBuf||(a=!1),i=i.next,s+=1;n.allBuffers=a,ue(t,e,!0,e.length,n,"",o.finish),e.pendingcb++,e.lastBufferedRequest=null,o.next?(e.corkedRequestsFree=o.next,o.next=null):e.corkedRequestsFree=new qt(e),e.bufferedRequestCount=0}else{for(;i;){var h=i.chunk,u=i.encoding,c=i.callback;if(ue(t,e,!1,e.objectMode?1:h.length,h,u,c),i=i.next,e.bufferedRequestCount--,e.writing)break}null===i&&(e.lastBufferedRequest=null)}e.bufferedRequest=i,e.bufferProcessing=!1}function fe(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function de(t,e){t._final((function(i){e.pendingcb--,i&&oe(t,i),e.prefinished=!0,t.emit("prefinish"),pe(t,e)}))}function pe(t,i){var r=fe(i);if(r&&(function(t,i){i.prefinished||i.finalCalled||("function"!=typeof t._final||i.destroyed?(i.prefinished=!0,t.emit("prefinish")):(i.pendingcb++,i.finalCalled=!0,e(de,t,i)))}(t,i),0===i.pendingcb&&(i.finished=!0,t.emit("finish"),i.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}R(he,Ft),ae.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(ae.prototype,"buffer",{get:Wt.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?($t=Function.prototype[Symbol.hasInstance],Object.defineProperty(he,Symbol.hasInstance,{value:function(t){return!!$t.call(this,t)||this===he&&(t&&t._writableState instanceof ae)}})):$t=function(t){return t instanceof this},he.prototype.pipe=function(){oe(this,new te)},he.prototype.write=function(t,i,r){var n,o=this._writableState,s=!1,a=!o.objectMode&&(n=t,Ht.isBuffer(n)||n instanceof zt);return a&&!Ht.isBuffer(t)&&(t=function(t){return Ht.from(t)}(t)),"function"==typeof i&&(r=i,i=null),a?i="buffer":i||(i=o.defaultEncoding),"function"!=typeof r&&(r=se),o.ending?function(t,i){var r=new re;oe(t,r),e(i,r)}(this,r):(a||function(t,i,r,n){var o;return null===r?o=new ie:"string"==typeof r||i.objectMode||(o=new Yt("chunk",["string","Buffer"],r)),!o||(oe(t,o),e(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,s=function(t,e,i,r,n,o){if(!i){var s=function(t,e,i){t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=Ht.from(e,i));return e}(e,r,n);r!==s&&(i=!0,n="buffer",r=s)}var a=e.objectMode?1:r.length;e.length+=a;var h=e.length<e.highWaterMark;h||(e.needDrain=!0);if(e.writing||e.corked){var u=e.lastBufferedRequest;e.lastBufferedRequest={chunk:r,encoding:n,isBuf:i,callback:o,next:null},u?u.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else ue(t,e,!1,a,r,n,o);return h}(this,o,a,t,i,r)),s},he.prototype.cork=function(){this._writableState.corked++},he.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||le(this,t))},he.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new ne(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(he.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(he.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),he.prototype._write=function(t,e,i){i(new Zt("_write()"))},he.prototype._writev=null,he.prototype.end=function(t,i,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,i=null):"function"==typeof i&&(r=i,i=null),null!=t&&this.write(t,i),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,i,r){i.ending=!0,pe(t,i),r&&(i.finished?e(r):t.once("finish",r));i.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(he.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(he.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),he.prototype.destroy=Xt.destroy,he.prototype._undestroy=Xt.undestroy,he.prototype._destroy=function(t,e){e(t)};var _e=Object.keys||function(t){var e=[];for(var i in t)e.push(i);return e};const ye=O;ye.Duplex=ve,R(ve,ye.Readable);for(var be=_e(ye.Writable.prototype),ge=0;ge<be.length;ge++){var we=be[ge];ve.prototype[we]||(ve.prototype[we]=ye.Writable.prototype[we])}function ve(t){if(!(this instanceof ve))return new ve(t);ye.Readable.call(this,t),ye.Writable.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",me)))}function me(){this._writableState.ended||e(Se,this)}function Se(t){t.end()}Object.defineProperty(ve.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(ve.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(ve.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(ve.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}});const Ee=O;Ee.Transform=De;var ke=j.codes,Re=ke.ERR_METHOD_NOT_IMPLEMENTED,Te=ke.ERR_MULTIPLE_CALLBACK,Me=ke.ERR_TRANSFORM_ALREADY_TRANSFORMING,xe=ke.ERR_TRANSFORM_WITH_LENGTH_0;function Le(t,e){var i=this._transformState;i.transforming=!1;var r=i.writecb;if(null===r)return this.emit("error",new Te);i.writechunk=null,i.writecb=null,null!=e&&this.push(e),r(t);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function De(t){if(!(this instanceof De))return new De(t);Ee.Duplex.call(this,t),this._transformState={afterTransform:Le.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",Oe)}function Oe(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?Ie(this,null,null):this._flush((function(e,i){Ie(t,e,i)}))}function Ie(t,e,i){if(e)return t.emit("error",e);if(null!=i&&t.push(i),t._writableState.length)throw new xe;if(t._transformState.transforming)throw new Me;return t.push(null)}R(De,Ee.Duplex),De.prototype.push=function(t,e){return this._transformState.needTransform=!1,Ee.Duplex.prototype.push.call(this,t,e)},De.prototype._transform=function(t,e,i){i(new Re("_transform()"))},De.prototype._write=function(t,e,i){var r=this._transformState;if(r.writecb=i,r.writechunk=t,r.writeencoding=e,!r.transforming){var n=this._readableState;(r.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},De.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},De.prototype._destroy=function(t,e){Ee.Duplex.prototype._destroy.call(this,t,(function(t){e(t)}))};const Be=O;function Ce(t){if(!(this instanceof Ce))return new Ce(t);Transform.call(this,t)}var Pe;Be.PassThrough=Ce,R(Ce,Be.Transform),Ce.prototype._transform=function(t,e,i){i(null,t)};var Ae=j.codes,Ke=Ae.ERR_MISSING_ARGS,je=Ae.ERR_STREAM_DESTROYED;function Ne(t){if(t)throw t}function Ue(t){t()}function Ve(t,e){return t.pipe(e)}var qe=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var r,n=function(t){return t.length?"function"!=typeof t[t.length-1]?Ne:t.pop():Ne}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new Ke("streams");var o=e.map((function(t,i){var s=i<e.length-1;return function(t,e,i,r){r=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(r);var n=!1;t.on("close",(function(){n=!0})),void 0===Pe&&(Pe=Q),Pe(t,{readable:e,writable:i},(function(t){if(t)return r(t);n=!0,r()}));var o=!1;return function(e){if(!n&&!o)return o=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void r(e||new je("pipe"))}}(t,s,i>0,(function(t){r||(r=t),t&&o.forEach(Ue),s||(o.forEach(Ue),n(r))}))}));return e.reduce(Ve)};!function(t,e){const i=O;(e=D.exports=i.Readable).Stream=i.Readable,e.Readable=i.Readable,e.Writable=i.Writable,e.Duplex=i.Duplex,e.Transform=i.Transform,e.PassThrough=i.PassThrough,e.finished=Q,e.pipeline=qe}(0,D.exports);var We=D.exports,Fe=y.Buffer,He=We;function ze(t){He.Stream.Transform.call(this),this._block=Fe.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}R(ze,He.Stream.Transform),ze.prototype._transform=function(t,e,i){var r=null;try{this.update(t,e)}catch(t){r=t}i(r)},ze.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},ze.prototype.update=function(t,e){if(function(t,e){if(!Fe.isBuffer(t)&&"string"!=typeof t)throw new TypeError(e+" must be a string or a buffer")}(t,"Data"),this._finalized)throw new Error("Digest already called");Fe.isBuffer(t)||(t=Fe.from(t,e));for(var i=this._block,r=0;this._blockOffset+t.length-r>=this._blockSize;){for(var n=this._blockOffset;n<this._blockSize;)i[n++]=t[r++];this._update(),this._blockOffset=0}for(;r<t.length;)i[this._blockOffset++]=t[r++];for(var o=0,s=8*t.length;s>0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},ze.prototype._update=function(){throw new Error("_update is not implemented")},ze.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var i=0;i<4;++i)this._length[i]=0;return e},ze.prototype._digest=function(){throw new Error("_digest is not implemented")};var $e=ze,Xe=R,Ge=$e,Je=y.Buffer,Ye=new Array(16);function Ze(){Ge.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function Qe(t,e){return t<<e|t>>>32-e}function ti(t,e,i,r,n,o,s){return Qe(t+(e&i|~e&r)+n+o|0,s)+e|0}function ei(t,e,i,r,n,o,s){return Qe(t+(e&r|i&~r)+n+o|0,s)+e|0}function ii(t,e,i,r,n,o,s){return Qe(t+(e^i^r)+n+o|0,s)+e|0}function ri(t,e,i,r,n,o,s){return Qe(t+(i^(e|~r))+n+o|0,s)+e|0}Xe(Ze,Ge),Ze.prototype._update=function(){for(var t=Ye,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);var i=this._a,r=this._b,n=this._c,o=this._d;i=ti(i,r,n,o,t[0],3614090360,7),o=ti(o,i,r,n,t[1],3905402710,12),n=ti(n,o,i,r,t[2],606105819,17),r=ti(r,n,o,i,t[3],3250441966,22),i=ti(i,r,n,o,t[4],4118548399,7),o=ti(o,i,r,n,t[5],1200080426,12),n=ti(n,o,i,r,t[6],2821735955,17),r=ti(r,n,o,i,t[7],4249261313,22),i=ti(i,r,n,o,t[8],1770035416,7),o=ti(o,i,r,n,t[9],2336552879,12),n=ti(n,o,i,r,t[10],4294925233,17),r=ti(r,n,o,i,t[11],2304563134,22),i=ti(i,r,n,o,t[12],1804603682,7),o=ti(o,i,r,n,t[13],4254626195,12),n=ti(n,o,i,r,t[14],2792965006,17),i=ei(i,r=ti(r,n,o,i,t[15],1236535329,22),n,o,t[1],4129170786,5),o=ei(o,i,r,n,t[6],3225465664,9),n=ei(n,o,i,r,t[11],643717713,14),r=ei(r,n,o,i,t[0],3921069994,20),i=ei(i,r,n,o,t[5],3593408605,5),o=ei(o,i,r,n,t[10],38016083,9),n=ei(n,o,i,r,t[15],3634488961,14),r=ei(r,n,o,i,t[4],3889429448,20),i=ei(i,r,n,o,t[9],568446438,5),o=ei(o,i,r,n,t[14],3275163606,9),n=ei(n,o,i,r,t[3],4107603335,14),r=ei(r,n,o,i,t[8],1163531501,20),i=ei(i,r,n,o,t[13],2850285829,5),o=ei(o,i,r,n,t[2],4243563512,9),n=ei(n,o,i,r,t[7],1735328473,14),i=ii(i,r=ei(r,n,o,i,t[12],2368359562,20),n,o,t[5],4294588738,4),o=ii(o,i,r,n,t[8],2272392833,11),n=ii(n,o,i,r,t[11],1839030562,16),r=ii(r,n,o,i,t[14],4259657740,23),i=ii(i,r,n,o,t[1],2763975236,4),o=ii(o,i,r,n,t[4],1272893353,11),n=ii(n,o,i,r,t[7],4139469664,16),r=ii(r,n,o,i,t[10],3200236656,23),i=ii(i,r,n,o,t[13],681279174,4),o=ii(o,i,r,n,t[0],3936430074,11),n=ii(n,o,i,r,t[3],3572445317,16),r=ii(r,n,o,i,t[6],76029189,23),i=ii(i,r,n,o,t[9],3654602809,4),o=ii(o,i,r,n,t[12],3873151461,11),n=ii(n,o,i,r,t[15],530742520,16),i=ri(i,r=ii(r,n,o,i,t[2],3299628645,23),n,o,t[0],4096336452,6),o=ri(o,i,r,n,t[7],1126891415,10),n=ri(n,o,i,r,t[14],2878612391,15),r=ri(r,n,o,i,t[5],4237533241,21),i=ri(i,r,n,o,t[12],1700485571,6),o=ri(o,i,r,n,t[3],2399980690,10),n=ri(n,o,i,r,t[10],4293915773,15),r=ri(r,n,o,i,t[1],2240044497,21),i=ri(i,r,n,o,t[8],1873313359,6),o=ri(o,i,r,n,t[15],4264355552,10),n=ri(n,o,i,r,t[6],2734768916,15),r=ri(r,n,o,i,t[13],1309151649,21),i=ri(i,r,n,o,t[4],4149444226,6),o=ri(o,i,r,n,t[11],3174756917,10),n=ri(n,o,i,r,t[2],718787259,15),r=ri(r,n,o,i,t[9],3951481745,21),this._a=this._a+i|0,this._b=this._b+r|0,this._c=this._c+n|0,this._d=this._d+o|0},Ze.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=Je.allocUnsafe(16);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t};var ni=Ze,oi=k.Buffer,si=R,ai=$e,hi=new Array(16),ui=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],ci=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],li=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],fi=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],di=[0,1518500249,1859775393,2400959708,2840853838],pi=[1352829926,1548603684,1836072691,2053994217,0];function _i(){ai.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function yi(t,e){return t<<e|t>>>32-e}function bi(t,e,i,r,n,o,s,a){return yi(t+(e^i^r)+o+s|0,a)+n|0}function gi(t,e,i,r,n,o,s,a){return yi(t+(e&i|~e&r)+o+s|0,a)+n|0}function wi(t,e,i,r,n,o,s,a){return yi(t+((e|~i)^r)+o+s|0,a)+n|0}function vi(t,e,i,r,n,o,s,a){return yi(t+(e&r|i&~r)+o+s|0,a)+n|0}function mi(t,e,i,r,n,o,s,a){return yi(t+(e^(i|~r))+o+s|0,a)+n|0}si(_i,ai),_i.prototype._update=function(){for(var t=hi,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var i=0|this._a,r=0|this._b,n=0|this._c,o=0|this._d,s=0|this._e,a=0|this._a,h=0|this._b,u=0|this._c,c=0|this._d,l=0|this._e,f=0;f<80;f+=1){var d,p;f<16?(d=bi(i,r,n,o,s,t[ui[f]],di[0],li[f]),p=mi(a,h,u,c,l,t[ci[f]],pi[0],fi[f])):f<32?(d=gi(i,r,n,o,s,t[ui[f]],di[1],li[f]),p=vi(a,h,u,c,l,t[ci[f]],pi[1],fi[f])):f<48?(d=wi(i,r,n,o,s,t[ui[f]],di[2],li[f]),p=wi(a,h,u,c,l,t[ci[f]],pi[2],fi[f])):f<64?(d=vi(i,r,n,o,s,t[ui[f]],di[3],li[f]),p=gi(a,h,u,c,l,t[ci[f]],pi[3],fi[f])):(d=mi(i,r,n,o,s,t[ui[f]],di[4],li[f]),p=bi(a,h,u,c,l,t[ci[f]],pi[4],fi[f])),i=s,s=o,o=yi(n,10),n=r,r=d,a=l,l=c,c=yi(u,10),u=h,h=p}var _=this._b+n+c|0;this._b=this._c+o+l|0,this._c=this._d+s+a|0,this._d=this._e+i+h|0,this._e=this._a+r+u|0,this._a=_},_i.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var t=oi.alloc?oi.alloc(20):new oi(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t};var Si=_i,Ei={exports:{}},ki=y.Buffer;function Ri(t,e){this._block=ki.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}Ri.prototype.update=function(t,e){"string"==typeof t&&(e=e||"utf8",t=ki.from(t,e));for(var i=this._block,r=this._blockSize,n=t.length,o=this._len,s=0;s<n;){for(var a=o%r,h=Math.min(n-s,r-a),u=0;u<h;u++)i[a+u]=t[s+u];s+=h,(o+=h)%r==0&&this._update(i)}return this._len+=n,this},Ri.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var i=8*this._len;if(i<=4294967295)this._block.writeUInt32BE(i,this._blockSize-4);else{var r=(4294967295&i)>>>0,n=(i-r)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(r,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},Ri.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Ti=Ri,Mi=R,xi=Ti,Li=y.Buffer,Di=[1518500249,1859775393,-1894007588,-899497514],Oi=new Array(80);function Ii(){this.init(),this._w=Oi,xi.call(this,64,56)}function Bi(t){return t<<30|t>>>2}function Ci(t,e,i,r){return 0===t?e&i|~e&r:2===t?e&i|e&r|i&r:e^i^r}Mi(Ii,xi),Ii.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Ii.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,o=0|this._c,s=0|this._d,a=0|this._e,h=0;h<16;++h)i[h]=t.readInt32BE(4*h);for(;h<80;++h)i[h]=i[h-3]^i[h-8]^i[h-14]^i[h-16];for(var u=0;u<80;++u){var c=~~(u/20),l=0|((e=r)<<5|e>>>27)+Ci(c,n,o,s)+a+i[u]+Di[c];a=s,s=o,o=Bi(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=a+this._e|0},Ii.prototype._hash=function(){var t=Li.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t};var Pi=Ii,Ai=R,Ki=Ti,ji=y.Buffer,Ni=[1518500249,1859775393,-1894007588,-899497514],Ui=new Array(80);function Vi(){this.init(),this._w=Ui,Ki.call(this,64,56)}function qi(t){return t<<5|t>>>27}function Wi(t){return t<<30|t>>>2}function Fi(t,e,i,r){return 0===t?e&i|~e&r:2===t?e&i|e&r|i&r:e^i^r}Ai(Vi,Ki),Vi.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Vi.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,o=0|this._c,s=0|this._d,a=0|this._e,h=0;h<16;++h)i[h]=t.readInt32BE(4*h);for(;h<80;++h)i[h]=(e=i[h-3]^i[h-8]^i[h-14]^i[h-16])<<1|e>>>31;for(var u=0;u<80;++u){var c=~~(u/20),l=qi(r)+Fi(c,n,o,s)+a+i[u]+Ni[c]|0;a=s,s=o,o=Wi(n),n=r,r=l}this._a=r+this._a|0,this._b=n+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=a+this._e|0},Vi.prototype._hash=function(){var t=ji.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t};var Hi=Vi,zi=R,$i=Ti,Xi=y.Buffer,Gi=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Ji=new Array(64);function Yi(){this.init(),this._w=Ji,$i.call(this,64,56)}function Zi(t,e,i){return i^t&(e^i)}function Qi(t,e,i){return t&e|i&(t|e)}function tr(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function er(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function ir(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}zi(Yi,$i),Yi.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},Yi.prototype._update=function(t){for(var e,i=this._w,r=0|this._a,n=0|this._b,o=0|this._c,s=0|this._d,a=0|this._e,h=0|this._f,u=0|this._g,c=0|this._h,l=0;l<16;++l)i[l]=t.readInt32BE(4*l);for(;l<64;++l)i[l]=0|(((e=i[l-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+i[l-7]+ir(i[l-15])+i[l-16];for(var f=0;f<64;++f){var d=c+er(a)+Zi(a,h,u)+Gi[f]+i[f]|0,p=tr(r)+Qi(r,n,o)|0;c=u,u=h,h=a,a=s+d|0,s=o,o=n,n=r,r=d+p|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=a+this._e|0,this._f=h+this._f|0,this._g=u+this._g|0,this._h=c+this._h|0},Yi.prototype._hash=function(){var t=Xi.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t};var rr=Yi,nr=R,or=rr,sr=Ti,ar=y.Buffer,hr=new Array(64);function ur(){this.init(),this._w=hr,sr.call(this,64,56)}nr(ur,or),ur.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},ur.prototype._hash=function(){var t=ar.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t};var cr=ur,lr=R,fr=Ti,dr=y.Buffer,pr=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],_r=new Array(160);function yr(){this.init(),this._w=_r,fr.call(this,128,112)}function br(t,e,i){return i^t&(e^i)}function gr(t,e,i){return t&e|i&(t|e)}function wr(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function vr(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function mr(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function Sr(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function Er(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function kr(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function Rr(t,e){return t>>>0<e>>>0?1:0}lr(yr,fr),yr.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},yr.prototype._update=function(t){for(var e=this._w,i=0|this._ah,r=0|this._bh,n=0|this._ch,o=0|this._dh,s=0|this._eh,a=0|this._fh,h=0|this._gh,u=0|this._hh,c=0|this._al,l=0|this._bl,f=0|this._cl,d=0|this._dl,p=0|this._el,_=0|this._fl,y=0|this._gl,b=0|this._hl,g=0;g<32;g+=2)e[g]=t.readInt32BE(4*g),e[g+1]=t.readInt32BE(4*g+4);for(;g<160;g+=2){var w=e[g-30],v=e[g-30+1],m=mr(w,v),S=Sr(v,w),E=Er(w=e[g-4],v=e[g-4+1]),k=kr(v,w),R=e[g-14],T=e[g-14+1],M=e[g-32],x=e[g-32+1],L=S+T|0,D=m+R+Rr(L,S)|0;D=(D=D+E+Rr(L=L+k|0,k)|0)+M+Rr(L=L+x|0,x)|0,e[g]=D,e[g+1]=L}for(var O=0;O<160;O+=2){D=e[O],L=e[O+1];var I=gr(i,r,n),B=gr(c,l,f),C=wr(i,c),P=wr(c,i),A=vr(s,p),K=vr(p,s),j=pr[O],N=pr[O+1],U=br(s,a,h),V=br(p,_,y),q=b+K|0,W=u+A+Rr(q,b)|0;W=(W=(W=W+U+Rr(q=q+V|0,V)|0)+j+Rr(q=q+N|0,N)|0)+D+Rr(q=q+L|0,L)|0;var F=P+B|0,H=C+I+Rr(F,P)|0;u=h,b=y,h=a,y=_,a=s,_=p,s=o+W+Rr(p=d+q|0,d)|0,o=n,d=f,n=r,f=l,r=i,l=c,i=W+H+Rr(c=q+F|0,q)|0}this._al=this._al+c|0,this._bl=this._bl+l|0,this._cl=this._cl+f|0,this._dl=this._dl+d|0,this._el=this._el+p|0,this._fl=this._fl+_|0,this._gl=this._gl+y|0,this._hl=this._hl+b|0,this._ah=this._ah+i+Rr(this._al,c)|0,this._bh=this._bh+r+Rr(this._bl,l)|0,this._ch=this._ch+n+Rr(this._cl,f)|0,this._dh=this._dh+o+Rr(this._dl,d)|0,this._eh=this._eh+s+Rr(this._el,p)|0,this._fh=this._fh+a+Rr(this._fl,_)|0,this._gh=this._gh+h+Rr(this._gl,y)|0,this._hh=this._hh+u+Rr(this._hl,b)|0},yr.prototype._hash=function(){var t=dr.allocUnsafe(64);function e(e,i,r){t.writeInt32BE(e,r),t.writeInt32BE(i,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t};var Tr=yr,Mr=R,xr=Tr,Lr=Ti,Dr=y.Buffer,Or=new Array(160);function Ir(){this.init(),this._w=Or,Lr.call(this,128,112)}Mr(Ir,xr),Ir.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},Ir.prototype._hash=function(){var t=Dr.allocUnsafe(48);function e(e,i,r){t.writeInt32BE(e,r),t.writeInt32BE(i,r+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t};var Br=Ir,Cr=Ei.exports=function(t){t=t.toLowerCase();var e=Cr[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e};Cr.sha=Pi,Cr.sha1=Hi,Cr.sha224=cr,Cr.sha256=rr,Cr.sha384=Br,Cr.sha512=Tr;var Pr=Ei.exports,Ar=h(c),Kr=y.Buffer,jr=b.Transform,Nr=Ar.StringDecoder;function Ur(t){jr.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}R(Ur,jr),Ur.prototype.update=function(t,e,i){"string"==typeof t&&(t=Kr.from(t,e));var r=this._update(t);return this.hashMode?this:(i&&(r=this._toString(r,i)),r)},Ur.prototype.setAutoPadding=function(){},Ur.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},Ur.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},Ur.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},Ur.prototype._transform=function(t,e,i){var r;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){r=t}finally{i(r)}},Ur.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},Ur.prototype._finalOrDigest=function(t){var e=this.__final()||Kr.alloc(0);return t&&(e=this._toString(e,t,!0)),e},Ur.prototype._toString=function(t,e,i){if(this._decoder||(this._decoder=new Nr(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var r=this._decoder.write(t);return i&&(r+=this._decoder.end()),r};var Vr=ni,qr=Si,Wr=Pr,Fr=Ur;function Hr(t){Fr.call(this,"digest"),this._hash=t}R(Hr,Fr),Hr.prototype._update=function(t){this._hash.update(t)},Hr.prototype._final=function(){return this._hash.digest()};var zr=l((function(t){return"md5"===(t=t.toLowerCase())?new Vr:"rmd160"===t||"ripemd160"===t?new qr:new Hr(Wr(t))})),$r={exports:{}},Xr=65536,Gr=4294967295;var Jr=y.Buffer,Yr=t.crypto||t.msCrypto;Yr&&Yr.getRandomValues?$r.exports=function(t,i){if(t>Gr)throw new RangeError("requested too many random bytes");var r=Jr.allocUnsafe(t);if(t>0)if(t>Xr)for(var n=0;n<t;n+=Xr)Yr.getRandomValues(r.slice(n,n+Xr));else Yr.getRandomValues(r);if("function"==typeof i)return e((function(){i(null,r)}));return r}:$r.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")};var Zr=l($r.exports);var Qr={CryptoLD:class{constructor({suites:t}={}){this.suites=t||new Map}use(t){this.suites.set(t.suite,t)}async generate(t={}){return this._suiteForType(t).generate(t)}async from(t={}){const e=this._suiteForType(t);return t["@context"]?e.fromKeyDocument({document:t}):e.from(t)}async fromKeyDocument({document:t,checkContext:e=!0,checkRevoked:i=!0}={}){if(!t)throw new TypeError('The "document" parameter is required.');return this._suiteForType(t).fromKeyDocument({document:t,checkContext:e,checkRevoked:i})}async fromKeyId({id:t,documentLoader:e,checkContext:i=!0,checkRevoked:r=!0}={}){if(!t)throw new TypeError('The "id" parameter is required.');if(!e)throw new TypeError('The "documentLoader" parameter is required.');let n;try{if(({document:n}=await e(t)),!n)throw new Error('The "documentLoader" function must return a "document" object.')}catch(t){const e=new Error("Error fetching document: "+t.message);throw e.cause=t,e}const o=n.type;if(!o)throw new Error("Key suite type not found in fetched document.");const s=this.suites.get(o);if(!s)throw new Error(`Support for suite "${o}" is not installed.`);return s.fromKeyDocument({document:n,checkContext:i,checkRevoked:r})}_installed({type:t}){return this.suites.has(t)}_suiteForType(t){const e=t&&t.type;if(!e)throw new TypeError("Missing key type.");if(!this._installed({type:e}))throw new Error(`Support for key type "${e}" is not installed.`);return this.suites.get(e)}}};
2
- /*!
3
- * Copyright (c) 2018-2021 Digital Bazaar, Inc. All rights reserved.
4
- */let tn=class{constructor({id:t,controller:e,revoked:i}={}){this.id=t,this.controller=e,this.revoked=i}static async generate(){throw new Error("Abstract method, must be implemented in subclass.")}static async fromKeyDocument({document:t,checkContext:e=!0,checkRevoked:i=!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(i&&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 i={id:this.id,type:this.type,controller:this.controller};return this.revoked&&(i.revoked=this.revoked),i}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.")}}}};tn.SUITE_CONTEXT="INVALID LDKeyPair CONTEXT";var en={LDKeyPair:tn};const{CryptoLD:rn}=Qr,{LDKeyPair:nn}=en;var on=l({CryptoLD:rn,LDKeyPair:nn});const sn="EcdsaSecp256k1VerificationKey2019",an=t=>zr("sha256").update(t).digest();class hn extends on.LDKeyPair{constructor({publicKeyBase58:t,privateKeyBase58:e,...i}){if(super(i),this.type=void 0,this.publicKeyBase58=void 0,this.privateKeyBase58=void 0,e&&!t){const t=g.publicKeyCreate(f(e));this.publicKeyBase58=d(t)}else this.publicKeyBase58=t;if(this.type=sn,this.privateKeyBase58=e,!this.publicKeyBase58)throw new TypeError('The "publicKeyBase58" property is required.')}static from(t){if(t.publicKeyHex||t.privateKeyHex){const{publicKeyHex:e,privateKeyHex:i,...n}=t;return new hn({...n,publicKeyBase58:e?d(r.from(e,"hex")):void 0,privateKeyBase58:i?d(r.from(i,"hex")):void 0})}return new hn(t)}static async generate({seed:t,compressed:e,...i}){if(t&&!g.privateKeyVerify(t))throw new Error("Provided seed is not a valid private key");let r=t;for(;void 0===r||!g.privateKeyVerify(r);)r=new Uint8Array(Zr(32));const n=g.publicKeyCreate(r,e);return new hn({publicKeyBase58:d(n),privateKeyBase58:d(r),...i})}export({publicKey:t=!1,privateKey:e=!1,includeContext:i=!1}={}){if(!t&&!e)throw new TypeError('export requires specifying either "publicKey" or "privateKey".');if(e&&!this.privateKeyBase58)throw new TypeError("No privateKey to export.");if(t&&!this.publicKeyBase58)throw new TypeError("No publicKey to export.");const r={type:this.type,id:this.id,controller:this.controller,revoked:this.revoked};return i&&(r["@context"]=hn.SUITE_CONTEXT),e&&(r.privateKeyBase58=this.privateKeyBase58),t&&(r.publicKeyBase58=this.publicKeyBase58),r}signer(){const{privateKeyBase58:t}=this;return t?{async sign({data:e}){const i=w.encode(JSON.stringify({alg:"ES256K",b64:!1,crit:["b64"]})),n=r.from(e.buffer,e.byteOffset,e.length),o=an(r.from(r.concat([r.from(`${i}.`,"utf8"),r.from(n.buffer,n.byteOffset,n.length)]))),{signature:s}=g.ecdsaSign(o,f(t));return`${i}..${w.encode(r.from(s))}`},id:this.id}:{async sign(){throw new Error("No private key to sign with.")},id:this.id}}verifier(){const{publicKeyBase58:t}=this;return t?{async verify({data:e,signature:i}){if(i.indexOf("..")<0)return!1;const[n,o]=i.split(".."),s=JSON.parse(w.decode(n));if("ES256K"!==s.alg||!1!==s.b64||!s.crit||!s.crit.length||"b64"!==s.crit[0])return!1;const a=r.from(e.buffer,e.byteOffset,e.length),h=an(r.from(r.concat([r.from(`${n}.`,"utf8"),r.from(a.buffer,a.byteOffset,a.length)])));let u;try{u=g.ecdsaVerify(r.from(w.decode(o,"hex"),"hex"),h,f(t))}catch(t){u=!1}return u},id:this.id}:{async verify(){throw new Error("No public key to verify against")},id:this.id}}}hn.suite=sn,hn.SUITE_CONTEXT="https://ns.did.ai/suites/secp256k1-2019/v1";const un="https://ns.did.ai/suites/secp256k1-2019/v1",cn=({document:t,contextUrl:e})=>{const i=t["@context"];return i===e||Array.isArray(i)&&i.includes(e)},ln=({document:t})=>{const e=cn({document:t,contextUrl:un}),i=cn({document:t,contextUrl:"https://www.w3.org/2018/credentials/v1"}),r=cn({document:t,contextUrl:"https://w3id.org/security/v2"});return e&&i?(console.warn("Warning: The secp256k1-2019/v1 and credentials/v1 contexts are incompatible."),console.warn("For VCs using EcdsaSecp256k1Signature2019 suite, using the credentials/v1 context is sufficient."),!1):e&&r?(console.warn("Warning: The secp256k1-2019/v1 and security/v2 contexts are incompatible."),console.warn("For VCs using EcdsaSecp256k1Signature2019 suite, using the security/v2 context is sufficient."),!1):e||i||r};let fn=class extends p.suites.LinkedDataSignature{constructor(t={}){super({type:"EcdsaSecp256k1Signature2019",LDKeyClass:hn,contextUrl:un,...t}),this.requiredKeyType=void 0,this.requiredKeyType="EcdsaSecp256k1VerificationKey2019"}async sign({verifyData:t,proof:e}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");return{...e,jws:await this.signer.sign({data:t})}}async verifySignature({verifyData:t,verificationMethod:e,proof:i}){const{jws:r}=i;if(!r||"string"!=typeof r)throw new TypeError('The proof does not include a valid "jws" property.');let{verifier:n}=this;if(!n){n=(await this.LDKeyClass.from(e)).verifier()}return n.verify({data:t,signature:r})}async assertVerificationMethod({verificationMethod:t}){if(!ln({document:t}))throw new TypeError(`The verification method (key) must contain "${this.contextUrl}".`);if(!_.hasValue(t,"type",this.requiredKeyType))throw new Error(`Invalid key type. Key type must be "${this.requiredKeyType}".`);if(void 0!==t.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:t,documentLoader:e}){if(this.key)return this.key.export({publicKey:!0});const i="object"==typeof t.verificationMethod?t.verificationMethod.id:t.verificationMethod;if(!i)throw new Error('No "verificationMethod" found in proof.');const r=await _.frame(i,{"@context":this.contextUrl,"@embed":"@always",id:i},{documentLoader:e,compactToRelative:!1});if(!r)throw new Error(`Verification method ${i} not found.`);if(void 0!==r.revoked)throw new Error("The verification method has been revoked.");return await this.assertVerificationMethod({verificationMethod:r}),r}async matchProof({proof:t,document:e,purpose:i,documentLoader:r,expansionMap:n}){if(!ln({document:e}))return!1;if(!await super.matchProof({proof:t,document:e,purpose:i,documentLoader:r,expansionMap:n}))return!1;if(!this.key)return!0;const{verificationMethod:o}=t,s="object"==typeof o?o.id:o;return this.isVerificationMethodMatchingKeyId(s)}ensureSuiteContext({document:t,addSuiteContext:e}){ln({document:t})||super.ensureSuiteContext({document:t,addSuiteContext:e})}isVerificationMethodMatchingKeyId(t){return t===this.key.id||t===`${this.key.controller}${this.key.id}`}};fn.CONTEXT_URL=un,fn.CONTEXT={"@context":{id:"@id",type:"@type","@protected":!0,proof:{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"},EcdsaSecp256k1VerificationKey2019:{"@id":"https://w3id.org/security#EcdsaSecp256k1VerificationKey2019","@context":{"@protected":!0,id:"@id",type:"@type",controller:{"@id":"https://w3id.org/security#controller","@type":"@id"},revoked:{"@id":"https://w3id.org/security#revoked","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},blockchainAccountId:{"@id":"https://w3id.org/security#blockchainAccountId"},publicKeyJwk:{"@id":"https://w3id.org/security#publicKeyJwk","@type":"@json"},publicKeyBase58:{"@id":"https://w3id.org/security#publicKeyBase58"},publicKeyMultibase:{"@id":"https://w3id.org/security#publicKeyMultibase","@type":"https://w3id.org/security#multibase"}}},EcdsaSecp256k1Signature2019:{"@id":"https://w3id.org/security#EcdsaSecp256k1Signature2019","@context":{"@protected":!0,id:"@id",type:"@type",challenge:"https://w3id.org/security#challenge",created:{"@id":"http://purl.org/dc/terms/created","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},domain:"https://w3id.org/security#domain",expires:{"@id":"https://w3id.org/security#expiration","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},nonce:"https://w3id.org/security#nonce",proofPurpose:{"@id":"https://w3id.org/security#proofPurpose","@type":"@vocab","@context":{"@protected":!0,id:"@id",type:"@type",assertionMethod:{"@id":"https://w3id.org/security#assertionMethod","@type":"@id","@container":"@set"},authentication:{"@id":"https://w3id.org/security#authenticationMethod","@type":"@id","@container":"@set"},capabilityInvocation:{"@id":"https://w3id.org/security#capabilityInvocationMethod","@type":"@id","@container":"@set"},capabilityDelegation:{"@id":"https://w3id.org/security#capabilityDelegationMethod","@type":"@id","@container":"@set"},keyAgreement:{"@id":"https://w3id.org/security#keyAgreementMethod","@type":"@id","@container":"@set"}}},jws:{"@id":"https://w3id.org/security#jws"},verificationMethod:{"@id":"https://w3id.org/security#verificationMethod","@type":"@id"}}}}};const dn="undefined"==typeof Buffer?r:Buffer,{purposes:{AssertionProofPurpose:pn}}=p;var _n;!function(t){t.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",t.checkDocumentSignature="checkDocumentSignature"}(_n||(_n={}));class yn extends T{verificationProcess=[_n.retrieveVerificationMethodPublicKey,_n.checkDocumentSignature];documentToVerify;issuer;proof;type="EcdsaSecp256k1Signature2019";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(t){return this.verificationProcess.map((e=>n.verifier.convertToVerificationSubsteps(t,e)))}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,i){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}validateProofType(){const t=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(t!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${t}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){o[this.documentToVerify.issuer]=this.getTargetVerificationMethodContainer();return function(t){return t in o?{contextUrl:null,document:o[t],documentUrl:t}:_.documentLoader(t)}}retrieveInitialDocument(){const t=s(this.documentToVerify);if(Array.isArray(t.proof)){const e=t.proof.find((t=>t.type===this.type));delete t.proof,t.proof=e}return t}getTargetVerificationMethodContainer(){return this.issuer.didDocument??this.issuer}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(_n.retrieveVerificationMethodPublicKey,(async()=>{const t=M(this.getTargetVerificationMethodContainer(),this.proof.verificationMethod);if(t.publicKeyJwk&&!t.publicKeyBase58){const i=(t=>{const e=m.from({...t,crv:"K-256"},"jwk").toString("blk","public"),i=S.publicKeyConvert(dn.from(e,"hex"),!0);return dn.from(i).toString("hex")})(t.publicKeyJwk);t.publicKeyBase58=(e=i,E.encode(dn.from(e,"hex")))}var e;this.publicKey=t.publicKeyBase58;const i=hn.from({...t});if(!i)throw new a(_n.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(i.revoked)throw new a(_n.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return i}),this.type)}async checkDocumentSignature(){await this.executeStep(_n.checkDocumentSignature,(async()=>{const t=new fn({key:this.verificationKey});t.date=new Date(Date.now()).toISOString();const e=await p.verify(this.retrieveInitialDocument(),{suite:t,purpose:new pn,documentLoader:this.generateDocumentLoader()});if(!e.verified)throw console.error(JSON.stringify(e,null,2)),new a(_n.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed`);console.log("Credential Secp256k1 signature successfully verified")}),this.type)}}export{yn as default};
@@ -1,52 +0,0 @@
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,d as s,e as u}from"./index-VOqA2-xz-CKqwdkuf.js";import{j as f}from"./jsonld-BpvX3DRL-qZrjsUmJ.js";import{d as p,e as l}from"./base64url-Cy03LJLt-vkTPfQOh.js";import{_ as y}from"./tslib.es6-CNEFicEt-CmLYFWVC.js";import{x as h,e as d}from"./x25519-Dm-l65ld-DcUk09rC.js";import{S as w}from"./Suite-B7Vy9AuU-D1ucdMDB.js";import"./_commonjs-dynamic-modules-COweQ1RR-BHR_E30J.js";
2
- /*!
3
- * Copyright (c) 2022 Digital Bazaar, Inc. All rights reserved.
4
- */function v({bytes: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"),L=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),S=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)*L);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)*S-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 D(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!!(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 D(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 D(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 D(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 X(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 X(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"+D(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):X(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:D,hexToBytes:X,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)}}});
6
- /*!
7
- * Copyright (c) 2020-2022 Digital Bazaar, Inc. All rights reserved.
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}}
10
- /*!
11
- * Copyright (c) 2018-2022 Digital Bazaar, Inc. All rights reserved.
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";
13
- /*!
14
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
15
- */
16
- const lt="Ed25519VerificationKey2020",yt=new Uint8Array([237,1]),ht=new Uint8Array([128,38]);class dt extends pt{constructor(t={}){super(t),this.type=lt;const{publicKeyMultibase:e,privateKeyMultibase:r}=t;if(!e)throw new TypeError('The "publicKeyMultibase" property is required.');if(!e||!wt(e,yt))throw new Error(`"publicKeyMultibase" has invalid header bytes: "${e}".`);if(r&&!wt(r,ht))throw new Error('"privateKeyMultibase" has invalid header bytes.');this.publicKeyMultibase=e,this.privateKeyMultibase=r,this.controller&&!this.id&&(this.id=`${this.controller}#${this.fingerprint()}`),v({bytes:this._publicKeyBuffer,code:"invalidPublicKeyLength",expectedLength:32})}static async from(t){return"Ed25519VerificationKey2018"===t.type?dt.fromEd25519VerificationKey2018(t):"JsonWebKey2020"===t.type?dt.fromJsonWebKey2020(t):new dt(t)}static fromEd25519VerificationKey2018({keyPair:t}={}){const e=vt(yt,s(t.publicKeyBase58)),r=new dt({id:t.id,controller:t.controller,publicKeyMultibase:e});return t.privateKeyBase58&&(r.privateKeyMultibase=vt(ht,s(t.privateKeyBase58))),r}static fromJsonWebKey2020({id:t,type:e,controller:r,publicKeyJwk:n}={}){if("JsonWebKey2020"!==e)throw new TypeError(`Invalid key type: "${e}".`);if(!n)throw new TypeError('"publicKeyJwk" property is required.');const{kty:i,crv:o}=n;if("OKP"!==i)throw new TypeError('"kty" is required to be "OKP".');if("Ed25519"!==o)throw new TypeError('"crv" is required to be "Ed25519".');const{x:a}=n,c=vt(yt,p(a));return dt.from({id:t,controller:r,publicKeyMultibase:c})}static async generate({seed:t,...e}={}){let r;r=t?await ut.generateKeyPairFromSeed(t):await ut.generateKeyPair();const n=vt(yt,r.publicKey),i=vt(ht,r.secretKey);return new dt({publicKeyMultibase:n,privateKeyMultibase:i,...e})}static fromFingerprint({fingerprint:t}={}){return new dt({publicKeyMultibase:t})}get _publicKeyBuffer(){if(!this.publicKeyMultibase)return;return s(this.publicKeyMultibase.substr(1)).slice(yt.length)}get _privateKeyBuffer(){if(!this.privateKeyMultibase)return;return s(this.privateKeyMultibase.substr(1)).slice(ht.length)}fingerprint(){return this.publicKeyMultibase}export({publicKey:t=!1,privateKey:e=!1,includeContext:r=!1}={}){if(!t&&!e)throw new TypeError('Export requires specifying either "publicKey" or "privateKey".');const n={id:this.id,type:this.type};return r&&(n["@context"]=dt.SUITE_CONTEXT),this.controller&&(n.controller=this.controller),t&&(n.publicKeyMultibase=this.publicKeyMultibase),e&&(n.privateKeyMultibase=this.privateKeyMultibase),this.revoked&&(n.revoked=this.revoked),n}toJwk({publicKey:t=!0,privateKey:e=!1}={}){if(!t&&!e)throw TypeError('Either a "publicKey" or a "privateKey" is required.');const r={crv:"Ed25519",kty:"OKP"};return t&&(r.x=l(this._publicKeyBuffer)),e&&(r.d=l(this._privateKeyBuffer)),r}async jwkThumbprint(){const t=`{"crv":"Ed25519","kty":"OKP","x":"${l(this._publicKeyBuffer)}"}`,e=(new TextEncoder).encode(t);return l(new Uint8Array(await ut.sha256digest({data:e})))}async toJsonWebKey2020(){return{"@context":"https://w3id.org/security/jws/v1",id:this.controller+"#"+await this.jwkThumbprint(),type:"JsonWebKey2020",controller:this.controller,publicKeyJwk:this.toJwk({publicKey:!0})}}verifyFingerprint({fingerprint:t}={}){if("string"!=typeof t||"z"!==t[0])return{error:new Error('"fingerprint" must be a multibase encoded string.'),valid:!1};let e;try{if(e=s(t.substr(1)),!e)throw new TypeError("Invalid encoding of fingerprint.")}catch(t){return{error:t,valid:!1}}const r=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}(this._publicKeyBuffer,e.slice(2)),n=e[0]===yt[0]&&e[1]===yt[1]&&r;return n?{valid:n}:{error:new Error("The fingerprint does not match the public key."),valid:!1}}signer(){const t=this._privateKeyBuffer;return{async sign({data:e}){if(!t)throw new Error("A private key is not available for signing.");return ut.sign(t,e)},id:this.id}}verifier(){const t=this._publicKeyBuffer;return{async verify({data:e,signature:r}){if(!t)throw new Error("A public key is not available for verifying.");return ut.verify(t,e,r)},id:this.id}}}function wt(t,e){if("string"!=typeof t||"z"!==t[0])return!1;const r=s(t.slice(1));return e.every(((t,e)=>r[e]===t))}function vt(t,e){const r=new Uint8Array(t.length+e.length);return r.set(t),r.set(e,t.length),"z"+u(r)}dt.suite=lt,dt.SUITE_CONTEXT="https://w3id.org/security/suites/ed25519-2020/v1";var gt,mt,bt,xt=(gt=function(t,e){!function(t,e){for(var r in e)t[r]=e[r]}(e,function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){
17
- /*!
18
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
19
- */
20
- t.exports={"@context":{id:"@id",type:"@type","@protected":!0,proof:{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"},Ed25519VerificationKey2020:{"@id":"https://w3id.org/security#Ed25519VerificationKey2020","@context":{"@protected":!0,id:"@id",type:"@type",controller:{"@id":"https://w3id.org/security#controller","@type":"@id"},revoked:{"@id":"https://w3id.org/security#revoked","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},publicKeyMultibase:{"@id":"https://w3id.org/security#publicKeyMultibase","@type":"https://w3id.org/security#multibase"}}},Ed25519Signature2020:{"@id":"https://w3id.org/security#Ed25519Signature2020","@context":{"@protected":!0,id:"@id",type:"@type",challenge:"https://w3id.org/security#challenge",created:{"@id":"http://purl.org/dc/terms/created","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},domain:"https://w3id.org/security#domain",expires:{"@id":"https://w3id.org/security#expiration","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},nonce:"https://w3id.org/security#nonce",proofPurpose:{"@id":"https://w3id.org/security#proofPurpose","@type":"@vocab","@context":{"@protected":!0,id:"@id",type:"@type",assertionMethod:{"@id":"https://w3id.org/security#assertionMethod","@type":"@id","@container":"@set"},authentication:{"@id":"https://w3id.org/security#authenticationMethod","@type":"@id","@container":"@set"},capabilityInvocation:{"@id":"https://w3id.org/security#capabilityInvocationMethod","@type":"@id","@container":"@set"},capabilityDelegation:{"@id":"https://w3id.org/security#capabilityDelegationMethod","@type":"@id","@container":"@set"},keyAgreement:{"@id":"https://w3id.org/security#keyAgreementMethod","@type":"@id","@container":"@set"}}},proofValue:{"@id":"https://w3id.org/security#proofValue","@type":"https://w3id.org/security#multibase"},verificationMethod:{"@id":"https://w3id.org/security#verificationMethod","@type":"@id"}}}}}},function(t,e,r){
21
- /*!
22
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
23
- */
24
- t.exports={CONTEXT_FILENAME:"ed25519-signature-2020-v1.jsonld",CONTEXT_URL:"https://w3id.org/security/suites/ed25519-2020/v1",CBORLD_CODEC_VALUE:20}},function(t,e,r){
25
- /*!
26
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
27
- */
28
- const n=r(0),i=r(1),{documentLoader:o}=r(3),{CONTEXT_URL:a,CBORLD_CODEC_VALUE:c}=i,s=new Map;s.set(i.CONTEXT_URL,n);const u=new Map;u.set(a,c),t.exports={constants:i,contexts:s,appContextMap:u,documentLoader:o,CONTEXT_URL:a,CONTEXT:n}},function(t,e,r){
29
- /*!
30
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
31
- */
32
- const{CONTEXT_URL:n}=r(1),i=r(0);t.exports={documentLoader(t){if(t!==n)throw new Error(`Loading document "${t}" is not allowed.`);return{contextUrl:null,document:i,documentUrl:t}}}}]))},gt(mt={exports:{}},mt.exports),mt.exports),Et=(bt=xt)&&bt.__esModule&&Object.prototype.hasOwnProperty.call(bt,"default")?bt.default:bt;xt.contexts,xt.constants,xt.CONTEXT,xt.CONTEXT_URL,xt.appContextMap,xt.documentLoader;var Kt=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t,e){!function(t,e){for(var r in e)t[r]=e[r]}(e,function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=2)}([function(t,e,r){
33
- /*!
34
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
35
- */
36
- t.exports={"@context":{id:"@id",type:"@type","@protected":!0,proof:{"@id":"https://w3id.org/security#proof","@type":"@id","@container":"@graph"},Ed25519VerificationKey2018:{"@id":"https://w3id.org/security#Ed25519VerificationKey2018","@context":{"@protected":!0,id:"@id",type:"@type",controller:{"@id":"https://w3id.org/security#controller","@type":"@id"},revoked:{"@id":"https://w3id.org/security#revoked","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},publicKeyBase58:{"@id":"https://w3id.org/security#publicKeyBase58"}}},Ed25519Signature2018:{"@id":"https://w3id.org/security#Ed25519Signature2018","@context":{"@protected":!0,id:"@id",type:"@type",challenge:"https://w3id.org/security#challenge",created:{"@id":"http://purl.org/dc/terms/created","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},domain:"https://w3id.org/security#domain",expires:{"@id":"https://w3id.org/security#expiration","@type":"http://www.w3.org/2001/XMLSchema#dateTime"},nonce:"https://w3id.org/security#nonce",proofPurpose:{"@id":"https://w3id.org/security#proofPurpose","@type":"@vocab","@context":{"@protected":!0,id:"@id",type:"@type",assertionMethod:{"@id":"https://w3id.org/security#assertionMethod","@type":"@id","@container":"@set"},authentication:{"@id":"https://w3id.org/security#authenticationMethod","@type":"@id","@container":"@set"},capabilityInvocation:{"@id":"https://w3id.org/security#capabilityInvocationMethod","@type":"@id","@container":"@set"},capabilityDelegation:{"@id":"https://w3id.org/security#capabilityDelegationMethod","@type":"@id","@container":"@set"},keyAgreement:{"@id":"https://w3id.org/security#keyAgreementMethod","@type":"@id","@container":"@set"}}},jws:{"@id":"https://w3id.org/security#jws"},verificationMethod:{"@id":"https://w3id.org/security#verificationMethod","@type":"@id"}}}}}},function(t,e,r){
37
- /*!
38
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
39
- */
40
- t.exports={CONTEXT_FILENAME:"ed25519-signature-2018-v1.jsonld",CONTEXT_URL:"https://w3id.org/security/suites/ed25519-2018/v1",CBORLD_CODEC_VALUE:19}},function(t,e,r){
41
- /*!
42
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
43
- */
44
- const n=r(0),i=r(1),{documentLoader:o}=r(3),{CONTEXT_URL:a,CBORLD_CODEC_VALUE:c}=i,s=new Map;s.set(a,n);const u=new Map;u.set(a,c),t.exports={constants:i,contexts:s,appContextMap:u,documentLoader:o,CONTEXT_URL:a,CONTEXT:n}},function(t,e,r){
45
- /*!
46
- * Copyright (c) 2021 Digital Bazaar, Inc. All rights reserved.
47
- */
48
- const{CONTEXT_URL:n}=r(1),i=r(0);t.exports={documentLoader(t){if(t!==n)throw new Error(`Loading document "${t}" is not allowed.`);return{contextUrl:null,document:i,documentUrl:t}}}}]))})),Tt=function(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}(Kt);Kt.contexts,Kt.constants,Kt.CONTEXT,Kt.CONTEXT_URL,Kt.appContextMap,Kt.documentLoader;
49
- /*!
50
- * Copyright (c) 2020-2021 Digital Bazaar, Inc. All rights reserved.
51
- */
52
- const{suites:{LinkedDataSignature:At}}=c,kt=Et.constants.CONTEXT_URL,Ot=Tt.constants.CONTEXT_URL;let Lt=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"+u(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=s(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(!St({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(!St({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 St({document:t,contextUrl:e}){const r=t["@context"];return r===e||Array.isArray(r)&&r.includes(e)}Lt.CONTEXT_URL=kt,Lt.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 Dt(){return Dt=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},Dt.apply(this,arguments)}var Xt=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 L(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(S([])));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 L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(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=S,L.prototype={constructor:L,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:S(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=Dt({},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(Xt.mark((function t(e){var r,n;return Xt.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(Xt.mark((function t(e){var r,n,i,o;return Xt.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(Xt.mark((function t(){return Xt.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(Xt.mark((function t(e){return Xt.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(Xt.mark((function t(e){var r,n,i;return Xt.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(Xt.mark((function t(e){var r,n,i,o,a;return Xt.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(Xt.mark((function t(e){var r,n,i;return Xt.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 L(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(S([])));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 L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function S(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=S,L.prototype={constructor:L,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:S(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}:f.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 Lt({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};