object

# `jwt_compact`

JWT compact serialization parsing and generation helpers.

Availability:
`logtalk_load(jwt(loader))`
Author: Paulo Moura
Version: 1:0:0
Date: 2026-07-06
Compilation flags:
`static, context_switching_calls`
Imports:
`public` jwt_helpers
Uses:
atom
json
user
Remarks:
(none)
Inherited public predicates:
check_option/1 check_options/1 default_option/1 default_options/1 option/2 option/3 valid_option/1 valid_options/1

## Public predicates

### `decode/3`

Decodes a compact JWT into header and claims JSON terms without verifying the signature.

Compilation flags:
`static`
Template:
`decode(Token,Header,Claims)`
Mode and number of proofs:
`decode(+atom,-term,-term)` - `one_or_error`
Exceptions:
`Token` is a variable:
`instantiation_error`
`Token` is neither a variable nor an atom:
`type_error(atom,Token)`
`Token` is an atom but not a valid compact JWT:
`domain_error(jwt_compact_serialization,Token)`
`Token` contains Base64URL data with characters outside the Base64URL alphabet:
`representation_error(base64)`

### `decode/5`

Decodes a compact JWT into header, claims, signature bytes, and signing input.

Compilation flags:
`static`
Template:
`decode(Token,Header,Claims,Signature,SigningInput)`
Mode and number of proofs:
`decode(+atom,-term,-term,-list(byte),-atom)` - `one_or_error`
Exceptions:
`Token` is a variable:
`instantiation_error`
`Token` is neither a variable nor an atom:
`type_error(atom,Token)`
`Token` is an atom but not a valid compact JWT:
`domain_error(jwt_compact_serialization,Token)`
`Token` contains Base64URL data with characters outside the Base64URL alphabet:
`representation_error(base64)`

### `header/2`

Decodes only the JWT header JSON term.

Compilation flags:
`static`
Template:
`header(Token,Header)`
Mode and number of proofs:
`header(+atom,-term)` - `one_or_error`
Exceptions:
`Token` is a variable:
`instantiation_error`
`Token` is neither a variable nor an atom:
`type_error(atom,Token)`
`Token` is an atom but not a valid compact JWT:
`domain_error(jwt_compact_serialization,Token)`
`Token` contains Base64URL data with characters outside the Base64URL alphabet:
`representation_error(base64)`

### `claims/2`

Decodes only the JWT claims JSON term.

Compilation flags:
`static`
Template:
`claims(Token,Claims)`
Mode and number of proofs:
`claims(+atom,-term)` - `one_or_error`
Exceptions:
`Token` is a variable:
`instantiation_error`
`Token` is neither a variable nor an atom:
`type_error(atom,Token)`
`Token` is an atom but not a valid compact JWT:
`domain_error(jwt_compact_serialization,Token)`
`Token` contains Base64URL data with characters outside the Base64URL alphabet:
`representation_error(base64)`

### `segments/5`

Splits a compact JWT into Base64URL segments and signing input.

Compilation flags:
`static`
Template:
`segments(Token,HeaderSegment,PayloadSegment,SignatureSegment,SigningInput)`
Mode and number of proofs:
`segments(+atom,-atom,-atom,-atom,-atom)` - `one_or_error`
Exceptions:
`Token` is a variable:
`instantiation_error`
`Token` is neither a variable nor an atom:
`type_error(atom,Token)`
`Token` is an atom but not a valid compact JWT:
`domain_error(jwt_compact_serialization,Token)`

### `signing_input/4`

Encodes header and payload JSON terms and returns the compact signing input.

Compilation flags:
`static`
Template:
`signing_input(Header,Payload,HeaderSegment,SigningInput)`
Mode and number of proofs:
`signing_input(+term,+term,-atom,-atom)` - `one_or_error`
Exceptions:
`Header` or `Payload` cannot be encoded as JSON:
`domain_error(json_sink,HeaderOrPayload)`
`Header` or `Payload` cannot be encoded as Base64URL bytes:
`domain_error(base64url_sink,codes(Codes))`

### `compact/4`

Builds a compact JWT from a signing input and signature bytes.

Compilation flags:
`static`
Template:
`compact(HeaderSegment,SigningInput,Signature,Token)`
Mode and number of proofs:
`compact(+atom,+atom,+list(byte),-atom)` - `one_or_error`
Exceptions:
`Signature` cannot be encoded as Base64URL bytes:
`domain_error(base64url_sink,codes(Codes))`

## Protected predicates

(no local declarations; see entity ancestors if any)

## Private predicates

(no local declarations; see entity ancestors if any)

## Operators

(none)