CodeSampleX

Sample

fast-uri 4.1.2

Verified sample for npm fast-uri 4.1.2. The contract ran on node 22 · linux debian/x64 · docker and passed: fastUri.parse parses full URI strings into…

sha256:4205d6bc35b9e398f789f943ca1d83c625599d59254758a9026c6694aee3c750

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

Verification-run environments

Environment Contract Stages Run
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-20

Case

HOW
Goal
verify pkg:npm/fast-uri@4.1.2
Packages
Created
2026-10-20T12:58:28Z

Contract

  1. fastUri.parse parses full URI strings into lowercased scheme, host, numeric port, path, query, fragment, and reference type
  2. fastUri.parse classifies path-only and fragment-only inputs as relative and same-document references
  3. fastUri.parse and fastUri.serialize handle zoned IPv6 literals, wss resourceName/secure flags, and urn:uuid components
  4. fastUri.parse populates the error property when given a literal backslash in authority or an out-of-range port
  5. fastUri.serialize formats URI component objects into RFC 3986 URI strings with dot-segment removal and default HTTP port elision
  6. fastUri.resolve resolves relative paths and query references against a base URI and throws an Error on malformed authority inputs
  7. fastUri.resolveComponent resolves a parsed relative URIComponent against a parsed base URIComponent
  8. fastUri.normalize normalizes both URI strings and URIComponent objects by folding case, removing dot-segments, and decoding escape-safe percent-encoded octets
  9. fastUri.equal returns true for canonically equivalent URIs and false for distinct or malformed authority URIs

Files

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

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/fast-uri@4.1.2
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/fast-uri@4.1.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:2fd30a6ade2105e434761123fa37e5e61f9c7866ca0775cc2999450bf671b402","contract":["fastUri.parse parses full URI strings into lowercased scheme, host, numeric port, path, query, fragment, and reference type","fastUri.parse classifies path-only and fragment-only inputs as relative and same-document references","fastUri.parse and fastUri.serialize handle zoned IPv6 literals, wss resourceName/secure flags, and urn:uuid components","fastUri.parse populates the error property when given a literal backslash in authority or an out-of-range port","fastUri.serialize formats URI component objects into RFC 3986 URI strings with dot-segment removal and default HTTP port elision","fastUri.resolve resolves relative paths and query references against a base URI and throws an Error on malformed authority inputs","fastUri.resolveComponent resolves a parsed relative URIComponent against a parsed base URIComponent","fastUri.normalize normalizes both URI strings and URIComponent objects by folding case, removing dot-segments, and decoding escape-safe percent-encoded octets","fastUri.equal returns true for canonically equivalent URIs and false for distinct or malformed authority URIs"],"goal":"verify pkg:npm/fast-uri@4.1.2","kind":"HOW","packages":["pkg:npm/fast-uri@4.1.2"],"schemaVersion":1,"symbols":["fastUri.parse","fastUri.serialize","fastUri.resolve","fastUri.resolveComponent","fastUri.normalize","fastUri.equal"]},"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@4.1.2"],"schemaVersion":1,"subject":"pkg:npm/fast-uri@4.1.2","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-fast-uri",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-fast-uri",
      "version": "1.0.0",
      "dependencies": {
        "fast-uri": "4.1.2"
      }
    },
    "node_modules/fast-uri": {
      "version": "4.1.2",
      "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-4.1.2.tgz",
      "integrity": "sha512-TyGmBcbDTZXcb2cj5MV89DrF42DKvb3y5DDUNh95iO+IMeAzMkVSxK1PZRrRIpc9yg8U2GhGdbofNa0LS/a4Bw==",
      "funding": [
        {
          "type": "github",
          "url": "https://github.com/sponsors/fastify"
        },
        {
          "type": "opencollective",
          "url": "https://opencollective.com/fastify"
        }
      ],
      "license": "BSD-3-Clause"
    }
  }
}
package.json
{
  "name": "sample-fast-uri",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "test": "node test/contract.mjs"
  },
  "dependencies": {
    "fast-uri": "4.1.2"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/fast-uri@4.1.2",
  "kind": "HOW",
  "packages": [
    "pkg:npm/fast-uri@4.1.2"
  ]
}
src/index.mjs
import fastUri from 'fast-uri'

export function parseUri (uri, options) {
  return fastUri.parse(uri, options)
}

export function serializeUri (components, options) {
  return fastUri.serialize(components, options)
}

export function resolveUri (baseUri, relativeUri, options) {
  return fastUri.resolve(baseUri, relativeUri, options)
}

export function resolveUriComponent (baseComponent, relativeComponent, options, skipNormalization) {
  return fastUri.resolveComponent(baseComponent, relativeComponent, options, skipNormalization)
}

export function normalizeUri (input, options) {
  return fastUri.normalize(input, options)
}

export function equalUri (uriA, uriB, options) {
  return fastUri.equal(uriA, uriB, options)
}
test/contract.mjs
import assert from 'node:assert/strict'
import fastUri from 'fast-uri'
import {
  parseUri,
  serializeUri,
  resolveUri,
  resolveUriComponent,
  normalizeUri,
  equalUri
} from '../src/index.mjs'

// 1. fastUri.parse: full URI with scheme, host, port, path, query, and fragment
const parsedFull = parseUri('HTTPS://EXAMPLE.COM:8443/v1/items?limit=10&sort=asc#top')
assert.equal(parsedFull.scheme, 'https')
assert.equal(parsedFull.host, 'example.com')
assert.equal(parsedFull.port, 8443)
assert.equal(parsedFull.path, '/v1/items')
assert.equal(parsedFull.query, 'limit=10&sort=asc')
assert.equal(parsedFull.fragment, 'top')
assert.equal(parsedFull.reference, 'uri')
assert.equal(parsedFull.error, undefined)

// 2. fastUri.parse: relative reference and same-document reference
const parsedRelative = parseUri('../catalog/search?q=uri')
assert.equal(parsedRelative.scheme, undefined)
assert.equal(parsedRelative.host, undefined)
assert.equal(parsedRelative.path, '../catalog/search')
assert.equal(parsedRelative.query, 'q=uri')
assert.equal(parsedRelative.reference, 'relative')

const parsedSameDoc = parseUri('#section-2')
assert.equal(parsedSameDoc.reference, 'same-document')
assert.equal(parsedSameDoc.fragment, 'section-2')

// 3. fastUri.parse & fastUri.serialize: zoned IPv6 literal and WebSocket / URN scheme handlers
const parsedZonedIpv6 = parseUri('http://[fe80::1%25eth0]:8080/health')
assert.equal(parsedZonedIpv6.scheme, 'http')
assert.equal(parsedZonedIpv6.host, 'fe80::1%eth0')
assert.equal(parsedZonedIpv6.port, 8080)
assert.equal(parsedZonedIpv6.path, '/health')

const serializedZonedIpv6 = serializeUri({
  scheme: 'http',
  host: 'fe80::1%eth0',
  port: 8080,
  path: '/health'
})
assert.equal(serializedZonedIpv6, 'http://[fe80::1%25eth0]:8080/health')

const parsedWs = parseUri('wss://example.com:443/chat?room=general')
assert.equal(parsedWs.scheme, 'wss')
assert.equal(parsedWs.secure, true)
assert.equal(parsedWs.resourceName, '/chat?room=general')

const parsedUrnUuid = parseUri('urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6')
assert.equal(parsedUrnUuid.scheme, 'urn')
assert.equal(parsedUrnUuid.nid, 'uuid')
assert.equal(parsedUrnUuid.uuid, 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6')
assert.equal(parsedUrnUuid.error, undefined)

// 4. fastUri.parse: malformed authority or port populates error property
const parsedBackslash = parseUri('http://example.com\\other/path')
assert.equal(parsedBackslash.error, 'URI authority must not contain a literal backslash.')

const parsedBadPort = parseUri('http://example.com:70000/path')
assert.equal(parsedBadPort.error, 'URI port is malformed.')

// 5. fastUri.serialize: component object to URI string with dot-segment removal and default port normalization
const serializedFull = serializeUri({
  scheme: 'https',
  host: 'localhost',
  port: 443,
  path: '/api/a/../b/list',
  query: 'page=1',
  fragment: 'results'
})
assert.equal(serializedFull, 'https://localhost/api/b/list?page=1#results')

// 6. fastUri.resolve & fastUri.resolveComponent: RFC 3986 relative resolution and error on malformed authority/port
assert.equal(
  resolveUri('http://example.com/dir/sub/file.html', '../other/index.html?x=1#frag'),
  'http://example.com/dir/other/index.html?x=1#frag'
)
assert.equal(
  resolveUri('http://example.com/dir/sub/file.html?old=1', '?new=2'),
  'http://example.com/dir/sub/file.html?new=2'
)
assert.throws(() => {
  resolveUri('http://example.com\\bad/base', 'next')
}, /backslash/i)

const resolvedComp = resolveUriComponent(
  fastUri.parse('http://example.com/a/b/c'),
  fastUri.parse('../d?k=v#end'),
  undefined,
  true
)
assert.equal(resolvedComp.scheme, 'http')
assert.equal(resolvedComp.host, 'example.com')
assert.equal(resolvedComp.path, '/a/d')
assert.equal(resolvedComp.query, 'k=v')
assert.equal(resolvedComp.fragment, 'end')

// 7. fastUri.normalize: string and URIComponent normalization
const normalizedStr = normalizeUri('HTTP://EXAMPLE.COM:80/a/b/../c/%41item?x=1#top')
assert.equal(normalizedStr, 'http://example.com/a/c/Aitem?x=1#top')

const normalizedComp = normalizeUri({
  scheme: 'HTTP',
  host: 'EXAMPLE.COM',
  path: '/x/./y/../z'
})
assert.equal(normalizedComp.scheme, 'http')
assert.equal(normalizedComp.host, 'example.com')
assert.equal(normalizedComp.path, '/x/z')

// 8. fastUri.equal: URI equivalence comparison and false on malformed authority
assert.equal(
  equalUri('http://EXAMPLE.COM:80/a/b/../c/%7Etest', 'http://example.com/a/c/~test'),
  true
)
assert.equal(
  equalUri('http://example.com/a/c', 'http://example.com/a/d'),
  false
)
assert.equal(
  equalUri('http://example.com\\bad', 'http://example.com\\bad'),
  false
)

Origin Seeder

anonymous