add auth moodule

This commit is contained in:
2026-04-18 13:43:13 +01:00
parent f163f22987
commit ba17904895
10 changed files with 131 additions and 106 deletions
+45
View File
@@ -0,0 +1,45 @@
/**
* RAW KEYCLOAK TOKEN
* Data Layer: Represents the uncleaned decoded JWT payload from Keycloak.
*/
export interface RawKeycloakToken {
sub: string; // Unique User ID
name?: string;
email?: string;
preferred_username: string;
given_name?: string;
family_name?: string;
email_verified: boolean;
picture?: string; // Avatar URL from Keycloak
realm_access?: {
roles: string[]; // Global roles (e.g., 'admin', 'editor')
};
resource_access?: {
[key: string]: {
roles: string[]; // Client-specific roles
};
};
exp: number; // Expiration Timestamp
iat: number; // Issued At Timestamp
}
/**
* USER PROFILE
* UI Layer: Represents the "Cleaned" object used by the frontend.
* Logic: Extracted from RawKeycloakToken via session-mapper.ts.
*/
export interface UserProfile {
id: string;
name: string;
email?: string;
username: string;
avatar: string | null;
roles: string[];
isPremium: boolean; // Derived state for the News Portal
}
/**
* AUTH STATUS
* Logic: Standardizes the possible states of the session.
*/
export type AuthStatus = 'loading' | 'authenticated' | 'unauthenticated';