mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 03:51:25 +00:00
fix(auth): strip line breaks from pasted keys
This commit is contained in:
@@ -4,6 +4,10 @@ import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { ModelProviderAuthMode, ModelProviderConfig } from "../config/types.js";
|
||||
import { formatCliCommand } from "../cli/command-format.js";
|
||||
import { getShellEnvAppliedKeys } from "../infra/shell-env.js";
|
||||
import {
|
||||
normalizeOptionalSecretInput,
|
||||
normalizeSecretInput,
|
||||
} from "../utils/normalize-secret-input.js";
|
||||
import {
|
||||
type AuthProfileStore,
|
||||
ensureAuthProfileStore,
|
||||
@@ -48,8 +52,7 @@ export function getCustomProviderApiKey(
|
||||
provider: string,
|
||||
): string | undefined {
|
||||
const entry = resolveProviderConfig(cfg, provider);
|
||||
const key = entry?.apiKey?.trim();
|
||||
return key || undefined;
|
||||
return normalizeOptionalSecretInput(entry?.apiKey);
|
||||
}
|
||||
|
||||
function resolveProviderAuthOverride(
|
||||
@@ -236,7 +239,7 @@ export function resolveEnvApiKey(provider: string): EnvApiKeyResult | null {
|
||||
const normalized = normalizeProviderId(provider);
|
||||
const applied = new Set(getShellEnvAppliedKeys());
|
||||
const pick = (envVar: string): EnvApiKeyResult | null => {
|
||||
const value = process.env[envVar]?.trim();
|
||||
const value = normalizeOptionalSecretInput(process.env[envVar]);
|
||||
if (!value) {
|
||||
return null;
|
||||
}
|
||||
@@ -387,7 +390,7 @@ export async function getApiKeyForModel(params: {
|
||||
}
|
||||
|
||||
export function requireApiKey(auth: ResolvedProviderAuth, provider: string): string {
|
||||
const key = auth.apiKey?.trim();
|
||||
const key = normalizeSecretInput(auth.apiKey);
|
||||
if (key) {
|
||||
return key;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user