CodeSampleX

Exemplo

@malept/flatpak-bundler 0.4.0

Amostra verificada para npm @malept/flatpak-bundler 0.4.0. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: translateArch maps x64 and amd64…

sha256:478c825aff1ebdb866a22be85d8eda972001bf211be578298255478e05dcae0f

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
1
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-28

Caso

HOW
Objetivo
verify pkg:npm/%40malept/flatpak-bundler@0.4.0
Pacotes
Ambiente
node 22.23.2
Criado
2026-08-28T05:29:49Z

Contrato

  1. translateArch maps x64 and amd64 architecture identifiers to x86_64
  2. translateArch maps ia32 architecture identifier to i386
  3. translateArch maps armv7l architecture identifier to arm
  4. translateArch preserves unmapped architecture identifiers without modification
  5. translateArch handles null and undefined inputs by returning them unchanged
  6. bundle is exported as an async function on the package namespace
  7. bundle rejects with an error when flatpak tools are unavailable in the host environment

Arquivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • test/contract.mjs

Baixar o artefato de código-fonte (tar.gz)

Código-fonte

PROMPT.md
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/%40malept/flatpak-bundler@0.4.0
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40malept/flatpak-bundler@0.4.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.
csx.json
{"case":{"caseId":"case:sha256:e6c140a94f27d827b149cc82a9b24c6f517726288eac7a473b4b7cf26761ff77","constraints":{"executionContext":"node"},"contract":["translateArch maps x64 and amd64 architecture identifiers to x86_64","translateArch maps ia32 architecture identifier to i386","translateArch maps armv7l architecture identifier to arm","translateArch preserves unmapped architecture identifiers without modification","translateArch handles null and undefined inputs by returning them unchanged","bundle is exported as an async function on the package namespace","bundle rejects with an error when flatpak tools are unavailable in the host environment"],"goal":"verify pkg:npm/%40malept/flatpak-bundler@0.4.0","kind":"HOW","packages":["pkg:npm/%40malept/flatpak-bundler@0.4.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/%40malept/flatpak-bundler@0.4.0"],"schemaVersion":1,"subject":"pkg:npm/%40malept/flatpak-bundler@0.4.0","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-flatpak-bundler",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-flatpak-bundler",
      "version": "1.0.0",
      "dependencies": {
        "@malept/flatpak-bundler": "0.4.0"
      }
    },
    "node_modules/@malept/flatpak-bundler": {
      "version": "0.4.0",
      "resolved": "https://registry.npmjs.org/@malept/flatpak-bundler/-/flatpak-bundler-0.4.0.tgz",
      "integrity": "sha512-9QOtNffcOF/c1seMCDnjckb3R9WHcG34tky+FHpNKKCW0wc/scYLwMtO+ptyGUfMW0/b/n4qRiALlaFHc9Oj7Q==",
      "license": "MIT",
      "dependencies": {
        "debug": "^4.1.1",
        "fs-extra": "^9.0.0",
        "lodash": "^4.17.15",
        "tmp-promise": "^3.0.2"
      },
      "engines": {
        "node": ">= 10.0.0"
      }
    },
    "node_modules/at-least-node": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz",
      "integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==",
      "license": "ISC",
      "engines": {
        "node": ">= 4.0.0"
      }
    },
    "node_modules/debug": {
      "version": "4.4.3",
      "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
      "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
      "license": "MIT",
      "dependencies": {
        "ms": "^2.1.3"
      },
      "engines": {
        "node": ">=6.0"
      },
      "peerDependenciesMeta": {
        "supports-color": {
          "optional": true
        }
      }
    },
    "node_modules/fs-extra": {
      "version": "9.1.0",
      "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.1.0.tgz",
      "integrity": "sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==",
      "license": "MIT",
      "dependencies": {
        "at-least-node": "^1.0.0",
        "graceful-fs": "^4.2.0",
        "jsonfile": "^6.0.1",
        "universalify": "^2.0.0"
      },
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/graceful-fs": {
      "version": "4.2.11",
      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
      "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
      "license": "ISC"
    },
    "node_modules/jsonfile": {
      "version": "6.2.1",
      "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz",
      "integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==",
      "license": "MIT",
      "dependencies": {
        "universalify": "^2.0.0"
      },
      "optionalDependencies": {
        "graceful-fs": "^4.1.6"
      }
    },
    "node_modules/lodash": {
      "version": "4.18.1",
      "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.18.1.tgz",
      "integrity": "sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==",
      "license": "MIT"
    },
    "node_modules/ms": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
      "license": "MIT"
    },
    "node_modules/tmp": {
      "version": "0.2.7",
      "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.7.tgz",
      "integrity": "sha512-e0votIpp4Uo2AJYSzVHV6xCcawuiez3DzqDAbrTc3YxBkplN6e+dM13ZeIcZnDg/QpSuU2zfZ3rzwY8ukEnaXw==",
      "license": "MIT",
      "engines": {
        "node": ">=14.14"
      }
    },
    "node_modules/tmp-promise": {
      "version": "3.0.3",
      "resolved": "https://registry.npmjs.org/tmp-promise/-/tmp-promise-3.0.3.tgz",
      "integrity": "sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ==",
      "license": "MIT",
      "dependencies": {
        "tmp": "^0.2.0"
      }
    },
    "node_modules/universalify": {
      "version": "2.0.1",
      "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
      "integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
      "license": "MIT",
      "engines": {
        "node": ">= 10.0.0"
      }
    }
  }
}
package.json
{
  "name": "sample-flatpak-bundler",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for @malept/flatpak-bundler",
  "main": "src/index.js",
  "dependencies": {
    "@malept/flatpak-bundler": "0.4.0"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40malept/flatpak-bundler@0.4.0",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40malept/flatpak-bundler@0.4.0"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const flatpakBundler = require('@malept/flatpak-bundler');

/**
 * Translates a Node.js architecture string into a Flatpak-compatible architecture string.
 *
 * @param {string} arch - Node.js architecture identifier (e.g. 'x64', 'ia32', 'armv7l', 'arm64')
 * @returns {string} The corresponding Flatpak architecture string.
 */
function resolveFlatpakArch(arch) {
  return flatpakBundler.translateArch(arch);
}

/**
 * Validates and prepares bundle options by translating architecture and invoking flatpak bundler.
 *
 * @param {object} manifest - Flatpak manifest configuration
 * @param {object} options - Build options
 * @returns {Promise<object>} Resulting build options after defaults
 */
async function createBundle(manifest, options = {}) {
  return flatpakBundler.bundle(manifest, options);
}

module.exports = {
  bundle: flatpakBundler.bundle,
  translateArch: flatpakBundler.translateArch,
  resolveFlatpakArch,
  createBundle
};
test/contract.mjs
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
import os from 'node:os';
import path from 'node:path';
import fs from 'node:fs';

const require = createRequire(import.meta.url);
const bundler = require('../src/index.js');
const rawBundler = require('@malept/flatpak-bundler');

// 1. translateArch maps x64 and amd64 architecture identifiers to x86_64
assert.strictEqual(typeof bundler.translateArch, 'function', 'translateArch must be a function');
assert.strictEqual(bundler.translateArch, rawBundler.translateArch, 'translateArch export must match @malept/flatpak-bundler.translateArch');
assert.strictEqual(bundler.translateArch('x64'), 'x86_64');
assert.strictEqual(bundler.translateArch('amd64'), 'x86_64');
assert.strictEqual(bundler.resolveFlatpakArch('x64'), 'x86_64');
assert.strictEqual(bundler.resolveFlatpakArch('amd64'), 'x86_64');

// 2. translateArch maps ia32 architecture identifier to i386
assert.strictEqual(bundler.translateArch('ia32'), 'i386');
assert.strictEqual(bundler.resolveFlatpakArch('ia32'), 'i386');

// 3. translateArch maps armv7l architecture identifier to arm
assert.strictEqual(bundler.translateArch('armv7l'), 'arm');
assert.strictEqual(bundler.resolveFlatpakArch('armv7l'), 'arm');

// 4. translateArch preserves unmapped architecture identifiers without modification
assert.strictEqual(bundler.translateArch('arm64'), 'arm64');
assert.strictEqual(bundler.translateArch('riscv64'), 'riscv64');
assert.strictEqual(bundler.translateArch('s390x'), 's390x');
assert.strictEqual(bundler.translateArch('ppc64le'), 'ppc64le');
assert.strictEqual(bundler.translateArch('mips'), 'mips');
assert.strictEqual(bundler.resolveFlatpakArch('arm64'), 'arm64');

// 5. translateArch handles null and undefined inputs by returning them unchanged
assert.strictEqual(bundler.translateArch(undefined), undefined);
assert.strictEqual(bundler.translateArch(null), null);
assert.strictEqual(bundler.translateArch(''), '');

// 6. bundle is exported as an async function on the package namespace
assert.strictEqual(typeof bundler.bundle, 'function', 'bundle must be a function');
assert.strictEqual(bundler.bundle, rawBundler.bundle, 'bundle export must match @malept/flatpak-bundler.bundle');
assert.strictEqual(typeof bundler.createBundle, 'function', 'createBundle wrapper must be a function');

// 7. bundle rejects with an error when flatpak tools are unavailable in the host environment
const tempWorkDir = fs.mkdtempSync(path.join(os.tmpdir(), 'flatpak-bundler-test-'));
try {
  await assert.rejects(
    async () => {
      await bundler.bundle(
        {
          id: 'org.example.TestApp',
          runtime: 'org.freedesktop.Platform',
          runtimeVersion: '23.08',
          sdk: 'org.freedesktop.Sdk'
        },
        {
          workingDir: tempWorkDir,
          arch: 'x64',
          cleanTmpdirs: true
        }
      );
    },
    (err) => {
      assert.ok(err instanceof Error, 'bundle must reject with an Error instance');
      return true;
    }
  );
} finally {
  fs.rmSync(tempWorkDir, { recursive: true, force: true });
}

console.log('All flatpak-bundler contract assertions passed.');

Seeder de origem

anônimo