CodeSampleX

Exemplo

side-channel-weakmap 1.0.2

Amostra verificada para npm side-channel-weakmap 1.0.2. O contrato rodou em node 22 · linux alpine/x64 · docker e passou: getSideChannelWeakMap() returns a…

sha256:cedd330b889c0c3bf8be06e66507564e7f3fe12ba4c85ebc901be6e570b0d218

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

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@1
2026-08-20

Caso

HOW
Objetivo
verify pkg:npm/side-channel-weakmap@1.0.2
Pacotes
Criado
2026-08-20T14:04:16Z

Contrato

  1. getSideChannelWeakMap() returns a channel object with set, get, has, delete, and assert methods
  2. channel.set(key, value) and channel.get(key) store and retrieve values for JavaScript object and primitive keys
  3. channel.has(key) returns true when the key exists in the channel and false when it does not
  4. channel.delete(key) removes the key-value pair, returning true if found and false otherwise
  5. channel.assert(key) throws a TypeError if the key is not stored in the channel, and returns without error when present
  6. multiple side channel instances maintain isolated, independent storage

Arquivos

  • PROMPT.md
  • csx.json
  • package-lock.json
  • package.json
  • spec.json
  • src/index.mjs
  • 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/side-channel-weakmap@1.0.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/side-channel-weakmap@1.0.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:018af83cd081cdf85e4fbe95b8b53199a125dd27a42a0bc9292c523761a00269","contract":["getSideChannelWeakMap() returns a channel object with set, get, has, delete, and assert methods","channel.set(key, value) and channel.get(key) store and retrieve values for JavaScript object and primitive keys","channel.has(key) returns true when the key exists in the channel and false when it does not","channel.delete(key) removes the key-value pair, returning true if found and false otherwise","channel.assert(key) throws a TypeError if the key is not stored in the channel, and returns without error when present","multiple side channel instances maintain isolated, independent storage"],"goal":"verify pkg:npm/side-channel-weakmap@1.0.2","kind":"HOW","packages":["pkg:npm/side-channel-weakmap@1.0.2"],"schemaVersion":1},"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/side-channel-weakmap@1.0.2"],"schemaVersion":1,"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "verify-side-channel-weakmap",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "verify-side-channel-weakmap",
      "version": "1.0.0",
      "dependencies": {
        "side-channel-weakmap": "1.0.2"
      }
    },
    "node_modules/call-bind-apply-helpers": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
      "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
      "license": "MIT",
      "dependencies": {
        "es-errors": "^1.3.0",
        "function-bind": "^1.1.2"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/call-bound": {
      "version": "1.0.4",
      "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
      "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
      "license": "MIT",
      "dependencies": {
        "call-bind-apply-helpers": "^1.0.2",
        "get-intrinsic": "^1.3.0"
      },
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/dunder-proto": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
      "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
      "license": "MIT",
      "dependencies": {
        "call-bind-apply-helpers": "^1.0.1",
        "es-errors": "^1.3.0",
        "gopd": "^1.2.0"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/es-define-property": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
      "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/es-errors": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
      "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/es-object-atoms": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
      "integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
      "license": "MIT",
      "dependencies": {
        "es-errors": "^1.3.0"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/function-bind": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
      "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
      "license": "MIT",
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/get-intrinsic": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
      "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
      "license": "MIT",
      "dependencies": {
        "call-bind-apply-helpers": "^1.0.2",
        "es-define-property": "^1.0.1",
        "es-errors": "^1.3.0",
        "es-object-atoms": "^1.1.1",
        "function-bind": "^1.1.2",
        "get-proto": "^1.0.1",
        "gopd": "^1.2.0",
        "has-symbols": "^1.1.0",
        "hasown": "^2.0.2",
        "math-intrinsics": "^1.1.0"
      },
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/get-proto": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
      "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
      "license": "MIT",
      "dependencies": {
        "dunder-proto": "^1.0.1",
        "es-object-atoms": "^1.0.0"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/gopd": {
      "version": "1.2.0",
      "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
      "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/has-symbols": {
      "version": "1.1.0",
      "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
      "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/hasown": {
      "version": "2.0.4",
      "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
      "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
      "license": "MIT",
      "dependencies": {
        "function-bind": "^1.1.2"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/math-intrinsics": {
      "version": "1.1.0",
      "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
      "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/object-inspect": {
      "version": "1.13.4",
      "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
      "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/side-channel-map": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
      "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
      "license": "MIT",
      "dependencies": {
        "call-bound": "^1.0.2",
        "es-errors": "^1.3.0",
        "get-intrinsic": "^1.2.5",
        "object-inspect": "^1.13.3"
      },
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/side-channel-weakmap": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
      "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
      "license": "MIT",
      "dependencies": {
        "call-bound": "^1.0.2",
        "es-errors": "^1.3.0",
        "get-intrinsic": "^1.2.5",
        "object-inspect": "^1.13.3",
        "side-channel-map": "^1.0.1"
      },
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    }
  }
}
package.json
{
  "name": "verify-side-channel-weakmap",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "side-channel-weakmap": "1.0.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/side-channel-weakmap@1.0.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/side-channel-weakmap@1.0.2"
  ]
}
src/index.mjs
import getSideChannelWeakMap from 'side-channel-weakmap';

export function createChannel() {
  return getSideChannelWeakMap();
}

export default getSideChannelWeakMap;
test/contract.mjs
import assert from 'node:assert';
import getSideChannelWeakMap, { createChannel } from '../src/index.mjs';

// 1. Channel initialization and API interface
const channel = createChannel();
assert.strictEqual(typeof channel, 'object', 'getSideChannelWeakMap must return an object');
assert.strictEqual(typeof channel.set, 'function', 'channel must have set method');
assert.strictEqual(typeof channel.get, 'function', 'channel must have get method');
assert.strictEqual(typeof channel.has, 'function', 'channel must have has method');
assert.strictEqual(typeof channel.delete, 'function', 'channel must have delete method');
assert.strictEqual(typeof channel.assert, 'function', 'channel must have assert method');

// 2. Setting and getting values across different JS key types
const objKey = { id: 1, name: 'object key' };
const fnKey = function () {};
const symKey = Symbol('sample-symbol');
const strKey = 'sample-string';
const numKey = 42;
const boolKey = true;

assert.strictEqual(channel.has(objKey), false, 'new key must not exist initially');
assert.strictEqual(channel.get(objKey), undefined, 'getting non-existent key must return undefined');

channel.set(objKey, { data: 'object-value' });
channel.set(fnKey, 'fn-value');
channel.set(symKey, 'sym-value');
channel.set(strKey, 'str-value');
channel.set(numKey, 'num-value');
channel.set(boolKey, 'bool-value');

// 3. Verifying has() and get()
assert.strictEqual(channel.has(objKey), true, 'has must return true for registered object key');
assert.deepStrictEqual(channel.get(objKey), { data: 'object-value' }, 'get must return stored object value');

assert.strictEqual(channel.has(fnKey), true, 'has must return true for function key');
assert.strictEqual(channel.get(fnKey), 'fn-value', 'get must return stored function key value');

assert.strictEqual(channel.has(symKey), true, 'has must return true for symbol key');
assert.strictEqual(channel.get(symKey), 'sym-value', 'get must return stored symbol key value');

assert.strictEqual(channel.has(strKey), true, 'has must return true for string key');
assert.strictEqual(channel.get(strKey), 'str-value', 'get must return stored string key value');

assert.strictEqual(channel.has(numKey), true, 'has must return true for number key');
assert.strictEqual(channel.get(numKey), 'num-value', 'get must return stored number key value');

assert.strictEqual(channel.has(boolKey), true, 'has must return true for boolean key');
assert.strictEqual(channel.get(boolKey), 'bool-value', 'get must return stored boolean key value');

// Overwriting an existing key value
channel.set(objKey, { data: 'updated-value' });
assert.deepStrictEqual(channel.get(objKey), { data: 'updated-value' }, 'get must return updated value');

// 4. Assert method behavior
assert.doesNotThrow(() => {
  channel.assert(objKey);
}, 'channel.assert must not throw for existing key');

const missingKey = { missing: true };
assert.throws(
  () => {
    channel.assert(missingKey);
  },
  {
    name: 'TypeError',
    message: /^Side channel does not contain/
  },
  'channel.assert must throw TypeError for missing key'
);

// 5. Delete method behavior
assert.strictEqual(channel.delete(objKey), true, 'delete must return true for existing key');
assert.strictEqual(channel.has(objKey), false, 'deleted key must not exist');
assert.strictEqual(channel.get(objKey), undefined, 'get must return undefined for deleted key');
assert.strictEqual(channel.delete(objKey), false, 'deleting already deleted key must return false');
assert.strictEqual(channel.delete(missingKey), false, 'deleting non-existent key must return false');

// 6. Channel isolation between instances
const channelA = getSideChannelWeakMap();
const channelB = getSideChannelWeakMap();
const sharedKey = { shared: true };

channelA.set(sharedKey, 'value-a');
assert.strictEqual(channelA.has(sharedKey), true);
assert.strictEqual(channelA.get(sharedKey), 'value-a');
assert.strictEqual(channelB.has(sharedKey), false, 'channelB should not have keys set in channelA');
assert.strictEqual(channelB.get(sharedKey), undefined);

channelB.set(sharedKey, 'value-b');
assert.strictEqual(channelA.get(sharedKey), 'value-a', 'channelA value should remain unmodified');
assert.strictEqual(channelB.get(sharedKey), 'value-b', 'channelB value should be isolated');

console.log('Contract test passed.');

Seeder de origem

anônimo