import * as cookie from "cookie" ; import { SessionToken } from "../../common" ; /**
 * Refresh token cookie name
 */ export const TOKEN_COOKIE_NAME = "__Secure-token" ; /**
 * Refresh token cookie path
 */ export const TOKEN_COOKIE_PATH = `/${ process . env . API_BASE_PATH }/authenticate` ; param header return export function parseTokenCookie ( value ) { if ( ! ( value && value . length ) ) throw new TypeError ( "Invalid request" ) ; const { [ TOKEN_COOKIE_NAME ] : token } = cookie . parse ( value ) ; return token ; } param token return export function issueTokenCookie ( { token , expires } ) { return cookie . serialize ( TOKEN_COOKIE_NAME , token , { expires , domain : process . env . COGNITO_IDENTITY_POOL_PROVIDER ! , path : TOKEN_COOKIE_PATH , secure : true , httpOnly : true , sameSite : true } ) ; } return export function resetTokenCookie ( ) { return cookie . serialize ( TOKEN_COOKIE_NAME , "" , { expires : new Date ( 0 ) , domain : process . env . COGNITO_IDENTITY_POOL_PROVIDER ! , path : TOKEN_COOKIE_PATH , secure : true , httpOnly : true , sameSite : true } ) ; }