샘플
fresh 2.0.0
검증된 샘플 — npm fresh 2.0.0. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: fresh(reqHeaders, resHeaders) returns false for unconditional requests…
sha256:a13513787b8f06f4ff588920fa652e8e8d861f2bb13222af32c831056298e691
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify pkg:npm/fresh@2.0.0
- 패키지
- 생성일
- 2026-08-20T13:52:02Z
컨트랙트
- fresh(reqHeaders, resHeaders) returns false for unconditional requests without if-modified-since or if-none-match
- fresh(reqHeaders, resHeaders) returns false when Cache-Control header contains no-cache even if ETags match
- fresh(reqHeaders, resHeaders) returns true when if-none-match exactly matches the response etag
- fresh(reqHeaders, resHeaders) returns true when matching weak ETags like W/"123" and "123"
- fresh(reqHeaders, resHeaders) returns true when if-none-match is wildcard *
- fresh(reqHeaders, resHeaders) returns true when if-modified-since is at or after response last-modified date
- fresh(reqHeaders, resHeaders) prioritizes if-none-match over if-modified-since when both are present
파일
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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/fresh@2.0.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/fresh@2.0.0
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:f8aa366ce0acad548bde72db92105d45ed260fe9a6f4c004e3f20cd9b8121604","contract":["fresh(reqHeaders, resHeaders) returns false for unconditional requests without if-modified-since or if-none-match","fresh(reqHeaders, resHeaders) returns false when Cache-Control header contains no-cache even if ETags match","fresh(reqHeaders, resHeaders) returns true when if-none-match exactly matches the response etag","fresh(reqHeaders, resHeaders) returns true when matching weak ETags like W/\"123\" and \"123\"","fresh(reqHeaders, resHeaders) returns true when if-none-match is wildcard *","fresh(reqHeaders, resHeaders) returns true when if-modified-since is at or after response last-modified date","fresh(reqHeaders, resHeaders) prioritizes if-none-match over if-modified-since when both are present"],"goal":"verify pkg:npm/fresh@2.0.0","kind":"HOW","packages":["pkg:npm/fresh@2.0.0"],"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/fresh@2.0.0"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
import fresh from 'fresh';
export function isResponseFresh(reqHeaders, resHeaders) {
return fresh(reqHeaders, resHeaders);
}
{
"name": "sample-fresh",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-fresh",
"version": "1.0.0",
"dependencies": {
"fresh": "2.0.0"
}
},
"node_modules/fresh": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz",
"integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
}
}
}
{
"name": "sample-fresh",
"version": "1.0.0",
"description": "Clean-room verification sample for fresh",
"type": "module",
"private": true,
"dependencies": {
"fresh": "2.0.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/fresh@2.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/fresh@2.0.0"
]
}
import assert from 'node:assert/strict';
import fresh from 'fresh';
import { isResponseFresh } from '../index.mjs';
// 1. Unconditional requests return false
assert.equal(fresh({}, {}), false);
assert.equal(isResponseFresh({ host: 'example.com' }, { etag: '"123"' }), false);
// 2. Cache-Control: no-cache returns false even when ETags match
assert.equal(fresh({ 'if-none-match': '"123"', 'cache-control': 'no-cache' }, { etag: '"123"' }), false);
assert.equal(fresh({ 'if-none-match': '"123"', 'cache-control': 'max-age=0, no-cache' }, { etag: '"123"' }), false);
// 3. Exact if-none-match match returns true
assert.equal(fresh({ 'if-none-match': '"123"' }, { etag: '"123"' }), true);
assert.equal(fresh({ 'if-none-match': '"123"' }, { etag: '"456"' }), false);
assert.equal(fresh({ 'if-none-match': '"foo", "bar"' }, { etag: '"bar"' }), true);
// 4. Weak ETag matching returns true
assert.equal(fresh({ 'if-none-match': 'W/"123"' }, { etag: '"123"' }), true);
assert.equal(fresh({ 'if-none-match': '"123"' }, { etag: 'W/"123"' }), true);
assert.equal(fresh({ 'if-none-match': 'W/"123"' }, { etag: 'W/"123"' }), true);
// 5. Wildcard * if-none-match returns true
assert.equal(fresh({ 'if-none-match': '*' }, { etag: '"anything"' }), true);
assert.equal(fresh({ 'if-none-match': '*' }, {}), true);
// 6. if-modified-since comparison
const now = new Date('2026-08-20T12:00:00Z').toUTCString();
const past = new Date('2026-08-20T11:00:00Z').toUTCString();
const future = new Date('2026-08-20T13:00:00Z').toUTCString();
assert.equal(fresh({ 'if-modified-since': now }, { 'last-modified': past }), true);
assert.equal(fresh({ 'if-modified-since': now }, { 'last-modified': now }), true);
assert.equal(fresh({ 'if-modified-since': past }, { 'last-modified': now }), false);
// 7. if-none-match takes precedence over if-modified-since
assert.equal(fresh({ 'if-none-match': '"mismatch"', 'if-modified-since': future }, { etag: '"actual"', 'last-modified': past }), false);
assert.equal(fresh({ 'if-none-match': '"match"', 'if-modified-since': past }, { etag: '"match"', 'last-modified': future }), true);
console.log('All fresh@2.0.0 contract assertions passed.');
오리진 시더
익명