securenow 7.0.0-anas.2 → 7.1.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.
@@ -2,12 +2,15 @@
2
2
 
3
3
  ## Quick Start (1 minute)
4
4
 
5
- ### 1. Install
5
+ ### 1. Install + login
6
6
 
7
7
  ```bash
8
8
  npm install securenow
9
+ npx securenow login # pick/create your app in the browser
9
10
  ```
10
11
 
12
+ `login` writes `.securenow/credentials.json` locally. No `.env` needed for local dev.
13
+
11
14
  ### 2. Add the module to `nuxt.config.ts`
12
15
 
13
16
  ```ts
@@ -16,16 +19,7 @@ export default defineNuxtConfig({
16
19
  });
17
20
  ```
18
21
 
19
- ### 3. Set environment variables
20
-
21
- Create a `.env` file in your project root:
22
-
23
- ```env
24
- SECURENOW_APPID=my-nuxt-app
25
- SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
26
- ```
27
-
28
- ### 4. Start your app
22
+ ### 3. Start your app
29
23
 
30
24
  ```bash
31
25
  nuxt dev
@@ -36,10 +30,20 @@ You should see in the console:
36
30
  ```
37
31
  [securenow] Nuxt module loaded — server plugin registered
38
32
  [securenow] šŸš€ Nuxt OTel SDK started → https://freetrial.securenow.ai:4318/v1/traces
39
- [securenow] service.name=my-nuxt-app instance.id=my-nuxt-app-...
40
33
  ```
41
34
 
42
- That's it — all server-side requests are now traced.
35
+ That's it — all server-side requests are now traced, logs forwarded, and bodies captured. The app you picked during `login` is where they land.
36
+
37
+ ### 4. (Optional) Override for CI / Docker / prod
38
+
39
+ `.securenow/credentials.json` is for local dev. For environments where you can't run `npx securenow login`, set env vars:
40
+
41
+ ```env
42
+ SECURENOW_APPID=<app-key-uuid>
43
+ SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
44
+ ```
45
+
46
+ Env vars always take precedence.
43
47
 
44
48
  ---
45
49
 
@@ -1,34 +1,32 @@
1
- # SecureNow Configuration for Next.js
2
- # Place these in your .env.local file
3
-
4
- # Required: Your application identifier
5
- SECURENOW_APPID=my-nextjs-app
6
-
7
- # Optional: Your OTLP collector endpoint (SecureNow or any OTLP-compatible backend)
8
- # Default: https://freetrial.securenow.ai:4318
9
- SECURENOW_INSTANCE=http://your-otlp-collector:4318
10
-
11
- # Optional: API Key or authentication headers
12
- OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-api-key-here"
13
-
14
- # Optional: Don't append UUID to service name (useful for dev)
15
- # SECURENOW_NO_UUID=1
16
-
17
- # Optional: Log level
18
- # OTEL_LOG_LEVEL=info
19
-
20
- # Optional: Disable specific instrumentations (comma-separated)
21
- # SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns
22
-
23
- # Optional: Create a test span on startup
24
- # SECURENOW_TEST_SPAN=1
25
-
26
- # Next.js will automatically use NODE_ENV
27
- # NODE_ENV=production
28
-
29
-
30
-
31
-
32
-
33
-
34
-
1
+ # SecureNow Configuration for Next.js
2
+ #
3
+ # ============================================================
4
+ # For local dev you do NOT need this file.
5
+ # Instead run:
6
+ # npx securenow login
7
+ # That writes .securenow/credentials.json and the SDK reads it.
8
+ # ============================================================
9
+ #
10
+ # This template is for CI / Docker / Vercel — places where you
11
+ # can't run the interactive login. Env vars always take
12
+ # precedence over .securenow/credentials.json.
13
+
14
+ # App routing key (UUID). From: npx securenow apps
15
+ SECURENOW_APPID=your-app-key-uuid
16
+
17
+ # OTLP collector endpoint. Default is the Free Trial.
18
+ SECURENOW_INSTANCE=https://freetrial.securenow.ai:4318
19
+
20
+ # Optional — defaults are already sensible. Flip to 0 to disable.
21
+ # SECURENOW_LOGGING_ENABLED=0 # forward console.* as OTLP logs
22
+ # SECURENOW_CAPTURE_BODY=0 # capture POST/PUT/PATCH JSON + form bodies
23
+ # SECURENOW_CAPTURE_MULTIPART=0 # capture multipart field / file metadata
24
+ # SECURENOW_MAX_BODY_SIZE=10240 # bytes (default 10KB)
25
+
26
+ # Optional — OTel tuning
27
+ # OTEL_LOG_LEVEL=info
28
+ # SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns
29
+ # SECURENOW_NO_UUID=1 # use bare APPID as service.name (no UUID suffix)
30
+
31
+ # Authentication (auto-set when SECURENOW_APPID is present)
32
+ # OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-api-key-here"
package/firewall-only.js CHANGED
@@ -8,7 +8,7 @@
8
8
  * NODE_OPTIONS='-r securenow/firewall-only' next start
9
9
  *
10
10
  * Reads .env via dotenv (if installed), then initialises the HTTP-level
11
- * firewall when SECURENOW_API_KEY is present.
11
+ * firewall when an API key is resolvable (env var or .securenow/credentials.json).
12
12
  */
13
13
 
14
14
  try { require('dotenv').config(); } catch (_) {}
@@ -16,7 +16,8 @@ try { require('dotenv').config(); } catch (_) {}
16
16
  const env = (k) =>
17
17
  process.env[k] ?? process.env[k.toUpperCase()] ?? process.env[k.toLowerCase()];
18
18
 
19
- const firewallApiKey = env('SECURENOW_API_KEY');
19
+ const { resolveApiKey } = require('./app-config');
20
+ const firewallApiKey = resolveApiKey();
20
21
 
21
22
  if (firewallApiKey && env('SECURENOW_FIREWALL_ENABLED') !== '0') {
22
23
  require('./firewall').init({
package/nextjs.js CHANGED
@@ -610,8 +610,10 @@ function registerSecureNow(options = {}) {
610
610
  }
611
611
  }
612
612
 
613
- // Firewall — runs independently from OTel so it works even if tracing fails
614
- const firewallApiKey = env('SECURENOW_API_KEY');
613
+ // Firewall — runs independently from OTel so it works even if tracing fails.
614
+ // Key comes from env OR .securenow/credentials.json (set via
615
+ // `npx securenow api-key set snk_live_...`), so you don't need a .env entry.
616
+ const firewallApiKey = require('./app-config').resolveApiKey();
615
617
  if (firewallApiKey && env('SECURENOW_FIREWALL_ENABLED') !== '0') {
616
618
  try {
617
619
  require('./firewall').init({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securenow",
3
- "version": "7.0.0-anas.2",
3
+ "version": "7.1.0",
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",
package/postinstall.js CHANGED
@@ -289,19 +289,11 @@ async function setup() {
289
289
  }
290
290
  }
291
291
 
292
- // Create .env.local if it doesn't exist
293
- const envPath = path.join(process.cwd(), '.env.local');
294
- if (!fs.existsSync(envPath)) {
295
- createEnvTemplate(envPath);
296
- console.log('āœ… Created .env.local template');
297
- }
298
-
299
292
  console.log('\nā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”');
300
293
  console.log('│ šŸš€ Next Steps: │');
301
294
  console.log('│ │');
302
- console.log('│ 1. Edit .env.local and set: │');
303
- console.log('│ SECURENOW_APPID=your-app-name │');
304
- console.log('│ SECURENOW_INSTANCE=http://your-otlp-backend:4318 │');
295
+ console.log('│ 1. Pick your app in the browser: │');
296
+ console.log('│ npx securenow login │');
305
297
  console.log('│ │');
306
298
  console.log('│ 2. Run your app: npm run dev │');
307
299
  console.log('│ │');
@@ -312,7 +304,7 @@ async function setup() {
312
304
  }
313
305
  console.log('│ šŸ“š Full guide: npm docs securenow │');
314
306
  console.log('ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜\n');
315
-
307
+
316
308
  rl.close();
317
309
  });
318
310