Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Latest commit

 

History

History
69 lines (41 loc) · 1.43 KB

jwt.md

File metadata and controls

69 lines (41 loc) · 1.43 KB

Namespace: jwt

Module jwt aims to provide an implementation of the JSON Web Token. Only compact serializtion is supported.

Table of contents

Functions

Functions

decode

decode(token: string): object

Decode JSON Web Token payload without signature validation.

Parameters

Name Type Description
token string The JWT to decode

Returns: object

The decoded payload


sign

sign(key: Key, payload: object, header?: object): string

Create JSON Web Token from payload and optional header.

Parameters

Name Type Description
key Key The signing key
payload object The payload claims
header? object The header fields

Returns: string

The signed JWT in compact serialization form


verify

verify(token: string, ...key: Key[]): object

Verify JSON Web Token signature and decode payload on success.

Parameters

Name Type Description
token string The JWT to verify
...key Key[] The signature validation key (or keys)

Returns: object

The payload of the verified token