netriskscan-cli 2.0.0 → 2.2.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.
- package/CHANGELOG.md +25 -0
- package/README.md +68 -35
- package/dist/cli.js +676 -44
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +3 -12
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,28 @@
|
|
|
1
|
+
# [2.2.0](https://github.com/TeamQQ/netriskscan-cli/compare/v2.1.0...v2.2.0) (2026-12-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **auth:** honor one-time CLI key exchange and reuse saved keys ([b13453a](https://github.com/TeamQQ/netriskscan-cli/commit/b13453abd3081906ff75551033a8440e22d9985e))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **cli:** resume queries after loopback Google authorization ([31cf0b5](https://github.com/TeamQQ/netriskscan-cli/commit/31cf0b5f2e58d8a626df8d092e08ca043c4285b3))
|
|
12
|
+
|
|
13
|
+
# [2.1.0](https://github.com/TeamQQ/netriskscan-cli/compare/v2.0.0...v2.1.0) (2026-12-02)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **cli:** complete Google sign-in and resume authenticated queries ([f32bbbb](https://github.com/TeamQQ/netriskscan-cli/commit/f32bbbbb1e23a5e7db664115b1e3ab2eb133c0ac))
|
|
19
|
+
|
|
20
|
+
## Google authorization
|
|
21
|
+
|
|
22
|
+
- Start the official Google authorization flow when a terminal query needs a key.
|
|
23
|
+
- Save the exchanged key in the OS credential store and resume the original request.
|
|
24
|
+
- Add `auth login`, `auth key`, and monthly usage details in `auth status`.
|
|
25
|
+
|
|
1
26
|
# [2.0.0](https://github.com/TeamQQ/netriskscan-cli/compare/v1.6.2...v2.0.0) (2026-12-02)
|
|
2
27
|
|
|
3
28
|
|
package/README.md
CHANGED
|
@@ -33,9 +33,14 @@ Use the CLI for investigations and operational tasks. Use the TypeScript client
|
|
|
33
33
|
npx netriskscan-cli check 8.8.8.8
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
With
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
With a configured key, the lookup runs immediately. When automatic Google sign-in is
|
|
37
|
+
available, the CLI opens your browser if an interactive command has no key. Complete
|
|
38
|
+
Google sign-in once. The browser returns to the CLI on `127.0.0.1`, and the CLI
|
|
39
|
+
saves the installation's key in the OS credential store and resumes the original query
|
|
40
|
+
with its existing options and output format.
|
|
41
|
+
|
|
42
|
+
The loopback endpoint requires the current NetRiskScan service. With an existing key
|
|
43
|
+
you can continue using the CLI on a headless device or against an older deployment.
|
|
39
44
|
|
|
40
45
|
## Product overview
|
|
41
46
|
|
|
@@ -100,17 +105,30 @@ account-level quota.
|
|
|
100
105
|
|
|
101
106
|
### Migrating from 1.x
|
|
102
107
|
|
|
103
|
-
Version 2 requires a key for all CLI lookups.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
`NetRiskScanClient` callers retain their existing authentication behavior.
|
|
108
|
+
Version 2 requires a key for all CLI lookups. Set `NETRISKSCAN_API_KEY` in CI/CD.
|
|
109
|
+
Interactive Google sign-in can save a key locally. Existing authenticated scripts use
|
|
110
|
+
the same query commands, success payloads, and numeric exit codes. Read `error.code`
|
|
111
|
+
to distinguish failures that share an exit code.
|
|
108
112
|
|
|
109
113
|
## Getting an API key
|
|
110
114
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
To authorize the CLI before running a query, run:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npx netriskscan-cli auth login
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
If the system browser cannot open, the CLI prints an authorization link. Open it in
|
|
122
|
+
a browser on the same computer and keep the terminal running. The terminal waits
|
|
123
|
+
up to ten minutes. Press Ctrl+C to cancel the query.
|
|
124
|
+
|
|
125
|
+
Interactive `check --json` and `batch --jsonl` keep the response on stdout and put
|
|
126
|
+
sign-in messages on stderr. Set `NETRISKSCAN_API_KEY` for CI, redirected output, or
|
|
127
|
+
batch input piped on stdin.
|
|
128
|
+
|
|
129
|
+
For a key you already manage in the [Developer Console](https://www.netriskscan.com/developer/keys),
|
|
130
|
+
use `ip-risk:read` for `check` and `batch` and `usage:read` for quota and plan
|
|
131
|
+
reads. Load the key from your secret manager into `NETRISKSCAN_API_KEY`.
|
|
114
132
|
|
|
115
133
|
```bash
|
|
116
134
|
npx netriskscan-cli auth save
|
|
@@ -124,12 +142,17 @@ each invocation. `auth save` sets the variable within its own process.
|
|
|
124
142
|
|
|
125
143
|
| Command | What it does |
|
|
126
144
|
| --------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
127
|
-
| `npx netriskscan-cli auth
|
|
128
|
-
| `npx netriskscan-cli auth status` | Verifies the selected key and shows its masked value,
|
|
145
|
+
| `npx netriskscan-cli auth key` | Reveals the stored key in an interactive terminal. `auth show` is also supported. |
|
|
146
|
+
| `npx netriskscan-cli auth status` | Verifies the selected key and shows its masked value, storage, plan, and monthly usage. |
|
|
129
147
|
| `npx netriskscan-cli auth logout` | Removes the local credential. Server-side revocation is available in the Developer Console. |
|
|
130
148
|
|
|
131
|
-
|
|
132
|
-
|
|
149
|
+
The CLI stores the new API key in your OS credential store and displays a redacted
|
|
150
|
+
identifier. Existing installations reuse the matching saved key.
|
|
151
|
+
|
|
152
|
+
The loopback flow uses a random state, PKCE S256, and RSA-encrypted key delivery.
|
|
153
|
+
The OS credential store holds the key and any pending delivery proof. If you remove
|
|
154
|
+
the local key while the installation's server key is still active, manage the key
|
|
155
|
+
in the Developer Console before authorizing a replacement.
|
|
133
156
|
|
|
134
157
|
## CLI and TypeScript integration
|
|
135
158
|
|
|
@@ -729,24 +752,7 @@ Request ID req_xxxxxxxx
|
|
|
729
752
|
The package also exports `NetRiskScanClient` and its response and error types for direct
|
|
730
753
|
Node.js/TypeScript integration. The CLI and SDK use the same API client and response contract:
|
|
731
754
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
```ts
|
|
735
|
-
import { NetRiskScanClient } from "netriskscan-cli";
|
|
736
|
-
|
|
737
|
-
const client = new NetRiskScanClient();
|
|
738
|
-
|
|
739
|
-
const { data } = await client.checkIp("1.1.1.1");
|
|
740
|
-
console.log(data.risk.index);
|
|
741
|
-
|
|
742
|
-
if (data.usage?.mode === "anonymous") {
|
|
743
|
-
console.log("available:", data.usage.remaining);
|
|
744
|
-
}
|
|
745
|
-
```
|
|
746
|
-
|
|
747
|
-
Pass `apiKey` to use Developer Account quota instead. `getUsage()` is account data and
|
|
748
|
-
always requires a key - without one it throws `NetRiskScanConfigError` before any request
|
|
749
|
-
is made:
|
|
755
|
+
Supply `apiKey` to use the Developer API and read the account's quota:
|
|
750
756
|
|
|
751
757
|
```ts
|
|
752
758
|
import { NetRiskScanClient, NetRiskScanApiError } from "netriskscan-cli";
|
|
@@ -812,7 +818,8 @@ See [examples/](examples/) for runnable scripts.
|
|
|
812
818
|
|
|
813
819
|
## Security
|
|
814
820
|
|
|
815
|
-
-
|
|
821
|
+
- Google authorization displays a redacted key identifier. Use `auth key` to view a saved key explicitly.
|
|
822
|
+
Error output and browser URLs omit the API key.
|
|
816
823
|
- There is no telemetry: **the CLI does not collect usage analytics or telemetry** of any
|
|
817
824
|
kind, in any version.
|
|
818
825
|
- If `--debug` needs to show an authorization value, it is redacted
|
|
@@ -838,6 +845,30 @@ Endpoints called by the CLI:
|
|
|
838
845
|
|
|
839
846
|
- `GET /v1/ip-risk/{ip}` with `ip-risk:read`
|
|
840
847
|
- `GET /v1/usage` with `usage:read`
|
|
848
|
+
- `POST /v1/cli/authorization/loopback` and its exchange and acknowledgement endpoints
|
|
849
|
+
for automatic Google sign-in
|
|
850
|
+
|
|
851
|
+
### Loopback authorization contract
|
|
852
|
+
|
|
853
|
+
The CLI sends `transactionId`, `installationId`, `state`, `redirectUri`,
|
|
854
|
+
`codeChallenge` (S256), and `publicKey` (base64 DER SPKI) in the start request.
|
|
855
|
+
The server returns `flow: "loopback"`, `transactionId`, `expiresAt`, and the
|
|
856
|
+
`https://www.netriskscan.com/developer/cli/loopback` browser URL
|
|
857
|
+
with `#transactionId=<id>&state=<state>`. The registered redirect URI uses an
|
|
858
|
+
ephemeral port on `http://127.0.0.1` and the exact path `/oauth/callback`.
|
|
859
|
+
|
|
860
|
+
After Google verifies the account, the server creates or links the Developer
|
|
861
|
+
account and redirects to the registered URI with `state` and a one-time `code`
|
|
862
|
+
(32 bytes encoded as base64url). It can instead return `state` and an OAuth
|
|
863
|
+
`error` such as `access_denied`. The CLI exchanges the code by posting
|
|
864
|
+
`{ codeVerifier, authorizationCode }` to `/v1/cli/authorization/loopback/{id}/exchange`.
|
|
865
|
+
The server verifies the PKCE proof, expiry, and code use, then issues a key bound
|
|
866
|
+
to the installation. An `issued` response contains `accountEmail`, `keyId`, `encryptedApiKey` (base64),
|
|
867
|
+
`encryption: "RSA-OAEP-256"`, and `expiresAt`. An `existing` response identifies the
|
|
868
|
+
installation's stored Key ID and carries no ciphertext. The code is redeemable once.
|
|
869
|
+
After saving the key, the CLI acknowledges delivery. If the server response was lost
|
|
870
|
+
or the existing local key is unavailable, revoke the installation key in the Developer
|
|
871
|
+
Console and sign in again.
|
|
841
872
|
|
|
842
873
|
The [OpenAPI contract](https://www.netriskscan.com/assets/paid-api-v1.yaml) also
|
|
843
874
|
documents the server-side batch endpoint. Key creation, rotation, and revocation
|
|
@@ -888,7 +919,9 @@ Yes - `netriskscan check <ip> --json` prints the raw API response, and
|
|
|
888
919
|
|
|
889
920
|
### Does NetRiskScan CLI work without an API key?
|
|
890
921
|
|
|
891
|
-
The CLI
|
|
922
|
+
The CLI can obtain a key through [interactive Google authorization](#getting-an-api-key)
|
|
923
|
+
using the loopback service. For unattended runs, set
|
|
924
|
+
`NETRISKSCAN_API_KEY` before running the command.
|
|
892
925
|
|
|
893
926
|
## Official resources
|
|
894
927
|
|