Sample
basic-ftp 5.3.1: parseList
Verified sample for npm basic-ftp 5.3.1: parseList. The contract ran on node 22 · linux alpine/x64 · docker and passed: parseList parses Unix-style directory…
sha256:9f28049b832d2040adddb62e2de719b5897b4c77f552eea73484a467bb885215
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
- 2
- Signing keys that built it
- 1
Declared environment
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
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@1node:22-alpine@sha256:c610fcdfb1d5… |
2026-08-26 |
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-07 |
Case
HOW- Goal
- verify basic-ftp.parseList in pkg:npm/basic-ftp@5.3.1
- Packages
- Symbols
-
- basic-ftp.parseList
- Environment
- node 22.23.2
- Created
- 2026-08-26T12:31:37Z
Contract
- parseList parses Unix-style directory listings into FileInfo objects with name, size, type, permissions, and symlink target
- parseList parses DOS-style directory listings into FileInfo objects with directory or file classification, size, and timestamp
- parseList parses RFC 3659 MLSD directory listings into FileInfo objects with parsed Date modifiedAt and Unix permissions
- parseList returns an empty array for empty directory listings or header-only total lines
- parseList throws an Error when encountering unsupported directory listing formats
Files
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.js
- 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 basic-ftp.parseList in pkg:npm/basic-ftp@5.3.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/basic-ftp@5.3.1
Demonstrate these symbols/APIs:
- basic-ftp.parseList
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:2f92a9760d3dbdf0848b5ba2f77e82f84cab2a1f395bbe5004edff9b06eba46d","constraints":{"executionContext":"node"},"contract":["parseList parses Unix-style directory listings into FileInfo objects with name, size, type, permissions, and symlink target","parseList parses DOS-style directory listings into FileInfo objects with directory or file classification, size, and timestamp","parseList parses RFC 3659 MLSD directory listings into FileInfo objects with parsed Date modifiedAt and Unix permissions","parseList returns an empty array for empty directory listings or header-only total lines","parseList throws an Error when encountering unsupported directory listing formats"],"goal":"verify basic-ftp.parseList in pkg:npm/basic-ftp@5.3.1","kind":"HOW","packages":["pkg:npm/basic-ftp@5.3.1"],"schemaVersion":1,"symbols":["basic-ftp.parseList"]},"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/basic-ftp@5.3.1"],"schemaVersion":1,"subject":"pkg:npm/basic-ftp@5.3.1","symbols":["basic-ftp.parseList"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-basic-ftp-parselist",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-basic-ftp-parselist",
"version": "1.0.0",
"dependencies": {
"basic-ftp": "5.3.1"
}
},
"node_modules/basic-ftp": {
"version": "5.3.1",
"resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.3.1.tgz",
"integrity": "sha512-bopVNp6ugyA150DDuZfPFdt1KZ5a94ZDiwX4hMgZDzF+GttD80lEy8kj98kbyhLXnPvhtIo93mdnLIjpCAeeOw==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
}
}
}
}
{
"name": "sample-basic-ftp-parselist",
"version": "1.0.0",
"private": true,
"description": "CodeSampleX sample for basic-ftp parseList",
"main": "src/index.js",
"dependencies": {
"basic-ftp": "5.3.1"
}
}
{
"schemaVersion": 1,
"goal": "verify basic-ftp.parseList in pkg:npm/basic-ftp@5.3.1",
"kind": "HOW",
"packages": [
"pkg:npm/basic-ftp@5.3.1"
],
"symbols": [
"basic-ftp.parseList"
]
}
const { parseList, FileInfo, FileType } = require('basic-ftp');
/**
* Parses raw FTP directory listing strings across Unix, DOS, and MLSD formats.
*
* @param {string} rawListing - Raw FTP directory listing text.
* @returns {FileInfo[]} Array of parsed FileInfo descriptors.
*/
function parseFtpListing(rawListing) {
return parseList(rawListing);
}
module.exports = {
parseList,
FileInfo,
FileType,
parseFtpListing
};
import assert from 'node:assert/strict';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const { parseList, FileInfo, FileType, parseFtpListing } = require('../src/index.js');
async function runContractTests() {
// 1. parseList parses Unix-style directory listings into FileInfo objects with name, size, type, permissions, and symlink target
const unixListing = [
'-rw-r--r-- 1 owner staff 1024 Jan 15 10:30 document.txt',
'drwxr-xr-x 2 owner staff 4096 Jan 15 10:31 folder',
'lrwxrwxrwx 1 owner staff 12 Jan 15 10:32 symlink -> document.txt'
].join('\r\n') + '\r\n';
const unixFiles = parseFtpListing(unixListing);
assert.equal(Array.isArray(unixFiles), true, 'parseList must return an array');
assert.equal(unixFiles.length, 3, 'Must parse 3 Unix directory items');
const unixFile = unixFiles[0];
assert.equal(unixFile.name, 'document.txt');
assert.equal(unixFile.size, 1024);
assert.equal(unixFile.type, FileType.File);
assert.equal(unixFile.isFile, true);
assert.equal(unixFile.isDirectory, false);
assert.equal(unixFile.isSymbolicLink, false);
assert.equal(unixFile.user, 'owner');
assert.equal(unixFile.group, 'staff');
assert.deepEqual(unixFile.permissions, { user: 6, group: 4, world: 4 });
assert.equal(unixFile.rawModifiedAt, 'Jan 15 10:30');
const unixDir = unixFiles[1];
assert.equal(unixDir.name, 'folder');
assert.equal(unixDir.size, 4096);
assert.equal(unixDir.type, FileType.Directory);
assert.equal(unixDir.isFile, false);
assert.equal(unixDir.isDirectory, true);
assert.equal(unixDir.isSymbolicLink, false);
const unixLink = unixFiles[2];
assert.equal(unixLink.name, 'symlink');
assert.equal(unixLink.link, 'document.txt');
assert.equal(unixLink.type, FileType.SymbolicLink);
assert.equal(unixLink.isFile, false);
assert.equal(unixLink.isDirectory, false);
assert.equal(unixLink.isSymbolicLink, true);
// 2. parseList parses DOS-style directory listings into FileInfo objects with directory or file classification, size, and timestamp
const dosListing = [
'01-15-22 02:30PM <DIR> subdir',
'01-15-22 03:45PM 2048 archive.zip'
].join('\r\n') + '\r\n';
const dosFiles = parseList(dosListing);
assert.equal(dosFiles.length, 2, 'Must parse 2 DOS directory items');
const dosDir = dosFiles[0];
assert.equal(dosDir.name, 'subdir');
assert.equal(dosDir.type, FileType.Directory);
assert.equal(dosDir.isDirectory, true);
assert.equal(dosDir.size, 0);
assert.equal(dosDir.rawModifiedAt, '01-15-22 02:30PM');
const dosFile = dosFiles[1];
assert.equal(dosFile.name, 'archive.zip');
assert.equal(dosFile.type, FileType.File);
assert.equal(dosFile.isFile, true);
assert.equal(dosFile.size, 2048);
assert.equal(dosFile.rawModifiedAt, '01-15-22 03:45PM');
// 3. parseList parses RFC 3659 MLSD directory listings into FileInfo objects with parsed Date modifiedAt and Unix permissions
const mlsdListing = [
'type=file;size=512;modify=20230115123000;UNIX.mode=0644; notes.txt',
'type=dir;modify=20230115123000;UNIX.mode=0755; photos'
].join('\r\n') + '\r\n';
const mlsdFiles = parseList(mlsdListing);
assert.equal(mlsdFiles.length, 2, 'Must parse 2 MLSD items');
const mlsdFile = mlsdFiles[0];
assert.equal(mlsdFile.name, 'notes.txt');
assert.equal(mlsdFile.type, FileType.File);
assert.equal(mlsdFile.isFile, true);
assert.equal(mlsdFile.size, 512);
assert(mlsdFile.modifiedAt instanceof Date, 'modifiedAt should be parsed Date');
assert.equal(mlsdFile.modifiedAt.toISOString(), '2023-01-15T12:30:00.000Z');
assert.deepEqual(mlsdFile.permissions, { user: 6, group: 4, world: 4 });
const mlsdDir = mlsdFiles[1];
assert.equal(mlsdDir.name, 'photos');
assert.equal(mlsdDir.type, FileType.Directory);
assert.equal(mlsdDir.isDirectory, true);
assert(mlsdDir.modifiedAt instanceof Date, 'modifiedAt should be parsed Date');
assert.deepEqual(mlsdDir.permissions, { user: 7, group: 5, world: 5 });
// 4. parseList returns an empty array for empty directory listings or header-only total lines
assert.deepEqual(parseList(''), [], 'Empty string listing should return empty array');
assert.deepEqual(parseList(' \r\n \n'), [], 'Whitespace listing should return empty array');
assert.deepEqual(parseList('total 0\r\n'), [], 'total header line should return empty array');
// 5. parseList throws an Error when encountering unsupported directory listing formats
assert.throws(
() => parseList('UNKNOWN NON-COMPLIANT FORMAT LINE 12345'),
/only supports MLSD, Unix- or DOS-style/,
'Should throw descriptive Error for unsupported listing format'
);
}
runContractTests().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
Origin Seeder
anonymous