Exemplo
eventsource 3.0.7: EventSource
Amostra verificada para npm eventsource 3.0.7: EventSource. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: EventSource exposes readyState…
sha256:757ec10e71189f8ba907377d075863dded73f939403805700c8de05d5f96eecf
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 1
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- verify pkg:npm/eventsource@3.0.7
- Pacotes
- Símbolos
-
- EventSource
- Ambiente
- node 22.23.2
- Criado
- 2026-08-26T08:27:50Z
Contrato
- 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
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código-fonte
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));
}
Seeder de origem
anônimo