CodeSampleX

Sample

chromium-bidi 2.1.2: Script

Verified sample for npm chromium-bidi 2.1.2: Script. The contract ran on node 22 · linux alpine/x64 · docker and passed: parseEvaluateParams validates…

sha256:02e1eee25949b11a3a0cc4b1b6a18ef91c225c40234a32b863f94eb7cf95ff81

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-27

Case

HOW
Goal
verify chromium-bidi.Script in pkg:npm/chromium-bidi@2.1.2
Packages
Symbols
  • chromium-bidi.Script
Created
2026-08-27T11:04:25Z

Contract

  1. parseEvaluateParams validates expression, target context or realm, awaitPromise, and resultOwnership options
  2. parseCallFunctionParams validates function declaration, target, arguments list, and this parameter
  3. parseDisownParams validates handles list and target context
  4. parseAddPreloadScriptParams validates function declaration, channel arguments, and context filters
  5. parseRemovePreloadScriptParams validates preload script identifier
  6. parseGetRealmsParams validates optional context filter and realm type filter
  7. parser rejects malformed parameter payloads and missing required fields

Files

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

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 chromium-bidi.Script in pkg:npm/chromium-bidi@2.1.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/chromium-bidi@2.1.2
Demonstrate these symbols/APIs:
  - chromium-bidi.Script

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:5c0e4dcd1ffcb53f1f45e2ce5e26c54e260ede65edc7539e10db360538b4464d","contract":["parseEvaluateParams validates expression, target context or realm, awaitPromise, and resultOwnership options","parseCallFunctionParams validates function declaration, target, arguments list, and this parameter","parseDisownParams validates handles list and target context","parseAddPreloadScriptParams validates function declaration, channel arguments, and context filters","parseRemovePreloadScriptParams validates preload script identifier","parseGetRealmsParams validates optional context filter and realm type filter","parser rejects malformed parameter payloads and missing required fields"],"goal":"verify chromium-bidi.Script in pkg:npm/chromium-bidi@2.1.2","kind":"HOW","packages":["pkg:npm/chromium-bidi@2.1.2"],"schemaVersion":1,"symbols":["chromium-bidi.Script"]},"contractCommand":["node","test/contract.mjs"],"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","symbols":["chromium-bidi.Script"],"verifierAdapter":"node-typescript@1"}
index.mjs
import { Script } from 'chromium-bidi/lib/esm/protocol-parser/protocol-parser.js';

export function parseEvaluate(params) {
  return Script.parseEvaluateParams(params);
}

export function parseCallFunction(params) {
  return Script.parseCallFunctionParams(params);
}

export function parseDisown(params) {
  return Script.parseDisownParams(params);
}

export function parseAddPreloadScript(params) {
  return Script.parseAddPreloadScriptParams(params);
}

export function parseRemovePreloadScript(params) {
  return Script.parseRemovePreloadScriptParams(params);
}

export function parseGetRealms(params) {
  return Script.parseGetRealmsParams(params);
}

export { Script };
package-lock.json
{
  "name": "sample-chromium-bidi-script",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-chromium-bidi-script",
      "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.1686980",
      "resolved": "https://registry.npmjs.org/devtools-protocol/-/devtools-protocol-0.0.1686980.tgz",
      "integrity": "sha512-NnnxGO1/cRffXL29DqGysbfgCcsYoIxprtmXgh+UDXFvhTwhRBewcRdGlEXvc3cmROi04JRmd2PqCURsijW25A==",
      "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-chromium-bidi-script",
  "version": "1.0.0",
  "description": "verify chromium-bidi.Script in pkg:npm/chromium-bidi@2.1.2",
  "type": "module",
  "main": "index.mjs",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "chromium-bidi": "2.1.2"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify chromium-bidi.Script in pkg:npm/chromium-bidi@2.1.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/chromium-bidi@2.1.2"
  ],
  "symbols": [
    "chromium-bidi.Script"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import {
  Script,
  parseEvaluate,
  parseCallFunction,
  parseDisown,
  parseAddPreloadScript,
  parseRemovePreloadScript,
  parseGetRealms,
} from '../index.mjs';

// 1. parseEvaluateParams validates expression, target context or realm, awaitPromise, and resultOwnership options
{
  const validContextEval = parseEvaluate({
    expression: '1 + 2',
    target: { context: 'context-id-1', sandbox: 'sandbox-a' },
    awaitPromise: true,
    resultOwnership: 'root',
    userActivation: true,
  });
  assert.equal(validContextEval.expression, '1 + 2');
  assert.deepEqual(validContextEval.target, { context: 'context-id-1', sandbox: 'sandbox-a' });
  assert.equal(validContextEval.awaitPromise, true);
  assert.equal(validContextEval.resultOwnership, 'root');
  assert.equal(validContextEval.userActivation, true);

  const validRealmEval = Script.parseEvaluateParams({
    expression: 'document.title',
    target: { realm: 'realm-id-1' },
    awaitPromise: false,
    resultOwnership: 'none',
  });
  assert.equal(validRealmEval.expression, 'document.title');
  assert.deepEqual(validRealmEval.target, { realm: 'realm-id-1' });
  assert.equal(validRealmEval.awaitPromise, false);
  assert.equal(validRealmEval.resultOwnership, 'none');
}

// 2. parseCallFunctionParams validates function declaration, target, arguments list, and this parameter
{
  const validCall = parseCallFunction({
    functionDeclaration: '(x, y) => x * y',
    target: { realm: 'realm-id-2' },
    awaitPromise: true,
    arguments: [
      { type: 'number', value: 6 },
      { type: 'number', value: 7 },
    ],
    this: { type: 'undefined' },
    resultOwnership: 'none',
  });
  assert.equal(validCall.functionDeclaration, '(x, y) => x * y');
  assert.deepEqual(validCall.target, { realm: 'realm-id-2' });
  assert.equal(validCall.awaitPromise, true);
  assert.equal(validCall.arguments.length, 2);
  assert.equal(validCall.arguments[0].value, 6);
  assert.equal(validCall.arguments[1].value, 7);
  assert.deepEqual(validCall.this, { type: 'undefined' });
}

// 3. parseDisownParams validates handles list and target context
{
  const validDisown = parseDisown({
    handles: ['handle-alpha', 'handle-beta'],
    target: { realm: 'realm-id-3' },
  });
  assert.deepEqual(validDisown.handles, ['handle-alpha', 'handle-beta']);
  assert.deepEqual(validDisown.target, { realm: 'realm-id-3' });
}

// 4. parseAddPreloadScriptParams validates function declaration, channel arguments, and context filters
{
  const validPreload = parseAddPreloadScript({
    functionDeclaration: '() => { window.testHook = true; }',
    arguments: [
      {
        type: 'channel',
        value: {
          channel: 'channel-init',
          ownership: 'root',
        },
      },
    ],
    contexts: ['ctx-123'],
    sandbox: 'preload-sandbox',
  });
  assert.equal(validPreload.functionDeclaration, '() => { window.testHook = true; }');
  assert.equal(validPreload.arguments[0].type, 'channel');
  assert.equal(validPreload.arguments[0].value.channel, 'channel-init');
  assert.deepEqual(validPreload.contexts, ['ctx-123']);
  assert.equal(validPreload.sandbox, 'preload-sandbox');
}

// 5. parseRemovePreloadScriptParams validates preload script identifier
{
  const validRemove = parseRemovePreloadScript({
    script: 'preload-script-uuid-999',
  });
  assert.equal(validRemove.script, 'preload-script-uuid-999');
}

// 6. parseGetRealmsParams validates optional context filter and realm type filter
{
  const validRealms = parseGetRealms({
    context: 'browsing-context-main',
    type: 'window',
  });
  assert.equal(validRealms.context, 'browsing-context-main');
  assert.equal(validRealms.type, 'window');

  const emptyRealms = parseGetRealms({});
  assert.equal(emptyRealms.context, undefined);
  assert.equal(emptyRealms.type, undefined);
}

// 7. parser rejects malformed parameter payloads and missing required fields
{
  // Missing required expression in evaluate
  assert.throws(() => {
    parseEvaluate({ target: { realm: 'r1' }, awaitPromise: true });
  });

  // Invalid expression type in evaluate
  assert.throws(() => {
    parseEvaluate({ expression: 42, target: { realm: 'r1' }, awaitPromise: true });
  });

  // Missing target in callFunction
  assert.throws(() => {
    parseCallFunction({ functionDeclaration: '() => {}', awaitPromise: false });
  });

  // Handles must be an array of strings in disown
  assert.throws(() => {
    parseDisown({ handles: 'single-handle', target: { realm: 'r1' } });
  });

  // Missing script ID in removePreloadScript
  assert.throws(() => {
    parseRemovePreloadScript({});
  });

  // Invalid realm type filter in getRealms
  assert.throws(() => {
    parseGetRealms({ type: 'invalid-realm-type' });
  });
}

console.log('All chromium-bidi.Script contract assertions passed.');

Origin Seeder

anonymous