Exemple
proxy-from-env 2.1.0
Échantillon vérifié pour npm proxy-from-env 2.1.0. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:b1cf59cdb08c2c224a026b14beff33b1cbb7ee65c6941206ba6fba4fe5059ba3
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é
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-27 |
Cas
HOW- Objectif
- verify pkg:npm/proxy-from-env@2.1.0
- Paquets
- Environnement
- node 22.23.2
- Créé
- 2026-08-27T13:03:18Z
Contrat
- getProxyForUrl returns an empty string when no proxy environment variables are set
- getProxyForUrl returns the HTTP_PROXY URL for an HTTP request URL
- getProxyForUrl returns the HTTPS_PROXY URL for an HTTPS request URL
- getProxyForUrl returns ALL_PROXY URL when specific protocol proxy is not set
- getProxyForUrl returns an empty string when NO_PROXY wildcard is set or host matches NO_PROXY
- getProxyForUrl respects port-specific NO_PROXY filtering
- getProxyForUrl prepends the request protocol scheme when the proxy environment variable lacks a URL scheme
- getProxyForUrl returns an empty string when given an invalid URL or string without a valid hostname
- getProxyForUrl accepts URL instance as input
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.mjs
Code 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/proxy-from-env@2.1.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/proxy-from-env@2.1.0
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.
{"case":{"caseId":"case:sha256:c360ff2e679af3025192a0035f6979c07df81298c6e5b51e64e005aba36af941","constraints":{"executionContext":"node"},"contract":["getProxyForUrl returns an empty string when no proxy environment variables are set","getProxyForUrl returns the HTTP_PROXY URL for an HTTP request URL","getProxyForUrl returns the HTTPS_PROXY URL for an HTTPS request URL","getProxyForUrl returns ALL_PROXY URL when specific protocol proxy is not set","getProxyForUrl returns an empty string when NO_PROXY wildcard is set or host matches NO_PROXY","getProxyForUrl respects port-specific NO_PROXY filtering","getProxyForUrl prepends the request protocol scheme when the proxy environment variable lacks a URL scheme","getProxyForUrl returns an empty string when given an invalid URL or string without a valid hostname","getProxyForUrl accepts URL instance as input"],"goal":"verify pkg:npm/proxy-from-env@2.1.0","kind":"HOW","packages":["pkg:npm/proxy-from-env@2.1.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","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/proxy-from-env@2.1.0"],"schemaVersion":1,"subject":"pkg:npm/proxy-from-env@2.1.0","verifierAdapter":"node-typescript@1"}
{
"name": "sample-proxy-from-env",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-proxy-from-env",
"version": "1.0.0",
"dependencies": {
"proxy-from-env": "2.1.0"
}
},
"node_modules/proxy-from-env": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz",
"integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==",
"license": "MIT",
"engines": {
"node": ">=10"
}
}
}
}
{
"name": "sample-proxy-from-env",
"version": "1.0.0",
"type": "module",
"private": true,
"dependencies": {
"proxy-from-env": "2.1.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/proxy-from-env@2.1.0",
"kind": "HOW",
"packages": [
"pkg:npm/proxy-from-env@2.1.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import process from 'node:process';
import { getProxyForUrl } from 'proxy-from-env';
function clearProxyEnv() {
delete process.env.http_proxy;
delete process.env.HTTP_PROXY;
delete process.env.https_proxy;
delete process.env.HTTPS_PROXY;
delete process.env.all_proxy;
delete process.env.ALL_PROXY;
delete process.env.no_proxy;
delete process.env.NO_PROXY;
}
// 1. getProxyForUrl returns an empty string when no proxy environment variables are set
{
clearProxyEnv();
const proxy = getProxyForUrl('http://example.com/test');
assert.equal(proxy, '');
}
// 2. getProxyForUrl returns the HTTP_PROXY URL for an HTTP request URL
{
clearProxyEnv();
process.env.HTTP_PROXY = 'http://proxy.example.com:8080';
const proxy = getProxyForUrl('http://example.com/api');
assert.equal(proxy, 'http://proxy.example.com:8080');
}
// 3. getProxyForUrl returns the HTTPS_PROXY URL for an HTTPS request URL
{
clearProxyEnv();
process.env.HTTPS_PROXY = 'http://secure-proxy.example.com:8443';
const proxy = getProxyForUrl('https://example.com/secure');
assert.equal(proxy, 'http://secure-proxy.example.com:8443');
}
// 4. getProxyForUrl returns ALL_PROXY URL when specific protocol proxy is not set
{
clearProxyEnv();
process.env.ALL_PROXY = 'socks5://proxy.example.com:1080';
const proxy = getProxyForUrl('http://example.com/other');
assert.equal(proxy, 'socks5://proxy.example.com:1080');
}
// 5. getProxyForUrl returns an empty string when NO_PROXY wildcard is set or host matches NO_PROXY
{
clearProxyEnv();
process.env.HTTP_PROXY = 'http://proxy.example.com:8080';
process.env.NO_PROXY = 'example.org,.example.net';
assert.equal(getProxyForUrl('http://example.org/index'), '');
assert.equal(getProxyForUrl('http://sub.example.net/'), '');
assert.equal(getProxyForUrl('http://other.example.com/'), 'http://proxy.example.com:8080');
process.env.NO_PROXY = '*';
assert.equal(getProxyForUrl('http://other.example.com/'), '');
}
// 6. getProxyForUrl respects port-specific NO_PROXY filtering
{
clearProxyEnv();
process.env.HTTP_PROXY = 'http://proxy.example.com:8080';
process.env.NO_PROXY = 'example.com:8080';
assert.equal(getProxyForUrl('http://example.com:8080/path'), '');
assert.equal(getProxyForUrl('http://example.com:80/path'), 'http://proxy.example.com:8080');
}
// 7. getProxyForUrl prepends the request protocol scheme when the proxy environment variable lacks a URL scheme
{
clearProxyEnv();
process.env.HTTP_PROXY = '127.0.0.1:8080';
const proxy = getProxyForUrl('http://example.com/data');
assert.equal(proxy, 'http://127.0.0.1:8080');
}
// 8. getProxyForUrl returns an empty string when given an invalid URL or string without a valid hostname
{
clearProxyEnv();
process.env.HTTP_PROXY = 'http://proxy.example.com:8080';
assert.equal(getProxyForUrl('not-a-valid-url'), '');
assert.equal(getProxyForUrl(''), '');
}
// 9. getProxyForUrl accepts URL instance as input
{
clearProxyEnv();
process.env.HTTP_PROXY = 'http://proxy.example.com:8080';
const urlObj = new URL('http://example.com/url-instance');
assert.equal(getProxyForUrl(urlObj), 'http://proxy.example.com:8080');
}
Seeder d'origine
anonyme