securenow 7.7.15 → 7.8.1

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.
@@ -22,8 +22,8 @@ function resolvedConfig(options = {}) {
22
22
  ? (noUuid ? baseName : `${baseName}-<uuid-per-worker>`)
23
23
  : '(auto-generated)';
24
24
  const apiKey = firewall.apiKey || '';
25
- const firewallEnabled = !!apiKey && firewall.enabled;
26
- const firewallLocalEnabled = firewall.enabled;
25
+ const firewallEnabled = !!apiKey;
26
+ const firewallLocalEnabled = true;
27
27
 
28
28
  return {
29
29
  serviceName,
@@ -36,6 +36,8 @@ function resolvedConfig(options = {}) {
36
36
  apiKey,
37
37
  firewallLocalEnabled,
38
38
  apiUrl: config.getApiUrl(),
39
+ firewallApiUrl: firewall.apiUrl,
40
+ firewallSyncEndpoint: `${firewall.apiUrl.replace(/\/$/, '')}/api/v1/firewall/sync`,
39
41
  loggingEnabled: appConfig.boolConfig('logging.enabled', true),
40
42
  captureBody: appConfig.boolConfig('capture.body', true),
41
43
  captureMultipart: appConfig.boolConfig('capture.multipart', true),
@@ -330,11 +332,12 @@ async function logSend(args, flags) {
330
332
  }
331
333
  }
332
334
 
333
- function okHttpStatus(status) {
335
+ function okHttpStatus(status, okStatuses) {
336
+ if (Array.isArray(okStatuses) && okStatuses.length) return okStatuses.includes(status);
334
337
  return status >= 200 && status < 300;
335
338
  }
336
339
 
337
- async function probe({ endpoint, method = 'POST', headers = {}, body = null, timeoutMs = 3000 }) {
340
+ async function probe({ endpoint, method = 'POST', headers = {}, body = null, timeoutMs = 3000, okStatuses = null }) {
338
341
  try {
339
342
  const res = await httpRequest({
340
343
  method,
@@ -344,9 +347,9 @@ async function probe({ endpoint, method = 'POST', headers = {}, body = null, tim
344
347
  timeoutMs,
345
348
  });
346
349
  return {
347
- ok: okHttpStatus(res.status),
350
+ ok: okHttpStatus(res.status, okStatuses),
348
351
  status: res.status,
349
- ...(okHttpStatus(res.status) ? {} : { error: `HTTP ${res.status}`, body: res.body ? res.body.slice(0, 500) : '' }),
352
+ ...(okHttpStatus(res.status, okStatuses) ? {} : { error: `HTTP ${res.status}`, body: res.body ? res.body.slice(0, 500) : '' }),
350
353
  };
351
354
  } catch (err) {
352
355
  return { ok: false, error: err.message };
@@ -356,7 +359,6 @@ async function probe({ endpoint, method = 'POST', headers = {}, body = null, tim
356
359
  function firewallStatusLabel(cfg) {
357
360
  if (cfg.firewallEnabled) return ui.c.green('enabled');
358
361
  if (!cfg.apiKey) return ui.c.dim('disabled (missing firewall API key)');
359
- if (!cfg.firewallLocalEnabled) return ui.c.yellow('disabled (config.firewall.enabled=false)');
360
362
  return ui.c.dim('disabled');
361
363
  }
362
364
 
@@ -372,6 +374,8 @@ function env(_args, flags) {
372
374
  otlpHeaders: Object.keys(cfg.headers || {}).length ? '***' : null,
373
375
  firewallApiKey: cfg.apiKey ? `${cfg.apiKey.slice(0, 12)}...` : null,
374
376
  apiUrl: cfg.apiUrl,
377
+ firewallApiUrl: cfg.firewallApiUrl,
378
+ firewallSyncEndpoint: cfg.firewallSyncEndpoint,
375
379
  loggingEnabled: cfg.loggingEnabled,
376
380
  otelLogLevel: cfg.otelLogLevel,
377
381
  captureBody: cfg.captureBody,
@@ -397,6 +401,7 @@ function env(_args, flags) {
397
401
  ['Body capture', cfg.captureBody ? ui.c.green('enabled') : ui.c.dim('disabled')],
398
402
  ['Multipart capture', cfg.captureMultipart ? ui.c.green('enabled') : ui.c.dim('disabled')],
399
403
  ['Firewall', firewallStatusLabel(cfg)],
404
+ ['Firewall sync', cfg.firewallEnabled ? cfg.firewallSyncEndpoint : ui.c.dim('(not active)')],
400
405
  ]);
401
406
 
402
407
  ui.heading('Resolved credentials');
@@ -454,6 +459,26 @@ async function doctor(_args, flags) {
454
459
  checks.push({ name: 'api', ...api });
455
460
  }
456
461
 
462
+ if (cfg.apiKey && cfg.firewallLocalEnabled) {
463
+ const query = new URLSearchParams();
464
+ if (cfg.appKey) query.set('app', cfg.appKey);
465
+ if (cfg.deploymentEnvironment) query.set('env', cfg.deploymentEnvironment);
466
+ const endpoint = `${cfg.firewallSyncEndpoint}${query.toString() ? `?${query.toString()}` : ''}`;
467
+ const spin4 = ui.spinner(`Probing firewall sync ${endpoint}`);
468
+ const sync = await probe({
469
+ method: 'GET',
470
+ endpoint,
471
+ headers: {
472
+ Authorization: `Bearer ${cfg.apiKey}`,
473
+ 'X-SecureNow-Environment': cfg.deploymentEnvironment,
474
+ },
475
+ okStatuses: [200, 304],
476
+ });
477
+ if (sync.ok) spin4.stop(`Firewall sync reachable (HTTP ${sync.status})`);
478
+ else spin4.fail(`Firewall sync unreachable: ${sync.error}`);
479
+ checks.push({ name: 'firewall-sync', ...sync });
480
+ }
481
+
457
482
  const warnings = [];
458
483
  const singletonOkMessage = otelApiCheck.ok && otelApiCheck.packages.length
459
484
  ? `OpenTelemetry API singleton OK (${otelApiCheck.versions[0] || 'unknown'})`
@@ -465,7 +490,7 @@ async function doctor(_args, flags) {
465
490
  warnings.push('OpenTelemetry diagnostic log level is `none`; provider registration/export errors are hidden. Set config.otel.logLevel to `error`/`warn`, or temporarily run with OTEL_LOG_LEVEL=debug.');
466
491
  }
467
492
  if (!cfg.appKey) {
468
- warnings.push('No app key resolved. Run `npx securenow login` or set app.key in .securenow/credentials.json.');
493
+ warnings.push('No app key resolved. Run `npx securenow app connect` or set app.key in .securenow/runtime.json.');
469
494
  }
470
495
  if (cfg.instance === 'https://ingest.securenow.ai') {
471
496
  warnings.push('Using the SecureNow ingest gateway. Dedicated instances are routed server-side after policy checks.');
@@ -475,9 +500,9 @@ async function doctor(_args, flags) {
475
500
  warnings.push('Using the legacy free-trial collector directly. Regenerate credentials so telemetry flows through https://ingest.securenow.ai.');
476
501
  }
477
502
  if (!cfg.apiKey && token) {
478
- warnings.push('CLI/MCP is authenticated with your SecureNow session token. Runtime firewall enforcement key is missing. Run `npx securenow login` or `npx securenow api-key set snk_live_...` to refresh .securenow/credentials.json.');
503
+ warnings.push('Admin CLI/MCP auth is connected, but runtime firewall enforcement key is missing. Run `npx securenow app connect` or `npx securenow api-key set snk_live_...` to refresh .securenow/runtime.json.');
479
504
  } else if (!cfg.apiKey) {
480
- warnings.push('Runtime firewall enforcement key is missing. Run `npx securenow login` or `npx securenow api-key set snk_live_...` to refresh .securenow/credentials.json.');
505
+ warnings.push('Runtime firewall enforcement key is missing. Run `npx securenow app connect` or `npx securenow api-key set snk_live_...` to refresh .securenow/runtime.json.');
481
506
  }
482
507
 
483
508
  const ok = checks.every((c) => c.ok);
package/cli/firewall.js CHANGED
@@ -32,7 +32,9 @@ async function status(args, flags) {
32
32
  console.log(` ${enabledLabel}`);
33
33
  console.log('');
34
34
  ui.keyValue([
35
- ['Blocked IPs', `${data.totalIps} total (${data.exactCount} exact + ${data.cidrCount} CIDR ranges)`],
35
+ ['Blocked IPs', `${data.totalIps} total`],
36
+ ['Global blocked IPs', `${data.globalBlockIps ?? data.totalIps} total (${data.exactCount} exact + ${data.cidrCount} CIDR ranges)`],
37
+ ['Scoped block rules', String(data.scopedBlockRuleCount ?? 0)],
36
38
  ['App scope', appKey || 'all apps'],
37
39
  ['Environment', data.environment || environment],
38
40
  ['Last updated', data.updatedAt || 'unknown'],
@@ -77,6 +79,8 @@ async function testIp(args, flags) {
77
79
  const appKey = await resolveAppKey(flags);
78
80
  const query = { environment };
79
81
  if (appKey) query.appKey = appKey;
82
+ if (flags.path || flags.route) query.path = flags.path || flags.route;
83
+ if (flags.method) query.method = flags.method;
80
84
  const data = await api.get(`/firewall/check/${encodeURIComponent(ip)}`, { query });
81
85
 
82
86
  s.stop(`IP ${ip} checked`);
@@ -99,10 +103,16 @@ async function testIp(args, flags) {
99
103
  console.log(` ${ui.c.dim('Allowlist is active — only listed IPs are permitted')}`);
100
104
  } else {
101
105
  console.log(` ${ui.c.bold(ui.c.red('BLOCKED'))} — ${ip} is in the blocklist`);
102
- if (data.matchedEntry && data.matchedEntry !== ip) {
103
- console.log(` ${ui.c.dim(`Matched by: ${data.matchedEntry}`)}`);
104
- }
105
- }
106
+ if (data.matchedEntry && data.matchedEntry !== ip) {
107
+ console.log(` ${ui.c.dim(`Matched by: ${data.matchedEntry}`)}`);
108
+ }
109
+ if (data.matchedRule) {
110
+ const scope = data.matchedRule.pathPattern
111
+ ? `${data.matchedRule.method || 'ALL'} ${data.matchedRule.pathMatchMode || 'prefix'}:${data.matchedRule.pathPattern}`
112
+ : data.matchedRule.method || 'ALL';
113
+ console.log(` ${ui.c.dim(`Rule scope: ${scope}`)}`);
114
+ }
115
+ }
106
116
  } else {
107
117
  if (data.allowlisted) {
108
118
  console.log(` ${ui.c.bold(ui.c.green('ALLOWED'))} — ${ip} is on the allowlist`);
@@ -111,7 +121,9 @@ async function testIp(args, flags) {
111
121
  }
112
122
  }
113
123
  console.log(` ${ui.c.dim(`App scope: ${appKey || 'all apps'} · Environment: ${data.environment || environment}`)}`);
114
- console.log(` ${ui.c.dim(`Blocklist contains ${data.totalBlockedIps} entries`)}`);
124
+ if (data.path) console.log(` ${ui.c.dim(`Request scope: ${data.method || 'GET'} ${data.path}`)}`);
125
+ if (data.scopedMatchRequiresPath) console.log(` ${ui.c.dim('Scoped block rules exist; pass --path to test route-specific matches')}`);
126
+ console.log(` ${ui.c.dim(`Blocklist contains ${data.totalBlockedIps} entries (${data.scopedBlockRuleCount || 0} scoped)`)}`);
115
127
  if (data.allowlistActive) {
116
128
  console.log(` ${ui.c.dim('Allowlist is active')}`);
117
129
  }
@@ -136,7 +148,7 @@ async function setEnabled(args, flags, enabled) {
136
148
  requireAuth();
137
149
  const appKey = await resolveAppKey(flags);
138
150
  if (!appKey) {
139
- ui.error('No app selected. Pass --app <key> or run `securenow login` / `securenow apps default <key>`.');
151
+ ui.error('No app selected. Pass --app <key> or run `securenow app connect` / `securenow apps default <key>`.');
140
152
  process.exit(1);
141
153
  }
142
154
 
package/cli/init.js CHANGED
@@ -81,7 +81,7 @@ async function init(_args, flags) {
81
81
 
82
82
  console.log('');
83
83
  ui.success('Setup complete.');
84
- ui.info('Run `npx securenow login` if this project is not linked to an app yet.');
84
+ ui.info('Run `npx securenow app connect` if this project is not linked to an app yet.');
85
85
  ui.info('Then verify with `npx securenow test-span` and `npx securenow status`.');
86
86
  }
87
87
 
@@ -101,10 +101,10 @@ function initCredentials(flags) {
101
101
  process.exit(1);
102
102
  }
103
103
  config.setApiKey(explicitApiKey, { local: true });
104
- ui.success('Stored firewall API key in .securenow/credentials.json');
104
+ ui.success('Stored firewall API key in .securenow/runtime.json');
105
105
  }
106
106
 
107
- ui.success('Ensured .securenow/credentials.json has secure defaults and explanations');
107
+ ui.success('Ensured .securenow/runtime.json has secure defaults and explanations');
108
108
  }
109
109
 
110
110
  async function initNextJs(dir, project, flags) {
@@ -233,8 +233,8 @@ function printAgentPrompt(kind, filename, major, project) {
233
233
  ui.heading('Codex/Claude prompt');
234
234
  console.log([
235
235
  'Set up SecureNow in this existing Next.js project without using .env files.',
236
- 'Use .securenow/credentials.json for local and production configuration; do not add .env files.',
237
- 'Ignore only .securenow/credentials.json and .securenow/credentials.*.json in git; keep the .securenow/ directory itself trackable for repo-owned files.',
236
+ 'Use .securenow/runtime.json for local SDK runtime configuration and .securenow/credentials.<env>.json for production runtime exports; do not add .env files.',
237
+ 'Ignore only SecureNow secret files (.securenow/admin.json, .securenow/runtime.json, and .securenow/credentials*.json); keep the .securenow/ directory itself trackable for repo-owned files.',
238
238
  commands
239
239
  ? `Use the project scripts for verification when appropriate: ${commands}. Ask before starting long-running dev/start servers, and ask which command to use if these scripts are not the right customer workflow.`
240
240
  : 'Ask the customer which command starts, builds, and tests this app because package.json does not expose an obvious script.',
package/cli/security.js CHANGED
@@ -441,7 +441,14 @@ async function alertHistoryList(args, flags) {
441
441
 
442
442
  // ── Blocklist ──
443
443
 
444
- async function blocklistList(args, flags) {
444
+ function describeBlockTarget(entry) {
445
+ const parts = [entry.ip || entry.cidr || '-'];
446
+ if (entry.method && entry.method !== 'ALL') parts.push(entry.method);
447
+ if (entry.pathPattern) parts.push(`${entry.pathMatchMode || 'prefix'}:${entry.pathPattern}`);
448
+ return parts.join(' ');
449
+ }
450
+
451
+ async function blocklistList(args, flags) {
445
452
  requireAuth();
446
453
  const s = ui.spinner('Fetching blocklist');
447
454
  try {
@@ -465,7 +472,7 @@ async function blocklistList(args, flags) {
465
472
  console.log('');
466
473
  const rows = items.map(b => [
467
474
  ui.c.dim(ui.truncate(b._id, 12)),
468
- ui.c.red(b.ip || b.cidr || '—'),
475
+ ui.c.red(describeBlockTarget(b)),
469
476
  ui.truncate(b.reason || '', 40),
470
477
  b.source || '—',
471
478
  b.status || 'active',
@@ -475,7 +482,7 @@ async function blocklistList(args, flags) {
475
482
  b.unblockedAt ? ui.timeAgo(b.unblockedAt) : ui.c.dim('—'),
476
483
  b.expiresAt ? new Date(b.expiresAt).toLocaleDateString() : ui.c.dim('permanent'),
477
484
  ]);
478
- ui.table(['ID', 'IP/CIDR', 'Reason', 'Source', 'Status', 'App', 'Env', 'Added', 'Unblocked', 'Expires'], rows);
485
+ ui.table(['ID', 'Target', 'Reason', 'Source', 'Status', 'App', 'Env', 'Added', 'Unblocked', 'Expires'], rows);
479
486
  console.log('');
480
487
  } catch (err) {
481
488
  s.fail('Failed to fetch blocklist');
@@ -496,11 +503,16 @@ async function blocklistAdd(args, flags) {
496
503
  if (flags.duration) body.duration = flags.duration;
497
504
  if (flags.app) body.appKey = flags.app;
498
505
  if (flags.env || flags.environment) body.environment = flags.env || flags.environment;
499
-
500
- const s = ui.spinner(`Blocking ${ip}`);
501
- try {
502
- await api.post('/blocklist', body);
503
- s.stop(`${ip} added to blocklist`);
506
+ if (flags.route || flags.path || flags.pattern) body.pathPattern = flags.route || flags.path || flags.pattern;
507
+ if (flags.mode || flags['path-mode']) body.pathMatchMode = flags.mode || flags['path-mode'];
508
+ if (flags.method) body.method = flags.method;
509
+
510
+ const target = describeBlockTarget({ ip, method: body.method, pathPattern: body.pathPattern, pathMatchMode: body.pathMatchMode });
511
+ const s = ui.spinner(`Blocking ${target}`);
512
+ try {
513
+ const data = await api.post('/blocklist', body);
514
+ s.stop(`${target} added to blocklist`);
515
+ if (flags.json) ui.json(data);
504
516
  } catch (err) {
505
517
  s.fail('Failed to add to blocklist');
506
518
  throw err;
@@ -611,9 +623,17 @@ async function allowlistAdd(args, flags) {
611
623
  body.applicationKeys = String(flags.app).split(',').map((x) => x.trim()).filter(Boolean);
612
624
  }
613
625
  if (flags.env || flags.environment) body.environment = flags.env || flags.environment;
614
-
615
- const s = ui.spinner(`Allowing ${ip}`);
616
- try {
626
+
627
+ if (!flags.force && !flags.yes) {
628
+ ui.warn('IP Allowlist is deny-by-default: once active, only listed IPs can reach the scoped app/environment and all others are blocked.');
629
+ ui.info('Use `securenow trusted add` instead if this IP should be trusted without locking out normal visitors.');
630
+ const ok = await ui.confirm('Add this IP to the restrictive allowlist?');
631
+ if (!ok) { ui.info('Cancelled'); return; }
632
+ }
633
+ body.allowlistDenyAllApproved = true;
634
+
635
+ const s = ui.spinner(`Allowing ${ip}`);
636
+ try {
617
637
  await api.post('/allowlist', body);
618
638
  s.stop(`${ip} added to allowlist`);
619
639
  } catch (err) {
package/cli.js CHANGED
@@ -40,12 +40,12 @@ function parseArgs(argv) {
40
40
 
41
41
  const COMMANDS = {
42
42
  init: {
43
- desc: 'Set up SecureNow in the current project (instrumentation + .securenow credentials)',
43
+ desc: 'Set up SecureNow in the current project (instrumentation + runtime credentials)',
44
44
  usage: 'securenow init [--env local] [--key <API_KEY>] [--ts|--js] [--src|--root] [--force]',
45
45
  flags: {
46
- env: 'Deployment environment to write into .securenow/credentials.json (default: local)',
46
+ env: 'Deployment environment to write into .securenow/runtime.json (default: local)',
47
47
  environment: 'Alias for --env',
48
- key: 'Firewall API key to write to .securenow/credentials.json',
48
+ key: 'Firewall API key to write to .securenow/runtime.json',
49
49
  'api-key': 'Alias for --key',
50
50
  typescript: 'Force TypeScript',
51
51
  javascript: 'Force JavaScript',
@@ -55,28 +55,63 @@ const COMMANDS = {
55
55
  },
56
56
  run: (a, f) => require('./cli/init').init(a, f),
57
57
  },
58
- login: {
59
- desc: 'Authenticate with SecureNow (saves to project .securenow/ by default)',
60
- usage: 'securenow login [--token <TOKEN>] [--global]',
58
+ login: {
59
+ desc: 'Onboard SecureNow admin auth and app runtime config',
60
+ usage: 'securenow login [--token <TOKEN>] [--global]',
61
61
  flags: {
62
62
  token: 'Authenticate with a token directly',
63
63
  global: 'Save credentials to ~/.securenow/ (shared across all projects)',
64
- },
65
- run: (a, f) => require('./cli/auth').login(a, f),
66
- },
67
- logout: {
68
- desc: 'Clear stored credentials',
69
- usage: 'securenow logout [--global]',
70
- flags: { global: 'Clear global credentials (~/.securenow/) instead of project-local' },
71
- run: (a, f) => require('./cli/auth').logout(a, f),
72
- },
73
- whoami: {
74
- desc: 'Show current session info',
64
+ },
65
+ run: (a, f) => require('./cli/auth').login(a, f),
66
+ },
67
+ admin: {
68
+ desc: 'Manage admin/control-plane CLI and MCP auth',
69
+ usage: 'securenow admin <subcommand> [options]',
70
+ sub: {
71
+ login: {
72
+ desc: 'Authenticate admin/control-plane CLI and MCP tools',
73
+ usage: 'securenow admin login [--token <TOKEN>] [--global]',
74
+ flags: {
75
+ token: 'Authenticate with a token directly',
76
+ global: 'Save admin auth to ~/.securenow/admin.json',
77
+ },
78
+ run: (a, f) => require('./cli/auth').adminLogin(a, f),
79
+ },
80
+ logout: {
81
+ desc: 'Clear admin/control-plane auth',
82
+ usage: 'securenow admin logout [--global]',
83
+ flags: { global: 'Clear global admin auth (~/.securenow/admin.json)' },
84
+ run: (a, f) => require('./cli/auth').logout(a, f),
85
+ },
86
+ },
87
+ defaultSub: 'login',
88
+ },
89
+ app: {
90
+ desc: 'Connect the current project runtime to a SecureNow app',
91
+ usage: 'securenow app <subcommand> [options]',
92
+ sub: {
93
+ connect: {
94
+ desc: 'Select/create app, mint firewall key, and write SDK runtime config',
95
+ usage: 'securenow app connect [--global]',
96
+ flags: { global: 'Save runtime config to ~/.securenow/runtime.json' },
97
+ run: (a, f) => require('./cli/auth').appConnect(a, f),
98
+ },
99
+ },
100
+ defaultSub: 'connect',
101
+ },
102
+ logout: {
103
+ desc: 'Clear admin/control-plane auth',
104
+ usage: 'securenow logout [--global]',
105
+ flags: { global: 'Clear global admin auth (~/.securenow/admin.json)' },
106
+ run: (a, f) => require('./cli/auth').logout(a, f),
107
+ },
108
+ whoami: {
109
+ desc: 'Show admin auth and SDK runtime status',
75
110
  usage: 'securenow whoami',
76
111
  run: () => require('./cli/auth').whoami(),
77
112
  },
78
113
  'api-key': {
79
- desc: 'Manage the firewall API key stored in .securenow/credentials.json',
114
+ desc: 'Manage the firewall API key stored in runtime credentials',
80
115
  usage: 'securenow api-key <subcommand> [options]',
81
116
  sub: {
82
117
  create: {
@@ -90,7 +125,7 @@ const COMMANDS = {
90
125
  run: (a, f) => require('./cli/apiKey').create(a, f),
91
126
  },
92
127
  set: {
93
- desc: 'Save an API key (snk_live_...) to the credentials file',
128
+ desc: 'Save an API key (snk_live_...) to runtime credentials',
94
129
  usage: 'securenow api-key set <snk_live_...> [--global]',
95
130
  flags: { global: 'Save to ~/.securenow/ instead of project-local' },
96
131
  run: (a, f) => require('./cli/apiKey').set(a, f),
@@ -273,7 +308,7 @@ const COMMANDS = {
273
308
  apps: { desc: 'List apps with their firewall on/off state', run: (a, f) => require('./cli/firewall').appsList(a, f) },
274
309
  enable: { desc: 'Turn the firewall ON for an app environment', usage: 'securenow firewall enable [--app <key>] [--env production]', flags: { app: 'App key (defaults to logged-in app)', env: 'Environment (default: production)', environment: 'Alias for --env' }, run: (a, f) => require('./cli/firewall').enable(a, f) },
275
310
  disable: { desc: 'Turn the firewall OFF for an app environment', usage: 'securenow firewall disable [--app <key>] [--env local]', flags: { app: 'App key (defaults to logged-in app)', env: 'Environment (default: production)', environment: 'Alias for --env' }, run: (a, f) => require('./cli/firewall').disable(a, f) },
276
- 'test-ip': { desc: 'Check if an IP would be blocked', usage: 'securenow firewall test-ip <ip> [--env production]', flags: { env: 'Environment (default: production)', environment: 'Alias for --env' }, run: (a, f) => require('./cli/firewall').testIp(a, f) },
311
+ 'test-ip': { desc: 'Check if an IP would be blocked', usage: 'securenow firewall test-ip <ip> [--path /admin/users] [--method GET] [--env production]', flags: { env: 'Environment (default: production)', environment: 'Alias for --env' }, run: (a, f) => require('./cli/firewall').testIp(a, f) },
277
312
  },
278
313
  defaultSub: 'status',
279
314
  },
@@ -379,10 +414,10 @@ const COMMANDS = {
379
414
  blocklist: {
380
415
  desc: 'Manage IP blocklist',
381
416
  usage: 'securenow blocklist <subcommand> [options]',
382
- flags: { app: 'Scope to app key', env: 'Scope to environment', environment: 'Alias for --env', page: 'Page number', limit: 'Max results', status: 'Entry status: active or removed', 'approval-status': 'Approval filter: pending, approved, or rejected', search: 'IP prefix search', view: 'List view: all or operational', reason: 'Audit reason for unblock', json: 'Output as JSON' },
417
+ flags: { app: 'Scope to app key', env: 'Scope to environment', environment: 'Alias for --env', page: 'Page number', limit: 'Max results', status: 'Entry status: active or removed', 'approval-status': 'Approval filter: pending, approved, or rejected', search: 'IP prefix search', view: 'List view: all or operational', reason: 'Audit reason for unblock', route: 'Route pattern such as /admin*', path: 'Alias for --route', pattern: 'Alias for --route', mode: 'Route match mode: prefix, exact, or regex', 'path-mode': 'Alias for --mode', method: 'HTTP method, or ALL', duration: 'Expiry, e.g. 24h or 7d', json: 'Output as JSON' },
383
418
  sub: {
384
419
  list: { desc: 'List blocked IPs', run: (a, f) => require('./cli/security').blocklistList(a, f) },
385
- add: { desc: 'Block an IP', usage: 'securenow blocklist add <ip> [--app <key>] [--env production] [--reason <reason>]', run: (a, f) => require('./cli/security').blocklistAdd(a, f) },
420
+ add: { desc: 'Block an IP', usage: 'securenow blocklist add <ip> [--route /admin*] [--mode prefix] [--method GET] [--app <key>] [--env production] [--duration 24h] [--reason <reason>]', run: (a, f) => require('./cli/security').blocklistAdd(a, f) },
386
421
  unblock: { desc: 'Unblock an IP and keep block history', usage: 'securenow blocklist unblock <id> [--reason <reason>]', run: (a, f) => require('./cli/security').blocklistRemove(a, f) },
387
422
  remove: { desc: 'Unblock an IP (compatibility alias)', usage: 'securenow blocklist remove <id> [--reason <reason>]', run: (a, f) => require('./cli/security').blocklistRemove(a, f) },
388
423
  stats: { desc: 'Blocklist statistics', run: (a, f) => require('./cli/security').blocklistStats(a, f) },
package/firewall-only.js CHANGED
@@ -17,15 +17,15 @@ try { require('dotenv').config({ quiet: true }); } catch (_) {}
17
17
  const appConfig = require('./app-config');
18
18
  const firewallOptions = appConfig.resolveFirewallOptions();
19
19
 
20
- // config.firewall.enabled=false disables the local SDK firewall.
21
- // In all other cases the toggle lives in the dashboard; default ON when an
22
- // API key is present.
23
- if (firewallOptions.apiKey && firewallOptions.enabled) {
20
+ // Runtime enable/disable is controlled by the dashboard/API toggle. If a
21
+ // firewall key is present, start sync so the remote toggle can be applied.
22
+ if (firewallOptions.apiKey) {
24
23
  require('./firewall').init({
25
24
  apiKey: firewallOptions.apiKey,
26
25
  appKey: firewallOptions.appKey,
27
26
  environment: firewallOptions.environment,
28
27
  apiUrl: firewallOptions.apiUrl,
28
+ apiUrlFallbacks: firewallOptions.apiUrlFallbacks,
29
29
  versionCheckInterval: firewallOptions.versionCheckInterval,
30
30
  syncInterval: firewallOptions.syncInterval,
31
31
  failMode: firewallOptions.failMode,