abla/jwt
Generated from source.
Import with import "abla/jwt".
Source: abla/jwt/entry.ab
JwtKey (class)
class JwtKey(
val kid: string,
val kty: string,
val alg: string,
val usable: bool,
val modulus: string,
val exponent: string,
val point: string
)
Stores a parsed JWK's identifier, algorithm, public key material and usability.
JwtKeySet (class)
class JwtKeySet(val keys: array<JwtKey>, val error: string)
The public keys of a JWKS document.
JwtOptions (class)
class JwtOptions(
val issuer: string = "",
val audience: string = "",
val clockToleranceSeconds: int = 0,
val requireSubject: bool = true,
// Seconds since the Unix epoch; a negative value reads the system clock.
val nowSeconds: int = -1,
// A token without an `exp` claim is refused ("expiration not found in token"): it would never expire. False accepts
// one, for issuers that bound tokens another way (decision #116 A).
val requireExpiration: bool = true
)
Sets the expected issuer and audience, clock tolerance, clock override and subject requirement.
JwtVerification (class)
class JwtVerification(
val valid: bool,
val error: string,
val subject: string,
val kid: string,
val header: Json,
val claims: Json
)
Carries verification status, failure detail and any decoded header and claims.
JwtBase64 (class)
class JwtBase64(val bytes: string, val valid: bool)
Carries decoded Base64URL bytes and whether the input was valid.
jwtBase64UrlDecode (fun)
fun jwtBase64UrlDecode(text: string): JwtBase64
Unpadded base64url (RFC 7515 section 2), strictly: no '=' padding and no non-zero bits after the last character, so each byte string has exactly one encoding (a token or signature cannot be re-encoded and still verify).
jwtBase64UrlEncode (fun)
fun jwtBase64UrlEncode(bytes: string): string
Encodes bytes as unpadded URL-safe Base64.
jwtKeySet (fun)
fun jwtKeySet(jwks: string): JwtKeySet
Parses a JWKS document. Keys with unsupported types or algorithms are skipped; error is set when the document itself is unusable.
JwtKeySet.size (extension fun)
fun JwtKeySet.size(): int
Returns the number of keys in the set.
JwtKeySet.hasKey (extension fun)
fun JwtKeySet.hasKey(kid: string): bool
Reports whether the key set contains the given key identifier.
JwtKeySet.select (extension fun)
fun JwtKeySet.select(kid: string, alg: string): int
Selects by kid when the token names one; otherwise the token's algorithm must identify exactly one key.
jwtNowSeconds (fun)
trusted fun jwtNowSeconds(): int
Reads the current Unix time in whole seconds, leaving zero if the clock read fails.
JwtKeySet.verify (extension fun)
fun JwtKeySet.verify(
token: string,
options: JwtOptions = JwtOptions()
): JwtVerification
Verifies the signature and claims and returns a failure result for malformed, unsupported or rejected tokens.
jwtDecodeUnverified (fun)
fun jwtDecodeUnverified(token: string): Json
Decodes claims without verifying anything (diagnostics only).
Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.