Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
export const SESSION_HEADER_KEYS = {
tenantId: 'x-tenant-id',
organizationUnitId: 'x-organization-unit-id',
currentPositionId: 'x-current-position-id',
currentProjectId: 'x-current-project-id',
} as const;
const TOKEN_STORAGE_KEYS = [
'ema-backoffice-auth-token',
'ema-portal-auth-token',
'auth-token',
] as const;
export function resolveTokenFromStorage(): string | undefined {
for (const key of TOKEN_STORAGE_KEYS) {
const stored = localStorage.getItem(key);
if (stored) return stored;
}
const match = document.cookie.match(/(?:^|;\s*)auth-token=([^;]*)/);
return match ? decodeURIComponent(match[1]) : undefined;
}
export function resolveSessionContext(state?: { auth?: { token?: string } }): {
token: string | undefined;
sessionHeaders: Record<string, string>;
} {
const token = state?.auth?.token ?? resolveTokenFromStorage();
return { token, sessionHeaders: {} };
}