securenow 7.7.10 → 7.7.11

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
@@ -157,7 +157,8 @@ npx securenow login --global
157
157
  # Check who you're logged in as (shows auth source)
158
158
  npx securenow whoami
159
159
 
160
- # Already have a firewall key? Store it without re-running login:
160
+ # Need or already have a firewall key? Create or store it without re-running login:
161
+ npx securenow api-key create --name "CLI firewall"
161
162
  npx securenow api-key set snk_live_abc123... # --global for ~/.securenow/
162
163
  npx securenow api-key show # masked key + source
163
164
  npx securenow api-key clear # remove just the key
@@ -491,7 +492,8 @@ npx securenow logs --json --level error | jq '.logs'
491
492
  | | `apps info <id>` | Application details |
492
493
  | | `apps delete <id>` | Delete application |
493
494
  | | `apps default <key>` | Set default app |
494
- | **API Key** | `api-key set <snk_live_...> [--global]` | Save firewall key to `.securenow/credentials.json` |
495
+ | **API Key** | `api-key create [--name "CLI firewall"] [--global]` | Mint and save a firewall key with your logged-in session |
496
+ | | `api-key set <snk_live_...> [--global]` | Save firewall key to `.securenow/credentials.json` |
495
497
  | | `api-key show` | Show masked key + source |
496
498
  | | `api-key clear [--global]` | Remove stored key (leaves session/app) |
497
499
  | **Observe** | `traces` | List traces |
package/README.md CHANGED
@@ -175,6 +175,7 @@ npx securenow login --global # save to ~/.securenow/ instead
175
175
  npx securenow login --token <TOKEN> # headless (CI)
176
176
  npx securenow init --env local # scaffold framework files + local env scope
177
177
  npx securenow credentials runtime --env production # write tokenless production credentials file
178
+ npx securenow api-key create --name "CLI firewall" # mint + store firewall key
178
179
  npx securenow api-key set snk_live_... # store firewall key in .securenow/credentials.json
179
180
 
180
181
  # Apps
@@ -301,6 +302,7 @@ After install, the `securenow` CLI is available via `npx securenow` or globally
301
302
  | `securenow logout` | Clear project-local credentials |
302
303
  | `securenow logout --global` | Clear ~/.securenow/ instead |
303
304
  | `securenow whoami` | Show current session (email, app, expiry) |
305
+ | `securenow api-key create [--name "CLI firewall"]` | Mint and store a firewall key using your session token |
304
306
  | `securenow api-key set <snk_live_...>` | Store firewall key in `.securenow/credentials.json` (`--global` for `~/.securenow/`) |
305
307
  | `securenow api-key show` | Print masked key + source file |
306
308
  | `securenow api-key clear` | Remove stored key (`--global` for `~/.securenow/`) |
package/SKILL-CLI.md CHANGED
@@ -153,16 +153,17 @@ securenow apps scan [--yes] # scan all app domains for new subd
153
153
 
154
154
  Manage the firewall API key stored in the credentials file. Since v7.5.1 the login flow writes `snk_live_...` keys to `.securenow/credentials.json` by default, so no env var is required for local dev.
155
155
 
156
- ```bash
157
- securenow api-key set snk_live_xxxxxxxxxx # save to project ./.securenow/ (default)
158
- securenow api-key set snk_live_xxx --global # save to ~/.securenow/ instead
156
+ ```bash
157
+ securenow api-key create --name "CLI firewall" # mint + save a firewall key with your logged-in session
158
+ securenow api-key set snk_live_xxxxxxxxxx # save to project ./.securenow/ (default)
159
+ securenow api-key set snk_live_xxx --global # save to ~/.securenow/ instead
159
160
  securenow api-key show # print the masked current key + its source
160
161
  securenow api-key clear # remove just the API key (keeps session/app)
161
162
  securenow api-key clear --global # same, but from the global file
162
163
  securenow credentials runtime --env production # write .securenow/credentials.production.json for production secret-file deploys
163
164
  ```
164
165
 
165
- The key must start with `snk_live_`. `securenow login` with firewall enabled writes the key automatically; use `api-key set` when you already have a key from the dashboard, or to rotate it later.
166
+ The key must start with `snk_live_`. `securenow login` with firewall enabled writes the key automatically; use `api-key create` when you have an account session but no runtime key yet, or `api-key set` when you already have a key from the dashboard.
166
167
 
167
168
  ### Init — Project Setup
168
169
 
package/cli/apiKey.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const { api, requireAuth } = require('./client');
3
4
  const config = require('./config');
4
5
  const ui = require('./ui');
5
6
 
@@ -8,6 +9,47 @@ function maskKey(key) {
8
9
  return `${key.slice(0, 12)}••••••${key.slice(-4)}`;
9
10
  }
10
11
 
12
+ async function create(args, flags) {
13
+ requireAuth();
14
+
15
+ const name = flags.name || args.join(' ').trim() || 'CLI firewall';
16
+ const preset = flags.preset || 'firewall';
17
+ const local = flags.global ? false : true;
18
+
19
+ const s = ui.spinner(`Creating ${preset} API key`);
20
+ try {
21
+ const result = await api.post('/api-keys', { name, preset });
22
+ const key = result && result.key;
23
+ if (!key || !key.startsWith('snk_live_')) {
24
+ throw new Error('API did not return a valid firewall key');
25
+ }
26
+
27
+ config.setApiKey(key, { local });
28
+ if (local) config.ensureLocalGitignore();
29
+ s.stop('API key created and saved');
30
+
31
+ if (flags.json) {
32
+ ui.json({
33
+ id: result.apiKey?._id || result.apiKey?.id || null,
34
+ name: result.apiKey?.name || name,
35
+ preset,
36
+ key: maskKey(key),
37
+ savedTo: local ? 'project .securenow/credentials.json' : '~/.securenow/credentials.json',
38
+ });
39
+ return;
40
+ }
41
+
42
+ ui.success(`API key saved (${maskKey(key)})`);
43
+ ui.info(local
44
+ ? 'Stored in project .securenow/credentials.json (local)'
45
+ : 'Stored in ~/.securenow/credentials.json (global)');
46
+ ui.info('The plaintext key is not printed. The SDK will read it from the credentials file.');
47
+ } catch (err) {
48
+ s.fail('Failed to create API key');
49
+ throw err;
50
+ }
51
+ }
52
+
11
53
  async function set(args, flags) {
12
54
  const key = args[0];
13
55
  if (!key) {
@@ -52,4 +94,4 @@ async function show() {
52
94
  ui.info(`Source: ${config.getAuthSource()}`);
53
95
  }
54
96
 
55
- module.exports = { set, clear, show };
97
+ module.exports = { create, set, clear, show };
package/cli/config.js CHANGED
@@ -47,6 +47,12 @@ function saveJSON(filepath, data) {
47
47
  }
48
48
  }
49
49
 
50
+ function credentialsForWrite(targetFile) {
51
+ const inherited = loadCredentials() || {};
52
+ const existing = loadJSON(targetFile);
53
+ return appConfig.mergeCredentials(inherited, existing) || {};
54
+ }
55
+
50
56
  function credentialsFileForLocal(local) {
51
57
  return local ? LOCAL_CREDENTIALS_FILE : CREDENTIALS_FILE;
52
58
  }
@@ -113,7 +119,7 @@ function withOnboardingFirewallEnabled(creds) {
113
119
  function ensureCredentialDefaults({ local, enableFirewall = false } = {}) {
114
120
  const useLocal = local === true || (local == null && hasLocalCredentials());
115
121
  const targetFile = credentialsFileForLocal(useLocal);
116
- const existing = loadJSON(targetFile);
122
+ const existing = useLocal ? credentialsForWrite(targetFile) : loadJSON(targetFile);
117
123
  const payload = enableFirewall
118
124
  ? withOnboardingFirewallEnabled(existing || {})
119
125
  : appConfig.withCredentialDefaults(existing || {}) || {};
@@ -168,7 +174,7 @@ function getApp() {
168
174
  function setApiKey(apiKey, { local } = {}) {
169
175
  const useLocal = local === true || (local == null && hasLocalCredentials());
170
176
  const targetFile = credentialsFileForLocal(useLocal);
171
- const existing = loadJSON(targetFile);
177
+ const existing = useLocal ? credentialsForWrite(targetFile) : loadJSON(targetFile);
172
178
  saveJSON(targetFile, withOnboardingFirewallEnabled({ ...existing, apiKey }));
173
179
  }
174
180
 
@@ -189,7 +195,7 @@ function getApiKey() {
189
195
  function setApp(app, { local } = {}) {
190
196
  const useLocal = local === true || (local == null && hasLocalCredentials());
191
197
  const targetFile = credentialsFileForLocal(useLocal);
192
- const existing = loadJSON(targetFile);
198
+ const existing = useLocal ? credentialsForWrite(targetFile) : loadJSON(targetFile);
193
199
  saveJSON(targetFile, appConfig.withCredentialDefaults({
194
200
  ...existing,
195
201
  app: {
package/cli.js CHANGED
@@ -77,11 +77,21 @@ const COMMANDS = {
77
77
  },
78
78
  'api-key': {
79
79
  desc: 'Manage the firewall API key stored in .securenow/credentials.json',
80
- usage: 'securenow api-key <subcommand> [options]',
81
- sub: {
82
- set: {
83
- desc: 'Save an API key (snk_live_...) to the credentials file',
84
- usage: 'securenow api-key set <snk_live_...> [--global]',
80
+ usage: 'securenow api-key <subcommand> [options]',
81
+ sub: {
82
+ create: {
83
+ desc: 'Create a firewall API key with your session token and save it',
84
+ usage: 'securenow api-key create [name] [--name <name>] [--preset firewall] [--global]',
85
+ flags: {
86
+ name: 'Human-readable key name',
87
+ preset: 'API key preset to create (default: firewall)',
88
+ global: 'Save to ~/.securenow/ instead of project-local',
89
+ },
90
+ run: (a, f) => require('./cli/apiKey').create(a, f),
91
+ },
92
+ set: {
93
+ desc: 'Save an API key (snk_live_...) to the credentials file',
94
+ usage: 'securenow api-key set <snk_live_...> [--global]',
85
95
  flags: { global: 'Save to ~/.securenow/ instead of project-local' },
86
96
  run: (a, f) => require('./cli/apiKey').set(a, f),
87
97
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securenow",
3
- "version": "7.7.10",
3
+ "version": "7.7.11",
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",