Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fido2/lib/main.js>tools.jwtVerify

A node.js library for performing FIDO 2.0 / WebAuthn server functionality
Go to Latest
function tools.jwtVerify
Re-export
import { tools } from "https://deno.land/x/fido2@3.3.5/lib/main.js";
const { jwtVerify } = tools;

Verifies the JWT format (to be a JWS Compact format), verifies the JWS signature, validates the JWT Claims Set.

Examples

Usage

const jwt =
  'eyJhbGciOiJFUzI1NiJ9.eyJ1cm46ZXhhbXBsZTpjbGFpbSI6dHJ1ZSwiaWF0IjoxNjA0MzE1MDc0LCJpc3MiOiJ1cm46ZXhhbXBsZTppc3N1ZXIiLCJhdWQiOiJ1cm46ZXhhbXBsZTphdWRpZW5jZSJ9.hx1nOfAT5LlXuzu8O-bhjXBGpklWDt2EsHw7-MDn49NrnwvVsstNhEnkW2ddauB7eSikFtUNeumLpFI9CWDBsg'

const { payload, protectedHeader } = await jose.jwtVerify(jwt, publicKey, {
  issuer: 'urn:example:issuer',
  audience: 'urn:example:audience',
})

console.log(protectedHeader)
console.log(payload)

Parameters

jwt: string | Uint8Array

JSON Web Token value (encoded as JWS).

key: KeyLike | Uint8Array

Key to verify the JWT with.

optional
options: JWTVerifyOptions

JWT Decryption and JWT Claims Set validation options.

Returns

Promise<JWTVerifyResult>

Parameters

jwt: string | Uint8Array

JSON Web Token value (encoded as JWS).

getKey: JWTVerifyGetKey

Function resolving a key to verify the JWT with.

optional
options: JWTVerifyOptions

JWT Decryption and JWT Claims Set validation options.

Returns

Promise<JWTVerifyResult & ResolvedKey>