fix and update

This commit is contained in:
lendry
2026-07-07 08:06:55 +03:00
parent 28b04ada81
commit 9ca5071f1a
8 changed files with 152 additions and 20 deletions

View File

@@ -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;