@socket-mesh/server 18.1.4 → 19.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/broker/broker-events.d.ts +4 -4
- package/dist/broker/broker.d.ts +10 -10
- package/dist/broker/broker.js +2 -1
- package/dist/broker/exchange-client.d.ts +1 -1
- package/dist/broker/exchange.d.ts +6 -1
- package/dist/broker/exchange.js +6 -1
- package/dist/broker/index.d.ts +5 -0
- package/dist/broker/index.js +5 -0
- package/dist/broker/simple-broker.d.ts +8 -8
- package/dist/broker/simple-broker.js +26 -23
- package/dist/broker/simple-exchange.d.ts +6 -7
- package/dist/broker/simple-exchange.js +18 -14
- package/dist/events/index.d.ts +49 -0
- package/dist/handlers/authenticate.d.ts +11 -11
- package/dist/handlers/authenticate.js +31 -28
- package/dist/handlers/handshake.d.ts +2 -2
- package/dist/handlers/handshake.js +21 -16
- package/dist/handlers/index.d.ts +7 -0
- package/dist/handlers/index.js +7 -0
- package/dist/handlers/publish.d.ts +3 -3
- package/dist/handlers/publish.js +2 -2
- package/dist/handlers/remove-auth-token.d.ts +4 -4
- package/dist/handlers/server-request-handler.d.ts +6 -7
- package/dist/handlers/subscribe.d.ts +3 -3
- package/dist/handlers/subscribe.js +3 -3
- package/dist/handlers/unsubscribe.d.ts +2 -2
- package/dist/handlers/unsubscribe.js +2 -2
- package/dist/index.d.ts +20 -18
- package/dist/index.js +19 -20
- package/dist/plugin/server-plugin.d.ts +23 -25
- package/dist/server-options.d.ts +14 -11
- package/dist/server-socket.d.ts +68 -19
- package/dist/server-socket.js +27 -8
- package/dist/server-transport.d.ts +33 -23
- package/dist/server-transport.js +59 -50
- package/dist/server.d.ts +89 -90
- package/dist/server.js +110 -79
- package/package.json +46 -17
- package/dist/server-event.d.ts +0 -49
- /package/dist/{server-event.js → events/index.js} +0 -0
package/dist/server.js
CHANGED
|
@@ -1,17 +1,43 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
1
|
+
import { AsyncStreamEmitter } from '@socket-mesh/async-stream-emitter';
|
|
2
|
+
import { defaultAuthEngine, isAuthEngine } from '@socket-mesh/auth-engine';
|
|
3
|
+
import { removeAuthTokenHandler } from '@socket-mesh/client';
|
|
4
|
+
import { toError } from '@socket-mesh/core';
|
|
5
|
+
import { ServerProtocolError } from '@socket-mesh/errors';
|
|
6
|
+
import defaultCodec from '@socket-mesh/formatter';
|
|
7
|
+
import { WebSocketServer } from 'ws';
|
|
8
|
+
import { SimpleBroker } from './broker/simple-broker.js';
|
|
9
|
+
import { authenticateHandler } from './handlers/authenticate.js';
|
|
10
|
+
import { handshakeHandler } from './handlers/handshake.js';
|
|
11
|
+
import { publishHandler } from './handlers/publish.js';
|
|
12
|
+
import { subscribeHandler } from './handlers/subscribe.js';
|
|
13
|
+
import { unsubscribeHandler } from './handlers/unsubscribe.js';
|
|
14
|
+
import { ServerSocket } from './server-socket.js';
|
|
14
15
|
export class Server extends AsyncStreamEmitter {
|
|
16
|
+
_callIdGenerator;
|
|
17
|
+
_handlers;
|
|
18
|
+
_isListening;
|
|
19
|
+
_isReady;
|
|
20
|
+
_pingIntervalRef;
|
|
21
|
+
_wss;
|
|
22
|
+
// | ServerSocket<TIncomingMap, TServiceMap, TOutgoingMap, TPrivateIncomingMap, TPrivateOutgoingMap, TServerState, TSocketState>
|
|
23
|
+
ackTimeoutMs;
|
|
24
|
+
allowClientPublish;
|
|
25
|
+
auth;
|
|
26
|
+
brokerEngine;
|
|
27
|
+
clientCount;
|
|
28
|
+
clients;
|
|
29
|
+
codecEngine;
|
|
30
|
+
httpServer;
|
|
31
|
+
isPingTimeoutDisabled;
|
|
32
|
+
origins;
|
|
33
|
+
pendingClientCount;
|
|
34
|
+
pendingClients;
|
|
35
|
+
pingIntervalMs;
|
|
36
|
+
pingTimeoutMs;
|
|
37
|
+
plugins;
|
|
38
|
+
socketChannelLimit;
|
|
39
|
+
socketStreamCleanupMode;
|
|
40
|
+
strictHandshake;
|
|
15
41
|
constructor(options) {
|
|
16
42
|
super();
|
|
17
43
|
let cid = 1;
|
|
@@ -19,6 +45,9 @@ export class Server extends AsyncStreamEmitter {
|
|
|
19
45
|
options = {};
|
|
20
46
|
}
|
|
21
47
|
options.clientTracking = true;
|
|
48
|
+
this._isListening = false;
|
|
49
|
+
this._isReady = false;
|
|
50
|
+
this._pingIntervalRef = null;
|
|
22
51
|
this.ackTimeoutMs = options.ackTimeoutMs || 10000;
|
|
23
52
|
this.allowClientPublish = options.allowClientPublish ?? true;
|
|
24
53
|
this.auth = isAuthEngine(options.authEngine) ? options.authEngine : defaultAuthEngine(options.authEngine);
|
|
@@ -30,12 +59,12 @@ export class Server extends AsyncStreamEmitter {
|
|
|
30
59
|
this.clientCount = 0;
|
|
31
60
|
this.codecEngine = options.codecEngine || defaultCodec;
|
|
32
61
|
this._handlers = Object.assign({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
62
|
+
'#authenticate': authenticateHandler,
|
|
63
|
+
'#handshake': handshakeHandler,
|
|
64
|
+
'#publish': publishHandler,
|
|
65
|
+
'#removeAuthToken': removeAuthTokenHandler,
|
|
66
|
+
'#subscribe': subscribeHandler,
|
|
67
|
+
'#unsubscribe': unsubscribeHandler
|
|
39
68
|
}, options.handlers);
|
|
40
69
|
this.httpServer = options.server;
|
|
41
70
|
this.plugins = options.plugins || [];
|
|
@@ -49,14 +78,14 @@ export class Server extends AsyncStreamEmitter {
|
|
|
49
78
|
this.socketStreamCleanupMode = options.socketStreamCleanupMode || 'kill';
|
|
50
79
|
this.strictHandshake = options.strictHandshake ?? true;
|
|
51
80
|
options.verifyClient = this.verifyClient.bind(this);
|
|
52
|
-
this._wss = new
|
|
81
|
+
this._wss = new WebSocketServer(options);
|
|
53
82
|
this._wss.on('close', this.onClose.bind(this));
|
|
54
83
|
this._wss.on('connection', this.onConnection.bind(this));
|
|
55
84
|
this._wss.on('error', this.onError.bind(this));
|
|
56
85
|
this._wss.on('headers', this.onHeaders.bind(this));
|
|
57
86
|
this._wss.on('listening', this.onListening.bind(this));
|
|
58
87
|
(async () => {
|
|
59
|
-
for await (
|
|
88
|
+
for await (const { error } of this.brokerEngine.listen('error')) {
|
|
60
89
|
this.emit('warning', { warning: error });
|
|
61
90
|
}
|
|
62
91
|
})();
|
|
@@ -80,34 +109,34 @@ export class Server extends AsyncStreamEmitter {
|
|
|
80
109
|
}
|
|
81
110
|
bind(socket) {
|
|
82
111
|
/*
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
})();
|
|
112
|
+
if (socket.type === 'client') {
|
|
113
|
+
(async () => {
|
|
114
|
+
for await (let event of socket.listen()) {
|
|
115
|
+
this.emit(
|
|
116
|
+
`socket${event.stream[0].toUpperCase()}${event.stream.substring(1)}` as any,
|
|
117
|
+
Object.assign(
|
|
118
|
+
{ socket },
|
|
119
|
+
event.value
|
|
120
|
+
)
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
})();
|
|
124
|
+
|
|
125
|
+
(async () => {
|
|
126
|
+
for await (let event of socket.channels.listen()) {
|
|
127
|
+
this.emit(
|
|
128
|
+
`socket${event.stream[0].toUpperCase()}${event.stream.substring(1)}` as any,
|
|
129
|
+
Object.assign(
|
|
130
|
+
{ socket },
|
|
131
|
+
event.value
|
|
132
|
+
)
|
|
133
|
+
);
|
|
107
134
|
}
|
|
108
|
-
|
|
135
|
+
})();
|
|
136
|
+
}
|
|
137
|
+
*/
|
|
109
138
|
(async () => {
|
|
110
|
-
for await (
|
|
139
|
+
for await (const _ of socket.listen('connect')) {
|
|
111
140
|
if (this.pendingClients[socket.id]) {
|
|
112
141
|
delete this.pendingClients[socket.id];
|
|
113
142
|
this.pendingClientCount--;
|
|
@@ -118,12 +147,12 @@ export class Server extends AsyncStreamEmitter {
|
|
|
118
147
|
}
|
|
119
148
|
})();
|
|
120
149
|
(async () => {
|
|
121
|
-
for await (
|
|
150
|
+
for await (const _ of socket.listen('connectAbort')) {
|
|
122
151
|
this.socketDisconnected(socket);
|
|
123
152
|
}
|
|
124
153
|
})();
|
|
125
154
|
(async () => {
|
|
126
|
-
for await (
|
|
155
|
+
for await (const _ of socket.listen('disconnect')) {
|
|
127
156
|
this.socketDisconnected(socket);
|
|
128
157
|
}
|
|
129
158
|
})();
|
|
@@ -139,12 +168,15 @@ export class Server extends AsyncStreamEmitter {
|
|
|
139
168
|
resolve();
|
|
140
169
|
});
|
|
141
170
|
if (!keepSocketsOpen) {
|
|
142
|
-
for (
|
|
171
|
+
for (const socket of Object.values(this.clients)) {
|
|
143
172
|
socket.disconnect();
|
|
144
173
|
}
|
|
145
174
|
}
|
|
146
175
|
});
|
|
147
176
|
}
|
|
177
|
+
emit(event, data) {
|
|
178
|
+
super.emit(event, data);
|
|
179
|
+
}
|
|
148
180
|
get exchange() {
|
|
149
181
|
return this.brokerEngine.exchange;
|
|
150
182
|
}
|
|
@@ -154,32 +186,35 @@ export class Server extends AsyncStreamEmitter {
|
|
|
154
186
|
get isReady() {
|
|
155
187
|
return this._isReady;
|
|
156
188
|
}
|
|
189
|
+
listen(event) {
|
|
190
|
+
return event ? super.listen(event) : super.listen();
|
|
191
|
+
}
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
157
193
|
onClose(code, reason) {
|
|
158
194
|
this.emit('close', {});
|
|
159
195
|
}
|
|
160
196
|
onConnection(wsSocket, upgradeReq) {
|
|
161
197
|
/*
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
198
|
+
if (!wsSocket.upgradeReq) {
|
|
199
|
+
// Normalize ws modules to match.
|
|
200
|
+
wsSocket.upgradeReq = upgradeReq;
|
|
201
|
+
}
|
|
202
|
+
*/
|
|
167
203
|
const socket = new ServerSocket({
|
|
168
204
|
ackTimeoutMs: this.ackTimeoutMs,
|
|
169
205
|
callIdGenerator: this._callIdGenerator,
|
|
170
206
|
codecEngine: this.codecEngine,
|
|
171
207
|
handlers: this._handlers,
|
|
172
208
|
plugins: this.plugins,
|
|
173
|
-
onUnhandledRequest: this.onUnhandledRequest.bind(this),
|
|
174
209
|
request: upgradeReq,
|
|
175
|
-
socket: wsSocket,
|
|
176
210
|
server: this,
|
|
211
|
+
socket: wsSocket,
|
|
177
212
|
state: {},
|
|
178
213
|
streamCleanupMode: this.socketStreamCleanupMode
|
|
179
214
|
});
|
|
180
215
|
this.pendingClientCount++;
|
|
181
216
|
this.bind(this.pendingClients[socket.id] = socket);
|
|
182
|
-
//
|
|
217
|
+
// ws.on('error', console.error);
|
|
183
218
|
this.emit('connection', { socket, upgradeReq });
|
|
184
219
|
// Emit event to signal that a socket handshake has been initiated.
|
|
185
220
|
this.emit('handshake', { socket });
|
|
@@ -197,14 +232,12 @@ export class Server extends AsyncStreamEmitter {
|
|
|
197
232
|
this._isListening = true;
|
|
198
233
|
this.emit('listening', {});
|
|
199
234
|
}
|
|
200
|
-
onUnhandledRequest(socket, packet) {
|
|
201
|
-
}
|
|
202
235
|
socketDisconnected(socket) {
|
|
203
|
-
if (
|
|
236
|
+
if (this.pendingClients[socket.id]) {
|
|
204
237
|
delete this.pendingClients[socket.id];
|
|
205
238
|
this.pendingClientCount--;
|
|
206
239
|
}
|
|
207
|
-
if (
|
|
240
|
+
if (this.clients[socket.id]) {
|
|
208
241
|
delete this.clients[socket.id];
|
|
209
242
|
this.clientCount--;
|
|
210
243
|
}
|
|
@@ -218,7 +251,7 @@ export class Server extends AsyncStreamEmitter {
|
|
|
218
251
|
for (const id in this.clients) {
|
|
219
252
|
this.clients[id]
|
|
220
253
|
.ping()
|
|
221
|
-
.catch(err => {
|
|
254
|
+
.catch((err) => {
|
|
222
255
|
this.onError(err);
|
|
223
256
|
});
|
|
224
257
|
}
|
|
@@ -237,16 +270,18 @@ export class Server extends AsyncStreamEmitter {
|
|
|
237
270
|
info.origin = '*';
|
|
238
271
|
}
|
|
239
272
|
if (this.origins.indexOf('*:*') === -1) {
|
|
240
|
-
let
|
|
273
|
+
let isOk = false;
|
|
241
274
|
try {
|
|
242
275
|
const url = new URL(info.origin);
|
|
243
276
|
url.port = url.port || (url.protocol === 'https:' ? '443' : '80');
|
|
244
|
-
|
|
245
|
-
~this.origins.indexOf(url.hostname + ':*')
|
|
246
|
-
~this.origins.indexOf('*:' + url.port));
|
|
277
|
+
isOk = !!(~this.origins.indexOf(url.hostname + ':' + url.port)
|
|
278
|
+
|| ~this.origins.indexOf(url.hostname + ':*')
|
|
279
|
+
|| ~this.origins.indexOf('*:' + url.port));
|
|
280
|
+
}
|
|
281
|
+
catch (e) {
|
|
282
|
+
// Intentional
|
|
247
283
|
}
|
|
248
|
-
|
|
249
|
-
if (!ok) {
|
|
284
|
+
if (!isOk) {
|
|
250
285
|
const error = new ServerProtocolError(`Failed to authorize socket handshake - Invalid origin: ${info.origin}`);
|
|
251
286
|
this.emit('warning', { warning: error });
|
|
252
287
|
callback(false, 403, error.message);
|
|
@@ -261,21 +296,17 @@ export class Server extends AsyncStreamEmitter {
|
|
|
261
296
|
}
|
|
262
297
|
}
|
|
263
298
|
catch (err) {
|
|
264
|
-
|
|
299
|
+
const error = toError(err);
|
|
300
|
+
callback(false, 401, typeof err === 'string' ? err : error.message);
|
|
265
301
|
return;
|
|
266
302
|
}
|
|
267
303
|
callback(true);
|
|
268
304
|
}
|
|
269
305
|
catch (err) {
|
|
270
|
-
|
|
271
|
-
this.
|
|
272
|
-
|
|
306
|
+
const error = toError(err);
|
|
307
|
+
this.onError(error);
|
|
308
|
+
this.emit('warning', { warning: error });
|
|
309
|
+
callback(false, 403, typeof err === 'string' ? err : error.message);
|
|
273
310
|
}
|
|
274
311
|
}
|
|
275
|
-
emit(event, data) {
|
|
276
|
-
super.emit(event, data);
|
|
277
|
-
}
|
|
278
|
-
listen(event) {
|
|
279
|
-
return super.listen(event);
|
|
280
|
-
}
|
|
281
312
|
}
|
package/package.json
CHANGED
|
@@ -1,18 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socket-mesh/server",
|
|
3
3
|
"description": "A TCP socket pair for easily transmitting full messages without worrying about request size limits.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "19.0.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": ["./dist"],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./broker": {
|
|
16
|
+
"types": "./dist/broker/index.d.ts",
|
|
17
|
+
"import": "./dist/broker/index.js",
|
|
18
|
+
"default": "./dist/broker/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./events": {
|
|
21
|
+
"types": "./dist/events/index.d.ts",
|
|
22
|
+
"import": "./dist/events/index.js",
|
|
23
|
+
"default": "./dist/events/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./handlers": {
|
|
26
|
+
"types": "./dist/handlers/index.d.ts",
|
|
27
|
+
"import": "./dist/handlers/index.js",
|
|
28
|
+
"default": "./dist/handlers/index.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
9
31
|
"author": {
|
|
10
32
|
"name": "Greg Kimmy"
|
|
11
33
|
},
|
|
12
34
|
"scripts": {
|
|
13
35
|
"build": "node ../../scripts/build.mjs && tsc --project tsconfig.build.json",
|
|
14
|
-
"deploy": "
|
|
15
|
-
"
|
|
36
|
+
"deploy": "node ../../scripts/publish.mjs",
|
|
37
|
+
"lint": "eslint . --c ../../eslint.config.mjs",
|
|
38
|
+
"lint:fix": "eslint . --c ../../eslint.config.mjs --fix",
|
|
39
|
+
"test": "tsx --tsconfig ./tsconfig.build.json --test ./src/**/*.{spec,test}.ts ./test/**/*.{spec,test}.ts"
|
|
16
40
|
},
|
|
17
41
|
"repository": {
|
|
18
42
|
"type": "git",
|
|
@@ -22,22 +46,27 @@
|
|
|
22
46
|
"url": "https://github.com/socket-mesh/client-server/labels/server"
|
|
23
47
|
},
|
|
24
48
|
"devDependencies": {
|
|
25
|
-
"@socket-mesh/local-storage": "
|
|
26
|
-
"@
|
|
27
|
-
"@types/
|
|
28
|
-
"@types/
|
|
49
|
+
"@socket-mesh/local-storage": "workspace:^",
|
|
50
|
+
"@socket-mesh/typescript-config": "workspace:^",
|
|
51
|
+
"@types/base64id": "catalog:base64id",
|
|
52
|
+
"@types/jsonwebtoken": "catalog:json-web-token",
|
|
53
|
+
"@types/ws": "catalog:ws"
|
|
29
54
|
},
|
|
30
55
|
"dependencies": {
|
|
31
|
-
"@socket-mesh/async-stream-emitter": "
|
|
32
|
-
"@socket-mesh/auth": "
|
|
33
|
-
"@socket-mesh/auth-engine": "
|
|
34
|
-
"@socket-mesh/
|
|
35
|
-
"@socket-mesh/
|
|
36
|
-
"@socket-mesh/
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
56
|
+
"@socket-mesh/async-stream-emitter": "workspace:^",
|
|
57
|
+
"@socket-mesh/auth": "workspace:^",
|
|
58
|
+
"@socket-mesh/auth-engine": "workspace:^",
|
|
59
|
+
"@socket-mesh/channels": "workspace:^",
|
|
60
|
+
"@socket-mesh/client": "workspace:^",
|
|
61
|
+
"@socket-mesh/core": "workspace:^",
|
|
62
|
+
"@socket-mesh/errors": "workspace:^",
|
|
63
|
+
"@socket-mesh/formatter": "workspace:^",
|
|
64
|
+
"@socket-mesh/stream-demux": "workspace:^",
|
|
65
|
+
"@socket-mesh/writable-consumable-stream": "workspace:^",
|
|
66
|
+
"base64id": "catalog:base64id",
|
|
67
|
+
"events": "catalog:",
|
|
68
|
+
"jsonwebtoken": "catalog:json-web-token",
|
|
69
|
+
"ws": "catalog:ws"
|
|
41
70
|
},
|
|
42
71
|
"keywords": [
|
|
43
72
|
"ncom",
|
package/dist/server-event.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { IncomingMessage } from "http";
|
|
2
|
-
import { ClientSocket, ServerPrivateMap } from "@socket-mesh/client";
|
|
3
|
-
import { ServerSocket } from "./server-socket.js";
|
|
4
|
-
import { AuthenticateEvent, BadAuthTokenEvent, ConnectEvent, CloseEvent as SCloseEvent, DisconnectEvent, ErrorEvent as SErrorEvent, MessageEvent, PingEvent, PongEvent, RequestEvent, ResponseEvent, ConnectingEvent, RemoveAuthTokenEvent, DeauthenticateEvent, AuthStateChangeEvent, ServiceMap, PublicMethodMap, PrivateMethodMap } from "@socket-mesh/core";
|
|
5
|
-
import { ChannelMap, SubscribeEvent, SubscribeFailEvent, SubscribeStateChangeEvent, UnsubscribeEvent } from "@socket-mesh/channels";
|
|
6
|
-
export type ServerEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = ConnectionEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | CloseEvent | ErrorEvent | HeadersEvent | HandshakeEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | ListeningEvent | SocketAuthStateChangeEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketAuthenticateEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketBadAuthTokenEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketCloseEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketDeauthenticateEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketErrorEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketMessageEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketConnectEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketConnectingEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketDisconnectEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketPingEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketPongEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketRemoveAuthTokenEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | SocketRequestEvent<TService, TIncoming, TPrivateIncoming> | SocketResponseEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState> | WarningEvent;
|
|
7
|
-
export interface ConnectionEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> {
|
|
8
|
-
socket: ServerSocket<TIncoming, TChannel, TService, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
9
|
-
upgradeReq: IncomingMessage;
|
|
10
|
-
}
|
|
11
|
-
export interface CloseEvent {
|
|
12
|
-
}
|
|
13
|
-
export interface ErrorEvent {
|
|
14
|
-
error: Error;
|
|
15
|
-
}
|
|
16
|
-
export interface HandshakeEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> {
|
|
17
|
-
socket: ServerSocket<TIncoming, TChannel, TService, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
18
|
-
}
|
|
19
|
-
export interface WarningEvent {
|
|
20
|
-
warning: Error;
|
|
21
|
-
}
|
|
22
|
-
export interface HeadersEvent {
|
|
23
|
-
headers: string[];
|
|
24
|
-
request: IncomingMessage;
|
|
25
|
-
}
|
|
26
|
-
export interface ListeningEvent {
|
|
27
|
-
}
|
|
28
|
-
export interface ServerSocketEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> {
|
|
29
|
-
socket: ClientSocket<PublicMethodMap, TChannel, TService, TState, TOutgoing & TPrivateOutgoing, TPrivateIncoming> | ServerSocket<TIncoming, TChannel, TService, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
30
|
-
}
|
|
31
|
-
export type SocketAuthStateChangeEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = AuthStateChangeEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
32
|
-
export type SocketAuthenticateEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = AuthenticateEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
33
|
-
export type SocketBadAuthTokenEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = BadAuthTokenEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
34
|
-
export type SocketCloseEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = SCloseEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
35
|
-
export type SocketDeauthenticateEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = DeauthenticateEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
36
|
-
export type SocketErrorEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = SErrorEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
37
|
-
export type SocketMessageEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = MessageEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
38
|
-
export type SocketConnectEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = ConnectEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
39
|
-
export type SocketConnectingEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = ConnectingEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
40
|
-
export type SocketDisconnectEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = DisconnectEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
41
|
-
export type SocketPingEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = PingEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
42
|
-
export type SocketPongEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = PongEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
43
|
-
export type SocketRemoveAuthTokenEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = RemoveAuthTokenEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
44
|
-
export type SocketRequestEvent<TService extends ServiceMap, TIncoming extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap> = RequestEvent<TIncoming & TPrivateIncoming & ServerPrivateMap, TService>;
|
|
45
|
-
export type SocketResponseEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = ResponseEvent<TOutgoing, TPrivateOutgoing, TService> & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
46
|
-
export type SocketSubscribeEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = SubscribeEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
47
|
-
export type SocketSubscribeFailEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = SubscribeFailEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
48
|
-
export type SocketSubscribeStateChangeEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = SubscribeStateChangeEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
49
|
-
export type SocketUnsubscribeEvent<TChannel extends ChannelMap, TService extends ServiceMap, TIncoming extends PublicMethodMap, TOutgoing extends PublicMethodMap, TPrivateIncoming extends PrivateMethodMap, TPrivateOutgoing extends PrivateMethodMap, TServerState extends object, TState extends object> = UnsubscribeEvent & ServerSocketEvent<TChannel, TService, TIncoming, TOutgoing, TPrivateIncoming, TPrivateOutgoing, TServerState, TState>;
|
|
File without changes
|