gose

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

Core:

JOSE:

COSE:

Types

Error type for JOSE and COSE operations.

Used by low-level JOSE/COSE primitives. The JWT and CWT layers wrap these errors in their own domain-specific variants for token validation.

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

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.

  • VerificationFailed

    Signature or MAC verification failed. Intentionally carries no detail to avoid leaking information that could enable oracle attacks.

Values

pub fn error_message(error: GoseError) -> String

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

Search Document