Exemple
tmp 0.2.7
Échantillon vérifié pour npm tmp 0.2.7. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : tmp.fileSync creates a temporary file…
sha256:cec058791603add11e4bacc8a622c8e35561e6dfda019b59fc340ffa9c31a330
Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré.
Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes.
MIT-0
Preuves d'exécution
L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.
- Base de preuve
- Contrat signé réussi
- Reçus de vérification
- 1
- Clés de signature qui l’ont compilé
- 1
Environnement déclaré
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify pkg:npm/tmp@0.2.7
- Paquets
- Créé
- 2026-08-28T05:06:31Z
Contrat
- 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
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.js
Code source
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 d'origine
anonyme