securenow 7.7.12 → 7.7.14

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/NPM_README.md CHANGED
@@ -9,7 +9,7 @@ OpenTelemetry instrumentation library for Node.js, Next.js, and Nuxt application
9
9
  - Built-in sensitive data redaction
10
10
  - Request body capture for debugging
11
11
  - Multi-layer firewall -- auto-blocks IPs from your SecureNow blocklist
12
- - `securenow init` scaffolds Next.js instrumentation and safe `serverExternalPackages`
12
+ - `securenow init` scaffolds Next.js instrumentation, safe `serverExternalPackages`, and standalone output tracing includes
13
13
  - `securenow/firewall-only` entry point for firewall without tracing overhead
14
14
  - Local and production configuration via `.securenow/credentials.json`
15
15
  - Single `-r securenow/register` flag -- works for both CJS and ESM apps
@@ -77,7 +77,7 @@ npx securenow init --key snk_live_abc123...
77
77
 
78
78
  This detects your framework and:
79
79
  - **Credentials**: Ensures `.securenow/credentials.json` has secure defaults and explanations
80
- - **Next.js**: Creates `instrumentation.ts`, adds `serverExternalPackages: ['securenow']` when safe, or prints a Codex/Claude-ready merge prompt for existing files
80
+ - **Next.js**: Creates `instrumentation.ts`, adds `serverExternalPackages: ['securenow']` plus `outputFileTracingIncludes` when safe, or prints a Codex/Claude-ready merge prompt for existing files
81
81
  - **Nuxt 3**: Suggests adding `securenow/nuxt` to modules
82
82
  - **Express / Node.js**: Shows how to add `-r securenow/register` to your start script
83
83
  - **All**: Stores `--key` in `.securenow/credentials.json`; no local `.env` file is needed
@@ -174,7 +174,7 @@ npx securenow init
174
174
  npx securenow init --key snk_live_abc123...
175
175
  ```
176
176
 
177
- For Next.js projects, `init` creates `instrumentation.ts` (or `.js` if no TypeScript), adds `serverExternalPackages: ['securenow']` when safe, and prints exact merge instructions for Codex/Claude when existing files need judgment. For Nuxt, it suggests adding `securenow/nuxt` to your modules. For Express/Node, it shows the `-r securenow/register` flag.
177
+ For Next.js projects, `init` creates `instrumentation.ts` (or `.js` if no TypeScript), adds `serverExternalPackages: ['securenow']` plus `outputFileTracingIncludes` when safe, and prints exact merge instructions for Codex/Claude when existing files need judgment. For Nuxt, it suggests adding `securenow/nuxt` to your modules. For Express/Node, it shows the `-r securenow/register` flag.
178
178
 
179
179
  ### MCP for Codex and Claude
180
180
 
@@ -957,7 +957,7 @@ Use `npx securenow init` for the current Next.js integration; it creates or prin
957
957
 
958
958
  #### Option A: `securenow init` (Recommended)
959
959
 
960
- The init command handles the boring parts: credentials defaults, `instrumentation.ts`, body auto-capture, and `serverExternalPackages` for Next 15+. If existing files are custom, it prints a Codex/Claude-ready prompt instead of guessing.
960
+ The init command handles the boring parts: credentials defaults, `instrumentation.ts`, body auto-capture, `serverExternalPackages`, and standalone output tracing includes for Next 15+. If existing files are custom, it prints a Codex/Claude-ready prompt instead of guessing.
961
961
 
962
962
  ```bash
963
963
  npx securenow login
@@ -967,15 +967,13 @@ npx securenow init
967
967
  **Generated `instrumentation.ts` (or `.js`):**
968
968
 
969
969
  ```typescript
970
- import { createRequire } from 'node:module';
971
-
972
- const require = createRequire(import.meta.url);
973
-
974
970
  export async function register() {
975
971
  if (process.env.NEXT_RUNTIME !== 'nodejs') return;
976
- const { registerSecureNow } = require('securenow/nextjs');
972
+
973
+ const securenowNext = await import(/* webpackIgnore: true */ 'securenow/nextjs');
974
+ const registerSecureNow = securenowNext.registerSecureNow || securenowNext.default?.registerSecureNow;
977
975
  registerSecureNow({ captureBody: true });
978
- require('securenow/nextjs-auto-capture');
976
+ await import(/* webpackIgnore: true */ 'securenow/nextjs-auto-capture');
979
977
  }
980
978
  ```
981
979
 
@@ -984,6 +982,9 @@ export async function register() {
984
982
  ```javascript
985
983
  const nextConfig = {
986
984
  serverExternalPackages: ['securenow'],
985
+ outputFileTracingIncludes: {
986
+ '/*': ['./node_modules/securenow/**/*'],
987
+ },
987
988
  };
988
989
 
989
990
  export default nextConfig;
@@ -999,6 +1000,9 @@ If you prefer not to run `init`, manually externalize SecureNow:
999
1000
  // next.config.js (Next.js 15+)
1000
1001
  module.exports = {
1001
1002
  serverExternalPackages: ['securenow'],
1003
+ outputFileTracingIncludes: {
1004
+ '/*': ['./node_modules/securenow/**/*'],
1005
+ },
1002
1006
  };
1003
1007
  ```
1004
1008
 
@@ -1009,10 +1013,13 @@ module.exports = {
1009
1013
  instrumentationHook: true,
1010
1014
  serverComponentsExternalPackages: ['securenow'],
1011
1015
  },
1016
+ outputFileTracingIncludes: {
1017
+ '/*': ['./node_modules/securenow/**/*'],
1018
+ },
1012
1019
  };
1013
1020
  ```
1014
1021
 
1015
- **Why is this needed?** Next.js bundles server code with webpack, which can break OpenTelemetry's dynamic `require()` calls and monkey-patching. Externalizing `securenow` keeps the SDK as normal Node.js runtime code.
1022
+ **Why is this needed?** Next.js bundles server code with webpack, which can break OpenTelemetry's dynamic `require()` calls and monkey-patching. Externalizing `securenow` keeps the SDK as normal Node.js runtime code. `outputFileTracingIncludes` keeps SecureNow's runtime modules available in standalone/self-hosted output, including the firewall.
1016
1023
 
1017
1024
  ---
1018
1025
 
@@ -1063,7 +1070,7 @@ The Nuxt server plugin (v5.13.0+) initializes the firewall independently from Op
1063
1070
  | Micro/HTTP | Yes | Yes | Yes | Yes | Full control |
1064
1071
  | Hono | Yes | Yes | Yes | Yes | Use ESM `-r` preload |
1065
1072
  | Feathers | Yes | Yes | Yes | Yes | Uses Express transport |
1066
- | Next.js | Yes | Yes | Yes | Yes | Use `instrumentation.ts` + `serverExternalPackages: ['securenow']` |
1073
+ | Next.js | Yes | Yes | Yes | Yes | Use `instrumentation.ts` + `serverExternalPackages` + `outputFileTracingIncludes` |
1067
1074
  | Nuxt 3 | Yes | Yes | Yes | Yes | Use `securenow/nuxt` module |
1068
1075
 
1069
1076
  ---
@@ -1135,7 +1142,7 @@ This is useful when:
1135
1142
  - You only need IP blocking, not observability
1136
1143
  - You want to minimize startup time and memory footprint
1137
1144
  - You're adding the firewall to a project that uses a different tracing solution
1138
- - For Next.js, this avoids the need for `serverExternalPackages` entirely
1145
+ - For non-Next Node apps, this avoids framework-specific tracing setup entirely
1139
1146
 
1140
1147
  Firewall-only mode uses the same `.securenow/credentials.json` key written by `login`, `api-key set`, or mounted from a runtime credentials file:
1141
1148
 
@@ -1290,7 +1297,7 @@ SecureNow provides multiple entry points depending on your needs:
1290
1297
  |-------------|-------|-------------------|-------------------|-------|
1291
1298
  | `securenow/register` | `node -r securenow/register app.js` | Yes | Yes | Default -- full tracing + firewall |
1292
1299
  | `securenow/firewall-only` | `node -r securenow/firewall-only app.js` | No | Yes | Firewall only, no OTel overhead |
1293
- | `securenow/nextjs` | `require('securenow/nextjs').registerSecureNow()` | Yes | Yes | Next.js instrumentation hook |
1300
+ | `securenow/nextjs` | `await import(/* webpackIgnore: true */ 'securenow/nextjs')` | Yes | Yes | Next.js instrumentation hook |
1294
1301
  | `securenow/nuxt` | `modules: ['securenow/nuxt']` | Yes | Yes | Nuxt 3 module |
1295
1302
  | `securenow/nextjs-webpack-config` | `withSecureNow(config)` | - | - | Next.js config wrapper |
1296
1303
  | `securenow/firewall` | `require('securenow/firewall').init({...})` | No | Yes | Programmatic firewall API |
@@ -1556,10 +1563,12 @@ const enabled: boolean = isLoggingEnabled();
1556
1563
  ```typescript
1557
1564
  // instrumentation.ts
1558
1565
  export async function register() {
1559
- if (process.env.NEXT_RUNTIME === 'nodejs') {
1560
- const { registerSecureNow } = require('securenow/nextjs');
1561
- registerSecureNow();
1562
- }
1566
+ if (process.env.NEXT_RUNTIME !== 'nodejs') return;
1567
+
1568
+ const securenowNext = await import(/* webpackIgnore: true */ 'securenow/nextjs');
1569
+ const registerSecureNow = securenowNext.registerSecureNow || securenowNext.default?.registerSecureNow;
1570
+ registerSecureNow({ captureBody: true });
1571
+ await import(/* webpackIgnore: true */ 'securenow/nextjs-auto-capture');
1563
1572
  }
1564
1573
  ```
1565
1574
 
@@ -1572,6 +1581,8 @@ module.exports = withSecureNow({
1572
1581
  });
1573
1582
  ```
1574
1583
 
1584
+ `withSecureNow()` adds the server external package config and `outputFileTracingIncludes` for standalone/self-hosted builds.
1585
+
1575
1586
  ### NestJS with TypeScript
1576
1587
 
1577
1588
  Use `-r securenow/register -r ts-node/register` flags instead of in-code require:
@@ -1796,6 +1807,9 @@ Bodies larger than `config.capture.maxBodySize` are truncated:
1796
1807
  ```javascript
1797
1808
  module.exports = {
1798
1809
  serverExternalPackages: ['securenow'],
1810
+ outputFileTracingIncludes: {
1811
+ '/*': ['./node_modules/securenow/**/*'],
1812
+ },
1799
1813
  };
1800
1814
  ```
1801
1815
 
@@ -1807,7 +1821,7 @@ For Next.js < 15, add `securenow` to `experimental.serverComponentsExternalPacka
1807
1821
 
1808
1822
  **Check 3: Check for OTel MODULE_NOT_FOUND errors**
1809
1823
 
1810
- If you see `MODULE_NOT_FOUND` for `@opentelemetry/*` packages, your `next.config.js` is missing the externalization. Run `npx securenow init`; if your config is custom, use the prompt it prints to merge the edit safely.
1824
+ If you see `MODULE_NOT_FOUND` for `@opentelemetry/*`, `./firewall`, or other SecureNow runtime modules, your `next.config.js` is missing the externalization or standalone output include. Run `npx securenow init`; if your config is custom, use the prompt it prints to merge the edit safely.
1811
1825
 
1812
1826
  **Check 4: Restart dev server**
1813
1827
 
package/README.md CHANGED
@@ -60,6 +60,24 @@ The SDK reads this file at boot and sends traces/logs directly to the right app
60
60
 
61
61
  ---
62
62
 
63
+ ## Monorepo / AI-agent setup
64
+
65
+ If you have many apps under one repo, authenticate once from the repo root:
66
+
67
+ ```bash
68
+ npx securenow login
69
+ ```
70
+
71
+ Then ask your coding agent to wire each app with this prompt:
72
+
73
+ ```text
74
+ I already ran npx securenow login from the repo root. For every Node.js or Next.js app under this repo: install securenow@latest, run or merge npx securenow init, create or reuse a SecureNow app, write local .securenow/credentials.json plus tokenless .securenow/credentials.production.json, gitignore .securenow, enable traces, logs, body capture, multipart metadata, and firewall, then verify with npx securenow env --json, npx securenow test-span, npx securenow log send, and a local HTTP smoke test where possible. Do not print secrets.
75
+ ```
76
+
77
+ For production, deploy the tokenless runtime credentials as a secret file mounted at `<app-root>/.securenow/credentials.json`.
78
+
79
+ ---
80
+
63
81
  ## Framework integration
64
82
 
65
83
  ### Node.js / Express / Fastify / NestJS / Koa / Hapi
@@ -82,27 +100,28 @@ NODE_OPTIONS="-r securenow/register" npm start
82
100
  npx securenow init
83
101
  ```
84
102
 
85
- Creates `instrumentation.ts` and shows you how to wrap `next.config.js`:
103
+ Creates `instrumentation.ts` and patches `next.config.*` when it can do so safely:
86
104
 
87
105
  ```typescript
88
106
  // instrumentation.ts
89
- import { createRequire } from 'node:module';
90
-
91
- const require = createRequire(import.meta.url);
92
-
93
107
  export async function register() {
94
108
  if (process.env.NEXT_RUNTIME !== 'nodejs') return;
95
- const { registerSecureNow } = require('securenow/nextjs');
109
+
110
+ const securenowNext = await import(/* webpackIgnore: true */ 'securenow/nextjs');
111
+ const registerSecureNow = securenowNext.registerSecureNow || securenowNext.default?.registerSecureNow;
96
112
  registerSecureNow({ captureBody: true });
97
- require('securenow/nextjs-auto-capture');
113
+ await import(/* webpackIgnore: true */ 'securenow/nextjs-auto-capture');
98
114
  }
99
115
  ```
100
116
 
101
- For Next.js 15+, `init` adds `securenow` to `serverExternalPackages` when it can safely edit the file:
117
+ For Next.js 15+, `init` adds `securenow` to `serverExternalPackages` and includes the SDK in standalone output when it can safely edit the file:
102
118
 
103
119
  ```javascript
104
120
  const nextConfig = {
105
121
  serverExternalPackages: ['securenow'],
122
+ outputFileTracingIncludes: {
123
+ '/*': ['./node_modules/securenow/**/*'],
124
+ },
106
125
  };
107
126
 
108
127
  export default nextConfig;
package/SKILL-API.md CHANGED
@@ -160,12 +160,15 @@ Run `npx securenow init` first. It creates the straightforward integration below
160
160
  ```javascript
161
161
  const nextConfig = {
162
162
  serverExternalPackages: ['securenow'],
163
+ outputFileTracingIncludes: {
164
+ '/*': ['./node_modules/securenow/**/*'],
165
+ },
163
166
  };
164
167
 
165
168
  export default nextConfig;
166
169
  ```
167
170
 
168
- For Next.js < 15, add `securenow` to `experimental.serverComponentsExternalPackages` instead.
171
+ For Next.js < 15, add `securenow` to `experimental.serverComponentsExternalPackages` instead and keep the same `outputFileTracingIncludes` block for standalone/self-hosted output.
169
172
 
170
173
  **2. `instrumentation.ts`** (or `.js`, can be in `src/`):
171
174
 
@@ -254,7 +257,7 @@ npx securenow login
254
257
  npx securenow init
255
258
  ```
256
259
 
257
- Auto-detects Next.js, creates `instrumentation.ts`, adds `serverExternalPackages: ['securenow']` when safe, and reuses the app, instance, firewall key, and secure defaults in `.securenow/credentials.json`. If files already exist, it prints an agent-ready prompt with the exact edits to propose.
260
+ Auto-detects Next.js, creates `instrumentation.ts`, adds `serverExternalPackages: ['securenow']` plus `outputFileTracingIncludes` when safe, and reuses the app, instance, firewall key, and secure defaults in `.securenow/credentials.json`. If files already exist, it prints an agent-ready prompt with the exact edits to propose.
258
261
 
259
262
  ---
260
263
 
package/SKILL-CLI.md CHANGED
@@ -173,7 +173,7 @@ securenow init [--env local] [--key <API_KEY>]
173
173
 
174
174
  Auto-detects framework (Next.js, Nuxt, Express, Fastify, Koa, Hapi, Node) from `package.json`. Then:
175
175
  - **Credentials**: ensures `.securenow/credentials.json` exists, has secure defaults/explanations, and `.securenow/` is gitignored
176
- - **Next.js**: creates `instrumentation.ts/js` with `securenow/nextjs` + `securenow/nextjs-auto-capture`, and adds `serverExternalPackages: ['securenow']` when the config can be patched safely
176
+ - **Next.js**: creates `instrumentation.ts/js` with `securenow/nextjs` + `securenow/nextjs-auto-capture`, and adds `serverExternalPackages: ['securenow']` plus `outputFileTracingIncludes` when the config can be patched safely
177
177
  - **Existing Next.js files**: prints a Codex/Claude-ready merge prompt when instrumentation or config already exists or is too custom to safely patch
178
178
  - **Nuxt**: tells you to add `securenow/nuxt` to modules
179
179
  - **Node/Express/etc.**: suggests adding `-r securenow/register` to start script
package/cli/init.js CHANGED
@@ -137,6 +137,9 @@ async function initNextJs(dir, project, flags) {
137
137
  fs.writeFileSync(newConfigPath, `/** @type {import('next').NextConfig} */
138
138
  const nextConfig = {
139
139
  serverExternalPackages: ['securenow'],
140
+ outputFileTracingIncludes: {
141
+ '/*': ['./node_modules/securenow/**/*'],
142
+ },
140
143
  };
141
144
 
142
145
  export default nextConfig;
@@ -149,21 +152,47 @@ function patchNextConfig(configPath, major) {
149
152
  const content = fs.readFileSync(configPath, 'utf8');
150
153
  const serverExternalWithSecureNow = /serverExternalPackages\s*:\s*\[[\s\S]*?['"]securenow['"][\s\S]*?\]/m.test(content);
151
154
  const serverComponentsWithSecureNow = /serverComponentsExternalPackages\s*:\s*\[[\s\S]*?['"]securenow['"][\s\S]*?\]/m.test(content);
152
- if (serverExternalWithSecureNow || serverComponentsWithSecureNow || content.includes('withSecureNow(')) {
155
+ const traceIncludeWithSecureNow = /outputFileTracingIncludes\s*:\s*{[\s\S]*?node_modules\/securenow\/\*\*/m.test(content);
156
+ if ((serverExternalWithSecureNow || serverComponentsWithSecureNow || content.includes('withSecureNow(')) && traceIncludeWithSecureNow) {
153
157
  return 'already';
154
158
  }
155
159
 
156
160
  if (major < 15) return 'manual';
157
161
 
162
+ function addTraceInclude(nextContent) {
163
+ if (traceIncludeWithSecureNow || /outputFileTracingIncludes\s*:/.test(nextContent)) return nextContent;
164
+ const insert = ` outputFileTracingIncludes: {\n '/*': ['./node_modules/securenow/**/*'],\n },\n`;
165
+ const patterns = [
166
+ /(const\s+nextConfig\s*=\s*{\s*\r?\n)/,
167
+ /(export\s+default\s+{\s*\r?\n)/,
168
+ /(module\.exports\s*=\s*{\s*\r?\n)/,
169
+ ];
170
+ for (const pattern of patterns) {
171
+ if (pattern.test(nextContent)) return nextContent.replace(pattern, `$1${insert}`);
172
+ }
173
+ return null;
174
+ }
175
+
176
+ if (serverExternalWithSecureNow || serverComponentsWithSecureNow || content.includes('withSecureNow(')) {
177
+ const withTraceInclude = addTraceInclude(content);
178
+ if (withTraceInclude && withTraceInclude !== content) {
179
+ fs.writeFileSync(configPath, withTraceInclude, 'utf8');
180
+ return 'patched';
181
+ }
182
+ return 'manual';
183
+ }
184
+
158
185
  const existingServerExternal = content.match(/serverExternalPackages\s*:\s*\[([\s\S]*?)\]/m);
159
186
  if (existingServerExternal) {
160
187
  const current = existingServerExternal[1].trim().replace(/,\s*$/, '');
161
188
  const replacement = `serverExternalPackages: [${current ? `${current}, ` : ''}'securenow']`;
162
- fs.writeFileSync(configPath, content.replace(existingServerExternal[0], replacement), 'utf8');
189
+ let nextContent = content.replace(existingServerExternal[0], replacement);
190
+ nextContent = addTraceInclude(nextContent) || nextContent;
191
+ fs.writeFileSync(configPath, nextContent, 'utf8');
163
192
  return 'patched';
164
193
  }
165
194
 
166
- const insert = ` serverExternalPackages: ['securenow'],\n`;
195
+ const insert = ` serverExternalPackages: ['securenow'],\n outputFileTracingIncludes: {\n '/*': ['./node_modules/securenow/**/*'],\n },\n`;
167
196
  const patterns = [
168
197
  /(const\s+nextConfig\s*=\s*{\s*\r?\n)/,
169
198
  /(export\s+default\s+{\s*\r?\n)/,
@@ -212,7 +241,7 @@ function printAgentPrompt(kind, filename, major, project) {
212
241
  ? `Merge this into ${filename}: in register(), return unless process.env.NEXT_RUNTIME === "nodejs"; then dynamically import "securenow/nextjs" and "securenow/nextjs-auto-capture" with /* webpackIgnore: true */ so Next does not bundle OpenTelemetry internals. Preserve all existing instrumentation.`
213
242
  : null,
214
243
  kind === 'next-config' && major >= 15
215
- ? `Update ${filename} while preserving existing config: add securenow to serverExternalPackages, e.g. serverExternalPackages: [...(existing || []), "securenow"].`
244
+ ? `Update ${filename} while preserving existing config: add securenow to serverExternalPackages, e.g. serverExternalPackages: [...(existing || []), "securenow"], and include SecureNow runtime files for standalone output with outputFileTracingIncludes: { "/*": ["./node_modules/securenow/**/*"] }.`
216
245
  : null,
217
246
  kind === 'next-config' && major < 15
218
247
  ? `Update ${filename} while preserving existing config: enable experimental.instrumentationHook and add securenow to experimental.serverComponentsExternalPackages.`
@@ -1,14 +1,17 @@
1
1
  'use strict';
2
2
 
3
3
  /**
4
- * Next.js configuration helpers for SecureNow
4
+ * Next.js configuration helpers for SecureNow
5
5
  *
6
6
  * Usage (recommended — zero-list approach):
7
7
  *
8
- * const { withSecureNow } = require('securenow/nextjs-webpack-config');
9
- * module.exports = withSecureNow({
10
- * // your existing next.config options
11
- * });
8
+ * const { withSecureNow } = require('securenow/nextjs-webpack-config');
9
+ * module.exports = withSecureNow({
10
+ * // your existing next.config options
11
+ * });
12
+ *
13
+ * This externalizes SecureNow for server bundles and includes the package in
14
+ * standalone output so runtime modules such as the firewall are available.
12
15
  *
13
16
  * Legacy webpack-only helper (still exported for backwards compat):
14
17
  *
@@ -19,6 +22,8 @@
19
22
  const EXTERNAL_PACKAGES = [
20
23
  'securenow',
21
24
  ];
25
+ const OUTPUT_TRACE_INCLUDE_KEY = '/*';
26
+ const SECURENOW_OUTPUT_TRACE_INCLUDE = './node_modules/securenow/**/*';
22
27
 
23
28
  function detectNextMajor() {
24
29
  try {
@@ -30,8 +35,9 @@ function detectNextMajor() {
30
35
  }
31
36
 
32
37
  /**
33
- * Wrap a Next.js config object to auto-externalize SecureNow + OTel
34
- * packages and enable the instrumentation hook.
38
+ * Wrap a Next.js config object to auto-externalize SecureNow,
39
+ * include runtime files in standalone output, and enable the
40
+ * instrumentation hook.
35
41
  *
36
42
  * module.exports = withSecureNow({ reactStrictMode: true });
37
43
  */
@@ -48,16 +54,18 @@ function withSecureNow(userConfig) {
48
54
  ...(cfg.serverExternalPackages || []),
49
55
  ...EXTERNAL_PACKAGES,
50
56
  ]);
51
- } else {
52
- cfg.experimental = { ...(cfg.experimental || {}) };
53
- cfg.experimental.instrumentationHook = true;
57
+ } else {
58
+ cfg.experimental = { ...(cfg.experimental || {}) };
59
+ cfg.experimental.instrumentationHook = true;
54
60
  cfg.experimental.serverComponentsExternalPackages = dedup([
55
61
  ...(cfg.experimental.serverComponentsExternalPackages || []),
56
62
  ...EXTERNAL_PACKAGES,
57
- ]);
58
- }
59
-
60
- const origWebpack = cfg.webpack;
63
+ ]);
64
+ }
65
+
66
+ cfg.outputFileTracingIncludes = mergeOutputFileTracingIncludes(cfg.outputFileTracingIncludes);
67
+
68
+ const origWebpack = cfg.webpack;
61
69
  cfg.webpack = (config, options) => {
62
70
  const c = origWebpack ? origWebpack(config, options) : config;
63
71
  return getSecureNowWebpackConfig(c, options);
@@ -66,9 +74,24 @@ function withSecureNow(userConfig) {
66
74
  return cfg;
67
75
  }
68
76
 
69
- function dedup(arr) {
70
- return [...new Set(arr)];
71
- }
77
+ function dedup(arr) {
78
+ return [...new Set(arr)];
79
+ }
80
+
81
+ function mergeOutputFileTracingIncludes(existing) {
82
+ const includes = { ...(existing || {}) };
83
+ const current = includes[OUTPUT_TRACE_INCLUDE_KEY];
84
+
85
+ if (Array.isArray(current)) {
86
+ includes[OUTPUT_TRACE_INCLUDE_KEY] = dedup([...current, SECURENOW_OUTPUT_TRACE_INCLUDE]);
87
+ } else if (typeof current === 'string') {
88
+ includes[OUTPUT_TRACE_INCLUDE_KEY] = dedup([current, SECURENOW_OUTPUT_TRACE_INCLUDE]);
89
+ } else if (!current) {
90
+ includes[OUTPUT_TRACE_INCLUDE_KEY] = [SECURENOW_OUTPUT_TRACE_INCLUDE];
91
+ }
92
+
93
+ return includes;
94
+ }
72
95
 
73
96
  /**
74
97
  * Legacy: suppress OTel webpack warnings and add externals.
@@ -97,4 +120,4 @@ function getSecureNowWebpackConfig(config, options) {
97
120
  return config;
98
121
  }
99
122
 
100
- module.exports = { withSecureNow, getSecureNowWebpackConfig, EXTERNAL_PACKAGES };
123
+ module.exports = { withSecureNow, getSecureNowWebpackConfig, EXTERNAL_PACKAGES };
package/nextjs.js CHANGED
@@ -5,19 +5,24 @@
5
5
  *
6
6
  * Usage in Next.js app:
7
7
  *
8
- * 1. Add securenow to serverExternalPackages in next.config.js:
8
+ * 1. Add securenow to serverExternalPackages and standalone output tracing
9
+ * includes in next.config.js:
9
10
  *
10
11
  * const nextConfig = {
11
12
  * serverExternalPackages: ["securenow"],
13
+ * outputFileTracingIncludes: {
14
+ * "/*": ["<securenow package glob>"],
15
+ * },
12
16
  * };
13
17
  *
14
18
  * 2. Create instrumentation.ts (or .js) in your project root:
15
19
  *
16
20
  * export async function register() {
17
21
  * if (process.env.NEXT_RUNTIME !== "nodejs") return;
18
- * const securenowNext = await import("securenow/nextjs");
19
- * securenowNext.registerSecureNow({ captureBody: true });
20
- * await import("securenow/nextjs-auto-capture");
22
+ * const securenowNext = await import(/* webpackIgnore: true *\/ "securenow/nextjs");
23
+ * const registerSecureNow = securenowNext.registerSecureNow || securenowNext.default?.registerSecureNow;
24
+ * registerSecureNow({ captureBody: true });
25
+ * await import(/* webpackIgnore: true *\/ "securenow/nextjs-auto-capture");
21
26
  * }
22
27
  *
23
28
  * 3. Run `npx securenow login` and `npx securenow init`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securenow",
3
- "version": "7.7.12",
3
+ "version": "7.7.14",
4
4
  "description": "OpenTelemetry instrumentation for Node.js, Next.js, and Nuxt - Send traces and logs to any OTLP-compatible backend",
5
5
  "type": "commonjs",
6
6
  "main": "register.js",