@duongtrungnguyen/next-helper
Version:
Helper library for Next.js 15
51 lines • 1.19 kB
TypeScript
import type { ReactNode } from "react";
export type AuthContextType = {
state: AuthState;
login: (credentials: LoginCredentials) => Promise<void>;
logout: () => Promise<void>;
refreshTokens: () => Promise<boolean>;
};
export type User = {
id: string;
username: string;
name?: string;
role?: string;
[key: string]: any;
};
export type AuthTokens = {
accessToken: string;
refreshToken: string;
};
export type AuthState = {
user: User | null;
isLoading: boolean;
isAuthenticated: boolean;
error: string | null;
};
export type LoginCredentials = {
username: string;
password: string;
};
export type RefreshTokenResponse = {
accessToken: string;
refreshToken?: string;
expiresAt: number;
};
export type LoginResponse = {
user: User;
accessToken: string;
refreshToken: string;
expiresAt: number;
};
export type AuthResult = {
user: User | null;
};
export type ConditionFn = (user?: User | null) => boolean;
export type ProtectProps = {
children: ReactNode;
fallback?: ReactNode;
role?: string;
condition?: ConditionFn;
redirectTo?: string;
};
//# sourceMappingURL=types.d.ts.map