CodeSampleX

Beispiel

cookie 1.1.1: parseSetCookie

Verifiziertes Beispiel für npm cookie 1.1.1: parseSetCookie. Der Vertrag lief auf node 22 · linux debian/x64 · docker und bestand.

sha256:2e4fca6f6e626928c49d8cce320696a09182fdc7504d1e60850664f1ef11c355

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 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-06

Fall

HOW
Ziel
verify cookie.parseSetCookie in pkg:npm/cookie@1.1.1
Pakete
Symbole
  • cookie.parseSetCookie
Umgebung
node 22.23.2
Erstellt
2026-09-06T01:05:22Z

Contract

  1. cookie.parseSetCookie parses basic name and value from a Set-Cookie header string
  2. cookie.parseSetCookie decodes URI encoded values and supports custom decode option
  3. cookie.parseSetCookie parses boolean flags including HttpOnly, Secure, and Partitioned
  4. cookie.parseSetCookie parses Domain and Path attributes
  5. cookie.parseSetCookie parses Max-Age as integer and Expires as Date object
  6. cookie.parseSetCookie parses Priority and SameSite attributes case-insensitively
  7. cookie.parseSetCookie ignores invalid or unrecognized attributes without throwing
  8. cookie.parseSetCookie handles empty name or value without throwing

Dateien

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • test/contract.cjs

Quellartefakt herunterladen (tar.gz)

Quelltext

PROMPT.md
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 cookie.parseSetCookie in pkg:npm/cookie@1.1.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/cookie@1.1.1
Demonstrate these symbols/APIs:
  - cookie.parseSetCookie
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.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.
csx.json
{"case":{"caseId":"case:sha256:906618c7f0dea13caea6c18609a69b7c3d15b3ed4828233ddd11dfad00e1460a","constraints":{"executionContext":"node"},"contract":["cookie.parseSetCookie parses basic name and value from a Set-Cookie header string","cookie.parseSetCookie decodes URI encoded values and supports custom decode option","cookie.parseSetCookie parses boolean flags including HttpOnly, Secure, and Partitioned","cookie.parseSetCookie parses Domain and Path attributes","cookie.parseSetCookie parses Max-Age as integer and Expires as Date object","cookie.parseSetCookie parses Priority and SameSite attributes case-insensitively","cookie.parseSetCookie ignores invalid or unrecognized attributes without throwing","cookie.parseSetCookie handles empty name or value without throwing"],"goal":"verify cookie.parseSetCookie in pkg:npm/cookie@1.1.1","kind":"HOW","packages":["pkg:npm/cookie@1.1.1"],"schemaVersion":1,"symbols":["cookie.parseSetCookie"]},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/cookie@1.1.1"],"schemaVersion":1,"subject":"pkg:npm/cookie@1.1.1","symbols":["cookie.parseSetCookie"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "cookie-parsesetcookie-verification",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "cookie-parsesetcookie-verification",
      "version": "1.0.0",
      "dependencies": {
        "cookie": "1.1.1"
      }
    },
    "node_modules/cookie": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/cookie/-/cookie-1.1.1.tgz",
      "integrity": "sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==",
      "license": "MIT",
      "engines": {
        "node": ">=18"
      },
      "funding": {
        "type": "opencollective",
        "url": "https://opencollective.com/express"
      }
    }
  }
}
package.json
{
  "name": "cookie-parsesetcookie-verification",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for cookie.parseSetCookie in cookie@1.1.1",
  "dependencies": {
    "cookie": "1.1.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify cookie.parseSetCookie in pkg:npm/cookie@1.1.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/cookie@1.1.1"
  ],
  "symbols": [
    "cookie.parseSetCookie"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.cjs
const assert = require('node:assert');
const cookie = require('cookie');

// 1. cookie.parseSetCookie parses basic name and value from a Set-Cookie header string
const c1 = cookie.parseSetCookie('foo=bar');
assert.strictEqual(c1.name, 'foo');
assert.strictEqual(c1.value, 'bar');

// 2. cookie.parseSetCookie decodes URI encoded values and supports custom decode option
const c2 = cookie.parseSetCookie('token=%E2%9C%93%20value');
assert.strictEqual(c2.name, 'token');
assert.strictEqual(c2.value, '✓ value');
const c2b = cookie.parseSetCookie('custom=abc', { decode: (v) => v.toUpperCase() });
assert.strictEqual(c2b.value, 'ABC');

// 3. cookie.parseSetCookie parses boolean flags including HttpOnly, Secure, and Partitioned
const c3 = cookie.parseSetCookie('session=123; HttpOnly; Secure; Partitioned');
assert.strictEqual(c3.httpOnly, true);
assert.strictEqual(c3.secure, true);
assert.strictEqual(c3.partitioned, true);

// 4. cookie.parseSetCookie parses Domain and Path attributes
const c4 = cookie.parseSetCookie('id=test; Domain=example.com; Path=/api');
assert.strictEqual(c4.domain, 'example.com');
assert.strictEqual(c4.path, '/api');

// 5. cookie.parseSetCookie parses Max-Age as integer and Expires as Date object
const c5 = cookie.parseSetCookie('id=test; Max-Age=3600; Expires=Wed, 21 Oct 2026 07:28:00 GMT');
assert.strictEqual(c5.maxAge, 3600);
assert.strictEqual(c5.expires instanceof Date, true);
assert.strictEqual(c5.expires.toUTCString(), 'Wed, 21 Oct 2026 07:28:00 GMT');
const c5b = cookie.parseSetCookie('id=test; Max-Age=-1');
assert.strictEqual(c5b.maxAge, -1);

// 6. cookie.parseSetCookie parses Priority and SameSite attributes case-insensitively
const c6 = cookie.parseSetCookie('key=val; Priority=High; SameSite=Lax');
assert.strictEqual(c6.priority, 'high');
assert.strictEqual(c6.sameSite, 'lax');
const c6b = cookie.parseSetCookie('key=val; Priority=LOW; SameSite=STRICT');
assert.strictEqual(c6b.priority, 'low');
assert.strictEqual(c6b.sameSite, 'strict');
const c6c = cookie.parseSetCookie('key=val; Priority=medium; SameSite=none');
assert.strictEqual(c6c.priority, 'medium');
assert.strictEqual(c6c.sameSite, 'none');

// 7. cookie.parseSetCookie ignores invalid or unrecognized attributes without throwing
const c7 = cookie.parseSetCookie('key=val; UnknownAttr=foo; Max-Age=notanumber; Expires=invalid-date; SameSite=invalid; Priority=invalid');
assert.strictEqual(c7.name, 'key');
assert.strictEqual(c7.value, 'val');
assert.strictEqual(c7.maxAge, undefined);
assert.strictEqual(c7.expires, undefined);
assert.strictEqual(c7.sameSite, undefined);
assert.strictEqual(c7.priority, undefined);

// 8. cookie.parseSetCookie handles empty name or value without throwing
const c8 = cookie.parseSetCookie('=emptyname');
assert.strictEqual(c8.name, '');
assert.strictEqual(c8.value, 'emptyname');
const c8b = cookie.parseSetCookie('emptyval=');
assert.strictEqual(c8b.name, 'emptyval');
assert.strictEqual(c8b.value, '');
const c8c = cookie.parseSetCookie('novalue');
assert.strictEqual(c8c.name, '');
assert.strictEqual(c8c.value, 'novalue');

console.log('Contract passed');

Ursprungs-Seeder

anonym