socket-function 0.145.0 → 0.147.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.145.0",
3
+ "version": "0.147.0",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
@@ -419,9 +419,8 @@ async function compressCached(bufferKey: string, buffer: () => Buffer): Promise<
419
419
  }
420
420
 
421
421
  export function getIsAllowClient(module: NodeJS.Module) {
422
- // TODO: Support blacklisting private modules.
423
- if (module.filename.includes("node_modules")) {
424
- // The packages are public anyway, so we might as well allow serving them client-side. They still need to be included server side, so this doesn't create any vulnerabilities.
422
+ // 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
+ if (allowAllNodeModulesFlag && module.filename.includes("node_modules")) {
425
424
  return true;
426
425
  }
427
426
  return module.allowclient && !module.serveronly;
@@ -445,6 +444,11 @@ export function setRequireBootRequire(dir: string) {
445
444
  baseController.rootResolvePath = dir;
446
445
  }
447
446
 
447
+ let allowAllNodeModulesFlag = false;
448
+ export function allowAllNodeModules() {
449
+ allowAllNodeModulesFlag = true;
450
+ }
451
+
448
452
  export const RequireController = SocketFunction.register(
449
453
  "RequireController-e2f811f3-14b8-4759-b0d6-73f14516cf1d",
450
454
  baseController,
@@ -461,6 +465,7 @@ export const RequireController = SocketFunction.register(
461
465
  injectHTMLBeforeStartup,
462
466
  addMapGetModules,
463
467
  addStaticRoot,
468
+ allowAllNodeModules,
464
469
  }
465
470
  }
466
471
  );