サンプル
proxy-from-env 1.1.0
検証済みサンプル — npm proxy-from-env 1.1.0. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: assert getProxyForUrl returns proxy url matching protocol…
sha256:20fca09b299083a2fa9781654699a2604afd649c73b5824b987fb97f8fe91d7e
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
MIT-0
実行証拠
宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。
- 証拠の基準
- 署名済みコントラクト合格
- 検証レシート
- 1
- ビルドした署名鍵
- 1
宣言された環境
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm
検証実行環境
| 環境 | コントラクト | ステージ | 実行日 |
|---|---|---|---|
| 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 |
ケース
HOW- ゴール
- verify pkg:npm/proxy-from-env@1.1.0
- パッケージ
- 環境
- node 22.23.2
- 作成日
- 2026-08-20T20:32:58Z
コントラクト
- assert getProxyForUrl returns proxy url matching protocol from environment variables
- assert getProxyForUrl prepends protocol scheme if proxy address lacks scheme
- assert getProxyForUrl returns empty string when no proxy environment variables are set
- assert getProxyForUrl respects NO_PROXY exact domain and wildcard matching
- assert getProxyForUrl respects NO_PROXY domain suffix matching with leading dot or asterisk
- assert getProxyForUrl respects NO_PROXY specific port filtering
- assert getProxyForUrl returns empty string for invalid or missing URL inputs
ファイル
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- 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/proxy-from-env@1.1.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/proxy-from-env@1.1.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:0579f60110fc32ffa2665fb76b05beb038a19261485af945219305402a079d9b","constraints":{"executionContext":"node"},"contract":["assert getProxyForUrl returns proxy url matching protocol from environment variables","assert getProxyForUrl prepends protocol scheme if proxy address lacks scheme","assert getProxyForUrl returns empty string when no proxy environment variables are set","assert getProxyForUrl respects NO_PROXY exact domain and wildcard matching","assert getProxyForUrl respects NO_PROXY domain suffix matching with leading dot or asterisk","assert getProxyForUrl respects NO_PROXY specific port filtering","assert getProxyForUrl returns empty string for invalid or missing URL inputs"],"goal":"verify pkg:npm/proxy-from-env@1.1.0","kind":"HOW","packages":["pkg:npm/proxy-from-env@1.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","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/proxy-from-env@1.1.0"],"schemaVersion":1,"subject":"pkg:npm/proxy-from-env@1.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",
"license": "MIT-0",
"dependencies": {
"proxy-from-env": "1.1.0"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
"license": "MIT"
}
}
}
{
"name": "sample-proxy-from-env",
"version": "1.0.0",
"type": "module",
"license": "MIT-0",
"dependencies": {
"proxy-from-env": "1.1.0"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/proxy-from-env@1.1.0",
"kind": "HOW",
"packages": [
"pkg:npm/proxy-from-env@1.1.0"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"runtime": "node@22.23.2"
}
}
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { getProxyForUrl } = require('proxy-from-env');
function withEnv(env, fn) {
const originalEnv = { ...process.env };
const proxyKeys = [
'http_proxy', 'HTTP_PROXY',
'https_proxy', 'HTTPS_PROXY',
'all_proxy', 'ALL_PROXY',
'no_proxy', 'NO_PROXY',
'npm_config_http_proxy', 'npm_config_https_proxy',
'npm_config_proxy', 'npm_config_no_proxy'
];
for (const k of proxyKeys) {
delete process.env[k];
}
Object.assign(process.env, env);
try {
fn();
} finally {
for (const k of proxyKeys) {
delete process.env[k];
}
Object.assign(process.env, originalEnv);
}
}
// 1. Returns proxy url matching protocol from environment variables
withEnv({
HTTP_PROXY: 'http://proxy.example.com:8080',
HTTPS_PROXY: 'https://secure.example.com:8443',
ALL_PROXY: 'socks://all.example.com:1080'
}, () => {
assert.equal(getProxyForUrl('http://example.com/api'), 'http://proxy.example.com:8080');
assert.equal(getProxyForUrl('https://example.com/api'), 'https://secure.example.com:8443');
assert.equal(getProxyForUrl('ws://example.com/socket'), 'socks://all.example.com:1080');
});
// 2. Prepends protocol scheme if proxy address lacks scheme
withEnv({
HTTP_PROXY: 'proxy.example.com:8080',
HTTPS_PROXY: 'secure.example.com:8443'
}, () => {
assert.equal(getProxyForUrl('http://example.com'), 'http://proxy.example.com:8080');
assert.equal(getProxyForUrl('https://example.com'), 'https://secure.example.com:8443');
});
// 3. Returns empty string when no proxy environment variables are set
withEnv({}, () => {
assert.equal(getProxyForUrl('http://example.com'), '');
assert.equal(getProxyForUrl('https://example.com'), '');
assert.equal(getProxyForUrl('ftp://example.com'), '');
});
// 4. Respects NO_PROXY exact domain and wildcard matching
withEnv({
HTTP_PROXY: 'http://proxy.example.com:8080',
NO_PROXY: 'example.com, example.org'
}, () => {
assert.equal(getProxyForUrl('http://example.com/page'), '');
assert.equal(getProxyForUrl('http://example.org/data'), '');
assert.equal(getProxyForUrl('http://example.net/page'), 'http://proxy.example.com:8080');
});
withEnv({
HTTP_PROXY: 'http://proxy.example.com:8080',
NO_PROXY: '*'
}, () => {
assert.equal(getProxyForUrl('http://example.com'), '');
assert.equal(getProxyForUrl('http://example.net'), '');
});
// 5. Respects NO_PROXY domain suffix matching with leading dot or asterisk
withEnv({
HTTP_PROXY: 'http://proxy.example.com:8080',
NO_PROXY: '.example.com, *.example.org'
}, () => {
assert.equal(getProxyForUrl('http://api.example.com'), '');
assert.equal(getProxyForUrl('http://service.example.org'), '');
assert.equal(getProxyForUrl('http://example.com'), 'http://proxy.example.com:8080');
});
// 6. Respects NO_PROXY specific port filtering
withEnv({
HTTP_PROXY: 'http://proxy.example.com:8080',
NO_PROXY: 'example.com:8080'
}, () => {
assert.equal(getProxyForUrl('http://example.com:8080/test'), '');
assert.equal(getProxyForUrl('http://example.com:3000/test'), 'http://proxy.example.com:8080');
});
// 7. Returns empty string for invalid or missing URL inputs
assert.equal(getProxyForUrl(''), '');
assert.equal(getProxyForUrl(null), '');
assert.equal(getProxyForUrl(undefined), '');
assert.equal(getProxyForUrl('no-protocol-host'), '');
assert.equal(getProxyForUrl({}), '');
オリジンシーダー
匿名