sd-jwt-0.1.0.0: Selective Disclosure for JSON Web Tokens (RFC 9901)
Safe HaskellNone
LanguageHaskell2010

SDJWT.Internal.Serialization

Description

Serialization and deserialization of SD-JWT structures.

This module provides functions to serialize and deserialize SD-JWTs to/from the tilde-separated format specified in RFC 9901.

Synopsis

Documentation

serializeSDJWT :: SDJWT -> Text Source #

Serialize SD-JWT to tilde-separated format.

Format: JWT~1~2~...~N~

The last tilde is always present, even if there are no disclosures.

deserializeSDJWT :: Text -> Either SDJWTError SDJWT Source #

Deserialize SD-JWT from tilde-separated format.

Parses a tilde-separated string into an SDJWT structure. Returns an error if the format is invalid or if a Key Binding JWT is present (use deserializePresentation for SD-JWT+KB).

serializePresentation :: SDJWTPresentation -> Text Source #

Serialize SD-JWT presentation.

Format: JWT~1~...~N~[KB-JWT]

If a Key Binding JWT is present, it is included as the last component. Otherwise, the last component is empty (just a trailing tilde).

deserializePresentation :: Text -> Either SDJWTError SDJWTPresentation Source #

Deserialize SD-JWT presentation.

Parses a tilde-separated string into an SDJWTPresentation structure. This handles both SD-JWT (without KB-JWT) and SD-JWT+KB (with KB-JWT) formats.

parseTildeSeparated :: Text -> Either SDJWTError (Text, [EncodedDisclosure], Maybe Text) Source #

Parse tilde-separated format.

Low-level function that parses the tilde-separated format and returns the components: (JWT, [Disclosures], Maybe KB-JWT).

The last component is Nothing for SD-JWT format (empty string after last tilde) or Just KB-JWT for SD-JWT+KB format.