CodeSampleX

Beispiel

get-uri 6.0.5: isValidProtocol

Verifiziertes Beispiel für npm get-uri 6.0.5: isValidProtocol. Der Vertrag lief auf node 22 · linux alpine/x64 · docker und bestand.

sha256:41f47f070dd16d9c373d5279e143af0526955faddba1736b083d67750cf2d79b

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

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

Fall

HOW
Ziel
verify get-uri.isValidProtocol in pkg:npm/get-uri@6.0.5
Pakete
Symbole
  • get-uri.isValidProtocol
Erstellt
2026-08-27T11:42:32Z

Contract

  1. isValidProtocol returns true for supported protocols: data, file, ftp, http, https
  2. isValidProtocol returns false for unsupported protocols (ws, wss, gopher, mailto, ssh, empty string)
  3. isValidProtocol returns false for protocol strings containing trailing colon

Dateien

  • PROMPT.md
  • csx.json
  • index.mjs
  • package-lock.json
  • package.json
  • spec.json
  • 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 get-uri.isValidProtocol in pkg:npm/get-uri@6.0.5
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/get-uri@6.0.5
Demonstrate these symbols/APIs:
  - get-uri.isValidProtocol

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:5fdc68724d4b9213a2f294460213c9a30aee6ca5979f090a0dea32d1d236e6a0","contract":["isValidProtocol returns true for supported protocols: data, file, ftp, http, https","isValidProtocol returns false for unsupported protocols (ws, wss, gopher, mailto, ssh, empty string)","isValidProtocol returns false for protocol strings containing trailing colon"],"goal":"verify get-uri.isValidProtocol in pkg:npm/get-uri@6.0.5","kind":"HOW","packages":["pkg:npm/get-uri@6.0.5"],"schemaVersion":1,"symbols":["get-uri.isValidProtocol"]},"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/get-uri@6.0.5"],"schemaVersion":1,"subject":"pkg:npm/get-uri@6.0.5","symbols":["get-uri.isValidProtocol"],"verifierAdapter":"node-typescript@1"}
index.mjs
import { isValidProtocol } from 'get-uri';

export function isSupportedUriProtocol(protocol) {
  return isValidProtocol(protocol);
}
package-lock.json
{
  "name": "sample",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "get-uri": "6.0.5"
      }
    },
    "node_modules/basic-ftp": {
      "version": "5.3.1",
      "resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.3.1.tgz",
      "integrity": "sha512-bopVNp6ugyA150DDuZfPFdt1KZ5a94ZDiwX4hMgZDzF+GttD80lEy8kj98kbyhLXnPvhtIo93mdnLIjpCAeeOw==",
      "license": "MIT",
      "engines": {
        "node": ">=10.0.0"
      }
    },
    "node_modules/data-uri-to-buffer": {
      "version": "6.0.2",
      "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz",
      "integrity": "sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==",
      "license": "MIT",
      "engines": {
        "node": ">= 14"
      }
    },
    "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/get-uri": {
      "version": "6.0.5",
      "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.5.tgz",
      "integrity": "sha512-b1O07XYq8eRuVzBNgJLstU6FYc1tS6wnMtF1I1D9lE8LxZSOGZ7LhxN54yPP6mGw5f2CkXY2BQUL9Fx41qvcIg==",
      "license": "MIT",
      "dependencies": {
        "basic-ftp": "^5.0.2",
        "data-uri-to-buffer": "^6.0.2",
        "debug": "^4.3.4"
      },
      "engines": {
        "node": ">= 14"
      }
    },
    "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"
    }
  }
}
package.json
{
  "name": "sample",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "license": "MIT-0",
  "dependencies": {
    "get-uri": "6.0.5"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify get-uri.isValidProtocol in pkg:npm/get-uri@6.0.5",
  "kind": "HOW",
  "packages": [
    "pkg:npm/get-uri@6.0.5"
  ],
  "symbols": [
    "get-uri.isValidProtocol"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import { isValidProtocol, protocols } from 'get-uri';

const supported = ['data', 'file', 'ftp', 'http', 'https'];

for (const protocol of supported) {
  assert.equal(
    isValidProtocol(protocol),
    true,
    `expected protocol "${protocol}" to be valid`
  );
  assert.ok(
    protocol in protocols,
    `expected protocol "${protocol}" to exist in exported protocols map`
  );
}

const unsupported = [
  'ws',
  'wss',
  'gopher',
  'mailto',
  'ssh',
  'unknown',
  '',
  'http:',
  'https:',
  'file:',
];

for (const protocol of unsupported) {
  assert.equal(
    isValidProtocol(protocol),
    false,
    `expected protocol "${protocol}" to be invalid`
  );
}

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

Ursprungs-Seeder

anonym