@profullstack/nichedb 0.37.0 → 0.39.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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +59 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@profullstack/nichedb",
3
- "version": "0.37.0",
3
+ "version": "0.39.0",
4
4
  "description": "CLI and MCP bridge for NicheDB: browse collections, manage sources and feeds, search items, from any deployment",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -15,7 +15,7 @@ import { homedir, tmpdir } from 'node:os';
15
15
  import { join } from 'node:path';
16
16
  import { createInterface } from 'node:readline';
17
17
 
18
- export const VERSION = '0.37.0';
18
+ export const VERSION = '0.39.0';
19
19
  const GEO_FLAGS = ['lat', 'long', 'radius', 'unit', 'bbox', 'sort', 'offset'];
20
20
  const DEFAULT_API = process.env.NICHEDB_API ?? 'https://nichedb.dev';
21
21
  const CONFIG_DIR = join(process.env.XDG_CONFIG_HOME ?? join(homedir(), '.config'), 'nichedb');
@@ -236,6 +236,20 @@ export const COMMANDS = [
236
236
  '--json',
237
237
  ],
238
238
  },
239
+ {
240
+ name: 'reputation',
241
+ usage: 'reputation <ip-or-domain>',
242
+ summary:
243
+ 'Is an IP or a domain on a blocklist? nichedb /traffic (human-reviewed bans), abuse.ch malware feeds and SURBL in one answer. Exits 1 when listed.',
244
+ options: ['--json'],
245
+ },
246
+ {
247
+ name: 'traffic',
248
+ usage: 'traffic [<ip>] [--days <n>] [--category <c>] [--txt]',
249
+ summary:
250
+ 'The human-reviewed /traffic IP blocklist: newest approvals, one address, or --txt for a fail2ban/nftables-ready list. Exits 1 when an address is listed.',
251
+ options: ['--days <n>', '--category <c>', '--limit <n>', '--offset <n>', '--txt', '--json'],
252
+ },
239
253
  {
240
254
  name: 'profiles',
241
255
  usage:
@@ -1048,6 +1062,50 @@ export async function run(
1048
1062
  for (const l of r.lookUpYourself) out(`${pad(l.name, 44)} ${l.url}`);
1049
1063
  return 0;
1050
1064
  }
1065
+ case 'reputation': {
1066
+ const indicator = rest[0];
1067
+ if (!indicator) throw new Error('reputation <ip-or-domain>');
1068
+ const r = await client.get(`/api/v1/reputation/${encodeURIComponent(indicator)}`);
1069
+ if (json) {
1070
+ out(JSON.stringify(r, null, 2));
1071
+ return 0;
1072
+ }
1073
+ out(`${r.query}: ${r.listed ? `LISTED, score ${r.score}/100` : 'not listed'}`);
1074
+ for (const reason of r.reasons) out(` ${reason}`);
1075
+ if (r.note) out(` ${r.note}`);
1076
+ out(` checked: ${r.checked.map((c) => c.name).join('; ')}`);
1077
+ out(` deeper: ${r.deeper.url}`);
1078
+ return r.listed ? 1 : 0;
1079
+ }
1080
+ case 'traffic': {
1081
+ const qs = new URLSearchParams();
1082
+ for (const k of ['days', 'category', 'limit', 'offset'])
1083
+ if (flags[k] && flags[k] !== true) qs.set(k, String(flags[k]));
1084
+ if (rest[0]) {
1085
+ const r = await client.get(`/api/v1/traffic/ip/${encodeURIComponent(rest[0])}`);
1086
+ if (json) out(JSON.stringify(r, null, 2));
1087
+ else if (!r.listed) out(`${r.ip}: not on /traffic`);
1088
+ else
1089
+ out(
1090
+ `${r.ip}: listed (${r.category}), ${r.servers} servers, ${r.blocks} bans, last seen ${String(r.last_seen).slice(0, 10)}`,
1091
+ );
1092
+ return r.listed ? 1 : 0;
1093
+ }
1094
+ if (flags.txt) {
1095
+ out(await client.text(`/traffic/blocklist.txt${qs.size ? `?${qs}` : ''}`));
1096
+ return 0;
1097
+ }
1098
+ const r = await client.get(`/api/v1/traffic${qs.size ? `?${qs}` : ''}`);
1099
+ if (json) {
1100
+ out(JSON.stringify(r, null, 2));
1101
+ return 0;
1102
+ }
1103
+ for (const x of r.addresses ?? r.rows ?? [])
1104
+ out(
1105
+ `${pad(x.ip, 40)} ${pad(x.category ?? 'other', 12)} ${String(x.last_seen ?? '').slice(0, 10)}`,
1106
+ );
1107
+ return 0;
1108
+ }
1051
1109
  case 'profiles': {
1052
1110
  const term = rest.join(' ');
1053
1111
  const qs = new URLSearchParams();