CodeSampleX

Beispiel

@types/node-forge 1.3.14: types

Verifiziertes Beispiel für npm @types/node-forge 1.3.14: types. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:9ed3b807024fcf8a75374e8ae3e1fe35a6ead110875f900f4604ebf1352b7f18

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
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

Fall

HOW
Ziel
verify @types/node-forge.types in pkg:npm/%40types/node-forge@1.3.14
Pakete
Symbole
  • @types/node-forge.types
Umgebung
node 22.23.2
Erstellt
2026-08-26T12:00:37Z

Contract

  1. @types/node-forge package.json defines types field pointing to index.d.ts
  2. @types/node-forge types declaration file exists and is accessible
  3. @types/node-forge types declaration file contains module declaration for node-forge
  4. @types/node-forge types declare fundamental primitives (Byte, Bytes, Hex, Base64, Utf8, OID, Encoding)
  5. @types/node-forge types declare PKI cryptographic interfaces and functions
  6. @types/node-forge types declare message digest (md) namespaces including sha256, sha512, and md5
  7. @types/node-forge types declare ASN.1, utility byte buffer, cipher, HMAC, and TLS namespaces

Dateien

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

Quellartefakt herunterladen (tar.gz)

Quelltext

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 @types/node-forge.types in 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
Demonstrate these symbols/APIs:
  - @types/node-forge.types

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:96bf482c06d366e34695442280a75982afa216afc03c5b61cc3552c123865e56","contract":["@types/node-forge package.json defines types field pointing to index.d.ts","@types/node-forge types declaration file exists and is accessible","@types/node-forge types declaration file contains module declaration for node-forge","@types/node-forge types declare fundamental primitives (Byte, Bytes, Hex, Base64, Utf8, OID, Encoding)","@types/node-forge types declare PKI cryptographic interfaces and functions","@types/node-forge types declare message digest (md) namespaces including sha256, sha512, and md5","@types/node-forge types declare ASN.1, utility byte buffer, cipher, HMAC, and TLS namespaces"],"goal":"verify @types/node-forge.types in pkg:npm/%40types/node-forge@1.3.14","kind":"HOW","packages":["pkg:npm/%40types/node-forge@1.3.14"],"schemaVersion":1,"symbols":["@types/node-forge.types"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","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","symbols":["@types/node-forge.types"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-node-forge-types-spec",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-node-forge-types-spec",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@types/node-forge": "1.3.14"
      }
    },
    "node_modules/@types/node": {
      "version": "26.3.0",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-26.3.0.tgz",
      "integrity": "sha512-L3fgrnchriRC2ExBflb8j4uZZURHZfQsmQeyVzhjcHW4kkwVyo8/0h1B2MVzMTrYUJYu6G7EWs14hW/L9putqw==",
      "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-spec",
  "version": "1.0.0",
  "private": true,
  "license": "MIT-0",
  "dependencies": {
    "@types/node-forge": "1.3.14"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @types/node-forge.types in pkg:npm/%40types/node-forge@1.3.14",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40types/node-forge@1.3.14"
  ],
  "symbols": [
    "@types/node-forge.types"
  ]
}
src/index.mjs
import fs from 'node:fs';
import path from 'node:path';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);

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

/**
 * Reads the package.json manifest of @types/node-forge.
 * @returns {object} Parsed package.json object
 */
export function getNodeForgePackageJson() {
  const pkgPath = require.resolve('@types/node-forge/package.json');
  return JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
}

/**
 * Resolves and returns the types declaration file path specified in package.json.
 * @returns {string} Absolute path to entrypoint declaration file
 */
export function getTypesDeclarationPath() {
  const pkg = getNodeForgePackageJson();
  const typesEntry = pkg.types || pkg.typings || 'index.d.ts';
  return path.join(getNodeForgeTypesDir(), typesEntry);
}

/**
 * Loads the full text content of the types declaration file.
 * @returns {string} Declaration file contents
 */
export function loadTypesDeclarationContent() {
  const declPath = getTypesDeclarationPath();
  return fs.readFileSync(declPath, 'utf8');
}

/**
 * Inspects @types/node-forge type definitions for core namespaces and symbol exports.
 * @returns {object} Object representing presence of core type definitions
 */
export function inspectNodeForgeTypes() {
  const content = loadTypesDeclarationContent();

  return {
    declaresNodeForgeModule: content.includes('declare module "node-forge"'),
    hasTypeByte: content.includes('type Byte = number;'),
    hasTypeBytes: content.includes('type Bytes = string;'),
    hasTypeHex: content.includes('type Hex = string;'),
    hasTypeBase64: content.includes('type Base64 = string;'),
    hasTypeUtf8: content.includes('type Utf8 = string;'),
    hasTypeOID: content.includes('type OID = string;'),
    hasTypeEncoding: content.includes('type Encoding = "raw" | "utf8";'),
    hasJsbnNamespace: content.includes('namespace jsbn'),
    hasBigIntegerClass: content.includes('class BigInteger'),
    hasPkiNamespace: content.includes('namespace pki'),
    hasPkiCertificate: content.includes('interface Certificate'),
    hasPkiCreateCertificate: content.includes('function createCertificate(): Certificate;'),
    hasPkiCertificateFromPem: content.includes('function certificateFromPem('),
    hasMdNamespace: content.includes('namespace md'),
    hasMdSha256: content.includes('namespace sha256'),
    hasMdSha512: content.includes('namespace sha512'),
    hasMd5: content.includes('namespace md5'),
    hasAsn1Namespace: content.includes('namespace asn1'),
    hasAsn1Create: content.includes('function create('),
    hasAsn1FromDer: content.includes('function fromDer('),
    hasUtilNamespace: content.includes('namespace util'),
    hasUtilByteBuffer: content.includes('interface ByteBuffer'),
    hasUtilCreateBuffer: content.includes('function createBuffer('),
    hasCipherNamespace: content.includes('namespace cipher'),
    hasHmacNamespace: content.includes('namespace hmac'),
    hasTlsNamespace: content.includes('namespace tls'),
    hasSshNamespace: content.includes('namespace ssh')
  };
}
test/contract.mjs
import assert from 'node:assert';
import fs from 'node:fs';
import {
  getNodeForgeTypesDir,
  getNodeForgePackageJson,
  getTypesDeclarationPath,
  loadTypesDeclarationContent,
  inspectNodeForgeTypes
} from '../src/index.mjs';

// 1. @types/node-forge package.json defines types field pointing to index.d.ts
const pkg = getNodeForgePackageJson();
assert.strictEqual(pkg.name, '@types/node-forge', 'Package name must be @types/node-forge');
assert.strictEqual(pkg.version, '1.3.14', 'Package version must be 1.3.14');
assert.strictEqual(pkg.types, 'index.d.ts', 'Package types field must specify index.d.ts');

// 2. @types/node-forge types declaration file exists and is accessible
const declPath = getTypesDeclarationPath();
assert.strictEqual(fs.existsSync(declPath), true, 'types declaration file must exist on disk');
assert.strictEqual(declPath.endsWith('index.d.ts'), true, 'types declaration path must end with index.d.ts');

// 3. @types/node-forge types declaration file contains module declaration for node-forge
const content = loadTypesDeclarationContent();
assert.strictEqual(typeof content, 'string', 'Declaration file content must be a string');
assert.strictEqual(content.includes('declare module "node-forge"'), true, 'Must declare module "node-forge"');

// 4. @types/node-forge types declare fundamental primitives (Byte, Bytes, Hex, Base64, Utf8, OID, Encoding)
const typesInfo = inspectNodeForgeTypes();
assert.strictEqual(typesInfo.hasTypeByte, true, 'Must declare Byte type alias');
assert.strictEqual(typesInfo.hasTypeBytes, true, 'Must declare Bytes type alias');
assert.strictEqual(typesInfo.hasTypeHex, true, 'Must declare Hex type alias');
assert.strictEqual(typesInfo.hasTypeBase64, true, 'Must declare Base64 type alias');
assert.strictEqual(typesInfo.hasTypeUtf8, true, 'Must declare Utf8 type alias');
assert.strictEqual(typesInfo.hasTypeOID, true, 'Must declare OID type alias');
assert.strictEqual(typesInfo.hasTypeEncoding, true, 'Must declare Encoding type alias');

// 5. @types/node-forge types declare PKI cryptographic interfaces and functions
assert.strictEqual(typesInfo.hasPkiNamespace, true, 'Must declare pki namespace');
assert.strictEqual(typesInfo.hasPkiCertificate, true, 'Must declare Certificate interface');
assert.strictEqual(typesInfo.hasPkiCreateCertificate, true, 'Must declare createCertificate signature');
assert.strictEqual(typesInfo.hasPkiCertificateFromPem, true, 'Must declare certificateFromPem signature');

// 6. @types/node-forge types declare message digest (md) namespaces including sha256, sha512, and md5
assert.strictEqual(typesInfo.hasMdNamespace, true, 'Must declare md namespace');
assert.strictEqual(typesInfo.hasMdSha256, true, 'Must declare md.sha256 namespace');
assert.strictEqual(typesInfo.hasMdSha512, true, 'Must declare md.sha512 namespace');
assert.strictEqual(typesInfo.hasMd5, true, 'Must declare md.md5 namespace');

// 7. @types/node-forge types declare ASN.1, utility byte buffer, cipher, HMAC, and TLS namespaces
assert.strictEqual(typesInfo.hasAsn1Namespace, true, 'Must declare asn1 namespace');
assert.strictEqual(typesInfo.hasAsn1Create, true, 'Must declare asn1.create function');
assert.strictEqual(typesInfo.hasAsn1FromDer, true, 'Must declare asn1.fromDer function');
assert.strictEqual(typesInfo.hasUtilNamespace, true, 'Must declare util namespace');
assert.strictEqual(typesInfo.hasUtilByteBuffer, true, 'Must declare util ByteBuffer interface');
assert.strictEqual(typesInfo.hasUtilCreateBuffer, true, 'Must declare util.createBuffer function');
assert.strictEqual(typesInfo.hasCipherNamespace, true, 'Must declare cipher namespace');
assert.strictEqual(typesInfo.hasHmacNamespace, true, 'Must declare hmac namespace');
assert.strictEqual(typesInfo.hasTlsNamespace, true, 'Must declare tls namespace');
assert.strictEqual(typesInfo.hasSshNamespace, true, 'Must declare ssh namespace');

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

Ursprungs-Seeder

anonym