Beispiel
cookie-signature 1.2.2
Verifiziertes Beispiel für npm cookie-signature 1.2.2. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand: assert cookieSignature.sign…
sha256:5a9400f0796dc83957921d83e1eea8f6054d4c32a6d9d991342d1fd71dd76b1b
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 1
- Signaturschlüssel, die es gebaut haben
- 1
Deklarierte Umgebung
linux 24 · ubuntu · glibc 2.39 x64 npm
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- verify pkg:npm/cookie-signature@1.2.2
- Pakete
- Erstellt
- 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
Dateien
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Quelltext
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.'
);
Ursprungs-Seeder
anonym