Ejemplo
tmp 0.2.7
Muestra verificada para npm tmp 0.2.7. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: tmp.fileSync creates a temporary file…
sha256:cec058791603add11e4bacc8a622c8e35561e6dfda019b59fc340ffa9c31a330
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
linux 24 · ubuntu · glibc 2.39 x64 npm
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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-28 |
Caso
HOW- Objetivo
- verify pkg:npm/tmp@0.2.7
- Paquetes
- Creado
- 2026-08-28T05:06:31Z
Contrato
- tmp.fileSync creates a temporary file synchronously returning name, fd, and removeCallback
- tmp.dirSync creates a temporary directory synchronously and removeCallback removes it
- tmp.file creates a temporary file asynchronously and passes path, fd, and cleanupCallback to the callback
- tmp.dir creates a temporary directory asynchronously and passes path and cleanupCallback to the callback
- tmp.tmpNameSync generates a unique temporary path matching prefix and postfix options
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Código fuente
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/tmp@0.2.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/tmp@0.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:e567298fe4893cc68dfa3389ba9b6a44eed7b9ce885fb93e0c1de33ce89227c8","contract":["tmp.fileSync creates a temporary file synchronously returning name, fd, and removeCallback","tmp.dirSync creates a temporary directory synchronously and removeCallback removes it","tmp.file creates a temporary file asynchronously and passes path, fd, and cleanupCallback to the callback","tmp.dir creates a temporary directory asynchronously and passes path and cleanupCallback to the callback","tmp.tmpNameSync generates a unique temporary path matching prefix and postfix options"],"goal":"verify pkg:npm/tmp@0.2.7","kind":"HOW","packages":["pkg:npm/tmp@0.2.7"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"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/tmp@0.2.7"],"schemaVersion":1,"subject":"pkg:npm/tmp@0.2.7","verifierAdapter":"node-typescript@1"}
{
"name": "sample-tmp",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-tmp",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"tmp": "0.2.7"
}
},
"node_modules/tmp": {
"version": "0.2.7",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz",
"integrity": "sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==",
"license": "MIT",
"engines": {
"node": ">=14.14"
}
}
}
}
{
"name": "sample-tmp",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for tmp",
"main": "src/index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"tmp": "0.2.7"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/tmp@0.2.7",
"kind": "HOW",
"packages": [
"pkg:npm/tmp@0.2.7"
]
}
const tmp = require('tmp');
function createTempFile(options) {
return tmp.fileSync(options);
}
function createTempDir(options) {
return tmp.dirSync(options);
}
function generateTempName(options) {
return tmp.tmpNameSync(options);
}
module.exports = {
createTempFile,
createTempDir,
generateTempName,
tmp
};
const assert = require('node:assert');
const fs = require('node:fs');
const path = require('node:path');
const tmp = require('tmp');
const { createTempFile, createTempDir, generateTempName } = require('../src/index.js');
async function runTests() {
// 1. tmp.fileSync creates a temporary file and returns name, fd, and removeCallback
const tmpFile = createTempFile({ prefix: 'test-file-', postfix: '.tmp' });
assert.strictEqual(typeof tmpFile.name, 'string', 'tmpFile.name should be a string');
assert.strictEqual(typeof tmpFile.fd, 'number', 'tmpFile.fd should be a number');
assert.strictEqual(typeof tmpFile.removeCallback, 'function', 'tmpFile.removeCallback should be a function');
assert.strictEqual(fs.existsSync(tmpFile.name), true, 'temporary file should exist on disk');
fs.writeSync(tmpFile.fd, Buffer.from('test data'));
tmpFile.removeCallback();
assert.strictEqual(fs.existsSync(tmpFile.name), false, 'temporary file should be removed after sync cleanup');
// 2. tmp.dirSync creates a temporary directory and removeCallback removes it
const tmpDir = createTempDir({ prefix: 'test-dir-', unsafeCleanup: true });
assert.strictEqual(typeof tmpDir.name, 'string', 'tmpDir.name should be a string');
assert.strictEqual(typeof tmpDir.removeCallback, 'function', 'tmpDir.removeCallback should be a function');
assert.strictEqual(fs.existsSync(tmpDir.name), true, 'temporary directory should exist on disk');
const nestedFile = path.join(tmpDir.name, 'nested.txt');
fs.writeFileSync(nestedFile, 'nested content');
assert.strictEqual(fs.existsSync(nestedFile), true, 'nested file should exist in temp dir');
tmpDir.removeCallback();
assert.strictEqual(fs.existsSync(tmpDir.name), false, 'temporary directory should be removed after sync cleanup');
// 3. tmp.file creates a temporary file asynchronously and cleanupCallback removes it
await new Promise((resolve, reject) => {
tmp.file({ prefix: 'async-file-', postfix: '.dat' }, (err, filePath, fd, cleanupCallback) => {
if (err) return reject(err);
try {
assert.strictEqual(typeof filePath, 'string', 'filePath should be a string');
assert.strictEqual(typeof fd, 'number', 'fd should be a number');
assert.strictEqual(typeof cleanupCallback, 'function', 'cleanupCallback should be a function');
assert.strictEqual(fs.existsSync(filePath), true, 'async temporary file should exist');
cleanupCallback((cleanupErr) => {
if (cleanupErr) return reject(cleanupErr);
try {
assert.strictEqual(fs.existsSync(filePath), false, 'async temporary file should be removed after async cleanup');
resolve();
} catch (e) {
reject(e);
}
});
} catch (e) {
reject(e);
}
});
});
// 4. tmp.dir creates a temporary directory asynchronously and cleanupCallback removes it
await new Promise((resolve, reject) => {
tmp.dir({ prefix: 'async-dir-', unsafeCleanup: true }, (err, dirPath, cleanupCallback) => {
if (err) return reject(err);
try {
assert.strictEqual(typeof dirPath, 'string', 'dirPath should be a string');
assert.strictEqual(typeof cleanupCallback, 'function', 'cleanupCallback should be a function');
assert.strictEqual(fs.existsSync(dirPath), true, 'async temporary directory should exist');
cleanupCallback((cleanupErr) => {
if (cleanupErr) return reject(cleanupErr);
try {
assert.strictEqual(fs.existsSync(dirPath), false, 'async temporary directory should be removed after async cleanup');
resolve();
} catch (e) {
reject(e);
}
});
} catch (e) {
reject(e);
}
});
});
// 5. tmp.tmpNameSync generates a unique temporary path matching prefix and postfix options
const generatedName = generateTempName({ prefix: 'custom-pref-', postfix: '.custom' });
assert.strictEqual(typeof generatedName, 'string', 'generatedName should be a string');
assert.strictEqual(path.basename(generatedName).startsWith('custom-pref-'), true, 'name should start with prefix');
assert.strictEqual(generatedName.endsWith('.custom'), true, 'name should end with postfix');
assert.strictEqual(fs.existsSync(generatedName), false, 'generated tempName should not exist prior to creation');
console.log('Contract tests passed successfully.');
}
runTests().catch(err => {
console.error(err);
process.exit(1);
});
Seeder de origen
anónimo