class SignJWT
extends ProduceJWT
import { SignJWT } from "https://deno.land/x/jose@v4.8.3/jwt/sign.ts";
The SignJWT class is a utility for creating Compact JWS formatted JWT strings.
Examples
Usage
Usage
const jwt = await new jose.SignJWT({ 'urn:example:claim': true })
.setProtectedHeader({ alg: 'ES256' })
.setIssuedAt()
.setIssuer('urn:example:issuer')
.setAudience('urn:example:audience')
.setExpirationTime('2h')
.sign(privateKey)
console.log(jwt)
Properties
private
_protectedHeader: JWTHeaderParametersMethods
setProtectedHeader(protectedHeader: JWTHeaderParameters)
Sets the JWS Protected Header on the SignJWT object.
sign(key: KeyLike | Uint8Array, options?: SignOptions): Promise<string>
Signs and returns the JWT.