@socket-mesh/server 17.3.4 → 17.3.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socket-mesh/server",
3
- "version": "17.3.4",
3
+ "version": "17.3.6",
4
4
  "description": "Server module for SocketMesh",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -7,9 +7,6 @@ import { AuthEngine } from "@socket-mesh/server-auth";
7
7
  export type ProtocolVersions = 1 | 2;
8
8
  export interface ServerOptions {
9
9
  httpServer?: HttpServer;
10
- wsEngine?: string | {
11
- Server: ws.Server;
12
- };
13
10
  wsEngineServerOptions?: ws.ServerOptions;
14
11
  authKey?: jwt.Secret;
15
12
  perMessageDeflate?: boolean | ws.PerMessageDeflateOptions;
package/server.js CHANGED
@@ -22,6 +22,7 @@ import { InvalidArgumentsError, InvalidOptionsError, InvalidActionError, ServerP
22
22
  import { MiddlewareType } from "./middleware-type";
23
23
  import { MiddlewareStream } from "./middleware-stream";
24
24
  import { ActionHandshakeWS } from "./action";
25
+ import ws from "ws";
25
26
  import base64id from 'base64id';
26
27
  import { ServerSocket } from "./serversocket";
27
28
  import url from "url";
@@ -151,12 +152,14 @@ export class Server extends AsyncStreamEmitter {
151
152
  this.emit('ready', {});
152
153
  }))();
153
154
  }
154
- let wsEngine = typeof opts.wsEngine === 'string' ? require(opts.wsEngine) : opts.wsEngine;
155
- if (!wsEngine || !wsEngine.Server) {
156
- throw new InvalidOptionsError('The wsEngine option must be a path or module name which points ' +
157
- 'to a valid WebSocket engine module with a compatible interface');
158
- }
159
- let WSServer = wsEngine.Server;
155
+ // let wsEngine = typeof opts.wsEngine === 'string' ? require(opts.wsEngine) : opts.wsEngine;
156
+ // if (!wsEngine || !wsEngine.Server) {
157
+ // throw new InvalidOptionsError(
158
+ // 'The wsEngine option must be a path or module name which points ' +
159
+ // 'to a valid WebSocket engine module with a compatible interface'
160
+ // );
161
+ // }
162
+ // let WSServer = wsEngine.Server;
160
163
  if (opts.authPrivateKey != null || opts.authPublicKey != null) {
161
164
  if (opts.authPrivateKey == null) {
162
165
  throw new InvalidOptionsError('The authPrivateKey option must be specified if authPublicKey is specified');
@@ -207,7 +210,7 @@ export class Server extends AsyncStreamEmitter {
207
210
  this.clientsCount = 0;
208
211
  this.pendingClients = {};
209
212
  this.pendingClientsCount = 0;
210
- let wsServerOptions = opts.wsEngineServerOptions || {};
213
+ const wsServerOptions = opts.wsEngineServerOptions || {};
211
214
  wsServerOptions.server = this.httpServer;
212
215
  wsServerOptions.verifyClient = this._verifyHandshake.bind(this);
213
216
  if (wsServerOptions.path == null && this._path != null) {
@@ -225,7 +228,7 @@ export class Server extends AsyncStreamEmitter {
225
228
  if (wsServerOptions.clientTracking == null) {
226
229
  wsServerOptions.clientTracking = false;
227
230
  }
228
- this.wsServer = new WSServer(wsServerOptions);
231
+ this.wsServer = new ws.Server(wsServerOptions);
229
232
  this.wsServer.on('error', this._handleServerError.bind(this));
230
233
  this.wsServer.on('connection', this._handleSocketConnection.bind(this));
231
234
  }
package/serversocket.d.ts CHANGED
@@ -162,7 +162,7 @@ export declare class ServerSocket<T> extends AsyncStreamEmitter<ServerSocketEven
162
162
  private _processTransmit;
163
163
  private _invoke;
164
164
  triggerAuthenticationEvents(oldAuthState: AuthState): void;
165
- setAuthToken(data: AuthToken, options: AuthTokenOptions): Promise<void>;
165
+ setAuthToken(data: AuthToken, options?: AuthTokenOptions): Promise<void>;
166
166
  getAuthToken(): AuthToken | null;
167
167
  deauthenticateSelf(): void;
168
168
  deauthenticate(options?: {