Sample
cookie-signature 1.2.2
Verified sample for npm cookie-signature 1.2.2. The contract ran on node 22 · linux alpine/x64 · docker and passed: assert cookieSignature.sign signs cookie…
sha256:5a9400f0796dc83957921d83e1eea8f6054d4c32a6d9d991342d1fd71dd76b1b
This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured.
How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people.
MIT-0
Execution evidence
The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.
- Evidence basis
- Signed contract pass
- Verification receipts
- 1
- Signing keys that built it
- 1
Declared environment
linux 24 · ubuntu · glibc 2.39 x64 npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-20 |
Case
HOW- Goal
- verify pkg:npm/cookie-signature@1.2.2
- Packages
- Created
- 2026-08-20T13:43:52Z
Contract
- assert cookieSignature.sign signs cookie string value with HMAC SHA256 base64 digest stripped of padding
- assert cookieSignature.unsign recovers the original cookie value when secret matches
- assert cookieSignature.unsign returns false for tampered payload or mismatched secret
- assert cookieSignature.sign and cookieSignature.unsign throw TypeError when argument types are invalid or secret is null
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Source
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:npm/cookie-signature@1.2.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/cookie-signature@1.2.2
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:5231ae376f805d1a6b1af7910e1cfd5bf1d23bb6f0b06d2c8aa8778f363fe0ee","contract":["assert cookieSignature.sign signs cookie string value with HMAC SHA256 base64 digest stripped of padding","assert cookieSignature.unsign recovers the original cookie value when secret matches","assert cookieSignature.unsign returns false for tampered payload or mismatched secret","assert cookieSignature.sign and cookieSignature.unsign throw TypeError when argument types are invalid or secret is null"],"goal":"verify pkg:npm/cookie-signature@1.2.2","kind":"HOW","packages":["pkg:npm/cookie-signature@1.2.2"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/cookie-signature@1.2.2"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
{
"name": "sample-cookie-signature",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-cookie-signature",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"cookie-signature": "1.2.2"
}
},
"node_modules/cookie-signature": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
"integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==",
"license": "MIT",
"engines": {
"node": ">=6.6.0"
}
}
}
}
{
"name": "sample-cookie-signature",
"version": "1.0.0",
"type": "module",
"license": "MIT-0",
"dependencies": {
"cookie-signature": "1.2.2"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/cookie-signature@1.2.2",
"kind": "HOW",
"packages": [
"pkg:npm/cookie-signature@1.2.2"
]
}
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const cookieSignature = require('cookie-signature');
// 1. Sign a cookie value with a secret
const secret = 'sample-secret-key';
const val = 'user-session-id';
const signed = cookieSignature.sign(val, secret);
assert.equal(typeof signed, 'string');
assert.equal(signed.startsWith(`${val}.`), true);
// 2. Unsign a valid signed cookie returns the original value
const unsigned = cookieSignature.unsign(signed, secret);
assert.equal(unsigned, val);
// 3. Unsign with wrong secret returns false
const unsignedWrongSecret = cookieSignature.unsign(signed, 'different-secret');
assert.equal(unsignedWrongSecret, false);
// 4. Unsign tampered cookie value returns false
const tampered = `${val}-tampered.${signed.split('.')[1]}`;
const unsignedTampered = cookieSignature.unsign(tampered, secret);
assert.equal(unsignedTampered, false);
// 5. Sign with non-string value or null secret throws TypeError
assert.throws(
() => cookieSignature.sign(12345, secret),
(err) => err instanceof TypeError && err.message === 'Cookie value must be provided as a string.'
);
assert.throws(
() => cookieSignature.sign(val, null),
(err) => err instanceof TypeError && err.message === 'Secret key must be provided.'
);
// 6. Unsign with non-string value or null secret throws TypeError
assert.throws(
() => cookieSignature.unsign(12345, secret),
(err) => err instanceof TypeError && err.message === 'Signed cookie string must be provided.'
);
assert.throws(
() => cookieSignature.unsign(signed, null),
(err) => err instanceof TypeError && err.message === 'Secret key must be provided.'
);
Origin Seeder
anonymous