byterover-cli 2.3.1 → 2.3.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.
- package/dist/agent/infra/llm/generators/ai-sdk-content-generator.d.ts +8 -0
- package/dist/agent/infra/llm/generators/ai-sdk-content-generator.js +39 -1
- package/dist/server/core/domain/errors/task-error.js +21 -1
- package/dist/server/utils/error-helpers.js +9 -1
- package/node_modules/@campfirein/brv-transport-client/package.json +1 -1
- package/node_modules/{socket.io-parser/node_modules/debug → debug}/package.json +7 -3
- package/node_modules/{socket.io-parser/node_modules/debug → debug}/src/browser.js +2 -1
- package/node_modules/{socket.io-client/node_modules/debug → debug}/src/common.js +57 -39
- package/node_modules/socket.io-client/build/cjs/index.d.ts +2 -2
- package/node_modules/socket.io-client/build/cjs/socket.js +2 -3
- package/node_modules/socket.io-client/build/esm/index.d.ts +2 -2
- package/node_modules/socket.io-client/build/esm/package.json +1 -1
- package/node_modules/socket.io-client/build/esm/socket.js +1 -3
- package/node_modules/socket.io-client/build/esm-debug/index.d.ts +2 -2
- package/node_modules/socket.io-client/build/esm-debug/package.json +1 -1
- package/node_modules/socket.io-client/build/esm-debug/socket.js +2 -3
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js +3 -3
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +1 -1
- package/node_modules/socket.io-client/dist/socket.io.js +89 -42
- package/node_modules/socket.io-client/dist/socket.io.js.map +1 -1
- package/node_modules/socket.io-client/dist/socket.io.min.js +3 -3
- package/node_modules/socket.io-client/dist/socket.io.min.js.map +1 -1
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +3 -3
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +1 -1
- package/node_modules/socket.io-client/package.json +3 -3
- package/node_modules/socket.io-parser/LICENSE +1 -1
- package/node_modules/socket.io-parser/build/cjs/binary.js +2 -3
- package/node_modules/socket.io-parser/build/cjs/index.d.ts +15 -4
- package/node_modules/socket.io-parser/build/cjs/index.js +62 -16
- package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +1 -1
- package/node_modules/socket.io-parser/build/cjs/is-binary.js +2 -3
- package/node_modules/socket.io-parser/build/esm/index.d.ts +15 -4
- package/node_modules/socket.io-parser/build/esm/index.js +60 -15
- package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +1 -1
- package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +15 -4
- package/node_modules/socket.io-parser/build/esm-debug/index.js +60 -15
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +1 -1
- package/node_modules/socket.io-parser/package.json +8 -22
- package/oclif.manifest.json +99 -99
- package/package.json +1 -3
- package/node_modules/socket.io-client/node_modules/debug/package.json +0 -60
- package/node_modules/socket.io-client/node_modules/debug/src/browser.js +0 -271
- package/node_modules/socket.io-parser/node_modules/debug/LICENSE +0 -20
- package/node_modules/socket.io-parser/node_modules/debug/README.md +0 -481
- package/node_modules/socket.io-parser/node_modules/debug/src/common.js +0 -274
- package/node_modules/socket.io-parser/node_modules/debug/src/index.js +0 -10
- package/node_modules/socket.io-parser/node_modules/debug/src/node.js +0 -263
- /package/node_modules/{socket.io-client/node_modules/debug → debug}/LICENSE +0 -0
- /package/node_modules/{socket.io-client/node_modules/debug → debug}/README.md +0 -0
- /package/node_modules/{socket.io-client/node_modules/debug → debug}/src/index.js +0 -0
- /package/node_modules/{socket.io-client/node_modules/debug → debug}/src/node.js +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "socket.io-client",
|
|
3
|
-
"version": "4.8.
|
|
3
|
+
"version": "4.8.3",
|
|
4
4
|
"description": "Realtime application framework client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"realtime",
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
"types": "./build/esm/index.d.ts",
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@socket.io/component-emitter": "~3.1.0",
|
|
49
|
-
"debug": "~4.
|
|
49
|
+
"debug": "~4.4.1",
|
|
50
50
|
"engine.io-client": "~6.6.1",
|
|
51
51
|
"socket.io-parser": "~4.2.4"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"compile": "rimraf ./build && tsc && tsc -p tsconfig.esm.json && ./postcompile.sh",
|
|
55
55
|
"test": "npm run format:check && npm run compile && if test \"$BROWSERS\" = \"1\" ; then npm run test:browser; else npm run test:node; fi",
|
|
56
|
-
"test:node": "mocha --
|
|
56
|
+
"test:node": "mocha --import=tsx --require test/support/hooks.ts --exit test/index.ts",
|
|
57
57
|
"test:browser": "ts-node test/browser-runner.ts",
|
|
58
58
|
"test:types": "tsd",
|
|
59
59
|
"build": "rollup -c support/rollup.config.umd.js && rollup -c support/rollup.config.esm.js && rollup -c support/rollup.config.umd.msgpack.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(The MIT License)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2014 Guillermo Rauch
|
|
3
|
+
Copyright (c) 2014-present Guillermo Rauch and Socket.IO contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
6
|
this software and associated documentation files (the 'Software'), to deal in
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.deconstructPacket = deconstructPacket;
|
|
4
|
+
exports.reconstructPacket = reconstructPacket;
|
|
4
5
|
const is_binary_js_1 = require("./is-binary.js");
|
|
5
6
|
/**
|
|
6
7
|
* Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder.
|
|
@@ -17,7 +18,6 @@ function deconstructPacket(packet) {
|
|
|
17
18
|
pack.attachments = buffers.length; // number of binary 'attachments'
|
|
18
19
|
return { packet: pack, buffers: buffers };
|
|
19
20
|
}
|
|
20
|
-
exports.deconstructPacket = deconstructPacket;
|
|
21
21
|
function _deconstructPacket(data, buffers) {
|
|
22
22
|
if (!data)
|
|
23
23
|
return data;
|
|
@@ -57,7 +57,6 @@ function reconstructPacket(packet, buffers) {
|
|
|
57
57
|
delete packet.attachments; // no longer useful
|
|
58
58
|
return packet;
|
|
59
59
|
}
|
|
60
|
-
exports.reconstructPacket = reconstructPacket;
|
|
61
60
|
function _reconstructPacket(data, buffers) {
|
|
62
61
|
if (!data)
|
|
63
62
|
return data;
|
|
@@ -53,20 +53,30 @@ export declare class Encoder {
|
|
|
53
53
|
interface DecoderReservedEvents {
|
|
54
54
|
decoded: (packet: Packet) => void;
|
|
55
55
|
}
|
|
56
|
+
type JSONReviver = (this: any, key: string, value: any) => any;
|
|
57
|
+
export interface DecoderOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Custom reviver to pass down to JSON.parse()
|
|
60
|
+
*/
|
|
61
|
+
reviver?: JSONReviver;
|
|
62
|
+
/**
|
|
63
|
+
* Maximum number of binary attachments per packet
|
|
64
|
+
* @default 10
|
|
65
|
+
*/
|
|
66
|
+
maxAttachments?: number;
|
|
67
|
+
}
|
|
56
68
|
/**
|
|
57
69
|
* A socket.io Decoder instance
|
|
58
70
|
*
|
|
59
71
|
* @return {Object} decoder
|
|
60
72
|
*/
|
|
61
73
|
export declare class Decoder extends Emitter<{}, {}, DecoderReservedEvents> {
|
|
62
|
-
private reviver?;
|
|
63
74
|
private reconstructor;
|
|
75
|
+
private opts;
|
|
64
76
|
/**
|
|
65
77
|
* Decoder constructor
|
|
66
|
-
*
|
|
67
|
-
* @param {function} reviver - custom reviver to pass down to JSON.stringify
|
|
68
78
|
*/
|
|
69
|
-
constructor(
|
|
79
|
+
constructor(opts?: DecoderOptions | JSONReviver);
|
|
70
80
|
/**
|
|
71
81
|
* Decodes an encoded packet string into packet JSON.
|
|
72
82
|
*
|
|
@@ -87,4 +97,5 @@ export declare class Decoder extends Emitter<{}, {}, DecoderReservedEvents> {
|
|
|
87
97
|
*/
|
|
88
98
|
destroy(): void;
|
|
89
99
|
}
|
|
100
|
+
export declare function isPacketValid(packet: Packet): boolean;
|
|
90
101
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0;
|
|
4
|
+
exports.isPacketValid = isPacketValid;
|
|
4
5
|
const component_emitter_1 = require("@socket.io/component-emitter");
|
|
5
6
|
const binary_js_1 = require("./binary.js");
|
|
6
7
|
const is_binary_js_1 = require("./is-binary.js");
|
|
@@ -10,11 +11,11 @@ const debug = (0, debug_1.default)("socket.io-parser"); // debug()
|
|
|
10
11
|
* These strings must not be used as event names, as they have a special meaning.
|
|
11
12
|
*/
|
|
12
13
|
const RESERVED_EVENTS = [
|
|
13
|
-
"connect",
|
|
14
|
-
"connect_error",
|
|
15
|
-
"disconnect",
|
|
16
|
-
"disconnecting",
|
|
17
|
-
"newListener",
|
|
14
|
+
"connect", // used on the client side
|
|
15
|
+
"connect_error", // used on the client side
|
|
16
|
+
"disconnect", // used on both sides
|
|
17
|
+
"disconnecting", // used on the server side
|
|
18
|
+
"newListener", // used by the Node.js EventEmitter
|
|
18
19
|
"removeListener", // used by the Node.js EventEmitter
|
|
19
20
|
];
|
|
20
21
|
/**
|
|
@@ -32,7 +33,7 @@ var PacketType;
|
|
|
32
33
|
PacketType[PacketType["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
|
|
33
34
|
PacketType[PacketType["BINARY_EVENT"] = 5] = "BINARY_EVENT";
|
|
34
35
|
PacketType[PacketType["BINARY_ACK"] = 6] = "BINARY_ACK";
|
|
35
|
-
})(PacketType
|
|
36
|
+
})(PacketType || (exports.PacketType = PacketType = {}));
|
|
36
37
|
/**
|
|
37
38
|
* A socket.io Encoder instance
|
|
38
39
|
*/
|
|
@@ -108,10 +109,6 @@ class Encoder {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
exports.Encoder = Encoder;
|
|
111
|
-
// see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
|
|
112
|
-
function isObject(value) {
|
|
113
|
-
return Object.prototype.toString.call(value) === "[object Object]";
|
|
114
|
-
}
|
|
115
112
|
/**
|
|
116
113
|
* A socket.io Decoder instance
|
|
117
114
|
*
|
|
@@ -120,12 +117,13 @@ function isObject(value) {
|
|
|
120
117
|
class Decoder extends component_emitter_1.Emitter {
|
|
121
118
|
/**
|
|
122
119
|
* Decoder constructor
|
|
123
|
-
*
|
|
124
|
-
* @param {function} reviver - custom reviver to pass down to JSON.stringify
|
|
125
120
|
*/
|
|
126
|
-
constructor(
|
|
121
|
+
constructor(opts) {
|
|
127
122
|
super();
|
|
128
|
-
this.
|
|
123
|
+
this.opts = Object.assign({
|
|
124
|
+
reviver: undefined,
|
|
125
|
+
maxAttachments: 10,
|
|
126
|
+
}, typeof opts === "function" ? { reviver: opts } : opts);
|
|
129
127
|
}
|
|
130
128
|
/**
|
|
131
129
|
* Decodes an encoded packet string into packet JSON.
|
|
@@ -196,7 +194,14 @@ class Decoder extends component_emitter_1.Emitter {
|
|
|
196
194
|
if (buf != Number(buf) || str.charAt(i) !== "-") {
|
|
197
195
|
throw new Error("Illegal attachments");
|
|
198
196
|
}
|
|
199
|
-
|
|
197
|
+
const n = Number(buf);
|
|
198
|
+
if (!isInteger(n) || n < 0) {
|
|
199
|
+
throw new Error("Illegal attachments");
|
|
200
|
+
}
|
|
201
|
+
else if (n > this.opts.maxAttachments) {
|
|
202
|
+
throw new Error("too many attachments");
|
|
203
|
+
}
|
|
204
|
+
p.attachments = n;
|
|
200
205
|
}
|
|
201
206
|
// look up namespace (if any)
|
|
202
207
|
if ("/" === str.charAt(i + 1)) {
|
|
@@ -243,7 +248,7 @@ class Decoder extends component_emitter_1.Emitter {
|
|
|
243
248
|
}
|
|
244
249
|
tryParse(str) {
|
|
245
250
|
try {
|
|
246
|
-
return JSON.parse(str, this.reviver);
|
|
251
|
+
return JSON.parse(str, this.opts.reviver);
|
|
247
252
|
}
|
|
248
253
|
catch (e) {
|
|
249
254
|
return false;
|
|
@@ -319,3 +324,44 @@ class BinaryReconstructor {
|
|
|
319
324
|
this.buffers = [];
|
|
320
325
|
}
|
|
321
326
|
}
|
|
327
|
+
function isNamespaceValid(nsp) {
|
|
328
|
+
return typeof nsp === "string";
|
|
329
|
+
}
|
|
330
|
+
// see https://caniuse.com/mdn-javascript_builtins_number_isinteger
|
|
331
|
+
const isInteger = Number.isInteger ||
|
|
332
|
+
function (value) {
|
|
333
|
+
return (typeof value === "number" &&
|
|
334
|
+
isFinite(value) &&
|
|
335
|
+
Math.floor(value) === value);
|
|
336
|
+
};
|
|
337
|
+
function isAckIdValid(id) {
|
|
338
|
+
return id === undefined || isInteger(id);
|
|
339
|
+
}
|
|
340
|
+
// see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
|
|
341
|
+
function isObject(value) {
|
|
342
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
343
|
+
}
|
|
344
|
+
function isDataValid(type, payload) {
|
|
345
|
+
switch (type) {
|
|
346
|
+
case PacketType.CONNECT:
|
|
347
|
+
return payload === undefined || isObject(payload);
|
|
348
|
+
case PacketType.DISCONNECT:
|
|
349
|
+
return payload === undefined;
|
|
350
|
+
case PacketType.EVENT:
|
|
351
|
+
return (Array.isArray(payload) &&
|
|
352
|
+
(typeof payload[0] === "number" ||
|
|
353
|
+
(typeof payload[0] === "string" &&
|
|
354
|
+
RESERVED_EVENTS.indexOf(payload[0]) === -1)));
|
|
355
|
+
case PacketType.ACK:
|
|
356
|
+
return Array.isArray(payload);
|
|
357
|
+
case PacketType.CONNECT_ERROR:
|
|
358
|
+
return typeof payload === "string" || isObject(payload);
|
|
359
|
+
default:
|
|
360
|
+
return false;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
function isPacketValid(packet) {
|
|
364
|
+
return (isNamespaceValid(packet.nsp) &&
|
|
365
|
+
isAckIdValid(packet.id) &&
|
|
366
|
+
isDataValid(packet.type, packet.data));
|
|
367
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isBinary = isBinary;
|
|
4
|
+
exports.hasBinary = hasBinary;
|
|
4
5
|
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
|
|
5
6
|
const isView = (obj) => {
|
|
6
7
|
return typeof ArrayBuffer.isView === "function"
|
|
@@ -24,7 +25,6 @@ function isBinary(obj) {
|
|
|
24
25
|
(withNativeBlob && obj instanceof Blob) ||
|
|
25
26
|
(withNativeFile && obj instanceof File));
|
|
26
27
|
}
|
|
27
|
-
exports.isBinary = isBinary;
|
|
28
28
|
function hasBinary(obj, toJSON) {
|
|
29
29
|
if (!obj || typeof obj !== "object") {
|
|
30
30
|
return false;
|
|
@@ -52,4 +52,3 @@ function hasBinary(obj, toJSON) {
|
|
|
52
52
|
}
|
|
53
53
|
return false;
|
|
54
54
|
}
|
|
55
|
-
exports.hasBinary = hasBinary;
|
|
@@ -53,20 +53,30 @@ export declare class Encoder {
|
|
|
53
53
|
interface DecoderReservedEvents {
|
|
54
54
|
decoded: (packet: Packet) => void;
|
|
55
55
|
}
|
|
56
|
+
type JSONReviver = (this: any, key: string, value: any) => any;
|
|
57
|
+
export interface DecoderOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Custom reviver to pass down to JSON.parse()
|
|
60
|
+
*/
|
|
61
|
+
reviver?: JSONReviver;
|
|
62
|
+
/**
|
|
63
|
+
* Maximum number of binary attachments per packet
|
|
64
|
+
* @default 10
|
|
65
|
+
*/
|
|
66
|
+
maxAttachments?: number;
|
|
67
|
+
}
|
|
56
68
|
/**
|
|
57
69
|
* A socket.io Decoder instance
|
|
58
70
|
*
|
|
59
71
|
* @return {Object} decoder
|
|
60
72
|
*/
|
|
61
73
|
export declare class Decoder extends Emitter<{}, {}, DecoderReservedEvents> {
|
|
62
|
-
private reviver?;
|
|
63
74
|
private reconstructor;
|
|
75
|
+
private opts;
|
|
64
76
|
/**
|
|
65
77
|
* Decoder constructor
|
|
66
|
-
*
|
|
67
|
-
* @param {function} reviver - custom reviver to pass down to JSON.stringify
|
|
68
78
|
*/
|
|
69
|
-
constructor(
|
|
79
|
+
constructor(opts?: DecoderOptions | JSONReviver);
|
|
70
80
|
/**
|
|
71
81
|
* Decodes an encoded packet string into packet JSON.
|
|
72
82
|
*
|
|
@@ -87,4 +97,5 @@ export declare class Decoder extends Emitter<{}, {}, DecoderReservedEvents> {
|
|
|
87
97
|
*/
|
|
88
98
|
destroy(): void;
|
|
89
99
|
}
|
|
100
|
+
export declare function isPacketValid(packet: Packet): boolean;
|
|
90
101
|
export {};
|
|
@@ -5,11 +5,11 @@ import { isBinary, hasBinary } from "./is-binary.js";
|
|
|
5
5
|
* These strings must not be used as event names, as they have a special meaning.
|
|
6
6
|
*/
|
|
7
7
|
const RESERVED_EVENTS = [
|
|
8
|
-
"connect",
|
|
9
|
-
"connect_error",
|
|
10
|
-
"disconnect",
|
|
11
|
-
"disconnecting",
|
|
12
|
-
"newListener",
|
|
8
|
+
"connect", // used on the client side
|
|
9
|
+
"connect_error", // used on the client side
|
|
10
|
+
"disconnect", // used on both sides
|
|
11
|
+
"disconnecting", // used on the server side
|
|
12
|
+
"newListener", // used by the Node.js EventEmitter
|
|
13
13
|
"removeListener", // used by the Node.js EventEmitter
|
|
14
14
|
];
|
|
15
15
|
/**
|
|
@@ -100,10 +100,6 @@ export class Encoder {
|
|
|
100
100
|
return buffers; // write all the buffers
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
// see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
|
|
104
|
-
function isObject(value) {
|
|
105
|
-
return Object.prototype.toString.call(value) === "[object Object]";
|
|
106
|
-
}
|
|
107
103
|
/**
|
|
108
104
|
* A socket.io Decoder instance
|
|
109
105
|
*
|
|
@@ -112,12 +108,13 @@ function isObject(value) {
|
|
|
112
108
|
export class Decoder extends Emitter {
|
|
113
109
|
/**
|
|
114
110
|
* Decoder constructor
|
|
115
|
-
*
|
|
116
|
-
* @param {function} reviver - custom reviver to pass down to JSON.stringify
|
|
117
111
|
*/
|
|
118
|
-
constructor(
|
|
112
|
+
constructor(opts) {
|
|
119
113
|
super();
|
|
120
|
-
this.
|
|
114
|
+
this.opts = Object.assign({
|
|
115
|
+
reviver: undefined,
|
|
116
|
+
maxAttachments: 10,
|
|
117
|
+
}, typeof opts === "function" ? { reviver: opts } : opts);
|
|
121
118
|
}
|
|
122
119
|
/**
|
|
123
120
|
* Decodes an encoded packet string into packet JSON.
|
|
@@ -188,7 +185,14 @@ export class Decoder extends Emitter {
|
|
|
188
185
|
if (buf != Number(buf) || str.charAt(i) !== "-") {
|
|
189
186
|
throw new Error("Illegal attachments");
|
|
190
187
|
}
|
|
191
|
-
|
|
188
|
+
const n = Number(buf);
|
|
189
|
+
if (!isInteger(n) || n < 0) {
|
|
190
|
+
throw new Error("Illegal attachments");
|
|
191
|
+
}
|
|
192
|
+
else if (n > this.opts.maxAttachments) {
|
|
193
|
+
throw new Error("too many attachments");
|
|
194
|
+
}
|
|
195
|
+
p.attachments = n;
|
|
192
196
|
}
|
|
193
197
|
// look up namespace (if any)
|
|
194
198
|
if ("/" === str.charAt(i + 1)) {
|
|
@@ -234,7 +238,7 @@ export class Decoder extends Emitter {
|
|
|
234
238
|
}
|
|
235
239
|
tryParse(str) {
|
|
236
240
|
try {
|
|
237
|
-
return JSON.parse(str, this.reviver);
|
|
241
|
+
return JSON.parse(str, this.opts.reviver);
|
|
238
242
|
}
|
|
239
243
|
catch (e) {
|
|
240
244
|
return false;
|
|
@@ -309,3 +313,44 @@ class BinaryReconstructor {
|
|
|
309
313
|
this.buffers = [];
|
|
310
314
|
}
|
|
311
315
|
}
|
|
316
|
+
function isNamespaceValid(nsp) {
|
|
317
|
+
return typeof nsp === "string";
|
|
318
|
+
}
|
|
319
|
+
// see https://caniuse.com/mdn-javascript_builtins_number_isinteger
|
|
320
|
+
const isInteger = Number.isInteger ||
|
|
321
|
+
function (value) {
|
|
322
|
+
return (typeof value === "number" &&
|
|
323
|
+
isFinite(value) &&
|
|
324
|
+
Math.floor(value) === value);
|
|
325
|
+
};
|
|
326
|
+
function isAckIdValid(id) {
|
|
327
|
+
return id === undefined || isInteger(id);
|
|
328
|
+
}
|
|
329
|
+
// see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
|
|
330
|
+
function isObject(value) {
|
|
331
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
332
|
+
}
|
|
333
|
+
function isDataValid(type, payload) {
|
|
334
|
+
switch (type) {
|
|
335
|
+
case PacketType.CONNECT:
|
|
336
|
+
return payload === undefined || isObject(payload);
|
|
337
|
+
case PacketType.DISCONNECT:
|
|
338
|
+
return payload === undefined;
|
|
339
|
+
case PacketType.EVENT:
|
|
340
|
+
return (Array.isArray(payload) &&
|
|
341
|
+
(typeof payload[0] === "number" ||
|
|
342
|
+
(typeof payload[0] === "string" &&
|
|
343
|
+
RESERVED_EVENTS.indexOf(payload[0]) === -1)));
|
|
344
|
+
case PacketType.ACK:
|
|
345
|
+
return Array.isArray(payload);
|
|
346
|
+
case PacketType.CONNECT_ERROR:
|
|
347
|
+
return typeof payload === "string" || isObject(payload);
|
|
348
|
+
default:
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
export function isPacketValid(packet) {
|
|
353
|
+
return (isNamespaceValid(packet.nsp) &&
|
|
354
|
+
isAckIdValid(packet.id) &&
|
|
355
|
+
isDataValid(packet.type, packet.data));
|
|
356
|
+
}
|
|
@@ -53,20 +53,30 @@ export declare class Encoder {
|
|
|
53
53
|
interface DecoderReservedEvents {
|
|
54
54
|
decoded: (packet: Packet) => void;
|
|
55
55
|
}
|
|
56
|
+
type JSONReviver = (this: any, key: string, value: any) => any;
|
|
57
|
+
export interface DecoderOptions {
|
|
58
|
+
/**
|
|
59
|
+
* Custom reviver to pass down to JSON.parse()
|
|
60
|
+
*/
|
|
61
|
+
reviver?: JSONReviver;
|
|
62
|
+
/**
|
|
63
|
+
* Maximum number of binary attachments per packet
|
|
64
|
+
* @default 10
|
|
65
|
+
*/
|
|
66
|
+
maxAttachments?: number;
|
|
67
|
+
}
|
|
56
68
|
/**
|
|
57
69
|
* A socket.io Decoder instance
|
|
58
70
|
*
|
|
59
71
|
* @return {Object} decoder
|
|
60
72
|
*/
|
|
61
73
|
export declare class Decoder extends Emitter<{}, {}, DecoderReservedEvents> {
|
|
62
|
-
private reviver?;
|
|
63
74
|
private reconstructor;
|
|
75
|
+
private opts;
|
|
64
76
|
/**
|
|
65
77
|
* Decoder constructor
|
|
66
|
-
*
|
|
67
|
-
* @param {function} reviver - custom reviver to pass down to JSON.stringify
|
|
68
78
|
*/
|
|
69
|
-
constructor(
|
|
79
|
+
constructor(opts?: DecoderOptions | JSONReviver);
|
|
70
80
|
/**
|
|
71
81
|
* Decodes an encoded packet string into packet JSON.
|
|
72
82
|
*
|
|
@@ -87,4 +97,5 @@ export declare class Decoder extends Emitter<{}, {}, DecoderReservedEvents> {
|
|
|
87
97
|
*/
|
|
88
98
|
destroy(): void;
|
|
89
99
|
}
|
|
100
|
+
export declare function isPacketValid(packet: Packet): boolean;
|
|
90
101
|
export {};
|
|
@@ -7,11 +7,11 @@ const debug = debugModule("socket.io-parser"); // debug()
|
|
|
7
7
|
* These strings must not be used as event names, as they have a special meaning.
|
|
8
8
|
*/
|
|
9
9
|
const RESERVED_EVENTS = [
|
|
10
|
-
"connect",
|
|
11
|
-
"connect_error",
|
|
12
|
-
"disconnect",
|
|
13
|
-
"disconnecting",
|
|
14
|
-
"newListener",
|
|
10
|
+
"connect", // used on the client side
|
|
11
|
+
"connect_error", // used on the client side
|
|
12
|
+
"disconnect", // used on both sides
|
|
13
|
+
"disconnecting", // used on the server side
|
|
14
|
+
"newListener", // used by the Node.js EventEmitter
|
|
15
15
|
"removeListener", // used by the Node.js EventEmitter
|
|
16
16
|
];
|
|
17
17
|
/**
|
|
@@ -104,10 +104,6 @@ export class Encoder {
|
|
|
104
104
|
return buffers; // write all the buffers
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
// see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
|
|
108
|
-
function isObject(value) {
|
|
109
|
-
return Object.prototype.toString.call(value) === "[object Object]";
|
|
110
|
-
}
|
|
111
107
|
/**
|
|
112
108
|
* A socket.io Decoder instance
|
|
113
109
|
*
|
|
@@ -116,12 +112,13 @@ function isObject(value) {
|
|
|
116
112
|
export class Decoder extends Emitter {
|
|
117
113
|
/**
|
|
118
114
|
* Decoder constructor
|
|
119
|
-
*
|
|
120
|
-
* @param {function} reviver - custom reviver to pass down to JSON.stringify
|
|
121
115
|
*/
|
|
122
|
-
constructor(
|
|
116
|
+
constructor(opts) {
|
|
123
117
|
super();
|
|
124
|
-
this.
|
|
118
|
+
this.opts = Object.assign({
|
|
119
|
+
reviver: undefined,
|
|
120
|
+
maxAttachments: 10,
|
|
121
|
+
}, typeof opts === "function" ? { reviver: opts } : opts);
|
|
125
122
|
}
|
|
126
123
|
/**
|
|
127
124
|
* Decodes an encoded packet string into packet JSON.
|
|
@@ -192,7 +189,14 @@ export class Decoder extends Emitter {
|
|
|
192
189
|
if (buf != Number(buf) || str.charAt(i) !== "-") {
|
|
193
190
|
throw new Error("Illegal attachments");
|
|
194
191
|
}
|
|
195
|
-
|
|
192
|
+
const n = Number(buf);
|
|
193
|
+
if (!isInteger(n) || n < 0) {
|
|
194
|
+
throw new Error("Illegal attachments");
|
|
195
|
+
}
|
|
196
|
+
else if (n > this.opts.maxAttachments) {
|
|
197
|
+
throw new Error("too many attachments");
|
|
198
|
+
}
|
|
199
|
+
p.attachments = n;
|
|
196
200
|
}
|
|
197
201
|
// look up namespace (if any)
|
|
198
202
|
if ("/" === str.charAt(i + 1)) {
|
|
@@ -239,7 +243,7 @@ export class Decoder extends Emitter {
|
|
|
239
243
|
}
|
|
240
244
|
tryParse(str) {
|
|
241
245
|
try {
|
|
242
|
-
return JSON.parse(str, this.reviver);
|
|
246
|
+
return JSON.parse(str, this.opts.reviver);
|
|
243
247
|
}
|
|
244
248
|
catch (e) {
|
|
245
249
|
return false;
|
|
@@ -314,3 +318,44 @@ class BinaryReconstructor {
|
|
|
314
318
|
this.buffers = [];
|
|
315
319
|
}
|
|
316
320
|
}
|
|
321
|
+
function isNamespaceValid(nsp) {
|
|
322
|
+
return typeof nsp === "string";
|
|
323
|
+
}
|
|
324
|
+
// see https://caniuse.com/mdn-javascript_builtins_number_isinteger
|
|
325
|
+
const isInteger = Number.isInteger ||
|
|
326
|
+
function (value) {
|
|
327
|
+
return (typeof value === "number" &&
|
|
328
|
+
isFinite(value) &&
|
|
329
|
+
Math.floor(value) === value);
|
|
330
|
+
};
|
|
331
|
+
function isAckIdValid(id) {
|
|
332
|
+
return id === undefined || isInteger(id);
|
|
333
|
+
}
|
|
334
|
+
// see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
|
|
335
|
+
function isObject(value) {
|
|
336
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
337
|
+
}
|
|
338
|
+
function isDataValid(type, payload) {
|
|
339
|
+
switch (type) {
|
|
340
|
+
case PacketType.CONNECT:
|
|
341
|
+
return payload === undefined || isObject(payload);
|
|
342
|
+
case PacketType.DISCONNECT:
|
|
343
|
+
return payload === undefined;
|
|
344
|
+
case PacketType.EVENT:
|
|
345
|
+
return (Array.isArray(payload) &&
|
|
346
|
+
(typeof payload[0] === "number" ||
|
|
347
|
+
(typeof payload[0] === "string" &&
|
|
348
|
+
RESERVED_EVENTS.indexOf(payload[0]) === -1)));
|
|
349
|
+
case PacketType.ACK:
|
|
350
|
+
return Array.isArray(payload);
|
|
351
|
+
case PacketType.CONNECT_ERROR:
|
|
352
|
+
return typeof payload === "string" || isObject(payload);
|
|
353
|
+
default:
|
|
354
|
+
return false;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
export function isPacketValid(packet) {
|
|
358
|
+
return (isNamespaceValid(packet.nsp) &&
|
|
359
|
+
isAckIdValid(packet.id) &&
|
|
360
|
+
isDataValid(packet.type, packet.data));
|
|
361
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "socket.io-parser",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.6",
|
|
4
4
|
"description": "socket.io protocol parser",
|
|
5
|
+
"homepage": "https://github.com/socketio/socket.io/tree/main/packages/socket.io-client#readme",
|
|
5
6
|
"repository": {
|
|
6
7
|
"type": "git",
|
|
7
|
-
"url": "https://github.com/socketio/socket.io
|
|
8
|
+
"url": "git+https://github.com/socketio/socket.io.git"
|
|
9
|
+
},
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/socketio/socket.io/issues"
|
|
8
12
|
},
|
|
9
13
|
"files": [
|
|
10
14
|
"build/"
|
|
@@ -15,32 +19,14 @@
|
|
|
15
19
|
"exports": {
|
|
16
20
|
"import": {
|
|
17
21
|
"node": "./build/esm-debug/index.js",
|
|
22
|
+
"development": "./build/esm-debug/index.js",
|
|
18
23
|
"default": "./build/esm/index.js"
|
|
19
24
|
},
|
|
20
25
|
"require": "./build/cjs/index.js"
|
|
21
26
|
},
|
|
22
27
|
"dependencies": {
|
|
23
28
|
"@socket.io/component-emitter": "~3.1.0",
|
|
24
|
-
"debug": "~4.
|
|
25
|
-
},
|
|
26
|
-
"devDependencies": {
|
|
27
|
-
"@babel/core": "~7.9.6",
|
|
28
|
-
"@babel/preset-env": "~7.9.6",
|
|
29
|
-
"@babel/register": "^7.18.9",
|
|
30
|
-
"@types/debug": "^4.1.5",
|
|
31
|
-
"@types/node": "^14.11.1",
|
|
32
|
-
"@wdio/cli": "^7.26.0",
|
|
33
|
-
"@wdio/local-runner": "^7.26.0",
|
|
34
|
-
"@wdio/mocha-framework": "^7.26.0",
|
|
35
|
-
"@wdio/sauce-service": "^7.26.0",
|
|
36
|
-
"@wdio/spec-reporter": "^7.26.0",
|
|
37
|
-
"benchmark": "2.1.2",
|
|
38
|
-
"expect.js": "0.3.1",
|
|
39
|
-
"mocha": "^10.1.0",
|
|
40
|
-
"prettier": "^2.1.2",
|
|
41
|
-
"rimraf": "^3.0.2",
|
|
42
|
-
"typescript": "^4.0.3",
|
|
43
|
-
"wdio-geckodriver-service": "^4.0.0"
|
|
29
|
+
"debug": "~4.4.1"
|
|
44
30
|
},
|
|
45
31
|
"scripts": {
|
|
46
32
|
"compile": "rimraf ./build && tsc && tsc -p tsconfig.esm.json && ./postcompile.sh",
|