Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Usage

import * as djwt from "https://raw.githubusercontent.com/timonson/djwt/master/mod.ts";

§Functions

create

Takes Header, Payload and CryptoKey and returns the url-safe encoded jwt.

decode

Takes a jwt and returns a 3-tuple [unknown, unknown, Uint8Array] if the jwt has a valid serialization. Otherwise it throws an Error. This function does not verify the digital signature.

getNumericDate

This helper function simplifies setting a NumericDate. It takes either a Date object or a number (in seconds) and returns the number of seconds from 1970-01-01T00:00:00Z UTC until the specified UTC date/time.

validate

It does not verify the digital signature.

validateAudClaim
validateTimingClaims
verify

Takes jwt, CryptoKey and VerifyOptions and returns the Payload of the jwt if the jwt is valid. Otherwise it throws an Error.

§Interfaces

Header

JWS §4.1.1: The "alg" value is a case-sensitive ASCII string containing a StringOrURI value. This Header Parameter MUST be present and MUST be understood and processed by implementations.

Payload

JWT §1: JWTs encode claims to be transmitted as a JSON [RFC7159] object [...]. JWT §4.1: The following Claim Names are registered in the IANA "JSON Web Token Claims" registry established by Section 10.1. None of the claims defined below are intended to be mandatory to use or implement in all cases, but rather they provide a starting point for a set of useful, interoperable claims. Applications using JWTs should define which specific claims they use and when they are required or optional.

§Type Aliases

VerifyOptions

With expLeeway and nbfLeeway implementers may provide for some small leeway to account for clock skew (JWT §4.1.4). The default is 1 second. By passing the option audience, this application tries to identify the recipient with a value in the aud claim. If the values don't match, an Error is thrown.