Jwt

zio.blocks.jwt.Jwt
object Jwt

Pure-Scala JWT implementation (RFC 7519).

==Minimal usage==

JvmJwtCryptoBackend.install()          // once at startup
val token = Jwt.sign(claims, key, Algorithm.HS256).getOrElse(throw new RuntimeException(...))
val claims = Jwt.decode(token, key, Algorithm.HS256).getOrElse(throw new RuntimeException(...))

Attributes

Source
Jwt.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Jwt.type

Members list

Value members

Concrete methods

def decode(token: String, key: Array[Byte], alg: Algorithm, clockSkewSeconds: Long = ..., issuer: Option[String] = ...): Either[JwtError, JwtClaims]

Decodes and verifies a compact JWT string (legacy overload).

Decodes and verifies a compact JWT string (legacy overload).

Value parameters

alg

the expected signing algorithm

clockSkewSeconds

allowable clock skew in seconds for exp/nbf validation

issuer

if set, the iss claim must match exactly

key

the secret or public key bytes

token

the compact three-segment JWT

Attributes

Source
Jwt.scala
def decode(token: String, key: Array[Byte], alg: Algorithm, backend: JwtCryptoBackend): Either[JwtError, JwtClaims]

Decodes with explicit backend (snapshot once per operation).

Decodes with explicit backend (snapshot once per operation).

Attributes

Source
Jwt.scala
def decode(token: String, key: Array[Byte], alg: Algorithm, backend: JwtCryptoBackend, nowSeconds: Long): Either[JwtError, JwtClaims]

Decodes with explicit backend and nowSeconds.

Decodes with explicit backend and nowSeconds.

Attributes

Source
Jwt.scala
def decode(token: String, key: Array[Byte], alg: Algorithm, options: JwtDecodeOptions): Either[JwtError, JwtClaims]

Decodes with full decode options.

Decodes with full decode options.

Attributes

Source
Jwt.scala
def decodeUnsafe(token: String): Either[JwtError, (JwtHeader, JwtClaims)]

Decodes a compact JWT without verifying the signature or validating claims. Useful for inspecting the header/payload of an untrusted token.

Decodes a compact JWT without verifying the signature or validating claims. Useful for inspecting the header/payload of an untrusted token.

This method is kept for compatibility. Prefer decodeWithoutVerification for new code.

Attributes

Source
Jwt.scala
def decodeUnsafe(token: String, limits: JwtLimits): Either[JwtError, (JwtHeader, JwtClaims)]

Compatibility alias for decodeUnsafe with limits.

Compatibility alias for decodeUnsafe with limits.

Attributes

Source
Jwt.scala
def decodeWithoutVerification(token: String, limits: JwtLimits = ...): Either[JwtError, (JwtHeader, JwtClaims)]

Decodes a compact JWT without verifying the signature or validating claims.

Decodes a compact JWT without verifying the signature or validating claims.

Value parameters

limits

resource limits

token

compact JWT string

Attributes

Source
Jwt.scala
def sign(claims: JwtClaims, key: Array[Byte], alg: Algorithm): Either[JwtError, String]

Signs claims with key and alg, returning a compact JWT string.

Signs claims with key and alg, returning a compact JWT string.

Attributes

Source
Jwt.scala
def sign(claims: JwtClaims, key: Array[Byte], alg: Algorithm, header: JwtHeader): Either[JwtError, String]

Signs claims with key and alg using an explicit header. Returns an error if header.alg != alg.

Signs claims with key and alg using an explicit header. Returns an error if header.alg != alg.

Attributes

Source
Jwt.scala
def sign(claims: JwtClaims, key: Array[Byte], alg: Algorithm, header: JwtHeader, backend: JwtCryptoBackend): Either[JwtError, String]

Signs with explicit backend (snapshot once per operation).

Signs with explicit backend (snapshot once per operation).

Attributes

Source
Jwt.scala
def sign(claims: JwtClaims, key: Array[Byte], alg: Algorithm, options: JwtSignOptions): Either[JwtError, String]

Signs with explicit sign options.

Signs with explicit sign options.

Attributes

Source
Jwt.scala
def sign(claims: JwtClaims, key: Array[Byte], alg: Algorithm, header: JwtHeader, options: JwtSignOptions): Either[JwtError, String]

Signs with explicit header and sign options.

Signs with explicit header and sign options.

Attributes

Source
Jwt.scala