Modules@robinpath/cookie

@robinpath/cookie

0.1.0Public

HTTP 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

Category Functions Auth License

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

FunctionDescription
cookie.parseParse Cookie header string
cookie.serializeSerialize Set-Cookie header
cookie.signSign cookie value with HMAC
cookie.unsignVerify and unsign cookie
cookie.getGet single cookie from header
cookie.removeGenerate removal Set-Cookie
cookie.parseSetCookieParse Set-Cookie header
cookie.isExpiredCheck if cookie is expired
cookie.jarCreate cookie jar
cookie.toHeaderBuild Cookie header from pairs
cookie.encodeURL-encode cookie value
cookie.decodeURL-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

License

MIT

Versions (1)

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

Category

web