@blockcerts/blockcerts-verifier 1.57.5 → 1.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle-stats.html +24 -20
- package/dist/EcdsaSecp256k1Signature2019-XwuS-fWx-n_8xXj1H.js +4 -0
- package/dist/Ed25519Signature2020-IJ4ybcbU-ii2PjWjh.js +52 -0
- package/dist/{HashlinkVerifier-40818bdd-tYZmELFg.js → HashlinkVerifier-wyKYZ83G-aKb9h_9G.js} +1 -1
- package/dist/{MerkleProof2017-ac8d147b-6wk-NtfB.js → MerkleProof2017-Ub6_JUVj-Z6jluDo2.js} +1 -1
- package/dist/MerkleProof2019-QUwyEIHd-9hBGmPq_.js +3 -0
- package/dist/base64url-qi3FT6uz-yv4mTXpu.js +4 -0
- package/dist/checkRevocationStatusList2021-d1qO1xnj-AIMXIqnZ.js +13 -0
- package/dist/controlVerificationMethod-6GJtYmqY-VwQyuM5o.js +1 -0
- package/dist/{did-key-common.esm-2e9ab4e3-X4avzjKx.js → did-key-common.esm-Fyh_U6fK-6hhnSYH5.js} +3 -3
- package/dist/{did-key-ed25519.esm-54d2cbca-E7NBXv8_.js → did-key-ed25519.esm-1lIlZtof-q2UR_X9G.js} +1 -1
- package/dist/did-key-secp256k1.esm-hA8kGTM0-5bW-jZai.js +1 -0
- package/dist/{downloadPDF-5Pw6AlBs.js → downloadPDF-6pZYEy3P.js} +8 -8
- package/dist/index-CZOUZnn4-Lnb5-WZi.js +5 -0
- package/dist/{index-6d4132ca-BtAgIaHS.js → index-MC635rre-r3wKwiyR.js} +2 -2
- package/dist/index.es-NoR6QQLP.js +56 -0
- package/dist/{jsonld-6909fb49-vaWL2Y4h.js → jsonld-CXlzLf4P-Wh4x173W.js} +1 -1
- package/dist/{jsonld-signatures-8ecbbaa2-MztjIc1c.js → jsonld-signatures-ooFWZVS--VI8BZQOv.js} +6 -6
- package/dist/main.js +110 -110
- package/dist/{purify-xGHUwWlQ.js → purify-05qYXQpp.js} +1 -1
- package/dist/tslib.es6-M1zqH4el-x9kNW1T_.js +1 -0
- package/dist/x25519-NtRELWAG-TIgip27e.js +1 -0
- package/package.json +5 -5
- package/dist/EcdsaSecp256k1Signature2019-01e33e56-_kD7OEMM.js +0 -4
- package/dist/Ed25519Signature2020-722d8d24-52XGswpx.js +0 -74
- package/dist/MerkleProof2019-6596bc5f-AOhD0MU2.js +0 -3
- package/dist/checkRevocationStatusList2021-904b13ff-HXtw_2Lc.js +0 -17
- package/dist/controlVerificationMethod-80d0e7f0-8ug9g49U.js +0 -1
- package/dist/did-key-secp256k1.esm-8a01b23c-iRA0puBs.js +0 -1
- package/dist/index-85f56501-xkysxAxC.js +0 -4
- package/dist/index-a93e1e88-w6XCMY1g.js +0 -1
- package/dist/index.es-YP2tdnLj.js +0 -56
- package/dist/tslib.es6-28b6776b-qWIKDnpX.js +0 -1
- package/dist/x25519-08f432f1-4TKeGPT6.js +0 -1
- /package/dist/{Suite-e65d26ad-e2QgHGhx.js → Suite-Bhitn5l3-e2QgHGhx.js} +0 -0
- /package/dist/{_commonjs-dynamic-modules-1e49c0dd-fkA6S-_a.js → _commonjs-dynamic-modules-F7P8sER7-fkA6S-_a.js} +0 -0
- /package/dist/{elliptic-a9d84078-BGmaMzNc.js → elliptic-il_lPAr--BGmaMzNc.js} +0 -0
- /package/dist/{ensureNotRevoked-2dc26afb-U5ByLE-t.js → ensureNotRevoked-2QGGtBqy-U5ByLE-t.js} +0 -0
- /package/dist/{ensureValidIssuingKey-b950fb8b-oM__XftS.js → ensureValidIssuingKey-zZEv5-cH-oM__XftS.js} +0 -0
- /package/dist/{index-0469d008-LwXIiw03.js → index-xsnp_Fid-LwXIiw03.js} +0 -0
- /package/dist/{pako.esm-7a9981ef-RAILONW0.js → pako.esm-jjCKMBM4-RAILONW0.js} +0 -0
- /package/dist/{sha256-71400caa-o9J6pXuo.js → sha256-wKeS8_4l-o9J6pXuo.js} +0 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{f as e,A as t,p as r,c as i,h as n,o,n as s,l as a,D as h,E as u,F as c,d as l}from"./main.js";import{j as f}from"./jsonld-signatures-ooFWZVS--VI8BZQOv.js";import{j as d}from"./jsonld-CXlzLf4P-Wh4x173W.js";import{s as p,b as y,d as b,r as _,a as w,k as g,e as v}from"./index-MC635rre-r3wKwiyR.js";import{r as m,i as E,e as S}from"./elliptic-il_lPAr--BGmaMzNc.js";import{d as k,e as R}from"./index-CZOUZnn4-Lnb5-WZi.js";import{S as T}from"./Suite-Bhitn5l3-e2QgHGhx.js";import"./pako.esm-jjCKMBM4-RAILONW0.js";import"./sha256-wKeS8_4l-o9J6pXuo.js";import"./index-xsnp_Fid-LwXIiw03.js";var M,x,A={exports:{}},K={},L=h(u),I=L.EventEmitter;function O(e,t){P(e,t),C(e)}function C(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function P(e,t){e.emit("error",t)}var D={destroy:function(e,r){var i=this,n=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return n||o?(r?r(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,t(P,this,e)):t(P,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,(function(e){!r&&e?i._writableState?i._writableState.errorEmitted?t(C,i):(i._writableState.errorEmitted=!0,t(O,i,e)):t(O,i,e):r?(t(C,i),r(e)):t(C,i)})),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(e,t){var r=e._readableState,i=e._writableState;r&&r.autoDestroy||i&&i.autoDestroy?e.destroy(t):e.emit("error",t)}},B={};var N={};function j(e,t,r){r||(r=Error);var i=function(e){var r,i;function n(r,i,n){return e.call(this,function(e,r,i){return"string"==typeof t?t:t(e,r,i)}(r,i,n))||this}return i=e,(r=n).prototype=Object.create(i.prototype),r.prototype.constructor=r,r.__proto__=i,n}(r);i.prototype.name=r.name,i.prototype.code=e,N[e]=i}function U(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}j("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),j("ERR_INVALID_ARG_TYPE",(function(e,t,r){var i,n,o,s;if("string"==typeof t&&(n="not ",t.substr(!o||o<0?0:+o,n.length)===n)?(i="must not be",t=t.replace(/^not /,"")):i="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))s="The ".concat(e," ").concat(i," ").concat(U(t,"type"));else{var a=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";s='The "'.concat(e,'" ').concat(a," ").concat(i," ").concat(U(t,"type"))}return s+=". Received type ".concat(typeof r)}),TypeError),j("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),j("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),j("ERR_STREAM_PREMATURE_CLOSE","Premature close"),j("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),j("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),j("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),j("ERR_STREAM_WRITE_AFTER_END","write after end"),j("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),j("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),j("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),B.codes=N;var V=B.codes.ERR_INVALID_OPT_VALUE;var q,W={getHighWaterMark:function(e,t,r,i){var n=function(e,t,r){return null!=e.highWaterMark?e.highWaterMark:t?e[r]:null}(t,i,r);if(null!=n){if(!isFinite(n)||Math.floor(n)!==n||n<0)throw new V(i?r:"highWaterMark",n);return Math.floor(n)}return e.objectMode?16:16384}},F={};function z(){if(q)return F;q=1;var e=p.Buffer,t=e.isEncoding||function(e){switch((e=""+e)&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function r(r){var i;switch(this.encoding=function(r){var i=function(e){if(!e)return"utf8";for(var t;;)switch(e){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 e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(r);if("string"!=typeof i&&(e.isEncoding===t||!t(r)))throw new Error("Unknown encoding: "+r);return i||r}(r),this.encoding){case"utf16le":this.text=o,this.end=s,i=4;break;case"utf8":this.fillLast=n,i=4;break;case"base64":this.text=a,this.end=h,i=3;break;default:return this.write=u,void(this.end=c)}this.lastNeed=0,this.lastTotal=0,this.lastChar=e.allocUnsafe(i)}function i(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function n(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function o(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function s(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function a(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function u(e){return e.toString(this.encoding)}function c(e){return e&&e.length?this.write(e):""}return F.StringDecoder=r,r.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""},r.prototype.end=function(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t},r.prototype.text=function(e,t){var r=function(e,t,r){var n=t.length-1;if(n<r)return 0;var o=i(t[n]);if(o>=0)return o>0&&(e.lastNeed=o-1),o;if(--n<r||-2===o)return 0;if(o=i(t[n]),o>=0)return o>0&&(e.lastNeed=o-2),o;if(--n<r||-2===o)return 0;if(o=i(t[n]),o>=0)return o>0&&(2===o?o=0:e.lastNeed=o-3),o;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},r.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length},F}var H=B.codes.ERR_STREAM_PREMATURE_CLOSE;function $(){}var Z,X,G,J,Y=function e(t,r,i){if("function"==typeof r)return e(t,null,r);r||(r={}),i=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,i=new Array(r),n=0;n<r;n++)i[n]=arguments[n];e.apply(this,i)}}}(i||$);var n=r.readable||!1!==r.readable&&t.readable,o=r.writable||!1!==r.writable&&t.writable,s=function(){t.writable||h()},a=t._writableState&&t._writableState.finished,h=function(){o=!1,a=!0,n||i.call(t)},u=t._readableState&&t._readableState.endEmitted,c=function(){n=!1,u=!0,o||i.call(t)},l=function(e){i.call(t,e)},f=function(){var e;return n&&!u?(t._readableState&&t._readableState.ended||(e=new H),i.call(t,e)):o&&!a?(t._writableState&&t._writableState.ended||(e=new H),i.call(t,e)):void 0},d=function(){t.req.on("finish",h)};return!function(e){return e.setHeader&&"function"==typeof e.abort}(t)?o&&!t._writableState&&(t.on("end",s),t.on("close",s)):(t.on("complete",h),t.on("abort",f),t.req?d():t.on("request",d)),t.on("end",c),t.on("finish",h),!1!==r.error&&t.on("error",l),t.on("close",f),function(){t.removeListener("complete",h),t.removeListener("abort",f),t.removeListener("request",d),t.req&&t.req.removeListener("finish",h),t.removeListener("end",s),t.removeListener("close",s),t.removeListener("finish",h),t.removeListener("end",c),t.removeListener("error",l),t.removeListener("close",f)}};function Q(){if(X)return Z;var e;function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}X=1;var i=Y,n=Symbol("lastResolve"),o=Symbol("lastReject"),s=Symbol("error"),a=Symbol("ended"),h=Symbol("lastPromise"),u=Symbol("handlePromise"),c=Symbol("stream");function l(e,t){return{value:e,done:t}}function f(e){var t=e[n];if(null!==t){var r=e[c].read();null!==r&&(e[h]=null,e[n]=null,e[o]=null,t(l(r,!1)))}}function d(e){t(f,e)}var p=Object.getPrototypeOf((function(){})),y=Object.setPrototypeOf((r(e={get stream(){return this[c]},next:function(){var e=this,r=this[s];if(null!==r)return Promise.reject(r);if(this[a])return Promise.resolve(l(void 0,!0));if(this[c].destroyed)return new Promise((function(r,i){t((function(){e[s]?i(e[s]):r(l(void 0,!0))}))}));var i,n=this[h];if(n)i=new Promise(function(e,t){return function(r,i){e.then((function(){t[a]?r(l(void 0,!0)):t[u](r,i)}),i)}}(n,this));else{var o=this[c].read();if(null!==o)return Promise.resolve(l(o,!1));i=new Promise(this[u])}return this[h]=i,i}},Symbol.asyncIterator,(function(){return this})),r(e,"return",(function(){var e=this;return new Promise((function(t,r){e[c].destroy(null,(function(e){e?r(e):t(l(void 0,!0))}))}))})),e),p);return Z=function(e){var t,f=Object.create(y,(r(t={},c,{value:e,writable:!0}),r(t,n,{value:null,writable:!0}),r(t,o,{value:null,writable:!0}),r(t,s,{value:null,writable:!0}),r(t,a,{value:e._readableState.endEmitted,writable:!0}),r(t,u,{value:function(e,t){var r=f[c].read();r?(f[h]=null,f[n]=null,f[o]=null,e(l(r,!1))):(f[n]=e,f[o]=t)},writable:!0}),t));return f[h]=null,i(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=f[o];return null!==t&&(f[h]=null,f[n]=null,f[o]=null,t(e)),void(f[s]=e)}var r=f[n];null!==r&&(f[h]=null,f[n]=null,f[o]=null,r(l(void 0,!0))),f[a]=!0})),e.on("readable",d.bind(null,f)),f}}const ee=K;ee.Readable=me,me.ReadableState=ve,L.EventEmitter;var te=function(e,t){return e.listeners(t).length},re=I,ie=m.Buffer,ne=e.Uint8Array||function(){};var oe,se=w;oe=se&&se.debuglog?se.debuglog("stream"):function(){};var ae,he,ue,ce=function(){if(x)return M;function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,i)}return r}function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}x=1;var i=m.Buffer,n=w.inspect,o=n&&n.custom||"inspect";return M=function(){function s(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),this.head=null,this.tail=null,this.length=0}var a,h,u;return a=s,h=[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return i.alloc(0);for(var t,r,n,o=i.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,r=o,n=a,i.prototype.copy.call(t,r,n),a+=s.data.length,s=s.next;return o}},{key:"consume",value:function(e,t){var r;return e<this.head.data.length?(r=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):r=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,r=1,i=t.data;for(e-=i.length;t=t.next;){var n=t.data,o=e>n.length?n.length:e;if(o===n.length?i+=n:i+=n.slice(0,e),0==(e-=o)){o===n.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=n.slice(o));break}++r}return this.length-=r,i}},{key:"_getBuffer",value:function(e){var t=i.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var o=r.data,s=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,s),0==(e-=s)){s===o.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=o.slice(s));break}++n}return this.length-=n,t}},{key:o,value:function(r,i){return n(this,function(r){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?e(Object(n),!0).forEach((function(e){t(r,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}({},i,{depth:0,customInspect:!1}))}}],h&&r(a.prototype,h),u&&r(a,u),s}(),M}(),le=D,fe=W.getHighWaterMark,de=B.codes,pe=de.ERR_INVALID_ARG_TYPE,ye=de.ERR_STREAM_PUSH_AFTER_EOF,be=de.ERR_METHOD_NOT_IMPLEMENTED,_e=de.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;E(me,re);var we=le.errorOrDestroy,ge=["error","close","destroy","pause","resume"];function ve(e,t,r){e=e||{},"boolean"!=typeof r&&(r=t instanceof ee.Duplex),this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=fe(this,e,"readableHighWaterMark",r),this.buffer=new ce,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(ae||(ae=z().StringDecoder),this.decoder=new ae(e.encoding),this.encoding=e.encoding)}function me(e){if(!(this instanceof me))return new me(e);var t=this instanceof ee.Duplex;this._readableState=new ve(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),re.call(this)}function Ee(e,t,r,i,n){oe("readableAddChunk",t);var o,s=e._readableState;if(null===t)s.reading=!1,function(e,t){if(oe("onEofChunk"),t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?Te(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,Me(e)))}(e,s);else if(n||(o=function(e,t){var r;i=t,ie.isBuffer(i)||i instanceof ne||"string"==typeof t||void 0===t||e.objectMode||(r=new pe("chunk",["string","Buffer","Uint8Array"],t));var i;return r}(s,t)),o)we(e,o);else if(s.objectMode||t&&t.length>0)if("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===ie.prototype||(t=function(e){return ie.from(e)}(t)),i)s.endEmitted?we(e,new _e):Se(e,s,t,!0);else if(s.ended)we(e,new ye);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?Se(e,s,t,!1):xe(e,s)):Se(e,s,t,!1)}else i||(s.reading=!1,xe(e,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function Se(e,t,r,i){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",r)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&Te(e)),xe(e,t)}Object.defineProperty(me.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),me.prototype.destroy=le.destroy,me.prototype._undestroy=le.undestroy,me.prototype._destroy=function(e,t){t(e)},me.prototype.push=function(e,t){var r,i=this._readableState;return i.objectMode?r=!0:"string"==typeof e&&((t=t||i.defaultEncoding)!==i.encoding&&(e=ie.from(e,t),t=""),r=!0),Ee(this,e,t,!1,r)},me.prototype.unshift=function(e){return Ee(this,e,null,!0,!1)},me.prototype.isPaused=function(){return!1===this._readableState.flowing},me.prototype.setEncoding=function(e){ae||(ae=z().StringDecoder);var t=new ae(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var r=this._readableState.buffer.head,i="";null!==r;)i+=t.write(r.data),r=r.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var ke=1073741824;function Re(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=ke?e=ke:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function Te(e){var r=e._readableState;oe("emitReadable",r.needReadable,r.emittedReadable),r.needReadable=!1,r.emittedReadable||(oe("emitReadable",r.flowing),r.emittedReadable=!0,t(Me,e))}function Me(e){var t=e._readableState;oe("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,Oe(e)}function xe(e,r){r.readingMore||(r.readingMore=!0,t(Ae,e,r))}function Ae(e,t){for(;!t.reading&&!t.ended&&(t.length<t.highWaterMark||t.flowing&&0===t.length);){var r=t.length;if(oe("maybeReadMore read 0"),e.read(0),r===t.length)break}t.readingMore=!1}function Ke(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function Le(e){oe("readable nexttick read 0"),e.read(0)}function Ie(e,t){oe("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),Oe(e),t.flowing&&!t.reading&&e.read(0)}function Oe(e){var t=e._readableState;for(oe("flow",t.flowing);t.flowing&&null!==e.read(););}function Ce(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function Pe(e){var r=e._readableState;oe("endReadable",r.endEmitted),r.endEmitted||(r.ended=!0,t(De,r,e))}function De(e,t){if(oe("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function Be(e,t){for(var r=0,i=e.length;r<i;r++)if(e[r]===t)return r;return-1}me.prototype.read=function(e){oe("read",e),e=parseInt(e,10);var t=this._readableState,r=e;if(0!==e&&(t.emittedReadable=!1),0===e&&t.needReadable&&((0!==t.highWaterMark?t.length>=t.highWaterMark:t.length>0)||t.ended))return oe("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?Pe(this):Te(this),null;if(0===(e=Re(e,t))&&t.ended)return 0===t.length&&Pe(this),null;var i,n=t.needReadable;return oe("need readable",n),(0===t.length||t.length-e<t.highWaterMark)&&oe("length less than watermark",n=!0),t.ended||t.reading?oe("reading or ended",n=!1):n&&(oe("do read"),t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1,t.reading||(e=Re(r,t))),null===(i=e>0?Ce(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&Pe(this)),null!==i&&this.emit("data",i),i},me.prototype._read=function(e){we(this,new be("_read()"))},me.prototype.pipe=function(e,i){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,oe("pipe count=%d opts=%j",o.pipesCount,i);var s=(!i||!1!==i.end)&&e!==r.stdout&&e!==r.stderr?h:y;function a(t,r){oe("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,oe("cleanup"),e.removeListener("close",d),e.removeListener("finish",p),e.removeListener("drain",u),e.removeListener("error",f),e.removeListener("unpipe",a),n.removeListener("end",h),n.removeListener("end",y),n.removeListener("data",l),c=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||u())}function h(){oe("onend"),e.end()}o.endEmitted?t(s):n.once("end",s),e.on("unpipe",a);var u=function(e){return function(){var t=e._readableState;oe("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&te(e,"data")&&(t.flowing=!0,Oe(e))}}(n);e.on("drain",u);var c=!1;function l(t){oe("ondata");var r=e.write(t);oe("dest.write",r),!1===r&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==Be(o.pipes,e))&&!c&&(oe("false write response, pause",o.awaitDrain),o.awaitDrain++),n.pause())}function f(t){oe("onerror",t),y(),e.removeListener("error",f),0===te(e,"error")&&we(e,t)}function d(){e.removeListener("finish",p),y()}function p(){oe("onfinish"),e.removeListener("close",d),y()}function y(){oe("unpipe"),n.unpipe(e)}return n.on("data",l),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",f),e.once("close",d),e.once("finish",p),e.emit("pipe",n),o.flowing||(oe("pipe resume"),n.resume()),e},me.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var i=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<n;o++)i[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=Be(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,r)),this},me.prototype.on=function(e,r){var i=re.prototype.on.call(this,e,r),n=this._readableState;return"data"===e?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===e&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,oe("on readable",n.length,n.reading),n.length?Te(this):n.reading||t(Le,this))),i},me.prototype.addListener=me.prototype.on,me.prototype.removeListener=function(e,r){var i=re.prototype.removeListener.call(this,e,r);return"readable"===e&&t(Ke,this),i},me.prototype.removeAllListeners=function(e){var r=re.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||t(Ke,this),r},me.prototype.resume=function(){var e=this._readableState;return e.flowing||(oe("resume"),e.flowing=!e.readableListening,function(e,r){r.resumeScheduled||(r.resumeScheduled=!0,t(Ie,e,r))}(this,e)),e.paused=!1,this},me.prototype.pause=function(){return oe("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(oe("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},me.prototype.wrap=function(e){var t=this,r=this._readableState,i=!1;for(var n in e.on("end",(function(){if(oe("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(n){(oe("wrapped data"),r.decoder&&(n=r.decoder.write(n)),r.objectMode&&null==n)||(r.objectMode||n&&n.length)&&(t.push(n)||(i=!0,e.pause()))})),e)void 0===this[n]&&"function"==typeof e[n]&&(this[n]=function(t){return function(){return e[t].apply(e,arguments)}}(n));for(var o=0;o<ge.length;o++)e.on(ge[o],this.emit.bind(this,ge[o]));return this._read=function(t){oe("wrapped _read",t),i&&(i=!1,e.resume())},this},"function"==typeof Symbol&&(me.prototype[Symbol.asyncIterator]=function(){return void 0===he&&(he=Q()),he(this)}),Object.defineProperty(me.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(me.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(me.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),me._fromList=Ce,Object.defineProperty(me.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(me.from=function(e,t){return void 0===ue&&(ue=J?G:(J=1,G=function(){throw new Error("Readable.from is not available in the browser")})),ue(me,e,t)});var Ne=function(e,t){if(je("noDeprecation"))return e;var r=!1;return function(){if(!r){if(je("throwDeprecation"))throw new Error(t);je("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}};function je(t){try{if(!e.localStorage)return!1}catch(e){return!1}var r=e.localStorage[t];return null!=r&&"true"===String(r).toLowerCase()}const Ue=K;function Ve(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var i=e.entry;e.entry=null;for(;i;){var n=i.callback;t.pendingcb--,n(r),i=i.next}t.corkedRequestsFree.next=e}(t,e)}}Ue.Writable=at,at.WritableState=st;var qe={deprecate:Ne},We=I,Fe=m.Buffer,ze=e.Uint8Array||function(){};var He,$e=D,Ze=W.getHighWaterMark,Xe=B.codes,Ge=Xe.ERR_INVALID_ARG_TYPE,Je=Xe.ERR_METHOD_NOT_IMPLEMENTED,Ye=Xe.ERR_MULTIPLE_CALLBACK,Qe=Xe.ERR_STREAM_CANNOT_PIPE,et=Xe.ERR_STREAM_DESTROYED,tt=Xe.ERR_STREAM_NULL_VALUES,rt=Xe.ERR_STREAM_WRITE_AFTER_END,it=Xe.ERR_UNKNOWN_ENCODING,nt=$e.errorOrDestroy;function ot(){}function st(e,r,i){e=e||{},"boolean"!=typeof i&&(i=r instanceof Ue.Duplex),this.objectMode=!!e.objectMode,i&&(this.objectMode=this.objectMode||!!e.writableObjectMode),this.highWaterMark=Ze(this,e,"writableHighWaterMark",i),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var n=!1===e.decodeStrings;this.decodeStrings=!n,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,r){var i=e._writableState,n=i.sync,o=i.writecb;if("function"!=typeof o)throw new Ye;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(i),r)!function(e,r,i,n,o){--r.pendingcb,i?(t(o,n),t(dt,e,r),e._writableState.errorEmitted=!0,nt(e,n)):(o(n),e._writableState.errorEmitted=!0,nt(e,n),dt(e,r))}(e,i,n,r,o);else{var s=lt(i)||e.destroyed;s||i.corked||i.bufferProcessing||!i.bufferedRequest||ct(e,i),n?t(ut,e,i,s,o):ut(e,i,s,o)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new Ve(this)}function at(e){var t=this instanceof Ue.Duplex;if(!t&&!He.call(at,this))return new at(e);this._writableState=new st(e,this,t),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),We.call(this)}function ht(e,t,r,i,n,o,s){t.writelen=i,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new et("write")):r?e._writev(n,t.onwrite):e._write(n,o,t.onwrite),t.sync=!1}function ut(e,t,r,i){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,i(),dt(e,t)}function ct(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var i=t.bufferedRequestCount,n=new Array(i),o=t.corkedRequestsFree;o.entry=r;for(var s=0,a=!0;r;)n[s]=r,r.isBuf||(a=!1),r=r.next,s+=1;n.allBuffers=a,ht(e,t,!0,t.length,n,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new Ve(t),t.bufferedRequestCount=0}else{for(;r;){var h=r.chunk,u=r.encoding,c=r.callback;if(ht(e,t,!1,t.objectMode?1:h.length,h,u,c),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function lt(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function ft(e,t){e._final((function(r){t.pendingcb--,r&&nt(e,r),t.prefinished=!0,e.emit("prefinish"),dt(e,t)}))}function dt(e,r){var i=lt(r);if(i&&(function(e,r){r.prefinished||r.finalCalled||("function"!=typeof e._final||r.destroyed?(r.prefinished=!0,e.emit("prefinish")):(r.pendingcb++,r.finalCalled=!0,t(ft,e,r)))}(e,r),0===r.pendingcb&&(r.finished=!0,e.emit("finish"),r.autoDestroy))){var n=e._readableState;(!n||n.autoDestroy&&n.endEmitted)&&e.destroy()}return i}E(at,We),st.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(st.prototype,"buffer",{get:qe.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(He=Function.prototype[Symbol.hasInstance],Object.defineProperty(at,Symbol.hasInstance,{value:function(e){return!!He.call(this,e)||this===at&&(e&&e._writableState instanceof st)}})):He=function(e){return e instanceof this},at.prototype.pipe=function(){nt(this,new Qe)},at.prototype.write=function(e,r,i){var n,o=this._writableState,s=!1,a=!o.objectMode&&(n=e,Fe.isBuffer(n)||n instanceof ze);return a&&!Fe.isBuffer(e)&&(e=function(e){return Fe.from(e)}(e)),"function"==typeof r&&(i=r,r=null),a?r="buffer":r||(r=o.defaultEncoding),"function"!=typeof i&&(i=ot),o.ending?function(e,r){var i=new rt;nt(e,i),t(r,i)}(this,i):(a||function(e,r,i,n){var o;return null===i?o=new tt:"string"==typeof i||r.objectMode||(o=new Ge("chunk",["string","Buffer"],i)),!o||(nt(e,o),t(n,o),!1)}(this,o,e,i))&&(o.pendingcb++,s=function(e,t,r,i,n,o){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Fe.from(t,r));return t}(t,i,n);i!==s&&(r=!0,n="buffer",i=s)}var a=t.objectMode?1:i.length;t.length+=a;var h=t.length<t.highWaterMark;h||(t.needDrain=!0);if(t.writing||t.corked){var u=t.lastBufferedRequest;t.lastBufferedRequest={chunk:i,encoding:n,isBuf:r,callback:o,next:null},u?u.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else ht(e,t,!1,a,i,n,o);return h}(this,o,a,e,r,i)),s},at.prototype.cork=function(){this._writableState.corked++},at.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||ct(this,e))},at.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new it(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(at.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(at.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),at.prototype._write=function(e,t,r){r(new Je("_write()"))},at.prototype._writev=null,at.prototype.end=function(e,r,i){var n=this._writableState;return"function"==typeof e?(i=e,e=null,r=null):"function"==typeof r&&(i=r,r=null),null!=e&&this.write(e,r),n.corked&&(n.corked=1,this.uncork()),n.ending||function(e,r,i){r.ending=!0,dt(e,r),i&&(r.finished?t(i):e.once("finish",i));r.ended=!0,e.writable=!1}(this,n,i),this},Object.defineProperty(at.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(at.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),at.prototype.destroy=$e.destroy,at.prototype._undestroy=$e.undestroy,at.prototype._destroy=function(e,t){t(e)};var pt=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};const yt=K;yt.Duplex=gt,E(gt,yt.Readable);for(var bt=pt(yt.Writable.prototype),_t=0;_t<bt.length;_t++){var wt=bt[_t];gt.prototype[wt]||(gt.prototype[wt]=yt.Writable.prototype[wt])}function gt(e){if(!(this instanceof gt))return new gt(e);yt.Readable.call(this,e),yt.Writable.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",vt)))}function vt(){this._writableState.ended||t(mt,this)}function mt(e){e.end()}Object.defineProperty(gt.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(gt.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(gt.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(gt.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed&&this._writableState.destroyed)},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}});const Et=K;Et.Transform=At;var St=B.codes,kt=St.ERR_METHOD_NOT_IMPLEMENTED,Rt=St.ERR_MULTIPLE_CALLBACK,Tt=St.ERR_TRANSFORM_ALREADY_TRANSFORMING,Mt=St.ERR_TRANSFORM_WITH_LENGTH_0;function xt(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(null===i)return this.emit("error",new Rt);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),i(e);var n=this._readableState;n.reading=!1,(n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}function At(e){if(!(this instanceof At))return new At(e);Et.Duplex.call(this,e),this._transformState={afterTransform:xt.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",Kt)}function Kt(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?Lt(this,null,null):this._flush((function(t,r){Lt(e,t,r)}))}function Lt(e,t,r){if(t)return e.emit("error",t);if(null!=r&&e.push(r),e._writableState.length)throw new Mt;if(e._transformState.transforming)throw new Tt;return e.push(null)}E(At,Et.Duplex),At.prototype.push=function(e,t){return this._transformState.needTransform=!1,Et.Duplex.prototype.push.call(this,e,t)},At.prototype._transform=function(e,t,r){r(new kt("_transform()"))},At.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var n=this._readableState;(i.needTransform||n.needReadable||n.length<n.highWaterMark)&&this._read(n.highWaterMark)}},At.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},At.prototype._destroy=function(e,t){Et.Duplex.prototype._destroy.call(this,e,(function(e){t(e)}))};const It=K;function Ot(e){if(!(this instanceof Ot))return new Ot(e);Transform.call(this,e)}var Ct;It.PassThrough=Ot,E(Ot,It.Transform),Ot.prototype._transform=function(e,t,r){r(null,e)};var Pt=B.codes,Dt=Pt.ERR_MISSING_ARGS,Bt=Pt.ERR_STREAM_DESTROYED;function Nt(e){if(e)throw e}function jt(e){e()}function Ut(e,t){return e.pipe(t)}var Vt=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var i,n=function(e){return e.length?"function"!=typeof e[e.length-1]?Nt:e.pop():Nt}(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Dt("streams");var o=t.map((function(e,r){var s=r<t.length-1;return function(e,t,r,i){i=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(i);var n=!1;e.on("close",(function(){n=!0})),void 0===Ct&&(Ct=Y),Ct(e,{readable:t,writable:r},(function(e){if(e)return i(e);n=!0,i()}));var o=!1;return function(t){if(!n&&!o)return o=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void i(t||new Bt("pipe"))}}(e,s,r>0,(function(e){i||(i=e),e&&o.forEach(jt),s||(o.forEach(jt),n(i))}))}));return t.reduce(Ut)};!function(e,t){const r=K;(t=A.exports=r.Readable).Stream=r.Readable,t.Readable=r.Readable,t.Writable=r.Writable,t.Duplex=r.Duplex,t.Transform=r.Transform,t.PassThrough=r.PassThrough,t.finished=Y,t.pipeline=Vt}(0,A.exports);var qt=A.exports,Wt=p.Buffer,Ft=qt;function zt(e){Ft.Stream.Transform.call(this),this._block=Wt.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}E(zt,Ft.Stream.Transform),zt.prototype._transform=function(e,t,r){var i=null;try{this.update(e,t)}catch(e){i=e}r(i)},zt.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},zt.prototype.update=function(e,t){if(function(e,t){if(!Wt.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");Wt.isBuffer(e)||(e=Wt.from(e,t));for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var n=this._blockOffset;n<this._blockSize;)r[n++]=e[i++];this._update(),this._blockOffset=0}for(;i<e.length;)r[this._blockOffset++]=e[i++];for(var o=0,s=8*e.length;s>0;++o)this._length[o]+=s,(s=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*s);return this},zt.prototype._update=function(){throw new Error("_update is not implemented")},zt.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},zt.prototype._digest=function(){throw new Error("_digest is not implemented")};var Ht=zt,$t=E,Zt=Ht,Xt=p.Buffer,Gt=new Array(16);function Jt(){Zt.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function Yt(e,t){return e<<t|e>>>32-t}function Qt(e,t,r,i,n,o,s){return Yt(e+(t&r|~t&i)+n+o|0,s)+t|0}function er(e,t,r,i,n,o,s){return Yt(e+(t&i|r&~i)+n+o|0,s)+t|0}function tr(e,t,r,i,n,o,s){return Yt(e+(t^r^i)+n+o|0,s)+t|0}function rr(e,t,r,i,n,o,s){return Yt(e+(r^(t|~i))+n+o|0,s)+t|0}$t(Jt,Zt),Jt.prototype._update=function(){for(var e=Gt,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,i=this._b,n=this._c,o=this._d;r=Qt(r,i,n,o,e[0],3614090360,7),o=Qt(o,r,i,n,e[1],3905402710,12),n=Qt(n,o,r,i,e[2],606105819,17),i=Qt(i,n,o,r,e[3],3250441966,22),r=Qt(r,i,n,o,e[4],4118548399,7),o=Qt(o,r,i,n,e[5],1200080426,12),n=Qt(n,o,r,i,e[6],2821735955,17),i=Qt(i,n,o,r,e[7],4249261313,22),r=Qt(r,i,n,o,e[8],1770035416,7),o=Qt(o,r,i,n,e[9],2336552879,12),n=Qt(n,o,r,i,e[10],4294925233,17),i=Qt(i,n,o,r,e[11],2304563134,22),r=Qt(r,i,n,o,e[12],1804603682,7),o=Qt(o,r,i,n,e[13],4254626195,12),n=Qt(n,o,r,i,e[14],2792965006,17),r=er(r,i=Qt(i,n,o,r,e[15],1236535329,22),n,o,e[1],4129170786,5),o=er(o,r,i,n,e[6],3225465664,9),n=er(n,o,r,i,e[11],643717713,14),i=er(i,n,o,r,e[0],3921069994,20),r=er(r,i,n,o,e[5],3593408605,5),o=er(o,r,i,n,e[10],38016083,9),n=er(n,o,r,i,e[15],3634488961,14),i=er(i,n,o,r,e[4],3889429448,20),r=er(r,i,n,o,e[9],568446438,5),o=er(o,r,i,n,e[14],3275163606,9),n=er(n,o,r,i,e[3],4107603335,14),i=er(i,n,o,r,e[8],1163531501,20),r=er(r,i,n,o,e[13],2850285829,5),o=er(o,r,i,n,e[2],4243563512,9),n=er(n,o,r,i,e[7],1735328473,14),r=tr(r,i=er(i,n,o,r,e[12],2368359562,20),n,o,e[5],4294588738,4),o=tr(o,r,i,n,e[8],2272392833,11),n=tr(n,o,r,i,e[11],1839030562,16),i=tr(i,n,o,r,e[14],4259657740,23),r=tr(r,i,n,o,e[1],2763975236,4),o=tr(o,r,i,n,e[4],1272893353,11),n=tr(n,o,r,i,e[7],4139469664,16),i=tr(i,n,o,r,e[10],3200236656,23),r=tr(r,i,n,o,e[13],681279174,4),o=tr(o,r,i,n,e[0],3936430074,11),n=tr(n,o,r,i,e[3],3572445317,16),i=tr(i,n,o,r,e[6],76029189,23),r=tr(r,i,n,o,e[9],3654602809,4),o=tr(o,r,i,n,e[12],3873151461,11),n=tr(n,o,r,i,e[15],530742520,16),r=rr(r,i=tr(i,n,o,r,e[2],3299628645,23),n,o,e[0],4096336452,6),o=rr(o,r,i,n,e[7],1126891415,10),n=rr(n,o,r,i,e[14],2878612391,15),i=rr(i,n,o,r,e[5],4237533241,21),r=rr(r,i,n,o,e[12],1700485571,6),o=rr(o,r,i,n,e[3],2399980690,10),n=rr(n,o,r,i,e[10],4293915773,15),i=rr(i,n,o,r,e[1],2240044497,21),r=rr(r,i,n,o,e[8],1873313359,6),o=rr(o,r,i,n,e[15],4264355552,10),n=rr(n,o,r,i,e[6],2734768916,15),i=rr(i,n,o,r,e[13],1309151649,21),r=rr(r,i,n,o,e[4],4149444226,6),o=rr(o,r,i,n,e[11],3174756917,10),n=rr(n,o,r,i,e[2],718787259,15),i=rr(i,n,o,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+i|0,this._c=this._c+n|0,this._d=this._d+o|0},Jt.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Xt.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};var ir=Jt,nr=m.Buffer,or=E,sr=Ht,ar=new Array(16),hr=[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],ur=[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],cr=[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],lr=[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],fr=[0,1518500249,1859775393,2400959708,2840853838],dr=[1352829926,1548603684,1836072691,2053994217,0];function pr(){sr.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function yr(e,t){return e<<t|e>>>32-t}function br(e,t,r,i,n,o,s,a){return yr(e+(t^r^i)+o+s|0,a)+n|0}function _r(e,t,r,i,n,o,s,a){return yr(e+(t&r|~t&i)+o+s|0,a)+n|0}function wr(e,t,r,i,n,o,s,a){return yr(e+((t|~r)^i)+o+s|0,a)+n|0}function gr(e,t,r,i,n,o,s,a){return yr(e+(t&i|r&~i)+o+s|0,a)+n|0}function vr(e,t,r,i,n,o,s,a){return yr(e+(t^(r|~i))+o+s|0,a)+n|0}or(pr,sr),pr.prototype._update=function(){for(var e=ar,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,i=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=br(r,i,n,o,s,e[hr[f]],fr[0],cr[f]),p=vr(a,h,u,c,l,e[ur[f]],dr[0],lr[f])):f<32?(d=_r(r,i,n,o,s,e[hr[f]],fr[1],cr[f]),p=gr(a,h,u,c,l,e[ur[f]],dr[1],lr[f])):f<48?(d=wr(r,i,n,o,s,e[hr[f]],fr[2],cr[f]),p=wr(a,h,u,c,l,e[ur[f]],dr[2],lr[f])):f<64?(d=gr(r,i,n,o,s,e[hr[f]],fr[3],cr[f]),p=_r(a,h,u,c,l,e[ur[f]],dr[3],lr[f])):(d=vr(r,i,n,o,s,e[hr[f]],fr[4],cr[f]),p=br(a,h,u,c,l,e[ur[f]],dr[4],lr[f])),r=s,s=o,o=yr(n,10),n=i,i=d,a=l,l=c,c=yr(u,10),u=h,h=p}var y=this._b+n+c|0;this._b=this._c+o+l|0,this._c=this._d+s+a|0,this._d=this._e+r+h|0,this._e=this._a+i+u|0,this._a=y},pr.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=nr.alloc?nr.alloc(20):new nr(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};var mr=pr,Er={exports:{}},Sr=p.Buffer;function kr(e,t){this._block=Sr.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}kr.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=Sr.from(e,t));for(var r=this._block,i=this._blockSize,n=e.length,o=this._len,s=0;s<n;){for(var a=o%i,h=Math.min(n-s,i-a),u=0;u<h;u++)r[a+u]=e[s+u];s+=h,(o+=h)%i==0&&this._update(r)}return this._len+=n,this},kr.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=(4294967295&r)>>>0,n=(r-i)/4294967296;this._block.writeUInt32BE(n,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},kr.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Rr=kr,Tr=E,Mr=Rr,xr=p.Buffer,Ar=[1518500249,1859775393,-1894007588,-899497514],Kr=new Array(80);function Lr(){this.init(),this._w=Kr,Mr.call(this,64,56)}function Ir(e){return e<<30|e>>>2}function Or(e,t,r,i){return 0===e?t&r|~t&i:2===e?t&r|t&i|r&i:t^r^i}Tr(Lr,Mr),Lr.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Lr.prototype._update=function(e){for(var t,r=this._w,i=0|this._a,n=0|this._b,o=0|this._c,s=0|this._d,a=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=r[h-3]^r[h-8]^r[h-14]^r[h-16];for(var u=0;u<80;++u){var c=~~(u/20),l=0|((t=i)<<5|t>>>27)+Or(c,n,o,s)+a+r[u]+Ar[c];a=s,s=o,o=Ir(n),n=i,i=l}this._a=i+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},Lr.prototype._hash=function(){var e=xr.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e};var Cr=Lr,Pr=E,Dr=Rr,Br=p.Buffer,Nr=[1518500249,1859775393,-1894007588,-899497514],jr=new Array(80);function Ur(){this.init(),this._w=jr,Dr.call(this,64,56)}function Vr(e){return e<<5|e>>>27}function qr(e){return e<<30|e>>>2}function Wr(e,t,r,i){return 0===e?t&r|~t&i:2===e?t&r|t&i|r&i:t^r^i}Pr(Ur,Dr),Ur.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Ur.prototype._update=function(e){for(var t,r=this._w,i=0|this._a,n=0|this._b,o=0|this._c,s=0|this._d,a=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=(t=r[h-3]^r[h-8]^r[h-14]^r[h-16])<<1|t>>>31;for(var u=0;u<80;++u){var c=~~(u/20),l=Vr(i)+Wr(c,n,o,s)+a+r[u]+Nr[c]|0;a=s,s=o,o=qr(n),n=i,i=l}this._a=i+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},Ur.prototype._hash=function(){var e=Br.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e};var Fr=Ur,zr=E,Hr=Rr,$r=p.Buffer,Zr=[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],Xr=new Array(64);function Gr(){this.init(),this._w=Xr,Hr.call(this,64,56)}function Jr(e,t,r){return r^e&(t^r)}function Yr(e,t,r){return e&t|r&(e|t)}function Qr(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function ei(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function ti(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}zr(Gr,Hr),Gr.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},Gr.prototype._update=function(e){for(var t,r=this._w,i=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)r[l]=e.readInt32BE(4*l);for(;l<64;++l)r[l]=0|(((t=r[l-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[l-7]+ti(r[l-15])+r[l-16];for(var f=0;f<64;++f){var d=c+ei(a)+Jr(a,h,u)+Zr[f]+r[f]|0,p=Qr(i)+Yr(i,n,o)|0;c=u,u=h,h=a,a=s+d|0,s=o,o=n,n=i,i=d+p|0}this._a=i+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},Gr.prototype._hash=function(){var e=$r.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var ri=Gr,ii=E,ni=ri,oi=Rr,si=p.Buffer,ai=new Array(64);function hi(){this.init(),this._w=ai,oi.call(this,64,56)}ii(hi,ni),hi.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},hi.prototype._hash=function(){var e=si.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var ui=hi,ci=E,li=Rr,fi=p.Buffer,di=[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],pi=new Array(160);function yi(){this.init(),this._w=pi,li.call(this,128,112)}function bi(e,t,r){return r^e&(t^r)}function _i(e,t,r){return e&t|r&(e|t)}function wi(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function gi(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function vi(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function mi(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function Ei(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function Si(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function ki(e,t){return e>>>0<t>>>0?1:0}ci(yi,li),yi.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},yi.prototype._update=function(e){for(var t=this._w,r=0|this._ah,i=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,y=0|this._fl,b=0|this._gl,_=0|this._hl,w=0;w<32;w+=2)t[w]=e.readInt32BE(4*w),t[w+1]=e.readInt32BE(4*w+4);for(;w<160;w+=2){var g=t[w-30],v=t[w-30+1],m=vi(g,v),E=mi(v,g),S=Ei(g=t[w-4],v=t[w-4+1]),k=Si(v,g),R=t[w-14],T=t[w-14+1],M=t[w-32],x=t[w-32+1],A=E+T|0,K=m+R+ki(A,E)|0;K=(K=K+S+ki(A=A+k|0,k)|0)+M+ki(A=A+x|0,x)|0,t[w]=K,t[w+1]=A}for(var L=0;L<160;L+=2){K=t[L],A=t[L+1];var I=_i(r,i,n),O=_i(c,l,f),C=wi(r,c),P=wi(c,r),D=gi(s,p),B=gi(p,s),N=di[L],j=di[L+1],U=bi(s,a,h),V=bi(p,y,b),q=_+B|0,W=u+D+ki(q,_)|0;W=(W=(W=W+U+ki(q=q+V|0,V)|0)+N+ki(q=q+j|0,j)|0)+K+ki(q=q+A|0,A)|0;var F=P+O|0,z=C+I+ki(F,P)|0;u=h,_=b,h=a,b=y,a=s,y=p,s=o+W+ki(p=d+q|0,d)|0,o=n,d=f,n=i,f=l,i=r,l=c,r=W+z+ki(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+y|0,this._gl=this._gl+b|0,this._hl=this._hl+_|0,this._ah=this._ah+r+ki(this._al,c)|0,this._bh=this._bh+i+ki(this._bl,l)|0,this._ch=this._ch+n+ki(this._cl,f)|0,this._dh=this._dh+o+ki(this._dl,d)|0,this._eh=this._eh+s+ki(this._el,p)|0,this._fh=this._fh+a+ki(this._fl,y)|0,this._gh=this._gh+h+ki(this._gl,b)|0,this._hh=this._hh+u+ki(this._hl,_)|0},yi.prototype._hash=function(){var e=fi.allocUnsafe(64);function t(t,r,i){e.writeInt32BE(t,i),e.writeInt32BE(r,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};var Ri=yi,Ti=E,Mi=Ri,xi=Rr,Ai=p.Buffer,Ki=new Array(160);function Li(){this.init(),this._w=Ki,xi.call(this,128,112)}Ti(Li,Mi),Li.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},Li.prototype._hash=function(){var e=Ai.allocUnsafe(48);function t(t,r,i){e.writeInt32BE(t,i),e.writeInt32BE(r,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};var Ii=Li,Oi=Er.exports=function(e){e=e.toLowerCase();var t=Oi[e];if(!t)throw new Error(e+" is not supported (we accept pull requests)");return new t};Oi.sha=Cr,Oi.sha1=Fr,Oi.sha224=ui,Oi.sha256=ri,Oi.sha384=Ii,Oi.sha512=Ri;var Ci=Er.exports,Pi=h(c),Di=p.Buffer,Bi=y.Transform,Ni=Pi.StringDecoder;function ji(e){Bi.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}E(ji,Bi),ji.prototype.update=function(e,t,r){"string"==typeof e&&(e=Di.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},ji.prototype.setAutoPadding=function(){},ji.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},ji.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},ji.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},ji.prototype._transform=function(e,t,r){var i;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){i=e}finally{r(i)}},ji.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},ji.prototype._finalOrDigest=function(e){var t=this.__final()||Di.alloc(0);return e&&(t=this._toString(t,e,!0)),t},ji.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new Ni(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var i=this._decoder.write(e);return r&&(i+=this._decoder.end()),i};var Ui=ir,Vi=mr,qi=Ci,Wi=ji;function Fi(e){Wi.call(this,"digest"),this._hash=e}E(Fi,Wi),Fi.prototype._update=function(e){this._hash.update(e)},Fi.prototype._final=function(){return this._hash.digest()};var zi=l((function(e){return"md5"===(e=e.toLowerCase())?new Ui:"rmd160"===e||"ripemd160"===e?new Vi:new Fi(qi(e))}));const Hi=new(0,S.ec)("secp256k1"),$i=Hi.curve,Zi=$i.n.constructor;function Xi(e){const t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){let r=new Zi(t);if(r.cmp($i.p)>=0)return null;r=r.toRed($i.red);let i=r.redSqr().redIMul(r).redIAdd($i.b).redSqrt();return 3===e!==i.isOdd()&&(i=i.redNeg()),Hi.keyPair({pub:{x:r,y:i}})}(t,e.subarray(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){let i=new Zi(t),n=new Zi(r);if(i.cmp($i.p)>=0||n.cmp($i.p)>=0)return null;if(i=i.toRed($i.red),n=n.toRed($i.red),(6===e||7===e)&&n.isOdd()!==(7===e))return null;const o=i.redSqr().redIMul(i);return n.redSqr().redISub(o.redIAdd($i.b)).isZero()?Hi.keyPair({pub:{x:i,y:n}}):null}(t,e.subarray(1,33),e.subarray(33,65));default:return null}}function Gi(e,t){const r=t.encode(null,33===e.length);for(let t=0;t<e.length;++t)e[t]=r[t]}var Ji={contextRandomize:()=>0,privateKeyVerify(e){const t=new Zi(e);return t.cmp($i.n)<0&&!t.isZero()?0:1},privateKeyNegate(e){const t=new Zi(e),r=$i.n.sub(t).umod($i.n).toArrayLike(Uint8Array,"be",32);return e.set(r),0},privateKeyTweakAdd(e,t){const r=new Zi(t);if(r.cmp($i.n)>=0)return 1;if(r.iadd(new Zi(e)),r.cmp($i.n)>=0&&r.isub($i.n),r.isZero())return 1;const i=r.toArrayLike(Uint8Array,"be",32);return e.set(i),0},privateKeyTweakMul(e,t){let r=new Zi(t);if(r.cmp($i.n)>=0||r.isZero())return 1;r.imul(new Zi(e)),r.cmp($i.n)>=0&&(r=r.umod($i.n));const i=r.toArrayLike(Uint8Array,"be",32);return e.set(i),0},publicKeyVerify:e=>null===Xi(e)?1:0,publicKeyCreate(e,t){const r=new Zi(t);if(r.cmp($i.n)>=0||r.isZero())return 1;return Gi(e,Hi.keyFromPrivate(t).getPublic()),0},publicKeyConvert(e,t){const r=Xi(t);if(null===r)return 1;return Gi(e,r.getPublic()),0},publicKeyNegate(e,t){const r=Xi(t);if(null===r)return 1;const i=r.getPublic();return i.y=i.y.redNeg(),Gi(e,i),0},publicKeyCombine(e,t){const r=new Array(t.length);for(let e=0;e<t.length;++e)if(r[e]=Xi(t[e]),null===r[e])return 1;let i=r[0].getPublic();for(let e=1;e<r.length;++e)i=i.add(r[e].pub);return i.isInfinity()?2:(Gi(e,i),0)},publicKeyTweakAdd(e,t,r){const i=Xi(t);if(null===i)return 1;if((r=new Zi(r)).cmp($i.n)>=0)return 2;const n=i.getPublic().add($i.g.mul(r));return n.isInfinity()?2:(Gi(e,n),0)},publicKeyTweakMul(e,t,r){const i=Xi(t);if(null===i)return 1;if((r=new Zi(r)).cmp($i.n)>=0||r.isZero())return 2;return Gi(e,i.getPublic().mul(r)),0},signatureNormalize(e){const t=new Zi(e.subarray(0,32)),r=new Zi(e.subarray(32,64));return t.cmp($i.n)>=0||r.cmp($i.n)>=0?1:(1===r.cmp(Hi.nh)&&e.set($i.n.sub(r).toArrayLike(Uint8Array,"be",32),32),0)},signatureExport(e,t){const r=t.subarray(0,32),i=t.subarray(32,64);if(new Zi(r).cmp($i.n)>=0)return 1;if(new Zi(i).cmp($i.n)>=0)return 1;const{output:n}=e;let o=n.subarray(4,37);o[0]=0,o.set(r,1);let s=33,a=0;for(;s>1&&0===o[a]&&!(128&o[a+1]);--s,++a);if(o=o.subarray(a),128&o[0])return 1;if(s>1&&0===o[0]&&!(128&o[1]))return 1;let h=n.subarray(39,72);h[0]=0,h.set(i,1);let u=33,c=0;for(;u>1&&0===h[c]&&!(128&h[c+1]);--u,++c);return h=h.subarray(c),128&h[0]||u>1&&0===h[0]&&!(128&h[1])?1:(e.outputlen=6+s+u,n[0]=48,n[1]=e.outputlen-2,n[2]=2,n[3]=o.length,n.set(o,4),n[4+s]=2,n[5+s]=h.length,n.set(h,6+s),0)},signatureImport(e,t){if(t.length<8)return 1;if(t.length>72)return 1;if(48!==t[0])return 1;if(t[1]!==t.length-2)return 1;if(2!==t[2])return 1;const r=t[3];if(0===r)return 1;if(5+r>=t.length)return 1;if(2!==t[4+r])return 1;const i=t[5+r];if(0===i)return 1;if(6+r+i!==t.length)return 1;if(128&t[4])return 1;if(r>1&&0===t[4]&&!(128&t[5]))return 1;if(128&t[r+6])return 1;if(i>1&&0===t[r+6]&&!(128&t[r+7]))return 1;let n=t.subarray(4,4+r);if(33===n.length&&0===n[0]&&(n=n.subarray(1)),n.length>32)return 1;let o=t.subarray(6+r);if(33===o.length&&0===o[0]&&(o=o.slice(1)),o.length>32)throw new Error("S length is too long");let s=new Zi(n);s.cmp($i.n)>=0&&(s=new Zi(0));let a=new Zi(t.subarray(6+r));return a.cmp($i.n)>=0&&(a=new Zi(0)),e.set(s.toArrayLike(Uint8Array,"be",32),0),e.set(a.toArrayLike(Uint8Array,"be",32),32),0},ecdsaSign(e,t,r,i,n){if(n){const e=n;n=n=>{const o=e(t,r,null,i,n);if(!(o instanceof Uint8Array&&32===o.length))throw new Error("This is the way");return new Zi(o)}}const o=new Zi(r);if(o.cmp($i.n)>=0||o.isZero())return 1;let s;try{s=Hi.sign(t,r,{canonical:!0,k:n,pers:i})}catch(e){return 1}return e.signature.set(s.r.toArrayLike(Uint8Array,"be",32),0),e.signature.set(s.s.toArrayLike(Uint8Array,"be",32),32),e.recid=s.recoveryParam,0},ecdsaVerify(e,t,r){const i={r:e.subarray(0,32),s:e.subarray(32,64)},n=new Zi(i.r),o=new Zi(i.s);if(n.cmp($i.n)>=0||o.cmp($i.n)>=0)return 1;if(1===o.cmp(Hi.nh)||n.isZero()||o.isZero())return 3;const s=Xi(r);if(null===s)return 2;const a=s.getPublic();return Hi.verify(t,i,a)?0:3},ecdsaRecover(e,t,r,i){const n={r:t.slice(0,32),s:t.slice(32,64)},o=new Zi(n.r),s=new Zi(n.s);if(o.cmp($i.n)>=0||s.cmp($i.n)>=0)return 1;if(o.isZero()||s.isZero())return 2;let a;try{a=Hi.recoverPubKey(i,n,r)}catch(e){return 2}return Gi(e,a),0},ecdh(e,t,r,i,n,o,s){const a=Xi(t);if(null===a)return 1;const h=new Zi(r);if(h.cmp($i.n)>=0||h.isZero())return 2;const u=a.getPublic().mul(h);if(void 0===n){const t=u.encode(null,!0),r=Hi.hash().update(t).digest();for(let t=0;t<32;++t)e[t]=r[t]}else{o||(o=new Uint8Array(32));const t=u.getX().toArray("be",32);for(let e=0;e<32;++e)o[e]=t[e];s||(s=new Uint8Array(32));const r=u.getY().toArray("be",32);for(let e=0;e<32;++e)s[e]=r[e];const a=n(o,s,i);if(!(a instanceof Uint8Array&&a.length===e.length))return 2;e.set(a)}return 0}};const Yi="Impossible case. Please create issue.",Qi="The tweak was out of range or the resulted private key is invalid",en="The tweak was out of range or equal to zero",tn="Unknow error on context randomization",rn="Private Key is invalid",nn="Public Key could not be parsed",on="Public Key serialization error",sn="The sum of the public keys is not valid",an="Signature could not be parsed",hn="The nonce generation function failed, or the private key was invalid",un="Public key could not be recover",cn="Scalar was invalid (zero or overflow)";function ln(e,t){if(!e)throw new Error(t)}function fn(e,t,r){if(ln(t instanceof Uint8Array,`Expected ${e} to be an Uint8Array`),void 0!==r)if(Array.isArray(r)){const i=`Expected ${e} to be an Uint8Array with length [${r.join(", ")}]`;ln(r.includes(t.length),i)}else{const i=`Expected ${e} to be an Uint8Array with length ${r}`;ln(t.length===r,i)}}function dn(e){ln("Boolean"===yn(e),"Expected compressed to be a Boolean")}function pn(e=(e=>new Uint8Array(e)),t){return"function"==typeof e&&(e=e(t)),fn("output",e,t),e}function yn(e){return Object.prototype.toString.call(e).slice(8,-1)}var bn=(e=>({contextRandomize(t){if(ln(null===t||t instanceof Uint8Array,"Expected seed to be an Uint8Array or null"),null!==t&&fn("seed",t,32),1===e.contextRandomize(t))throw new Error(tn)},privateKeyVerify:t=>(fn("private key",t,32),0===e.privateKeyVerify(t)),privateKeyNegate(t){switch(fn("private key",t,32),e.privateKeyNegate(t)){case 0:return t;case 1:throw new Error(Yi)}},privateKeyTweakAdd(t,r){switch(fn("private key",t,32),fn("tweak",r,32),e.privateKeyTweakAdd(t,r)){case 0:return t;case 1:throw new Error(Qi)}},privateKeyTweakMul(t,r){switch(fn("private key",t,32),fn("tweak",r,32),e.privateKeyTweakMul(t,r)){case 0:return t;case 1:throw new Error(en)}},publicKeyVerify:t=>(fn("public key",t,[33,65]),0===e.publicKeyVerify(t)),publicKeyCreate(t,r=!0,i){switch(fn("private key",t,32),dn(r),i=pn(i,r?33:65),e.publicKeyCreate(i,t)){case 0:return i;case 1:throw new Error(rn);case 2:throw new Error(on)}},publicKeyConvert(t,r=!0,i){switch(fn("public key",t,[33,65]),dn(r),i=pn(i,r?33:65),e.publicKeyConvert(i,t)){case 0:return i;case 1:throw new Error(nn);case 2:throw new Error(on)}},publicKeyNegate(t,r=!0,i){switch(fn("public key",t,[33,65]),dn(r),i=pn(i,r?33:65),e.publicKeyNegate(i,t)){case 0:return i;case 1:throw new Error(nn);case 2:throw new Error(Yi);case 3:throw new Error(on)}},publicKeyCombine(t,r=!0,i){ln(Array.isArray(t),"Expected public keys to be an Array"),ln(t.length>0,"Expected public keys array will have more than zero items");for(const e of t)fn("public key",e,[33,65]);switch(dn(r),i=pn(i,r?33:65),e.publicKeyCombine(i,t)){case 0:return i;case 1:throw new Error(nn);case 2:throw new Error(sn);case 3:throw new Error(on)}},publicKeyTweakAdd(t,r,i=!0,n){switch(fn("public key",t,[33,65]),fn("tweak",r,32),dn(i),n=pn(n,i?33:65),e.publicKeyTweakAdd(n,t,r)){case 0:return n;case 1:throw new Error(nn);case 2:throw new Error(Qi)}},publicKeyTweakMul(t,r,i=!0,n){switch(fn("public key",t,[33,65]),fn("tweak",r,32),dn(i),n=pn(n,i?33:65),e.publicKeyTweakMul(n,t,r)){case 0:return n;case 1:throw new Error(nn);case 2:throw new Error(en)}},signatureNormalize(t){switch(fn("signature",t,64),e.signatureNormalize(t)){case 0:return t;case 1:throw new Error(an)}},signatureExport(t,r){fn("signature",t,64);const i={output:r=pn(r,72),outputlen:72};switch(e.signatureExport(i,t)){case 0:return r.slice(0,i.outputlen);case 1:throw new Error(an);case 2:throw new Error(Yi)}},signatureImport(t,r){switch(fn("signature",t),r=pn(r,64),e.signatureImport(r,t)){case 0:return r;case 1:throw new Error(an);case 2:throw new Error(Yi)}},ecdsaSign(t,r,i={},n){fn("message",t,32),fn("private key",r,32),ln("Object"===yn(i),"Expected options to be an Object"),void 0!==i.data&&fn("options.data",i.data),void 0!==i.noncefn&&ln("Function"===yn(i.noncefn),"Expected options.noncefn to be a Function");const o={signature:n=pn(n,64),recid:null};switch(e.ecdsaSign(o,t,r,i.data,i.noncefn)){case 0:return o;case 1:throw new Error(hn);case 2:throw new Error(Yi)}},ecdsaVerify(t,r,i){switch(fn("signature",t,64),fn("message",r,32),fn("public key",i,[33,65]),e.ecdsaVerify(t,r,i)){case 0:return!0;case 3:return!1;case 1:throw new Error(an);case 2:throw new Error(nn)}},ecdsaRecover(t,r,i,n=!0,o){switch(fn("signature",t,64),ln("Number"===yn(r)&&r>=0&&r<=3,"Expected recovery id to be a Number within interval [0, 3]"),fn("message",i,32),dn(n),o=pn(o,n?33:65),e.ecdsaRecover(o,t,r,i)){case 0:return o;case 1:throw new Error(an);case 2:throw new Error(un);case 3:throw new Error(Yi)}},ecdh(t,r,i={},n){switch(fn("public key",t,[33,65]),fn("private key",r,32),ln("Object"===yn(i),"Expected options to be an Object"),void 0!==i.data&&fn("options.data",i.data),void 0!==i.hashfn?(ln("Function"===yn(i.hashfn),"Expected options.hashfn to be a Function"),void 0!==i.xbuf&&fn("options.xbuf",i.xbuf,32),void 0!==i.ybuf&&fn("options.ybuf",i.ybuf,32),fn("output",n)):n=pn(n,32),e.ecdh(n,t,r,i.data,i.hashfn,i.xbuf,i.ybuf)){case 0:return n;case 1:throw new Error(nn);case 2:throw new Error(cn)}}}))(Ji),_n=l(bn),wn={exports:{}},gn=65536,vn=4294967295;var mn=p.Buffer,En=e.crypto||e.msCrypto;En&&En.getRandomValues?wn.exports=function(e,r){if(e>vn)throw new RangeError("requested too many random bytes");var i=mn.allocUnsafe(e);if(e>0)if(e>gn)for(var n=0;n<e;n+=gn)En.getRandomValues(i.slice(n,n+gn));else En.getRandomValues(i);if("function"==typeof r)return t((function(){r(null,i)}));return i}:wn.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")};var Sn=l(wn.exports);var kn={CryptoLD:class{constructor({suites:e}={}){this.suites=e||new Map}use(e){this.suites.set(e.suite,e)}async generate(e={}){return this._suiteForType(e).generate(e)}async from(e={}){const t=this._suiteForType(e);return e["@context"]?t.fromKeyDocument({document:e}):t.from(e)}async fromKeyDocument({document:e,checkContext:t=!0,checkRevoked:r=!0}={}){if(!e)throw new TypeError('The "document" parameter is required.');return this._suiteForType(e).fromKeyDocument({document:e,checkContext:t,checkRevoked:r})}async fromKeyId({id:e,documentLoader:t,checkContext:r=!0,checkRevoked:i=!0}={}){if(!e)throw new TypeError('The "id" parameter is required.');if(!t)throw new TypeError('The "documentLoader" parameter is required.');let n;try{if(({document:n}=await t(e)),!n)throw new Error('The "documentLoader" function must return a "document" object.')}catch(e){const t=new Error("Error fetching document: "+e.message);throw t.cause=e,t}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:r,checkRevoked:i})}_installed({type:e}){return this.suites.has(e)}_suiteForType(e){const t=e&&e.type;if(!t)throw new TypeError("Missing key type.");if(!this._installed({type:t}))throw new Error(`Support for key type "${t}" is not installed.`);return this.suites.get(t)}}};
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) 2018-2021 Digital Bazaar, Inc. All rights reserved.
|
|
4
|
+
*/let Rn=class{constructor({id:e,controller:t,revoked:r}={}){this.id=e,this.controller=t,this.revoked=r}static async generate(){throw new Error("Abstract method, must be implemented in subclass.")}static async fromKeyDocument({document:e,checkContext:t=!0,checkRevoked:r=!0}={}){if(!e)throw new TypeError('The "document" parameter is required.');if(t){if(![].concat(e["@context"]).includes(this.SUITE_CONTEXT))throw new Error('Key document does not contain required context "'+this.SUITE_CONTEXT+'".')}if(r&&e.revoked)throw new Error(`Key has been revoked since: "${e.revoked}".`);return this.from(e)}static async from(){throw new Error("Abstract method from() must be implemented in subclass.")}export({publicKey:e=!1,privateKey:t=!1}={}){if(!e&&!t)throw new Error('Export requires specifying either "publicKey" or "privateKey".');const r={id:this.id,type:this.type,controller:this.controller};return this.revoked&&(r.revoked=this.revoked),r}fingerprint(){throw new Error("Abstract method, must be implemented in subclass.")}verifyFingerprint(){throw new Error("Abstract method, must be implemented in subclass.")}signer(){return{async sign({}){throw new Error("Abstract method, must be implemented in subclass.")}}}verifier(){return{async verify({}){throw new Error("Abstract method, must be implemented in subclass.")}}}};Rn.SUITE_CONTEXT="INVALID LDKeyPair CONTEXT";var Tn={LDKeyPair:Rn};const{CryptoLD:Mn}=kn,{LDKeyPair:xn}=Tn;var An=l({CryptoLD:Mn,LDKeyPair:xn});const Kn="EcdsaSecp256k1VerificationKey2019",Ln=e=>zi("sha256").update(e).digest();class In extends An.LDKeyPair{constructor({publicKeyBase58:e,privateKeyBase58:t,...r}){if(super(r),this.type=void 0,this.publicKeyBase58=void 0,this.privateKeyBase58=void 0,t&&!e){const e=bn.publicKeyCreate(k(t));this.publicKeyBase58=R(e)}else this.publicKeyBase58=e;if(this.type=Kn,this.privateKeyBase58=t,!this.publicKeyBase58)throw new TypeError('The "publicKeyBase58" property is required.')}static from(e){if(e.publicKeyHex||e.privateKeyHex){const{publicKeyHex:t,privateKeyHex:r,...n}=e;return new In({...n,publicKeyBase58:t?R(i.from(t,"hex")):void 0,privateKeyBase58:r?R(i.from(r,"hex")):void 0})}return new In(e)}static async generate({seed:e,compressed:t,...r}){if(e&&!bn.privateKeyVerify(e))throw new Error("Provided seed is not a valid private key");let i=e;for(;void 0===i||!bn.privateKeyVerify(i);)i=new Uint8Array(Sn(32));const n=bn.publicKeyCreate(i,t);return new In({publicKeyBase58:R(n),privateKeyBase58:R(i),...r})}export({publicKey:e=!1,privateKey:t=!1,includeContext:r=!1}={}){if(!e&&!t)throw new TypeError('export requires specifying either "publicKey" or "privateKey".');if(t&&!this.privateKeyBase58)throw new TypeError("No privateKey to export.");if(e&&!this.publicKeyBase58)throw new TypeError("No publicKey to export.");const i={type:this.type,id:this.id,controller:this.controller,revoked:this.revoked};return r&&(i["@context"]=In.SUITE_CONTEXT),t&&(i.privateKeyBase58=this.privateKeyBase58),e&&(i.publicKeyBase58=this.publicKeyBase58),i}signer(){const{privateKeyBase58:e}=this;return e?{async sign({data:t}){const r=b.encode(JSON.stringify({alg:"ES256K",b64:!1,crit:["b64"]})),n=i.from(t.buffer,t.byteOffset,t.length),o=Ln(i.from(i.concat([i.from(`${r}.`,"utf8"),i.from(n.buffer,n.byteOffset,n.length)]))),{signature:s}=bn.ecdsaSign(o,k(e));return`${r}..${b.encode(i.from(s))}`},id:this.id}:{async sign(){throw new Error("No private key to sign with.")},id:this.id}}verifier(){const{publicKeyBase58:e}=this;return e?{async verify({data:t,signature:r}){if(r.indexOf("..")<0)return!1;const[n,o]=r.split(".."),s=JSON.parse(b.decode(n));if("ES256K"!==s.alg||!1!==s.b64||!s.crit||!s.crit.length||"b64"!==s.crit[0])return!1;const a=i.from(t.buffer,t.byteOffset,t.length),h=Ln(i.from(i.concat([i.from(`${n}.`,"utf8"),i.from(a.buffer,a.byteOffset,a.length)])));let u;try{u=bn.ecdsaVerify(i.from(b.decode(o,"hex"),"hex"),h,k(e))}catch(e){u=!1}return u},id:this.id}:{async verify(){throw new Error("No public key to verify against")},id:this.id}}}In.suite=Kn,In.SUITE_CONTEXT="https://ns.did.ai/suites/secp256k1-2019/v1";const On="https://ns.did.ai/suites/secp256k1-2019/v1",Cn=({document:e,contextUrl:t})=>{const r=e["@context"];return r===t||Array.isArray(r)&&r.includes(t)},Pn=({document:e})=>{const t=Cn({document:e,contextUrl:On}),r=Cn({document:e,contextUrl:"https://www.w3.org/2018/credentials/v1"}),i=Cn({document:e,contextUrl:"https://w3id.org/security/v2"});return t&&r?(console.warn("Warning: The secp256k1-2019/v1 and credentials/v1 contexts are incompatible."),console.warn("For VCs using EcdsaSecp256k1Signature2019 suite, using the credentials/v1 context is sufficient."),!1):t&&i?(console.warn("Warning: The secp256k1-2019/v1 and security/v2 contexts are incompatible."),console.warn("For VCs using EcdsaSecp256k1Signature2019 suite, using the security/v2 context is sufficient."),!1):t||r||i};let Dn=class extends f.suites.LinkedDataSignature{constructor(e={}){super({type:"EcdsaSecp256k1Signature2019",LDKeyClass:In,contextUrl:On,...e}),this.requiredKeyType=void 0,this.requiredKeyType="EcdsaSecp256k1VerificationKey2019"}async sign({verifyData:e,proof:t}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");return{...t,jws:await this.signer.sign({data:e})}}async verifySignature({verifyData:e,verificationMethod:t,proof:r}){const{jws:i}=r;if(!i||"string"!=typeof i)throw new TypeError('The proof does not include a valid "jws" property.');let{verifier:n}=this;if(!n){n=(await this.LDKeyClass.from(t)).verifier()}return n.verify({data:e,signature:i})}async assertVerificationMethod({verificationMethod:e}){if(!Pn({document:e}))throw new TypeError(`The verification method (key) must contain "${this.contextUrl}".`);if(!d.hasValue(e,"type",this.requiredKeyType))throw new Error(`Invalid key type. Key type must be "${this.requiredKeyType}".`);if(void 0!==e.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:e,documentLoader:t}){if(this.key)return this.key.export({publicKey:!0});const r="object"==typeof e.verificationMethod?e.verificationMethod.id:e.verificationMethod;if(!r)throw new Error('No "verificationMethod" found in proof.');const i=await d.frame(r,{"@context":this.contextUrl,"@embed":"@always",id:r},{documentLoader:t,compactToRelative:!1});if(!i)throw new Error(`Verification method ${r} not found.`);if(void 0!==i.revoked)throw new Error("The verification method has been revoked.");return await this.assertVerificationMethod({verificationMethod:i}),i}async matchProof({proof:e,document:t,purpose:r,documentLoader:i,expansionMap:n}){if(!Pn({document:t}))return!1;if(!await super.matchProof({proof:e,document:t,purpose:r,documentLoader:i,expansionMap:n}))return!1;if(!this.key)return!0;const{verificationMethod:o}=e,s="object"==typeof o?o.id:o;return this.isVerificationMethodMatchingKeyId(s)}ensureSuiteContext({document:e,addSuiteContext:t}){Pn({document:e})||super.ensureSuiteContext({document:e,addSuiteContext:t})}isVerificationMethodMatchingKeyId(e){return e===this.key.id||e===`${this.key.controller}${this.key.id}`}};Dn.CONTEXT_URL=On,Dn.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 Bn="undefined"==typeof Buffer?i:Buffer,{purposes:{AssertionProofPurpose:Nn}}=f;var jn;!function(e){e.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",e.checkDocumentSignature="checkDocumentSignature"}(jn||(jn={}));class Un extends T{verificationProcess=[jn.retrieveVerificationMethodPublicKey,jn.checkDocumentSignature];documentToVerify;issuer;proof;type="EcdsaSecp256k1Signature2019";verificationKey;publicKey;constructor(e){super(e),e.executeStep&&(this.executeStep=e.executeStep),this.documentToVerify=e.document,this.issuer=e.issuer,this.proof=e.proof,this.validateProofType()}async init(){}async verifyProof(){for(const e of this.verificationProcess){if(!this[e])return void console.error("verification logic for",e,"not implemented");await this[e]()}}async verifyIdentity(){}getProofVerificationSteps(e){return this.verificationProcess.map((t=>n.verifier.convertToVerificationSubsteps(e,t)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(e){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(e,t,r){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}validateProofType(){const e=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(e!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${e}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){o[this.documentToVerify.issuer]=this.getTargetVerificationMethodContainer();return function(e){return e in o?{contextUrl:null,document:o[e],documentUrl:e}:d.documentLoader(e)}}retrieveInitialDocument(){const e=s(this.documentToVerify);if(Array.isArray(e.proof)){const t=e.proof.find((e=>e.type===this.type));delete e.proof,e.proof=t}return e}getTargetVerificationMethodContainer(){return this.issuer.didDocument??this.issuer}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(jn.retrieveVerificationMethodPublicKey,(async()=>{const e=_(this.getTargetVerificationMethodContainer(),this.proof.verificationMethod);if(e.publicKeyJwk&&!e.publicKeyBase58){const r=(e=>{const t=g.from({...e,crv:"K-256"},"jwk").toString("blk","public"),r=_n.publicKeyConvert(Bn.from(t,"hex"),!0);return Bn.from(r).toString("hex")})(e.publicKeyJwk);e.publicKeyBase58=(t=r,v.encode(Bn.from(t,"hex")))}var t;this.publicKey=e.publicKeyBase58;const r=In.from({...e});if(!r)throw new a(jn.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(r.revoked)throw new a(jn.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return r}),this.type)}async checkDocumentSignature(){await this.executeStep(jn.checkDocumentSignature,(async()=>{const e=new Dn({key:this.verificationKey});e.date=new Date(Date.now()).toISOString();const t=await f.verify(this.retrieveInitialDocument(),{suite:e,purpose:new Nn,documentLoader:this.generateDocumentLoader()});if(!t.verified)throw console.error(JSON.stringify(t,null,2)),new a(jn.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed`);console.log("Credential Secp256k1 signature successfully verified")}),this.type)}}export{Un as default};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import{h as t,o as e,n as r,l as n,y as i,c as o,i as a}from"./main.js";import{j as c}from"./jsonld-signatures-ooFWZVS--VI8BZQOv.js";import{j as s}from"./jsonld-CXlzLf4P-Wh4x173W.js";import{d as u,e as f}from"./index-CZOUZnn4-Lnb5-WZi.js";import{d as p,e as l}from"./base64url-qi3FT6uz-yv4mTXpu.js";import{_ as y}from"./tslib.es6-M1zqH4el-x9kNW1T_.js";import{x as h,e as d}from"./x25519-NtRELWAG-TIgip27e.js";import{S as w}from"./Suite-Bhitn5l3-e2QgHGhx.js";import"./_commonjs-dynamic-modules-F7P8sER7-fkA6S-_a.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"),S=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),L=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");class P{constructor(t,e,r,n){this.x=t,this.y=e,this.z=r,this.t=n}static fromAffine(t){if(!(t instanceof R))throw new TypeError("ExtendedPoint#fromAffine: expected Point");return t.equals(R.ZERO)?P.ZERO:new P(t.x,t.y,m,Z(t.x*t.y))}static toAffineBatch(t){const e=function(t,e=K.P){const r=new Array(t.length),n=H(t.reduce(((t,n,i)=>n===g?t:(r[i]=t,Z(t*n,e))),m),e);return t.reduceRight(((t,n,i)=>n===g?t:(r[i]=Z(t*r[i],e),Z(t*n,e))),n),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return this.toAffineBatch(t).map(this.fromAffine)}equals(t){_(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:a}=t,c=Z(e*a),s=Z(i*n),u=Z(r*a),f=Z(o*n);return c===s&&u===f}negate(){return new P(Z(-this.x),this.y,this.z,Z(-this.t))}double(){const{x:t,y:e,z:r}=this,{a:n}=K,i=Z(t*t),o=Z(e*e),a=Z(b*Z(r*r)),c=Z(n*i),s=t+e,u=Z(Z(s*s)-i-o),f=c+o,p=f-a,l=c-o,y=Z(u*p),h=Z(f*l),d=Z(u*l),w=Z(p*f);return new P(y,h,w,d)}add(t){_(t);const{x:e,y:r,z:n,t:i}=this,{x:o,y:a,z:c,t:s}=t,u=Z((r-e)*(a+o)),f=Z((r+e)*(a-o)),p=Z(f-u);if(p===g)return this.double();const l=Z(n*b*s),y=Z(i*b*c),h=y+l,d=f+u,w=y-l,v=Z(h*p),m=Z(d*w),x=Z(h*w),E=Z(p*d);return new P(v,m,E,x)}subtract(t){return this.add(t.negate())}precomputeWindow(t){const e=1+256/t,r=[];let n=this,i=n;for(let o=0;o<e;o++){i=n,r.push(i);for(let e=1;e<2**(t-1);e++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(t,e){!e&&this.equals(P.BASE)&&(e=R.BASE);const r=e&&e._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=e&&I.get(e);n||(n=this.precomputeWindow(r),e&&1!==r&&(n=P.normalizeZ(n),I.set(e,n)));let i=P.ZERO,o=P.BASE;const a=1+256/r,c=2**(r-1),s=BigInt(2**r-1),u=2**r,f=BigInt(r);for(let e=0;e<a;e++){const r=e*c;let a=Number(t&s);t>>=f,a>c&&(a-=u,t+=m);const p=r,l=r+Math.abs(a)-1,y=e%2!=0,h=a<0;0===a?o=o.add(B(y,n[p])):i=i.add(B(h,n[l]))}return P.normalizeZ([i,o])[0]}multiply(t,e){return this.wNAF(rt(t,K.l),e)}multiplyUnsafe(t){let e=rt(t,K.l,!1);const r=P.BASE,n=P.ZERO;if(e===g)return n;if(this.equals(n)||e===m)return this;if(this.equals(r))return this.wNAF(e);let i=n,o=this;for(;e>g;)e&m&&(i=i.add(o)),o=o.double(),e>>=m;return i}isSmallOrder(){return this.multiplyUnsafe(K.h).equals(P.ZERO)}isTorsionFree(){let t=this.multiplyUnsafe(K.l/b).double();return K.l%b&&(t=t.add(this)),t.equals(P.ZERO)}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(P.ZERO);null==t&&(t=i?x:H(n));const o=Z(e*t),a=Z(r*t),c=Z(n*t);if(i)return R.ZERO;if(c!==m)throw new Error("invZ was invalid");return new R(o,a)}fromRistrettoBytes(){U()}toRistrettoBytes(){U()}fromRistrettoHash(){U()}}function B(t,e){const r=e.negate();return t?r:e}function _(t){if(!(t instanceof P))throw new TypeError("ExtendedPoint expected")}function M(t){if(!(t instanceof N))throw new TypeError("RistrettoPoint expected")}function U(){throw new Error("Legacy method: switch to RistrettoPoint")}P.BASE=new P(K.Gx,K.Gy,m,Z(K.Gx*K.Gy)),P.ZERO=new P(g,m,m,g);class N{constructor(t){this.ep=t}static calcElligatorRistrettoMap(t){const{d:e}=K,r=Z(A*t*t),n=Z((r+m)*S);let i=BigInt(-1);const o=Z((i-e*r)*Z(r+e));let{isValid:a,value:c}=Y(n,o),s=Z(c*t);F(s)||(s=Z(-s)),a||(c=s),a||(i=r);const u=Z(i*(r-m)*L-o),f=c*c,p=Z((c+c)*o),l=Z(u*k),y=Z(m-f),h=Z(m+f);return new P(Z(p*h),Z(y*l),Z(l*h),Z(p*y))}static hashToCurve(t){const e=q((t=et(t,64)).slice(0,32)),r=this.calcElligatorRistrettoMap(e),n=q(t.slice(32,64)),i=this.calcElligatorRistrettoMap(n);return new N(r.add(i))}static fromHex(t){t=et(t,32);const{a:e,d:r}=K,n="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",i=q(t);if(!function(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}(z(i),t)||F(i))throw new Error(n);const o=Z(i*i),a=Z(m+e*o),c=Z(m-e*o),s=Z(a*a),u=Z(c*c),f=Z(e*r*s-u),{isValid:p,value:l}=Q(Z(f*u)),y=Z(l*c),h=Z(l*y*f);let d=Z((i+i)*y);F(d)&&(d=Z(-d));const w=Z(a*h),v=Z(d*w);if(!p||F(v)||w===g)throw new Error(n);return new N(new P(d,w,m,v))}toRawBytes(){let{x:t,y:e,z:r,t:n}=this.ep;const i=Z(Z(r+e)*Z(r-e)),o=Z(t*e),a=Z(o*o),{value:c}=Q(Z(i*a)),s=Z(c*i),u=Z(c*o),f=Z(s*u*n);let p;if(F(n*f)){let r=Z(e*A),n=Z(t*A);t=r,e=n,p=Z(s*O)}else p=u;F(t*f)&&(e=Z(-e));let l=Z((r-e)*p);return F(l)&&(l=Z(-l)),z(l)}toHex(){return X(this.toRawBytes())}toString(){return this.toHex()}equals(t){M(t);const e=this.ep,r=t.ep,n=Z(e.x*r.y)===Z(e.y*r.x),i=Z(e.y*r.y)===Z(e.x*r.x);return n||i}add(t){return M(t),new N(this.ep.add(t.ep))}subtract(t){return M(t),new N(this.ep.subtract(t.ep))}multiply(t){return new N(this.ep.multiply(t))}multiplyUnsafe(t){return new N(this.ep.multiplyUnsafe(t))}}N.BASE=new N(P.BASE),N.ZERO=new N(P.ZERO);const I=new WeakMap;class R{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,I.delete(this)}static fromHex(t,e=!0){const{d:r,P:n}=K,i=(t=et(t,32)).slice();i[31]=-129&t[31];const o=W(i);if(e&&o>=n)throw new Error("Expected 0 < hex < P");if(!e&&o>=T)throw new Error("Expected 0 < hex < 2**256");const a=Z(o*o),c=Z(a-m),s=Z(r*a+m);let{isValid:u,value:f}=Y(c,s);if(!u)throw new Error("Point.fromHex: invalid y coordinate");const p=(f&m)===m;return 0!=(128&t[31])!==p&&(f=Z(-f)),new R(f,o)}static async fromPrivateKey(t){return(await it(t)).point}toRawBytes(){const t=z(this.y);return t[31]|=this.x&m?128:0,t}toHex(){return X(this.toRawBytes())}toX25519(){const{y:t}=this;return z(Z((m+t)*H(m-t)))}isTorsionFree(){return P.fromAffine(this).isTorsionFree()}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new R(Z(-this.x),this.y)}add(t){return P.fromAffine(this).add(P.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return P.fromAffine(this).multiply(t,this).toAffine()}}R.BASE=new R(K.Gx,K.Gy),R.ZERO=new R(g,m);class j{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromHex(t){const e=et(t,64),r=R.fromHex(e.slice(0,32),!1),n=W(e.slice(32,64));return new j(r,n)}assertValidity(){const{r:t,s:e}=this;if(!(t instanceof R))throw new Error("Expected Point instance");return rt(e,K.l,!1),this}toRawBytes(){const t=new Uint8Array(64);return t.set(this.r.toRawBytes()),t.set(z(this.s),32),t}toHex(){return X(this.toRawBytes())}}function C(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Expected Uint8Array list");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}const V=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function X(t){if(!(t instanceof Uint8Array))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=V[t[r]];return e}function D(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){const n=2*r,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[r]=o}return e}function J(t){return D(t.toString(16).padStart(64,"0"))}function z(t){return J(t).reverse()}function F(t){return(Z(t)&m)===m}function W(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");return BigInt("0x"+X(Uint8Array.from(t).reverse()))}const G=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function q(t){return Z(W(t)&G)}function Z(t,e=K.P){const r=t%e;return r>=g?r:e+r}function H(t,e=K.P){if(t===g||e<=g)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=Z(t,e),n=e,i=g,o=m;for(;r!==g;){const t=n%r,e=i-o*(n/r);n=r,r=t,i=o,o=e}if(n!==m)throw new Error("invert: does not exist");return Z(i,e)}function $(t,e){const{P:r}=K;let n=t;for(;e-- >g;)n*=n,n%=r;return n}function Y(t,e){const r=Z(e*e*e),n=function(t){const{P:e}=K,r=BigInt(5),n=BigInt(10),i=BigInt(20),o=BigInt(40),a=BigInt(80),c=t*t%e*t%e,s=$(c,b)*c%e,u=$(s,m)*t%e,f=$(u,r)*u%e,p=$(f,n)*f%e,l=$(p,i)*p%e,y=$(l,o)*l%e,h=$(y,a)*y%e,d=$(h,a)*y%e,w=$(d,n)*f%e;return{pow_p_5_8:$(w,b)*t%e,b2:c}}(t*Z(r*r*e)).pow_p_5_8;let i=Z(t*r*n);const o=Z(e*i*i),a=i,c=Z(i*A),s=o===t,u=o===Z(-t),f=o===Z(-t*A);return s&&(i=a),(u||f)&&(i=c),F(i)&&(i=Z(-i)),{isValid:s||u,value:i}}function Q(t){return Y(m,t)}function tt(t){return Z(W(t),K.l)}function et(t,e){const r=t instanceof Uint8Array?Uint8Array.from(t):D(t);if("number"==typeof e&&r.length!==e)throw new Error(`Expected ${e} bytes`);return r}function rt(t,e,r=!0){if(!e)throw new TypeError("Specify max value");if("number"==typeof t&&Number.isSafeInteger(t)&&(t=BigInt(t)),"bigint"==typeof t&&t<e)if(r){if(g<t)return t}else if(g<=t)return t;throw new TypeError("Expected valid scalar: 0 < scalar < max")}let nt;async function it(t){return function(t){const e=((r=t.slice(0,32))[0]&=248,r[31]&=127,r[31]|=64,r);var r;const n=t.slice(32,64),i=tt(e),o=R.BASE.multiply(i),a=o.toRawBytes();return{head:e,prefix:n,scalar:i,point:o,pointBytes:a}}(await ct.sha512(function(t){if(32!==(t="bigint"==typeof t||"number"==typeof t?J(rt(t,T)):et(t)).length)throw new Error("Expected 32 bytes");return t}(t)))}async function ot(t,e,r){const{r:n,SB:i,msg:o,pub:a}=function(t,e,r){e=et(e),r instanceof R||(r=R.fromHex(r,!1));const{r:n,s:i}=t instanceof j?t.assertValidity():j.fromHex(t);return{r:n,s:i,SB:P.BASE.multiplyUnsafe(i),pub:r,msg:e}}(t,e,r),c=await ct.sha512(n.toRawBytes(),a.toRawBytes(),o);return function(t,e,r,n){const i=tt(n),o=P.fromAffine(t).multiplyUnsafe(i);return P.fromAffine(e).add(o).subtract(r).multiplyUnsafe(K.h).equals(P.ZERO)}(a,n,i,c)}R.BASE._setWindowSize(8);const at={node:i,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},ct={bytesToHex:X,hexToBytes:D,concatBytes:C,getExtendedPublicKey:it,mod:Z,invert:H,TORSION_SUBGROUP:["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"],hashToPrivateScalar:t=>{if((t=et(t)).length<40||t.length>1024)throw new Error("Expected 40-1024 bytes of private key as per FIPS 186");return Z(W(t),K.l-m)+m},randomBytes:(t=32)=>{if(at.web)return at.web.getRandomValues(new Uint8Array(t));if(at.node){const{randomBytes:e}=at.node;return new Uint8Array(e(t).buffer)}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>ct.randomBytes(32),sha512:async(...t)=>{const e=C(...t);if(at.web){const t=await at.web.subtle.digest("SHA-512",e.buffer);return new Uint8Array(t)}if(at.node)return Uint8Array.from(at.node.createHash("sha512").update(e).digest());throw new Error("The environment doesn't have sha512 function")},precompute(t=8,e=R.BASE){const r=e.equals(R.BASE)?e:new R(e.x,e.y);return r._setWindowSize(t),r.multiply(b),r},sha512Sync:void 0};Object.defineProperties(ct,{sha512Sync:{configurable:!1,get:()=>nt,set(t){nt||(nt=t)}}});
|
|
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,u(t.publicKeyBase58)),r=new dt({id:t.id,controller:t.controller,publicKeyMultibase:e});return t.privateKeyBase58&&(r.privateKeyMultibase=vt(ht,u(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 u(this.publicKeyMultibase.substr(1)).slice(yt.length)}get _privateKeyBuffer(){if(!this.privateKeyMultibase)return;return u(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=u(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=u(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"+f(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 St=class extends At{constructor({key:t,signer:e,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}={}){super({type:"Ed25519Signature2020",LDKeyClass:dt,contextUrl:kt,key:t,signer:e,verifier:r,proof:n,date:i,useNativeCanonize:o,canonizeOptions:a}),this.requiredKeyType="Ed25519VerificationKey2020"}async sign({verifyData:t,proof:e}){if(!this.signer||"function"!=typeof this.signer.sign)throw new Error("A signer API has not been specified.");const r=await this.signer.sign({data:t});return e.proofValue="z"+f(r),e}async verifySignature({verifyData:t,verificationMethod:e,proof:r}){const{proofValue:n}=r;if(!n||"string"!=typeof n)throw new TypeError('The proof does not include a valid "proofValue" property.');if("z"!==n[0])throw new Error("Only base58btc multibase encoding is supported.");const i=u(n.substr(1));let{verifier:o}=this;if(!o){o=(await this.LDKeyClass.from(e)).verifier()}return o.verify({data:t,signature:i})}async assertVerificationMethod({verificationMethod:t}){let e;if("Ed25519VerificationKey2020"===t.type)e=kt;else{if("Ed25519VerificationKey2018"!==t.type)throw new Error(`Unsupported key type "${t.type}".`);e=Ot}if(!Lt({document:t,contextUrl:e}))throw new TypeError(`The verification method (key) must contain "${e}" context.`);if(void 0!==t.revoked)throw new Error("The verification method has been revoked.")}async getVerificationMethod({proof:t,documentLoader:e}){if(this.key)return this.key.export({publicKey:!0});let{verificationMethod:r}=t;if("object"==typeof r&&(r=r.id),!r)throw new Error('No "verificationMethod" found in proof.');const{document:n}=await e(r);return r="string"==typeof n?JSON.parse(n):n,await this.assertVerificationMethod({verificationMethod:r}),"Ed25519VerificationKey2018"===r.type&&(r=(await dt.fromEd25519VerificationKey2018({keyPair:r})).export({publicKey:!0,includeContext:!0})),r}async matchProof({proof:t,document:e,purpose:r,documentLoader:n}){if(!Lt({document:e,contextUrl:kt}))return!1;if(!await super.matchProof({proof:t,document:e,purpose:r,documentLoader:n}))return!1;if(!this.key)return!0;const{verificationMethod:i}=t;return"object"==typeof i?i.id===this.key.id:i===this.key.id}};function Lt({document:t,contextUrl:e}){const r=t["@context"];return r===e||Array.isArray(r)&&r.includes(e)}St.CONTEXT_URL=kt,St.CONTEXT=Et.contexts.get(kt);var Pt,Bt,_t={exports:{}},Mt={};_t.exports=(Pt||(Pt=1,Bt=Mt,Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.staticImplements=function(){return function(t){}}),Mt);var Ut,Nt=_t.exports,It={exports:{}},Rt={};It.exports=(Ut||(Ut=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.staticImplements=function(){return function(t){}}}(Rt)),Rt);var jt=It.exports;function Ct(t,e,r,n,i,o,a){try{var c=t[o](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function Vt(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Ct(o,n,i,a,c,"next",t)}function c(t){Ct(o,n,i,a,c,"throw",t)}a(void 0)}))}}function Xt(){return Xt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},Xt.apply(this,arguments)}var Dt=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=e&&e.prototype instanceof w?e:w,o=Object.create(i.prototype),a=new S(n||[]);return o._invoke=function(t,e,r){var n=p;return function(i,o){if(n===y)throw new Error("Generator is already running");if(n===h){if("throw"===i)throw o;return P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var c=A(a,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===p)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=y;var s=f(t,e,r);if("normal"===s.type){if(n=r.done?h:l,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=h,r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p="suspendedStart",l="suspendedYield",y="executing",h="completed",d={};function w(){}function v(){}function g(){}var m={};m[o]=function(){return this};var b=Object.getPrototypeOf,x=b&&b(b(L([])));x&&x!==r&&n.call(x,o)&&(m=x);var E=g.prototype=w.prototype=Object.create(m);function K(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,c){var s=f(t[i],t,o);if("throw"!==s.type){var u=s.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function A(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=f(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function L(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:P}}function P(){return{value:e,done:!0}}return v.prototype=E.constructor=g,g.constructor=v,v.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},K(T.prototype),T.prototype[a]=function(){return this},t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new T(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},K(E),s(E,c,"Generator"),E[o]=function(){return this},E.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return c.type="throw",c.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function Jt(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),c=i.charCodeAt(0);if(255!==e[c])throw new TypeError(i+" is ambiguous");e[c]=n}var s=t.length,u=t.charAt(0),f=Math.log(s)/Math.log(256),p=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return o.alloc(0);var r=0;if(" "!==t[r]){for(var n=0,i=0;t[r]===u;)n++,r++;for(var a=(t.length-r)*f+1>>>0,c=new Uint8Array(a);t[r];){var p=e[t.charCodeAt(r)];if(255===p)return;for(var l=0,y=a-1;(0!==p||l<i)&&-1!==y;y--,l++)p+=s*c[y]>>>0,c[y]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,r++}if(" "!==t[r]){for(var h=a-i;h!==a&&0===c[h];)h++;var d=o.allocUnsafe(n+(a-h));d.fill(0,0,n);for(var w=n;h!==a;)d[w++]=c[h++];return d}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=o.from(e)),!a(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,c=e.length;i!==c&&0===e[i];)i++,r++;for(var f=(c-i)*p+1>>>0,l=new Uint8Array(f);i!==c;){for(var y=e[i],h=0,d=f-1;(0!==y||h<n)&&-1!==d;d--,h++)y+=256*l[d]>>>0,l[d]=y%s>>>0,y=y/s>>>0;if(0!==y)throw new Error("Non-zero carry");n=h,i++}for(var w=f-n;w!==f&&0===l[w];)w++;for(var v=u.repeat(r);w<f;++w)v+=t.charAt(l[w]);return v},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}var zt,Ft=Jt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),Wt=function(t){return o.from(t||"").toString("base64")},Gt=function(t){return Wt(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},qt=function(t,e){void 0===e&&(e="base58btc");var r=new Uint8Array(2+t.length);if(r[0]=236,r[1]=1,r.set(t,2),"base58btc"===e)return"z"+Ft.encode(r);if("base64url"===e)return"u"+Gt(r);throw new Error("Unsupported encoding: "+e)},Zt=function(t){return Uint8Array.from(o.from(t.x,"base64"))},Ht={JsonWebKey2020:function(t){var e,r=Zt(t.publicKeyJwk),n=void 0;t.privateKeyJwk&&(n=(e=t.privateKeyJwk,{publicKey:Zt(e),privateKey:Uint8Array.from(o.from(e.d,"base64"))}).privateKey);return{publicKey:r,privateKey:n}},X25519KeyAgreementKey2019:function(t){var e=Ft.decode(t.publicKeyBase58),r=void 0;return t.privateKeyBase58&&(r=Uint8Array.from(Ft.decode(t.privateKeyBase58))),{publicKey:e,privateKey:r}}},$t={JsonWebKey2020:function(t,e,r,n){var i={kty:"OKP",crv:"X25519",x:Gt(r)},o={id:t,type:"JsonWebKey2020",controller:e,publicKeyJwk:i};return n&&(o.privateKeyJwk=Xt({},i,{d:Gt(n)})),o},X25519KeyAgreementKey2019:function(t,e,r,n){var i={id:t,type:"X25519KeyAgreementKey2019",controller:e,publicKeyBase58:Ft.encode(r)};return n&&(i.privateKeyBase58=Ft.encode(n)),i}},Yt=zt=function(){function t(t){this.type="JsonWebKey2020",this.id=t.id,this.type=t.type||"JsonWebKey2020",this.controller=t.controller,this.publicKey=t.publicKey,this.privateKey=t.privateKey}t.fingerprintFromPublicKey=function(){var t=Vt(Dt.mark((function t(e){var r,n;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,zt.from(e);case 2:return r=t.sent,n=r.publicKey,t.abrupt("return",qt(n));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.fromFingerprint=function(){var t=Vt(Dt.mark((function t(e){var r,n,i,o;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.fingerprint,236!==(n=Ft.decode(r.substring(1)))[0]||1!==n[1]){t.next=12;break}return t.next=5,zt.from({id:"",controller:"",type:"X25519KeyAgreementKey2019",publicKeyBase58:Ft.encode(n.slice(2))});case 5:return i=t.sent,t.next=8,i.fingerprint();case 8:return o=t.sent,i.id="did:key:"+o+"#"+o,i.controller="did:key:"+o,t.abrupt("return",i);case 12:throw new Error("Unsupported fingerprint type: "+r);case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var e=t.prototype;return e.fingerprint=function(){var t=Vt(Dt.mark((function t(){return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",qt(this.publicKey));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.export=function(){var t=Vt(Dt.mark((function t(e){return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===e&&(e={privateKey:!1,type:"JsonWebKey2020"}),!$t[e.type]){t.next=3;break}return t.abrupt("return",$t[e.type](this.id,this.controller,this.publicKey,e.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(e));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.deriveSecret=function(){var t=Vt(Dt.mark((function t(e){var r,n,i;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.publicKey,t.next=3,zt.from(r);case 3:if(n=t.sent,this.privateKey){t.next=6;break}throw new Error("No private key available for deriveSecret");case 6:return i=h.sharedKey(this.privateKey,n.publicKey,!0),t.abrupt("return",i);case 8:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),t}();function Qt(t,e,r,n,i,o,a){try{var c=t[o](a),s=c.value}catch(t){return void r(t)}c.done?e(s):Promise.resolve(s).then(n,i)}function te(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Qt(o,n,i,a,c,"next",t)}function c(t){Qt(o,n,i,a,c,"throw",t)}a(void 0)}))}}function ee(){return ee=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},ee.apply(this,arguments)}Yt.generate=function(){var t=Vt(Dt.mark((function t(e){var r,n,i,o,a;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.secureRandom,n=h.generateKeyPair({isAvailable:!0,randomBytes:r}),i=qt(n.publicKey),a=(o="did:key:"+i)+"#"+i,t.abrupt("return",new zt({id:a,type:"JsonWebKey2020",controller:o,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),Yt.from=function(){var t=Vt(Dt.mark((function t(e){var r,n,i;return Dt.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=Ht[e.type](e),n=r.publicKey,i=r.privateKey,t.abrupt("return",new zt({id:e.id,type:e.type,controller:e.controller,publicKey:n,privateKey:i}));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),Yt=zt=y([jt.staticImplements()],Yt);var re=function(t,e){return t(e={exports:{}},e.exports),e.exports}((function(t){var e=function(t){var e,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},o=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function s(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(t){s=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=e&&e.prototype instanceof w?e:w,o=Object.create(i.prototype),a=new S(n||[]);return o._invoke=function(t,e,r){var n=p;return function(i,o){if(n===y)throw new Error("Generator is already running");if(n===h){if("throw"===i)throw o;return P()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var c=A(a,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===p)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=y;var s=f(t,e,r);if("normal"===s.type){if(n=r.done?h:l,s.arg===d)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n=h,r.method="throw",r.arg=s.arg)}}}(t,r,a),o}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p="suspendedStart",l="suspendedYield",y="executing",h="completed",d={};function w(){}function v(){}function g(){}var m={};m[o]=function(){return this};var b=Object.getPrototypeOf,x=b&&b(b(L([])));x&&x!==r&&n.call(x,o)&&(m=x);var E=g.prototype=w.prototype=Object.create(m);function K(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,c){var s=f(t[i],t,o);if("throw"!==s.type){var u=s.arg,p=u.value;return p&&"object"==typeof p&&n.call(p,"__await")?e.resolve(p.__await).then((function(t){r("next",t,a,c)}),(function(t){r("throw",t,a,c)})):e.resolve(p).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,c)}))}c(s.arg)}var i;this._invoke=function(t,n){function o(){return new e((function(e,i){r(t,n,e,i)}))}return i=i?i.then(o,o):o()}}function A(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,A(t,r),"throw"===r.method))return d;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var i=f(n,t.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,d;var o=i.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,d):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,d)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function S(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function L(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,a=function r(){for(;++i<t.length;)if(n.call(t,i))return r.value=t[i],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:P}}function P(){return{value:e,done:!0}}return v.prototype=E.constructor=g,g.constructor=v,v.displayName=s(g,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s(t,c,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},K(T.prototype),T.prototype[a]=function(){return this},t.AsyncIterator=T,t.async=function(e,r,n,i,o){void 0===o&&(o=Promise);var a=new T(u(e,r,n,i),o);return t.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},K(E),s(E,c,"Generator"),E[o]=function(){return this},E.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=L,S.prototype={constructor:S,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(O),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function i(n,i){return c.type="throw",c.arg=t,r.next=n,i&&(r.method="next",r.arg=e),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],c=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var s=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(s&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,d):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),d},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:L(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),d}},t}(t.exports);try{regeneratorRuntime=e}catch(t){Function("r","regeneratorRuntime = r")(e)}}));function ne(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),c=i.charCodeAt(0);if(255!==e[c])throw new TypeError(i+" is ambiguous");e[c]=n}var s=t.length,u=t.charAt(0),f=Math.log(s)/Math.log(256),p=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return o.alloc(0);var r=0;if(" "!==t[r]){for(var n=0,i=0;t[r]===u;)n++,r++;for(var a=(t.length-r)*f+1>>>0,c=new Uint8Array(a);t[r];){var p=e[t.charCodeAt(r)];if(255===p)return;for(var l=0,y=a-1;(0!==p||l<i)&&-1!==y;y--,l++)p+=s*c[y]>>>0,c[y]=p%256>>>0,p=p/256>>>0;if(0!==p)throw new Error("Non-zero carry");i=l,r++}if(" "!==t[r]){for(var h=a-i;h!==a&&0===c[h];)h++;var d=o.allocUnsafe(n+(a-h));d.fill(0,0,n);for(var w=n;h!==a;)d[w++]=c[h++];return d}}}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=o.from(e)),!a(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,n=0,i=0,c=e.length;i!==c&&0===e[i];)i++,r++;for(var f=(c-i)*p+1>>>0,l=new Uint8Array(f);i!==c;){for(var y=e[i],h=0,d=f-1;(0!==y||h<n)&&-1!==d;d--,h++)y+=256*l[d]>>>0,l[d]=y%s>>>0,y=y/s>>>0;if(0!==y)throw new Error("Non-zero carry");n=h,i++}for(var w=f-n;w!==f&&0===l[w];)w++;for(var v=u.repeat(r);w<f;++w)v+=t.charAt(l[w]);return v},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}var ie,oe=ne("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),ae=function(t){return o.from(t||"").toString("base64")},ce=function(t){return ae(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},se=function(t,e){void 0===e&&(e="base58btc");var r=new Uint8Array(2+t.length);if(r[0]=237,r[1]=1,r.set(t,2),"base58btc"===e)return"z"+oe.encode(r);if("base64url"===e)return"u"+ce(r);throw new Error("Unsupported encoding: "+e)},ue=function(t){return Uint8Array.from(o.from(t.x,"base64"))},fe={JsonWebKey2020:function(t){var e,r=ue(t.publicKeyJwk),n=void 0;t.privateKeyJwk&&(n=(e=t.privateKeyJwk,{publicKey:ue(e),privateKey:Uint8Array.from(o.concat([o.from(e.d,"base64"),o.from(e.x,"base64")]))}).privateKey);return{publicKey:r,privateKey:n}},Ed25519VerificationKey2018:function(t){var e=oe.decode(t.publicKeyBase58),r=void 0;return t.privateKeyBase58&&(r=Uint8Array.from(oe.decode(t.privateKeyBase58))),{publicKey:e,privateKey:r}}},pe=function(t){if(!fe[t.type])throw new Error("Cannot import from unsupported type: "+JSON.stringify(t,null,2));return fe[t.type](t)},le={JsonWebKey2020:function(t,e,r,n){var i={kty:"OKP",crv:"Ed25519",x:ce(r)},o={id:t,type:"JsonWebKey2020",controller:e,publicKeyJwk:i};return n&&(o.privateKeyJwk=ee({},i,{d:ce(n.slice(0,n.length/2))})),o},Ed25519VerificationKey2018:function(t,e,r,n){var i={id:t,type:"Ed25519VerificationKey2018",controller:e,publicKeyBase58:oe.encode(r)};return n&&(i.privateKeyBase58=oe.encode(n)),i}},ye={EdDsa:{__proto__:null,signer:function(t){return{sign:function(e){return te(re.mark((function r(){var n;return re.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return n=e.data,r.abrupt("return",d.sign(t,n));case 2:case"end":return r.stop()}}),r)})))()}}},verifier:function(t){return{verify:function(e){return te(re.mark((function r(){var n,i,o;return re.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=e.data,i=e.signature,o=!1;try{o=d.verify(t,n,i)}catch(t){}return r.abrupt("return",o);case 4:case"end":return r.stop()}}),r)})))()}}}}},he=ie=function(){function t(t){this.type="JsonWebKey2020",this.id=t.id,this.type=t.type||"JsonWebKey2020",this.controller=t.controller,this.publicKey=t.publicKey,this.privateKey=t.privateKey}t.fingerprintFromPublicKey=function(){var t=te(re.mark((function t(e){var r,n;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,ie.from(e);case 2:return r=t.sent,n=r.publicKey,t.abrupt("return",se(n));case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.toX25519KeyPair=function(){var t=te(re.mark((function t(e){var r,n,i;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=d.convertPublicKeyToX25519(e.publicKey),n=void 0,e.privateKey&&(n=d.convertSecretKeyToX25519(e.privateKey)),i=new Yt({id:"",type:"X25519KeyAgreementKey2019",controller:e.controller,publicKey:r,privateKey:n}),t.t0=e.controller+"#",t.next=7,i.fingerprint();case 7:return t.t1=t.sent,i.id=t.t0+t.t1,t.abrupt("return",i);case 10:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),t.fromFingerprint=function(){var t=te(re.mark((function t(e){var r,n,i,o;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.fingerprint,237!==(n=oe.decode(r.substring(1)))[0]||1!==n[1]){t.next=12;break}return t.next=5,ie.from({id:"",controller:"",type:"Ed25519VerificationKey2018",publicKeyBase58:oe.encode(n.slice(2))});case 5:return i=t.sent,t.next=8,i.fingerprint();case 8:return o=t.sent,i.id="did:key:"+o+"#"+o,i.controller="did:key:"+o,t.abrupt("return",i);case 12:throw new Error("Unsupported fingerprint type: "+r);case 13:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}();var e=t.prototype;return e.fingerprint=function(){var t=te(re.mark((function t(){return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",se(this.publicKey));case 1:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),e.export=function(){var t=te(re.mark((function t(e){return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0===e&&(e={privateKey:!1,type:"JsonWebKey2020"}),!le[e.type]){t.next=3;break}return t.abrupt("return",le[e.type](this.id,this.controller,this.publicKey,e.privateKey?this.privateKey:void 0));case 3:throw new Error("Unsupported export options: "+JSON.stringify(e));case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),e.signer=function(t){if(void 0===t&&(t="EdDsa"),!this.privateKey)throw new Error("No private key to sign with.");if(ye[t])return ye[t].signer(this.privateKey);throw new Error("Unsupported suite type "+t)},e.verifier=function(t){if(void 0===t&&(t="EdDsa"),!this.publicKey)throw new Error("No public key to verify with.");if(ye[t])return ye[t].verifier(this.publicKey);throw new Error("Unsupported suite type "+t)},e.getDerivedKeyPairs=function(){var t=te(re.mark((function t(){return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.t0=this,t.next=3,ie.toX25519KeyPair(this);case 3:return t.t1=t.sent,t.abrupt("return",[t.t0,t.t1]);case 5:case"end":return t.stop()}}),t,this)})));return function(){return t.apply(this,arguments)}}(),t}();he.generate=function(){var t=te(re.mark((function t(e){var r,n,i,o,a;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.secureRandom,n=d.generateKeyPair({isAvailable:!0,randomBytes:r}),i=se(n.publicKey),a=(o="did:key:"+i)+"#"+i,t.abrupt("return",new ie({id:a,type:"JsonWebKey2020",controller:o,publicKey:n.publicKey,privateKey:n.secretKey}));case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),he.from=function(){var t=te(re.mark((function t(e){var r,n,i;return re.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=pe(e),n=r.publicKey,i=r.privateKey,t.abrupt("return",new ie({id:e.id,type:e.type,controller:e.controller,publicKey:n,privateKey:i}));case 2:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),he=ie=y([Nt.staticImplements()],he);const{purposes:{AssertionProofPurpose:de}}=c;var we;!function(t){t.retrieveVerificationMethodPublicKey="retrieveVerificationMethodPublicKey",t.checkDocumentSignature="checkDocumentSignature"}(we||(we={}));class ve extends w{verificationProcess=[we.retrieveVerificationMethodPublicKey,we.checkDocumentSignature];documentToVerify;issuer;proof;type="Ed25519Signature2020";verificationKey;publicKey;constructor(t){super(t),t.executeStep&&(this.executeStep=t.executeStep),this.documentToVerify=t.document,this.issuer=t.issuer,this.proof=t.proof,this.validateProofType()}async init(){}async verifyProof(){for(const t of this.verificationProcess){if(!this[t])return void console.error("verification logic for",t,"not implemented");await this[t]()}}async verifyIdentity(){}getProofVerificationSteps(e){return this.verificationProcess.map((r=>t.verifier.convertToVerificationSubsteps(e,r)))}getIdentityVerificationSteps(){return[]}getIssuerPublicKey(){return this.publicKey}getIssuerName(){return this.issuer.name??""}getIssuerProfileDomain(){try{return new URL(this.getIssuerProfileUrl()).hostname??""}catch(t){return""}}getIssuerProfileUrl(){return this.issuer.id??""}getSigningDate(){return this.proof.created}async executeStep(t,e,r){throw new Error("doAction method needs to be overwritten by injecting from CVJS")}async publicKeyJwkToString(t){return await he.fingerprintFromPublicKey(t)}validateProofType(){const t=this.isProofChain()?this.proof.chainedProofType:this.proof.type;if(t!==this.type)throw new Error(`Incompatible proof type passed. Expected: ${this.type}, Got: ${t}`)}isProofChain(){return"ChainedProof2021"===this.proof.type}generateDocumentLoader(){e[this.documentToVerify.issuer]=this.issuer.didDocument;return function(t){return t in e?{contextUrl:null,document:e[t],documentUrl:t}:s.documentLoader(t)}}retrieveInitialDocument(){const t=r(this.documentToVerify);if(Array.isArray(t.proof)){const e=t.proof.find((t=>t.type===this.type));delete t.proof,t.proof=e}return t}async retrieveVerificationMethodPublicKey(){this.verificationKey=await this.executeStep(we.retrieveVerificationMethodPublicKey,(async()=>{const t=this.issuer.didDocument.verificationMethod.find((t=>t.id===this.proof.verificationMethod));if(!t)throw new n(we.retrieveVerificationMethodPublicKey,"The verification method of the document does not match the provided issuer.");try{this.publicKey=t.publicKeyMultibase??await this.publicKeyJwkToString(t)}catch(t){console.error("ERROR retrieving Ed25519Signature2020 public key",t)}const e=await dt.from({...t});if(!e)throw new n(we.retrieveVerificationMethodPublicKey,"Could not derive the verification key");if(e.revoked)throw new n(we.retrieveVerificationMethodPublicKey,"The verification key has been revoked");return e}),this.type)}async checkDocumentSignature(){await this.executeStep(we.checkDocumentSignature,(async()=>{const t=new St({key:this.verificationKey});t.date=new Date(Date.now()).toISOString();const e=await c.verify(this.retrieveInitialDocument(),{suite:t,purpose:new de,documentLoader:this.generateDocumentLoader()});if(!e.verified)throw console.error(JSON.stringify(e,null,2)),new n(we.checkDocumentSignature,`The document's ${this.type} signature could not be confirmed`);console.log("Credential Ed25519 signature successfully verified")}),this.type)}}export{ve as default};
|