export const cookieNames = {
    session: 'nterminal_session',
    device: 'nterminal_device'
};
const deviceCookieMaxAgeSeconds = 30 * 24 * 60 * 60;
export function authCookieOptions(config, maxAgeSeconds) {
    const options = {
        httpOnly: true,
        sameSite: 'lax',
        secure: config.cookieSecure,
        path: '/'
    };
    if (maxAgeSeconds !== undefined) {
        options.maxAge = maxAgeSeconds;
    }
    return options;
}
export function setSessionCookie(reply, config, sessionId) {
    reply.setCookie(cookieNames.session, sessionId, authCookieOptions(config, Math.ceil(config.sessionTtlMs / 1000)));
}
export function setDeviceCookie(reply, config, token) {
    reply.setCookie(cookieNames.device, token, authCookieOptions(config, deviceCookieMaxAgeSeconds));
}
export function clearSessionCookie(reply, config) {
    reply.clearCookie(cookieNames.session, authCookieOptions(config));
}
export function clearAuthCookies(reply, config) {
    reply.clearCookie(cookieNames.session, authCookieOptions(config));
    reply.clearCookie(cookieNames.device, authCookieOptions(config));
}
//# sourceMappingURL=cookies.js.map