AssemblyScript package that provides simple jws handling for jwt tokens.
npm install @gcoredev/as-jwt
import { jwtVerify, JwtValidation } from "@gcoredev/as-jwt/assembly";
const token = "<base64-header>.<base64-payload>.<signed-secret>";
const secret = "my-long-private-key-that-is-hard-to-guess";
const result: JwtValidation = jwtVerify(token, secret);
if (result === JwtValidation.Ok) {
// Jwt is valid.
} else {
// Jwt validation failed
}
jwtVerify(token, secret): JwtValidation
Validates token
signature has been signed with a valid secret
.
Also validates that claims contain an exp
date and that the token is not expired.
compactVerify(token, secret): JwtValidation
Validates token
signature has been signed with a valid secret
.
Does NOT validate any claims in the payload.
Under the hood this package is powered by: