fix: close competition cutover integrity gaps
This commit is contained in:
1 parent
7ea2002975
commit
683d602d63
57 files changed
+4805
-1582
No files matched your search
@@ -0,0 +1,35 @@
|
||||
export interface AuthQueryScopeInput {
|
||||
authUserId: string | null;
|
||||
accountKey: string | null;
|
||||
msalConfigured: boolean;
|
||||
msalReady: boolean;
|
||||
}
|
||||
|
||||
interface ExecuteAuthScopedQueryInput<T> {
|
||||
accountKey: string | null;
|
||||
acquireAccessToken: () => Promise<string>;
|
||||
request: (authorizationHeader: string | null) => Promise<T>;
|
||||
}
|
||||
|
||||
export function resolveAuthQueryScope({
|
||||
authUserId,
|
||||
accountKey,
|
||||
msalConfigured,
|
||||
msalReady,
|
||||
}: AuthQueryScopeInput) {
|
||||
return {
|
||||
cacheKey: [authUserId, accountKey] as const,
|
||||
ready: Boolean(authUserId || !msalConfigured || msalReady),
|
||||
};
|
||||
}
|
||||
|
||||
export async function executeAuthScopedQuery<T>({
|
||||
accountKey,
|
||||
acquireAccessToken,
|
||||
request,
|
||||
}: ExecuteAuthScopedQueryInput<T>): Promise<T> {
|
||||
if (!accountKey) return request(null);
|
||||
|
||||
const accessToken = await acquireAccessToken();
|
||||
return request(`Bearer ${accessToken}`);
|
||||
}
|
||||
Reference in new issue
Block a user