iosignal 7.0.0 → 7.0.3

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.
@@ -15,7 +15,7 @@ import fs, { readFileSync } from 'fs';
15
15
  import { memoryUsage } from 'process';
16
16
  import path from 'path';
17
17
 
18
- var version$1 = "7.0.0";
18
+ var version$1 = "7.0.3";
19
19
  var pkg = {
20
20
  version: version$1};
21
21
 
@@ -759,7 +759,6 @@ const t=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1
759
759
  */var J=(Y||(Y=1,function(t){const e=function(){if(K)return V;K=1,V.byteLength=function(t){var e=o(t),r=e[0],n=e[1];return 3*(r+n)/4-n},V.toByteArray=function(t){var n,i,f=o(t),s=f[0],u=f[1],h=new r(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),a=0,c=u>0?s-4:s;for(i=0;i<c;i+=4)n=e[t.charCodeAt(i)]<<18|e[t.charCodeAt(i+1)]<<12|e[t.charCodeAt(i+2)]<<6|e[t.charCodeAt(i+3)],h[a++]=n>>16&255,h[a++]=n>>8&255,h[a++]=255&n;return 2===u&&(n=e[t.charCodeAt(i)]<<2|e[t.charCodeAt(i+1)]>>4,h[a++]=255&n),1===u&&(n=e[t.charCodeAt(i)]<<10|e[t.charCodeAt(i+1)]<<4|e[t.charCodeAt(i+2)]>>2,h[a++]=n>>8&255,h[a++]=255&n),h},V.fromByteArray=function(e){for(var r,n=e.length,i=n%3,o=[],f=16383,u=0,h=n-i;u<h;u+=f)o.push(s(e,u,u+f>h?h:u+f));return 1===i?(r=e[n-1],o.push(t[r>>2]+t[r<<4&63]+"==")):2===i&&(r=(e[n-2]<<8)+e[n-1],o.push(t[r>>10]+t[r>>4&63]+t[r<<2&63]+"=")),o.join("")};for(var t=[],e=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=0;i<64;++i)t[i]=n[i],e[n.charCodeAt(i)]=i;function o(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return -1===r&&(r=e),[r,r===e?0:4-r%4]}function f(e){return t[e>>18&63]+t[e>>12&63]+t[e>>6&63]+t[63&e]}function s(t,e,r){for(var n,i=[],o=e;o<r;o+=3)n=(t[o]<<16&16711680)+(t[o+1]<<8&65280)+(255&t[o+2]),i.push(f(n));return i.join("")}return e["-".charCodeAt(0)]=62,e["_".charCodeAt(0)]=63,V}(),r=Q(),n="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=f,t.SlowBuffer=function(t){return +t!=t&&(t=0),f.alloc(+t)},t.INSPECT_MAX_BYTES=50;const i=2147483647;function o(t){if(t>i)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,f.prototype),e}function f(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return h(t)}return s(t,e,r)}function s(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!f.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|p(t,e);let n=o(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(J(t,Uint8Array)){const e=new Uint8Array(t);return c(e.buffer,e.byteOffset,e.byteLength)}return a(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(J(t,ArrayBuffer)||t&&J(t.buffer,ArrayBuffer))return c(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(J(t,SharedArrayBuffer)||t&&J(t.buffer,SharedArrayBuffer)))return c(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return f.from(n,e,r);const i=function(t){if(f.isBuffer(t)){const e=0|l(t.length),r=o(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||W(t.length)?o(0):a(t):"Buffer"===t.type&&Array.isArray(t.data)?a(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return f.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function u(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function h(t){return u(t),o(t<0?0:0|l(t))}function a(t){const e=t.length<0?0:0|l(t.length),r=o(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function c(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,f.prototype),n}function l(t){if(t>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return 0|t}function p(t,e){if(f.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||J(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&true===arguments[2];if(!n&&0===r)return 0;let i=false;for(;;)switch(e){case "ascii":case "latin1":case "binary":return r;case "utf8":case "utf-8":return q(t).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return 2*r;case "hex":return r>>>1;case "base64":return Y(t).length;default:if(i)return n?-1:q(t).length;e=(""+e).toLowerCase(),i=true;}}function y(t,e,r){let n=false;if((void 0===e||e<0)&&(e=0),e>this.length)return "";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return "";if((r>>>=0)<=(e>>>=0))return "";for(t||(t="utf8");;)switch(t){case "hex":return T(this,e,r);case "utf8":case "utf-8":return U(this,e,r);case "ascii":return v(this,e,r);case "latin1":case "binary":return L(this,e,r);case "base64":return A(this,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return R(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=true;}}function g(t,e,r){const n=t[e];t[e]=t[r],t[r]=n;}function d(t,e,r,n,i){if(0===t.length)return -1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),W(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return -1;r=t.length-1;}else if(r<0){if(!i)return -1;r=0;}if("string"==typeof e&&(e=f.from(e,n)),f.isBuffer(e))return 0===e.length?-1:b(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):b(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(t,e,r,n,i){let o,f=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return -1;f=2,s/=2,u/=2,r/=2;}function h(t,e){return 1===f?t[e]:t.readUInt16BE(e*f)}if(i){let n=-1;for(o=r;o<s;o++)if(h(t,o)===h(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*f}else -1!==n&&(o-=o-n),n=-1;}else for(r+u>s&&(r=s-u),o=r;o>=0;o--){let r=true;for(let n=0;n<u;n++)if(h(t,o+n)!==h(e,n)){r=false;break}if(r)return o}return -1}function w(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let f;for(n>o/2&&(n=o/2),f=0;f<n;++f){const n=parseInt(e.substr(2*f,2),16);if(W(n))return f;t[r+f]=n;}return f}function B(t,e,r,n){return G(q(e,t.length-r),t,r,n)}function E(t,e,r,n){return G(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function m(t,e,r,n){return G(Y(e),t,r,n)}function _(t,e,r,n){return G(function(t,e){let r,n,i;const o=[];for(let f=0;f<t.length&&!((e-=2)<0);++f)r=t.charCodeAt(f),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function A(t,r,n){return 0===r&&n===t.length?e.fromByteArray(t):e.fromByteArray(t.slice(r,n))}function U(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,f=e>239?4:e>223?3:e>191?2:1;if(i+f<=r){let r,n,s,u;switch(f){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u));}}null===o?(o=65533,f=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=f;}return function(t){const e=t.length;if(e<=I)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=I));return r}(n)}t.kMaxLength=i,f.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return false}}(),f.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(f.prototype,"parent",{enumerable:true,get:function(){if(f.isBuffer(this))return this.buffer}}),Object.defineProperty(f.prototype,"offset",{enumerable:true,get:function(){if(f.isBuffer(this))return this.byteOffset}}),f.poolSize=8192,f.from=function(t,e,r){return s(t,e,r)},Object.setPrototypeOf(f.prototype,Uint8Array.prototype),Object.setPrototypeOf(f,Uint8Array),f.alloc=function(t,e,r){return function(t,e,r){return u(t),t<=0?o(t):void 0!==e?"string"==typeof r?o(t).fill(e,r):o(t).fill(e):o(t)}(t,e,r)},f.allocUnsafe=function(t){return h(t)},f.allocUnsafeSlow=function(t){return h(t)},f.isBuffer=function(t){return null!=t&&true===t._isBuffer&&t!==f.prototype},f.compare=function(t,e){if(J(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),J(e,Uint8Array)&&(e=f.from(e,e.offset,e.byteLength)),!f.isBuffer(t)||!f.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},f.isEncoding=function(t){switch(String(t).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "latin1":case "binary":case "base64":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return true;default:return false}},f.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return f.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=f.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(J(e,Uint8Array))i+e.length>n.length?(f.isBuffer(e)||(e=f.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else {if(!f.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i);}i+=e.length;}return n},f.byteLength=p,f.prototype._isBuffer=true,f.prototype.swap16=function(){const t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)g(this,e,e+1);return this},f.prototype.swap32=function(){const t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)g(this,e,e+3),g(this,e+1,e+2);return this},f.prototype.swap64=function(){const t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},f.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?U(this,0,t):y.apply(this,arguments)},f.prototype.toLocaleString=f.prototype.toString,f.prototype.equals=function(t){if(!f.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===f.compare(this,t)},f.prototype.inspect=function(){let e="";const r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},n&&(f.prototype[n]=f.prototype.inspect),f.prototype.compare=function(t,e,r,n,i){if(J(t,Uint8Array)&&(t=f.from(t,t.offset,t.byteLength)),!f.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return -1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const u=Math.min(o,s),h=this.slice(n,i),a=t.slice(e,r);for(let t=0;t<u;++t)if(h[t]!==a[t]){o=h[t],s=a[t];break}return o<s?-1:s<o?1:0},f.prototype.includes=function(t,e,r){return -1!==this.indexOf(t,e,r)},f.prototype.indexOf=function(t,e,r){return d(this,t,e,r,true)},f.prototype.lastIndexOf=function(t,e,r){return d(this,t,e,r,false)},f.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else {if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=false;for(;;)switch(n){case "hex":return w(this,t,e,r);case "utf8":case "utf-8":return B(this,t,e,r);case "ascii":case "latin1":case "binary":return E(this,t,e,r);case "base64":return m(this,t,e,r);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return _(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=true;}},f.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const I=4096;function v(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function L(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function T(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=X[t[n]];return i}function R(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function S(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,r,n,i,o){if(!f.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function O(t,e,r,n,i){F(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,f>>=8,t[r++]=f,r}function M(t,e,r,n,i){F(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let f=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=f,f>>=8,t[r+2]=f,f>>=8,t[r+1]=f,f>>=8,t[r]=f,r+8}function C(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(t,e,n,i,o){return e=+e,n>>>=0,o||C(t,0,n,4),r.write(t,e,n,i,23,4),n+4}function k(t,e,n,i,o){return e=+e,n>>>=0,o||C(t,0,n,8),r.write(t,e,n,i,52,8),n+8}f.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,f.prototype),n},f.prototype.readUintLE=f.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},f.prototype.readUintBE=f.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},f.prototype.readUint8=f.prototype.readUInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),this[t]},f.prototype.readUint16LE=f.prototype.readUInt16LE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]|this[t+1]<<8},f.prototype.readUint16BE=f.prototype.readUInt16BE=function(t,e){return t>>>=0,e||S(t,2,this.length),this[t]<<8|this[t+1]},f.prototype.readUint32LE=f.prototype.readUInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},f.prototype.readUint32BE=f.prototype.readUInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},f.prototype.readBigUInt64LE=Z(function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))}),f.prototype.readBigUInt64BE=Z(function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return (BigInt(n)<<BigInt(32))+BigInt(i)}),f.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},f.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||S(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},f.prototype.readInt8=function(t,e){return t>>>=0,e||S(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},f.prototype.readInt16LE=function(t,e){t>>>=0,e||S(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt16BE=function(t,e){t>>>=0,e||S(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},f.prototype.readInt32LE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},f.prototype.readInt32BE=function(t,e){return t>>>=0,e||S(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},f.prototype.readBigInt64LE=Z(function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return (BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)}),f.prototype.readBigInt64BE=Z(function(t){H(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||z(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return (BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)}),f.prototype.readFloatLE=function(t,e){return t>>>=0,e||S(t,4,this.length),r.read(this,t,true,23,4)},f.prototype.readFloatBE=function(t,e){return t>>>=0,e||S(t,4,this.length),r.read(this,t,false,23,4)},f.prototype.readDoubleLE=function(t,e){return t>>>=0,e||S(t,8,this.length),r.read(this,t,true,52,8)},f.prototype.readDoubleBE=function(t,e){return t>>>=0,e||S(t,8,this.length),r.read(this,t,false,52,8)},f.prototype.writeUintLE=f.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||N(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},f.prototype.writeUintBE=f.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||N(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},f.prototype.writeUint8=f.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,1,255,0),this[e]=255&t,e+1},f.prototype.writeUint16LE=f.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},f.prototype.writeUint16BE=f.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},f.prototype.writeUint32LE=f.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},f.prototype.writeUint32BE=f.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},f.prototype.writeBigUInt64LE=Z(function(t,e=0){return O(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),f.prototype.writeBigUInt64BE=Z(function(t,e=0){return M(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),f.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);N(this,t,e,r,n-1,-n);}let i=0,o=1,f=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===f&&0!==this[e+i-1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},f.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);N(this,t,e,r,n-1,-n);}let i=r-1,o=1,f=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===f&&0!==this[e+i+1]&&(f=1),this[e+i]=(t/o|0)-f&255;return e+r},f.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},f.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},f.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},f.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},f.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},f.prototype.writeBigInt64LE=Z(function(t,e=0){return O(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),f.prototype.writeBigInt64BE=Z(function(t,e=0){return M(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),f.prototype.writeFloatLE=function(t,e,r){return x(this,t,e,true,r)},f.prototype.writeFloatBE=function(t,e,r){return x(this,t,e,false,r)},f.prototype.writeDoubleLE=function(t,e,r){return k(this,t,e,true,r)},f.prototype.writeDoubleBE=function(t,e,r){return k(this,t,e,false,r)},f.prototype.copy=function(t,e,r,n){if(!f.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},f.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!f.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e);}}else "number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else {const o=f.isBuffer(t)?t:f.from(t,n),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%s];}return this};const P={};function $(t,e,r){P[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:true,configurable:true}),this.name=`${this.name} [${t}]`,this.stack,delete this.name;}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:true,enumerable:true,value:t,writable:true});}toString(){return `${this.name} [${t}]: ${this.message}`}};}function j(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return `${t.slice(0,r)}${e}`}function F(t,e,r,n,i,o){if(t>r||t<e){const r="bigint"==typeof e?"n":"";let n;throw n=0===e||e===BigInt(0)?`>= 0${r} and < 2${r} ** ${8*(o+1)}${r}`:`>= -(2${r} ** ${8*(o+1)-1}${r}) and < 2 ** ${8*(o+1)-1}${r}`,new P.ERR_OUT_OF_RANGE("value",n,t)}!function(t,e,r){H(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||z(e,t.length-(r+1));}(n,i,o);}function H(t,e){if("number"!=typeof t)throw new P.ERR_INVALID_ARG_TYPE(e,"number",t)}function z(t,e,r){if(Math.floor(t)!==t)throw H(t,r),new P.ERR_OUT_OF_RANGE("offset","an integer",t);if(e<0)throw new P.ERR_BUFFER_OUT_OF_BOUNDS;throw new P.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${e}`,t)}$("ERR_BUFFER_OUT_OF_BOUNDS",function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),$("ERR_INVALID_ARG_TYPE",function(t,e){return `The "${t}" argument must be of type number. Received type ${typeof e}`},TypeError),$("ERR_OUT_OF_RANGE",function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=j(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=j(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n},RangeError);const D=/[^+/0-9A-Za-z-_]/g;function q(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let f=0;f<n;++f){if(r=t.charCodeAt(f),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(f+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320);}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r);}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128);}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128);}else {if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128);}}return o}function Y(t){return e.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(D,"")).length<2)return "";for(;t.length%4!=0;)t+="=";return t}(t))}function G(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function J(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function W(t){return t!=t}const X=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i];}return e}();function Z(t){return "undefined"==typeof BigInt?tt:t}function tt(){throw new Error("BigInt not supported")}}(D)),D);let W={SERVER_TIME_NONCE:176,AUTH_REQ:177,AUTH_RES:178,AUTH_FAIL:179,ENC_PACK:182,ENC_E2E:183,ENC_488:184};for(let t in W)W[W[t]]=t;const X={SERVER_TIME_NONCE:H.meta(H.MB("header","8",0),H.MB("unixTime","32L",0),H.MB("milTime","16L",0),H.MB("counter","16L",0),H.MB("nonce",J.Buffer.alloc(4))),AUTH_REQ:H.meta(H.MB("header","8",0),H.MB("id8",J.Buffer.alloc(8)),H.MB("nonce",J.Buffer.alloc(4)),H.MB("hmac32",J.Buffer.alloc(32))),AUTH_RES:H.meta(H.MB("header","8",0),H.MB("hmac32",J.Buffer.alloc(32))),ENC_PACK:H.meta(H.MB("type","8",0),H.MB("len","32L",0),H.MB("salt12",J.Buffer.alloc(12)),H.MB("hmac",8,0)),ENC_488:H.meta(H.MB("type","8",0),H.MB("len","32L",0),H.MB("otpSrc8",J.Buffer.alloc(8)),H.MB("hmac8",J.Buffer.alloc(8)))};function Z(t){let e=t[t.length-1];return e[2]+e[3]}const tt={SERVER_TIME_NONCE:Z(X.SERVER_TIME_NONCE),AUTH_REQ:Z(X.AUTH_REQ),AUTH_RES:Z(X.AUTH_RES),ENC_PACK:Z(X.ENC_PACK),ENC_488:Z(X.ENC_488)};function et(t,e){if(!(t instanceof Uint8Array&&e instanceof Uint8Array&&t.length===e.length))return false;let r=0;for(let n=0;n<t.length;n++)r|=t[n]^e[n];return 0===r}function rt(t,e,r,n,i=false){if(!(t instanceof Uint8Array))return;const o=J.Buffer.from(t);return o.length<r||o[0]!==e||(i?o.readUInt32LE(1)!==o.length-r:o.length!==r)?void 0:H.unpack(o,n)}function nt(t){return globalThis.crypto.getRandomValues(J.Buffer.alloc(t))}class it{constructor(){this._id8=J.Buffer.alloc(8),this._otpSrc44=J.Buffer.alloc(44),this._otp36=J.Buffer.alloc(36),this._hmac=J.Buffer.alloc(32),this.auth_salt12=J.Buffer.alloc(12),this.localNonce=J.Buffer.alloc(4),this.remoteNonce=J.Buffer.alloc(4),this.isAuthorized=false,this.counter=0,this._hasKey=false,this._lastSendTime=0;}clearAuth(){this._id8.fill(0),this._otpSrc44.fill(0),this._otp36.fill(0),this._hmac.fill(0),this.auth_salt12.fill(0),this.localNonce.fill(0),this.remoteNonce.fill(0),this.isAuthorized=false,this.counter=0,this._hasKey=false,this._lastSendTime=0;}set_hash_id8(t){H.B8(z.hash(t)).copy(this._id8,0,0,8);}set_id8(t){let e=H.B8(t);this._id8.fill(0),e.copy(this._id8,0,0,8);}set_key(t){const e=H.B8(t);if(!e||0===e.length)throw new TypeError("Key must not be empty");this.copy_key(H.B8(z.hash(e)));}set_id_key(t){let e=t.indexOf(".");if(-1==e)return;let r=t.substring(0,e),n=t.substring(e+1);this.set_id8(r),this.set_key(n);}copy_id8(t){t.copy(this._id8,0,0,8);}copy_key(t){if(!(t instanceof Uint8Array)||32!==t.length)throw new TypeError("copy_key requires exactly 32 bytes");this._otpSrc44.set(t,0),this._hasKey=true;}sha256_n(t,e){let r=z.hash(t);for(let t=0;t<e;t++)r=z.hash(r);return r}set_clock_rand(){this.set_clock_nonce(nt(4));}set_clock_nonce(t){if(!(t instanceof Uint8Array)||4!==t.length)throw new TypeError("Nonce must be 4 bytes");let e=Math.max(Date.now(),this._lastSendTime);if(this.counter=this.counter+1&65535,0===this.counter&&e===this._lastSendTime&&e++,!Number.isSafeInteger(e)||e<0||Math.floor(e/1e3)>4294967295)throw new RangeError("Clock is outside the protocol range");this._lastSendTime=e;J.Buffer.concat([H.NB("32L",Math.floor(e/1e3)),H.NB("16L",e%1e3),H.NB("16L",this.counter),J.Buffer.from(t)]).copy(this._otpSrc44,32);}_requireKey(){if(!this._hasKey)throw new Error("Set a key before encryption or authentication")}set_salt12(t,e){if(12!=t.byteLength)throw TypeError("set_salt12: Invalid salt12 byteLength.");t.copy(this._otpSrc44,32);}resetOTP(){this._requireKey(),H.B8(z.hash(this._otpSrc44)).copy(this._otp36,0,0,32);}getIndexOTP(t){return this._otp36.writeUInt32LE(t,32),z.hash(this._otp36)}generateHMAC(t){this._requireKey();let e=J.Buffer.concat([this._otpSrc44,t]);this._hmac=H.B8(z.hash(e));}getHMAC8(t){this._requireKey();let e=J.Buffer.concat([this._otpSrc44,t]);return this._hmac=H.B8(z.hash(e)),this._hmac.subarray(0,8)}xotp(t,e=0,r=false){let n=(t=H.B8(t,r)).byteLength,i=e,o=0,f=0;for(;n>0;){f=n<32?n:32;let e=this.getIndexOTP(++i);for(let r=0;r<f;r++)t[o++]^=e[r];n-=32;}return t}server_time_nonce(){const t=Date.now(),e=Math.floor(t/1e3),r=t%1e3;return this.localNonce=nt(4),this.auth_salt12=J.Buffer.concat([H.NB("32L",e),H.NB("16L",r),nt(2),this.localNonce]),J.Buffer.concat([H.NB("8",W.SERVER_TIME_NONCE),this.auth_salt12])}auth_req(t){if(!this._hasKey)return false;let e=rt(t,W.SERVER_TIME_NONCE,tt.SERVER_TIME_NONCE,X.SERVER_TIME_NONCE);if(e&&e.milTime>=1e3)return false;if(e){let t=J.Buffer.concat([H.NB("32L",e.unixTime),H.NB("16L",e.milTime),H.NB("16L",e.counter),e.nonce]);return this.set_salt12(t,"auth_req"),this.localNonce=nt(4),this.generateHMAC(this.localNonce),this.remoteNonce=e.nonce,H.pack(H.MB("#header","8",W.AUTH_REQ),H.MB("#id8",this._id8),H.MB("#nonce",this.localNonce),H.MB("#hmac32",this._hmac))}return false}verify_auth_req(t){if(!this._hasKey)return false;let e;if(t instanceof Uint8Array?e=rt(t,W.AUTH_REQ,tt.AUTH_REQ,X.AUTH_REQ):t&&"object"==typeof t&&(e=t),!e||e.header!==W.AUTH_REQ||!(e.id8 instanceof Uint8Array)||8!==e.id8.length||!(e.nonce instanceof Uint8Array)||4!==e.nonce.length||!(e.hmac32 instanceof Uint8Array)||32!==e.hmac32.length||e.$OTHERS&&0!==e.$OTHERS.length)return false;this.set_salt12(this.auth_salt12,"verify_auth_req 1/2"),this.generateHMAC(e.nonce);let r=this._hmac;if(et(e.hmac32,r)){this.remoteNonce=J.Buffer.from(e.nonce);let t=J.Buffer.concat([this.localNonce,this.remoteNonce,this.localNonce]);this.set_salt12(t,"verify_auth_req 2/2"),this.generateHMAC(e.nonce);let r=this._hmac,n=H.rawPack(H.MB("header","8",W.AUTH_RES),H.MB("hmac32",r));return this.isAuthorized=true,n}return false}verify_auth_res(t){if(!this._hasKey)return false;let e=rt(t,W.AUTH_RES,tt.AUTH_RES,X.AUTH_RES);if(e){let t=J.Buffer.concat([this.remoteNonce,this.localNonce,this.remoteNonce]);if(this.set_salt12(t,"verify_auth_res"),this.generateHMAC(this.localNonce),et(this._hmac,e.hmac32))return this.isAuthorized=true,true}}encrypt_488(t){if(!this.isAuthorized||!this._hasKey)return;t=H.B8(t),this.set_clock_nonce(this.remoteNonce),this.resetOTP();let e=this.getHMAC8(t),r=this.xotp(t);return H.pack(H.MB("#type","8",W.ENC_488),H.MB("#len","32L",t.byteLength),H.MB("#otpSrc8",this._otpSrc44.subarray(32,40)),H.MB("#hmac8",e),H.MB("#xdata",r))}decrypt_488(t){if(!this.isAuthorized||!this._hasKey)return;let e=t;if(t instanceof Uint8Array&&t[0]===W.ENC_E2E){if(t.length<tt.ENC_488)return;const r=J.Buffer.from(t),n=r.readUInt32LE(1);if(n>r.length-tt.ENC_488)return;e=J.Buffer.from(r.subarray(0,tt.ENC_488+n)),e[0]=W.ENC_488;}const r=rt(e,W.ENC_488,tt.ENC_488,X.ENC_488,true);if(!(r&&(n=r.otpSrc8,n.readUInt16LE(4)<1e3)))return;var n;this.set_salt12(J.Buffer.concat([r.otpSrc8,this.localNonce]),"decrypt_488"),this.resetOTP();const i=this.xotp(r.$OTHERS??J.Buffer.alloc(0));return et(this.getHMAC8(i),r.hmac8)?i:void 0}encryptPack(t){this._requireKey(),t=H.B8(t),this.set_clock_rand(),this.resetOTP();let e=this.getHMAC8(t),r=this.xotp(t);return H.pack(H.MB("#type","8",W.ENC_PACK),H.MB("#len","32L",t.byteLength),H.MB("#salt12",this._otpSrc44.subarray(32)),H.MB("#hmac8",e),H.MB("#xdata",r))}decryptPack(t){if(!this._hasKey)return;const e=rt(t,W.ENC_PACK,tt.ENC_PACK,X.ENC_PACK,true);if(!e)return;this.set_salt12(e.salt12,"decryptPack"),this.resetOTP();const r=this.xotp(e.$OTHERS??J.Buffer.alloc(0));return et(e.hmac,this.getHMAC8(r))?(e.data=r,e):void 0}encrypt_e2e(t,e){return this._withKey(e,()=>this.encryptPack(t))}decrypt_e2e(t,e){return this._withKey(e,()=>this.decryptPack(t))}_withKey(t,e){const r=H.B8(t);if(!r||0===r.length)throw new TypeError("Key must not be empty");const n=[J.Buffer.from(this._otpSrc44),J.Buffer.from(this._otp36),J.Buffer.from(this._hmac)],i=this._hasKey;try{return this._otpSrc44.set(z.hash(r),0),this._hasKey=!0,e()}finally{this._otpSrc44.set(n[0]),this._otp36.set(n[1]),this._hmac.set(n[2]),this._hasKey=i;for(const t of n)t.fill(0);}}}it.RAND=nt,it.BohoMsg=W,it.Meta=X,it.MetaSize=tt,it.sha256=z,it.MBP=H,it.Buffer=J.Buffer;
760
760
 
761
761
  /**
762
- * @typedef {import('meta-buffer-pack').MBP} MBP
763
762
  * @typedef {import('../common/constants.js').IOMsg} IOMsg
764
763
  * @typedef {import('../common/constants.js').PAYLOAD_TYPE} PAYLOAD_TYPE
765
764
  * @typedef {import('../common/constants.js').SIZE_LIMIT} SIZE_LIMIT
@@ -868,7 +867,7 @@ class IOCore extends EventEmitter {
868
867
  this.connectionCheckerPeriod = SIZE_LIMIT.CONNECTION_CHECKER_PERIOD;
869
868
  /**
870
869
  * Interval ID for connection checker.
871
- * @type {NodeJS.Timeout | null}
870
+ * @type {ReturnType<typeof setInterval> | null}
872
871
  */
873
872
  this.connectionCheckerIntervalID = null;
874
873
 
@@ -878,6 +877,7 @@ class IOCore extends EventEmitter {
878
877
  */
879
878
  this.boho = new it();
880
879
 
880
+ /** @type {import('buffer').Buffer} */
881
881
  this.serverTimeNonce = Buffer$1.alloc( it.MetaSize.SERVER_TIME_NONCE );
882
882
  /**
883
883
  * Indicates if the connection is TLS (wss).
@@ -964,7 +964,7 @@ class IOCore extends EventEmitter {
964
964
 
965
965
 
966
966
  /**
967
- * Performs common cleanup for the connection. It clears pending promises,
967
+ * Performs common cleanup for the connection. It rejects pending RPCs,
968
968
  * resets the socket reference, and sets the state to closed.
969
969
  * This method is guarded to only run once.
970
970
  * If autoReconnect is false, it also clears the keep-alive timer.
@@ -999,6 +999,12 @@ class IOCore extends EventEmitter {
999
999
  }
1000
1000
  this.socket = null;
1001
1001
  }
1002
+ const error = new Error('Connection closed');
1003
+ error.code = 'CONNECTION_CLOSED';
1004
+ for (const [, reject, timeoutId] of this.promiseMap.values()) {
1005
+ clearTimeout(timeoutId);
1006
+ reject(error);
1007
+ }
1002
1008
  this.promiseMap.clear();
1003
1009
  this.cid = '';
1004
1010
  if (this.boho) this.boho.isAuthorized = false;
@@ -1692,11 +1698,12 @@ class IOCore extends EventEmitter {
1692
1698
  call(target, topic, ...args) {
1693
1699
  if (!target || !topic)
1694
1700
  return Promise.reject(new Error('request need target and topic)'))
1701
+ this.mid = (this.mid + 1) & 0xffff;
1695
1702
  let sigPack;
1696
1703
  if (args.length > 0) {
1697
1704
  sigPack = $$1.pack(
1698
1705
  $$1.MB('#MsgType', '8', IOMsg.CALL),
1699
- $$1.MB('mid', '16', ++this.mid),
1706
+ $$1.MB('mid', '16', this.mid),
1700
1707
  $$1.MB('target', target),
1701
1708
  $$1.MB('topic', topic),
1702
1709
  $$1.MBA(...args)
@@ -1704,7 +1711,7 @@ class IOCore extends EventEmitter {
1704
1711
  } else {
1705
1712
  sigPack = $$1.pack(
1706
1713
  $$1.MB('#MsgType', '8', IOMsg.CALL),
1707
- $$1.MB('mid', '16', ++this.mid),
1714
+ $$1.MB('mid', '16', this.mid),
1708
1715
  $$1.MB('target', target),
1709
1716
  $$1.MB('topic', topic)
1710
1717
  );
@@ -2014,6 +2021,9 @@ function pack(payload) {
2014
2021
  }
2015
2022
 
2016
2023
  class CongRx extends Transform {
2024
+ /**
2025
+ * @param {import('stream').TransformOptions} [options] Stream options.
2026
+ */
2017
2027
  constructor(options) {
2018
2028
  super(options);
2019
2029
  this.buffer = Buffer.alloc(0);
@@ -2056,54 +2066,45 @@ class CongRx extends Transform {
2056
2066
 
2057
2067
 
2058
2068
  parse() {
2059
- let head = this.buffer[0];
2060
- let headerLen;
2061
- let payloadSize;
2062
-
2063
- if (head == CongType.TYPE_LEN1) {
2064
- headerLen = 2;
2065
- if (this.buffer.byteLength < headerLen) return;
2066
- payloadSize = this.buffer.readUint8(1);
2067
-
2068
- } else if (head == CongType.TYPE_LEN2) {
2069
- headerLen = 3;
2070
- if (this.buffer.byteLength < headerLen) return;
2071
- payloadSize = this.buffer.readUint16LE(1);
2072
-
2073
- } else if (head == CongType.TYPE_LEN3) {
2074
- headerLen = 4;
2075
- if (this.buffer.byteLength < headerLen) return;
2076
- payloadSize = this.buffer.readUint16LE(1) + this.buffer.readUint8(3) * 65536;
2077
-
2078
- } else if (head == CongType.TYPE_LEN4) {
2079
- headerLen = 5;
2080
- if (this.buffer.byteLength < headerLen) return;
2081
- payloadSize = this.buffer.readUint32LE(1);
2082
-
2083
- } else {
2084
- this.emit('wrong', this.buffer);
2085
- this.buffer = Buffer.alloc(0);
2086
- }
2069
+ while (this.buffer.byteLength > 0) {
2070
+ const head = this.buffer[0];
2071
+ let headerLen;
2072
+ let payloadSize;
2073
+
2074
+ if (head === CongType.TYPE_LEN1) {
2075
+ headerLen = 2;
2076
+ if (this.buffer.byteLength < headerLen) return;
2077
+ payloadSize = this.buffer.readUint8(1);
2078
+ } else if (head === CongType.TYPE_LEN2) {
2079
+ headerLen = 3;
2080
+ if (this.buffer.byteLength < headerLen) return;
2081
+ payloadSize = this.buffer.readUint16LE(1);
2082
+ } else if (head === CongType.TYPE_LEN3) {
2083
+ headerLen = 4;
2084
+ if (this.buffer.byteLength < headerLen) return;
2085
+ payloadSize = this.buffer.readUint16LE(1) + this.buffer.readUint8(3) * 65536;
2086
+ } else if (head === CongType.TYPE_LEN4) {
2087
+ headerLen = 5;
2088
+ if (this.buffer.byteLength < headerLen) return;
2089
+ payloadSize = this.buffer.readUint32LE(1);
2090
+ } else {
2091
+ this.emit('wrong', this.buffer);
2092
+ this.buffer = Buffer.alloc(0);
2093
+ return;
2094
+ }
2087
2095
 
2096
+ const frameSize = headerLen + payloadSize;
2097
+ if (this.buffer.byteLength < frameSize) return;
2088
2098
 
2089
- if (payloadSize == this.buffer.byteLength - headerLen) {
2090
- this.frames.push(this.buffer.subarray(headerLen));
2091
- this.buffer = Buffer.alloc(0);
2092
- return
2093
- } else if (payloadSize < this.buffer.byteLength - headerLen) {
2094
- this.frames.push(this.buffer.subarray(headerLen, headerLen + payloadSize));
2095
- this.buffer = this.buffer.subarray(headerLen + payloadSize);
2096
- this.parse();
2097
- } else {
2098
- // not ready
2099
- // console.log('+')
2100
- return
2099
+ this.frames.push(this.buffer.subarray(headerLen, frameSize));
2100
+ if (this.buffer.byteLength === frameSize) {
2101
+ this.buffer = Buffer.alloc(0);
2102
+ return;
2103
+ }
2104
+ // Consume each complete frame without growing the call stack.
2105
+ this.buffer = this.buffer.subarray(frameSize);
2101
2106
  }
2102
-
2103
-
2104
2107
  }
2105
-
2106
-
2107
2108
  }
2108
2109
 
2109
2110
  class IOCongSocket extends IOCore {
@@ -7331,6 +7332,7 @@ let serverOption = {
7331
7332
  httpServer: null,
7332
7333
  wsPath: null,
7333
7334
  timeout: 50000,
7335
+ pingTimeoutGrace: 5000,
7334
7336
  showMessage: 'none',
7335
7337
  showMetric: 0,
7336
7338
  showChannel: 0,
@@ -7482,6 +7484,7 @@ class RemoteCore {
7482
7484
  rxQuotaChecker(message) {
7483
7485
  let rxBytes = message.byteLength;
7484
7486
  this.manager.rxBytes += rxBytes;
7487
+ if (this.manager.telemetry) { this.manager.telemetry.rxBytes += rxBytes; this.manager.telemetry.rxMessages++; }
7485
7488
 
7486
7489
  if (serverOption.useQuota.signalSize && (rxBytes > this.quota.signalSize)) {
7487
7490
  console.log('## quota: size over');
@@ -7953,6 +7956,10 @@ const decoder$2 = new TextDecoder();
7953
7956
  class Remote extends RemoteCore {
7954
7957
  constructor(socket, req, manager) {
7955
7958
  super(socket, manager);
7959
+ this.txQueuePeakBytes = 0;
7960
+ this.txWriteFalseCount = 0;
7961
+ this.txBlockedSince = null;
7962
+ this.txDrainMaxMs = 0;
7956
7963
  this.socketType = socket.socketType;
7957
7964
 
7958
7965
  if (this.socketType === 'websocket') {
@@ -7989,6 +7996,11 @@ class Remote extends RemoteCore {
7989
7996
  this.manager.removeRemote(this);
7990
7997
  };
7991
7998
  } else { // TCP else
7999
+ socket.on('drain', () => {
8000
+ if (this.txBlockedSince === null) return;
8001
+ this.txDrainMaxMs = Math.max(this.txDrainMaxMs, performance.now() - this.txBlockedSince);
8002
+ this.txBlockedSince = null;
8003
+ });
7992
8004
  this.congRx = new CongRx();
7993
8005
  socket.on('data', data => { this.congRx.write(data); });
7994
8006
 
@@ -8057,6 +8069,7 @@ class Remote extends RemoteCore {
8057
8069
  // any type of received messages: message, ping, pong
8058
8070
  receiveMonitor() {
8059
8071
  this.socket.rxCounter++;
8072
+ if (this.socket.isAlive === false) this.manager.heartbeatPending.delete(this);
8060
8073
  this.socket.isAlive = true;
8061
8074
  }
8062
8075
 
@@ -8120,10 +8133,16 @@ class Remote extends RemoteCore {
8120
8133
  }
8121
8134
  }
8122
8135
 
8136
+ recordTxQueue() {
8137
+ const queued = this.socket.bufferedAmount ?? this.socket.writableLength ?? 0;
8138
+ if (queued > this.txQueuePeakBytes) this.txQueuePeakBytes = queued;
8139
+ }
8140
+
8123
8141
  // node.js server side remote.
8124
8142
  send(message, isBinary) {
8125
8143
  // console.log(`<-S [${IOMsg[ message[0]]}]`)
8126
8144
  this.manager.txBytes += message.byteLength;
8145
+ if (this.manager.telemetry) { this.manager.telemetry.txBytes += message.byteLength; this.manager.telemetry.txMessages++; }
8127
8146
  this.socket.txCounter++;
8128
8147
  if (this.socketType === 'websocket') {
8129
8148
  if (this.socket.readyState === 1) {
@@ -8132,6 +8151,7 @@ class Remote extends RemoteCore {
8132
8151
  } else {
8133
8152
  this.socket.send(message);
8134
8153
  }
8154
+ this.recordTxQueue();
8135
8155
  } else {
8136
8156
  console.log('server(ws)Remote.send() called. not open state. current readyState:', this.socket.readyState );
8137
8157
  this.close(true);
@@ -8139,7 +8159,12 @@ class Remote extends RemoteCore {
8139
8159
 
8140
8160
  } else { //CongSocket
8141
8161
  if (this.socket.readyState == 'open') {
8142
- this.socket.write(pack(message));
8162
+ const writable = this.socket.write(pack(message));
8163
+ this.recordTxQueue();
8164
+ if (!writable) {
8165
+ this.txWriteFalseCount++;
8166
+ if (this.txBlockedSince === null) this.txBlockedSince = performance.now();
8167
+ }
8143
8168
  } else {
8144
8169
  console.log('server(cong)Remote.send() called. not open state. current readyState:', this.socket.readyState );
8145
8170
  this.close(true);
@@ -8343,6 +8368,12 @@ class Manager {
8343
8368
 
8344
8369
  constructor(server, authManager) {
8345
8370
  this.server = server;
8371
+ this.pingPeriod = serverOption.timeout;
8372
+ this.pingGrace = serverOption.pingTimeoutGrace;
8373
+ if (!Number.isFinite(this.pingPeriod) || this.pingPeriod <= 0 ||
8374
+ !Number.isFinite(this.pingGrace) || this.pingGrace < 0) {
8375
+ throw new RangeError('Invalid heartbeat period or grace');
8376
+ }
8346
8377
  this.txBytes = 0;
8347
8378
  this.rxBytes = 0;
8348
8379
 
@@ -8369,25 +8400,20 @@ class Manager {
8369
8400
  this.metrics = new Metrics(this);
8370
8401
  this.lastSSID = 0;
8371
8402
 
8372
- this.pingIntervalID = setInterval(e => {
8373
- this.remotes.forEach(function each(remo) {
8374
- let socket = remo.socket;
8375
- if (socket.isAlive === false) {
8376
- console.log('## timeout. cid:', remo.cid);
8377
- remo.close();
8378
- return;
8379
- }
8380
-
8381
- socket.txCounter++;
8382
- socket.isAlive = false;
8383
- if (remo.socketType === 'websocket') {
8384
- socket.ping();
8385
- } else {
8386
- remo.ping();
8387
- }
8388
-
8389
- });
8390
- }, serverOption.timeout);
8403
+ const groups = Math.min(50, Math.max(1, Math.floor(this.pingPeriod / 1000)));
8404
+ this.pingGroups = Array.from({ length: groups }, () => new Set());
8405
+ this.nextPingGroup = 0;
8406
+ this.pingGroupCursor = 0;
8407
+ // Same timeout for all entries: insertion order is also deadline order.
8408
+ this.heartbeatPending = new Map();
8409
+ this.pingTickMs = this.pingPeriod / groups;
8410
+ this.heartbeatStopped = false;
8411
+ const tick = () => {
8412
+ if (this.heartbeatStopped) return;
8413
+ this.heartbeatTick();
8414
+ if (!this.heartbeatStopped) this.pingIntervalID = setTimeout(tick, this.pingTickMs);
8415
+ };
8416
+ this.pingIntervalID = setTimeout(tick, this.pingTickMs);
8391
8417
 
8392
8418
  if (serverOption.showMetric) {
8393
8419
  this.monitIntervalID = setInterval((e) => {
@@ -8399,10 +8425,37 @@ class Manager {
8399
8425
  }
8400
8426
 
8401
8427
 
8428
+ heartbeatTick() {
8429
+ const now = performance.now();
8430
+ // Process only expired requests, not every connected peer.
8431
+ for (const [remote, deadline] of this.heartbeatPending) {
8432
+ if (deadline > now) break;
8433
+ this.heartbeatPending.delete(remote);
8434
+ if (!remote._closing && remote.socket.isAlive === false) remote.close(true);
8435
+ }
8436
+ // The single timer schedules its next tick after this work; missed groups are not replayed.
8437
+ const group = this.pingGroups[this.pingGroupCursor];
8438
+ this.pingGroupCursor = (this.pingGroupCursor + 1) % this.pingGroups.length;
8439
+ for (const remote of group) {
8440
+ if (remote._closing || this.heartbeatPending.has(remote)) continue;
8441
+ remote.socket.isAlive = false;
8442
+ this.heartbeatPending.set(remote, performance.now() + this.pingPeriod + this.pingGrace);
8443
+ try {
8444
+ remote.ping();
8445
+ } catch {
8446
+ this.heartbeatPending.delete(remote);
8447
+ remote.close(true);
8448
+ }
8449
+ }
8450
+ }
8451
+
8402
8452
  addRemote(socket, req) {
8403
8453
  socket.isAlive = true;
8404
8454
  let remote = new Remote(socket, req, this);
8405
8455
  this.remotes.add(remote);
8456
+ remote.pingGroup = this.nextPingGroup;
8457
+ this.pingGroups[remote.pingGroup].add(remote);
8458
+ this.nextPingGroup = (this.nextPingGroup + 1) % this.pingGroups.length;
8406
8459
  remote.send(remote.issueAuthChallenge());
8407
8460
  remote.send( Buffer.from([ IOMsg.SERVER_READY]) );
8408
8461
  remote.setState(STATE.SERVER_READY);
@@ -8416,6 +8469,8 @@ class Manager {
8416
8469
  removeRemote(remote) {
8417
8470
 
8418
8471
  remote._closing = true;
8472
+ this.pingGroups[remote.pingGroup]?.delete(remote);
8473
+ this.heartbeatPending.delete(remote);
8419
8474
  remote.setState(STATE.CLOSED);
8420
8475
 
8421
8476
  let remoteInfo = `- IP:${remote.ip} #${remote.ssid} cid:${remote.cid} ${remote?.socket.socketType === 'websocket' ? "WS" : "CS"} `;
@@ -8594,6 +8649,7 @@ class Manager {
8594
8649
 
8595
8650
  }
8596
8651
 
8652
+ if (this.telemetry) this.telemetry.publishes++;
8597
8653
  let sentCounter = 0;
8598
8654
  if (this.channel_map.has(tag)) {
8599
8655
  // console.log('raw channel_map matched tag:', tag)
@@ -8605,6 +8661,7 @@ class Manager {
8605
8661
  } else {
8606
8662
  limit = remotes.size;
8607
8663
  }
8664
+ if (this.telemetry) this.telemetry.quotaExcluded += remotes.size - limit;
8608
8665
  let peers = remotes.values();
8609
8666
  while (sentCounter < limit) {
8610
8667
  let c = peers.next().value;
@@ -8624,6 +8681,7 @@ class Manager {
8624
8681
  // } else {
8625
8682
  // // console.log(`pub >> [${tag}] sent: ${sentCounter} [no quota limit] total: ${remotes.size} subscribers. ` )
8626
8683
  // }
8684
+ if (this.telemetry) this.telemetry.deliveryAttempts += sentCounter;
8627
8685
  return ['ok', sentCounter]
8628
8686
  }
8629
8687
  }
@@ -8757,7 +8815,10 @@ class Manager {
8757
8815
 
8758
8816
  close() {
8759
8817
  this.metrics.close();
8760
- clearInterval(this.pingIntervalID);
8818
+ this.heartbeatStopped = true;
8819
+ clearTimeout(this.pingIntervalID);
8820
+ this.heartbeatPending.clear();
8821
+ for (const group of this.pingGroups) group.clear();
8761
8822
  if (this.monitIntervalID) {
8762
8823
  clearInterval(this.monitIntervalID);
8763
8824
  }
@@ -8783,6 +8844,10 @@ const STATUS = {
8783
8844
 
8784
8845
  class Server extends require$$0$3 {
8785
8846
 
8847
+ /**
8848
+ * @param {object} options Server configuration.
8849
+ * @param {any} [authManager] Optional authentication manager.
8850
+ */
8786
8851
  constructor(options, authManager) {
8787
8852
  super();
8788
8853
  const security = { ...serverOption.security, ...options.security };
@@ -8797,6 +8862,13 @@ class Server extends require$$0$3 {
8797
8862
  this.port = null;
8798
8863
  this.congPort = null;
8799
8864
 
8865
+ if (options.pingTimeoutGrace !== undefined) {
8866
+ if (!Number.isFinite(options.pingTimeoutGrace) || options.pingTimeoutGrace < 0) {
8867
+ throw new RangeError('pingTimeoutGrace must be a finite non-negative number');
8868
+ }
8869
+ serverOption.pingTimeoutGrace = options.pingTimeoutGrace;
8870
+ }
8871
+
8800
8872
  if (options.timeout) {
8801
8873
  let pingT = parseInt(options.timeout);
8802
8874
  if (pingT && pingT >= 1000) serverOption.timeout = pingT;
@@ -8930,49 +9002,44 @@ class Server extends require$$0$3 {
8930
9002
  throw new Error(`Service ${service} : no commands or !Array.`)
8931
9003
  }
8932
9004
 
8933
- // Service TYPE 1. single call() function.
8934
- if ( service_module.call && typeof service_module.call == 'function' ) {
8935
- this.on(service, (remote, req) => {
8936
- try {
8937
- if (!service_module.checkPermission(remote, req)) {
8938
- remote.response(req.mid, STATUS.ERROR, "NO_PERMISSION.");
8939
- return
8940
- }
8941
- if( service_module.commands.includes( req.topic )){
8942
- // console.log('server service_module req', req )
8943
- service_module.call(remote, req);
8944
- }else {
8945
- remote.response(req.mid, STATUS.ERROR, "UNKNOWN_COMMAND");
8946
- }
8947
- } catch (error) {
8948
- console.error(`Unhandled Service Error in service [${service}]:`, error);
8949
- remote.response(req.mid, STATUS.ERROR, "INTERNAL_SERVER_ERROR");
9005
+ const handleError = (remote, req, error) => {
9006
+ console.error(`Unhandled Service Error in service [${service}]:`, error);
9007
+ if (remote._closing) return;
9008
+ // A disconnected transport can also fail while reporting the service error.
9009
+ try {
9010
+ remote.response(req.mid, STATUS.ERROR, "INTERNAL_SERVER_ERROR");
9011
+ } catch (responseError) {
9012
+ console.error(`Service error response failed [${service}]:`, responseError);
9013
+ }
9014
+ };
9015
+ const useCall = typeof service_module.call === 'function';
9016
+ this.on(service, (remote, req) => {
9017
+ try {
9018
+ if (!service_module.checkPermission(remote, req)) {
9019
+ remote.response(req.mid, STATUS.ERROR, "NO_PERMISSION.");
9020
+ return;
8950
9021
  }
8951
- });
8952
- } else {
8953
- // Service TYPE 2. multiple functions.
8954
- this.on(service, (remote, req) => {
8955
- try {
8956
- if (!service_module.checkPermission(remote, req)) {
8957
- remote.response(req.mid, STATUS.ERROR, "NO_PERMISSION.");
8958
- return
8959
- }
8960
- if( service_module.commands.includes( req.topic )){
8961
- service_module[req.topic](remote, req);
8962
- }else {
8963
- remote.response(req.mid, STATUS.ERROR, "UNKNOWN_COMMAND");
8964
- }
8965
- } catch (error) {
8966
- console.error(`Unhandled Service Error in service [${service}]:`, error);
8967
- remote.response(req.mid, STATUS.ERROR, "INTERNAL_SERVER_ERROR");
9022
+ if (!service_module.commands.includes(req.topic)) {
9023
+ remote.response(req.mid, STATUS.ERROR, "UNKNOWN_COMMAND");
9024
+ return;
8968
9025
  }
8969
- });
8970
- }
9026
+ // Keep synchronous invocation and the service receiver; also observe async failures.
9027
+ const result = useCall
9028
+ ? service_module.call(remote, req)
9029
+ : service_module[req.topic](remote, req);
9030
+ Promise.resolve(result).catch(error => handleError(remote, req, error));
9031
+ } catch (error) {
9032
+ handleError(remote, req, error);
9033
+ }
9034
+ });
8971
9035
  this.serviceNames.add(service);
8972
9036
  // console.log(`[Service attached: ${service} ] accept commands: ${service_module.commands}`)
8973
9037
  return this
8974
9038
  }
8975
9039
 
9040
+ /**
9041
+ * @param {() => void} [callback] Called when the server has closed.
9042
+ */
8976
9043
  close(callback) {
8977
9044
  console.log('closing iosignal server...');
8978
9045
  if (this.manager) {
@@ -2,7 +2,7 @@
2
2
  * Core class for handling WebSocket communication.
3
3
  * @augments {EventEmitter}
4
4
  */
5
- export class IOCore {
5
+ export class IOCore extends EventEmitter<string | symbol, any> {
6
6
  /**
7
7
  * @param {string} url - The WebSocket URL to connect to.
8
8
  */
@@ -70,14 +70,15 @@ export class IOCore {
70
70
  connectionCheckerPeriod: number;
71
71
  /**
72
72
  * Interval ID for connection checker.
73
- * @type {NodeJS.Timeout | null}
73
+ * @type {ReturnType<typeof setInterval> | null}
74
74
  */
75
- connectionCheckerIntervalID: NodeJS.Timeout | null;
75
+ connectionCheckerIntervalID: ReturnType<typeof setInterval> | null;
76
76
  /**
77
77
  * Boho instance for encryption/decryption.
78
78
  * @type {Boho}
79
79
  */
80
80
  boho: Boho;
81
+ /** @type {import('buffer').Buffer} */
81
82
  serverTimeNonce: import("buffer").Buffer;
82
83
  /**
83
84
  * Indicates if the connection is TLS (wss).
@@ -152,7 +153,7 @@ export class IOCore {
152
153
  */
153
154
  private _closed;
154
155
  /**
155
- * Performs common cleanup for the connection. It clears pending promises,
156
+ * Performs common cleanup for the connection. It rejects pending RPCs,
156
157
  * resets the socket reference, and sets the state to closed.
157
158
  * This method is guarded to only run once.
158
159
  * If autoReconnect is false, it also clears the keep-alive timer.
@@ -411,7 +412,6 @@ export class IOCore {
411
412
  */
412
413
  stateChange(state: string, emitEventAndMessage?: string): boolean;
413
414
  }
414
- export type MBP = import("meta-buffer-pack").MBP;
415
415
  export type IOMsg = import("../common/constants.js").IOMsg;
416
416
  export type PAYLOAD_TYPE = import("../common/constants.js").PAYLOAD_TYPE;
417
417
  export type SIZE_LIMIT = import("../common/constants.js").SIZE_LIMIT;
@@ -419,4 +419,5 @@ export type ENC_MODE = import("../common/constants.js").ENC_MODE;
419
419
  export type STATE = import("../common/constants.js").STATE;
420
420
  export type quotaTable = any;
421
421
  export type Buffer = import("boho").Buffer;
422
+ import { EventEmitter } from "eventemitter3";
422
423
  import Boho from "boho";
@@ -25,9 +25,9 @@ export default class IO extends IOCore {
25
25
  static MBP: MBP;
26
26
  /**
27
27
  * The Buffer class from Boho.
28
- * @type {Buffer}
28
+ * @type {typeof import('buffer').Buffer}
29
29
  */
30
- static Buffer: Buffer;
30
+ static Buffer: typeof import("buffer").Buffer;
31
31
  /**
32
32
  * Constants used by the client.
33
33
  * @type {object}
@@ -73,7 +73,7 @@ export default class IO extends IOCore {
73
73
  */
74
74
  socket_send(data: BufferSource): void;
75
75
  }
76
- export type MBP = import("boho").MBP;
76
+ export type MBP = typeof import("meta-buffer-pack").default;
77
77
  export type Buffer = import("boho").Buffer;
78
78
  import { IOCore } from "../IOCore.js";
79
79
  import Boho from 'boho';