サンプル
eventsource 3.0.7: EventSource
検証済みサンプル — npm eventsource 3.0.7: EventSource. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: EventSource exposes readyState constants…
sha256:757ec10e71189f8ba907377d075863dded73f939403805700c8de05d5f96eecf
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-26 |
ケース
HOW- ゴール
- verify pkg:npm/eventsource@3.0.7
- パッケージ
- シンボル
-
- EventSource
- 環境
- node 22.23.2
- 作成日
- 2026-08-26T08:27:50Z
コントラクト
- EventSource exposes readyState constants CONNECTING (0), OPEN (1), and CLOSED (2)
- EventSource initializes with CONNECTING readyState, the target URL, and default options
- EventSource connects to an SSE endpoint and dispatches open event with readyState OPEN
- EventSource receives and parses standard message events with event.data
- EventSource receives and dispatches custom named events via addEventListener
- EventSource.close() terminates the connection and transitions readyState to CLOSED
ファイル
- PROMPT.md
- csx.json
- 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/eventsource@3.0.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/eventsource@3.0.7
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.
{"case":{"caseId":"case:sha256:27b05d1f2852da43248c77d69324a8d2e072a9a19283d39763f468e5fcb9b5c6","constraints":{"executionContext":"node"},"contract":["EventSource exposes readyState constants CONNECTING (0), OPEN (1), and CLOSED (2)","EventSource initializes with CONNECTING readyState, the target URL, and default options","EventSource connects to an SSE endpoint and dispatches open event with readyState OPEN","EventSource receives and parses standard message events with event.data","EventSource receives and dispatches custom named events via addEventListener","EventSource.close() terminates the connection and transitions readyState to CLOSED"],"goal":"verify pkg:npm/eventsource@3.0.7","kind":"HOW","packages":["pkg:npm/eventsource@3.0.7"],"schemaVersion":1,"symbols":["EventSource"]},"contractCommand":["node","test/contract.mjs"],"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/eventsource@3.0.7"],"schemaVersion":1,"subject":"pkg:npm/eventsource@3.0.7","symbols":["EventSource"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-eventsource-verify",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-eventsource-verify",
"version": "1.0.0",
"dependencies": {
"eventsource": "3.0.7"
}
},
"node_modules/eventsource": {
"version": "3.0.7",
"resolved": "https://registry.npmjs.org/eventsource/-/eventsource-3.0.7.tgz",
"integrity": "sha512-CRT1WTyuQoD771GW56XEZFQ/ZoSfWid1alKGDYMmkt2yl8UXrVR4pspqWNEcqKvVIzg6PAltWjxcSSPrboA4iA==",
"license": "MIT",
"dependencies": {
"eventsource-parser": "^3.0.1"
},
"engines": {
"node": ">=18.0.0"
}
},
"node_modules/eventsource-parser": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-3.1.1.tgz",
"integrity": "sha512-EKN1vKAMcZ8MlYMpaNuxN6R9yakzH6uajHcHVTqWJzvu5pWw9DyhbP35HH8MVBQ+dZjAfDxk+A8NiR9KWaXiyQ==",
"license": "MIT",
"engines": {
"node": ">=18.0.0"
}
}
}
}
{
"name": "sample-eventsource-verify",
"version": "1.0.0",
"private": true,
"dependencies": {
"eventsource": "3.0.7"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/eventsource@3.0.7",
"kind": "HOW",
"packages": [
"pkg:npm/eventsource@3.0.7"
],
"symbols": [
"EventSource"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import http from 'node:http';
import { EventSource } from 'eventsource';
// 1. EventSource exposes readyState constants CONNECTING (0), OPEN (1), and CLOSED (2)
{
assert.equal(EventSource.CONNECTING, 0);
assert.equal(EventSource.OPEN, 1);
assert.equal(EventSource.CLOSED, 2);
}
// Helper to run offline HTTP SSE server for network contracts
async function createTestServer() {
const server = http.createServer((req, res) => {
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
'Connection': 'keep-alive',
});
res.write('event: custom-event\ndata: payload-data\n\n');
res.write('data: line1\ndata: line2\n\n');
});
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
const port = server.address().port;
const url = `http://127.0.0.1:${port}/sse`;
return { server, url };
}
const { server, url } = await createTestServer();
try {
// 2. EventSource initializes with CONNECTING readyState, the target URL, and default options
const es = new EventSource(url);
assert.equal(es.readyState, EventSource.CONNECTING);
assert.equal(es.url, url);
assert.equal(es.withCredentials, false);
assert.equal(es.CONNECTING, 0);
assert.equal(es.OPEN, 1);
assert.equal(es.CLOSED, 2);
const receivedCustomEvents = [];
const receivedMessages = [];
await new Promise((resolve, reject) => {
const timeout = setTimeout(() => {
reject(new Error('Test timed out waiting for SSE events'));
}, 5000);
// 3. EventSource connects to an SSE endpoint and dispatches open event with readyState OPEN
es.addEventListener('open', () => {
assert.equal(es.readyState, EventSource.OPEN);
});
// 5. EventSource receives and dispatches custom named events via addEventListener
es.addEventListener('custom-event', (event) => {
receivedCustomEvents.push(event.data);
});
// 4. EventSource receives and parses standard message events with event.data
es.addEventListener('message', (event) => {
receivedMessages.push(event.data);
if (receivedCustomEvents.length === 1 && receivedMessages.length === 1) {
clearTimeout(timeout);
resolve();
}
});
es.addEventListener('error', (err) => {
clearTimeout(timeout);
reject(err);
});
});
assert.deepEqual(receivedCustomEvents, ['payload-data']);
assert.deepEqual(receivedMessages, ['line1\nline2']);
// 6. EventSource.close() terminates the connection and transitions readyState to CLOSED
es.close();
assert.equal(es.readyState, EventSource.CLOSED);
} finally {
await new Promise((resolve) => server.close(resolve));
}
オリジンシーダー
匿名