HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

  • Packagejose-0.13
  • Exports32
  • LanguageGHC2021
  • LicenceApache-2.0
  • SourceHeader.hs

Constructing header parameters

Header protection support

classclass Eq a => ProtectionSupport a where

Class that defines the protected and (if supported) unprotected values for a protection indicator data type.

Methods

Instances2ProtectionSupport

Use this protection type when the serialisation only supports protected headers.

Instances5Eq, Show, ProtectionSupport, FromCompact, ToCompact

Defining header parsers

The parseParamsFor function defines the parser for a header type.

parseParamsFor
  :: (HasParams a, HasParams b)
  => Proxy b -> Maybe Object -> Maybe Object -> Parser a

It is defined over two objects: the protected header and the unprotected header. The following functions are provided for parsing header parameters:

headerOptional

An optional parameter that may be protected or unprotected.

headerRequired

A required parameter that may be protected or unprotected.

headerOptionalProtected

An optional parameter that, if present, MUST be carried in the protected header.

headerRequiredProtected

A required parameter that, if present, MUST be carried in the protected header.

Duplicate headers are forbidden. The above functions all perform duplicate header detection. If you do not use them, be sure to perform this detection yourself!

An example parser:

instance HasParams ACMEHeader where
  parseParamsFor proxy hp hu = ACMEHeader
    <$> parseParamsFor proxy hp hu
    <*> headerRequiredProtected "nonce" hp hu
classclass HasParams (a :: Type -> Type) where

A thing with parameters.

Methods

Instances2HasParams

Parsing headers

valueparseCrit
  1. :: (Foldable t0, Foldable t1, Traversable t2, Traversable t3, MonadFail m)
  2. => t0 Text

    reserved header parameters

  3. -> t1 Text

    recognised extensions

  4. -> Object

    full header (union of protected and unprotected headers)

  5. -> t2 (t3 Text)

    crit header

  6. -> m (t2 (t3 Text))

Parse a "crit" header param

Fails if:

  • any reserved header appears in "crit" header

  • any value in "crit" is not a recognised extension

  • any value in "crit" does not have a corresponding key in the object

Encoding headers

Header fields shared by JWS and JWE