/** * ProfileStorageManager — Profile-Scoped Browser Storage * * Architecture: * - localStorage stores all profile data keyed by profile ID * - sessionStorage stores the active profile ID per browser tab * - Different tabs can have different active profiles simultaneously * * Storage layout: * localStorage: * "bf-profiles" → ProfileMeta[] (list of all profiles) * "bf-p-{profileId}-user" → User object * "bf-p-{profileId}-tokens" → AuthTokens * "bf-p-{profileId}-workspace-token" → string (workspace JWT) * "bf-p-{profileId}-context" → { orgId, workspaceId, projectId, tenantId } * "bf-p-{profileId}-locale" → string (locale code) * "bf-p-{profileId}-theme-mode" → string * "bf-p-{profileId}-theme-brand" → string * "bf-p-{profileId}-theme-density" → string * "bf-p-{profileId}-theme-typography" → string * "bf-p-{profileId}-sidebar-collapsed" → "true"|"false" * sessionStorage: * "bf-active-profile" → string (profileId for this tab) */ export interface ProfileMeta { id: string; email: string; name: string; avatar?: string; lastLogin: string; } export interface AuthTokens { accessToken: string; refreshToken?: string; expiresAt?: number; } export interface ProfileContext { organizationId?: string | null; workspaceId?: string | null; projectId?: string | null; tenantId?: string | null; } export interface ProfileUser { id: string; email: string; firstName?: string; lastName?: string; avatar?: string; username?: string; name?: string; role?: string; permissions?: string[]; [key: string]: unknown; } /** * Custom event dispatched when profile storage changes (same-tab). * The native 'storage' event only fires in OTHER tabs. */ export declare const PROFILE_STORAGE_CHANGE_EVENT = "bf-profile-storage-change"; export declare function getProfiles(): ProfileMeta[]; export declare function setProfiles(profiles: ProfileMeta[]): void; export declare function addProfile(meta: ProfileMeta): void; export declare function removeProfile(profileId: string): void; export declare function removeAllProfiles(): void; export declare function getActiveProfileId(): string | null; export declare function setActiveProfileId(profileId: string): void; export declare function clearActiveProfileId(): void; /** * Get or initialize active profile. * Resolution order: per-tab pointer → durable last-active hint → first profile. */ export declare function resolveActiveProfileId(): string | null; export declare function getProfileUser(profileId: string): ProfileUser | null; export declare function setProfileUser(profileId: string, user: ProfileUser | null): void; export declare function getProfileTokens(profileId: string): AuthTokens | null; export declare function setProfileTokens(profileId: string, tokens: AuthTokens | null): void; export declare function getProfileWorkspaceToken(profileId: string): string | null; export declare function setProfileWorkspaceToken(profileId: string, token: string | null): void; export declare function getProfileContext(profileId: string): ProfileContext | null; export declare function setProfileContext(profileId: string, context: ProfileContext): void; export declare function getProfileLocale(profileId: string): string | null; export declare function setProfileLocale(profileId: string, locale: string): void; /** Read user for the active profile in this tab */ export declare function getActiveUser(): ProfileUser | null; /** Read tokens for the active profile in this tab */ export declare function getActiveTokens(): AuthTokens | null; /** Read workspace token for the active profile in this tab */ export declare function getActiveWorkspaceToken(): string | null; /** Read context for the active profile in this tab */ export declare function getActiveContext(): ProfileContext | null; /** * Full login: creates/updates a profile, sets tokens + user, makes it active. */ export declare function loginProfile(user: ProfileUser, tokens: AuthTokens): string; /** * Logout current profile in this tab. Removes profile data. */ export declare function logoutActiveProfile(): void; /** * Logout all profiles. Clears everything. */ export declare function logoutAllProfiles(): void; /** * Switch active profile for this tab. */ export declare function switchProfile(profileId: string): boolean; //# sourceMappingURL=ProfileStorageManager.d.ts.map