CodeSampleX

Sample

engine.io-client 6.6.6: verify engine.io-client socket instantiation and configuration options

Verified sample for npm engine.io-client 6.6.6: verify engine.io-client socket instantiation and configuration options. The contract ran on node 22 · linux…

sha256:29684e0758ca039033e7bc3d2e26c51602bbed9aa161ecd69c44709361098288

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 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

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

Case

HOW
Goal
verify engine.io-client socket instantiation and configuration options
Packages
Symbols
  • Socket
Environment
node 22.23.2
Created
2026-08-26T14:26:49Z

Contract

  1. Socket exports protocol version 4 and Socket constructor classes
  2. Socket initializes with default options in node environment with readyState opening and binaryType nodebuffer
  3. Socket supports custom options including transport selection, custom path, and timestamp parameters
  4. Socket emits events via inherited emitter methods
  5. Socket establishes connection, completes handshake, and sends packets over polling transport
  6. Socket closes cleanly and transitions readyState to closed
  7. Socket emits error and close events when connecting to unreachable endpoint

Files

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.js
  • 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 engine.io-client socket instantiation and configuration options
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/engine.io-client@6.6.6
Demonstrate these symbols/APIs:
  - Socket

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:64e56fbdef1949d627831369d069b60c127d61e2c98be88d7bd9ebc00e011d90","contract":["Socket exports protocol version 4 and Socket constructor classes","Socket initializes with default options in node environment with readyState opening and binaryType nodebuffer","Socket supports custom options including transport selection, custom path, and timestamp parameters","Socket emits events via inherited emitter methods","Socket establishes connection, completes handshake, and sends packets over polling transport","Socket closes cleanly and transitions readyState to closed","Socket emits error and close events when connecting to unreachable endpoint"],"goal":"verify engine.io-client socket instantiation and configuration options","kind":"HOW","packages":["pkg:npm/engine.io-client@6.6.6"],"schemaVersion":1,"symbols":["Socket"]},"contractCommand":["node","test/contract.js"],"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/engine.io-client@6.6.6"],"schemaVersion":1,"subject":"pkg:npm/engine.io-client@6.6.6","symbols":["Socket"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-engine-io-client",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-engine-io-client",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "engine.io-client": "6.6.6"
      }
    },
    "node_modules/@socket.io/component-emitter": {
      "version": "3.1.2",
      "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz",
      "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==",
      "license": "MIT"
    },
    "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/engine.io-client": {
      "version": "6.6.6",
      "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.6.6.tgz",
      "integrity": "sha512-iY6QdftLQ9pyiPoX082bpf/u1UewnOaJrtJIF9T0++QB34lZrj0uP+Q/bj8AlUsAxqhnkTV2BS8SBZSxOmoV5Q==",
      "license": "MIT",
      "dependencies": {
        "@socket.io/component-emitter": "~3.1.0",
        "debug": "~4.4.1",
        "engine.io-parser": "~5.2.1",
        "ws": "~8.21.0",
        "xmlhttprequest-ssl": "~2.1.1"
      }
    },
    "node_modules/engine.io-parser": {
      "version": "5.2.3",
      "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.3.tgz",
      "integrity": "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q==",
      "license": "MIT",
      "engines": {
        "node": ">=10.0.0"
      }
    },
    "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/ws": {
      "version": "8.21.3",
      "resolved": "https://registry.npmjs.org/ws/-/ws-8.21.3.tgz",
      "integrity": "sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw==",
      "license": "MIT",
      "engines": {
        "node": ">=10.0.0"
      },
      "peerDependencies": {
        "bufferutil": "^4.0.1",
        "utf-8-validate": ">=5.0.2"
      },
      "peerDependenciesMeta": {
        "bufferutil": {
          "optional": true
        },
        "utf-8-validate": {
          "optional": true
        }
      }
    },
    "node_modules/xmlhttprequest-ssl": {
      "version": "2.1.2",
      "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.1.2.tgz",
      "integrity": "sha512-TEU+nJVUUnA4CYJFLvK5X9AOeH4KvDvhIfm0vV1GaQRtchnG0hgK5p8hw/xjv8cunWYCsiPCSDzObPyhEwq3KQ==",
      "engines": {
        "node": ">=0.4.0"
      }
    }
  }
}
package.json
{
  "name": "sample-engine-io-client",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification sample for engine.io-client",
  "main": "src/index.js",
  "scripts": {
    "test": "node test/contract.js"
  },
  "dependencies": {
    "engine.io-client": "6.6.6"
  },
  "license": "MIT-0"
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify engine.io-client socket instantiation and configuration options",
  "kind": "HOW",
  "packages": [
    "pkg:npm/engine.io-client@6.6.6"
  ],
  "symbols": [
    "Socket"
  ]
}
src/index.js
'use strict';

const {
  Socket,
  protocol,
  transports,
  SocketWithoutUpgrade,
  SocketWithUpgrade
} = require('engine.io-client');

/**
 * Creates an Engine.IO client socket with specified options.
 * @param {string|object} uri
 * @param {object} [opts]
 * @returns {Socket}
 */
function createSocket(uri, opts) {
  return new Socket(uri, opts);
}

module.exports = {
  Socket,
  protocol,
  transports,
  SocketWithoutUpgrade,
  SocketWithUpgrade,
  createSocket
};
test/contract.js
'use strict';

const assert = require('assert');
const http = require('http');
const {
  Socket,
  protocol,
  transports,
  SocketWithoutUpgrade,
  SocketWithUpgrade,
  createSocket
} = require('../src/index.js');

async function main() {
  // 1. Socket exports protocol version 4 and Socket constructor classes
  {
    assert.strictEqual(typeof protocol, 'number');
    assert.strictEqual(protocol, 4);
    assert.strictEqual(typeof Socket, 'function');
    assert.strictEqual(typeof SocketWithoutUpgrade, 'function');
    assert.strictEqual(typeof SocketWithUpgrade, 'function');
    assert.strictEqual(typeof createSocket, 'function');
  }

  // 2. Socket initializes with default options in node environment with readyState opening and binaryType nodebuffer
  {
    const socket = new Socket('http://localhost:3000');
    assert.strictEqual(socket.readyState, 'opening');
    assert.strictEqual(socket.binaryType, 'nodebuffer');
    assert.strictEqual(Array.isArray(socket.writeBuffer), true);
    assert.strictEqual(socket.writeBuffer.length, 0);
    socket.close();
    assert.strictEqual(socket.readyState, 'closed');
  }

  // 3. Socket supports custom options including transport selection, custom path, and timestamp parameters
  {
    const socket = createSocket('http://localhost:12345', {
      transports: ['polling'],
      path: '/custom-engine/',
      timestampParam: 'ts',
      autoUnref: true
    });
    assert.strictEqual(socket.readyState, 'opening');
    socket.binaryType = 'arraybuffer';
    assert.strictEqual(socket.binaryType, 'arraybuffer');
    socket.close();
    assert.strictEqual(socket.readyState, 'closed');
  }

  // 4. Socket emits events via inherited emitter methods
  {
    const socket = new Socket('http://localhost:12345');
    let emittedValue = null;
    const onCustom = (val) => { emittedValue = val; };
    socket.on('custom-event', onCustom);
    socket.emit('custom-event', 'data-payload');
    assert.strictEqual(emittedValue, 'data-payload');
    socket.off('custom-event', onCustom);
    socket.emit('custom-event', 'ignored-payload');
    assert.strictEqual(emittedValue, 'data-payload');
    socket.close();
  }

  // 5. Socket establishes connection, completes handshake, and sends packets over polling transport
  // 6. Socket closes cleanly and transitions readyState to closed
  {
    const sessionId = 'eio-session-proof-1';
    let receivedPacket = null;

    const server = http.createServer((req, res) => {
      if (req.method === 'GET') {
        const handshake = JSON.stringify({
          sid: sessionId,
          upgrades: [],
          pingInterval: 10000,
          pingTimeout: 5000,
          maxPayload: 100000
        });
        res.writeHead(200, { 'Content-Type': 'text/plain; charset=UTF-8' });
        res.end('0' + handshake);
      } else if (req.method === 'POST') {
        let body = '';
        req.on('data', chunk => { body += chunk; });
        req.on('end', () => {
          receivedPacket = body;
          res.writeHead(200, { 'Content-Type': 'text/plain; charset=UTF-8' });
          res.end('ok');
        });
      }
    });

    await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
    const port = server.address().port;

    const socket = new Socket(`http://127.0.0.1:${port}`, {
      transports: ['polling']
    });

    let opened = false;
    let handshakeReceived = null;

    socket.on('handshake', (data) => {
      handshakeReceived = data;
    });

    await new Promise((resolve, reject) => {
      socket.on('open', () => {
        opened = true;
        resolve();
      });
      socket.on('error', reject);
    });

    assert.strictEqual(opened, true);
    assert.strictEqual(socket.id, sessionId);
    assert.strictEqual(socket.readyState, 'open');
    assert.strictEqual(handshakeReceived.sid, sessionId);
    assert.strictEqual(handshakeReceived.pingInterval, 10000);

    socket.send('hello-engine-proof');
    await new Promise((resolve) => setTimeout(resolve, 80));
    assert.strictEqual(receivedPacket, '4hello-engine-proof');

    let closed = false;
    await new Promise((resolve) => {
      socket.on('close', () => {
        closed = true;
        resolve();
      });
      socket.close();
    });

    assert.strictEqual(closed, true);
    assert.strictEqual(socket.readyState, 'closed');

    await new Promise((resolve) => server.close(resolve));
  }

  // 7. Socket emits error and close events when connecting to unreachable endpoint
  {
    const socket = new Socket('http://127.0.0.1:59999', {
      transports: ['polling'],
      requestTimeout: 300
    });

    let errorFired = false;
    await new Promise((resolve) => {
      socket.on('error', () => {
        errorFired = true;
      });
      socket.on('close', () => {
        resolve();
      });
    });

    assert.strictEqual(errorFired, true);
    assert.strictEqual(socket.readyState, 'closed');
  }

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

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

Origin Seeder

anonymous