@robinpath/cookie
0.1.0PublicHTTP cookie parsing, serialization, signing/verification, Set-Cookie handling, and cookie jar management
@robinpath/cookie
HTTP cookie parsing, serialization, signing/verification, Set-Cookie handling, and cookie jar management
Why use this module?
The cookie module lets you:
- Parse Cookie header string
- Serialize Set-Cookie header
- Sign cookie value with HMAC
- Verify and unsign cookie
- Get single cookie from header
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
npm install @robinpath/cookie
Quick Start
No credentials needed — start using it right away:
cookie.serialize "session" "abc123" {"httpOnly": true, "maxAge": 3600}
Available Functions
| Function | Description |
|---|---|
cookie.parse | Parse Cookie header string |
cookie.serialize | Serialize Set-Cookie header |
cookie.sign | Sign cookie value with HMAC |
cookie.unsign | Verify and unsign cookie |
cookie.get | Get single cookie from header |
cookie.remove | Generate removal Set-Cookie |
cookie.parseSetCookie | Parse Set-Cookie header |
cookie.isExpired | Check if cookie is expired |
cookie.jar | Create cookie jar |
cookie.toHeader | Build Cookie header from pairs |
cookie.encode | URL-encode cookie value |
cookie.decode | URL-decode cookie value |
Examples
Serialize Set-Cookie header
cookie.serialize "session" "abc123" {"httpOnly": true, "maxAge": 3600}
Sign cookie value with HMAC
cookie.sign "userId=123" "my-secret"
Verify and unsign cookie
cookie.unsign $signed "my-secret"
Integration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/cookie";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
cookie.serialize "session" "abc123" {"httpOnly": true, "maxAge": 3600}
`);
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/feed
RSS, Atom, and JSON Feed creation, parsing, manipulation, and auto-detection
$ robinpath install @robinpath/cookie
