add auth
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import type { AuthIntent, AuthSession, AuthStep } from '../auth/auth.models';
|
||||
|
||||
export type ClaimStage = 'idle' | 'check' | 'success';
|
||||
|
||||
export interface ClaimState {
|
||||
@@ -17,10 +19,53 @@ export interface ProfileState {
|
||||
joinedLabel: string;
|
||||
}
|
||||
|
||||
export interface AuthState {
|
||||
email: string;
|
||||
accessToken: string | null;
|
||||
tokenType: string;
|
||||
refreshToken?: string;
|
||||
expiresAt?: number;
|
||||
authenticated: boolean;
|
||||
step: AuthStep;
|
||||
resendSeconds: number;
|
||||
pending: boolean;
|
||||
error: string;
|
||||
sheetVisible: boolean;
|
||||
intent: AuthIntent;
|
||||
pendingLandmarkId: string | null;
|
||||
codeRequestId: number;
|
||||
}
|
||||
|
||||
export interface GorodarState {
|
||||
collectedIds: string[];
|
||||
photos: Record<string, string>;
|
||||
collectedAt: Record<string, string>;
|
||||
claim: ClaimState;
|
||||
profile: ProfileState;
|
||||
auth: AuthState;
|
||||
}
|
||||
|
||||
export const RESEND_SECONDS = 60;
|
||||
|
||||
export function sessionToAuth(session: AuthSession | null): Pick<
|
||||
AuthState,
|
||||
'email' | 'accessToken' | 'tokenType' | 'refreshToken' | 'expiresAt' | 'authenticated'
|
||||
> {
|
||||
if (!session) {
|
||||
return {
|
||||
email: '',
|
||||
accessToken: null,
|
||||
tokenType: 'Bearer',
|
||||
authenticated: false,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
email: session.email,
|
||||
accessToken: session.accessToken,
|
||||
tokenType: session.tokenType,
|
||||
refreshToken: session.refreshToken,
|
||||
expiresAt: session.expiresAt,
|
||||
authenticated: true,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user