socket-function 0.147.0 → 0.148.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "socket-function",
3
- "version": "0.147.0",
3
+ "version": "0.148.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -419,11 +419,12 @@ async function compressCached(bufferKey: string, buffer: () => Buffer): Promise<
419
419
  }
420
420
 
421
421
  export function getIsAllowClient(module: NodeJS.Module) {
422
+ if (module.serveronly) return false;
422
423
  // IMPORTANT! We do not allow everything in node modules by default, as most things in node modules, you don't want to import client-side, and it will break if you import it client-side. Many of these are imported, but will never end up being called client-side, so it's fine to exclude them.
423
424
  if (allowAllNodeModulesFlag && module.filename.includes("node_modules")) {
424
425
  return true;
425
426
  }
426
- return module.allowclient && !module.serveronly;
427
+ return module.allowclient;
427
428
  }
428
429
 
429
430
  type ClientRemapCallback = (args: GetModulesArgs) => Promise<GetModulesArgs>;
@@ -2,7 +2,6 @@ import https from "https";
2
2
  import http from "http";
3
3
  import net from "net";
4
4
  import tls from "tls";
5
- import * as ws from "ws";
6
5
  import { getNodeIdsFromRequest, httpCallHandler } from "./callHTTPHandler";
7
6
  import { SocketFunction } from "../SocketFunction";
8
7
  import { getTrustedCertificates, watchTrustedCertificates } from "./certStore";
@@ -60,6 +59,7 @@ export type SocketServerConfig = (
60
59
  export async function startSocketServer(
61
60
  config: SocketServerConfig
62
61
  ): Promise<string> {
62
+ const ws = await import("ws");
63
63
 
64
64
  const webSocketServer = new ws.Server({
65
65
  noServer: true,
@@ -1,4 +1,3 @@
1
- import ws from "ws";
2
1
  import tls from "tls";
3
2
  import { isNode } from "./misc";
4
3
  import { SenderInterface } from "./CallFactory";
@@ -6,6 +5,7 @@ import { getTrustedCertificates } from "./certStore";
6
5
  import { getNodeIdLocation } from "./nodeCache";
7
6
  import debugbreak from "debugbreak";
8
7
  import { SocketFunction } from "../SocketFunction";
8
+ import type * as ws from "ws";
9
9
 
10
10
  export function getTLSSocket(webSocket: ws.WebSocket) {
11
11
  return (webSocket as any)._socket as tls.TLSSocket;
@@ -36,6 +36,7 @@ export function createWebsocketFactory(): (nodeId: string) => SenderInterface {
36
36
  if (!SocketFunction.silent) {
37
37
  console.log(`Connecting to ${address}:${port}`);
38
38
  }
39
+ const ws = require("ws") as typeof import("ws");
39
40
  let webSocket = new ws.WebSocket(`wss://${address}:${port}`, undefined, {
40
41
  ca: getTrustedCertificates(),
41
42
  });