@based/server 3.4.0 → 3.4.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/.turbo/turbo-build.log +2 -2
- package/dist/handlers/removeField/index.js +1 -0
- package/dist/handlers/removeField/index.js.map +1 -1
- package/dist/secrets.js +6 -3
- package/dist/secrets.js.map +1 -1
- package/package.json +1 -1
- package/dist/auth/authorize.d.ts +0 -2
- package/dist/auth/authorize.js +0 -8
- package/dist/auth/authorize.js.map +0 -1
- package/dist/auth/authorizeAdvanced.d.ts +0 -2
- package/dist/auth/authorizeAdvanced.js +0 -10
- package/dist/auth/authorizeAdvanced.js.map +0 -1
- package/dist/auth/defaults/authorize.d.ts +0 -2
- package/dist/auth/defaults/authorize.js +0 -8
- package/dist/auth/defaults/authorize.js.map +0 -1
- package/dist/auth/defaults/authorizeAdvanced.d.ts +0 -2
- package/dist/auth/defaults/authorizeAdvanced.js +0 -8
- package/dist/auth/defaults/authorizeAdvanced.js.map +0 -1
- package/dist/auth/defaults/index.d.ts +0 -2
- package/dist/auth/defaults/index.js +0 -19
- package/dist/auth/defaults/index.js.map +0 -1
- package/dist/auth/index.d.ts +0 -10
- package/dist/auth/index.js +0 -23
- package/dist/auth/index.js.map +0 -1
- package/dist/error.d.ts +0 -34
- package/dist/error.js +0 -107
- package/dist/error.js.map +0 -1
- package/dist/functions/index.d.ts +0 -31
- package/dist/functions/index.js +0 -200
- package/dist/functions/index.js.map +0 -1
- package/dist/functions/timeout.d.ts +0 -3
- package/dist/functions/timeout.js +0 -23
- package/dist/functions/timeout.js.map +0 -1
- package/dist/network/http/authorize.d.ts +0 -3
- package/dist/network/http/authorize.js +0 -30
- package/dist/network/http/authorize.js.map +0 -1
- package/dist/network/http/compress.d.ts +0 -6
- package/dist/network/http/compress.js +0 -47
- package/dist/network/http/compress.js.map +0 -1
- package/dist/network/http/end.d.ts +0 -4
- package/dist/network/http/end.js +0 -19
- package/dist/network/http/end.js.map +0 -1
- package/dist/network/http/function/index.d.ts +0 -3
- package/dist/network/http/function/index.js +0 -82
- package/dist/network/http/function/index.js.map +0 -1
- package/dist/network/http/function/stream/DataStream.d.ts +0 -7
- package/dist/network/http/function/stream/DataStream.js +0 -17
- package/dist/network/http/function/stream/DataStream.js.map +0 -1
- package/dist/network/http/function/stream/index.d.ts +0 -8
- package/dist/network/http/function/stream/index.js +0 -93
- package/dist/network/http/function/stream/index.js.map +0 -1
- package/dist/network/http/function/stream/multipartFormStream.d.ts +0 -0
- package/dist/network/http/function/stream/multipartFormStream.js +0 -194
- package/dist/network/http/function/stream/multipartFormStream.js.map +0 -1
- package/dist/network/http/function/stream/stream.d.ts +0 -4
- package/dist/network/http/function/stream/stream.js +0 -49
- package/dist/network/http/function/stream/stream.js.map +0 -1
- package/dist/network/http/function.d.ts +0 -3
- package/dist/network/http/function.js +0 -46
- package/dist/network/http/function.js.map +0 -1
- package/dist/network/http/get.d.ts +0 -3
- package/dist/network/http/get.js +0 -143
- package/dist/network/http/get.js.map +0 -1
- package/dist/network/http/index.d.ts +0 -3
- package/dist/network/http/index.js +0 -125
- package/dist/network/http/index.js.map +0 -1
- package/dist/network/http/readBody.d.ts +0 -2
- package/dist/network/http/readBody.js +0 -134
- package/dist/network/http/readBody.js.map +0 -1
- package/dist/network/http/readPostData.d.ts +0 -3
- package/dist/network/http/readPostData.js +0 -50
- package/dist/network/http/readPostData.js.map +0 -1
- package/dist/network/http/send.d.ts +0 -6
- package/dist/network/http/send.js +0 -65
- package/dist/network/http/send.js.map +0 -1
- package/dist/network/http/sendError.d.ts +0 -4
- package/dist/network/http/sendError.js +0 -27
- package/dist/network/http/sendError.js.map +0 -1
- package/dist/network/http/stream/DataStream.d.ts +0 -7
- package/dist/network/http/stream/DataStream.js +0 -17
- package/dist/network/http/stream/DataStream.js.map +0 -1
- package/dist/network/http/stream/formStream.d.ts +0 -4
- package/dist/network/http/stream/formStream.js +0 -184
- package/dist/network/http/stream/formStream.js.map +0 -1
- package/dist/network/http/stream/getExtenstion.d.ts +0 -2
- package/dist/network/http/stream/getExtenstion.js +0 -22
- package/dist/network/http/stream/getExtenstion.js.map +0 -1
- package/dist/network/http/stream/index.d.ts +0 -9
- package/dist/network/http/stream/index.js +0 -42
- package/dist/network/http/stream/index.js.map +0 -1
- package/dist/network/http/stream/multipartFormStream.d.ts +0 -0
- package/dist/network/http/stream/multipartFormStream.js +0 -194
- package/dist/network/http/stream/multipartFormStream.js.map +0 -1
- package/dist/network/http/stream/storeFile.d.ts +0 -5
- package/dist/network/http/stream/storeFile.js +0 -30
- package/dist/network/http/stream/storeFile.js.map +0 -1
- package/dist/network/http/stream/stream.d.ts +0 -4
- package/dist/network/http/stream/stream.js +0 -49
- package/dist/network/http/stream/stream.js.map +0 -1
- package/dist/network/http/stream/types.d.ts +0 -9
- package/dist/network/http/stream/types.js +0 -3
- package/dist/network/http/stream/types.js.map +0 -1
- package/dist/network/http/streamFunction/DataStream.d.ts +0 -7
- package/dist/network/http/streamFunction/DataStream.js +0 -17
- package/dist/network/http/streamFunction/DataStream.js.map +0 -1
- package/dist/network/http/streamFunction/endStreamRequest.d.ts +0 -3
- package/dist/network/http/streamFunction/endStreamRequest.js +0 -20
- package/dist/network/http/streamFunction/endStreamRequest.js.map +0 -1
- package/dist/network/http/streamFunction/getExtension.d.ts +0 -2
- package/dist/network/http/streamFunction/getExtension.js +0 -22
- package/dist/network/http/streamFunction/getExtension.js.map +0 -1
- package/dist/network/http/streamFunction/index.d.ts +0 -3
- package/dist/network/http/streamFunction/index.js +0 -71
- package/dist/network/http/streamFunction/index.js.map +0 -1
- package/dist/network/http/streamFunction/multipartFormStream.d.ts +0 -5
- package/dist/network/http/streamFunction/multipartFormStream.js +0 -189
- package/dist/network/http/streamFunction/multipartFormStream.js.map +0 -1
- package/dist/network/http/streamFunction/multipartStream.d.ts +0 -13
- package/dist/network/http/streamFunction/multipartStream.js +0 -166
- package/dist/network/http/streamFunction/multipartStream.js.map +0 -1
- package/dist/network/http/streamFunction/stream.d.ts +0 -4
- package/dist/network/http/streamFunction/stream.js +0 -106
- package/dist/network/http/streamFunction/stream.js.map +0 -1
- package/dist/network/index.d.ts +0 -4
- package/dist/network/index.js +0 -84
- package/dist/network/index.js.map +0 -1
- package/dist/network/message/auth.d.ts +0 -4
- package/dist/network/message/auth.js +0 -35
- package/dist/network/message/auth.js.map +0 -1
- package/dist/network/message/function.d.ts +0 -3
- package/dist/network/message/function.js +0 -70
- package/dist/network/message/function.js.map +0 -1
- package/dist/network/message/get.d.ts +0 -3
- package/dist/network/message/get.js +0 -111
- package/dist/network/message/get.js.map +0 -1
- package/dist/network/message/index.d.ts +0 -3
- package/dist/network/message/index.js +0 -61
- package/dist/network/message/index.js.map +0 -1
- package/dist/network/message/observable.d.ts +0 -5
- package/dist/network/message/observable.js +0 -105
- package/dist/network/message/observable.js.map +0 -1
- package/dist/network/message/send.d.ts +0 -3
- package/dist/network/message/send.js +0 -11
- package/dist/network/message/send.js.map +0 -1
- package/dist/network/rest/function.d.ts +0 -3
- package/dist/network/rest/function.js +0 -85
- package/dist/network/rest/function.js.map +0 -1
- package/dist/network/rest/index.d.ts +0 -3
- package/dist/network/rest/index.js +0 -65
- package/dist/network/rest/index.js.map +0 -1
- package/dist/network/upgrade.d.ts +0 -4
- package/dist/network/upgrade.js +0 -48
- package/dist/network/upgrade.js.map +0 -1
- package/dist/observable/index.d.ts +0 -8
- package/dist/observable/index.js +0 -224
- package/dist/observable/index.js.map +0 -1
- package/dist/protocol.d.ts +0 -18
- package/dist/protocol.js +0 -206
- package/dist/protocol.js.map +0 -1
- package/dist/server.d.ts +0 -28
- package/dist/server.js +0 -96
- package/dist/server.js.map +0 -1
- package/dist/workers/index.d.ts +0 -0
- package/dist/workers/index.js +0 -20
- package/dist/workers/index.js.map +0 -1
- package/dist/workers/workerCode.d.ts +0 -12
- package/dist/workers/workerCode.js +0 -46
- package/dist/workers/workerCode.js.map +0 -1
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const DataStream_1 = require("./DataStream");
|
|
7
|
-
const send_1 = require("../send");
|
|
8
|
-
const node_zlib_1 = __importDefault(require("node:zlib"));
|
|
9
|
-
const error_1 = require("../../../error");
|
|
10
|
-
const endStreamRequest_1 = __importDefault(require("./endStreamRequest"));
|
|
11
|
-
const MAX_CHUNK_SIZE = 1024 * 1024 * 5;
|
|
12
|
-
const UNCOMPRESS_OPTS = {
|
|
13
|
-
// can be endless scince we limit by incoming
|
|
14
|
-
chunkSize: 1024 * 1024 * 100,
|
|
15
|
-
};
|
|
16
|
-
exports.default = (client, size) => {
|
|
17
|
-
const stream = new DataStream_1.DataStream();
|
|
18
|
-
let total = 0;
|
|
19
|
-
let progress = 0;
|
|
20
|
-
let setInProgress = false;
|
|
21
|
-
stream.emit('progress', progress);
|
|
22
|
-
const emitProgress = size > 200000;
|
|
23
|
-
const contentEncoding = client.context.headers['content-encoding'];
|
|
24
|
-
if (contentEncoding) {
|
|
25
|
-
let uncompressStream;
|
|
26
|
-
if (contentEncoding === 'deflate') {
|
|
27
|
-
uncompressStream = node_zlib_1.default.createInflate(UNCOMPRESS_OPTS);
|
|
28
|
-
}
|
|
29
|
-
else if (contentEncoding === 'gzip') {
|
|
30
|
-
uncompressStream = node_zlib_1.default.createGunzip(UNCOMPRESS_OPTS);
|
|
31
|
-
}
|
|
32
|
-
else if (contentEncoding === 'br') {
|
|
33
|
-
uncompressStream = node_zlib_1.default.createBrotliDecompress(UNCOMPRESS_OPTS);
|
|
34
|
-
}
|
|
35
|
-
if (uncompressStream) {
|
|
36
|
-
client.res.onData((c, isLast) => {
|
|
37
|
-
total += c.byteLength;
|
|
38
|
-
if (c.byteLength > MAX_CHUNK_SIZE) {
|
|
39
|
-
(0, send_1.sendHttpError)(client, error_1.BasedErrorCode.ChunkTooLarge);
|
|
40
|
-
uncompressStream.destroy();
|
|
41
|
-
stream.destroy();
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const buf = Buffer.alloc(c.byteLength, Buffer.from(c));
|
|
45
|
-
if (emitProgress) {
|
|
46
|
-
progress = total / size;
|
|
47
|
-
if (!setInProgress) {
|
|
48
|
-
setInProgress = true;
|
|
49
|
-
setTimeout(() => {
|
|
50
|
-
stream.emit('progress', progress);
|
|
51
|
-
setInProgress = false;
|
|
52
|
-
}, 250);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (isLast) {
|
|
56
|
-
if (!emitProgress) {
|
|
57
|
-
stream.emit('progress', 1);
|
|
58
|
-
}
|
|
59
|
-
uncompressStream.end(buf);
|
|
60
|
-
(0, endStreamRequest_1.default)(client);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
if (!uncompressStream.write(buf)) {
|
|
64
|
-
// handle backpressure
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
uncompressStream.pipe(stream);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
(0, send_1.sendHttpError)(client, error_1.BasedErrorCode.InvalidPayload, 'Unsupported Content-Encoding');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
client.res.onData((c, isLast) => {
|
|
76
|
-
total += c.byteLength;
|
|
77
|
-
if (c.byteLength > MAX_CHUNK_SIZE) {
|
|
78
|
-
(0, send_1.sendHttpError)(client, error_1.BasedErrorCode.ChunkTooLarge);
|
|
79
|
-
stream.destroy();
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (emitProgress) {
|
|
83
|
-
progress = total / size;
|
|
84
|
-
if (!setInProgress) {
|
|
85
|
-
setInProgress = true;
|
|
86
|
-
setTimeout(() => {
|
|
87
|
-
stream.emit('progress', progress);
|
|
88
|
-
setInProgress = false;
|
|
89
|
-
}, 250);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
if (isLast) {
|
|
93
|
-
if (!emitProgress) {
|
|
94
|
-
stream.emit('progress', 1);
|
|
95
|
-
}
|
|
96
|
-
stream.end(Buffer.from(c));
|
|
97
|
-
(0, endStreamRequest_1.default)(client);
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
stream.write(Buffer.from(c));
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return stream;
|
|
105
|
-
};
|
|
106
|
-
//# sourceMappingURL=stream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../../src/network/http/streamFunction/stream.ts"],"names":[],"mappings":";;;;;AAAA,6CAAyC;AAEzC,kCAAuC;AACvC,0DAA4B;AAC5B,0CAA+C;AAC/C,0EAAiD;AAEjD,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,CAAC,CAAA;AAEtC,MAAM,eAAe,GAAG;IACtB,6CAA6C;IAC7C,SAAS,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;CAC7B,CAAA;AAED,kBAAe,CAAC,MAAkB,EAAE,IAAY,EAAc,EAAE;IAC9D,MAAM,MAAM,GAAG,IAAI,uBAAU,EAAE,CAAA;IAC/B,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,IAAI,QAAQ,GAAG,CAAC,CAAA;IAChB,IAAI,aAAa,GAAG,KAAK,CAAA;IACzB,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;IACjC,MAAM,YAAY,GAAG,IAAI,GAAG,MAAM,CAAA;IAElC,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAElE,IAAI,eAAe,EAAE;QACnB,IAAI,gBAA4C,CAAA;QAChD,IAAI,eAAe,KAAK,SAAS,EAAE;YACjC,gBAAgB,GAAG,mBAAI,CA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CAAC,CAAC,CAAC,CAAA;aAC7B;QACH,CAAC,CAAC,CAAA;KACH;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
|
package/dist/network/index.d.ts
DELETED
package/dist/network/index.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const uws_1 = __importDefault(require("@based/uws"));
|
|
7
|
-
const upgrade_1 = require("./upgrade");
|
|
8
|
-
const message_1 = require("./message");
|
|
9
|
-
const observable_1 = require("../observable");
|
|
10
|
-
const http_1 = require("./http");
|
|
11
|
-
// ----------------- mem test code -------------------
|
|
12
|
-
// let cl = 0
|
|
13
|
-
// const genLargeMemBlock = (): string => {
|
|
14
|
-
// ++cl
|
|
15
|
-
// let str = ''
|
|
16
|
-
// for (let i = 0; i < 100000; i++) {
|
|
17
|
-
// str += Math.random() * 99999 + ' xxxx'
|
|
18
|
-
// }
|
|
19
|
-
// return str
|
|
20
|
-
// }
|
|
21
|
-
// let cnt = 0
|
|
22
|
-
// setInterval(() => {
|
|
23
|
-
// ++cnt
|
|
24
|
-
// console.info('Amount of clients', cl, 'after', cnt, 'seconds')
|
|
25
|
-
// }, 1e3)
|
|
26
|
-
// -----------------------------------------------------
|
|
27
|
-
exports.default = (server, { key, cert, port }) => {
|
|
28
|
-
const app = key && cert
|
|
29
|
-
? uws_1.default.SSLApp({
|
|
30
|
-
key_file_name: key,
|
|
31
|
-
cert_file_name: cert,
|
|
32
|
-
ssl_prefer_low_memory_usage: true,
|
|
33
|
-
})
|
|
34
|
-
: uws_1.default.App();
|
|
35
|
-
if (port) {
|
|
36
|
-
server.port = port;
|
|
37
|
-
}
|
|
38
|
-
app
|
|
39
|
-
.ws('/*', {
|
|
40
|
-
maxPayloadLength: 1024 * 1024 * 5,
|
|
41
|
-
idleTimeout: 100,
|
|
42
|
-
maxBackpressure: 1024,
|
|
43
|
-
// compression: uws.SHARED_COMPRESSOR,
|
|
44
|
-
upgrade: server.auth?.config?.authorizeConnection
|
|
45
|
-
? (res, req, ctx) => {
|
|
46
|
-
(0, upgrade_1.upgradeAuthorize)(server.auth.config.authorizeConnection, res, req, ctx);
|
|
47
|
-
}
|
|
48
|
-
: upgrade_1.upgrade,
|
|
49
|
-
message: (ws, data, isBinary) => {
|
|
50
|
-
(0, message_1.message)(server, ws.c, data, isBinary);
|
|
51
|
-
},
|
|
52
|
-
open: (ws) => {
|
|
53
|
-
if (ws) {
|
|
54
|
-
// ws.bla = genLargeMemBlock()
|
|
55
|
-
const client = { ws };
|
|
56
|
-
ws.c = client;
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
close: (ws) => {
|
|
60
|
-
// cl--
|
|
61
|
-
ws.obs.forEach((id) => {
|
|
62
|
-
(0, observable_1.unsubscribeIgnoreClient)(server, id, ws.c);
|
|
63
|
-
});
|
|
64
|
-
// Looks really ugly but same impact on memory and GC as using the ws directly
|
|
65
|
-
// and better for dc's when functions etc are in progress
|
|
66
|
-
ws.c.ws = null;
|
|
67
|
-
ws.c = null;
|
|
68
|
-
},
|
|
69
|
-
drain: () => {
|
|
70
|
-
// console.info('drain')
|
|
71
|
-
// lets handle drain efficiently (or more efficiently at least)
|
|
72
|
-
// call client.drain can be much more efficient
|
|
73
|
-
// if (ws.client && ws.client.backpressureQueue) {
|
|
74
|
-
// ws.client.drain()
|
|
75
|
-
// }
|
|
76
|
-
},
|
|
77
|
-
})
|
|
78
|
-
// REST
|
|
79
|
-
.get('/*', (res, req) => (0, http_1.httpHandler)(server, req, res))
|
|
80
|
-
.post('/*', (res, req) => (0, http_1.httpHandler)(server, req, res))
|
|
81
|
-
.options('/*', (res, req) => (0, http_1.httpHandler)(server, req, res));
|
|
82
|
-
server.uwsApp = app;
|
|
83
|
-
};
|
|
84
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/network/index.ts"],"names":[],"mappings":";;;;;AAEA,qDAA4B;AAC5B,uCAAqD;AACrD,uCAAmC;AACnC,8CAAuD;AACvD,iCAAoC;AAEpC,sDAAsD;AACtD,aAAa;AACb,2CAA2C;AAC3C,SAAS;AACT,iBAAiB;AACjB,uCAAuC;AACvC,6CAA6C;AAC7C,MAAM;AACN,eAAe;AACf,IAAI;AACJ,cAAc;AACd,sBAAsB;AACtB,UAAU;AACV,mEAAmE;AACnE,UAAU;AACV,wDAAwD;AAExD,kBAAe,CAAC,MAAmB,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAiB,EAAE,EAAE;IACzE,MAAM,GAAG,GACP,GAAG,IAAI,IAAI;QACT,CAAC,CAAC,aAAG,CAAC,MAAM,CAAC;YACT,aAAa,EAAE,GAAG;YAClB,cAAc,EAAE,IAAI;YACpB,2BAA2B,EAAE,IAAI;SAClC,CAAC;QACJ,CAAC,CAAC,aAAG,CAAC,GAAG,EAAE,CAAA;IAEf,IAAI,IAAI,EAAE;QACR,MAAM,CAAC,IAAI,GAAG,IAAI,CAAA;KACnB;IAED,GAAG;SACA,EAAE,CAAC,IAAI,EAAE;QACR,gBAAgB,EAAE,IAAI,GAAG,IAAI,GAAG,CAAC;QACjC,WAAW,EAAE,GAAG;QAChB,eAAe,EAAE,IAAI;QACrB,sCAAsC;QACtC,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,mBAAmB;YAC/C,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;gBAChB,IAAA,0BAAgB,EACd,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,EACtC,GAAG,EACH,GAAG,EACH,GAAG,CACJ,CAAA;YACH,CAAC;YACH,CAAC,CAAC,iBAAO;QACX,OAAO,EAAE,CAAC,EA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C,CAAC,CAAA;IAE7D,MAAM,CAAC,MAAM,GAAG,GAAG,CAAA;AACrB,CAAC,CAAA"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { BasedServer } from '../../server';
|
|
2
|
-
import { WebsocketClient } from '../../types';
|
|
3
|
-
export declare type AuthState = any;
|
|
4
|
-
export declare const authMessage: (arr: Uint8Array, start: number, len: number, isDeflate: boolean, client: WebsocketClient, server: BasedServer) => boolean;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.authMessage = void 0;
|
|
4
|
-
const protocol_1 = require("../../protocol");
|
|
5
|
-
const observable_1 = require("./observable");
|
|
6
|
-
const authMessage = (arr, start, len, isDeflate, client,
|
|
7
|
-
// eslint-disable-next-line
|
|
8
|
-
server) => {
|
|
9
|
-
// | 4 header | * payload |
|
|
10
|
-
const authPayload = (0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 4, start + len)), isDeflate);
|
|
11
|
-
// authorizeHandshake here
|
|
12
|
-
let authState;
|
|
13
|
-
try {
|
|
14
|
-
// this has to be part of the handshake
|
|
15
|
-
authState = JSON.parse(authPayload);
|
|
16
|
-
}
|
|
17
|
-
catch (err) {
|
|
18
|
-
console.error("can't decode auth payload", err);
|
|
19
|
-
}
|
|
20
|
-
if (client.ws) {
|
|
21
|
-
client.ws.authState = authState;
|
|
22
|
-
if (client.ws.unauthorizedObs.size) {
|
|
23
|
-
client.ws.unauthorizedObs.forEach((obs) => {
|
|
24
|
-
const { id, name, checksum, payload } = obs;
|
|
25
|
-
(0, observable_1.enableSubscribe)(server, client, id, checksum, name, payload);
|
|
26
|
-
});
|
|
27
|
-
//
|
|
28
|
-
client.ws.unauthorizedObs.clear();
|
|
29
|
-
}
|
|
30
|
-
client.ws.send((0, protocol_1.encodeAuthResponse)((0, protocol_1.valueToBuffer)(true)), true, false);
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
};
|
|
34
|
-
exports.authMessage = authMessage;
|
|
35
|
-
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/network/message/auth.ts"],"names":[],"mappings":";;;AAAA,6CAIuB;AAGvB,6CAA8C;AAIvC,MAAM,WAAW,GAAG,CACzB,GAAe,EACf,KAAa,EACb,GAAW,EACX,SAAkB,EAClB,MAAuB;AACvB,2BAA2B;AAC3B,MAAmB,EACV,EAAE;IACX,2BAA2B;IAE3B,MAAM,WAAW,GAAG,IAAA,wBAAa,EAC/B,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,CAAC,EACjD,SAAS,CACV,CAAA;IAED,0BAA0B;IAE1B,IAAI,SAAoB,CAAA;IACxB,IAAI;QACF,uCAAuC;QACvC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;KACpC;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAA;KAChD;IACD,IAAI,MAAM,CAAC,EAAE,EAAE;QACb,MAAM,CAAC,EAAE,CAAC,SAAS,GAAG,SAAS,CAAA;QAE/B,IAAI,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE;YAClC,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;gBACxC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,GAAG,CAAA;gBAC3C,IAAA,4BAAe,EAAC,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;YAC9D,CAAC,CAAC,CAAA;YACF,EAAE;YACF,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;SAClC;QAED,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,IAAA,6BAAkB,EAAC,IAAA,wBAAa,EAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;KACrE;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAzCY,QAAA,WAAW,eAyCvB"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.functionMessage = void 0;
|
|
4
|
-
const functions_1 = require("../../functions");
|
|
5
|
-
const protocol_1 = require("../../protocol");
|
|
6
|
-
const error_1 = require("../../error");
|
|
7
|
-
const send_1 = require("./send");
|
|
8
|
-
const functionMessage = (arr, start, len, isDeflate, client, server) => {
|
|
9
|
-
// | 4 header | 3 id | 1 name length | * name | * payload |
|
|
10
|
-
const reqId = (0, protocol_1.readUint8)(arr, start + 4, 3);
|
|
11
|
-
const nameLen = arr[start + 7];
|
|
12
|
-
const name = (0, protocol_1.decodeName)(arr, start + 8, start + 8 + nameLen);
|
|
13
|
-
const payload = (0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 8 + nameLen, start + len)), isDeflate);
|
|
14
|
-
if (!name || !reqId) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
const route = server.functions.route(name);
|
|
18
|
-
if (!route || route.observable === true || route.stream === true) {
|
|
19
|
-
// stream not with ws for now...
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
server.auth.config
|
|
23
|
-
.authorize(server, client, name, payload)
|
|
24
|
-
.then((ok) => {
|
|
25
|
-
if (!ok) {
|
|
26
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.AuthorizeRejectedError, {
|
|
27
|
-
requestId: reqId,
|
|
28
|
-
});
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
server.functions
|
|
32
|
-
.install(name)
|
|
33
|
-
.then((spec) => {
|
|
34
|
-
if (spec && !(0, functions_1.isObservableFunctionSpec)(spec)) {
|
|
35
|
-
spec
|
|
36
|
-
.function(payload, client)
|
|
37
|
-
.then((v) => {
|
|
38
|
-
client.ws?.send((0, protocol_1.encodeFunctionResponse)(reqId, (0, protocol_1.valueToBuffer)(v)), true, false);
|
|
39
|
-
})
|
|
40
|
-
.catch((err) => {
|
|
41
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.FunctionError, {
|
|
42
|
-
requestId: reqId,
|
|
43
|
-
err,
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.FunctionNotFound, {
|
|
49
|
-
requestId: reqId,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
.catch((err) => {
|
|
54
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.FunctionNotFound, {
|
|
55
|
-
requestId: reqId,
|
|
56
|
-
err,
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
})
|
|
60
|
-
.catch((err) => {
|
|
61
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.AuthorizeFunctionError, {
|
|
62
|
-
requestId: reqId,
|
|
63
|
-
err,
|
|
64
|
-
});
|
|
65
|
-
return false;
|
|
66
|
-
});
|
|
67
|
-
return true;
|
|
68
|
-
};
|
|
69
|
-
exports.functionMessage = functionMessage;
|
|
70
|
-
//# sourceMappingURL=function.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/network/message/function.ts"],"names":[],"mappings":";;;AAAA,+CAA0D;AAC1D,6CAMuB;AAEvB,uCAA4C;AAC5C,iCAAkC;AAG3B,MAAM,eAAe,GAAG,CAC7B,GAAe,EACf,KAAa,EACb,GAAW,EACX,SAAkB,EAClB,MAAuB,EACvB,MAAmB,EACV,EAAE;IACX,2DAA2D;I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BAC3C,IAAI;qBACD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;qBACzB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;oBACV,MAAM,CAAC,EAAE,EAAE,IAAI,CACb,IAAA,iCAAsB,EAAC,KAAK,EAAE,IAAA,wBAAa,EAAC,CAAC,CAAC,CAAC,EAC/C,IAAI,EACJ,KAAK,CACN,CAAA;gBACH,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;oBACb,IAAA,gBAAS,EAAC,MAAM,EAAE,sBAAc,CAAC,aAAa,EAAE;wBAC9C,SAAS,EAAE,KAAK;wBAChB,GAAG;qBACJ,CAAC,CAAA;gBACJ,CAAC,CAAC,CAAA;aACL;iBAAM;gBACL,IAAA,gBAAS,EAAC,MAAM,EAAE,sBAAc,CAAC,gBAAgB,EAAE;oBACjD,SAAS,EAAE,KAAK;iBACjB,CAAC,CAAA;aACH;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACb,IAAA,gBAAS,EAAC,MAAM,EAAE,sBAAc,CAAC,gBAAgB,EAAE;gBACjD,SAAS,EAAE,KAAK;gBAChB,GAAG;aACJ,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACN,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,IAAA,gBAAS,EAAC,MAAM,EAAE,sBAAc,CAAC,sBAAsB,EAAE;YACvD,SAAS,EAAE,KAAK;YAChB,GAAG;SACJ,CAAC,CAAA;QACF,OAAO,KAAK,CAAA;IACd,CAAC,CAAC,CAAA;IAEJ,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAhFY,QAAA,eAAe,mBAgF3B"}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMessage = void 0;
|
|
4
|
-
const functions_1 = require("../../functions");
|
|
5
|
-
const protocol_1 = require("../../protocol");
|
|
6
|
-
const observable_1 = require("../../observable");
|
|
7
|
-
const error_1 = require("../../error");
|
|
8
|
-
const send_1 = require("./send");
|
|
9
|
-
const sendGetData = (server, id, obs, checksum, client) => {
|
|
10
|
-
if (!client.ws) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if (checksum === 0) {
|
|
14
|
-
client.ws.send(obs.cache, true, false);
|
|
15
|
-
}
|
|
16
|
-
else if (checksum === obs.checksum) {
|
|
17
|
-
client.ws.send((0, protocol_1.encodeGetResponse)(id), true, false);
|
|
18
|
-
}
|
|
19
|
-
else if (obs.diffCache && obs.previousChecksum === checksum) {
|
|
20
|
-
client.ws.send(obs.diffCache, true, false);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
client.ws.send(obs.cache, true, false);
|
|
24
|
-
}
|
|
25
|
-
if (obs.clients.size === 0) {
|
|
26
|
-
(0, observable_1.destroy)(server, id);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const getMessage = (arr, start, len, isDeflate, client, server) => {
|
|
30
|
-
// | 4 header | 8 id | 8 checksum | 1 name length | * name | * payload |
|
|
31
|
-
const nameLen = arr[start + 20];
|
|
32
|
-
const id = (0, protocol_1.readUint8)(arr, start + 4, 8);
|
|
33
|
-
const checksum = (0, protocol_1.readUint8)(arr, start + 12, 8);
|
|
34
|
-
const name = (0, protocol_1.decodeName)(arr, start + 21, start + 21 + nameLen);
|
|
35
|
-
if (!name || !id) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
const route = server.functions.route(name);
|
|
39
|
-
if (!route || !route.observable) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
const payload = (0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 21 + nameLen, start + len)), isDeflate);
|
|
43
|
-
server.auth.config
|
|
44
|
-
.authorize(server, client, name, payload)
|
|
45
|
-
.then((ok) => {
|
|
46
|
-
if (!client.ws) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
if (!ok) {
|
|
50
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.AuthorizeRejectedError, {
|
|
51
|
-
observableId: id,
|
|
52
|
-
});
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
if (server.activeObservablesById.has(id)) {
|
|
56
|
-
const obs = server.activeObservablesById.get(id);
|
|
57
|
-
if (obs.beingDestroyed) {
|
|
58
|
-
clearTimeout(obs.beingDestroyed);
|
|
59
|
-
obs.beingDestroyed = null;
|
|
60
|
-
}
|
|
61
|
-
if (obs.cache) {
|
|
62
|
-
sendGetData(server, id, obs, checksum, client);
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
if (!obs.onNextData) {
|
|
66
|
-
obs.onNextData = new Set();
|
|
67
|
-
}
|
|
68
|
-
obs.onNextData.add(() => {
|
|
69
|
-
sendGetData(server, id, obs, checksum, client);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
server.functions
|
|
75
|
-
.install(name)
|
|
76
|
-
.then((spec) => {
|
|
77
|
-
if (spec && (0, functions_1.isObservableFunctionSpec)(spec)) {
|
|
78
|
-
const obs = (0, observable_1.create)(server, name, id, payload);
|
|
79
|
-
if (!client.ws?.obs.has(id)) {
|
|
80
|
-
if (!obs.onNextData) {
|
|
81
|
-
obs.onNextData = new Set();
|
|
82
|
-
}
|
|
83
|
-
obs.onNextData.add(() => {
|
|
84
|
-
sendGetData(server, id, obs, checksum, client);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.FunctionNotFound, {
|
|
90
|
-
observableId: id,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
.catch((err) => {
|
|
95
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.FunctionNotFound, {
|
|
96
|
-
observableId: id,
|
|
97
|
-
err,
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
.catch((err) => {
|
|
103
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.AuthorizeFunctionError, {
|
|
104
|
-
observableId: id,
|
|
105
|
-
err,
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
return true;
|
|
109
|
-
};
|
|
110
|
-
exports.getMessage = getMessage;
|
|
111
|
-
//# sourceMappingURL=get.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/network/message/get.ts"],"names":[],"mappings":";;;AAAA,+CAA0D;AAC1D,6CAKuB;AAEvB,iDAAkD;AAElD,uCAA4C;AAC5C,iCAAkC;AAElC,MAAM,WAAW,GAAG,CAClB,MAAmB,EACnB,EAAU,EACV,GAAqB,EACrB,QAAgB,EAChB,MAAuB,EACvB,EAAE;IACF,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;QACd,OAAM;KACP;IAED,IAAI,QAAQ,KAAK,CAAC,EAAE;QAClB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;KACvC;SAAM,IAAI,QAAQ,KAAK,GAAG,CAAC,QAAQ,EAAE;QACpC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,IAAA,4BAAiB,EAAC,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;KACnD;SAAM,IAAI,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,gBAAgB,KAAK,QAAQ,EAAE;QAC7D,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;KAC3C;SAAM;QACL,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,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AAE,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;wBAC3B,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE;4BACnB,GAAG,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAA;yBAC3B;wBACD,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE;4BACtB,WAAW,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;wBAChD,CAAC,CAAC,CAAA;qBACH;iBACF;qBAAM;oBACL,IAAA,gBAAS,EAAC,MAAM,EAAE,sBAAc,CAAC,gBAAgB,EAAE;wBACjD,YAAY,EAAE,EAAE;qBACjB,CAAC,CAAA;iBACH;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,IAAA,gBAAS,EAAC,MAAM,EAAE,sBAAc,CAAC,gBAAgB,EAAE;oBACjD,YAAY,EAAE,EAAE;oBAChB,GAAG;iBACJ,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;SACL;IACH,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,IAAA,gBAAS,EAAC,MAAM,EAAE,sBAAc,CAAC,sBAAsB,EAAE;YACvD,YAAY,EAAE,EAAE;YAChB,GAAG;SACJ,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEJ,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAjGY,QAAA,UAAU,cAiGtB"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.message = void 0;
|
|
4
|
-
const protocol_1 = require("../../protocol");
|
|
5
|
-
const function_1 = require("./function");
|
|
6
|
-
const observable_1 = require("./observable");
|
|
7
|
-
const auth_1 = require("./auth");
|
|
8
|
-
const get_1 = require("./get");
|
|
9
|
-
const reader = (server, client, arr, start) => {
|
|
10
|
-
const { len, isDeflate, type } = (0, protocol_1.decodeHeader)((0, protocol_1.readUint8)(arr, start, 4));
|
|
11
|
-
const next = len + start;
|
|
12
|
-
// type 0 = function
|
|
13
|
-
if (type === 0 &&
|
|
14
|
-
(0, function_1.functionMessage)(arr, start, len, isDeflate, client, server)) {
|
|
15
|
-
return next;
|
|
16
|
-
}
|
|
17
|
-
// type 1 = subscribe
|
|
18
|
-
if (type === 1 &&
|
|
19
|
-
(0, observable_1.subscribeMessage)(arr, start, len, isDeflate, client, server)) {
|
|
20
|
-
return next;
|
|
21
|
-
}
|
|
22
|
-
// type 2 = unsubscribe
|
|
23
|
-
if (type === 2 && (0, observable_1.unsubscribeMessage)(arr, start, client, server)) {
|
|
24
|
-
return next;
|
|
25
|
-
}
|
|
26
|
-
// type 3 = get
|
|
27
|
-
if (type === 3 && (0, get_1.getMessage)(arr, start, len, isDeflate, client, server)) {
|
|
28
|
-
return next;
|
|
29
|
-
}
|
|
30
|
-
// type 4 = auth
|
|
31
|
-
if (type === 4 && (0, auth_1.authMessage)(arr, start, len, isDeflate, client, server)) {
|
|
32
|
-
return next;
|
|
33
|
-
}
|
|
34
|
-
// emit whats wrong
|
|
35
|
-
console.warn('Unsupported incoming message with type', type);
|
|
36
|
-
};
|
|
37
|
-
const message = (server, client, msg, isBinary) => {
|
|
38
|
-
if (!client.ws) {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (!isBinary) {
|
|
42
|
-
// TODO: add an event here for illegal requests
|
|
43
|
-
client.ws.close();
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
// check if msg if empty (0) then it idle timeout
|
|
47
|
-
const uint8View = new Uint8Array(msg);
|
|
48
|
-
const len = uint8View.length;
|
|
49
|
-
let next = 0;
|
|
50
|
-
while (next < len) {
|
|
51
|
-
const n = reader(server, client, uint8View, next);
|
|
52
|
-
if (n === undefined) {
|
|
53
|
-
// Malformed message close client
|
|
54
|
-
client.ws.close();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
next = n;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
exports.message = message;
|
|
61
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/network/message/index.ts"],"names":[],"mappings":";;;AACA,6CAAwD;AACxD,yCAA4C;AAC5C,6CAAmE;AACnE,iCAAoC;AACpC,+BAAkC;AAGlC,MAAM,MAAM,GAAG,CACb,MAAmB,EACnB,MAAuB,EACvB,GAAe,EACf,KAAa,EACL,EAAE;IACV,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAA,uBAAY,EAAC,IAAA,oBAAS,EAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;IACvE,MAAM,IAAI,GAAG,GAAG,GAAG,KAAK,CAAA;IAExB,oBAAoB;IACpB,IACE,IAAI,KAAK,CAAC;QACV,IAAA,0BAAe,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAC3D;QACA,OAAO,IAAI,CAAA;KACZ;IAED,qBAAqB;IACrB,IACE,IAAI,KAAK,CAAC;QACV,IAAA,6BAAgB,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAC5D;QACA,OAAO,IAAI,CAAA;KACZ;IAED,uBAAuB;IACvB,IAAI,IAAI,KAAK,CAAC,IAAI,IAAA,+BAAkB,EAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QAChE,OAAO,IAAI,CAAA;KACZ;IAED,eAAe;IACf,IAAI,IAAI,KAAK,CAAC,IAAI,IAAA,gBAAU,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QACxE,OAAO,IAAI,CAAA;KACZ;IAED,gBAAgB;IAChB,IAAI,IAAI,KAAK,CAAC,IAAI,IAAA,kBAAW,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE;QACzE,OAAO,IAAI,CAAA;KACZ;IAED,mBAAmB;IACnB,OAAO,CAAC,IAAI,CAAC,wCAAwC,EAAE,IAAI,CAAC,CAAA;AAC9D,CAAC,CAAA;AAEM,MAAM,OAAO,GAAG,CACrB,MAAmB,EACnB,MAAuB,EACvB,GAAgB,EAChB,QAAiB,EACjB,EAAE;IACF,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;QACd,OAAM;KACP;IAED,IAAI,CAAC,QAAQ,EAAE;QACb,+CAA+C;QAC/C,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;QACjB,OAAM;KACP;IAED,iDAAiD;IAEjD,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAA;IACrC,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,CAAA;IAC5B,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,OAAO,IAAI,GAAG,GAAG,EAAE;QACjB,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;QACjD,IAAI,CAAC,KAAK,SAAS,EAAE;YACnB,iCAAiC;YACjC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;YACjB,OAAM;SACP;QACD,IAAI,GAAG,CAAC,CAAA;KACT;AACH,CAAC,CAAA;AA9BY,QAAA,OAAO,WA8BnB"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { BasedServer } from '../../server';
|
|
2
|
-
import { WebsocketClient } from '../../types';
|
|
3
|
-
export declare const enableSubscribe: (server: BasedServer, client: WebsocketClient, id: number, checksum: number, name: string, payload: any) => void;
|
|
4
|
-
export declare const subscribeMessage: (arr: Uint8Array, start: number, len: number, isDeflate: boolean, client: WebsocketClient, server: BasedServer) => boolean;
|
|
5
|
-
export declare const unsubscribeMessage: (arr: Uint8Array, start: number, client: WebsocketClient, server: BasedServer) => boolean;
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unsubscribeMessage = exports.subscribeMessage = exports.enableSubscribe = void 0;
|
|
4
|
-
const functions_1 = require("../../functions");
|
|
5
|
-
const protocol_1 = require("../../protocol");
|
|
6
|
-
const observable_1 = require("../../observable");
|
|
7
|
-
const error_1 = require("../../error");
|
|
8
|
-
const send_1 = require("./send");
|
|
9
|
-
const enableSubscribe = (server, client, id, checksum, name, payload) => {
|
|
10
|
-
client.ws.subscribe(String(id));
|
|
11
|
-
client.ws.obs.add(id);
|
|
12
|
-
if (server.activeObservablesById.has(id)) {
|
|
13
|
-
(0, observable_1.subscribe)(server, id, checksum, client);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
server.functions
|
|
17
|
-
.install(name)
|
|
18
|
-
.then((spec) => {
|
|
19
|
-
if (spec && (0, functions_1.isObservableFunctionSpec)(spec)) {
|
|
20
|
-
const obs = (0, observable_1.create)(server, name, id, payload);
|
|
21
|
-
if (!client.ws?.obs.has(id)) {
|
|
22
|
-
if (obs.clients.size === 0) {
|
|
23
|
-
(0, observable_1.destroy)(server, id);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
(0, observable_1.subscribe)(server, id, checksum, client);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.FunctionNotFound, {
|
|
32
|
-
observableId: id,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
.catch((err) => {
|
|
37
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.FunctionNotFound, {
|
|
38
|
-
observableId: id,
|
|
39
|
-
err,
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
exports.enableSubscribe = enableSubscribe;
|
|
45
|
-
const subscribeMessage = (arr, start, len, isDeflate, client, server) => {
|
|
46
|
-
// | 4 header | 8 id | 8 checksum | 1 name length | * name | * payload |
|
|
47
|
-
const nameLen = arr[start + 20];
|
|
48
|
-
const id = (0, protocol_1.readUint8)(arr, start + 4, 8);
|
|
49
|
-
const checksum = (0, protocol_1.readUint8)(arr, start + 12, 8);
|
|
50
|
-
const name = (0, protocol_1.decodeName)(arr, start + 21, start + 21 + nameLen);
|
|
51
|
-
if (!name || !id) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
const route = server.functions.route(name);
|
|
55
|
-
if (!route || !route.observable) {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
if (client.ws?.obs.has(id)) {
|
|
59
|
-
// allready subscribed to this id
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
const payload = (0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 21 + nameLen, start + len)), isDeflate);
|
|
63
|
-
server.auth.config
|
|
64
|
-
.authorize(server, client, name, payload)
|
|
65
|
-
.then((ok) => {
|
|
66
|
-
if (!client.ws) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (!ok) {
|
|
70
|
-
client.ws.unauthorizedObs.add({ id, checksum, name, payload });
|
|
71
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.AuthorizeRejectedError, {
|
|
72
|
-
observableId: id,
|
|
73
|
-
});
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
(0, exports.enableSubscribe)(server, client, id, checksum, name, payload);
|
|
77
|
-
})
|
|
78
|
-
.catch((err) => {
|
|
79
|
-
(0, send_1.sendError)(client, error_1.BasedErrorCode.AuthorizeFunctionError, {
|
|
80
|
-
observableId: id,
|
|
81
|
-
err,
|
|
82
|
-
});
|
|
83
|
-
(0, observable_1.destroy)(server, id);
|
|
84
|
-
});
|
|
85
|
-
return true;
|
|
86
|
-
};
|
|
87
|
-
exports.subscribeMessage = subscribeMessage;
|
|
88
|
-
const unsubscribeMessage = (arr, start, client, server) => {
|
|
89
|
-
// | 4 header | 8 id |
|
|
90
|
-
const id = (0, protocol_1.readUint8)(arr, start + 4, 8);
|
|
91
|
-
if (!id) {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
if (!client.ws) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (!client.ws.obs.has(id)) {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
client.ws.unsubscribe(String(id));
|
|
101
|
-
(0, observable_1.unsubscribe)(server, id, client);
|
|
102
|
-
return true;
|
|
103
|
-
};
|
|
104
|
-
exports.unsubscribeMessage = unsubscribeMessage;
|
|
105
|
-
//# sourceMappingURL=observable.js.map
|