mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-05-24 22:15:42 +00:00
- 8.2: update-notifier em omniroute.mjs (cache 24h, stderr-only, respeita CI/quiet/json/opt-out) - 8.12: cliToken.mjs (sha256 de machineId + salt) injetado automaticamente em apiFetch - 8.12: middleware cliTokenAuth.ts valida token apenas em loopback, timing-safe compare - 8.12: requireManagementAuth aceita CLI token como bypass local - env-doc-sync: OMNIROUTE_DISABLE_CLI_TOKEN e OMNIROUTE_NO_UPDATE_NOTIFIER no allowlist
22 lines
509 B
JavaScript
22 lines
509 B
JavaScript
import crypto from "node:crypto";
|
|
|
|
const SALT = "omniroute-cli-auth-v1";
|
|
export const CLI_TOKEN_HEADER = "x-omniroute-cli-token";
|
|
|
|
let _cached = null;
|
|
|
|
export async function getCliToken() {
|
|
if (_cached !== null) return _cached;
|
|
try {
|
|
const { machineIdSync } = await import("node-machine-id");
|
|
const mid = machineIdSync();
|
|
_cached = crypto
|
|
.createHash("sha256")
|
|
.update(mid + SALT)
|
|
.digest("hex")
|
|
.substring(0, 32);
|
|
} catch {
|
|
_cached = "";
|
|
}
|
|
return _cached;
|
|
}
|