JWT
import { jwt } from 'https://deno.land/x/cheetah/mod.ts'
Generate a Secret
You can parse either a CryptoKey as secret to the listed functions below, or use the CLI to generate a random secret that can be stored in a database. You can also store the generated secret in the JWT_SECRET
environment variable and pass the context instead to it as secret.
Sign a Payload
const token = await jwt.sign(secret, payload)
Verify the Validity of a JWT
The function returns the payload if the token is valid and undefined
if it isn't.
const payload = await jwt.verify(secret, token)