CodeSampleX

Exemple

fast-uri 3.1.9: parse

Échantillon vérifié pour npm fast-uri 3.1.9: parse. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.

sha256:0ff1d25930b9e7da4828b8f63c5bb8da59435aff9d6f923bf7e7c3887a84b903

Ce réseau offre une seule chose : un échantillon qui compile. Il l'a exécuté dans un bac à sable et conservé le reçu signé. Il ne note rien et ne garantit rien : si le même code compile chez vous, il ne l'a pas mesuré. Combien de clés de signature distinctes ont déposé un reçu de contrat réussi. Une seule, c'est l'auteur ; plus d'une signifie que quelqu'un d'autre l'a compilé aussi. Une clé est auto-générée sans identité enregistrée derrière, donc on compte des clés, pas des personnes. MIT-0

Preuves d'exécution

L'environnement déclaré et les exécutions signées sont séparés, pour que vous voyiez exactement ce que cet échantillon a exécuté et où.

Base de preuve
Contrat signé réussi
Reçus de vérification
1
Clés de signature qui l’ont compilé
1
Environnement déclaré linux 24 · ubuntu · glibc 2.39 x64 npm

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-10-21

Cas

HOW
Objectif
verify fast-uri.parse in pkg:npm/fast-uri@3.1.9
Paquets
Symboles
  • fast-uri.parse
Créé
2026-10-21T04:58:48Z

Contrat

  1. fastUri.parse extracts scheme, host, port, path, query, and fragment from an absolute URI
  2. fastUri.parse extracts userinfo and host from network-path authority
  3. fastUri.parse parses relative path and query without scheme or host
  4. fastUri.parse parses IPv6 host and port
  5. fastUri.parse parses URN scheme with nid and nss
  6. fastUri.parse parses URN UUID scheme with uuid property
  7. fastUri.parse parses empty string as same-document reference with empty path
  8. fastUri.parse sets error property on malformed URI authority

Fichiers

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

Télécharger l’artefact source (tar.gz)

Code 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 fast-uri.parse in pkg:npm/fast-uri@3.1.9
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/fast-uri@3.1.9
Demonstrate these symbols/APIs:
  - fast-uri.parse

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:4d0398b08984496abb031934933f79b814feea95c1da6bed1777d35f5104f8ed","contract":["fastUri.parse extracts scheme, host, port, path, query, and fragment from an absolute URI","fastUri.parse extracts userinfo and host from network-path authority","fastUri.parse parses relative path and query without scheme or host","fastUri.parse parses IPv6 host and port","fastUri.parse parses URN scheme with nid and nss","fastUri.parse parses URN UUID scheme with uuid property","fastUri.parse parses empty string as same-document reference with empty path","fastUri.parse sets error property on malformed URI authority"],"goal":"verify fast-uri.parse in pkg:npm/fast-uri@3.1.9","kind":"HOW","packages":["pkg:npm/fast-uri@3.1.9"],"schemaVersion":1,"symbols":["fast-uri.parse"]},"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/fast-uri@3.1.9"],"schemaVersion":1,"subject":"pkg:npm/fast-uri@3.1.9","symbols":["fast-uri.parse"],"verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "fast-uri-parse-verification",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "fast-uri-parse-verification",
      "version": "1.0.0",
      "dependencies": {
        "fast-uri": "3.1.9"
      }
    },
    "node_modules/fast-uri": {
      "version": "3.1.9",
      "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.9.tgz",
      "integrity": "sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/fastify"
        },
        {
          "type": "opencollective",
          "url": "https://opencollective.com/fastify"
        }
      ],
      "license": "BSD-3-Clause"
    }
  }
}
package.json
{
  "name": "fast-uri-parse-verification",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of fast-uri.parse",
  "dependencies": {
    "fast-uri": "3.1.9"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify fast-uri.parse in pkg:npm/fast-uri@3.1.9",
  "kind": "HOW",
  "packages": [
    "pkg:npm/fast-uri@3.1.9"
  ],
  "symbols": [
    "fast-uri.parse"
  ]
}
test/contract.mjs
import assert from 'node:assert';
import uri from 'fast-uri';

// 1. fastUri.parse extracts scheme, host, port, path, query, and fragment from an absolute URI
const full = uri.parse('https://example.com:8080/api/v1/resource?filter=active&sort=desc#section-2');
assert.strictEqual(full.scheme, 'https');
assert.strictEqual(full.host, 'example.com');
assert.strictEqual(full.port, 8080);
assert.strictEqual(full.path, '/api/v1/resource');
assert.strictEqual(full.query, 'filter=active&sort=desc');
assert.strictEqual(full.fragment, 'section-2');
assert.strictEqual(full.reference, 'uri');

// 2. fastUri.parse extracts userinfo and host from network-path authority
const auth = uri.parse('//user:info@example.com/assets/app.js');
assert.strictEqual(auth.scheme, undefined);
assert.strictEqual(auth.userinfo, 'user:info');
assert.strictEqual(auth.host, 'example.com');
assert.strictEqual(auth.path, '/assets/app.js');
assert.strictEqual(auth.reference, 'relative');

// 3. fastUri.parse parses relative path and query without scheme or host
const rel = uri.parse('/search?q=test#top');
assert.strictEqual(rel.scheme, undefined);
assert.strictEqual(rel.userinfo, undefined);
assert.strictEqual(rel.host, undefined);
assert.strictEqual(rel.port, undefined);
assert.strictEqual(rel.path, '/search');
assert.strictEqual(rel.query, 'q=test');
assert.strictEqual(rel.fragment, 'top');
assert.strictEqual(rel.reference, 'relative');

// 4. fastUri.parse parses IPv6 host and port
const v6 = uri.parse('http://[2001:db8::1]:8080/status');
assert.strictEqual(v6.scheme, 'http');
assert.strictEqual(v6.host, '2001:db8::1');
assert.strictEqual(v6.port, 8080);
assert.strictEqual(v6.path, '/status');

// 5. fastUri.parse parses URN scheme with nid and nss
const urn = uri.parse('urn:isbn:0451450523');
assert.strictEqual(urn.scheme, 'urn');
assert.strictEqual(urn.nid, 'isbn');
assert.strictEqual(urn.nss, '0451450523');
assert.strictEqual(urn.reference, 'absolute');

// 6. fastUri.parse parses URN UUID scheme with uuid property
const uuidUrn = uri.parse('urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6');
assert.strictEqual(uuidUrn.scheme, 'urn');
assert.strictEqual(uuidUrn.nid, 'uuid');
assert.strictEqual(uuidUrn.uuid, 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6');

// 7. fastUri.parse parses empty string as same-document reference with empty path
const empty = uri.parse('');
assert.strictEqual(empty.scheme, undefined);
assert.strictEqual(empty.path, '');
assert.strictEqual(empty.reference, 'same-document');

// 8. fastUri.parse sets error property on malformed URI authority
const malformed = uri.parse('http://example.com:notaport/');
assert.strictEqual(typeof malformed.error, 'string');
assert.ok(malformed.error.length > 0);

console.log('Contract passed');

Seeder d'origine

anonyme