{-# 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 :: input -> output
encode = Base -> input -> output
forall bin bout.
(ByteArrayAccess bin, ByteArray bout) =>
Base -> bin -> bout
convertToBase Base
Base64URLUnpadded
decode :: (ByteArrayAccess input, ByteArray output, MonadError JwtError m) => input -> m output
decode :: input -> m output
decode input
bs = (String -> m output)
-> (output -> m output) -> Either String output -> m output
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (JwtError -> m output
forall e (m :: * -> *) a. MonadError e m => e -> m a
throwError (JwtError -> m output)
-> (String -> JwtError) -> String -> m output
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> JwtError
Base64Error) output -> m output
forall (m :: * -> *) a. Monad m => a -> m a
return (Either String output -> m output)
-> Either String output -> m output
forall a b. (a -> b) -> a -> b
$ Base -> input -> Either String output
forall bin bout.
(ByteArrayAccess bin, ByteArray bout) =>
Base -> bin -> Either String bout
convertFromBase Base
Base64URLUnpadded input
bs