Skip to main content

JWT authentication

A Wing library for working with JWT authentication.

Prerequisites

Installation

npm i @winglibs/jwt

Usage

bring util;
bring jwt;

test "will sign and verify" {
let id = util.nanoid();
let token = jwt.sign({ foo: id }, "shhhhh");
let decoded1 = jwt.verify(token, secret: "shhhhh");
}

License

This library is licensed under the MIT License.

API Reference

Table of Contents

Util (preflight class)

No description

Constructor

new(): Util

Properties

No properties

Methods

SignatureDescription
static inflight decode(token: str, options: DecodeOptions?): JsonNo description
static inflight sign(data: Json, secret: str, options: SignOptions?): strNo description
static inflight verify(token: str, options: VerifyOptions): JsonNo description

DecodeOptions (struct)

No description

Properties

NameTypeDescription
completebool?No description

SignOptions (struct)

No description

Properties

NameTypeDescription
algorithmstr?No description
audience
Array?
No description
encodingstr?No description
expiresInduration?No description
issuerstr?No description
jwtidstr?No description
keyidstr?No description
notBeforeduration?No description
subjectstr?No description

VerifyJwtOptions (struct)

No description

Properties

NameTypeDescription
algorithms
Array?
No description
audiencestr?No description
ignoreExpirationbool?No description
ignoreNotBeforebool?No description
issuerstr?No description
jwtidstr?No description
maxAgestr?No description
noncestr?No description
subjectstr?No description

VerifyOptions (struct)

No description

Properties

NameTypeDescription
jwksUristr?No description
optionsVerifyJwtOptions?No description
secretstr?No description