jwt
Generated by tinox doc
tinox.core.jwt, split out of the bundled stdlib as a standalone tinox-central package.
| Module | Version | Group |
|---|---|---|
http | 1.1.0 | tinox.core |
json | 1.1.0 | tinox.core |
Encode verify
import tinox.core.jwt
import tinox.core.json
class Main
{
fnc main() -> Int32
{
const secret: String = "super-secret-key"
const payload: Map<String, JsonValue> = Map::new()
payload["sub"] = Json::parse("\"user-42\"")
const token: String = Jwt::encode(payload, secret)
println(token)
const ok: Bool = Jwt::verify(token, secret)
println("valid: " + ok.toString())
const decoded: Map<String, JsonValue> = Jwt::decode(token, secret)
println(decoded["sub"].getString())
return 0
}
}
class Jwks
Methods
fn fetchRsaKey(jwksUri: String, kid: String) → Map<String, String>
fn rsaVerifySha256(message: List<Int64>, signature: List<Int64>, modulus: List<Int64>, exponent: List<Int64>) → Bool
fn tinoxBytesToString(bytes: List<Int64>) → String
class Jwt
Methods
fn encode(payload: Map<String, JsonValue>, secret: String) → String
fn decode(token: String, secret: String) → Map<String, JsonValue>
fn verify(token: String, secret: String) → Bool
fn decodeRs256(token: String, n: String, e: String) → Map<String, JsonValue>
fn verifyRs256(token: String, n: String, e: String) → Bool
fn checkTemporalClaims(payload: Map<String, JsonValue>) → Nothing
fn decodeSegment(part: String) → Map<String, JsonValue>
fn extractHeader(token: String) → Map<String, JsonValue>
fn extractPayload(token: String) → Map<String, JsonValue>
fn isExpired(token: String) → Bool
fn stringToBytes(s: String) → List<Int64>
fn bytesToString(b: List<Int64>) → String