Skip to content

Latest commit

 

History

History
23 lines (11 loc) · 517 Bytes

README.md

File metadata and controls

23 lines (11 loc) · 517 Bytes

JWT basics with jsonwebtoken library

Generate key pair

const { privateKey, publicKey } = generateKeyPair()

Issue JWT token - without expires

issue_jwt = (payload: object, privateKey: string)

Issue JWT token - with expires

issue_jwt_expires = (payload: object, privateKey: string, expiresIn: string)

Verify JWT token

verify_jwt(jwtToken, publicKey)

Decode JWT token

const { header, payload } = decode_jwt(jwtToken)