Modules@robinpath/jwt

@robinpath/jwt

0.1.0Public

JWT (JSON Web Token) creation, signing, verification, and decoding using HMAC (HS256, HS384, HS512)

@robinpath/jwt

JWT (JSON Web Token) creation, signing, verification, and decoding using HMAC (HS256, HS384, HS512)

Category Functions Auth License

Why use this module?

The jwt module lets you:

  • Create a signed JWT token from a payload object using HMAC (HS256, HS384, or HS512)
  • Verify a JWT token signature and expiration, returning the decoded payload
  • Decode a JWT token WITHOUT verifying its signature (unsafe — use for inspection only)
  • Extract and decode the header from a JWT token (no verification)
  • Extract and decode the payload from a JWT token without verification

All functions are callable directly from RobinPath scripts with a simple, consistent API.

Installation

npm install @robinpath/jwt

Quick Start

No credentials needed — start using it right away:

jwt.verify "eyJhbGciOiJIUzI1NiJ9..." "my-secret"

Available Functions

FunctionDescription
jwt.signCreate a signed JWT token from a payload object using HMAC (HS256, HS384, or HS512)
jwt.verifyVerify a JWT token signature and expiration, returning the decoded payload
jwt.decodeDecode a JWT token WITHOUT verifying its signature (unsafe — use for inspection only)
jwt.getHeaderExtract and decode the header from a JWT token (no verification)
jwt.getPayloadExtract and decode the payload from a JWT token without verification
jwt.isExpiredCheck whether a JWT token has expired based on its exp claim
jwt.getExpirationGet the expiration timestamp (exp claim) from a JWT token

Examples

Verify a JWT token signature and expiration, returning the decoded payload

jwt.verify "eyJhbGciOiJIUzI1NiJ9..." "my-secret"

Decode a JWT token WITHOUT verifying its signature (unsafe — use for inspection only)

jwt.decode "eyJhbGciOiJIUzI1NiJ9..."

Extract and decode the header from a JWT token (no verification)

jwt.getHeader "eyJhbGciOiJIUzI1NiJ9..."

Integration with RobinPath

import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/jwt";

const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);

const result = await rp.executeScript(`
  jwt.verify "eyJhbGciOiJIUzI1NiJ9..." "my-secret"
`);

Full API Reference

See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.

Related Modules

License

MIT

Versions (1)

VersionTagPublished
0.1.0latestyesterday
Install
$ robinpath install @robinpath/jwt
Version0.1.0
LicenseMIT
Unpacked Size5.0 KB
Versions1
Weekly Downloads0
Total Downloads0
Stars0
Last Publishyesterday
Createdyesterday

Category

web