{-# LANGUAGE OverloadedStrings, FlexibleContexts #-}
{-# OPTIONS_HADDOCK hide #-}
module Jose.Internal.Base64 where
import Control.Monad.Error
import Data.ByteArray
import Data.ByteArray.Encoding
import Jose.Types
encode :: (ByteArrayAccess input, ByteArray output) => input -> output
encode = convertToBase Base64URLUnpadded
decode :: (ByteArrayAccess input, ByteArray output, MonadError JwtError m) => input -> m output
decode bs = either (throwError . Base64Error) return $ convertFromBase Base64URLUnpadded bs