import crumb from "@hapi/crumb" ; import { ServerRegisterPluginObject } from "@hapi/hapi" ; import { RouteConfig } from "../types" ; type Config = { isDev : string | undefined ; previewMode : boolean ; } ; export const configureCrumbPlugin = ( config , routeConfig ? ) : ServerRegisterPluginObject < crumb . RegisterOptions > => { return { plugin : crumb , options : { logUnauthorized : true , enforce : routeConfig ? routeConfig . enforceCsrf || false : ! config . previewMode , cookieOptions : { path : "/" , isSecure : ! ! config . isDev , isHttpOnly : true , isSameSite : "Strict" , } , skip : ( request ) => { return request . method === "post" && request . payload == null ; } , } , } ; } ;