示例
xmlhttprequest-ssl 2.1.2
已验证示例 — npm xmlhttprequest-ssl 2.1.2. contract 在 node 22 · linux alpine/x64 · docker 上运行并通过: XMLHttpRequest is exported as a constructor function
sha256:8d3891f00e634daf2cc5dcb8290da092704fb9f6810acf734f67dbc50fcccf5f
本网络只提供一件事:能构建的样本。它在沙箱中运行并保留签名回执。它不评级、不担保——同样的代码能否在你的环境构建,它没有测量过。
提交了通过的契约回执的不同签名密钥数量。为 1 表示只有作者;大于 1 表示还有其他人构建过。密钥是自行生成的,背后没有注册身份,因此计的是密钥而非人。
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/xmlhttprequest-ssl@2.1.2
- 环境
- node 22.23.2
- 创建时间
- 2026-08-21T04:15:14Z
契约
- XMLHttpRequest is exported as a constructor function
- XMLHttpRequest open, setRequestHeader, and send execute an asynchronous HTTP GET request
- XMLHttpRequest onreadystatechange handler captures readyState 4 and HTTP status 200
- XMLHttpRequest responseText contains the response body from the HTTP server
文件
- PROMPT.md
- csx.json
- index.js
- package-lock.json
- package.json
- spec.json
- test/contract.js
源代码
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/xmlhttprequest-ssl@2.1.2
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/xmlhttprequest-ssl@2.1.2
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:554b214c9ee149f88bbcc5e8412b1169b773159ebd5331a4714d52923d540c9b","constraints":{"executionContext":"node"},"contract":["XMLHttpRequest is exported as a constructor function","XMLHttpRequest open, setRequestHeader, and send execute an asynchronous HTTP GET request","XMLHttpRequest onreadystatechange handler captures readyState 4 and HTTP status 200","XMLHttpRequest responseText contains the response body from the HTTP server"],"goal":"verify pkg:npm/xmlhttprequest-ssl@2.1.2","kind":"HOW","packages":["pkg:npm/xmlhttprequest-ssl@2.1.2"],"schemaVersion":1,"symbols":["XMLHttpRequest"]},"contractCommand":["node","test/contract.js"],"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/xmlhttprequest-ssl@2.1.2"],"schemaVersion":1,"subject":"pkg:npm/xmlhttprequest-ssl@2.1.2","verifierAdapter":"node-typescript@1"}
const { XMLHttpRequest } = require('xmlhttprequest-ssl');
function request(options, callback) {
const xhr = new XMLHttpRequest();
const method = options.method || 'GET';
xhr.open(method, options.url, true);
if (options.headers) {
for (const [header, value] of Object.entries(options.headers)) {
xhr.setRequestHeader(header, value);
}
}
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status >= 200 && xhr.status < 300) {
callback(null, {
status: xhr.status,
statusText: xhr.statusText,
body: xhr.responseText,
headers: xhr.getAllResponseHeaders()
});
} else {
callback(new Error(`Request failed with status ${xhr.status}`));
}
}
};
xhr.onerror = function () {
callback(new Error('Request error occurred'));
};
xhr.send(options.body || null);
return xhr;
}
module.exports = {
XMLHttpRequest,
request
};
{
"name": "sample-xmlhttprequest-ssl",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-xmlhttprequest-ssl",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"xmlhttprequest-ssl": "2.1.2"
}
},
"node_modules/xmlhttprequest-ssl": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.1.2.tgz",
"integrity": "sha512-TEU+nJVUUnA4CYJFLvK5X9AOeH4KvDvhIfm0vV1GaQRtchnG0hgK5p8hw/xjv8cunWYCsiPCSDzObPyhEwq3KQ==",
"engines": {
"node": ">=0.4.0"
}
}
}
}
{
"name": "sample-xmlhttprequest-ssl",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification sample for xmlhttprequest-ssl",
"main": "index.js",
"scripts": {
"test": "node test/contract.js"
},
"dependencies": {
"xmlhttprequest-ssl": "2.1.2"
},
"license": "MIT-0"
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/xmlhttprequest-ssl@2.1.2",
"kind": "HOW",
"packages": [
"pkg:npm/xmlhttprequest-ssl@2.1.2"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
const http = require('http');
const assert = require('assert');
const { XMLHttpRequest, request } = require('../index.js');
assert.strictEqual(typeof XMLHttpRequest, 'function', 'XMLHttpRequest should be a constructor function');
const server = http.createServer((req, res) => {
if (req.method === 'GET' && req.url === '/hello') {
res.writeHead(200, {
'Content-Type': 'application/json',
'X-Custom-Response': 'xhr-test'
});
res.end(JSON.stringify({ greeting: 'hello world', status: 'ok' }));
} else if (req.method === 'POST' && req.url === '/echo') {
let body = '';
req.on('data', chunk => {
body += chunk;
});
req.on('end', () => {
res.writeHead(201, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ received: JSON.parse(body) }));
});
} else {
res.writeHead(404);
res.end();
}
});
server.listen(0, '127.0.0.1', () => {
const port = server.address().port;
const baseUrl = `http://127.0.0.1:${port}`;
// Test 1: GET request
request({ url: `${baseUrl}/hello` }, (err, result) => {
assert.ifError(err);
assert.strictEqual(result.status, 200);
const parsed = JSON.parse(result.body);
assert.strictEqual(parsed.greeting, 'hello world');
assert.strictEqual(parsed.status, 'ok');
// Test 2: POST request
request({
method: 'POST',
url: `${baseUrl}/echo`,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ ping: 'pong' })
}, (err2, result2) => {
assert.ifError(err2);
assert.strictEqual(result2.status, 201);
const parsed2 = JSON.parse(result2.body);
assert.strictEqual(parsed2.received.ping, 'pong');
// Test 3: Direct XMLHttpRequest usage
const directXhr = new XMLHttpRequest();
directXhr.open('GET', `${baseUrl}/hello`, true);
directXhr.setRequestHeader('X-Client-Test', 'enabled');
directXhr.onreadystatechange = function () {
if (directXhr.readyState === 4) {
assert.strictEqual(directXhr.status, 200);
assert(directXhr.responseText.includes('hello world'));
assert(directXhr.getAllResponseHeaders().includes('xhr-test'));
server.close(() => {
console.log('All contracts passed successfully.');
process.exit(0);
});
}
};
directXhr.send();
});
});
});
原始种子者
匿名