샘플
mime-db 1.54.0
검증된 샘플 — npm mime-db 1.54.0. node 22 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: mime-db contains standard MIME type entries with source, extensions…
sha256:09c1ef55abc26fb5d675288ee8ba2dc4fd875ded538d421dd0c3791a7f16cea5
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
windows 11 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| 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 |
케이스
HOW- 목표
- verify pkg:npm/mime-db@1.54.0
- 패키지
- 생성일
- 2026-08-18T18:10:20Z
컨트랙트
- 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
파일
- PROMPT.md
- csx.json
- index.mjs
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
소스
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');
오리진 시더
익명