mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 10:01:24 +00:00
fix(auth): strip line breaks from pasted keys
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { AuthProfileCredential, AuthProfileStore } from "./types.js";
|
||||
import { normalizeSecretInput } from "../../utils/normalize-secret-input.js";
|
||||
import { normalizeProviderId } from "../model-selection.js";
|
||||
import {
|
||||
ensureAuthProfileStore,
|
||||
@@ -49,8 +50,19 @@ export function upsertAuthProfile(params: {
|
||||
credential: AuthProfileCredential;
|
||||
agentDir?: string;
|
||||
}): void {
|
||||
const credential =
|
||||
params.credential.type === "api_key"
|
||||
? {
|
||||
...params.credential,
|
||||
...(typeof params.credential.key === "string"
|
||||
? { key: normalizeSecretInput(params.credential.key) }
|
||||
: {}),
|
||||
}
|
||||
: params.credential.type === "token"
|
||||
? { ...params.credential, token: normalizeSecretInput(params.credential.token) }
|
||||
: params.credential;
|
||||
const store = ensureAuthProfileStore(params.agentDir);
|
||||
store.profiles[params.profileId] = params.credential;
|
||||
store.profiles[params.profileId] = credential;
|
||||
saveAuthProfileStore(store, params.agentDir);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user