securenow 5.18.0 → 6.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.
Files changed (85) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +40 -239
  3. package/cli.js +455 -415
  4. package/console-instrumentation.js +136 -147
  5. package/docs/ALL-FRAMEWORKS-QUICKSTART.md +455 -1339
  6. package/docs/ARCHITECTURE.md +3 -3
  7. package/docs/AUTO-BODY-CAPTURE.md +1 -1
  8. package/docs/AUTO-SETUP.md +4 -4
  9. package/docs/AUTOMATIC-IP-CAPTURE.md +5 -5
  10. package/docs/BODY-CAPTURE-QUICKSTART.md +2 -2
  11. package/docs/CHANGELOG-NEXTJS.md +1 -1
  12. package/docs/CUSTOMER-GUIDE.md +16 -16
  13. package/docs/EASIEST-SETUP.md +5 -5
  14. package/docs/ENVIRONMENT-VARIABLES.md +652 -880
  15. package/docs/EXPRESS-BODY-CAPTURE.md +12 -13
  16. package/docs/EXPRESS-SETUP-GUIDE.md +720 -719
  17. package/docs/INDEX.md +4 -22
  18. package/docs/LOGGING-GUIDE.md +708 -701
  19. package/docs/LOGGING-QUICKSTART.md +239 -234
  20. package/docs/NEXTJS-BODY-CAPTURE.md +2 -2
  21. package/docs/NEXTJS-GUIDE.md +14 -14
  22. package/docs/NEXTJS-QUICKSTART.md +1 -1
  23. package/docs/NEXTJS-WRAPPER-APPROACH.md +1 -1
  24. package/docs/QUICKSTART-BODY-CAPTURE.md +2 -2
  25. package/docs/REDACTION-EXAMPLES.md +1 -1
  26. package/docs/REQUEST-BODY-CAPTURE.md +10 -19
  27. package/docs/VERCEL-OTEL-MIGRATION.md +3 -3
  28. package/examples/README.md +6 -6
  29. package/examples/instrumentation-with-auto-capture.ts +1 -1
  30. package/examples/nextjs-env-example.txt +2 -2
  31. package/examples/nextjs-instrumentation.js +1 -1
  32. package/examples/nextjs-instrumentation.ts +1 -1
  33. package/examples/nextjs-with-logging-example.md +6 -6
  34. package/examples/nextjs-with-options.ts +1 -1
  35. package/examples/test-nextjs-setup.js +1 -1
  36. package/nextjs-auto-capture.js +207 -199
  37. package/nextjs-middleware.js +181 -186
  38. package/nextjs-webpack-config.js +53 -88
  39. package/nextjs-wrapper.js +158 -158
  40. package/nextjs.d.ts +1 -1
  41. package/nextjs.js +135 -190
  42. package/package.json +45 -67
  43. package/postinstall.js +6 -6
  44. package/register.d.ts +1 -1
  45. package/register.js +4 -39
  46. package/tracing.d.ts +1 -2
  47. package/tracing.js +22 -287
  48. package/web-vite.mjs +156 -239
  49. package/CONSUMING-APPS-GUIDE.md +0 -455
  50. package/NPM_README.md +0 -1933
  51. package/SKILL-API.md +0 -600
  52. package/SKILL-CLI.md +0 -409
  53. package/cidr.js +0 -83
  54. package/cli/apps.js +0 -585
  55. package/cli/auth.js +0 -280
  56. package/cli/client.js +0 -115
  57. package/cli/config.js +0 -173
  58. package/cli/firewall.js +0 -100
  59. package/cli/fp.js +0 -638
  60. package/cli/init.js +0 -201
  61. package/cli/monitor.js +0 -440
  62. package/cli/run.js +0 -133
  63. package/cli/security.js +0 -1064
  64. package/cli/ui.js +0 -386
  65. package/docs/API-KEYS-GUIDE.md +0 -233
  66. package/docs/AUTO-SETUP-SUMMARY.md +0 -331
  67. package/docs/BODY-CAPTURE-FIX.md +0 -261
  68. package/docs/COMPLETION-REPORT.md +0 -408
  69. package/docs/FINAL-SOLUTION.md +0 -335
  70. package/docs/FIREWALL-GUIDE.md +0 -426
  71. package/docs/IMPLEMENTATION-SUMMARY.md +0 -410
  72. package/docs/NEXTJS-BODY-CAPTURE-COMPARISON.md +0 -323
  73. package/docs/NEXTJS-SETUP-COMPLETE.md +0 -795
  74. package/docs/NUXT-GUIDE.md +0 -166
  75. package/docs/SOLUTION-SUMMARY.md +0 -312
  76. package/firewall-cloud.js +0 -212
  77. package/firewall-iptables.js +0 -139
  78. package/firewall-only.js +0 -38
  79. package/firewall-tcp.js +0 -74
  80. package/firewall.js +0 -720
  81. package/free-trial-banner.js +0 -174
  82. package/nuxt-server-plugin.mjs +0 -423
  83. package/nuxt.d.ts +0 -60
  84. package/nuxt.mjs +0 -75
  85. package/resolve-ip.js +0 -77
package/cli/run.js DELETED
@@ -1,133 +0,0 @@
1
- 'use strict';
2
-
3
- const { spawn } = require('child_process');
4
- const path = require('path');
5
- const fs = require('fs');
6
- const ui = require('./ui');
7
-
8
- function isESM(scriptPath) {
9
- if (scriptPath.endsWith('.mjs')) return true;
10
- if (scriptPath.endsWith('.cjs')) return false;
11
-
12
- let dir = path.resolve(path.dirname(scriptPath));
13
- while (true) {
14
- const pkgPath = path.join(dir, 'package.json');
15
- if (fs.existsSync(pkgPath)) {
16
- try {
17
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
18
- return pkg.type === 'module';
19
- } catch { return false; }
20
- }
21
- const parent = path.dirname(dir);
22
- if (parent === dir) break;
23
- dir = parent;
24
- }
25
- return false;
26
- }
27
-
28
- function resolveSecurenowRegister() {
29
- // When running from the published package, securenow/register resolves to our own register.js.
30
- // When running from the monorepo, resolve relative to this file.
31
- try {
32
- return require.resolve('securenow/register');
33
- } catch {
34
- return path.resolve(__dirname, '..', 'register.js');
35
- }
36
- }
37
-
38
- function resolveESMHook() {
39
- // --import uses ESM resolution which requires file:// URLs for absolute paths
40
- // on Windows. Using the bare specifier lets Node's own resolver handle it.
41
- try {
42
- const resolved = require.resolve('@opentelemetry/instrumentation/hook.mjs');
43
- const { pathToFileURL } = require('url');
44
- return pathToFileURL(resolved).href;
45
- } catch {
46
- return '@opentelemetry/instrumentation/hook.mjs';
47
- }
48
- }
49
-
50
- /**
51
- * securenow run [node-flags...] <script> [app-args...]
52
- *
53
- * Spawns node with the correct OTel preload flags.
54
- * Passes through Node flags (--watch, --inspect, etc.) and app arguments.
55
- *
56
- * We re-parse from process.argv directly so that flags like --watch and
57
- * --inspect are forwarded to node verbatim (the CLI's own arg parser
58
- * would otherwise consume them).
59
- */
60
- function run(rawArgs) {
61
- // rawArgs comes directly from process.argv, everything after `run` (or the file path)
62
- if (!rawArgs || rawArgs.length === 0) {
63
- ui.error('Missing script path.');
64
- console.log('');
65
- console.log(` ${ui.c.bold('Usage:')} securenow run [node-flags] <script> [app-args]`);
66
- console.log('');
67
- console.log(` ${ui.c.bold('Examples:')}`);
68
- console.log(` securenow run src/index.js`);
69
- console.log(` securenow run --watch src/index.js`);
70
- console.log(` securenow run --inspect src/server.js --port 3000`);
71
- console.log('');
72
- process.exit(1);
73
- }
74
-
75
- const args = rawArgs;
76
-
77
- // Split into: node flags (before the script), script path, and app args (after)
78
- const nodeFlags = [];
79
- let scriptIdx = -1;
80
-
81
- for (let i = 0; i < args.length; i++) {
82
- if (args[i].startsWith('-')) {
83
- nodeFlags.push(args[i]);
84
- } else {
85
- scriptIdx = i;
86
- break;
87
- }
88
- }
89
-
90
- if (scriptIdx === -1) {
91
- ui.error('No script path found. Provide a .js/.mjs/.ts file to run.');
92
- process.exit(1);
93
- }
94
-
95
- const scriptPath = args[scriptIdx];
96
- const appArgs = args.slice(scriptIdx + 1);
97
-
98
- const esm = isESM(scriptPath);
99
- const registerPath = resolveSecurenowRegister();
100
-
101
- const otelFlags = [];
102
- if (esm) {
103
- otelFlags.push('--import', resolveESMHook());
104
- }
105
- otelFlags.push('--require', registerPath);
106
-
107
- const finalArgs = [...otelFlags, ...nodeFlags, scriptPath, ...appArgs];
108
-
109
- const nodeExe = process.execPath;
110
-
111
- if (process.env.SECURENOW_DEBUG) {
112
- console.log(`[securenow] ${ui.c.dim('exec:')} ${nodeExe} ${finalArgs.join(' ')}`);
113
- }
114
-
115
- const child = spawn(nodeExe, finalArgs, {
116
- stdio: 'inherit',
117
- env: process.env,
118
- cwd: process.cwd(),
119
- });
120
-
121
- child.on('close', (code) => process.exit(code ?? 1));
122
- child.on('error', (err) => {
123
- ui.error(`Failed to start: ${err.message}`);
124
- process.exit(1);
125
- });
126
-
127
- // Forward termination signals to the child
128
- for (const sig of ['SIGINT', 'SIGTERM', 'SIGHUP']) {
129
- process.on(sig, () => child.kill(sig));
130
- }
131
- }
132
-
133
- module.exports = { run };