Exemplo
convert-source-map 2.0.0
Amostra verificada para npm convert-source-map 2.0.0. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: fromObject converts a source map…
sha256:31989c2b5ebccf8fb18d68c01a2306c7c4431e0c20bdf78759619331a3c340ff
Esta rede oferece uma coisa: uma amostra que compila. Ela a executou em um sandbox e guardou o recibo assinado. Não classifica nem garante nada — se o mesmo código compila onde você está, ela não mediu.
Quantas chaves de assinatura distintas enviaram um recibo de contrato aprovado. Uma é só o autor; mais de uma significa que outra pessoa também o compilou. Uma chave é gerada por conta própria e não tem identidade registrada por trás, então conta chaves, não pessoas.
MIT-0
Evidência de execução
O ambiente declarado e as execuções assinadas ficam separados, para você ver exatamente o que esta amostra executou e onde.
- Base da evidência
- Contrato assinado aprovado
- Recibos de verificação
- 2
- Chaves de assinatura que o compilaram
- 1
Ambiente declarado
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Ambientes das execuções de verificação
| Ambiente | Contrato | Etapas | Execução |
|---|---|---|---|
| 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 |
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-07 |
Caso
HOW- Objetivo
- verify pkg:npm/convert-source-map@2.0.0
- Pacotes
- Ambiente
- node 22.23.2
- Criado
- 2026-08-25T02:34:41Z
Contrato
- fromObject converts a source map object and returns new copy via toObject and JSON string via toJSON
- fromJSON parses a source map JSON string and allows modifying properties via getProperty, setProperty, and addProperty
- fromBase64 and toBase64 convert between base64-encoded strings and source map objects
- fromComment and toComment parse and format inline base64 and URI-encoded sourceMappingURL comments
- fromSource finds the last inline source map comment from source code or returns null if absent
- removeComments and removeMapFileComments strip inline data URIs and external map file comments from source text
- generateMapFileComment formats single-line and multi-line sourceMappingURL references to map files
- fromMapFileComment reads map file content using a custom reader function
Arquivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Código-fonte
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@2.0.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/convert-source-map@2.0.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
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:ea77ca5ba5a7f7298fe4423f887787d9b1d65aa5a5dbe0bb6661db739e3d06e2","constraints":{"executionContext":"node"},"contract":["fromObject converts a source map object and returns new copy via toObject and JSON string via toJSON","fromJSON parses a source map JSON string and allows modifying properties via getProperty, setProperty, and addProperty","fromBase64 and toBase64 convert between base64-encoded strings and source map objects","fromComment and toComment parse and format inline base64 and URI-encoded sourceMappingURL comments","fromSource finds the last inline source map comment from source code or returns null if absent","removeComments and removeMapFileComments strip inline data URIs and external map file comments from source text","generateMapFileComment formats single-line and multi-line sourceMappingURL references to map files","fromMapFileComment reads map file content using a custom reader function"],"goal":"verify pkg:npm/convert-source-map@2.0.0","kind":"HOW","packages":["pkg:npm/convert-source-map@2.0.0"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","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@2.0.0"],"schemaVersion":1,"subject":"pkg:npm/convert-source-map@2.0.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": "2.0.0"
}
},
"node_modules/convert-source-map": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",
"integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",
"license": "MIT"
}
}
}
{
"name": "sample-convert-source-map",
"version": "1.0.0",
"private": true,
"dependencies": {
"convert-source-map": "2.0.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/convert-source-map@2.0.0",
"kind": "HOW",
"packages": [
"pkg:npm/convert-source-map@2.0.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import convert from 'convert-source-map';
const rawMap = {
version: 3,
file: 'min.js',
names: ['bar', 'baz'],
sources: ['one.js', 'two.js'],
sourceRoot: 'http://example.com/www/js/',
mappings: 'CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,OAAU,GACrB',
};
// 1. fromObject converts a source map object and returns new copy via toObject and JSON string via toJSON
{
const conv = convert.fromObject(rawMap);
const obj = conv.toObject();
assert.deepEqual(obj, rawMap);
assert.notEqual(obj, rawMap);
const jsonStr = conv.toJSON();
assert.equal(typeof jsonStr, 'string');
assert.deepEqual(JSON.parse(jsonStr), rawMap);
}
// 2. fromJSON parses a source map JSON string and allows modifying properties via getProperty, setProperty, and addProperty
{
const json = JSON.stringify(rawMap);
const conv = convert.fromJSON(json);
assert.equal(conv.getProperty('file'), 'min.js');
conv.setProperty('file', 'bundle.min.js');
assert.equal(conv.getProperty('file'), 'bundle.min.js');
conv.addProperty('x_custom', 'custom-value');
assert.equal(conv.getProperty('x_custom'), 'custom-value');
assert.throws(
() => {
conv.addProperty('file', 'other.js');
},
{
name: 'Error',
message: 'property "file" already exists on the sourcemap, use set property instead',
}
);
}
// 3. fromBase64 and toBase64 convert between base64-encoded strings and source map objects
{
const conv = convert.fromObject(rawMap);
const base64 = conv.toBase64();
assert.equal(typeof base64, 'string');
const parsed = convert.fromBase64(base64);
assert.deepEqual(parsed.toObject(), rawMap);
}
// 4. fromComment and toComment parse and format inline base64 and URI-encoded sourceMappingURL comments
{
const conv = convert.fromObject(rawMap);
const singleLineComment = conv.toComment();
assert.ok(singleLineComment.startsWith('//# sourceMappingURL=data:application/json;charset=utf-8;base64,'));
const parsedFromSingle = convert.fromComment(singleLineComment);
assert.deepEqual(parsedFromSingle.toObject(), rawMap);
const multiLineComment = conv.toComment({ multiline: true });
assert.ok(multiLineComment.startsWith('/*# sourceMappingURL=data:application/json;charset=utf-8;base64,'));
assert.ok(multiLineComment.endsWith(' */'));
const parsedFromMulti = convert.fromComment(multiLineComment);
assert.deepEqual(parsedFromMulti.toObject(), rawMap);
const uriComment = conv.toComment({ encoding: 'uri' });
assert.ok(uriComment.startsWith('//# sourceMappingURL=data:application/json;charset=utf-8,'));
const parsedFromUri = convert.fromComment(uriComment);
assert.deepEqual(parsedFromUri.toObject(), rawMap);
}
// 5. fromSource finds the last inline source map comment from source code or returns null if absent
{
const conv = convert.fromObject(rawMap);
const comment = conv.toComment();
const sourceCode = `function foo() { return 42; }\n${comment}`;
const extracted = convert.fromSource(sourceCode);
assert.ok(extracted);
assert.deepEqual(extracted.toObject(), rawMap);
const noCommentCode = 'function bar() { return 1; }';
assert.equal(convert.fromSource(noCommentCode), null);
}
// 6. removeComments and removeMapFileComments strip inline data URIs and external map file comments from source text
{
const inlineComment = convert.fromObject(rawMap).toComment();
const codeWithInline = `console.log("hello");\n${inlineComment}\n`;
const codeWithoutInline = convert.removeComments(codeWithInline);
assert.equal(codeWithoutInline.trim(), 'console.log("hello");');
const mapFileComment = convert.generateMapFileComment('bundle.js.map');
const codeWithMapFile = `console.log("world");\n${mapFileComment}\n`;
const codeWithoutMapFile = convert.removeMapFileComments(codeWithMapFile);
assert.equal(codeWithoutMapFile.trim(), 'console.log("world");');
}
// 7. generateMapFileComment formats single-line and multi-line sourceMappingURL references to map files
{
const single = convert.generateMapFileComment('app.min.js.map');
assert.equal(single, '//# sourceMappingURL=app.min.js.map');
const multi = convert.generateMapFileComment('app.min.js.map', { multiline: true });
assert.equal(multi, '/*# sourceMappingURL=app.min.js.map */');
}
// 8. fromMapFileComment reads map file content using a custom reader function
{
const comment = '//# sourceMappingURL=mapfile.json';
const readFn = (filename) => {
assert.equal(filename, 'mapfile.json');
return JSON.stringify(rawMap);
};
const conv = convert.fromMapFileComment(comment, readFn);
assert.deepEqual(conv.toObject(), rawMap);
}
Seeder de origem
anônimo