CodeSampleX

Sample

@types/node-forge 1.3.14

Verified sample for npm @types/node-forge 1.3.14. The contract ran on node 22 · linux alpine/x64 · docker and passed: @types/node-forge package.json declares…

sha256:7537edf9ef74691bca46e88e3b4bedf80110f13fbb1b701dd05fea84e3afe69a

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

Case

HOW
Goal
verify pkg:npm/%40types/node-forge@1.3.14
Packages
Environment
node 22.23.2
Created
2026-08-23T15:04:03Z

Contract

  1. @types/node-forge package.json declares type definitions entry point index.d.ts and version 1.3.14
  2. @types/node-forge declaration file index.d.ts exists and declares node-forge module
  3. @types/node-forge index.d.ts declares PKI namespace with certificate and RSA key generation signatures
  4. @types/node-forge index.d.ts declares message digest namespaces for sha256, sha512, and md5
  5. @types/node-forge index.d.ts declares ASN.1 structure manipulation functions
  6. @types/node-forge index.d.ts declares utility functions for byte buffers and hex conversions
  7. @types/node-forge inspectTypeDefinitions helper validates all core cryptographic type definitions

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 pkg:npm/%40types/node-forge@1.3.14
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40types/node-forge@1.3.14

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:0543579af93a846a58bc4167dd05bb2ec291bd820737900cb9f7d78cc0101c15","contract":["@types/node-forge package.json declares type definitions entry point index.d.ts and version 1.3.14","@types/node-forge declaration file index.d.ts exists and declares node-forge module","@types/node-forge index.d.ts declares PKI namespace with certificate and RSA key generation signatures","@types/node-forge index.d.ts declares message digest namespaces for sha256, sha512, and md5","@types/node-forge index.d.ts declares ASN.1 structure manipulation functions","@types/node-forge index.d.ts declares utility functions for byte buffers and hex conversions","@types/node-forge inspectTypeDefinitions helper validates all core cryptographic type definitions"],"goal":"verify pkg:npm/%40types/node-forge@1.3.14","kind":"HOW","packages":["pkg:npm/%40types/node-forge@1.3.14"],"schemaVersion":1},"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/%40types/node-forge@1.3.14"],"schemaVersion":1,"subject":"pkg:npm/%40types/node-forge@1.3.14","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-node-forge-types",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-node-forge-types",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@types/node-forge": "1.3.14"
      }
    },
    "node_modules/@types/node": {
      "version": "26.2.0",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-26.2.0.tgz",
      "integrity": "sha512-5IviulTZeRNp2vAJ514cc/HUlY5nZ9fCbq9DMyC52BrhFZACo3nI0R7qBxhQmo/d27NFe96ur/b7Wwxklda+kg==",
      "license": "MIT",
      "dependencies": {
        "undici-types": "~8.3.0"
      }
    },
    "node_modules/@types/node-forge": {
      "version": "1.3.14",
      "resolved": "https://registry.npmjs.org/@types/node-forge/-/node-forge-1.3.14.tgz",
      "integrity": "sha512-mhVF2BnD4BO+jtOp7z1CdzaK4mbuK0LLQYAvdOLqHTavxFNq4zA1EmYkpnFjP8HOUzedfQkRnp0E2ulSAYSzAw==",
      "license": "MIT",
      "dependencies": {
        "@types/node": "*"
      }
    },
    "node_modules/undici-types": {
      "version": "8.3.0",
      "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-8.3.0.tgz",
      "integrity": "sha512-j375ScV60dom+YkPFIfTLcOiPxkN/buHz5GobjLhixFuANaNs3C9l4GmrWqejgXWJ7BbJcFYpTEUkS1Ge8bpZQ==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-node-forge-types",
  "version": "1.0.0",
  "private": true,
  "license": "MIT-0",
  "dependencies": {
    "@types/node-forge": "1.3.14"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/%40types/node-forge@1.3.14",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/node-forge@1.3.14"
  ]
}
src/index.js
const fs = require('node:fs');
const path = require('node:path');

/**
 * Returns the absolute directory path of the installed @types/node-forge package.
 * @returns {string} Directory path
 */
function getNodeForgeTypesDir() {
  const pkgPath = require.resolve('@types/node-forge/package.json');
  return path.dirname(pkgPath);
}

/**
 * Resolves the path to a declaration or resource file in @types/node-forge.
 * @param {string} [subPath='index.d.ts'] - Relative declaration file path
 * @returns {string} Absolute path to declaration file
 */
function getDeclarationPath(subPath = 'index.d.ts') {
  return path.join(getNodeForgeTypesDir(), subPath);
}

/**
 * Loads the text content of a declaration file in @types/node-forge.
 * @param {string} [subPath='index.d.ts'] - Relative declaration file path
 * @returns {string} Text content of the declaration file
 */
function loadDeclarationContent(subPath = 'index.d.ts') {
  const declPath = getDeclarationPath(subPath);
  return fs.readFileSync(declPath, 'utf8');
}

/**
 * Inspects core node-forge TypeScript declaration signatures and namespaces.
 * @returns {object} Summary of discovered type definitions
 */
function inspectTypeDefinitions() {
  const content = loadDeclarationContent('index.d.ts');

  return {
    declaresModule: content.includes('declare module "node-forge"'),
    hasPkiNamespace: content.includes('namespace pki'),
    hasPkiCreateCertificate: content.includes('function createCertificate(): Certificate;'),
    hasPkiCertificateFromPem: content.includes('function certificateFromPem('),
    hasRsaGenerateKeyPair: content.includes('function generateKeyPair('),
    hasMdNamespace: content.includes('namespace md'),
    hasSha256Namespace: content.includes('namespace sha256'),
    hasSha512Namespace: content.includes('namespace sha512'),
    hasMd5Namespace: content.includes('namespace md5'),
    hasAsn1Namespace: content.includes('namespace asn1'),
    hasAsn1Create: content.includes('function create('),
    hasAsn1FromDer: content.includes('function fromDer('),
    hasAsn1ToDer: content.includes('function toDer('),
    hasUtilNamespace: content.includes('namespace util'),
    hasUtilCreateBuffer: content.includes('function createBuffer('),
    hasUtilBytesToHex: content.includes('function bytesToHex('),
    hasUtilHexToBytes: content.includes('function hexToBytes('),
    hasCipherNamespace: content.includes('namespace cipher'),
    hasCreateCipher: content.includes('function createCipher('),
    hasHmacNamespace: content.includes('namespace hmac'),
    hasJsbnNamespace: content.includes('namespace jsbn'),
    hasBigIntegerClass: content.includes('class BigInteger')
  };
}

module.exports = {
  getNodeForgeTypesDir,
  getDeclarationPath,
  loadDeclarationContent,
  inspectTypeDefinitions
};
test/contract.js
const assert = require('node:assert');
const fs = require('node:fs');
const path = require('node:path');
const {
  getNodeForgeTypesDir,
  getDeclarationPath,
  loadDeclarationContent,
  inspectTypeDefinitions
} = require('../src/index.js');

// 1. @types/node-forge package.json declares type definitions entry point index.d.ts and version 1.3.14
const pkgJson = require('@types/node-forge/package.json');
assert.strictEqual(pkgJson.name, '@types/node-forge', 'package name should match @types/node-forge');
assert.strictEqual(pkgJson.version, '1.3.14', 'package version should match 1.3.14');
assert.strictEqual(pkgJson.types, 'index.d.ts', 'package types entry should point to index.d.ts');

// 2. @types/node-forge declaration file index.d.ts exists and declares node-forge module
const indexDeclPath = getDeclarationPath('index.d.ts');
assert.strictEqual(fs.existsSync(indexDeclPath), true, 'index.d.ts should exist on disk');
const content = loadDeclarationContent('index.d.ts');
assert.strictEqual(typeof content, 'string', 'declaration content should be string');
assert.strictEqual(content.includes('declare module "node-forge"'), true, 'index.d.ts must declare module node-forge');

// 3. @types/node-forge index.d.ts declares PKI namespace with certificate and RSA key generation signatures
assert.strictEqual(content.includes('namespace pki'), true, 'index.d.ts must declare pki namespace');
assert.strictEqual(content.includes('function createCertificate(): Certificate;'), true, 'pki must declare createCertificate');
assert.strictEqual(content.includes('function certificateFromPem('), true, 'pki must declare certificateFromPem');
assert.strictEqual(content.includes('function generateKeyPair('), true, 'pki.rsa must declare generateKeyPair');

// 4. @types/node-forge index.d.ts declares message digest namespaces for sha256, sha512, and md5
assert.strictEqual(content.includes('namespace md'), true, 'index.d.ts must declare md namespace');
assert.strictEqual(content.includes('namespace sha256'), true, 'md must declare sha256 namespace');
assert.strictEqual(content.includes('namespace sha512'), true, 'md must declare sha512 namespace');
assert.strictEqual(content.includes('namespace md5'), true, 'md must declare md5 namespace');

// 5. @types/node-forge index.d.ts declares ASN.1 structure manipulation functions
assert.strictEqual(content.includes('namespace asn1'), true, 'index.d.ts must declare asn1 namespace');
assert.strictEqual(content.includes('function create('), true, 'asn1 must declare create function');
assert.strictEqual(content.includes('function fromDer('), true, 'asn1 must declare fromDer function');
assert.strictEqual(content.includes('function toDer('), true, 'asn1 must declare toDer function');

// 6. @types/node-forge index.d.ts declares utility functions for byte buffers and hex conversions
assert.strictEqual(content.includes('namespace util'), true, 'index.d.ts must declare util namespace');
assert.strictEqual(content.includes('function createBuffer('), true, 'util must declare createBuffer function');
assert.strictEqual(content.includes('function bytesToHex('), true, 'util must declare bytesToHex function');
assert.strictEqual(content.includes('function hexToBytes('), true, 'util must declare hexToBytes function');

// 7. @types/node-forge inspectTypeDefinitions helper validates all core cryptographic type definitions
const inspection = inspectTypeDefinitions();
assert.strictEqual(inspection.declaresModule, true);
assert.strictEqual(inspection.hasPkiNamespace, true);
assert.strictEqual(inspection.hasPkiCreateCertificate, true);
assert.strictEqual(inspection.hasPkiCertificateFromPem, true);
assert.strictEqual(inspection.hasRsaGenerateKeyPair, true);
assert.strictEqual(inspection.hasMdNamespace, true);
assert.strictEqual(inspection.hasSha256Namespace, true);
assert.strictEqual(inspection.hasSha512Namespace, true);
assert.strictEqual(inspection.hasMd5Namespace, true);
assert.strictEqual(inspection.hasAsn1Namespace, true);
assert.strictEqual(inspection.hasAsn1Create, true);
assert.strictEqual(inspection.hasAsn1FromDer, true);
assert.strictEqual(inspection.hasAsn1ToDer, true);
assert.strictEqual(inspection.hasUtilNamespace, true);
assert.strictEqual(inspection.hasUtilCreateBuffer, true);
assert.strictEqual(inspection.hasUtilBytesToHex, true);
assert.strictEqual(inspection.hasUtilHexToBytes, true);
assert.strictEqual(inspection.hasCipherNamespace, true);
assert.strictEqual(inspection.hasCreateCipher, true);
assert.strictEqual(inspection.hasHmacNamespace, true);
assert.strictEqual(inspection.hasJsbnNamespace, true);
assert.strictEqual(inspection.hasBigIntegerClass, true);

console.log('All @types/node-forge contract tests passed successfully.');

Origin Seeder

anonymous