fix and update
This commit is contained in:
@@ -598,6 +598,29 @@ export async function syncFedcmSession(accessToken?: string | null) {
|
||||
}
|
||||
}
|
||||
|
||||
export interface FedcmSessionStatus {
|
||||
active: boolean;
|
||||
requiresPin: boolean;
|
||||
sessionId: string | null;
|
||||
userId: string | null;
|
||||
}
|
||||
|
||||
export async function fetchFedcmSessionStatus(apiBase: string): Promise<FedcmSessionStatus | null> {
|
||||
if (typeof window === 'undefined' || !apiBase.trim()) return null;
|
||||
const base = apiBase.replace(/\/+$/, '');
|
||||
try {
|
||||
const response = await fetch(`${base}/fedcm/session/status`, {
|
||||
method: 'GET',
|
||||
credentials: 'include',
|
||||
cache: 'no-store'
|
||||
});
|
||||
if (!response.ok) return null;
|
||||
return (await response.json()) as FedcmSessionStatus;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
let fedcmSyncTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let fedcmSyncInFlight = false;
|
||||
|
||||
|
||||
@@ -45,3 +45,11 @@ export async function finalizeFedcmLogin(accessToken: string) {
|
||||
export function shouldFinalizeFedcmLogin(pathname: string) {
|
||||
return pathname.startsWith('/auth/login');
|
||||
}
|
||||
|
||||
export function isFedcmLoginPopup() {
|
||||
if (typeof window === 'undefined') return false;
|
||||
if (window.opener) return true;
|
||||
if (window.IdentityProvider?.close) return true;
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
return params.get('fedcm') === '1';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user