import * as cookie from "cookie" ; const noEscape = ( str ) => str ; export const AUTH_KEY = "prismic-auth" ; export function parsePrismicAuthToken ( cookieString ) { const parsed = parse ( cookieString ) ; return parsed [ AUTH_KEY ] ? parsed [ AUTH_KEY ] : "" ; } export function parse ( cookieString ) { return cookie . parse ( cookieString , { decode : noEscape } ) ; } export function serializeCookie ( name , value ) { return cookie . serialize ( name , value , { encode : noEscape } ) ; } export function serializeCookies ( cookies ) { const newCookiesMap = cookies . map ( ( str ) => parse ( str ) ) . reduce ( ( acc , curr ) => { return { ... acc , ... curr } ; } , { } ) ; return Object . entries ( newCookiesMap ) . map ( ( [ key , value ] ) => { return serializeCookie ( key , value ) ; } ) . join ( "; " ) ; }