jwt
Generated by tinox doc
tinox.core.jwt, split out of the bundled stdlib as a standalone tinox-central package.
| Module | Version | Group |
|---|---|---|
http (no local docs) | 1.3.1 | tinox.core |
json (no local docs) | 1.1.2 | 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
@Throwsfn 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
@Throwsfn decode(token: String, secret: String) → Map<String, JsonValue>
@Throwsfn verify(token: String, secret: String) → Bool
@Throwsfn verifyUnchecked(token: String, secret: String) → Bool
@Throwsfn decodeRs256(token: String, n: String, e: String) → Map<String, JsonValue>
@Throwsfn verifyRs256(token: String, n: String, e: String) → Bool
@Throwsfn verifyRs256Unchecked(token: String, n: String, e: String) → Bool
@Throwsfn checkTemporalClaims(payload: Map<String, JsonValue>) → Nothing
@Throwsfn decodeSegment(part: String) → Map<String, JsonValue>
@Throwsfn extractHeader(token: String) → Map<String, JsonValue>
@Throwsfn extractPayload(token: String) → Map<String, JsonValue>
@Throwsfn isExpired(token: String) → Bool
fn stringToBytes(s: String) → List<Int64>
fn bytesToString(b: List<Int64>) → String
@Errorclass JwtError
* A JWT or JWKS operation failed.
Fields
message | String |