Sample
follow-redirects 1.16.0
Verified sample for npm follow-redirects 1.16.0. The contract ran on node 22 · linux alpine/x64 · docker and passed: followRedirects exports http and https…
sha256:10bb4eb9761b8a066161ed3654884b7d3fcd66088b437fd14007bdc31ed8f6f1
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
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm
Verification-run environments
| Environment | Contract | Stages | Run |
|---|---|---|---|
| node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1 |
2026-08-20 |
Case
HOW- Goal
- verify pkg:npm/follow-redirects@1.16.0
- Packages
- Environment
- node 22.23.2
- Created
- 2026-08-20T20:35:02Z
Contract
- followRedirects exports http and https drop-in wrappers and wrap function
- http.get follows 301 and 302 redirects automatically to destination URL and populates responseUrl
- trackRedirects option records redirect history array with status codes and URLs for each hop
- maxRedirects option limits maximum redirect count and emits error when limit is exceeded
- beforeRedirect callback allows intercepting and inspecting redirect options before following
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Source
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/follow-redirects@1.16.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/follow-redirects@1.16.0
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- 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.
{"case":{"caseId":"case:sha256:24396618ab3d586916cac766910334e6fb925c5e4bd0b91e19f846f0b9efbe34","constraints":{"executionContext":"node"},"contract":["followRedirects exports http and https drop-in wrappers and wrap function","http.get follows 301 and 302 redirects automatically to destination URL and populates responseUrl","trackRedirects option records redirect history array with status codes and URLs for each hop","maxRedirects option limits maximum redirect count and emits error when limit is exceeded","beforeRedirect callback allows intercepting and inspecting redirect options before following"],"goal":"verify pkg:npm/follow-redirects@1.16.0","kind":"HOW","packages":["pkg:npm/follow-redirects@1.16.0"],"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","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/follow-redirects@1.16.0"],"schemaVersion":1,"subject":"pkg:npm/follow-redirects@1.16.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-follow-redirects",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-follow-redirects",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"follow-redirects": "1.16.0"
}
},
"node_modules/follow-redirects": {
"version": "1.16.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz",
"integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==",
"license": "MIT",
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
}
}
}
{
"name": "sample-follow-redirects",
"version": "1.0.0",
"type": "module",
"license": "MIT-0",
"dependencies": {
"follow-redirects": "1.16.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/follow-redirects@1.16.0",
"kind": "HOW",
"packages": [
"pkg:npm/follow-redirects@1.16.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import http from 'node:http';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const followRedirects = require('follow-redirects');
const { http: fHttp, https: fHttps } = followRedirects;
// 1. followRedirects exports http and https drop-in wrappers and wrap function
assert.equal(typeof fHttp, 'object', 'followRedirects.http should be an object');
assert.equal(typeof fHttp.get, 'function', 'followRedirects.http.get should be a function');
assert.equal(typeof fHttp.request, 'function', 'followRedirects.http.request should be a function');
assert.equal(typeof fHttps, 'object', 'followRedirects.https should be an object');
assert.equal(typeof fHttps.get, 'function', 'followRedirects.https.get should be a function');
assert.equal(typeof fHttps.request, 'function', 'followRedirects.https.request should be a function');
assert.equal(typeof followRedirects.wrap, 'function', 'followRedirects.wrap should be a function');
// Create local test HTTP server for offline testing
const server = http.createServer((req, res) => {
if (req.url === '/redirect-1') {
res.writeHead(302, { Location: '/redirect-2' });
res.end();
} else if (req.url === '/redirect-2') {
res.writeHead(301, { Location: '/final' });
res.end();
} else if (req.url === '/final') {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('final destination reached');
} else if (req.url === '/loop-a') {
res.writeHead(302, { Location: '/loop-b' });
res.end();
} else if (req.url === '/loop-b') {
res.writeHead(302, { Location: '/loop-a' });
res.end();
} else {
res.writeHead(404);
res.end('not found');
}
});
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
const port = server.address().port;
const baseUrl = `http://127.0.0.1:${port}`;
try {
// 2. http.get follows 301 and 302 redirects automatically to destination URL and populates responseUrl
await new Promise((resolve, reject) => {
fHttp.get(`${baseUrl}/redirect-1`, (res) => {
let data = '';
res.on('data', (chunk) => { data += chunk; });
res.on('end', () => {
try {
assert.equal(res.statusCode, 200);
assert.equal(data, 'final destination reached');
assert.equal(res.responseUrl, `${baseUrl}/final`);
resolve();
} catch (e) {
reject(e);
}
});
}).on('error', reject);
});
// 3. trackRedirects option records redirect history array with status codes and URLs for each hop
await new Promise((resolve, reject) => {
fHttp.get({
host: '127.0.0.1',
port,
path: '/redirect-1',
trackRedirects: true,
}, (res) => {
let data = '';
res.on('data', (chunk) => { data += chunk; });
res.on('end', () => {
try {
assert.equal(res.statusCode, 200);
assert.ok(Array.isArray(res.redirects), 'res.redirects should be an array');
assert.equal(res.redirects.length, 3);
assert.equal(res.redirects[0].statusCode, 302);
assert.equal(res.redirects[0].url, `${baseUrl}/redirect-1`);
assert.equal(res.redirects[1].statusCode, 301);
assert.equal(res.redirects[1].url, `${baseUrl}/redirect-2`);
assert.equal(res.redirects[2].statusCode, 200);
assert.equal(res.redirects[2].url, `${baseUrl}/final`);
resolve();
} catch (e) {
reject(e);
}
});
}).on('error', reject);
});
// 4. maxRedirects option limits maximum redirect count and emits error when limit is exceeded
await new Promise((resolve, reject) => {
const req = fHttp.get({
host: '127.0.0.1',
port,
path: '/loop-a',
maxRedirects: 3,
});
req.on('error', (err) => {
try {
assert.match(err.message, /Maximum number of redirects exceeded/i);
resolve();
} catch (e) {
reject(e);
}
});
req.on('response', () => {
reject(new Error('Expected maxRedirects error but received response'));
});
});
// 5. beforeRedirect callback allows intercepting and inspecting redirect options before following
const redirectedHops = [];
await new Promise((resolve, reject) => {
fHttp.get({
host: '127.0.0.1',
port,
path: '/redirect-1',
beforeRedirect: (options, responseDetails) => {
redirectedHops.push({
path: options.path,
statusCode: responseDetails.statusCode,
});
},
}, (res) => {
res.resume();
res.on('end', () => {
try {
assert.equal(redirectedHops.length, 2);
assert.equal(redirectedHops[0].statusCode, 302);
assert.equal(redirectedHops[0].path, '/redirect-2');
assert.equal(redirectedHops[1].statusCode, 301);
assert.equal(redirectedHops[1].path, '/final');
resolve();
} catch (e) {
reject(e);
}
});
}).on('error', reject);
});
console.log('All contract assertions passed.');
} finally {
await new Promise((resolve) => server.close(resolve));
}
Origin Seeder
anonymous