test(onboard): satisfy gateway token lint

This commit is contained in:
BKF-Gitty
2026-04-17 00:49:03 +03:00
committed by Gustavo Madeira Santana
parent 8c188f4607
commit 39d18a4b86
2 changed files with 7 additions and 4 deletions

View File

@@ -9,9 +9,13 @@ import { applyNonInteractiveGatewayConfig } from "./gateway-config.js";
const randomToken = vi.hoisted(() => vi.fn(() => "generated-random-token"));
vi.mock("../../onboard-helpers.js", () => ({
normalizeGatewayTokenInput: (value: unknown): string => {
if (typeof value !== "string") return "";
if (typeof value !== "string") {
return "";
}
const trimmed = value.trim();
if (trimmed === "undefined" || trimmed === "null") return "";
if (trimmed === "undefined" || trimmed === "null") {
return "";
}
return trimmed;
},
randomToken,

View File

@@ -64,8 +64,7 @@ export function applyNonInteractiveGatewayConfig(params: {
// plaintext > ambient OPENCLAW_GATEWAY_TOKEN > randomToken(). Ambient env
// must not rotate a token already written to disk — a stale shell or
// launchd env var otherwise breaks already-paired clients.
let gatewayToken =
explicitGatewayToken || existingPlaintextToken || envGatewayToken || undefined;
let gatewayToken = explicitGatewayToken || existingPlaintextToken || envGatewayToken || undefined;
const gatewayTokenRefEnv = normalizeOptionalString(opts.gatewayTokenRefEnv ?? "") ?? "";
if (authMode === "token") {