import { CookiesOptions } from 'next-auth' ; import { isENVDev } from '../utilities/env' ; /**
 * Copy from 'https://github.com/nextauthjs/next-auth/blob/227ff2259f/src/core/lib/cookie.ts' as we can't import it directly
 *
 * Use secure cookies if the site uses HTTPS
 * This being conditional allows cookies to work non-HTTPS development URLs
 * Honour secure cookie option, which sets 'secure' and also adds '__Secure-'
 * prefix, but enable them by default if the site URL is HTTPS; but not for
 * non-HTTPS URLs like http://localhost which are used in development).
 * For more on prefixes see https://googlechrome.github.io/samples/cookie-prefixes/
 *
 */ export function defaultCookies ( useSecureCookies ) { const cookiePrefix = useSecureCookies ? '__Secure-' : '' ; const sameSite = isENVDev ? 'lax' : 'none' ; return { sessionToken : { name : `${ cookiePrefix }next-auth.session-token` , options : { httpOnly : true , sameSite , path : '/' , secure : useSecureCookies , } , } , callbackUrl : { name : `${ cookiePrefix }next-auth.callback-url` , options : { sameSite , path : '/' , secure : useSecureCookies , } , } , csrfToken : { name : `${ useSecureCookies ? '__Host-' : '' }next-auth.csrf-token` , options : { httpOnly : true , sameSite , path : '/' , secure : useSecureCookies , } , } , pkceCodeVerifier : { name : `${ cookiePrefix }next-auth.pkce.code_verifier` , options : { httpOnly : true , sameSite , path : '/' , secure : useSecureCookies , } , } , state : { name : `${ cookiePrefix }next-auth.state` , options : { httpOnly : true , sameSite , path : '/' , secure : useSecureCookies , } , } , } ; }