Exemple
env-paths 2.2.1
Échantillon vérifié pour npm env-paths 2.2.1. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : Calling envPaths returns…
sha256:7cb9d06d647edb45d2d6256d62cd9eb6300e3012c4d1381b32686b718aefc8ef
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-23 |
Cas
HOW- Objectif
- verify pkg:npm/env-paths@2.2.1
- Paquets
- Créé
- 2026-08-23T13:29:34Z
Contrat
- Calling envPaths returns standard XDG paths on Linux including data, config, cache, log, and temp directories
- Calling envPaths with default options appends the '-nodejs' suffix to the application directory name
- Setting suffix option to false disables the suffix and uses the bare application name
- Setting suffix option to a custom string appends the custom suffix to the application directory name
- Passing a non-string name argument throws a TypeError
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
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/env-paths@2.2.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/env-paths@2.2.1
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:c192eef179b812cd173899e4a6bd06e84ba93d356d0e04567b3940e01200b438","contract":["Calling envPaths returns standard XDG paths on Linux including data, config, cache, log, and temp directories","Calling envPaths with default options appends the '-nodejs' suffix to the application directory name","Setting suffix option to false disables the suffix and uses the bare application name","Setting suffix option to a custom string appends the custom suffix to the application directory name","Passing a non-string name argument throws a TypeError"],"goal":"verify pkg:npm/env-paths@2.2.1","kind":"HOW","packages":["pkg:npm/env-paths@2.2.1"],"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/env-paths@2.2.1"],"schemaVersion":1,"subject":"pkg:npm/env-paths@2.2.1","verifierAdapter":"node-typescript@1"}
{
"name": "sample-env-paths",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-env-paths",
"version": "1.0.0",
"dependencies": {
"env-paths": "2.2.1"
}
},
"node_modules/env-paths": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz",
"integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==",
"license": "MIT",
"engines": {
"node": ">=6"
}
}
}
}
{
"name": "sample-env-paths",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"env-paths": "2.2.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/env-paths@2.2.1",
"kind": "HOW",
"packages": [
"pkg:npm/env-paths@2.2.1"
]
}
import assert from 'node:assert/strict';
import os from 'node:os';
import path from 'node:path';
import process from 'node:process';
import envPaths from 'env-paths';
// 1. envPaths returns an object containing data, config, cache, log, and temp directory paths
{
const paths = envPaths('myapp', { suffix: false });
assert.equal(typeof paths, 'object');
assert.ok(typeof paths.data === 'string' && paths.data.length > 0);
assert.ok(typeof paths.config === 'string' && paths.config.length > 0);
assert.ok(typeof paths.cache === 'string' && paths.cache.length > 0);
assert.ok(typeof paths.log === 'string' && paths.log.length > 0);
assert.ok(typeof paths.temp === 'string' && paths.temp.length > 0);
const homedir = os.homedir();
const tmpdir = os.tmpdir();
const username = path.basename(homedir);
const expectedData = process.env.XDG_DATA_HOME || path.join(homedir, '.local', 'share');
const expectedConfig = process.env.XDG_CONFIG_HOME || path.join(homedir, '.config');
const expectedCache = process.env.XDG_CACHE_HOME || path.join(homedir, '.cache');
const expectedLog = process.env.XDG_STATE_HOME || path.join(homedir, '.local', 'state');
const expectedTemp = path.join(tmpdir, username, 'myapp');
assert.equal(paths.data, path.join(expectedData, 'myapp'));
assert.equal(paths.config, path.join(expectedConfig, 'myapp'));
assert.equal(paths.cache, path.join(expectedCache, 'myapp'));
assert.equal(paths.log, path.join(expectedLog, 'myapp'));
assert.equal(paths.temp, expectedTemp);
}
// 2. envPaths defaults to appending '-nodejs' suffix to the provided application name
{
const paths = envPaths('myapp');
assert.ok(paths.data.endsWith('myapp-nodejs'));
assert.ok(paths.config.endsWith('myapp-nodejs'));
assert.ok(paths.cache.endsWith('myapp-nodejs'));
assert.ok(paths.log.endsWith('myapp-nodejs'));
assert.ok(paths.temp.endsWith('myapp-nodejs'));
}
// 3. envPaths with suffix option set to false disables suffixing and keeps the original application name
{
const paths = envPaths('myapp', { suffix: false });
assert.ok(paths.data.endsWith(path.sep + 'myapp'));
assert.ok(!paths.data.endsWith('myapp-nodejs'));
}
// 4. envPaths with custom suffix option appends the custom suffix string to the application name
{
const paths = envPaths('myapp', { suffix: 'server' });
assert.ok(paths.data.endsWith('myapp-server'));
}
// 5. envPaths validates argument type and throws TypeError when name is not a string
{
assert.throws(
() => {
envPaths(12345);
},
{
name: 'TypeError',
message: 'Expected string, got number',
}
);
}
Seeder d'origine
anonyme