35 lines
764 B
TypeScript
35 lines
764 B
TypeScript
export const COOKIE_NAMES = {
|
|
COLOR_SCHEME: 'color-scheme',
|
|
ACCESS_TOKEN: 'access_token',
|
|
REFRESH_TOKEN: 'refresh_token',
|
|
} as const;
|
|
|
|
export type CookieName = (typeof COOKIE_NAMES)[keyof typeof COOKIE_NAMES];
|
|
|
|
export interface CookieOptions {
|
|
path?: string;
|
|
maxAge?: number;
|
|
sameSite?: 'strict' | 'lax' | 'none';
|
|
secure?: boolean;
|
|
}
|
|
|
|
export const COLOR_SCHEME_COOKIE_OPTIONS: CookieOptions = {
|
|
path: '/',
|
|
maxAge: 60 * 60 * 24 * 365,
|
|
sameSite: 'lax',
|
|
};
|
|
|
|
export const AUTH_ACCESS_COOKIE_OPTIONS: CookieOptions = {
|
|
path: '/',
|
|
maxAge: 900, // 15 minutes
|
|
sameSite: 'lax',
|
|
secure: true,
|
|
};
|
|
|
|
export const AUTH_REFRESH_COOKIE_OPTIONS: CookieOptions = {
|
|
path: '/',
|
|
maxAge: 60 * 60 * 24 * 7, // 7 days
|
|
sameSite: 'lax',
|
|
secure: true,
|
|
};
|