-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/

-- | A modern Base64 library
--   
--   A performant, featureful RFC 4648 and 7049-compliant Base64
--   implementation
@package base64
@version 1.0

-- | This module contains the Base64 type definition,
--   Alphabet datatype, alphabet constraints, and various quality of
--   life combinators for working with Base64-wrapped data.
module Data.Base64.Types

-- | The different kinds of supported Base64 encodings
data Alphabet

-- | Standard base64 according to RFC 4648 §4 Padding is always
--   inserted when encoding, and required when decoding
StdPadded :: Alphabet

-- | Standard base64 according to RFC 4648 §4 Padding is never
--   inserted when encoding, and optional when decoding per RFC
--   7049.
UrlPadded :: Alphabet

-- | URL-safe base64 according to RFC 4648 §5 aka base64url Padding
--   is never inserted when encoding, and optional when decoding
UrlUnpadded :: Alphabet

-- | Any non-standard, non RFC 4648-compliant base64 encoding. Can only be
--   decoded using lenient decoders.
NonStandard :: Alphabet

-- | Wraps a value, asserting that it is or is intended to be in a
--   particular kind of Base64 encoding use extractBase64 to
--   extract the value, and assertBase64 to tag a value as
--   base64-encoded
data Base64 (k :: Alphabet) a

-- | Assert the provenance of a value encoded in a particular base64
--   alphabet.
--   
--   Warning: This is a blind assertion that a particular value is
--   base64 encoded in some alphabet. If you are not sure of the provenance
--   of the value, you may experience odd behavior when attempting to
--   decode. Use at your own risk. If I see any issues logged on this
--   project from negligent use of this or coerceBase64, I will
--   smite you.
assertBase64 :: forall (k :: Alphabet) a. a -> Base64 k a

-- | Forget the provenance of a base64-encoded value.
extractBase64 :: forall (k :: Alphabet) a. Base64 k a -> a

-- | Coerce the alphabet of a base64-encoded bytestring
--   
--   Warning: This is a blind assertion that a particular value is
--   base64 encoded in some alphabet. If you are not sure of the provenance
--   of the value, you may experience odd behavior when attempting to
--   decode. Use at your own risk. If I see any issues logged on this
--   project from negligent use of this or assertBase64, I will
--   smite you.
coerceBase64 :: forall (j :: Alphabet) (k :: Alphabet) a. Base64 k a -> Base64 j a

-- | The type family of Url-safe alphabets
--   
--   This type family defines the union of compatible Url-safe base64
--   types. To write a function that is parametric over such types, issue a
--   constraint like `forall k. UrlAlphabet k`.
type family UrlAlphabet (k :: Alphabet)

-- | The type family of standard alphabets
--   
--   This type family defines the union of compatible standard alphabet
--   base64 types
type family StdAlphabet (k :: Alphabet)

-- | The type family of non-standard alphabets
--   
--   Only untyped variants of encodeBase64/decodeBase64 can interact with
--   this type family, in addition to assertion/coercion/extraction of
--   these types of values.
type family NonStandardAlphabet (k :: Alphabet)

-- | This module contains ByteString-valued combinators for
--   implementing the RFC 4648 specification of the Base64 encoding format.
--   This includes lenient decoding variants, as well as internal and
--   external validation for canonicity.
module Data.ByteString.Base64

-- | Encode a ByteString value as Base64 Text with padding.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> encodeBase64 "Sun"
--   "U3Vu"
--   
encodeBase64 :: ByteString -> Base64 'StdPadded Text

-- | Encode a ByteString value as a Base64 ByteString value
--   with padding.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> encodeBase64' "Sun"
--   "U3Vu"
--   
encodeBase64' :: ByteString -> Base64 'StdPadded ByteString

-- | Decode a padded Base64-encoded ByteString value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64 $ assertBase64 @'StdPadded "U3Vu"
--   "Sun"
--   
decodeBase64 :: forall (k :: Alphabet). StdAlphabet k => Base64 k ByteString -> ByteString

-- | Decode a padded untyped Base64-encoded ByteString value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Untyped "U3Vu"
--   Right "Sun"
--   
--   
--   
--   >>> decodeBase64Untyped "U3V"
--   Left "Base64-encoded bytestring requires padding"
--   
--   
--   
--   >>> decodeBase64Untyped "U3V="
--   Left "non-canonical encoding detected at offset: 2"
--   
decodeBase64Untyped :: ByteString -> Either Text ByteString

-- | Leniently decode an untyped Base64-encoded ByteString value.
--   This function will not generate parse errors. If input data contains
--   padding chars, then the input will be parsed up until the first pad
--   character.
--   
--   Note: This is not RFC 4648-compliant.
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Lenient "U3Vu"
--   "Sun"
--   
--   
--   
--   >>> decodeBase64Lenient "U3V"
--   "Su"
--   
--   
--   
--   >>> decodeBase64Lenient "U3V="
--   "Su"
--   
decodeBase64Lenient :: ByteString -> ByteString

-- | Tell whether a ByteString value is base64 encoded.
--   
--   This function will also detect non-canonical encodings such as
--   ZE==, which are externally valid Base64-encoded values, but
--   are internally inconsistent "impossible" values.
--   
--   
Examples:
--   
--   
--   >>> isBase64 "U3Vu"
--   True
--   
--   
--   
--   >>> isBase64 "U3V"
--   False
--   
--   
--   
--   >>> isBase64 "U3V="
--   False
--   
isBase64 :: ByteString -> Bool

-- | Tell whether a ByteString value is a valid Base64 format.
--   
--   This will not tell you whether or not this is a correct Base64
--   representation, only that it conforms to the correct shape. To check
--   whether it is a true Base64 encoded ByteString value, use
--   isBase64.
--   
--   
Examples:
--   
--   
--   >>> isValidBase64 "U3Vu"
--   True
--   
--   
--   
--   >>> isValidBase64 "U3V"
--   True
--   
--   
--   
--   >>> isValidBase64 "U3V="
--   True
--   
--   
--   
--   >>> isValidBase64 "%"
--   False
--   
isValidBase64 :: ByteString -> Bool

-- | This module contains ByteString-valued combinators for
--   implementing the RFC 4648 specification of the url-safe Base64
--   (Base64url) encoding format. This includes strictly padded/unpadded
--   and lenient decoding variants, as well as internal and external
--   validation for canonicity.
module Data.ByteString.Base64.URL

-- | Encode a ByteString value as a Base64url Text value with
--   padding.
--   
--   See: RFC-4648 section 5
--   
--   
Examples:
--   
--   
--   >>> encodeBase64 "<<?>>"
--   "PDw_Pj4="
--   
encodeBase64 :: ByteString -> Base64 'UrlPadded Text

-- | Encode a ByteString as a Base64url ByteString value with
--   padding.
--   
--   See: RFC-4648 section 5
--   
--   
Examples:
--   
--   
--   >>> encodeBase64' "<<?>>"
--   "PDw_Pj4="
--   
encodeBase64' :: ByteString -> Base64 'UrlPadded ByteString

-- | Encode a ByteString value as Base64url Text without
--   padding. Note that for Base64url, padding is optional. If you call
--   this function, you will simply be encoding as Base64url and stripping
--   padding chars from the output.
--   
--   See: RFC-4648 section 3.2
--   
--   
Examples:
--   
--   
--   >>> encodeBase64Unpadded "<<?>>"
--   "PDw_Pj4"
--   
encodeBase64Unpadded :: ByteString -> Base64 'UrlUnpadded Text

-- | Encode a ByteString value as Base64url without padding. Note
--   that for Base64url, padding is optional. If you call this function,
--   you will simply be encoding as Base64url and stripping padding chars
--   from the output.
--   
--   See: RFC-4648 section 3.2
--   
--   
Examples:
--   
--   
--   >>> encodeBase64Unpadded' "<<?>>"
--   "PDw_Pj4"
--   
encodeBase64Unpadded' :: ByteString -> Base64 'UrlUnpadded ByteString

-- | Decode a Base64url encoded ByteString value, either padded or
--   unpadded. The correct decoding function is dispatched based on the
--   existence of padding.
--   
--   For typed values: - If a padded value is required, use
--   decodeBase64Padded - If an unpadded value is required, use
--   decodeBase64Unpadded
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlPadded "PDw_Pj4="
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
decodeBase64 :: forall (k :: Alphabet). UrlAlphabet k => Base64 k ByteString -> ByteString

-- | Decode an untyped Base64url encoded ByteString value. If its
--   length is not a multiple of 4, then padding chars will be added to
--   fill out the input to a multiple of 4 for safe decoding as
--   Base64url-encoded values are optionally padded.
--   
--   For a decoder that fails to decode untyped values of incorrect size: -
--   If a padded value is required, use decodeBase64PaddedUntyped -
--   If an unpadded value is required, use
--   decodeBase64UnpaddedUntyped
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Untyped "PDw_Pj4="
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw_Pj4"
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw-Pg="
--   Left "Base64-encoded bytestring has invalid padding"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw-Pg"
--   Right "<<>>"
--   
decodeBase64Untyped :: ByteString -> Either Text ByteString

-- | Decode an unpadded Base64url-encoded ByteString value. Input
--   strings are required to be unpadded, and will undergo validation prior
--   to decoding to confirm.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Unpadded $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
decodeBase64Unpadded :: Base64 'UrlUnpadded ByteString -> ByteString

-- | Decode an unpadded, untyped Base64url-encoded ByteString value.
--   Input strings are required to be unpadded, and will undergo validation
--   prior to decoding to confirm.
--   
--   In general, unless unpadded Base64url is explicitly required, it is
--   safer to call decodeBase64Untyped.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw_Pj4"
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw_Pj4="
--   Left "Base64-encoded bytestring has invalid padding"
--   
decodeBase64UnpaddedUntyped :: ByteString -> Either Text ByteString

-- | Decode a padded Base64url-encoded ByteString value. Input
--   strings are required to be correctly padded, and will be validated
--   prior to decoding to confirm.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Padded $ assertBase64 @'UrlPadded "PDw_Pj4="
--   "<<?>>"
--   
decodeBase64Padded :: Base64 'UrlPadded ByteString -> ByteString

-- | Decode a padded, untyped Base64url-encoded ByteString value.
--   Input strings are required to be correctly padded, and will be
--   validated prior to decoding to confirm.
--   
--   In general, unless padded Base64url is explicitly required, it is
--   safer to call decodeBase64Untyped.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64PaddedUntyped "PDw_Pj4="
--   Right "<<?>>"
--   
decodeBase64PaddedUntyped :: ByteString -> Either Text ByteString

-- | Leniently decode an unpadded, untyped Base64url-encoded
--   ByteString. This function will not generate parse errors. If
--   input data contains padding chars, then the input will be parsed up
--   until the first pad character.
--   
--   Note: This is not RFC 4648-compliant.
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Lenient "PDw_Pj4="
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64Lenient "PDw_%%%$}Pj4"
--   "<<?>>"
--   
decodeBase64Lenient :: ByteString -> ByteString

-- | Tell whether a ByteString is encoded in padded or
--   unpadded Base64url format.
--   
--   This function will also detect non-canonical encodings such as
--   ZE==, which are externally valid Base64url-encoded values,
--   but are internally inconsistent "impossible" values.
--   
--   
Examples:
--   
--   
--   >>> isBase64Url "PDw_Pj4="
--   True
--   
--   
--   
--   >>> isBase64Url "PDw_Pj4"
--   True
--   
--   
--   
--   >>> isBase64Url "PDw_Pj"
--   False
--   
isBase64Url :: ByteString -> Bool

-- | Tell whether a ByteString is a valid Base64url format.
--   
--   This will not tell you whether or not this is a correct Base64url
--   representation, only that it conforms to the correct shape. To check
--   whether it is a true Base64 encoded ByteString value, use
--   isBase64Url.
--   
--   
Examples:
--   
--   
--   >>> isValidBase64Url "PDw_Pj4="
--   True
--   
--   
--   
--   >>> isValidBase64Url "PDw_Pj"
--   True
--   
--   
--   
--   >>> isValidBase64Url "%"
--   False
--   
isValidBase64Url :: ByteString -> Bool

-- | This module contains ByteString-valued combinators for
--   implementing the RFC 4648 specification of the Base64 encoding format.
--   This includes lenient decoding variants, as well as internal and
--   external validation for canonicity.
module Data.ByteString.Lazy.Base64

-- | Encode a ByteString value as Base64 Text with padding.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> encodeBase64 "Sun"
--   "U3Vu"
--   
encodeBase64 :: ByteString -> Base64 'StdPadded Text

-- | Encode a ByteString value as a Base64 ByteString value
--   with padding.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> encodeBase64' "Sun"
--   "U3Vu"
--   
encodeBase64' :: ByteString -> Base64 'StdPadded ByteString

-- | Decode a padded Base64-encoded ByteString value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64 $ assertBase64 @'StdPadded "U3Vu"
--   "Sun"
--   
decodeBase64 :: forall (k :: Alphabet). StdAlphabet k => Base64 k ByteString -> ByteString

-- | Decode a padded untyped Base64-encoded ByteString value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Untyped "U3Vu"
--   Right "Sun"
--   
--   
--   
--   >>> decodeBase64Untyped "U3V"
--   Left "Base64-encoded bytestring requires padding"
--   
--   
--   
--   >>> decodeBase64Untyped "U3V="
--   Left "non-canonical encoding detected at offset: 2"
--   
decodeBase64Untyped :: ByteString -> Either Text ByteString

-- | Leniently decode an unpadded Base64-encoded ByteString value.
--   This function will not generate parse errors. If input data contains
--   padding chars, then the input will be parsed up until the first pad
--   character.
--   
--   Note: This is not RFC 4648-compliant.
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Lenient "U3Vu"
--   "Sun"
--   
--   
--   
--   >>> decodeBase64Lenient "U3V"
--   "Su"
--   
--   
--   
--   >>> decodeBase64Lenient "U3V="
--   "Su"
--   
decodeBase64Lenient :: ByteString -> ByteString

-- | Tell whether a ByteString value is base64 encoded.
--   
--   This function will also detect non-canonical encodings such as
--   ZE==, which are externally valid Base64-encoded values, but
--   are internally inconsistent "impossible" values.
--   
--   
Examples:
--   
--   
--   >>> isBase64 "U3Vu"
--   True
--   
--   
--   
--   >>> isBase64 "U3V"
--   False
--   
--   
--   
--   >>> isBase64 "U3V="
--   False
--   
isBase64 :: ByteString -> Bool

-- | Tell whether a ByteString value is a valid Base64 format.
--   
--   This will not tell you whether or not this is a correct Base64
--   representation, only that it conforms to the correct shape. To check
--   whether it is a true Base64 encoded ByteString value, use
--   isBase64.
--   
--   
Examples:
--   
--   
--   >>> isValidBase64 "U3Vu"
--   True
--   
--   
--   
--   >>> isValidBase64 "U3V"
--   True
--   
--   
--   
--   >>> isValidBase64 "U3V="
--   True
--   
--   
--   
--   >>> isValidBase64 "%"
--   False
--   
isValidBase64 :: ByteString -> Bool

-- | This module contains ByteString-valued combinators for
--   implementing the RFC 4648 specification of the Base64url encoding
--   format. This includes strictly padded/unpadded and lenient decoding
--   variants, as well as internal and external validation for canonicity.
module Data.ByteString.Lazy.Base64.URL

-- | Encode a ByteString value as a Base64url Text value
--   with padding.
--   
--   See: RFC-4648 section 5
--   
--   
Examples:
--   
--   
--   >>> encodeBase64 "<<?>>"
--   "PDw_Pj4="
--   
encodeBase64 :: ByteString -> Base64 'UrlPadded Text

-- | Encode a ByteString as a Base64url ByteString value with
--   padding.
--   
--   See: RFC-4648 section 5
--   
--   
Examples:
--   
--   
--   >>> encodeBase64' "<<?>>"
--   "PDw_Pj4="
--   
encodeBase64' :: ByteString -> Base64 'UrlPadded ByteString

-- | Encode a ByteString value as Base64url Text without
--   padding.
--   
--   See: RFC-4648 section 3.2
--   
--   
Examples:
--   
--   
--   >>> encodeBase64Unpadded "<<?>>"
--   "PDw_Pj4"
--   
encodeBase64Unpadded :: ByteString -> Base64 'UrlUnpadded Text

-- | Encode a ByteString value as Base64url without padding.
--   
--   See: RFC-4648 section 3.2
--   
--   
Examples:
--   
--   
--   >>> encodeBase64Unpadded' "<<?>>"
--   "PDw_Pj4"
--   
encodeBase64Unpadded' :: ByteString -> Base64 'UrlUnpadded ByteString

-- | Decode a Base64url encoded ByteString value, either padded or
--   unpadded. The correct decoding function is dispatched based on the
--   existence of padding.
--   
--   For typed values: - If a padded value is required, use
--   decodeBase64Padded - If an unpadded value is required, use
--   decodeBase64Unpadded
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlPadded "PDw_Pj4="
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlUnpadded "PDw-Pg"
--   "<<>>"
--   
decodeBase64 :: forall (k :: Alphabet). UrlAlphabet k => Base64 k ByteString -> ByteString

-- | Decode a padded Base64url encoded ByteString value. If its
--   length is not a multiple of 4, then padding chars will be added to
--   fill out the input to a multiple of 4 for safe decoding as
--   Base64url-encoded values are optionally padded.
--   
--   For a decoder that fails to decode untyped values of incorrect size: -
--   If a padded value is required, use decodeBase64PaddedUntyped -
--   If an unpadded value is required, use
--   decodeBase64UnpaddedUntyped
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Untyped "PDw_Pj4="
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw_Pj4"
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw-Pg="
--   Left "Base64-encoded bytestring has invalid padding"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw-Pg"
--   Right "<<>>"
--   
decodeBase64Untyped :: ByteString -> Either Text ByteString

-- | Decode an unpadded Base64url-encoded ByteString value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Unpadded $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
decodeBase64Unpadded :: Base64 'UrlUnpadded ByteString -> ByteString

-- | Decode an unpadded, untyped Base64url-encoded ByteString value.
--   Input strings are required to be unpadded, and will undergo validation
--   prior to decoding to confirm.
--   
--   In general, unless unpadded Base64url is explicitly required, it is
--   safer to call decodeBase64Untyped.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw_Pj4"
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw_Pj4="
--   Left "Base64-encoded bytestring has invalid padding"
--   
decodeBase64UnpaddedUntyped :: ByteString -> Either Text ByteString

-- | Decode a padded Base64url-encoded ByteString value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Unpadded $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
decodeBase64Padded :: Base64 'UrlPadded ByteString -> ByteString

-- | Decode a padded, untyped Base64url-encoded ByteString value.
--   Input strings are required to be correctly padded, and will be
--   validated prior to decoding to confirm.
--   
--   In general, unless padded Base64url is explicitly required, it is
--   safer to call decodeBase64.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64PaddedUntyped "PDw_Pj4="
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64PaddedUntyped "PDw_Pj4"
--   Left "Base64-encoded bytestring requires padding"
--   
decodeBase64PaddedUntyped :: ByteString -> Either Text ByteString

-- | Leniently decode an unpadded, untyped Base64url-encoded
--   ByteString. This function will not generate parse errors. If
--   input data contains padding chars, then the input will be parsed up
--   until the first pad character.
--   
--   Note: This is not RFC 4648-compliant.
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Lenient "PDw_Pj4="
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64Lenient "PDw_%%%$}Pj4"
--   "<<?>>"
--   
decodeBase64Lenient :: ByteString -> ByteString

-- | Tell whether an untyped ByteString is Base64url-encoded.
--   
--   
Examples:
--   
--   
--   >>> isBase64Url "PDw_Pj4="
--   True
--   
--   
--   
--   >>> isBase64Url "PDw_Pj4"
--   True
--   
--   
--   
--   >>> isBase64Url "PDw_Pj"
--   False
--   
isBase64Url :: ByteString -> Bool

-- | Tell whether an untyped ByteString is a valid Base64url format.
--   
--   This will not tell you whether or not this is a correct Base64url
--   representation, only that it conforms to the correct shape. To check
--   whether it is a true Base64 encoded ByteString value, use
--   isBase64Url.
--   
--   
Examples:
--   
--   
--   >>> isValidBase64Url "PDw_Pj4="
--   True
--   
--   
--   
--   >>> isValidBase64Url "PDw_Pj"
--   True
--   
--   
--   
--   >>> isValidBase64Url "%"
--   False
--   
isValidBase64Url :: ByteString -> Bool

-- | This module contains ShortByteString-valued combinators for
--   implementing the RFC 4648 specification of the Base64 encoding format.
--   This includes lenient decoding variants, as well as internal and
--   external validation for canonicity.
module Data.ByteString.Short.Base64

-- | Encode a ShortByteString value as Base64 ShortText with
--   padding.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> encodeBase64 "Sun"
--   "U3Vu"
--   
encodeBase64 :: ShortByteString -> Base64 'StdPadded ShortText

-- | Encode a ShortByteString value as a Base64
--   ShortByteString value with padding.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> encodeBase64' "Sun"
--   "U3Vu"
--   
encodeBase64' :: ShortByteString -> Base64 'StdPadded ShortByteString

-- | Decode a padded Base64-encoded ShortByteString value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64 $ assertBase64 @'StdPadded "U3Vu"
--   "Sun"
--   
decodeBase64 :: forall (k :: Alphabet). StdAlphabet k => Base64 k ShortByteString -> ShortByteString

-- | Decode a padded Base64-encoded ShortByteString value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Untyped "U3Vu"
--   Right "Sun"
--   
--   
--   
--   >>> decodeBase64Untyped "U3V"
--   Left "Base64-encoded bytestring requires padding"
--   
--   
--   
--   >>> decodeBase64Untyped "U3V="
--   Left "non-canonical encoding detected at offset: 2"
--   
decodeBase64Untyped :: ShortByteString -> Either Text ShortByteString

-- | Leniently decode an unpadded Base64-encoded ShortByteString
--   value. This function will not generate parse errors. If input data
--   contains padding chars, then the input will be parsed up until the
--   first pad character.
--   
--   Note: This is not RFC 4648-compliant.
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Lenient "U3Vu"
--   "Sun"
--   
--   
--   
--   >>> decodeBase64Lenient "U3V"
--   "Su"
--   
--   
--   
--   >>> decodeBase64Lenient "U3V="
--   "Su"
--   
decodeBase64Lenient :: ShortByteString -> ShortByteString

-- | Tell whether a ShortByteString value is base64 encoded.
--   
--   This function will also detect non-canonical encodings such as
--   ZE==, which are externally valid Base64-encoded values, but
--   are internally inconsistent "impossible" values.
--   
--   
Examples:
--   
--   
--   >>> isBase64 "U3Vu"
--   True
--   
--   
--   
--   >>> isBase64 "U3V"
--   False
--   
--   
--   
--   >>> isBase64 "U3V="
--   False
--   
isBase64 :: ShortByteString -> Bool

-- | Tell whether a ShortByteString value is a valid Base64 format.
--   
--   This will not tell you whether or not this is a correct Base64
--   representation, only that it conforms to the correct shape. To check
--   whether it is a true Base64 encoded ShortByteString value, use
--   isBase64.
--   
--   
Examples:
--   
--   
--   >>> isValidBase64 "U3Vu"
--   True
--   
--   
--   
--   >>> isValidBase64 "U3V"
--   True
--   
--   
--   
--   >>> isValidBase64 "U3V="
--   True
--   
--   
--   
--   >>> isValidBase64 "%"
--   False
--   
isValidBase64 :: ShortByteString -> Bool

-- | This module contains ShortByteString-valued combinators for
--   implementing the RFC 4648 specification of the Base64url encoding
--   format. This includes strictly padded/unpadded and lenient decoding
--   variants, as well as internal and external validation for canonicity.
module Data.ByteString.Short.Base64.URL

-- | Encode a ShortByteString value as a Base64url Text value
--   with padding.
--   
--   See: RFC-4648 section 5
--   
--   
Examples:
--   
--   
--   >>> encodeBase64 "<<?>>"
--   "PDw_Pj4="
--   
encodeBase64 :: ShortByteString -> Base64 'UrlPadded ShortText

-- | Encode a ShortByteString as a Base64url ShortByteString
--   value with padding.
--   
--   See: RFC-4648 section 5
--   
--   
Examples:
--   
--   
--   >>> encodeBase64' "<<?>>"
--   "PDw_Pj4="
--   
encodeBase64' :: ShortByteString -> Base64 'UrlPadded ShortByteString

-- | Encode a ShortByteString value as Base64url Text without
--   padding.
--   
--   See: RFC-4648 section 3.2
--   
--   
Examples:
--   
--   
--   >>> encodeBase64Unpadded "<<?>>"
--   "PDw_Pj4"
--   
encodeBase64Unpadded :: ShortByteString -> Base64 'UrlUnpadded ShortText

-- | Encode a ShortByteString value as Base64url without padding.
--   
--   See: RFC-4648 section 3.2
--   
--   
Examples:
--   
--   
--   >>> encodeBase64Unpadded' "<<?>>"
--   "PDw_Pj4"
--   
encodeBase64Unpadded' :: ShortByteString -> Base64 'UrlUnpadded ShortByteString

-- | Decode a Base64url encoded ShortByteString value, either padded
--   or unpadded. The correct decoding function is dispatched based on the
--   existence of padding.
--   
--   For typed values: - If a padded value is required, use
--   decodeBase64Padded - If an unpadded value is required, use
--   decodeBase64Unpadded
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlPadded "PDw_Pj4="
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
decodeBase64 :: forall (k :: Alphabet). UrlAlphabet k => Base64 k ShortByteString -> ShortByteString

-- | Decode an untyped Base64url encoded ByteString value. If its
--   length is not a multiple of 4, then padding chars will be added to
--   fill out the input to a multiple of 4 for safe decoding as
--   Base64url-encoded values are optionally padded.
--   
--   For a decoder that fails to decode untyped values of incorrect size: -
--   If a padded value is required, use decodeBase64PaddedUntyped -
--   If an unpadded value is required, use
--   decodeBase64UnpaddedUntyped
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Untyped "PDw_Pj4="
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw_Pj4"
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw-Pg="
--   Left "Base64-encoded bytestring has invalid padding"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw-Pg"
--   Right "<<>>"
--   
decodeBase64Untyped :: ShortByteString -> Either Text ShortByteString

-- | Decode an unpadded Base64url-encoded ShortByteString value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Unpadded $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
decodeBase64Unpadded :: Base64 'UrlUnpadded ShortByteString -> ShortByteString

-- | Decode an unpadded, untyped Base64url encoded ByteString
--   value. If its length is not a multiple of 4, then padding chars will
--   be added to fill out the input to a multiple of 4 for safe decoding as
--   Base64url-encoded values are optionally padded.
--   
--   In general, unless unpadded Base64url is explicitly required, it is
--   safer to call decodeBase64.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw_Pj4"
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw-Pg="
--   Left "Base64-encoded bytestring has invalid padding"
--   
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw-Pg"
--   Right "<<>>"
--   
decodeBase64UnpaddedUntyped :: ShortByteString -> Either Text ShortByteString

-- | Decode a padded Base64url-encoded ShortByteString value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Padded $ assertBase64 @'UrlPadded "PDw_Pj4="
--   "<<?>>"
--   
decodeBase64Padded :: Base64 'UrlPadded ShortByteString -> ShortByteString

-- | Decode a padded, untyped Base64url encoded ByteString value.
--   
--   For a decoder that fails on unpadded input of incorrect size, use
--   decodeBase64UnpaddedUntyped.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64PaddedUntyped "PDw_Pj4="
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64PaddedUntyped "PDw_Pj4"
--   Left "Base64-encoded bytestring requires padding"
--   
decodeBase64PaddedUntyped :: ShortByteString -> Either Text ShortByteString

-- | Leniently decode an unpadded, untyped Base64url-encoded
--   ShortByteString. This function will not generate parse errors.
--   If input data contains padding chars, then the input will be parsed up
--   until the first pad character.
--   
--   Note: This is not RFC 4648-compliant.
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Lenient "PDw_Pj4="
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64Lenient "PDw_%%%$}Pj4"
--   "<<?>>"
--   
decodeBase64Lenient :: ShortByteString -> ShortByteString

-- | Tell whether an untyped ShortByteString is Base64url-encoded.
--   
--   
Examples:
--   
--   
--   >>> isBase64Url "PDw_Pj4="
--   True
--   
--   
--   
--   >>> isBase64Url "PDw_Pj4"
--   True
--   
--   
--   
--   >>> isBase64Url "PDw_Pj"
--   False
--   
isBase64Url :: ShortByteString -> Bool

-- | Tell whether an untyped ShortByteString is a valid Base64url
--   format.
--   
--   This will not tell you whether or not this is a correct Base64url
--   representation, only that it conforms to the correct shape. To check
--   whether it is a true Base64 encoded ShortByteString value, use
--   isBase64Url.
--   
--   
Examples:
--   
--   
--   >>> isValidBase64Url "PDw_Pj4="
--   True
--   
--   
--   
--   >>> isValidBase64Url "PDw_Pj"
--   True
--   
--   
--   
--   >>> isValidBase64Url "%"
--   False
--   
isValidBase64Url :: ShortByteString -> Bool

-- | This module contains the error types raised (not as exceptions!) in
--   the decoding process.
module Data.Text.Encoding.Base64.Error

-- | This data type represents the type of decoding errors of various kinds
--   as they pertain to decoding Text values. Namely, to distinguish
--   between decoding errors from opaque unicode exceptions caught in the
--   unicode decoding process.
data Base64Error e

-- | The error associated with decoding failure as a result of the Base64
--   decoding process
DecodeError :: !Text -> Base64Error e

-- | The error associated with the decoding failure as a result of the
--   conversion process
ConversionError :: !e -> Base64Error e
instance GHC.Classes.Eq e => GHC.Classes.Eq (Data.Text.Encoding.Base64.Error.Base64Error e)
instance GHC.Internal.Exception.Type.Exception e => GHC.Internal.Exception.Type.Exception (Data.Text.Encoding.Base64.Error.Base64Error e)
instance GHC.Internal.Generics.Generic (Data.Text.Encoding.Base64.Error.Base64Error e)
instance Control.DeepSeq.NFData e => Control.DeepSeq.NFData (Data.Text.Encoding.Base64.Error.Base64Error e)
instance GHC.Internal.Show.Show e => GHC.Internal.Show.Show (Data.Text.Encoding.Base64.Error.Base64Error e)

-- | This module contains Text-valued combinators for implementing
--   the RFC 4648 specification of the Base64 encoding format. This
--   includes lenient decoding variants, as well as internal and external
--   validation for canonicity.
module Data.Text.Encoding.Base64

-- | Encode a Text value in Base64 with padding.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> encodeBase64 "Sun"
--   "U3Vu"
--   
encodeBase64 :: Text -> Base64 'StdPadded Text

-- | Decode a padded Base64-encoded Text value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64 $ assertBase64 @'StdPadded "U3Vu"
--   "Sun"
--   
decodeBase64 :: forall (k :: Alphabet). StdAlphabet k => Base64 k Text -> Text

-- | Decode a padded, untyped Base64-encoded Text value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Untyped "U3Vu"
--   Right "Sun"
--   
decodeBase64Untyped :: Text -> Either Text Text

-- | Attempt to decode an untyped Text value as Base64, converting
--   from ByteString to Text according to some encoding
--   function. In practice, This is something like decodeUtf8',
--   which may produce an error.
--   
--   See: RFC-4648 section 4
--   
--   
Example:
--   
--   
--   decodeBase64UntypedWith decodeUtf8'
--     :: ByteString -> Either (Base64Error UnicodeException) Text
--   
decodeBase64UntypedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base64Error err) Text

-- | Leniently decode an untyped Base64-encoded Text value. This
--   function will not generate parse errors. If input data contains
--   padding chars, then the input will be parsed up until the first pad
--   character.
--   
--   Note: This is not RFC 4648-compliant.
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Lenient "U3Vu"
--   "Sun"
--   
--   
--   
--   >>> decodeBase64Lenient "U3V"
--   "Su"
--   
--   
--   
--   >>> decodeBase64Lenient "U3V="
--   "Su"
--   
decodeBase64Lenient :: Text -> Text

-- | Tell whether an untyped Text value is Base64-encoded.
--   
--   
Examples:
--   
--   
--   >>> isBase64 "U3Vu"
--   True
--   
--   
--   
--   >>> isBase64 "U3V"
--   False
--   
--   
--   
--   >>> isBase64 "U3V="
--   False
--   
isBase64 :: Text -> Bool

-- | Tell whether an untyped Text value is a valid Base64 format.
--   
--   This will not tell you whether or not this is a correct Base64
--   representation, only that it conforms to the correct shape. To check
--   whether it is a true Base64 encoded Text value, use
--   isBase64.
--   
--   
Examples:
--   
--   
--   >>> isValidBase64 "U3Vu"
--   True
--   
--   
--   
--   >>> isValidBase64 "U3V"
--   True
--   
--   
--   
--   >>> isValidBase64 "U3V="
--   True
--   
--   
--   
--   >>> isValidBase64 "%"
--   False
--   
isValidBase64 :: Text -> Bool

-- | This module contains Text-valued combinators for implementing
--   the RFC 4648 specification of the Base64url encoding format. This
--   includes strictly padded/unpadded and lenient decoding variants, as
--   well as internal and external validation for canonicity.
module Data.Text.Encoding.Base64.URL

-- | Encode a Text value in Base64url with padding.
--   
--   See: RFC-4648 section 5
--   
--   
Examples:
--   
--   
--   >>> encodeBase64 "<<?>>"
--   "PDw_Pj4="
--   
encodeBase64 :: Text -> Base64 'UrlPadded Text

-- | Encode a Text value in Base64url without padding.
--   
--   See: RFC-4648 section 3.2
--   
--   
Examples:
--   
--   
--   >>> encodeBase64Unpadded "<<?>>"
--   "PDw_Pj4"
--   
encodeBase64Unpadded :: Text -> Base64 'UrlUnpadded Text

-- | Decode a Base64url encoded Text value, either padded or
--   unpadded. The correct decoding function is dispatched based on the
--   existence of padding.
--   
--   For typed values: - If a padded value is required, use
--   decodeBase64Padded - If an unpadded value is required, use
--   decodeBase64Unpadded
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlPadded "PDw_Pj4="
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
decodeBase64 :: forall (k :: Alphabet). UrlAlphabet k => Base64 k Text -> Text

-- | Decode an untyped Base64url encoded Text value. If its length
--   is not a multiple of 4, then padding chars will be added to fill out
--   the input to a multiple of 4 for safe decoding as Base64url-encoded
--   values are optionally padded.
--   
--   For a decoder that fails to decode untyped values of incorrect size: -
--   If a padded value is required, use decodeBase64PaddedUntyped -
--   If an unpadded value is required, use
--   decodeBase64UnpaddedUntyped
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Untyped "PDw_Pj4="
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw_Pj4"
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw-Pg="
--   Left "Base64-encoded bytestring has invalid padding"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw-Pg"
--   Right "<<>>"
--   
decodeBase64Untyped :: Text -> Either Text Text

-- | Attempt to decode an untyped ByteString value as Base64url,
--   converting from ByteString to Text according to some
--   encoding function. In practice, This is something like
--   decodeUtf8', which may produce an error.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   decodeBase64UntypedWith decodeUtf8'
--     :: Text -> Either (Base64Error UnicodeException) Text
--   
decodeBase64UntypedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base64Error err) Text

-- | Decode an unpadded Base64url encoded Text value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Unpadded $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
decodeBase64Unpadded :: Base64 'UrlUnpadded Text -> Text

-- | Decode a unpadded, untyped Base64url-encoded Text value. If its
--   length is not a multiple of 4, then padding chars will be added to
--   fill out the input to a multiple of 4 for safe decoding as base64url
--   encodings are optionally padded.
--   
--   For a decoder that fails on unpadded input, use
--   decodeBase64PaddedUntyped
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw_Pj4"
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw-Pg="
--   Left "Base64-encoded bytestring has invalid padding"
--   
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw-Pg"
--   Right "<<>>"
--   
decodeBase64UnpaddedUntyped :: Text -> Either Text Text

-- | Attempt to decode an untyped, unpadded ByteString value as
--   Base64url, converting from ByteString to Text according
--   to some encoding function. In practice, This is something like
--   decodeUtf8', which may produce an error.
--   
--   See: RFC-4648 section 4
--   
--   
Example:
--   
--   
--   decodeBase64UnpaddedUntypedWith decodeUtf8'
--     :: ByteString -> Either (Base64Error UnicodeException) Text
--   
decodeBase64UnpaddedUntypedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base64Error err) Text

-- | Decode a padded Base64url encoded Text value
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Padded $ assertBase64 @'UrlPadded "PDw_Pj4="
--   "<<?>>"
--   
decodeBase64Padded :: Base64 'UrlPadded Text -> Text

-- | Decode an untyped, padded Base64url encoded Text value
--   
--   For a decoder that fails on padded input, use
--   decodeBase64UnpaddedUntyped
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64PaddedUntyped "PDw_Pj4="
--   Right "<<?>>"
--   
decodeBase64PaddedUntyped :: Text -> Either Text Text

-- | Attempt to decode a padded, untyped ByteString value as
--   Base64url, converting from ByteString to Text according
--   to some encoding function. In practice, This is something like
--   decodeUtf8', which may produce an error.
--   
--   See: RFC-4648 section 4
--   
--   
Example:
--   
--   
--   decodeBase64PaddedWith decodeUtf8'
--     :: ByteString -> Either (Base64Error UnicodeException) Text
--   
decodeBase64PaddedUntypedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base64Error err) Text

-- | Leniently decode an untyped Base64url-encoded Text. This
--   function will not generate parse errors. If input data contains
--   padding chars, then the input will be parsed up until the first pad
--   character.
--   
--   Note: This is not RFC 4648-compliant.
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Lenient "PDw_Pj4="
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64Lenient "PDw_%%%$}Pj4"
--   "<<?>>"
--   
decodeBase64Lenient :: Text -> Text

-- | Tell whether an untyped Text value is Base64url-encoded.
--   
--   
Examples:
--   
--   
--   >>> isBase64Url "PDw_Pj4="
--   True
--   
--   
--   
--   >>> isBase64Url "PDw_Pj4"
--   True
--   
--   
--   
--   >>> isBase64Url "PDw_Pj"
--   False
--   
isBase64Url :: Text -> Bool

-- | Tell whether an untyped Text value is a valid Base64url format.
--   
--   This will not tell you whether or not this is a correct Base64url
--   representation, only that it conforms to the correct shape. To check
--   whether it is a true Base64 encoded Text value, use
--   isBase64Url.
--   
--   
Examples:
--   
--   
--   >>> isValidBase64Url "PDw_Pj4="
--   True
--   
--   
--   
--   >>> isValidBase64Url "PDw_Pj"
--   True
--   
--   
--   
--   >>> isValidBase64Url "%"
--   False
--   
isValidBase64Url :: Text -> Bool

-- | This module contains Text-valued combinators implementing the
--   RFC 4648 specification for the Base64 encoding format. This includes
--   lenient decoding variants, and external + internal validations for
--   canonicity.
module Data.Text.Lazy.Encoding.Base64

-- | Encode a Text value in Base64 with padding.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> encodeBase64 "Sun"
--   "U3Vu"
--   
encodeBase64 :: Text -> Base64 'StdPadded Text

-- | Decode a padded Base64-encoded Text value
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64 $ assertBase64 @'StdPadded "U3Vu"
--   "Sun"
--   
decodeBase64 :: forall (k :: Alphabet). StdAlphabet k => Base64 k Text -> Text

-- | Decode a padded, untyped Base64-encoded Text value
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Untyped "U3Vu"
--   Right "Sun"
--   
--   
--   
--   >>> decodeBase64Untyped "U3V"
--   Left "Base64-encoded bytestring requires padding"
--   
--   
--   
--   >>> decodeBase64Untyped "U3V="
--   Left "non-canonical encoding detected at offset: 2"
--   
decodeBase64Untyped :: Text -> Either Text Text

-- | Attempt to decode a ByteString value as Base64, converting from
--   ByteString to Text according to some encoding function.
--   In practice, This is something like decodeUtf8', which may
--   produce an error.
--   
--   See: RFC-4648 section 4
--   
--   
Example:
--   
--   
--   decodeBase64UntypedWith decodeUtf8'
--     :: ByteString -> Either (Base64Error UnicodeException) Text
--   
decodeBase64UntypedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base64Error err) Text

-- | Leniently decode an untyped Base64-encoded Text value. This
--   function will not generate parse errors. If input data contains
--   padding chars, then the input will be parsed up until the first pad
--   character.
--   
--   Note: This is not RFC 4648-compliant.
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Lenient "U3Vu"
--   "Sun"
--   
--   
--   
--   >>> decodeBase64Lenient "U3V"
--   "Su"
--   
--   
--   
--   >>> decodeBase64Lenient "U3V="
--   "Su"
--   
decodeBase64Lenient :: Text -> Text

-- | Tell whether an untyped Text value is Base64-encoded.
--   
--   
Examples:
--   
--   
--   >>> isBase64 "U3Vu"
--   True
--   
--   
--   
--   >>> isBase64 "U3V"
--   False
--   
--   
--   
--   >>> isBase64 "U3V="
--   False
--   
isBase64 :: Text -> Bool

-- | Tell whether an untyped Text value is a valid Base64 format.
--   
--   This will not tell you whether or not this is a correct Base64
--   representation, only that it conforms to the correct shape. To check
--   whether it is a true Base64 encoded Text value, use
--   isBase64.
--   
--   
Examples:
--   
--   
--   >>> isValidBase64 "U3Vu"
--   True
--   
--   
--   
--   >>> isValidBase64 "U3V"
--   True
--   
--   
--   
--   >>> isValidBase64 "U3V="
--   True
--   
--   
--   
--   >>> isValidBase64 "%"
--   False
--   
isValidBase64 :: Text -> Bool

-- | This module contains Text-valued combinators for implementing
--   the RFC 4648 specification of the Base64url encoding format. This
--   includes strictly padded/unpadded and lenient decoding variants, as
--   well as internal and external validation for canonicity.
module Data.Text.Lazy.Encoding.Base64.URL

-- | Encode a Text value in Base64url with padding.
--   
--   See: RFC-4648 section 5
--   
--   
Examples:
--   
--   
--   >>> encodeBase64 "<<?>>"
--   "PDw_Pj4="
--   
encodeBase64 :: Text -> Base64 'UrlPadded Text

-- | Encode a Text value in Base64url without padding. Note that for
--   Base64url, padding is optional. If you call this function, you will
--   simply be encoding as Base64url and stripping padding chars from the
--   output.
--   
--   See: RFC-4648 section 3.2
--   
--   
Examples:
--   
--   
--   >>> encodeBase64Unpadded "<<?>>"
--   "PDw_Pj4"
--   
encodeBase64Unpadded :: Text -> Base64 'UrlUnpadded Text

-- | Decode an arbitrarily Base64url-encoded Text value.
--   
--   For typed values: - If a padded value is required, use
--   decodeBase64Padded - If an unpadded value is required, use
--   decodeBase64Unpadded
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlPadded "PDw_Pj4="
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
decodeBase64 :: forall (k :: Alphabet). UrlAlphabet k => Base64 k Text -> Text

-- | Decode an untyped Base64url-encoded Text value. If its length
--   is not a multiple of 4, then padding chars will be added to fill out
--   the input to a multiple of 4 for safe decoding as base64url encodings
--   are optionally padded.
--   
--   For a decoder that fails on unpadded input, use
--   decodeBase64Unpadded.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Untyped "PDw_Pj4="
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw_Pj4"
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw-Pg="
--   Left "Base64-encoded bytestring has invalid padding"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw-Pg"
--   Right "<<>>"
--   
decodeBase64Untyped :: Text -> Either Text Text

-- | Attempt to decode an untyped lazy ByteString value as
--   Base64url, converting from ByteString to Text according
--   to some encoding function. In practice, This is something like
--   decodeUtf8', which may produce an error.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   decodeBase64With decodeUtf8'
--     :: ByteString -> Either (Base64Error UnicodeException) Text
--   
decodeBase64UntypedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base64Error err) Text

-- | Decode an unpadded Base64url encoded Text value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Unpadded $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
decodeBase64Unpadded :: Base64 'UrlUnpadded Text -> Text

-- | Decode an unpadded, untyped Base64url encoded Text value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw_Pj4"
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw_Pj4="
--   Left "Base64-encoded bytestring has invalid padding"
--   
decodeBase64UnpaddedUntyped :: Text -> Either Text Text

-- | Attempt to decode an unpadded, untyped lazy ByteString value as
--   Base64url, converting from ByteString to Text according
--   to some encoding function. In practice, This is something like
--   decodeUtf8', which may produce an error.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   decodeBase64UnpaddedUntypedWith decodeUtf8'
--     :: ByteString -> Either (Base64Error UnicodeException) Text
--   
decodeBase64UnpaddedUntypedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base64Error err) Text

-- | Decode a padded Base64url encoded Text value
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Padded $ assertBase64 @'UrlPadded "PDw_Pj4="
--   "<<?>>"
--   
decodeBase64Padded :: Base64 'UrlPadded Text -> Text

-- | Decode an untyped, padded Base64url encoded Text value
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64PaddedUntyped "PDw_Pj4="
--   Right "<<?>>"
--   
decodeBase64PaddedUntyped :: Text -> Either Text Text

-- | Attempt to decode a padded, untyped lazy ByteString value as
--   Base64url, converting from ByteString to Text according
--   to some encoding function. In practice, This is something like
--   decodeUtf8', which may produce an error.
--   
--   See: RFC-4648 section 4
--   
--   
Example:
--   
--   
--   decodeBase64PaddedWith decodeUtf8'
--     :: ByteString -> Either (Base64Error UnicodeException) Text
--   
decodeBase64PaddedUntypedWith :: (ByteString -> Either err Text) -> ByteString -> Either (Base64Error err) Text

-- | Leniently decode an untyped Base64url-encoded Text. This
--   function will not generate parse errors. If input data contains
--   padding chars, then the input will be parsed up until the first pad
--   character.
--   
--   Note: This is not RFC 4648-compliant.
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Lenient "PDw_Pj4="
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64Lenient "PDw_%%%$}Pj4"
--   "<<?>>"
--   
decodeBase64Lenient :: Text -> Text

-- | Tell whether an untyped Text value is Base64url-encoded
--   
--   
Examples:
--   
--   
--   >>> isBase64Url "PDw_Pj4="
--   True
--   
--   
--   
--   >>> isBase64Url "PDw_Pj4"
--   True
--   
--   
--   
--   >>> isBase64Url "PDw_Pj"
--   False
--   
isBase64Url :: Text -> Bool

-- | Tell whether an untyped Text value is a valid Base64url format.
--   
--   This will not tell you whether or not this is a correct Base64url
--   representation, only that it conforms to the correct shape. To check
--   whether it is a true Base64 encoded Text value, use
--   isBase64Url.
--   
--   
Examples:
--   
--   
--   >>> isValidBase64Url "PDw_Pj4="
--   True
--   
--   
--   
--   >>> isValidBase64Url "PDw_Pj"
--   True
--   
--   
--   
--   >>> isValidBase64Url "%"
--   False
--   
isValidBase64Url :: Text -> Bool

-- | This module contains ShortText-valued combinators implementing
--   the RFC 4648 specification for the Base64 encoding format. This
--   includes lenient decoding variants, and external + internal
--   validations for canonicity.
module Data.Text.Short.Encoding.Base64

-- | Encode a ShortText value in Base64 with padding.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> encodeBase64 "Sun"
--   "U3Vu"
--   
encodeBase64 :: ShortText -> Base64 'StdPadded ShortText

-- | Decode a padded Base64-encoded ShortText value
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64 $ assertBase64 @'StdPadded "U3Vu"
--   "Sun"
--   
decodeBase64 :: forall (k :: Alphabet). StdAlphabet k => Base64 k ShortText -> ShortText

-- | Decode a padded Base64-encoded ShortText value
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Untyped "U3Vu"
--   Right "Sun"
--   
--   
--   
--   >>> decodeBase64Untyped "U3V"
--   Left "Base64-encoded bytestring requires padding"
--   
--   
--   
--   >>> decodeBase64Untyped "U3V="
--   Left "non-canonical encoding detected at offset: 2"
--   
decodeBase64Untyped :: ShortText -> Either Text ShortText

-- | Attempt to decode an untyped ShortByteString value as Base64,
--   converting from ByteString to ShortText according to
--   some encoding function. In practice, This is something like
--   decodeUtf8', which may produce an error.
--   
--   See: RFC-4648 section 4
--   
--   
Example:
--   
--   
--   decodeBase64UntypedWith decodeUtf8'
--     :: ShortByteString -> Either (Base64Error UnicodeException) ShortText
--   
decodeBase64UntypedWith :: (ShortByteString -> Either err ShortText) -> ShortByteString -> Either (Base64Error err) ShortText

-- | Leniently decode an untyped Base64-encoded ShortText value.
--   This function will not generate parse errors. If input data contains
--   padding chars, then the input will be parsed up until the first pad
--   character.
--   
--   Note: This is not RFC 4648-compliant.
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Lenient "U3Vu"
--   "Sun"
--   
--   
--   
--   >>> decodeBase64Lenient "U3V"
--   "Su"
--   
--   
--   
--   >>> decodeBase64Lenient "U3V="
--   "Su"
--   
decodeBase64Lenient :: ShortText -> ShortText

-- | Tell whether an untyped ShortText value is Base64-encoded.
--   
--   
Examples:
--   
--   
--   >>> isBase64 "U3Vu"
--   True
--   
--   
--   
--   >>> isBase64 "U3V"
--   False
--   
--   
--   
--   >>> isBase64 "U3V="
--   False
--   
isBase64 :: ShortText -> Bool

-- | Tell whether an untyped ShortText value is a valid Base64
--   format.
--   
--   This will not tell you whether or not this is a correct Base64
--   representation, only that it conforms to the correct shape. To check
--   whether it is a true Base64 encoded ShortText value, use
--   isBase64.
--   
--   
Examples:
--   
--   
--   >>> isValidBase64 "U3Vu"
--   True
--   
--   
--   
--   >>> isValidBase64 "U3V"
--   True
--   
--   
--   
--   >>> isValidBase64 "U3V="
--   True
--   
--   
--   
--   >>> isValidBase64 "%"
--   False
--   
isValidBase64 :: ShortText -> Bool

-- | This module contains ShortText-valued combinators implementing
--   the RFC 4648 specification for the Base64url encoding format. This
--   includes strictly padded/unpadded and lenient decoding variants, and
--   external + internal validations for canonicity.
module Data.Text.Short.Encoding.Base64.URL

-- | Encode a ShortText value in Base64url with padding.
--   
--   See: RFC-4648 section 5
--   
--   
Examples:
--   
--   
--   >>> encodeBase64 "<<?>>"
--   "PDw_Pj4="
--   
encodeBase64 :: ShortText -> Base64 'UrlPadded ShortText

-- | Encode a ShortText value in Base64url without padding.
--   
--   See: RFC-4648 section 3.2
--   
--   
Examples:
--   
--   
--   >>> encodeBase64Unpadded "<<?>>"
--   "PDw_Pj4"
--   
encodeBase64Unpadded :: ShortText -> Base64 'UrlUnpadded ShortText

-- | Decode an arbitrarily padded Base64url-encoded ShortText value.
--   
--   For typed values: - If a padded value is required, use
--   decodeBase64Padded - If an unpadded value is required, use
--   decodeBase64Unpadded
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlPadded "PDw_Pj4="
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64 $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
decodeBase64 :: forall (k :: Alphabet). UrlAlphabet k => Base64 k ShortText -> ShortText

-- | Decode an untyped padded Base64url-encoded ShortText value. If
--   its length is not a multiple of 4, then padding chars will be added to
--   fill out the input to a multiple of 4 for safe decoding as base64url
--   encodings are optionally padded.
--   
--   For a decoder that fails on unpadded input, use
--   decodeBase64Unpadded.
--   
--   Note: This function makes sure that decoding is total by
--   deferring to decodeUtf8. This will always round trip for any
--   valid Base64-encoded text value, but it may not round trip for bad
--   inputs. The onus is on the caller to make sure inputs are valid. If
--   unsure, defer to decodeBase64With and pass in a custom decode
--   function.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Untyped "PDw_Pj4="
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw_Pj4"
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw-Pg="
--   Left "Base64-encoded bytestring has invalid padding"
--   
--   
--   
--   >>> decodeBase64Untyped "PDw-Pg"
--   Right "<<>>"
--   
decodeBase64Untyped :: ShortText -> Either Text ShortText

-- | Attempt to decode an untyped ShortByteString value as
--   Base64url, converting from ByteString to ShortText
--   according to some encoding function. In practice, This is something
--   like decodeUtf8', which may produce an error.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   decodeBase64With decodeUtf8'
--     :: ShortByteString -> Either (Base64Error UnicodeException) ShortText
--   
decodeBase64UntypedWith :: (ShortByteString -> Either err ShortText) -> ShortByteString -> Either (Base64Error err) ShortText

-- | Decode an unpadded Base64url encoded ShortText value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Unpadded $ assertBase64 @'UrlUnpadded "PDw_Pj4"
--   "<<?>>"
--   
decodeBase64Unpadded :: Base64 'UrlUnpadded ShortText -> ShortText

-- | Decode an untyped, unpadded Base64url encoded ShortText value.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw_Pj4"
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64UnpaddedUntyped "PDw_Pj4="
--   Left "Base64-encoded bytestring has invalid padding"
--   
decodeBase64UnpaddedUntyped :: ShortText -> Either Text ShortText

-- | Attempt to decode an untyped, unpadded ShortByteString value as
--   Base64url, converting from ShortByteString to ShortText
--   according to some encoding function. In practice, This is something
--   like decodeUtf8', which may produce an error.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   decodeBase64UnpaddedWith decodeUtf8'
--     :: ShortByteString -> Either (Base64Error UnicodeException) ShortText
--   
decodeBase64UnpaddedUntypedWith :: (ShortByteString -> Either err ShortText) -> ShortByteString -> Either (Base64Error err) ShortText

-- | Decode a padded Base64url encoded ShortText value
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Padded $ assertBase64 @'UrlPadded "PDw_Pj4="
--   "<<?>>"
--   
decodeBase64Padded :: Base64 'UrlPadded ShortText -> ShortText

-- | Decode an untyped, padded Base64url encoded ShortText value
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   >>> decodeBase64PaddedUntyped "PDw_Pj4="
--   Right "<<?>>"
--   
--   
--   
--   >>> decodeBase64PaddedUntyped "PDw_Pj4"
--   Left "Base64-encoded bytestring requires padding"
--   
decodeBase64PaddedUntyped :: ShortText -> Either Text ShortText

-- | Attempt to decode an untyped, padded ShortByteString value as
--   Base64url, converting from ByteString to ShortText
--   according to some encoding function. In practice, This is something
--   like decodeUtf8', which may produce an error.
--   
--   See: RFC-4648 section 4
--   
--   
Examples:
--   
--   
--   decodeBase64With decodeUtf8'
--     :: ShortByteString -> Either (Base64Error UnicodeException) ShortText
--   
decodeBase64PaddedUntypedWith :: (ShortByteString -> Either err ShortText) -> ShortByteString -> Either (Base64Error err) ShortText

-- | Leniently decode an untyped, unpadded Base64url-encoded
--   ShortText. This function will not generate parse errors. If
--   input data contains padding chars, then the input will be parsed up
--   until the first pad character.
--   
--   Note: This is not RFC 4648-compliant.
--   
--   
Examples:
--   
--   
--   >>> decodeBase64Lenient "PDw_Pj4="
--   "<<?>>"
--   
--   
--   
--   >>> decodeBase64Lenient "PDw_%%%$}Pj4"
--   "<<?>>"
--   
decodeBase64Lenient :: ShortText -> ShortText

-- | Tell whether an untyped ShortText value is Base64url-encoded.
--   
--   
Examples:
--   
--   
--   >>> isBase64Url "PDw_Pj4="
--   True
--   
--   
--   
--   >>> isBase64Url "PDw_Pj4"
--   True
--   
--   
--   
--   >>> isBase64Url "PDw_Pj"
--   False
--   
isBase64Url :: ShortText -> Bool

-- | Tell whether an untyped ShortText value is a valid Base64url
--   format.
--   
--   This will not tell you whether or not this is a correct Base64url
--   representation, only that it conforms to the correct shape. To check
--   whether it is a true Base64 encoded ShortText value, use
--   isBase64Url.
--   
--   
Examples:
--   
--   
--   >>> isValidBase64Url "PDw_Pj4="
--   True
--   
--   
--   
--   >>> isValidBase64Url "PDw_Pj"
--   True
--   
--   
--   
--   >>> isValidBase64Url "%"
--   False
--   
isValidBase64Url :: ShortText -> Bool
