Ejemplo
convert-source-map 1.9.0
Muestra verificada para npm convert-source-map 1.9.0. El contrato se ejecutó en node 22 · linux alpine/x64 · docker y pasó: fromObject converts a source map…
sha256:3da0b0fb6d3493e7b5d2ecd2dcc0487399af4afe00f358d3189502ab22103033
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
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
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-25 |
Caso
HOW- Objetivo
- verify pkg:npm/convert-source-map@1.9.0
- Paquetes
- Entorno
- node 22.23.2
- Creado
- 2026-08-25T02:37:43Z
Contrato
- fromObject converts a source map object to a Converter with toComment and toJSON methods
- fromComment parses inline line and block sourceMappingURL comments into source map objects
- fromJSON and fromBase64 reconstruct source map converters from serialized formats
- fromSource extracts embedded inline source map from source code string
- removeComments strips inline source map comment annotations from source code
- setProperty and getProperty modify and inspect source map metadata properties
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- test/contract.mjs
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/convert-source-map@1.9.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/convert-source-map@1.9.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:d928a57238232f7f02686681914c9f0c7007076e6c2718c8c8718183192e4741","contract":["fromObject converts a source map object to a Converter with toComment and toJSON methods","fromComment parses inline line and block sourceMappingURL comments into source map objects","fromJSON and fromBase64 reconstruct source map converters from serialized formats","fromSource extracts embedded inline source map from source code string","removeComments strips inline source map comment annotations from source code","setProperty and getProperty modify and inspect source map metadata properties"],"goal":"verify pkg:npm/convert-source-map@1.9.0","kind":"HOW","packages":["pkg:npm/convert-source-map@1.9.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/convert-source-map@1.9.0"],"schemaVersion":1,"subject":"pkg:npm/convert-source-map@1.9.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-convert-source-map",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-convert-source-map",
"version": "1.0.0",
"dependencies": {
"convert-source-map": "1.9.0"
}
},
"node_modules/convert-source-map": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz",
"integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==",
"license": "MIT"
}
}
}
{
"name": "sample-convert-source-map",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification of convert-source-map",
"main": "src/index.js",
"dependencies": {
"convert-source-map": "1.9.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/convert-source-map@1.9.0",
"kind": "HOW",
"packages": [
"pkg:npm/convert-source-map@1.9.0"
]
}
const convertSourceMap = require('convert-source-map');
/**
* Generate an inline sourceMappingURL comment from a source map object.
* @param {object} mapObject - Source map object.
* @param {object} [options] - Generation options.
* @param {boolean} [options.multiline=false] - Whether to generate a block comment.
* @returns {string} Inline comment string.
*/
function createSourceMapComment(mapObject, options = {}) {
const converter = convertSourceMap.fromObject(mapObject);
return converter.toComment(options);
}
/**
* Parse a source map object from an inline comment string.
* @param {string} comment - Inline comment containing source map.
* @returns {object|null} Parsed source map object, or null if invalid.
*/
function parseSourceMapFromComment(comment) {
const converter = convertSourceMap.fromComment(comment);
return converter ? converter.toObject() : null;
}
/**
* Extract and parse an inline source map from a source code string.
* @param {string} sourceCode - Source code containing inline source map.
* @returns {object|null} Parsed source map object, or null if not found.
*/
function parseSourceMapFromSource(sourceCode) {
const converter = convertSourceMap.fromSource(sourceCode);
return converter ? converter.toObject() : null;
}
/**
* Strip inline source map comments from source code.
* @param {string} sourceCode - Source code containing inline source maps.
* @returns {string} Source code without inline source map comments.
*/
function stripSourceMapComments(sourceCode) {
return convertSourceMap.removeComments(sourceCode);
}
/**
* Set a metadata property on a source map object.
* @param {object} mapObject - Source map object.
* @param {string} key - Property name.
* @param {any} value - Property value.
* @returns {object} Updated source map object.
*/
function modifySourceMapProperty(mapObject, key, value) {
const converter = convertSourceMap.fromObject(mapObject);
converter.setProperty(key, value);
return converter.toObject();
}
module.exports = {
convertSourceMap,
createSourceMapComment,
parseSourceMapFromComment,
parseSourceMapFromSource,
stripSourceMapComments,
modifySourceMapProperty
};
import assert from 'node:assert';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const {
convertSourceMap,
createSourceMapComment,
parseSourceMapFromComment,
parseSourceMapFromSource,
stripSourceMapComments,
modifySourceMapProperty
} = require('../src/index.js');
// 1. Export verification
assert.strictEqual(typeof convertSourceMap, 'object', 'convertSourceMap should be exported');
assert.strictEqual(typeof convertSourceMap.fromObject, 'function', 'fromObject should be a function');
assert.strictEqual(typeof convertSourceMap.fromJSON, 'function', 'fromJSON should be a function');
assert.strictEqual(typeof convertSourceMap.fromBase64, 'function', 'fromBase64 should be a function');
assert.strictEqual(typeof convertSourceMap.fromComment, 'function', 'fromComment should be a function');
assert.strictEqual(typeof convertSourceMap.fromSource, 'function', 'fromSource should be a function');
assert.strictEqual(typeof convertSourceMap.removeComments, 'function', 'removeComments should be a function');
assert.strictEqual(typeof createSourceMapComment, 'function', 'createSourceMapComment should be a function');
assert.strictEqual(typeof parseSourceMapFromComment, 'function', 'parseSourceMapFromComment should be a function');
assert.strictEqual(typeof parseSourceMapFromSource, 'function', 'parseSourceMapFromSource should be a function');
assert.strictEqual(typeof stripSourceMapComments, 'function', 'stripSourceMapComments should be a function');
assert.strictEqual(typeof modifySourceMapProperty, 'function', 'modifySourceMapProperty should be a function');
// 2. fromObject converts a source map object to a Converter with toComment and toJSON methods
const sampleMap = {
version: 3,
file: 'output.js',
sources: ['input.js'],
mappings: 'AAAA;'
};
const conv = convertSourceMap.fromObject(sampleMap);
assert.deepStrictEqual(conv.toObject(), sampleMap);
assert.strictEqual(typeof conv.toJSON(), 'string');
assert.strictEqual(typeof conv.toBase64(), 'string');
const lineComment = conv.toComment();
assert.ok(lineComment.startsWith('//# sourceMappingURL=data:application/json;charset=utf-8;base64,'));
const blockComment = conv.toComment({ multiline: true });
assert.ok(blockComment.startsWith('/*# sourceMappingURL=data:application/json;charset=utf-8;base64,'));
assert.ok(blockComment.endsWith('*/'));
// 3. fromComment parses inline line and block sourceMappingURL comments into source map objects
const parsedLine = parseSourceMapFromComment(lineComment);
assert.deepStrictEqual(parsedLine, sampleMap);
const parsedBlock = parseSourceMapFromComment(blockComment);
assert.deepStrictEqual(parsedBlock, sampleMap);
// 4. fromJSON and fromBase64 reconstruct source map converters from serialized formats
const jsonString = JSON.stringify(sampleMap);
const fromJsonConv = convertSourceMap.fromJSON(jsonString);
assert.deepStrictEqual(fromJsonConv.toObject(), sampleMap);
const base64String = Buffer.from(jsonString).toString('base64');
const fromBase64Conv = convertSourceMap.fromBase64(base64String);
assert.deepStrictEqual(fromBase64Conv.toObject(), sampleMap);
// 5. fromSource extracts embedded inline source map from source code string
const sampleCode = 'function hello() { return 1; }\n' + lineComment;
const parsedFromCode = parseSourceMapFromSource(sampleCode);
assert.deepStrictEqual(parsedFromCode, sampleMap);
// 6. removeComments strips inline source map comment annotations from source code
const stripped = stripSourceMapComments(sampleCode);
assert.strictEqual(stripped, 'function hello() { return 1; }\n');
assert.strictEqual(convertSourceMap.fromSource(stripped), null);
// 7. setProperty and getProperty modify and inspect source map metadata properties
const updatedMap = modifySourceMapProperty(sampleMap, 'sourcesContent', ['function hello() {}']);
assert.deepStrictEqual(updatedMap.sourcesContent, ['function hello() {}']);
assert.strictEqual(updatedMap.version, 3);
assert.strictEqual(updatedMap.file, 'output.js');
console.log('Contract tests passed successfully.');
Seeder de origen
anónimo