vigievuln 1.0.1 → 1.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.
- package/CHANGELOG.md +10 -0
- package/README.md +45 -3
- package/completions/vigievuln.bash +4 -1
- package/completions/vigievuln.zsh +3 -0
- package/lib/account-client.js +165 -0
- package/lib/account-session.js +436 -0
- package/lib/application-plugins/runner.js +73 -13
- package/lib/application-plugins/wordpress.js +10 -3
- package/lib/application-providers/live-snapshot.js +6 -1
- package/lib/application-providers/wordfence-client.js +70 -0
- package/lib/application-providers/wordfence-projection.js +76 -0
- package/lib/application-providers/wordfence-v3.js +22 -6
- package/lib/certfr.js +17 -2
- package/lib/cli-command-routing.js +49 -0
- package/lib/cli-project-commands.js +85 -0
- package/lib/cli-watch.js +110 -0
- package/lib/cms-snapshot-warm.js +11 -4
- package/lib/codecs/composer/registry.js +2 -2
- package/lib/codecs/composer/relations.js +18 -0
- package/lib/codecs/composer.codec.js +2 -0
- package/lib/codecs/go/parse.js +23 -9
- package/lib/codecs/go/registry.js +2 -2
- package/lib/codecs/go.codec.js +20 -3
- package/lib/codecs/maven.codec.js +20 -1
- package/lib/codecs/npm/collect.js +90 -6
- package/lib/codecs/npm/registry.js +2 -2
- package/lib/codecs/nuget/parse.js +5 -1
- package/lib/codecs/nuget/registry.js +2 -2
- package/lib/codecs/nuget.codec.js +2 -12
- package/lib/codecs/pypi/registry.js +2 -2
- package/lib/codecs/ruby/parse.js +3 -0
- package/lib/codecs/ruby/registry.js +2 -2
- package/lib/codecs/ruby/relations.js +62 -0
- package/lib/codecs/ruby.codec.js +4 -1
- package/lib/codecs/version-evidence.js +18 -0
- package/lib/cve-match.js +4 -0
- package/lib/deps-descriptor.js +1 -1
- package/lib/epss.js +6 -2
- package/lib/euvd.js +20 -2
- package/lib/hosted-proxy.js +49 -0
- package/lib/kev.js +17 -1
- package/lib/nvd.js +4 -4
- package/lib/osv-db.js +1 -0
- package/lib/osv.js +3 -2
- package/lib/outdated.js +6 -5
- package/lib/packagist-audit.js +3 -3
- package/lib/project-client.js +121 -0
- package/lib/project-descriptor.js +30 -0
- package/lib/providers/certfr.js +1 -0
- package/lib/providers/euvd.js +1 -0
- package/lib/providers/github.js +1 -0
- package/lib/providers/index.js +15 -5
- package/lib/providers/kev.js +1 -1
- package/lib/providers/wordfence.js +5 -1
- package/lib/resource-cache/engine.js +149 -20
- package/lib/resource-cache/validate.js +10 -3
- package/lib/resource-cache/wordfence.js +77 -0
- package/lib/retire.js +29 -14
- package/lib/source-health.js +6 -0
- package/lib/transitive.js +1 -1
- package/package.json +1 -1
- package/vigievuln.js +158 -52
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog — VigieVuln
|
|
2
2
|
|
|
3
|
+
## [1.1.0] — 2026-10-28
|
|
4
|
+
|
|
5
|
+
- Hosted proxy scans query CVE, KEV, EUVD and CERT-FR records by dependency or CVE instead of downloading bulk catalogues.
|
|
6
|
+
- Configure the official proxy persistently, sign in to create a proxy key, and reuse it for later scans.
|
|
7
|
+
- Preserve OSV pagination tokens through the proxy and identify stale responses in batches.
|
|
8
|
+
- Sign in and upload a reviewed project descriptor to monitor direct dependencies for high or critical vulnerabilities.
|
|
9
|
+
- Use `watch`, `scan`, `login`, `logout` and `whoami` as direct commands; `watch --export` prepares a local descriptor.
|
|
10
|
+
- Use targeted Wordfence results through the hosted proxy, with explicit warnings when cached data is stale.
|
|
11
|
+
- Limit GitHub release notes to the changelog section for the release version.
|
|
12
|
+
|
|
3
13
|
## [1.0.1] — 2026-10-26
|
|
4
14
|
|
|
5
15
|
- Regenerated the HTML sample reports, terminal demo and report screenshot with VigieVuln branding.
|
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
<h1 align="center">
|
|
2
|
-
VigieVuln
|
|
2
|
+
<img src="docs/assets/VigieVuln_Logo_sm.png" alt="VigieVuln" height="200">
|
|
3
3
|
</h1>
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
[](https://www.npmjs.com/package/vigievuln)
|
|
6
7
|
[](https://www.npmjs.com/package/vigievuln)
|
|
7
8
|
[](LICENSE)
|
|
@@ -25,11 +26,13 @@ It scans **10 ecosystems + 9 CMS/Frameworks** (WordPress, Drupal, Symfony, Larav
|
|
|
25
26
|
- **10 ecosystems in one pass**; Maven, Gradle, npm/Yarn/pnpm, Composer, PyPI, NuGet, Go, Ruby — plus **vendored JS**, committed **native binaries** (identified by checksum) and **embedded JARs** (fat-jars/war/ear, opened in-memory).
|
|
26
27
|
- **No build tools**; No `mvn`/`gradle`/`npm`/`pip`/`dotnet`/`go`, no `node_modules/` → [how](docs/COMPARISON.md#how-its-autonomous-no-build-tools)
|
|
27
28
|
- **CVE from multiple sources, merged & prioritised**; CVEProject + OSV.dev + Packagist security advisories + NVD, ranked **CISA KEV → EPSS → CVSS**.
|
|
28
|
-
- **European references on every CVE**: ENISA **EUVD** id + ENISA's exploited flag, **GCVE** id, and the **CERT-FR** advisories citing it
|
|
29
|
+
- **European references on every CVE**: ENISA **EUVD** id + ENISA's exploited flag, **GCVE** id, and the **CERT-FR** advisories citing it. Hosted proxy lookups send relevant CVE identifiers to the proxy.
|
|
29
30
|
- **Beyond CVEs**; Report **EOL and out-of-active-support** frameworks, deprecated/abandoned/yanked, outdated, SPDX **licenses**, and **private/internal packages**
|
|
30
31
|
- **CMS & frameworks audited as instances**; Symfony, Laravel, WordPress, Drupal, Joomla, PrestaShop, TYPO3, Magento/Adobe Commerce and SPIP with per-instance inventory (core, plugins, themes, bundles, components) → [the dedicated guide](docs/CMS-FRAMEWORKS.md)
|
|
31
32
|
- **Crypto material**; committed **certificates**, **private vs public keys** across PEM/OpenSSH/PuTTY/PGP and JKS/PKCS#12 keystores.
|
|
32
33
|
- **Air-gapped flow**; **zero network under `--offline`** → [Benchmark](docs/BENCHMARK.md) · [Air-gapped](#air-gapped-audits)
|
|
34
|
+
- **Hosted proxy with a verified account**; `--set-proxy-cache vigievuln` → [hosted proxy](docs/USAGE.md#hosted-vigievuln-proxy)
|
|
35
|
+
- **Project monitoring**; `vigievuln watch ./project --name 'My Project'` — one free project with up to **100 distinct direct dependency coordinates** → [monitoring guide](docs/USAGE.md#project-monitoring)
|
|
33
36
|
- **Shared cache for a scanner fleet**; `vigievuln serve-cache` + `--proxy-cache` → [cache usage](docs/USAGE.md#shared-proxy-cache-server-serve-cache----proxy-cache)
|
|
34
37
|
- **Supply-chain risk**; known-**malicious** advisories and suspected **typosquats** (`--typosquat`).
|
|
35
38
|
- **Audit-grade**; every report carries a **provenance manifest** and a **Methodology & limitations** chapter; a `SHA256SUMS`;
|
|
@@ -53,11 +56,50 @@ existing credentials, warmed data and air-gapped workflows keep working.
|
|
|
53
56
|
|
|
54
57
|
```bash
|
|
55
58
|
npm install -g vigievuln
|
|
56
|
-
vigievuln
|
|
59
|
+
vigievuln scan ./code # → ./vigievuln-report/cve-report.html
|
|
57
60
|
```
|
|
58
61
|
|
|
59
62
|
A free [NVD API key](https://nvd.nist.gov/developers/request-an-api-key) (instant) gives 10× faster enrichment: `vigievuln --set-nvd-key YOUR_KEY`. A few common runs; full list via `vigievuln --help` or [docs/USAGE.md](docs/USAGE.md)
|
|
60
63
|
|
|
64
|
+
### Monitor a project
|
|
65
|
+
|
|
66
|
+
Create and verify your [account](https://www.vigievuln.fr/account), then:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
vigievuln login
|
|
70
|
+
vigievuln whoami
|
|
71
|
+
vigievuln watch ./project --name 'My Project'
|
|
72
|
+
vigievuln project status
|
|
73
|
+
vigievuln logout
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`watch` collects the inventory locally and uploads it once. Run it again with the same unique project name to update that project's inventory; it does not run a background watcher. `login` creates an account session and does not configure the proxy cache.
|
|
77
|
+
|
|
78
|
+
The free tier includes **one project and up to 100 distinct direct dependency coordinates per project**. Multiple versions of the same coordinate count once. Dependencies whose direct relationship cannot be established are excluded from monitoring and reported as incomplete coverage. This quota applies to hosted monitoring, not local scans.
|
|
79
|
+
|
|
80
|
+
To review the inventory before uploading, export it locally:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
vigievuln watch ./project --export fichier.json
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`--export` only writes the descriptor: it runs offline, requires no login and sends nothing to the service. Review package names and versions, including private packages, before uploading. Source code, paths and registry URLs are omitted from the descriptor.
|
|
87
|
+
|
|
88
|
+
Monitoring establishes a silent initial baseline, then reports new high or critical vulnerabilities (CVSS ≥ 7) and known exploited vulnerabilities affecting direct dependencies. Enable alerts in your account and refresh the inventory when dependencies change. [Monitoring workflow and compatibility commands](docs/USAGE.md#project-monitoring).
|
|
89
|
+
|
|
90
|
+
Existing commands remain supported: `vigievuln -s ./code`, `auth login|status|logout`, `--prepare-project` and `project push`.
|
|
91
|
+
|
|
92
|
+
### Official Vigie Vuln proxy cache
|
|
93
|
+
|
|
94
|
+
Configure the proxy once, then sign in with your verified [Vigie Vuln account](https://www.vigievuln.fr/account) when prompted:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
vigievuln --set-proxy-cache vigievuln # `default` selects the same official proxy
|
|
98
|
+
vigievuln scan ./code
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The selection and the proxy key created during proxy sign-in are saved in `~/.fad-checker/config.json` and reused on subsequent scans. This proxy key is separate from the account session used by `watch`. Alternatively, save an existing key with `vigievuln --set-proxy-cache-token <key>`, or provide it via `VIGIEVULN_PROXY_CACHE_TOKEN` (useful in CI). Remove the selection or key with `--unset-proxy-cache` or `--unset-proxy-cache-token`. `--proxy-cache <url>` overrides the saved selection for one scan. The hosted proxy receives requested package coordinates and CVE identifiers; it does not receive your source code. [Proxy documentation](docs/USAGE.md#hosted-vigievuln-proxy).
|
|
102
|
+
|
|
61
103
|
### Interactive HTML samples
|
|
62
104
|
|
|
63
105
|
- **[Apache Dubbo 2.7.8 — open the report](https://9pings.github.io/VigieVuln/samples/dubbo.html)**: the project used for the report screenshot below, rescanned with VigieVuln 1.0.1; 105 Maven descriptors, direct/transitive CVEs, KEV matches, EOL and fix recommendations.
|
|
@@ -6,11 +6,14 @@ _fad_check_complete() {
|
|
|
6
6
|
COMPREPLY=()
|
|
7
7
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
8
8
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
9
|
-
opts="--src --target --exclude --verbose --no-report --no-transitive --no-all-libs --no-osv --no-nvd --no-epss --no-kev --licenses --no-retire --retire-refresh --report-output --report-html --report-doc --report-xlsx --report-sbom --report-csaf --report-json --report-sarif --fail-on --fail-on-new --baseline --no-checksums --ignore --vex --ignore-test --cve-refresh --cve-offline --snyk --transitive-depth --offline --ecosystem --no-maven --no-npm --no-yarn --no-nuget --no-composer --no-pypi --no-go --no-ruby --no-jars --no-binaries --no-certs --cert-expiry-days --retries --no-nvd-mirror --eol-support --no-eol --no-js --set-nvd-key --show-config --completion --help --version --disable --activate --report --help-all -s -t -e -h -v -d -a -r -o"
|
|
9
|
+
opts="--vigievuln-proxy --proxy-cache --proxy-cache-token --src --target --exclude --verbose --no-report --no-transitive --no-all-libs --no-osv --no-nvd --no-epss --no-kev --licenses --no-retire --retire-refresh --report-output --report-html --report-doc --report-xlsx --report-sbom --report-csaf --report-json --report-sarif --fail-on --fail-on-new --baseline --no-checksums --ignore --vex --ignore-test --cve-refresh --cve-offline --snyk --transitive-depth --offline --ecosystem --no-maven --no-npm --no-yarn --no-nuget --no-composer --no-pypi --no-go --no-ruby --no-jars --no-binaries --no-certs --cert-expiry-days --retries --no-nvd-mirror --eol-support --no-eol --no-js --set-nvd-key --show-config --completion --help --version --disable --activate --report --help-all -s -t -e -h -v -d -a -r -o"
|
|
10
10
|
case "$prev" in
|
|
11
11
|
--src|-s|--target|-t|--report-output|-o)
|
|
12
12
|
COMPREPLY=( $(compgen -d -- "$cur") )
|
|
13
13
|
return 0 ;;
|
|
14
|
+
--vigievuln-proxy)
|
|
15
|
+
COMPREPLY=( $(compgen -W "fr com" -- "$cur") )
|
|
16
|
+
return 0 ;;
|
|
14
17
|
--ecosystem)
|
|
15
18
|
COMPREPLY=( $(compgen -W "auto all maven npm yarn nuget composer pypi" -- "$cur") )
|
|
16
19
|
return 0 ;;
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
_fad_check() {
|
|
4
4
|
local -a opts
|
|
5
5
|
opts=(
|
|
6
|
+
'--vigievuln-proxy[Use the hosted proxy]::domain:(fr com)'
|
|
7
|
+
'--proxy-cache[Shared proxy URL]:url:'
|
|
8
|
+
'--proxy-cache-token[Proxy authentication key]:token:'
|
|
6
9
|
'-s[root directory containing pom.xml files]:directory:_directories'
|
|
7
10
|
'--src[root directory containing pom.xml files]:directory:_directories'
|
|
8
11
|
'-t[output directory]:directory:_directories'
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { createAccountSessionStore, validateAccountSession } = require('./account-session');
|
|
4
|
+
|
|
5
|
+
const ACCOUNT_ORIGIN = 'https://www.vigievuln.fr';
|
|
6
|
+
const DEFAULT_TIMEOUT_MS = 15000;
|
|
7
|
+
const MAX_RESPONSE_BYTES = 64 * 1024;
|
|
8
|
+
|
|
9
|
+
class AccountClientError extends Error {
|
|
10
|
+
constructor(code, message, status) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'AccountClientError';
|
|
13
|
+
this.code = code;
|
|
14
|
+
if (status !== undefined) this.status = status;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const invalidResponse = () => new AccountClientError('INVALID_RESPONSE', 'Invalid account API response.');
|
|
19
|
+
const isAccount = value => value && typeof value === 'object' && !Array.isArray(value) &&
|
|
20
|
+
typeof value.id === 'string' && value.id.length > 0 && typeof value.email === 'string' && value.email.length > 0;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Account authentication for future project commands; no proxy config or keys.
|
|
24
|
+
* Only the transport, store, clock and timeout are injectable; never the origin.
|
|
25
|
+
* login({email,password}) -> {account,expiresAt}; me() -> {account};
|
|
26
|
+
* logout() -> {revoked}. logout always clears local storage, including on a
|
|
27
|
+
* remote error, which is still reported (revocation is then unconfirmed).
|
|
28
|
+
* The password exists only in the in-flight request, never in the store.
|
|
29
|
+
*/
|
|
30
|
+
function createAccountClient({ fetcher = globalThis.fetch, now = Date.now,
|
|
31
|
+
sessionStore = createAccountSessionStore({ now }), timeoutMs = DEFAULT_TIMEOUT_MS } = {}) {
|
|
32
|
+
if (typeof fetcher !== 'function' || !Number.isInteger(timeoutMs) || timeoutMs <= 0 || timeoutMs > 2147483647) {
|
|
33
|
+
throw new AccountClientError('INVALID_OPTIONS', 'Invalid account transport or timeout.');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function request(route, method, body, token) {
|
|
37
|
+
const controller = new AbortController();
|
|
38
|
+
let timer;
|
|
39
|
+
let response;
|
|
40
|
+
const deadline = new Promise((_, reject) => {
|
|
41
|
+
timer = setTimeout(() => {
|
|
42
|
+
reject(new AccountClientError('TIMEOUT', 'Account API request timed out.'));
|
|
43
|
+
controller.abort();
|
|
44
|
+
}, timeoutMs);
|
|
45
|
+
});
|
|
46
|
+
const operation = async () => {
|
|
47
|
+
response = await fetcher(ACCOUNT_ORIGIN + '/v1/accounts/' + route, {
|
|
48
|
+
method, redirect: 'error', credentials: 'omit', cache: 'no-store',
|
|
49
|
+
headers: { accept: 'application/json', ...(body !== undefined ? { 'content-type': 'application/json' } : {}),
|
|
50
|
+
...(token ? { authorization: 'Bearer ' + token } : {}) },
|
|
51
|
+
...(body !== undefined ? { body: JSON.stringify(body) } : {}), signal: controller.signal,
|
|
52
|
+
});
|
|
53
|
+
if (controller.signal.aborted) {
|
|
54
|
+
if (response.body && !response.body.locked) void response.body.cancel().catch(() => {});
|
|
55
|
+
throw new AccountClientError('TIMEOUT', 'Account API request timed out.');
|
|
56
|
+
}
|
|
57
|
+
// Also reject an injected transport that reports a redirect/followed URL.
|
|
58
|
+
if (response.redirected || (response.status >= 300 && response.status < 400) ||
|
|
59
|
+
(response.url && response.url !== ACCOUNT_ORIGIN + '/v1/accounts/' + route)) {
|
|
60
|
+
throw new AccountClientError('REDIRECT_REFUSED', 'Account API redirects are forbidden.');
|
|
61
|
+
}
|
|
62
|
+
if (!response.ok) {
|
|
63
|
+
const code = ({ 401: 'UNAUTHORIZED', 403: 'FORBIDDEN', 429: 'RATE_LIMITED' })[response.status] || 'HTTP_ERROR';
|
|
64
|
+
throw new AccountClientError(code, `Account API request failed (HTTP ${response.status}).`, response.status);
|
|
65
|
+
}
|
|
66
|
+
if (!/^application\/json(?:\s*;|$)/i.test(response.headers.get('content-type') || '') || !response.body) throw invalidResponse();
|
|
67
|
+
const reader = response.body.getReader();
|
|
68
|
+
const cancel = () => { void reader.cancel().catch(() => {}); };
|
|
69
|
+
controller.signal.addEventListener('abort', cancel, { once: true });
|
|
70
|
+
const chunks = [];
|
|
71
|
+
let size = 0;
|
|
72
|
+
try {
|
|
73
|
+
while (true) {
|
|
74
|
+
const { value, done } = await reader.read();
|
|
75
|
+
if (done) break;
|
|
76
|
+
size += value.byteLength;
|
|
77
|
+
if (size > MAX_RESPONSE_BYTES) throw invalidResponse();
|
|
78
|
+
chunks.push(Buffer.from(value));
|
|
79
|
+
}
|
|
80
|
+
} finally {
|
|
81
|
+
// Do not allow cancellation of an injected stream to hold up the timeout.
|
|
82
|
+
controller.signal.removeEventListener('abort', cancel);
|
|
83
|
+
cancel();
|
|
84
|
+
reader.releaseLock();
|
|
85
|
+
}
|
|
86
|
+
let data;
|
|
87
|
+
try { data = JSON.parse(Buffer.concat(chunks).toString('utf8')); }
|
|
88
|
+
catch { throw invalidResponse(); }
|
|
89
|
+
if (!data || typeof data !== 'object' || Array.isArray(data)) throw invalidResponse();
|
|
90
|
+
return data;
|
|
91
|
+
};
|
|
92
|
+
try { return await Promise.race([operation(), deadline]); }
|
|
93
|
+
catch (error) {
|
|
94
|
+
if (error instanceof AccountClientError) throw error;
|
|
95
|
+
// Fetch/JSON errors can include a URL, credentials or response contents.
|
|
96
|
+
throw new AccountClientError('NETWORK_ERROR', 'Unable to reach the account API.');
|
|
97
|
+
} finally {
|
|
98
|
+
clearTimeout(timer);
|
|
99
|
+
controller.abort();
|
|
100
|
+
if (response?.body && !response.body.locked) void response.body.cancel().catch(() => {});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function currentSession() {
|
|
105
|
+
const session = await sessionStore.read();
|
|
106
|
+
if (!session) throw new AccountClientError('NOT_AUTHENTICATED', 'No account session. Sign in first.');
|
|
107
|
+
return validateAccountSession(session, now());
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function login(credentials = {}) {
|
|
111
|
+
const { email, password } = credentials || {};
|
|
112
|
+
if (typeof email !== 'string' || !email.trim() || email.length > 254 ||
|
|
113
|
+
typeof password !== 'string' || !password || Buffer.byteLength(password, 'utf8') > 512) {
|
|
114
|
+
throw new AccountClientError('INVALID_CREDENTIALS', 'An email and password are required.');
|
|
115
|
+
}
|
|
116
|
+
const data = await request('login', 'POST', { email, password });
|
|
117
|
+
let session;
|
|
118
|
+
try { session = validateAccountSession(data, now()); }
|
|
119
|
+
catch { throw invalidResponse(); }
|
|
120
|
+
if (data.tokenType !== 'Bearer' || !isAccount(data.account)) throw invalidResponse();
|
|
121
|
+
try { await sessionStore.write(session); }
|
|
122
|
+
catch (error) {
|
|
123
|
+
// Avoid leaving a newly issued session alive when local persistence fails.
|
|
124
|
+
try { await request('logout', 'POST', {}, session.token); } catch { /* expires server-side */ }
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
return { account: data.account, expiresAt: session.expiresAt };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
async function me() {
|
|
131
|
+
const session = await currentSession();
|
|
132
|
+
try {
|
|
133
|
+
const data = await request('me', 'GET', undefined, session.token);
|
|
134
|
+
if (!isAccount(data.account)) throw invalidResponse();
|
|
135
|
+
return { account: data.account };
|
|
136
|
+
} catch (error) {
|
|
137
|
+
if (error.code === 'UNAUTHORIZED') await sessionStore.clear();
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
async function createProxyKey() {
|
|
143
|
+
const session = await currentSession();
|
|
144
|
+
const data = await request('proxy-keys', 'POST', { name: 'VigieVuln CLI' }, session.token);
|
|
145
|
+
if (typeof data?.key?.token !== 'string' || !data.key.token) throw invalidResponse();
|
|
146
|
+
return { token: data.key.token };
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function logout() {
|
|
150
|
+
try {
|
|
151
|
+
const stored = await sessionStore.read();
|
|
152
|
+
if (!stored) return { revoked: 0 };
|
|
153
|
+
let session;
|
|
154
|
+
try { session = validateAccountSession(stored, now()); }
|
|
155
|
+
catch (error) { if (error.code === 'SESSION_EXPIRED') return { revoked: 0 }; throw error; }
|
|
156
|
+
const data = await request('logout', 'POST', {}, session.token);
|
|
157
|
+
if (!Number.isSafeInteger(data.revoked) || data.revoked < 0) throw invalidResponse();
|
|
158
|
+
return { revoked: data.revoked };
|
|
159
|
+
} finally { await sessionStore.clear(); }
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return { login, logout, me, createProxyKey };
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
module.exports = { ACCOUNT_ORIGIN, DEFAULT_TIMEOUT_MS, createAccountClient, AccountClientError };
|