@robinpath/jwt
0.1.0PublicJWT (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)
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
| Function | Description |
|---|---|
jwt.sign | Create a signed JWT token from a payload object using HMAC (HS256, HS384, or HS512) |
jwt.verify | Verify a JWT token signature and expiration, returning the decoded payload |
jwt.decode | Decode a JWT token WITHOUT verifying its signature (unsafe — use for inspection only) |
jwt.getHeader | Extract and decode the header from a JWT token (no verification) |
jwt.getPayload | Extract and decode the payload from a JWT token without verification |
jwt.isExpired | Check whether a JWT token has expired based on its exp claim |
jwt.getExpiration | Get 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
@robinpath/json— JSON module for complementary functionality
License
MIT
Versions (1)
| Version | Tag | Published |
|---|---|---|
| 0.1.0 | latest | yesterday |
Related Modules
@robinpath/api
HTTP client for making requests to external APIs with profiles, auth, download/upload, and auto-JSON parsing
@robinpath/auth
API authentication helpers (Basic, Bearer, API key, HMAC) for RobinPath
@robinpath/browser
Headless browser automation with Puppeteer: launch browsers, navigate pages, interact with elements, take screenshots, generate PDFs, and scrape data
@robinpath/cookie
HTTP cookie parsing, serialization, signing/verification, Set-Cookie handling, and cookie jar management
$ robinpath install @robinpath/jwt
