CodeSampleX

Exemple

fast-uri 3.1.6

Échantillon vérifié pour npm fast-uri 3.1.6. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi : fastUri.parse parses full URI…

sha256:d24be421ffb0b506a6d41bbca42a9f3541c5a4a0103c4f080e51ca6b95da2f50

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
2
Clés de signature qui l’ont compilé
1
Environnement déclaré node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

Environnements des exécutions de vérification

Environnement Contrat Étapes Exécution
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
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-09-07

Cas

HOW
Objectif
verify pkg:npm/fast-uri@3.1.6
Paquets
Environnement
node 22.23.2
Créé
2026-08-26T06:46:18Z

Contrat

  1. fastUri.parse parses full URI into scheme, host, port, path, query, and fragment components
  2. fastUri.parse parses relative paths without scheme or authority
  3. fastUri.parse parses IPv6 host literals and reports error property on malformed domains
  4. fastUri.serialize formats URI component objects into complete URI strings
  5. fastUri.serialize formats relative URI component objects with path and query parameters
  6. fastUri.resolve resolves relative paths, absolute-path references, and query string references against a base URI
  7. fastUri.resolveComponent resolves parsed relative URIComponent against parsed base URIComponent
  8. fastUri.normalize normalizes host casing, path dot-segments, and unreserved percent-encoded characters
  9. fastUri.equal determines RFC 3986 equivalence between equivalent URI strings

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 pkg:npm/fast-uri@3.1.6
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/fast-uri@3.1.6
Constraints:
  - executionContext: node
Required runtime conditions:
  - ecosystem: npm
  - language: javascript
  - moduleSystem: cjs
  - packageManager: npm@10.9.8
  - runtime: node@22.23.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:cc3bce9dce0a0c078b0f12f7632be8cecbfffd2cf58d0e419a60a2574d2f9503","constraints":{"executionContext":"node"},"contract":["fastUri.parse parses full URI into scheme, host, port, path, query, and fragment components","fastUri.parse parses relative paths without scheme or authority","fastUri.parse parses IPv6 host literals and reports error property on malformed domains","fastUri.serialize formats URI component objects into complete URI strings","fastUri.serialize formats relative URI component objects with path and query parameters","fastUri.resolve resolves relative paths, absolute-path references, and query string references against a base URI","fastUri.resolveComponent resolves parsed relative URIComponent against parsed base URIComponent","fastUri.normalize normalizes host casing, path dot-segments, and unreserved percent-encoded characters","fastUri.equal determines RFC 3986 equivalence between equivalent URI strings"],"goal":"verify pkg:npm/fast-uri@3.1.6","kind":"HOW","packages":["pkg:npm/fast-uri@3.1.6"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"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/fast-uri@3.1.6"],"schemaVersion":1,"subject":"pkg:npm/fast-uri@3.1.6","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "fast-uri-verification",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "fast-uri-verification",
      "version": "1.0.0",
      "dependencies": {
        "fast-uri": "3.1.6"
      }
    },
    "node_modules/fast-uri": {
      "version": "3.1.6",
      "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.6.tgz",
      "integrity": "sha512-7Ical1vFEMr0onbVzEDIreM22I4khW+fzyQPwvAFWBp1iwdshSZRsL4jjRvPG9JP1uiqMHRto+YU6R2/CzDz5Q==",
      "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-verification",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for fast-uri",
  "dependencies": {
    "fast-uri": "3.1.6"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/fast-uri@3.1.6",
  "kind": "HOW",
  "packages": [
    "pkg:npm/fast-uri@3.1.6"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
test/contract.mjs
import assert from 'node:assert';
import uri from 'fast-uri';

// 1. fastUri.parse parses full URI into scheme, host, port, path, query, and fragment components
const parsed = uri.parse('http://example.com:8080/path/sub?q=test#heading');
assert.strictEqual(parsed.scheme, 'http');
assert.strictEqual(parsed.host, 'example.com');
assert.strictEqual(parsed.port, 8080);
assert.strictEqual(parsed.path, '/path/sub');
assert.strictEqual(parsed.query, 'q=test');
assert.strictEqual(parsed.fragment, 'heading');
assert.strictEqual(parsed.reference, 'uri');

// 2. fastUri.parse parses relative paths without scheme or authority
const rel = uri.parse('/api/v1/users?page=2#top');
assert.strictEqual(rel.scheme, undefined);
assert.strictEqual(rel.host, undefined);
assert.strictEqual(rel.port, undefined);
assert.strictEqual(rel.path, '/api/v1/users');
assert.strictEqual(rel.query, 'page=2');
assert.strictEqual(rel.fragment, 'top');
assert.strictEqual(rel.reference, 'relative');

// 3. fastUri.parse parses IPv6 host literals and reports error property on malformed domains
const ipv6 = uri.parse('http://[::1]:3000/');
assert.strictEqual(ipv6.scheme, 'http');
assert.strictEqual(ipv6.host, '::1');
assert.strictEqual(ipv6.port, 3000);
const malformed = uri.parse('http://invalid domain with spaces');
assert.ok(malformed.error);

// 4. fastUri.serialize formats URI component objects into complete URI strings
const serialized = uri.serialize({
  scheme: 'http',
  host: 'example.com',
  port: 8080,
  path: '/api/resource',
  query: 'filter=active',
  fragment: 'section1'
});
assert.strictEqual(serialized, 'http://example.com:8080/api/resource?filter=active#section1');

// 5. fastUri.serialize formats relative URI component objects with path and query parameters
const relSerialized = uri.serialize({
  path: '/docs',
  query: 'lang=en'
});
assert.strictEqual(relSerialized, '/docs?lang=en');

// 6. fastUri.resolve resolves relative paths, absolute-path references, and query string references against a base URI
assert.strictEqual(uri.resolve('http://example.com/a/b/c', '../d'), 'http://example.com/a/d');
assert.strictEqual(uri.resolve('http://example.com/a/b/c', '/main/target'), 'http://example.com/main/target');
assert.strictEqual(uri.resolve('http://example.com/a/b', '?filter=all'), 'http://example.com/a/b?filter=all');
assert.strictEqual(uri.resolve('http://example.com/a/b', '#section2'), 'http://example.com/a/b#section2');

// 7. fastUri.resolveComponent resolves parsed relative URIComponent against parsed base URIComponent
const baseComp = uri.parse('http://example.com/a/b');
const relComp = uri.parse('c');
const resolvedComp = uri.resolveComponent(baseComp, relComp);
assert.strictEqual(resolvedComp.scheme, 'http');
assert.strictEqual(resolvedComp.host, 'example.com');
assert.strictEqual(resolvedComp.path, '/a/c');

// 8. fastUri.normalize normalizes host casing, path dot-segments, and unreserved percent-encoded characters
assert.strictEqual(uri.normalize('http://EXAMPLE.COM/a/b/../c/%7A'), 'http://example.com/a/c/z');
assert.strictEqual(uri.normalize('http://example.com/a/./b'), 'http://example.com/a/b');

// 9. fastUri.equal determines RFC 3986 equivalence between equivalent URI strings
assert.strictEqual(uri.equal('http://EXAMPLE.COM/a/b/../c/%7A', 'http://example.com/a/c/z'), true);
assert.strictEqual(uri.equal('http://example.com:8080/test', 'http://example.com:8080/test'), true);
assert.strictEqual(uri.equal('http://example.com/a', 'http://example.com/b'), false);

console.log('Contract passed');

Seeder d'origine

anonyme