import Cookies from 'js-cookie'

const TokenKey = 'Admin-Token'

const isSecure = window.location.protocol === 'https:'

export function getToken(): string | undefined {
  return Cookies.get(TokenKey)
}

export function setToken(token: string): void {
  Cookies.set(TokenKey, token, {
    secure: isSecure,
    sameSite: 'Strict',
    expires: 1,
  })
}

export function removeToken(): void {
  Cookies.remove(TokenKey)
}
