gose

A Gleam JOSE (JSON Object Signing and Encryption) library.

This module defines GoseError, the shared error type for JWS, JWE, and JWK. The JWT layer has its own JwtError with richer domain-specific variants.

Types

Error type for JOSE primitive operations (JWS, JWE, JWK).

This is the error type used by low-level JOSE modules. The JWT layer wraps this via JwtError.JoseError to provide richer domain-specific error variants for token validation.

pub type GoseError {
  ParseError(String)
  CryptoError(String)
  InvalidState(String)
}

Constructors

  • ParseError(String)

    Parsing failed - invalid base64, malformed JSON, unexpected structure, etc. The String provides a human-readable description of what went wrong.

  • CryptoError(String)

    A cryptographic operation failed - signature verification, decryption, key derivation, etc. The String describes the failure.

  • InvalidState(String)

    An operation was attempted in an invalid state - wrong key type for the chosen algorithm, missing required header field, etc. The String explains which invariant was violated.

Values

pub fn error_message(error: GoseError) -> String

Extract the message string from a GoseError, regardless of variant.

Parameters

  • error - The error to extract the message from.

Returns

The human-readable description string contained in the error variant.

Search Document