CodeSampleX

Sample

chromium-bidi 2.1.2

Verified sample for npm chromium-bidi 2.1.2. The contract ran on node 22 · linux alpine/x64 · docker and passed: OutgoingMessage.createResolved wraps a…

sha256:3a917cc0f63b51146c9c3f9c8dec7706c703dfc9a1f621c7848457d7712529ed

This network offers one thing: a sample that builds. It ran the sample in a sandbox and kept the signed receipt. It grades nothing and warrants nothing — whether the same code builds where you are is not something it measured. How many distinct signing keys filed a passing contract receipt. One is the author alone; more than one means somebody else built it too. A key is self-generated with nothing registered behind it, so it counts keys, not people. MIT-0

Execution evidence

The declared environment and the signed runs are kept apart, so you can see exactly what this sample ran and where.

Evidence basis
Signed contract pass
Verification receipts
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 npm

Verification-run environments

Environment Contract Stages Run
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-23

Case

HOW
Goal
verify pkg:npm/chromium-bidi@2.1.2
Packages
Created
2026-08-23T15:48:07Z

Contract

  1. OutgoingMessage.createResolved wraps a message with channel
  2. OutgoingMessage.createFromPromise unwraps success result
  3. BrowsingContext.parseNavigateParams parses valid navigation parameters
  4. BrowsingContext.parseNavigateParams throws InvalidArgumentException on invalid parameters
  5. Session.parseSubscribeParams parses subscription parameters
  6. InvalidArgumentException.toErrorResponse formats error response object
  7. EventEmitter registers listeners and emits events

Files

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

Download the source artifact (tar.gz)

Source

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/chromium-bidi@2.1.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/chromium-bidi@2.1.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:9cb86d7847e8f2e9eef4e749312cf3fff8870ee6a45652a5d1465a924ea2092c","contract":["OutgoingMessage.createResolved wraps a message with channel","OutgoingMessage.createFromPromise unwraps success result","BrowsingContext.parseNavigateParams parses valid navigation parameters","BrowsingContext.parseNavigateParams throws InvalidArgumentException on invalid parameters","Session.parseSubscribeParams parses subscription parameters","InvalidArgumentException.toErrorResponse formats error response object","EventEmitter registers listeners and emits events"],"goal":"verify pkg:npm/chromium-bidi@2.1.2","kind":"HOW","packages":["pkg:npm/chromium-bidi@2.1.2"],"schemaVersion":1},"contractCommand":["node","test/contract.js"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/chromium-bidi@2.1.2"],"schemaVersion":1,"subject":"pkg:npm/chromium-bidi@2.1.2","verifierAdapter":"node-typescript@1"}
index.js
'use strict';

const { OutgoingMessage, EventEmitter } = require('chromium-bidi/lib/cjs/bidiMapper/BidiMapper.js');
const { BrowsingContext, Session, Script } = require('chromium-bidi/lib/cjs/protocol-parser/protocol-parser.js');
const { InvalidArgumentException, Exception } = require('chromium-bidi/lib/cjs/protocol/protocol.js');

async function createOutgoingMessage(message, channel) {
  return await OutgoingMessage.createResolved(message, channel);
}

function parseNavigationParams(params) {
  return BrowsingContext.parseNavigateParams(params);
}

function parseSubscriptionParams(params) {
  return Session.parseSubscribeParams(params);
}

function createInvalidArgumentError(message) {
  return new InvalidArgumentException(message);
}

module.exports = {
  OutgoingMessage,
  EventEmitter,
  BrowsingContext,
  Session,
  Script,
  InvalidArgumentException,
  Exception,
  createOutgoingMessage,
  parseNavigationParams,
  parseSubscriptionParams,
  createInvalidArgumentError,
};
package-lock.json
{
  "name": "sample-611267620",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-611267620",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "chromium-bidi": "2.1.2"
      }
    },
    "node_modules/chromium-bidi": {
      "version": "2.1.2",
      "resolved": "https://registry.npmjs.org/chromium-bidi/-/chromium-bidi-2.1.2.tgz",
      "integrity": "sha512-vtRWBK2uImo5/W2oG6/cDkkHSm+2t6VHgnj+Rcwhb0pP74OoUb4GipyRX/T/y39gYQPhioP0DPShn+A7P6CHNw==",
      "license": "Apache-2.0",
      "dependencies": {
        "mitt": "^3.0.1",
        "zod": "^3.24.1"
      },
      "peerDependencies": {
        "devtools-protocol": "*"
      }
    },
    "node_modules/devtools-protocol": {
      "version": "0.0.1684464",
      "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1684464.tgz",
      "integrity": "sha512-QGCy1oIGCTLtFtJuNZaU6QhaUjMyvTmHWiL3fCiHpE4F2N8r6lyobhqFJQiEh1a6PoCBp/JkjckQy3Lx2i2lfg==",
      "license": "BSD-3-Clause",
      "peer": true
    },
    "node_modules/mitt": {
      "version": "3.0.1",
      "resolved": "https://registry.npmjs.org/mitt/-/mitt-3.0.1.tgz",
      "integrity": "sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==",
      "license": "MIT"
    },
    "node_modules/zod": {
      "version": "3.25.76",
      "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
      "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
      "license": "MIT",
      "funding": {
        "url": "https://github.com/sponsors/colinhacks"
      }
    }
  }
}
package.json
{
  "name": "sample-611267620",
  "version": "1.0.0",
  "description": "Minimal sample verifying pkg:npm/chromium-bidi@2.1.2",
  "main": "index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "keywords": [],
  "author": "",
  "license": "MIT-0",
  "dependencies": {
    "chromium-bidi": "2.1.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/chromium-bidi@2.1.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/chromium-bidi@2.1.2"
  ]
}
test/contract.js
'use strict';

const assert = require('assert');
const {
  OutgoingMessage,
  EventEmitter,
  BrowsingContext,
  Session,
  InvalidArgumentException,
  createOutgoingMessage,
  parseNavigationParams,
  parseSubscriptionParams,
  createInvalidArgumentError,
} = require('../index.js');

async function runContract() {
  // 1. OutgoingMessage.createResolved wraps a message with channel
  const messageData = { id: 1, type: 'success', result: { status: 'ok' } };
  const res = await createOutgoingMessage(messageData, 'test-channel');
  assert.strictEqual(res.kind, 'success');
  assert.strictEqual(res.value.channel, 'test-channel');
  assert.deepStrictEqual(res.value.message, messageData);

  // 2. OutgoingMessage.createFromPromise unwraps success result
  const promiseInput = Promise.resolve({
    kind: 'success',
    value: { id: 2, type: 'event', method: 'log.entryAdded', params: { text: 'test' } },
  });
  const promiseRes = await OutgoingMessage.createFromPromise(promiseInput, 'event-channel');
  assert.strictEqual(promiseRes.kind, 'success');
  assert.strictEqual(promiseRes.value.channel, 'event-channel');
  assert.strictEqual(promiseRes.value.message.id, 2);

  // 3. BrowsingContext.parseNavigateParams parses valid navigation parameters
  const validNav = {
    context: 'context-abc-123',
    url: 'https://example.com',
    wait: 'complete',
  };
  const parsedNav = parseNavigationParams(validNav);
  assert.strictEqual(parsedNav.context, 'context-abc-123');
  assert.strictEqual(parsedNav.url, 'https://example.com');
  assert.strictEqual(parsedNav.wait, 'complete');

  // 4. BrowsingContext.parseNavigateParams throws InvalidArgumentException on invalid parameters
  assert.throws(
    () => {
      parseNavigationParams({ context: 12345 });
    },
    (err) => {
      assert(err instanceof InvalidArgumentException, 'Error must be InvalidArgumentException');
      assert.strictEqual(err.error, 'invalid argument');
      return true;
    }
  );

  // 5. Session.parseSubscribeParams parses subscription parameters
  const validSub = {
    events: ['browsingContext.domContentLoaded'],
    contexts: ['context-abc-123'],
  };
  const parsedSub = parseSubscriptionParams(validSub);
  assert.deepStrictEqual(parsedSub.events, ['browsingContext.domContentLoaded']);
  assert.deepStrictEqual(parsedSub.contexts, ['context-abc-123']);

  // 6. InvalidArgumentException.toErrorResponse formats error response object
  const customErr = createInvalidArgumentError('Invalid navigation context ID');
  assert.strictEqual(customErr.error, 'invalid argument');
  assert.strictEqual(customErr.message, 'Invalid navigation context ID');
  const errResponse = customErr.toErrorResponse(101);
  assert.strictEqual(errResponse.type, 'error');
  assert.strictEqual(errResponse.id, 101);
  assert.strictEqual(errResponse.error, 'invalid argument');
  assert.strictEqual(errResponse.message, 'Invalid navigation context ID');

  // 7. EventEmitter registers listeners and emits events
  const emitter = new EventEmitter();
  let emittedPayload = null;
  emitter.on('channelMessage', (payload) => {
    emittedPayload = payload;
  });
  emitter.emit('channelMessage', { status: 'active' });
  assert.deepStrictEqual(emittedPayload, { status: 'active' });

  console.log('Contract tests passed successfully.');
}

runContract().catch((err) => {
  console.error('Contract test failed:', err);
  process.exit(1);
});

Origin Seeder

anonymous