mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 21:48:27 +00:00
refactor(auth): share resolve profile params type
This commit is contained in:
@@ -84,6 +84,13 @@ function isExpiredCredential(expires: number | undefined): boolean {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ResolveApiKeyForProfileParams = {
|
||||||
|
cfg?: OpenClawConfig;
|
||||||
|
store: AuthProfileStore;
|
||||||
|
profileId: string;
|
||||||
|
agentDir?: string;
|
||||||
|
};
|
||||||
|
|
||||||
async function refreshOAuthTokenWithLock(params: {
|
async function refreshOAuthTokenWithLock(params: {
|
||||||
profileId: string;
|
profileId: string;
|
||||||
agentDir?: string;
|
agentDir?: string;
|
||||||
@@ -143,12 +150,9 @@ async function refreshOAuthTokenWithLock(params: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function tryResolveOAuthProfile(params: {
|
async function tryResolveOAuthProfile(
|
||||||
cfg?: OpenClawConfig;
|
params: ResolveApiKeyForProfileParams,
|
||||||
store: AuthProfileStore;
|
): Promise<{ apiKey: string; provider: string; email?: string } | null> {
|
||||||
profileId: string;
|
|
||||||
agentDir?: string;
|
|
||||||
}): Promise<{ apiKey: string; provider: string; email?: string } | null> {
|
|
||||||
const { cfg, store, profileId } = params;
|
const { cfg, store, profileId } = params;
|
||||||
const cred = store.profiles[profileId];
|
const cred = store.profiles[profileId];
|
||||||
if (!cred || cred.type !== "oauth") {
|
if (!cred || cred.type !== "oauth") {
|
||||||
@@ -187,12 +191,9 @@ async function tryResolveOAuthProfile(params: {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function resolveApiKeyForProfile(params: {
|
export async function resolveApiKeyForProfile(
|
||||||
cfg?: OpenClawConfig;
|
params: ResolveApiKeyForProfileParams,
|
||||||
store: AuthProfileStore;
|
): Promise<{ apiKey: string; provider: string; email?: string } | null> {
|
||||||
profileId: string;
|
|
||||||
agentDir?: string;
|
|
||||||
}): Promise<{ apiKey: string; provider: string; email?: string } | null> {
|
|
||||||
const { cfg, store, profileId } = params;
|
const { cfg, store, profileId } = params;
|
||||||
const cred = store.profiles[profileId];
|
const cred = store.profiles[profileId];
|
||||||
if (!cred) {
|
if (!cred) {
|
||||||
|
|||||||
Reference in New Issue
Block a user