Exemplo
text-decoder 1.2.7
Amostra verificada para npm text-decoder 1.2.7. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: TextDecoder defaults to utf8 and decodes…
sha256:50f8c8d2efc61b98dc4752ba85486751ce54966d84e726855bbe433319a7d6eb
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
linux 24 · ubuntu · glibc 2.39 x64 npm
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-23 |
Caso
HOW- Objetivo
- verify pkg:npm/text-decoder@1.2.7
- Pacotes
- Criado
- 2026-08-23T15:18:30Z
Contrato
- TextDecoder defaults to utf8 and decodes multibyte UTF-8 characters across streamed chunk boundaries
- TextDecoder remaining property returns the number of buffered incomplete multibyte bytes
- TextDecoder passes through string input unchanged
- TextDecoder write method aliases push for stream compatibility
- TextDecoder end flushes any buffered bytes and resets remaining state to zero
- TextDecoder supports pass-through encodings like ascii and hex, and throws on unsupported or unknown encodings
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/text-decoder@1.2.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/text-decoder@1.2.7
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:dbec213d9df95a222094f9b1738510a49fb68bece83d5ee84cc54af4d6af23a4","contract":["TextDecoder defaults to utf8 and decodes multibyte UTF-8 characters across streamed chunk boundaries","TextDecoder remaining property returns the number of buffered incomplete multibyte bytes","TextDecoder passes through string input unchanged","TextDecoder write method aliases push for stream compatibility","TextDecoder end flushes any buffered bytes and resets remaining state to zero","TextDecoder supports pass-through encodings like ascii and hex, and throws on unsupported or unknown encodings"],"goal":"verify pkg:npm/text-decoder@1.2.7","kind":"HOW","packages":["pkg:npm/text-decoder@1.2.7"],"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/text-decoder@1.2.7"],"schemaVersion":1,"subject":"pkg:npm/text-decoder@1.2.7","verifierAdapter":"node-typescript@1"}
{
"name": "sample-text-decoder",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-text-decoder",
"version": "1.0.0",
"dependencies": {
"text-decoder": "1.2.7"
}
},
"node_modules/b4a": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/b4a/-/b4a-1.8.1.tgz",
"integrity": "sha512-aiqre1Nr0B/6DgE2N5vwTc+2/oQZ4Wh1t4NznYY4E00y8LCt6NqdRv81so00oo27D8MVKTpUa/MwUUtBLXCoDw==",
"license": "Apache-2.0",
"peerDependencies": {
"react-native-b4a": "*"
},
"peerDependenciesMeta": {
"react-native-b4a": {
"optional": true
}
}
},
"node_modules/text-decoder": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.7.tgz",
"integrity": "sha512-vlLytXkeP4xvEq2otHeJfSQIRyWxo/oZGEbXrtEEF9Hnmrdly59sUbzZ/QgyWuLYHctCHxFF4tRQZNQ9k60ExQ==",
"license": "Apache-2.0",
"dependencies": {
"b4a": "^1.6.4"
}
}
}
}
{
"name": "sample-text-decoder",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"text-decoder": "1.2.7"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/text-decoder@1.2.7",
"kind": "HOW",
"packages": [
"pkg:npm/text-decoder@1.2.7"
]
}
import assert from 'node:assert/strict';
import TextDecoder from 'text-decoder';
// 1. TextDecoder defaults to utf8 and decodes multibyte UTF-8 characters across streamed chunk boundaries
const td = new TextDecoder();
// UTF-8 bytes for '💩' (U+1F4A9): F0 9F 92 A9 (4 bytes)
const chunk1 = Buffer.of(0xf0, 0x9f, 0x92);
const chunk2 = Buffer.of(0xa9);
assert.strictEqual(td.push(chunk1), '', 'Incomplete 3-byte chunk of 4-byte sequence returns empty string');
assert.strictEqual(td.remaining, 3, 'Remaining bytes should be 3');
assert.strictEqual(td.push(chunk2), '💩', 'Final byte completes the character and returns decoded string');
assert.strictEqual(td.remaining, 0, 'Remaining bytes should now be 0');
// Multi-character streaming: 'hello 🌍!' where 🌍 is F0 9F 8C 8D
const tdStream = new TextDecoder();
const part1 = Buffer.concat([Buffer.from('hello '), Buffer.of(0xf0, 0x9f)]);
const part2 = Buffer.concat([Buffer.of(0x8c, 0x8d), Buffer.from('!')]);
assert.strictEqual(tdStream.push(part1), 'hello ', 'Decodes prefix ASCII before incomplete multibyte sequence');
assert.strictEqual(tdStream.push(part2), '🌍!', 'Completes emoji and continues decoding remainder');
// 2. TextDecoder remaining property returns the number of buffered incomplete multibyte bytes
const tdRem = new TextDecoder();
assert.strictEqual(tdRem.remaining, 0);
tdRem.push(Buffer.of(0xe2, 0x82)); // Euro sign € is E2 82 AC (3 bytes)
assert.strictEqual(tdRem.remaining, 2);
tdRem.push(Buffer.of(0xac));
assert.strictEqual(tdRem.remaining, 0);
// 3. TextDecoder passes through string input unchanged
const tdStr = new TextDecoder();
assert.strictEqual(tdStr.push('already string'), 'already string');
assert.strictEqual(tdStr.push(' another string'), ' another string');
// 4. TextDecoder write method aliases push for stream compatibility
const tdWrite = new TextDecoder();
assert.strictEqual(tdWrite.write(Buffer.from('stream data ')), 'stream data ');
assert.strictEqual(tdWrite.write('string data'), 'string data');
// 5. TextDecoder end flushes any buffered bytes and resets remaining state to zero
const tdEnd = new TextDecoder();
tdEnd.push(Buffer.of(0xf0, 0x9f)); // partial sequence
assert.strictEqual(tdEnd.remaining, 2);
const flushed = tdEnd.end(); // flushes remaining
assert.strictEqual(tdEnd.remaining, 0, 'Remaining reset after end');
assert.strictEqual(typeof flushed, 'string');
const tdEndWithData = new TextDecoder();
const endResult = tdEndWithData.end(Buffer.from('final chunk'));
assert.strictEqual(endResult, 'final chunk');
// 6. TextDecoder supports pass-through encodings like ascii and hex, and throws on unsupported or unknown encodings
const tdAscii = new TextDecoder('ascii');
assert.strictEqual(tdAscii.push(Buffer.from('abc')), 'abc');
const tdHex = new TextDecoder('hex');
assert.strictEqual(tdHex.push(Buffer.from('hi')), '6869');
assert.throws(() => new TextDecoder('utf16le'), {
name: 'Error',
message: 'Unsupported encoding: utf16le'
});
assert.throws(() => new TextDecoder('base64'), {
name: 'Error',
message: 'Unsupported encoding: base64'
});
assert.throws(() => new TextDecoder('invalid-enc'), {
name: 'Error',
message: 'Unknown encoding: invalid-enc'
});
console.log('Contract tests passed successfully.');
Seeder de origem
anônimo