Fluent Builder
Compose JWTs fluently with jwtNew() — chain claim methods and terminate with .sign() or .encrypt().
Why Use the Builder?
Functional BIF call
Builder equivalent
Anatomy of a Chain
token = jwtNew() // 1. Start the chain
.subject( "user-123" ) // 2. Standard claims
.issuer( "my-api" )
.audience( [ "web", "mobile" ] )
.claim( "roles", [ "admin" ] ) // 3. Custom claim
.expireIn( 3600 ) // 4. Time claims
.issuedNow()
.jti( createUUID() )
.header( "kid", "v2" ) // 5. JOSE headers
.sign( secret, "HS256" ); // 6. Terminate → token stringConditional Composition
Re-using an Existing Payload
Encrypting (JWE) Instead of Signing
Defaults Apply Here Too
Reference Tables
Related
Last updated
Was this helpful?
