mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 12:11:20 +00:00
refactor: simplify legacy auth provider normalization
This commit is contained in:
@@ -215,10 +215,11 @@ export function buildPersistedAuthProfileSecretsStore(
|
||||
export function applyLegacyAuthStore(store: AuthProfileStore, legacy: LegacyAuthStore): void {
|
||||
for (const [provider, cred] of Object.entries(legacy)) {
|
||||
const profileId = `${provider}:default`;
|
||||
const credentialProvider = cred.provider ?? provider;
|
||||
if (cred.type === "api_key") {
|
||||
store.profiles[profileId] = {
|
||||
type: "api_key",
|
||||
provider: String(cred.provider ?? provider),
|
||||
provider: credentialProvider,
|
||||
key: cred.key,
|
||||
...(cred.email ? { email: cred.email } : {}),
|
||||
};
|
||||
@@ -227,7 +228,7 @@ export function applyLegacyAuthStore(store: AuthProfileStore, legacy: LegacyAuth
|
||||
if (cred.type === "token") {
|
||||
store.profiles[profileId] = {
|
||||
type: "token",
|
||||
provider: String(cred.provider ?? provider),
|
||||
provider: credentialProvider,
|
||||
token: cred.token,
|
||||
...(typeof cred.expires === "number" ? { expires: cred.expires } : {}),
|
||||
...(cred.email ? { email: cred.email } : {}),
|
||||
@@ -236,7 +237,7 @@ export function applyLegacyAuthStore(store: AuthProfileStore, legacy: LegacyAuth
|
||||
}
|
||||
store.profiles[profileId] = {
|
||||
type: "oauth",
|
||||
provider: String(cred.provider ?? provider),
|
||||
provider: credentialProvider,
|
||||
access: cred.access,
|
||||
refresh: cred.refresh,
|
||||
expires: cred.expires,
|
||||
|
||||
Reference in New Issue
Block a user