CodeSampleX

サンプル

https-proxy-agent 5.0.1

検証済みサンプル — npm https-proxy-agent 5.0.1. node 22 · linux alpine/x64 · docker で contract を実行し、成功しました: createProxyAgent instantiates an HttpsProxyAgent from a…

sha256:e31082752400314ad14ad08a63db7b25925e98a27f3171fddd95d71479b927b9

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 MIT-0

実行証拠

宣言された環境と署名済みの実行を分けてあります。このサンプルが何をどこで実行したかをそのまま確認できます。

証拠の基準
署名済みコントラクト合格
検証レシート
1
ビルドした署名鍵
1
宣言された環境 node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10

検証実行環境

環境 コントラクト ステージ 実行日
node 22 · linux alpine/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1
2026-08-21

ケース

HOW
ゴール
verify pkg:npm/https-proxy-agent@5.0.1
パッケージ
環境
node 22.23.2
作成日
2026-08-21T04:35:58Z

コントラクト

  1. createProxyAgent instantiates an HttpsProxyAgent from a string URL with parsed host, port, and protocol
  2. supports proxy authentication credentials via configuration options
  3. detects HTTPS proxy scheme and enables secureProxy mode
  4. supports proxy options object configuration with custom headers
  5. getProxyConfig extracts normalized proxy configuration from the agent instance
  6. implements callback method required for Node HTTP/HTTPS request dispatching

ファイル

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

ソースアーティファクトをダウンロード (tar.gz)

ソース

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/https-proxy-agent@5.0.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/https-proxy-agent@5.0.1
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.
csx.json
{"case":{"caseId":"case:sha256:ee305e96d1be2e19917cde6501a2b0e8abd472087780338eec802abccb57f23d","constraints":{"executionContext":"node"},"contract":["createProxyAgent instantiates an HttpsProxyAgent from a string URL with parsed host, port, and protocol","supports proxy authentication credentials via configuration options","detects HTTPS proxy scheme and enables secureProxy mode","supports proxy options object configuration with custom headers","getProxyConfig extracts normalized proxy configuration from the agent instance","implements callback method required for Node HTTP/HTTPS request dispatching"],"goal":"verify pkg:npm/https-proxy-agent@5.0.1","kind":"HOW","packages":["pkg:npm/https-proxy-agent@5.0.1"],"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/https-proxy-agent@5.0.1"],"schemaVersion":1,"subject":"pkg:npm/https-proxy-agent@5.0.1","verifierAdapter":"node-typescript@1"}
package-lock.json
{
  "name": "sample-https-proxy-agent",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-https-proxy-agent",
      "version": "1.0.0",
      "dependencies": {
        "https-proxy-agent": "5.0.1"
      }
    },
    "node_modules/agent-base": {
      "version": "6.0.2",
      "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz",
      "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==",
      "license": "MIT",
      "dependencies": {
        "debug": "4"
      },
      "engines": {
        "node": ">= 6.0.0"
      }
    },
    "node_modules/debug": {
      "version": "4.4.3",
      "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
      "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
      "license": "MIT",
      "dependencies": {
        "ms": "^2.1.3"
      },
      "engines": {
        "node": ">=6.0"
      },
      "peerDependenciesMeta": {
        "supports-color": {
          "optional": true
        }
      }
    },
    "node_modules/https-proxy-agent": {
      "version": "5.0.1",
      "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz",
      "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==",
      "license": "MIT",
      "dependencies": {
        "agent-base": "6",
        "debug": "4"
      },
      "engines": {
        "node": ">= 6"
      }
    },
    "node_modules/ms": {
      "version": "2.1.3",
      "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
      "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
      "license": "MIT"
    }
  }
}
package.json
{
  "name": "sample-https-proxy-agent",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification of https-proxy-agent",
  "main": "src/index.js",
  "dependencies": {
    "https-proxy-agent": "5.0.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify pkg:npm/https-proxy-agent@5.0.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/https-proxy-agent@5.0.1"
  ],
  "constraints": {
    "executionContext": "node"
  },
  "runtimeConditions": {
    "ecosystem": "npm",
    "language": "javascript",
    "moduleSystem": "cjs",
    "packageManager": "npm@10.9.8",
    "runtime": "node@22.23.2"
  }
}
src/index.js
const { HttpsProxyAgent } = require('https-proxy-agent');

/**
 * Creates an HttpsProxyAgent instance from a URL string or options object.
 *
 * @param {string | object} proxy - The proxy URL string or configuration options
 * @param {object} [options] - Additional agent options
 * @returns {HttpsProxyAgent} Configured HttpsProxyAgent instance
 */
function createProxyAgent(proxy, options) {
  return new HttpsProxyAgent(proxy, options);
}

/**
 * Parses and returns normalized proxy configuration details from an agent instance.
 *
 * @param {HttpsProxyAgent} agent - The HttpsProxyAgent instance
 * @returns {object} Normalized proxy configuration
 */
function getProxyConfig(agent) {
  return {
    protocol: agent.proxy.protocol,
    host: agent.proxy.host || agent.proxy.hostname,
    port: agent.proxy.port,
    auth: agent.proxy.auth || null,
    secureProxy: Boolean(agent.secureProxy)
  };
}

module.exports = {
  createProxyAgent,
  getProxyConfig,
  HttpsProxyAgent
};
test/contract.mjs
import assert from 'node:assert';
import { createRequire } from 'node:module';

const require = createRequire(import.meta.url);
const { createProxyAgent, getProxyConfig, HttpsProxyAgent } = require('../src/index.js');

// 1. Export verification
assert.strictEqual(typeof HttpsProxyAgent, 'function', 'HttpsProxyAgent should be exported as a constructor function');
assert.strictEqual(typeof createProxyAgent, 'function', 'createProxyAgent should be exported as a function');
assert.strictEqual(typeof getProxyConfig, 'function', 'getProxyConfig should be exported as a function');

// 2. createProxyAgent instantiates an HttpsProxyAgent from a string URL with parsed host, port, and protocol
const agent1 = createProxyAgent('http://127.0.0.1:8080');
assert(agent1 instanceof HttpsProxyAgent, 'agent1 should be an instance of HttpsProxyAgent');
assert.strictEqual(agent1.proxy.protocol, 'http:');
assert.strictEqual(agent1.proxy.port, 8080);
assert.strictEqual(agent1.proxy.hostname, '127.0.0.1');

// 3. supports proxy authentication credentials via configuration options
const agentAuth = createProxyAgent({
  protocol: 'http:',
  host: '127.0.0.1',
  port: 3128,
  auth: 'testuser:testpass'
});
assert.strictEqual(agentAuth.proxy.auth, 'testuser:testpass');
assert.strictEqual(agentAuth.proxy.port, 3128);

// 4. detects HTTPS proxy scheme and enables secureProxy mode
const agentTls = createProxyAgent('https://127.0.0.1:8443');
assert.strictEqual(agentTls.secureProxy, true);
assert.strictEqual(agentTls.proxy.protocol, 'https:');
assert.strictEqual(agentTls.proxy.port, 8443);

// 5. supports proxy options object configuration with custom headers
const agentOptions = createProxyAgent({
  protocol: 'http:',
  host: '127.0.0.1',
  port: 9090,
  headers: {
    'X-Custom-Proxy-Header': 'custom-proxy-value'
  }
});
assert.strictEqual(agentOptions.proxy.port, 9090);
assert.strictEqual(agentOptions.proxy.headers['X-Custom-Proxy-Header'], 'custom-proxy-value');

// 6. getProxyConfig extracts normalized proxy configuration from the agent instance
const config = getProxyConfig(agentAuth);
assert.deepStrictEqual(config, {
  protocol: 'http:',
  host: '127.0.0.1',
  port: 3128,
  auth: 'testuser:testpass',
  secureProxy: false
});

// 7. implements callback method required for Node HTTP/HTTPS request dispatching
assert.strictEqual(typeof agent1.callback, 'function', 'agent.callback should be a function');

console.log('Contract tests passed successfully.');

オリジンシーダー

匿名