llonebot-dist 7.11.0 → 7.11.2
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/llbot.js +38149 -71365
- package/llbot.js.map +1 -1
- package/node_modules/file-type/package.json +36 -53
- package/node_modules/file-type/readme.md +35 -102
- package/node_modules/file-type/source/detectors/asf.js +127 -0
- package/node_modules/file-type/source/detectors/ebml.js +120 -0
- package/node_modules/file-type/source/detectors/png.js +123 -0
- package/node_modules/file-type/source/detectors/zip.js +643 -0
- package/node_modules/file-type/{core.d.ts → source/index.d.ts} +49 -22
- package/node_modules/file-type/{core.js → source/index.js} +253 -1056
- package/node_modules/file-type/source/index.test-d.ts +53 -0
- package/node_modules/file-type/source/parser.js +65 -0
- package/node_modules/file-type/{supported.js → source/supported.js} +14 -6
- package/node_modules/file-type/{util.js → source/tokens.js} +2 -2
- package/node_modules/strtok3/LICENSE.txt +1 -1
- package/node_modules/strtok3/README.md +2 -2
- package/node_modules/strtok3/lib/AbstractTokenizer.d.ts +1 -1
- package/node_modules/strtok3/lib/AbstractTokenizer.js +4 -1
- package/node_modules/strtok3/lib/ReadStreamTokenizer.d.ts +3 -0
- package/node_modules/strtok3/lib/ReadStreamTokenizer.js +6 -1
- package/node_modules/strtok3/lib/stream/WebStreamByobReader.js +1 -1
- package/node_modules/strtok3/package.json +8 -8
- package/node_modules/ws/index.js +15 -6
- package/node_modules/ws/lib/permessage-deflate.js +6 -6
- package/node_modules/ws/lib/websocket-server.js +5 -5
- package/node_modules/ws/lib/websocket.js +6 -6
- package/node_modules/ws/package.json +4 -3
- package/node_modules/ws/wrapper.mjs +14 -1
- package/package.json +1 -1
- package/webui/assets/index-BkP41fNe.js +37 -0
- package/webui/assets/{index-B6wi2XZx.css → index-DsGxgscs.css} +1 -1
- package/webui/index.html +2 -2
- package//346/233/264/346/226/260/346/227/245/345/277/227.txt +42 -2
- package/node_modules/file-type/index.d.ts +0 -98
- package/node_modules/file-type/index.js +0 -110
- package/webui/assets/index-DwQjH3d6.js +0 -37
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {ReadableStream as NodeReadableStream} from 'node:stream/web';
|
|
2
|
+
import {expectType} from 'tsd';
|
|
3
|
+
import {
|
|
4
|
+
type FileTypeResult,
|
|
5
|
+
type FileTypeResult as FileTypeResultBrowser,
|
|
6
|
+
type AnyWebReadableByteStreamWithFileType,
|
|
7
|
+
fileTypeFromBlob,
|
|
8
|
+
fileTypeFromBuffer,
|
|
9
|
+
fileTypeFromFile,
|
|
10
|
+
fileTypeFromStream,
|
|
11
|
+
fileTypeStream,
|
|
12
|
+
FileTypeParser,
|
|
13
|
+
} from './index.js';
|
|
14
|
+
|
|
15
|
+
// `fileTypeStream`: accepts StreamOptions & FileTypeOptions
|
|
16
|
+
(async () => {
|
|
17
|
+
const webStream = new ReadableStream<Uint8Array>();
|
|
18
|
+
expectType<AnyWebReadableByteStreamWithFileType>(await fileTypeStream(webStream, {sampleSize: 256}));
|
|
19
|
+
expectType<AnyWebReadableByteStreamWithFileType>(await fileTypeStream(webStream, {sampleSize: 256, customDetectors: []}));
|
|
20
|
+
expectType<AnyWebReadableByteStreamWithFileType>(await fileTypeStream(webStream, {signal: AbortSignal.timeout(1000)}));
|
|
21
|
+
})();
|
|
22
|
+
|
|
23
|
+
// `FileTypeParser`: tests generic input types and options
|
|
24
|
+
(async () => {
|
|
25
|
+
const fileTypeParser = new FileTypeParser({customDetectors: [], signal: AbortSignal.timeout(1000)});
|
|
26
|
+
const fileTypeParserWithMpeg = new FileTypeParser({mpegOffsetTolerance: 10});
|
|
27
|
+
const webStream = new ReadableStream<Uint8Array>();
|
|
28
|
+
const nodeWebStream = new NodeReadableStream<Uint8Array>();
|
|
29
|
+
|
|
30
|
+
expectType<FileTypeResult | undefined>(await fileTypeParser.fromStream(webStream));
|
|
31
|
+
expectType<FileTypeResult | undefined>(await fileTypeParser.fromStream(nodeWebStream));
|
|
32
|
+
|
|
33
|
+
expectType<AnyWebReadableByteStreamWithFileType>(await fileTypeParser.toDetectionStream(webStream, {sampleSize: 256}));
|
|
34
|
+
})();
|
|
35
|
+
|
|
36
|
+
// `fileTypeFromStream`: accepts FileTypeOptions
|
|
37
|
+
(async () => {
|
|
38
|
+
const webStream = new ReadableStream<Uint8Array>();
|
|
39
|
+
expectType<FileTypeResult | undefined>(await fileTypeFromStream(webStream, {signal: AbortSignal.timeout(1000)}));
|
|
40
|
+
})();
|
|
41
|
+
|
|
42
|
+
// Test that Blob overload returns browser-specific result
|
|
43
|
+
expectType<Promise<FileTypeResultBrowser | undefined>>(fileTypeFromBlob(new Blob([])));
|
|
44
|
+
|
|
45
|
+
// `fileTypeFromFile`: accepts a file path and options
|
|
46
|
+
expectType<Promise<FileTypeResult | undefined>>(fileTypeFromFile('file.bin'));
|
|
47
|
+
expectType<Promise<FileTypeResult | undefined>>(fileTypeFromFile('file.bin', {signal: AbortSignal.timeout(1000)}));
|
|
48
|
+
|
|
49
|
+
// `FileTypeParser#fromFile`: accepts a file path
|
|
50
|
+
(async () => {
|
|
51
|
+
const fileTypeParser = new FileTypeParser();
|
|
52
|
+
expectType<Promise<FileTypeResult | undefined>>(fileTypeParser.fromFile('file.bin'));
|
|
53
|
+
})();
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export const maximumUntrustedSkipSizeInBytes = 16 * 1024 * 1024;
|
|
2
|
+
|
|
3
|
+
export class ParserHardLimitError extends Error {}
|
|
4
|
+
|
|
5
|
+
export function getSafeBound(value, maximum, reason) {
|
|
6
|
+
if (
|
|
7
|
+
!Number.isFinite(value)
|
|
8
|
+
|| value < 0
|
|
9
|
+
|| value > maximum
|
|
10
|
+
) {
|
|
11
|
+
throw new ParserHardLimitError(`${reason} has invalid size ${value} (maximum ${maximum} bytes)`);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function safeIgnore(tokenizer, length, {maximumLength = maximumUntrustedSkipSizeInBytes, reason = 'skip'} = {}) {
|
|
18
|
+
const safeLength = getSafeBound(length, maximumLength, reason);
|
|
19
|
+
await tokenizer.ignore(safeLength);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function safeReadBuffer(tokenizer, buffer, options, {maximumLength = buffer.length, reason = 'read'} = {}) {
|
|
23
|
+
const length = options?.length ?? buffer.length;
|
|
24
|
+
const safeLength = getSafeBound(length, maximumLength, reason);
|
|
25
|
+
return tokenizer.readBuffer(buffer, {
|
|
26
|
+
...options,
|
|
27
|
+
length: safeLength,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function checkBytes(buffer, headers, options) {
|
|
32
|
+
options = {
|
|
33
|
+
offset: 0,
|
|
34
|
+
...options,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
for (const [index, header] of headers.entries()) {
|
|
38
|
+
// If a bitmask is set
|
|
39
|
+
if (options.mask) {
|
|
40
|
+
// If header doesn't equal `buf` with bits masked off
|
|
41
|
+
if (header !== (options.mask[index] & buffer[index + options.offset])) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
} else if (header !== buffer[index + options.offset]) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function hasUnknownFileSize(tokenizer) {
|
|
53
|
+
const fileSize = tokenizer.fileInfo.size;
|
|
54
|
+
return (
|
|
55
|
+
!Number.isFinite(fileSize)
|
|
56
|
+
|| fileSize === Number.MAX_SAFE_INTEGER
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function hasExceededUnknownSizeScanBudget(tokenizer, startOffset, maximumBytes) {
|
|
61
|
+
return (
|
|
62
|
+
hasUnknownFileSize(tokenizer)
|
|
63
|
+
&& tokenizer.position - startOffset > maximumBytes
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// MIME media subtypes prefixed with `x-ft-` are custom and defined by us. They are neither formally registered with IANA nor based on any informal conventions.
|
|
2
|
+
|
|
1
3
|
export const extensions = [
|
|
2
4
|
'jpg',
|
|
3
5
|
'png',
|
|
@@ -179,6 +181,9 @@ export const extensions = [
|
|
|
179
181
|
'tar.gz',
|
|
180
182
|
'reg',
|
|
181
183
|
'dat',
|
|
184
|
+
'key',
|
|
185
|
+
'numbers',
|
|
186
|
+
'pages',
|
|
182
187
|
];
|
|
183
188
|
|
|
184
189
|
export const mimeTypes = [
|
|
@@ -262,7 +267,7 @@ export const mimeTypes = [
|
|
|
262
267
|
'application/x-unix-archive',
|
|
263
268
|
'application/x-rpm',
|
|
264
269
|
'application/x-compress',
|
|
265
|
-
'application/
|
|
270
|
+
'application/lzip',
|
|
266
271
|
'application/x-cfb',
|
|
267
272
|
'application/x-mie',
|
|
268
273
|
'application/mxf',
|
|
@@ -291,8 +296,8 @@ export const mimeTypes = [
|
|
|
291
296
|
'model/gltf-binary',
|
|
292
297
|
'application/vnd.tcpdump.pcap',
|
|
293
298
|
'audio/x-dsf', // Non-standard
|
|
294
|
-
'application/x
|
|
295
|
-
'application/x
|
|
299
|
+
'application/x-ms-shortcut', // Informal, used by freedesktop.org shared-mime-info
|
|
300
|
+
'application/x-ft-apple.alias',
|
|
296
301
|
'audio/x-voc',
|
|
297
302
|
'audio/vnd.dolby.dd-raw',
|
|
298
303
|
'audio/x-m4a',
|
|
@@ -332,11 +337,11 @@ export const mimeTypes = [
|
|
|
332
337
|
'application/x-ace-compressed',
|
|
333
338
|
'application/avro',
|
|
334
339
|
'application/vnd.iccprofile',
|
|
335
|
-
'application/x
|
|
340
|
+
'application/x-ft-fbx',
|
|
336
341
|
'application/vnd.visio',
|
|
337
342
|
'application/vnd.android.package-archive',
|
|
338
|
-
'application/
|
|
339
|
-
'application/x-lz4', //
|
|
343
|
+
'application/x-ft-draco',
|
|
344
|
+
'application/x-lz4', // Informal, used by freedesktop.org shared-mime-info
|
|
340
345
|
'application/vnd.openxmlformats-officedocument.presentationml.template',
|
|
341
346
|
'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
|
|
342
347
|
'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
|
|
@@ -357,4 +362,7 @@ export const mimeTypes = [
|
|
|
357
362
|
'application/x-ms-regedit',
|
|
358
363
|
'application/x-ft-windows-registry-hive',
|
|
359
364
|
'application/x-jmp-data',
|
|
365
|
+
'application/vnd.apple.keynote',
|
|
366
|
+
'application/vnd.apple.numbers',
|
|
367
|
+
'application/vnd.apple.pages',
|
|
360
368
|
];
|
|
@@ -32,7 +32,7 @@ Checks whether the TAR checksum is valid.
|
|
|
32
32
|
@returns {boolean} `true` if the TAR checksum is valid, otherwise `false`.
|
|
33
33
|
*/
|
|
34
34
|
export function tarHeaderChecksumMatches(arrayBuffer, offset = 0) {
|
|
35
|
-
const readSum = Number.parseInt(new StringType(6).get(arrayBuffer, 148).replace(/\0
|
|
35
|
+
const readSum = Number.parseInt(new StringType(6).get(arrayBuffer, 148).replace(/\0.*$/v, '').trim(), 8); // Read sum in header
|
|
36
36
|
if (Number.isNaN(readSum)) {
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
@@ -55,6 +55,6 @@ ID3 UINT32 sync-safe tokenizer token.
|
|
|
55
55
|
28 bits (representing up to 256MB) integer, the msb is 0 to avoid "false syncsignals".
|
|
56
56
|
*/
|
|
57
57
|
export const uint32SyncSafeToken = {
|
|
58
|
-
get: (buffer, offset) => (buffer[offset + 3] & 0x7F) | ((buffer[offset + 2]) << 7) | ((buffer[offset + 1]) << 14) | ((buffer[offset]) << 21),
|
|
58
|
+
get: (buffer, offset) => (buffer[offset + 3] & 0x7F) | ((buffer[offset + 2] & 0x7F) << 7) | ((buffer[offset + 1] & 0x7F) << 14) | ((buffer[offset] & 0x7F) << 21),
|
|
59
59
|
len: 4,
|
|
60
60
|
};
|
|
@@ -229,7 +229,7 @@ readBuffer(buffer: Uint8Array, options?: IReadChunkOptions): Promise<number>;
|
|
|
229
229
|
| Parameter | Type | Description |
|
|
230
230
|
|------------|----------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
231
231
|
| buffer | [Buffer](https://nodejs.org/api/buffer.html) | Uint8Array | Target buffer to write the data read to |
|
|
232
|
-
| options | [IReadChunkOptions](#ireadchunkoptions) | An integer specifying the number of bytes to read |
|
|
232
|
+
| options | [IReadChunkOptions](#ireadchunkoptions-interface) | An integer specifying the number of bytes to read |
|
|
233
233
|
|
|
234
234
|
Return promise with number of bytes read.
|
|
235
235
|
The number of bytes read may be less than requested if the `mayBeLess` flag is set.
|
|
@@ -245,7 +245,7 @@ peekBuffer(uint8Array: Uint8Array, options?: IReadChunkOptions): Promise<number>
|
|
|
245
245
|
| Parameter | Type | Description |
|
|
246
246
|
|------------|-----------------------------------------|-----------------------------------------------------|
|
|
247
247
|
| buffer | Buffer | Uint8Array | Target buffer to write the data read (peeked) to. |
|
|
248
|
-
| options | [IReadChunkOptions](#ireadchunkoptions) | An integer specifying the number of bytes to read. | |
|
|
248
|
+
| options | [IReadChunkOptions](#ireadchunkoptions-interface) | An integer specifying the number of bytes to read. | |
|
|
249
249
|
|
|
250
250
|
Return value `Promise<number>` Promise with number of bytes read. The number of bytes read may be less if the `mayBeLess` flag was set.
|
|
251
251
|
|
|
@@ -65,7 +65,7 @@ export declare abstract class AbstractTokenizer implements ITokenizer {
|
|
|
65
65
|
peekNumber(token: IToken<number>): Promise<number>;
|
|
66
66
|
/**
|
|
67
67
|
* Ignore number of bytes, advances the pointer in under tokenizer-stream.
|
|
68
|
-
* @param length - Number of bytes to ignore
|
|
68
|
+
* @param length - Number of bytes to ignore. Must be ≥ 0.
|
|
69
69
|
* @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available
|
|
70
70
|
*/
|
|
71
71
|
ignore(length: number): Promise<number>;
|
|
@@ -71,10 +71,13 @@ export class AbstractTokenizer {
|
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Ignore number of bytes, advances the pointer in under tokenizer-stream.
|
|
74
|
-
* @param length - Number of bytes to ignore
|
|
74
|
+
* @param length - Number of bytes to ignore. Must be ≥ 0.
|
|
75
75
|
* @return resolves the number of bytes ignored, equals length if this available, otherwise the number of bytes available
|
|
76
76
|
*/
|
|
77
77
|
async ignore(length) {
|
|
78
|
+
if (length < 0) {
|
|
79
|
+
throw new RangeError('ignore length must be ≥ 0 bytes');
|
|
80
|
+
}
|
|
78
81
|
if (this.fileInfo.size !== undefined) {
|
|
79
82
|
const bytesLeft = this.fileInfo.size - this.position;
|
|
80
83
|
if (length > bytesLeft) {
|
|
@@ -24,6 +24,9 @@ export declare class ReadStreamTokenizer extends AbstractTokenizer {
|
|
|
24
24
|
* @returns Promise with number of bytes peeked
|
|
25
25
|
*/
|
|
26
26
|
peekBuffer(uint8Array: Uint8Array, options?: IReadChunkOptions): Promise<number>;
|
|
27
|
+
/**
|
|
28
|
+
* @param length Number of bytes to ignore. Must be ≥ 0.
|
|
29
|
+
*/
|
|
27
30
|
ignore(length: number): Promise<number>;
|
|
28
31
|
abort(): Promise<void>;
|
|
29
32
|
close(): Promise<void>;
|
|
@@ -75,8 +75,13 @@ export class ReadStreamTokenizer extends AbstractTokenizer {
|
|
|
75
75
|
}
|
|
76
76
|
return bytesRead;
|
|
77
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* @param length Number of bytes to ignore. Must be ≥ 0.
|
|
80
|
+
*/
|
|
78
81
|
async ignore(length) {
|
|
79
|
-
|
|
82
|
+
if (length < 0) {
|
|
83
|
+
throw new RangeError('ignore length must be ≥ 0 bytes');
|
|
84
|
+
}
|
|
80
85
|
const bufSize = Math.min(maxBufferSize, length);
|
|
81
86
|
const buf = new Uint8Array(bufSize);
|
|
82
87
|
let totBytesRead = 0;
|
|
@@ -13,7 +13,7 @@ export class WebStreamByobReader extends WebStreamReader {
|
|
|
13
13
|
async readFromStream(buffer, mayBeLess) {
|
|
14
14
|
if (buffer.length === 0)
|
|
15
15
|
return 0;
|
|
16
|
-
// @ts-
|
|
16
|
+
// @ts-expect-error
|
|
17
17
|
const result = await this.reader.read(new Uint8Array(buffer.length), { min: mayBeLess ? undefined : buffer.length });
|
|
18
18
|
if (result.done) {
|
|
19
19
|
this.endOfStream = result.done;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "strtok3",
|
|
3
|
-
"version": "10.3.
|
|
3
|
+
"version": "10.3.5",
|
|
4
4
|
"description": "A promise based streaming tokenizer",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Borewit",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"repository": {
|
|
36
36
|
"type": "git",
|
|
37
|
-
"url": "https://github.com/Borewit/strtok3.git"
|
|
37
|
+
"url": "git+https://github.com/Borewit/strtok3.git"
|
|
38
38
|
},
|
|
39
39
|
"license": "MIT",
|
|
40
40
|
"type": "module",
|
|
@@ -57,21 +57,21 @@
|
|
|
57
57
|
"@tokenizer/token": "^0.3.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@biomejs/biome": "2.
|
|
60
|
+
"@biomejs/biome": "2.4.8",
|
|
61
61
|
"@types/chai": "^5.2.2",
|
|
62
62
|
"@types/chai-as-promised": "^8.0.2",
|
|
63
63
|
"@types/debug": "^4.1.12",
|
|
64
64
|
"@types/mocha": "^10.0.10",
|
|
65
65
|
"@types/node": "^24.1.0",
|
|
66
|
-
"c8": "^
|
|
66
|
+
"c8": "^11.0.0",
|
|
67
67
|
"chai": "^5.2.1",
|
|
68
|
-
"chai-as-promised": "^8.0.
|
|
69
|
-
"del-cli": "^
|
|
70
|
-
"mocha": "^11.7.
|
|
68
|
+
"chai-as-promised": "^8.0.2",
|
|
69
|
+
"del-cli": "^7.0.0",
|
|
70
|
+
"mocha": "^11.7.5",
|
|
71
71
|
"node-readable-to-web-readable-stream": "^0.4.2",
|
|
72
72
|
"remark-cli": "^12.0.1",
|
|
73
73
|
"remark-preset-lint-recommended": "^7.0.1",
|
|
74
|
-
"token-types": "^6.
|
|
74
|
+
"token-types": "^6.1.2",
|
|
75
75
|
"ts-node": "^10.9.2",
|
|
76
76
|
"typescript": "^5.8.3",
|
|
77
77
|
"uint8array-extras": "^1.4.0"
|
package/node_modules/ws/index.js
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const createWebSocketStream = require('./lib/stream');
|
|
4
|
+
const extension = require('./lib/extension');
|
|
5
|
+
const PerMessageDeflate = require('./lib/permessage-deflate');
|
|
6
|
+
const Receiver = require('./lib/receiver');
|
|
7
|
+
const Sender = require('./lib/sender');
|
|
8
|
+
const subprotocol = require('./lib/subprotocol');
|
|
3
9
|
const WebSocket = require('./lib/websocket');
|
|
10
|
+
const WebSocketServer = require('./lib/websocket-server');
|
|
4
11
|
|
|
5
|
-
WebSocket.createWebSocketStream =
|
|
6
|
-
WebSocket.
|
|
7
|
-
WebSocket.
|
|
8
|
-
WebSocket.
|
|
9
|
-
|
|
12
|
+
WebSocket.createWebSocketStream = createWebSocketStream;
|
|
13
|
+
WebSocket.extension = extension;
|
|
14
|
+
WebSocket.PerMessageDeflate = PerMessageDeflate;
|
|
15
|
+
WebSocket.Receiver = Receiver;
|
|
16
|
+
WebSocket.Sender = Sender;
|
|
17
|
+
WebSocket.Server = WebSocketServer;
|
|
18
|
+
WebSocket.subprotocol = subprotocol;
|
|
10
19
|
WebSocket.WebSocket = WebSocket;
|
|
11
|
-
WebSocket.WebSocketServer =
|
|
20
|
+
WebSocket.WebSocketServer = WebSocketServer;
|
|
12
21
|
|
|
13
22
|
module.exports = WebSocket;
|
|
@@ -37,6 +37,9 @@ class PerMessageDeflate {
|
|
|
37
37
|
* acknowledge disabling of client context takeover
|
|
38
38
|
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
|
39
39
|
* calls to zlib
|
|
40
|
+
* @param {Boolean} [options.isServer=false] Create the instance in either
|
|
41
|
+
* server or client mode
|
|
42
|
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
40
43
|
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
|
41
44
|
* use of a custom server window size
|
|
42
45
|
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
|
@@ -47,16 +50,13 @@ class PerMessageDeflate {
|
|
|
47
50
|
* deflate
|
|
48
51
|
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
|
49
52
|
* inflate
|
|
50
|
-
* @param {Boolean} [isServer=false] Create the instance in either server or
|
|
51
|
-
* client mode
|
|
52
|
-
* @param {Number} [maxPayload=0] The maximum allowed message length
|
|
53
53
|
*/
|
|
54
|
-
constructor(options
|
|
55
|
-
this._maxPayload = maxPayload | 0;
|
|
54
|
+
constructor(options) {
|
|
56
55
|
this._options = options || {};
|
|
57
56
|
this._threshold =
|
|
58
57
|
this._options.threshold !== undefined ? this._options.threshold : 1024;
|
|
59
|
-
this.
|
|
58
|
+
this._maxPayload = this._options.maxPayload | 0;
|
|
59
|
+
this._isServer = !!this._options.isServer;
|
|
60
60
|
this._deflate = null;
|
|
61
61
|
this._inflate = null;
|
|
62
62
|
|
|
@@ -293,11 +293,11 @@ class WebSocketServer extends EventEmitter {
|
|
|
293
293
|
this.options.perMessageDeflate &&
|
|
294
294
|
secWebSocketExtensions !== undefined
|
|
295
295
|
) {
|
|
296
|
-
const perMessageDeflate = new PerMessageDeflate(
|
|
297
|
-
this.options.perMessageDeflate,
|
|
298
|
-
true,
|
|
299
|
-
this.options.maxPayload
|
|
300
|
-
);
|
|
296
|
+
const perMessageDeflate = new PerMessageDeflate({
|
|
297
|
+
...this.options.perMessageDeflate,
|
|
298
|
+
isServer: true,
|
|
299
|
+
maxPayload: this.options.maxPayload
|
|
300
|
+
});
|
|
301
301
|
|
|
302
302
|
try {
|
|
303
303
|
const offers = extension.parse(secWebSocketExtensions);
|
|
@@ -693,7 +693,7 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
693
693
|
} else {
|
|
694
694
|
try {
|
|
695
695
|
parsedUrl = new URL(address);
|
|
696
|
-
} catch
|
|
696
|
+
} catch {
|
|
697
697
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
698
698
|
}
|
|
699
699
|
}
|
|
@@ -755,11 +755,11 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
755
755
|
opts.timeout = opts.handshakeTimeout;
|
|
756
756
|
|
|
757
757
|
if (opts.perMessageDeflate) {
|
|
758
|
-
perMessageDeflate = new PerMessageDeflate(
|
|
759
|
-
opts.perMessageDeflate
|
|
760
|
-
false,
|
|
761
|
-
opts.maxPayload
|
|
762
|
-
);
|
|
758
|
+
perMessageDeflate = new PerMessageDeflate({
|
|
759
|
+
...opts.perMessageDeflate,
|
|
760
|
+
isServer: false,
|
|
761
|
+
maxPayload: opts.maxPayload
|
|
762
|
+
});
|
|
763
763
|
opts.headers['Sec-WebSocket-Extensions'] = format({
|
|
764
764
|
[PerMessageDeflate.extensionName]: perMessageDeflate.offer()
|
|
765
765
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ws",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.20.0",
|
|
4
4
|
"description": "Simple to use, blazing fast and thoroughly tested websocket client and server for Node.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"HyBi",
|
|
@@ -55,12 +55,13 @@
|
|
|
55
55
|
}
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
+
"@eslint/js": "^10.0.1",
|
|
58
59
|
"benchmark": "^2.1.4",
|
|
59
60
|
"bufferutil": "^4.0.1",
|
|
60
|
-
"eslint": "^
|
|
61
|
+
"eslint": "^10.0.1",
|
|
61
62
|
"eslint-config-prettier": "^10.0.1",
|
|
62
63
|
"eslint-plugin-prettier": "^5.0.0",
|
|
63
|
-
"globals": "^
|
|
64
|
+
"globals": "^17.0.0",
|
|
64
65
|
"mocha": "^8.4.0",
|
|
65
66
|
"nyc": "^15.0.0",
|
|
66
67
|
"prettier": "^3.0.0",
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
import createWebSocketStream from './lib/stream.js';
|
|
2
|
+
import extension from './lib/extension.js';
|
|
3
|
+
import PerMessageDeflate from './lib/permessage-deflate.js';
|
|
2
4
|
import Receiver from './lib/receiver.js';
|
|
3
5
|
import Sender from './lib/sender.js';
|
|
6
|
+
import subprotocol from './lib/subprotocol.js';
|
|
4
7
|
import WebSocket from './lib/websocket.js';
|
|
5
8
|
import WebSocketServer from './lib/websocket-server.js';
|
|
6
9
|
|
|
7
|
-
export {
|
|
10
|
+
export {
|
|
11
|
+
createWebSocketStream,
|
|
12
|
+
extension,
|
|
13
|
+
PerMessageDeflate,
|
|
14
|
+
Receiver,
|
|
15
|
+
Sender,
|
|
16
|
+
subprotocol,
|
|
17
|
+
WebSocket,
|
|
18
|
+
WebSocketServer
|
|
19
|
+
};
|
|
20
|
+
|
|
8
21
|
export default WebSocket;
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"llonebot-dist","version":"7.11.
|
|
1
|
+
{"name":"llonebot-dist","version":"7.11.2","type":"module","description":"","main":"llbot.js","author":"linyuchen","repository":{"type":"git","url":"https://github.com/LLOneBot/LuckyLilliaBot"}}
|