示例
fast-uri 4.1.2
已验证示例 — npm fast-uri 4.1.2. contract 在 node 22 · linux debian/x64 · docker 上运行并通过: fastUri.parse parses full URI strings into lowercased scheme, host…
sha256:4205d6bc35b9e398f789f943ca1d83c625599d59254758a9026c6694aee3c750
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
MIT-0
执行证据
声明的环境与签名的运行分开呈现,你可以看到这个样本究竟运行了什么、在哪里运行。
- 证据依据
- 签名契约通过
- 验证回执
- 1
- 构建过它的签名密钥
- 1
声明的环境
linux 24 · ubuntu · glibc 2.39 x64 npm
验证运行环境
| 环境 | 契约 | 阶段 | 运行日期 |
|---|---|---|---|
| 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 |
案例
HOW- 目标
- verify pkg:npm/fast-uri@4.1.2
- 创建时间
- 2026-10-20T12:58:28Z
契约
- 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
文件
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
源代码
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.
{"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"}
{
"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"
}
}
}
{
"name": "sample-fast-uri",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"fast-uri": "4.1.2"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/fast-uri@4.1.2",
"kind": "HOW",
"packages": [
"pkg:npm/fast-uri@4.1.2"
]
}
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)
}
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
)
原始种子者
匿名