Exemple
mime-db 1.54.0
Échantillon vérifié pour npm mime-db 1.54.0. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : mime-db contains standard MIME…
sha256:09c1ef55abc26fb5d675288ee8ba2dc4fd875ded538d421dd0c3791a7f16cea5
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é
windows 11 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:2175b912ea1c23b1 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-19 |
Cas
HOW- Objectif
- verify pkg:npm/mime-db@1.54.0
- Paquets
- Créé
- 2026-08-18T18:10:20Z
Contrat
- mime-db contains standard MIME type entries with source, extensions, charset, and compressible metadata
- db['application/json'] defines charset UTF-8, compressible true, and json extension
- db['text/html'] defines compressible true and html, htm extensions
- db['image/png'] defines non-compressible media type with png extension
- lookup retrieves MIME metadata for registered types and returns undefined for unknown types
- findTypeByExtension maps file extensions to corresponding media types
- isCompressible correctly identifies compressible text and data formats
- getExtensions retrieves all associated file extensions for a given MIME type
Fichiers
- PROMPT.md
- csx.json
- index.mjs
- 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/mime-db@1.54.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/mime-db@1.54.0
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:b3849d76cf31ccf2829ffb23ad948d8019d09175d758ce809ba865e0ef61a25f","contract":["mime-db contains standard MIME type entries with source, extensions, charset, and compressible metadata","db['application/json'] defines charset UTF-8, compressible true, and json extension","db['text/html'] defines compressible true and html, htm extensions","db['image/png'] defines non-compressible media type with png extension","lookup retrieves MIME metadata for registered types and returns undefined for unknown types","findTypeByExtension maps file extensions to corresponding media types","isCompressible correctly identifies compressible text and data formats","getExtensions retrieves all associated file extensions for a given MIME type"],"goal":"verify pkg:npm/mime-db@1.54.0","kind":"HOW","packages":["pkg:npm/mime-db@1.54.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","ecosystem":"npm","os":"windows","osVersionBucket":"11","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/mime-db@1.54.0"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
import db from 'mime-db';
/**
* Returns the MIME type entry for a given media type.
* @param {string} type
* @returns {object|undefined}
*/
export function lookup(type) {
return db[type.toLowerCase()];
}
/**
* Finds the first MIME type that has the given file extension.
* @param {string} extension
* @returns {string|undefined}
*/
export function findTypeByExtension(extension) {
const ext = extension.toLowerCase().replace(/^\./, '');
for (const [type, data] of Object.entries(db)) {
if (data.extensions && data.extensions.includes(ext)) {
return type;
}
}
return undefined;
}
/**
* Checks if a given MIME type is marked as compressible.
* @param {string} type
* @returns {boolean}
*/
export function isCompressible(type) {
const entry = db[type.toLowerCase()];
return Boolean(entry && entry.compressible);
}
/**
* Returns the file extensions associated with a given MIME type.
* @param {string} type
* @returns {string[]}
*/
export function getExtensions(type) {
const entry = db[type.toLowerCase()];
return entry && entry.extensions ? [...entry.extensions] : [];
}
/**
* Returns the default charset for a given MIME type.
* @param {string} type
* @returns {string|undefined}
*/
export function getCharset(type) {
const entry = db[type.toLowerCase()];
return entry ? entry.charset : undefined;
}
export { db };
{
"name": "sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample",
"version": "1.0.0",
"dependencies": {
"mime-db": "1.54.0"
}
},
"node_modules/mime-db": {
"version": "1.54.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",
"integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
}
}
}
{
"name": "sample",
"version": "1.0.0",
"type": "module",
"dependencies": {
"mime-db": "1.54.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/mime-db@1.54.0",
"kind": "HOW",
"packages": [
"pkg:npm/mime-db@1.54.0"
]
}
import assert from 'node:assert/strict';
import db from 'mime-db';
import {
lookup,
findTypeByExtension,
isCompressible,
getExtensions,
getCharset,
db as exportedDb
} from '../index.mjs';
// Case 1: database contains standard MIME entries
{
assert.equal(typeof db, 'object', 'mime-db export must be an object');
assert(Object.keys(db).length > 1000, 'mime-db should contain thousands of MIME type entries');
assert.equal(exportedDb, db, 'exported db must match imported db');
}
// Case 2: application/json entry validation
{
const jsonEntry = db['application/json'];
assert.ok(jsonEntry, 'application/json entry must exist');
assert.equal(jsonEntry.source, 'iana', 'application/json source must be iana');
assert.equal(jsonEntry.charset, 'UTF-8', 'application/json charset must be UTF-8');
assert.equal(jsonEntry.compressible, true, 'application/json must be compressible');
assert.ok(Array.isArray(jsonEntry.extensions), 'application/json extensions must be an array');
assert(jsonEntry.extensions.includes('json'), 'application/json must include "json" extension');
}
// Case 3: text/html entry validation
{
const htmlEntry = db['text/html'];
assert.ok(htmlEntry, 'text/html entry must exist');
assert.equal(htmlEntry.source, 'iana', 'text/html source must be iana');
assert.equal(htmlEntry.compressible, true, 'text/html must be compressible');
assert.ok(htmlEntry.extensions.includes('html'), 'text/html extensions must include "html"');
assert.ok(htmlEntry.extensions.includes('htm'), 'text/html extensions must include "htm"');
}
// Case 4: image/png entry validation
{
const pngEntry = db['image/png'];
assert.ok(pngEntry, 'image/png entry must exist');
assert.equal(pngEntry.compressible, false, 'image/png compressible must be false');
assert.deepEqual(pngEntry.extensions, ['png'], 'image/png extensions must be ["png"]');
}
// Case 5: lookup wrapper function
{
assert.deepEqual(lookup('application/json'), db['application/json'], 'lookup should find application/json');
assert.deepEqual(lookup('TEXT/HTML'), db['text/html'], 'lookup should be case-insensitive');
assert.equal(lookup('non-existent/fake-type'), undefined, 'lookup should return undefined for unknown types');
}
// Case 6: findTypeByExtension wrapper function
{
assert.equal(findTypeByExtension('json'), 'application/json', 'extension "json" should map to application/json');
assert.equal(findTypeByExtension('.html'), 'text/html', 'extension ".html" with leading dot should map to text/html');
assert.equal(findTypeByExtension('PNG'), 'image/png', 'case-insensitive extension lookup should work');
assert.equal(findTypeByExtension('nonexistentext12345'), undefined, 'unknown extension should return undefined');
}
// Case 7: isCompressible wrapper function
{
assert.equal(isCompressible('text/html'), true, 'text/html must be compressible');
assert.equal(isCompressible('application/json'), true, 'application/json must be compressible');
assert.equal(isCompressible('image/png'), false, 'image/png must not be compressible');
assert.equal(isCompressible('unknown/type'), false, 'unknown type should not be compressible');
}
// Case 8: getExtensions and getCharset wrapper functions
{
const htmlExts = getExtensions('text/html');
assert.ok(htmlExts.includes('html') && htmlExts.includes('htm'), 'getExtensions should return html extensions');
assert.deepEqual(getExtensions('unknown/type'), [], 'getExtensions should return empty array for unknown types');
assert.equal(getCharset('application/json'), 'UTF-8', 'getCharset should return UTF-8 for application/json');
assert.equal(getCharset('unknown/type'), undefined, 'getCharset should return undefined for unknown types');
}
console.log('PASS: all mime-db contract assertions passed');
Seeder d'origine
anonyme