mirror of
https://github.com/BradNut/boredgame
synced 2025-09-08 17:40:22 +00:00
35 lines
678 B
TypeScript
35 lines
678 B
TypeScript
|
|
import { config } from '$lib/server/api/common/config';
|
||
|
|
import env from '$lib/server/api/common/env';
|
||
|
|
|
||
|
|
export function createSessionTokenCookie(token: string, expiresAt: Date) {
|
||
|
|
return {
|
||
|
|
name: 'session',
|
||
|
|
value: token,
|
||
|
|
attributes: {
|
||
|
|
path: '/',
|
||
|
|
maxAge: 60 * 60 * 24 * 30,
|
||
|
|
domain: env.DOMAIN,
|
||
|
|
sameSite: 'lax',
|
||
|
|
secure: config.isProduction,
|
||
|
|
httpOnly: true,
|
||
|
|
expires: expiresAt,
|
||
|
|
},
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
export function createBlankSessionTokenCookie() {
|
||
|
|
return {
|
||
|
|
name: 'session',
|
||
|
|
value: '',
|
||
|
|
attributes: {
|
||
|
|
path: '/',
|
||
|
|
maxAge: 0,
|
||
|
|
domain: env.DOMAIN,
|
||
|
|
sameSite: 'lax',
|
||
|
|
secure: config.isProduction,
|
||
|
|
httpOnly: true,
|
||
|
|
expires: new Date(0),
|
||
|
|
},
|
||
|
|
};
|
||
|
|
}
|