Exemple
pdfjs-dist 6.5.438
Échantillon vérifié pour npm pdfjs-dist 6.5.438. Le contrat s'est exécuté sur node 22 · linux debian/x64 · docker et a réussi.
sha256:f7dcb9a96ff8a3065e6d7fb3e717a823d9e02472cffa96c5e285b515d19cd30e
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 debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-11-26 |
Cas
HOW- Objectif
- verify pkg:npm/pdfjs-dist@6.5.438
- Paquets
- Environnement
- node 22.23.2
- Créé
- 2026-11-26T23:42:36Z
Contrat
- Importing pdfjs-dist/legacy/build/pdf.mjs in Node.js ESM exports version 6.5.438, getDocument, VerbosityLevel, and InvalidPDFException
- getDocument({ data: Uint8Array, verbosity: VerbosityLevel.ERRORS }).promise loads an in-memory multi-page PDF without a browser DOM or network access
- PDFDocumentProxy exposes numPages, getMetadata().info (Title and Author), and getPage(n) returning PageViewport dimensions and getTextContent() text items
- PDFDocumentProxy.destroy() is absent in pdfjs-dist@6.5.438; teardown uses loadingTask.destroy() (doc.loadingTask.destroy())
- getDocument rejects a Node.js Buffer passed as data with an Error requiring Uint8Array
- getDocument rejects malformed PDF bytes with InvalidPDFException
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- 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/pdfjs-dist@6.5.438
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/pdfjs-dist@6.5.438
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:c04567529d8b3c512ea5b45f47562a8ca51065c70c6297a1a2ff54002700148e","constraints":{"executionContext":"node"},"contract":["Importing pdfjs-dist/legacy/build/pdf.mjs in Node.js ESM exports version 6.5.438, getDocument, VerbosityLevel, and InvalidPDFException","getDocument({ data: Uint8Array, verbosity: VerbosityLevel.ERRORS }).promise loads an in-memory multi-page PDF without a browser DOM or network access","PDFDocumentProxy exposes numPages, getMetadata().info (Title and Author), and getPage(n) returning PageViewport dimensions and getTextContent() text items","PDFDocumentProxy.destroy() is absent in pdfjs-dist@6.5.438; teardown uses loadingTask.destroy() (doc.loadingTask.destroy())","getDocument rejects a Node.js Buffer passed as data with an Error requiring Uint8Array","getDocument rejects malformed PDF bytes with InvalidPDFException"],"goal":"verify pkg:npm/pdfjs-dist@6.5.438","kind":"HOW","packages":["pkg:npm/pdfjs-dist@6.5.438"],"schemaVersion":1},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"esm","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/pdfjs-dist@6.5.438"],"schemaVersion":1,"subject":"pkg:npm/pdfjs-dist@6.5.438","verifierAdapter":"node-typescript@1"}
{
"name": "verify-pdfjs-dist",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "verify-pdfjs-dist",
"version": "1.0.0",
"dependencies": {
"pdfjs-dist": "6.5.438"
}
},
"node_modules/@napi-rs/canvas": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas/-/canvas-1.2.1.tgz",
"integrity": "sha512-dTFJYKi4eE9Yr9FlLi7hN/Q+15VVmpnA1HrKkTzGQuWiVw5MWBL2reLXAaXUMENmzKxtlqYCtCp1NIeQqx+uEA==",
"license": "MIT",
"optional": true,
"workspaces": [
"e2e/*"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
},
"optionalDependencies": {
"@napi-rs/canvas-android-arm64": "1.2.1",
"@napi-rs/canvas-darwin-arm64": "1.2.1",
"@napi-rs/canvas-darwin-x64": "1.2.1",
"@napi-rs/canvas-linux-arm-gnueabihf": "1.2.1",
"@napi-rs/canvas-linux-arm64-gnu": "1.2.1",
"@napi-rs/canvas-linux-arm64-musl": "1.2.1",
"@napi-rs/canvas-linux-riscv64-gnu": "1.2.1",
"@napi-rs/canvas-linux-x64-gnu": "1.2.1",
"@napi-rs/canvas-linux-x64-musl": "1.2.1",
"@napi-rs/canvas-win32-arm64-msvc": "1.2.1",
"@napi-rs/canvas-win32-x64-msvc": "1.2.1"
}
},
"node_modules/@napi-rs/canvas-android-arm64": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-android-arm64/-/canvas-android-arm64-1.2.1.tgz",
"integrity": "sha512-CtM+0Xieqc8jMyIm6sPLbnvDut4/BmSAP+HQnbbwPcw3ZG+bY1NhwndtpOzAPcNbIPyWuiShSF99/Ja7vYeXbw==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-darwin-arm64": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-darwin-arm64/-/canvas-darwin-arm64-1.2.1.tgz",
"integrity": "sha512-DazlaWwTa1xIdROpA8e95ttU4yNedl6brXbqBm+upoQ/1WIpmDu4zwanYp6ftGIbrjMld/OjJK15kFrDPWLoEQ==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-darwin-x64": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-darwin-x64/-/canvas-darwin-x64-1.2.1.tgz",
"integrity": "sha512-XU9zFjeRusfeP49/Dk4CNqvMzxOiBtrl6Qoyndp2Wxk0LhJxgiUhhSMGLIripipZZKfKJOo1h/k8FswMVk0PuA==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-arm-gnueabihf": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm-gnueabihf/-/canvas-linux-arm-gnueabihf-1.2.1.tgz",
"integrity": "sha512-24R1MI8ZcWSrqU5rD+hRelWsoExMc4Bo8vRbIIge4f5X97P4pvrPMIMV0e5szSyU9y5aF8gA+CCXwWWRwFthYg==",
"cpu": [
"arm"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-arm64-gnu": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm64-gnu/-/canvas-linux-arm64-gnu-1.2.1.tgz",
"integrity": "sha512-2pxxAlQ3wTYxqZnuqXhQbE4sTvLC1/dYkuPpudggCgvQXRb6KYm6K01UAL2kWqpkTqFmy6kHfIjLJ/86vQhOnQ==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-arm64-musl": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-arm64-musl/-/canvas-linux-arm64-musl-1.2.1.tgz",
"integrity": "sha512-+Ksk8ilbmbA4oMu+BfOL/WZMeDY0Z40TblthqS8Ssr6K7MFXh9707O1H3uJcVx3H7plXWsDuycGai20FBRO0sg==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-riscv64-gnu": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-riscv64-gnu/-/canvas-linux-riscv64-gnu-1.2.1.tgz",
"integrity": "sha512-B7Y0cljUn/kTmDiSJ7q94axEvQMJLoJZX8FDf8+JdvAkQiUR2tHnDomGIxtHsvXGmzf3UE736YdtvNLEfCDjdg==",
"cpu": [
"riscv64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-x64-gnu": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-x64-gnu/-/canvas-linux-x64-gnu-1.2.1.tgz",
"integrity": "sha512-1/7y8Yx589PcQE8Xuvc0ZLRwEsjA1FonfV+ZWUS4s+pwI6Aa5i+VHUhAv+pR1692A+mIjuaH5FpH89+CFK0Nng==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-linux-x64-musl": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-linux-x64-musl/-/canvas-linux-x64-musl-1.2.1.tgz",
"integrity": "sha512-fiO90vFdt9Kq3v+sPHSczzbpRi2CTMx6NQdfD31zfJFeouXVR8EeiGyHpXuV5wwE6ui7IQLmVTHq7Uz3V0xq/w==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-win32-arm64-msvc": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-win32-arm64-msvc/-/canvas-win32-arm64-msvc-1.2.1.tgz",
"integrity": "sha512-COZrzxhGGpWwP+3xMtppDz3J7ycLKsIZfClKxAmJRZFR5sVmiujy+ShnMyzmQtzTzpFInxkzQ35maAxYjR88kA==",
"cpu": [
"arm64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/@napi-rs/canvas-win32-x64-msvc": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/@napi-rs/canvas-win32-x64-msvc/-/canvas-win32-x64-msvc-1.2.1.tgz",
"integrity": "sha512-oPzPLrFlox/NAcqVVT8mHaXF0FsQ2XXX3nWy/l5yV/NksxBf9V/nnCes+O5fz+xzzwDNVjL5EOk7+siz5HmfCA==",
"cpu": [
"x64"
],
"license": "MIT",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">= 10"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/Brooooooklyn"
}
},
"node_modules/pdfjs-dist": {
"version": "6.5.438",
"resolved": "https://registry.npmjs.org/pdfjs-dist/-/pdfjs-dist-6.5.438.tgz",
"integrity": "sha512-vg8Pw1x+AFKy4AMDvhuWl5cOYV8d698UoEANoFFhc79hqXDnZQqnOXoxw3HG907WHOg1JYOvLhP756boddFxpA==",
"license": "Apache-2.0",
"engines": {
"node": ">=22.13.0 || >=24"
},
"optionalDependencies": {
"@napi-rs/canvas": "^1.0.13"
}
}
}
}
{
"name": "verify-pdfjs-dist",
"version": "1.0.0",
"private": true,
"type": "module",
"scripts": {
"test": "node test/contract.mjs"
},
"dependencies": {
"pdfjs-dist": "6.5.438"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/pdfjs-dist@6.5.438",
"kind": "HOW",
"packages": [
"pkg:npm/pdfjs-dist@6.5.438"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
import * as pdfjsLib from "pdfjs-dist/legacy/build/pdf.mjs";
/**
* Build a minimal, valid multi-page PDF 1.4 document in memory as a Uint8Array.
* @param {{ title: string, author: string, pages: string[] }} spec
* @returns {Uint8Array}
*/
export function buildMinimalPdf({ title, author, pages }) {
const escapePdfString = (s) =>
s.replace(/\\/g, "\\\\").replace(/\(/g, "\\(").replace(/\)/g, "\\)");
// Object layout:
// 1: Catalog
// 2: Pages
// 3: Font (Helvetica)
// 4: Info
// For each page i (0-based):
// 5 + 2*i: Page object
// 6 + 2*i: Content stream object
const pageObjNums = pages.map((_, i) => 5 + i * 2);
const objects = [];
objects.push(`1 0 obj\n<< /Type /Catalog /Pages 2 0 R >>\nendobj\n`);
objects.push(
`2 0 obj\n<< /Type /Pages /Kids [${pageObjNums
.map((n) => `${n} 0 R`)
.join(" ")}] /Count ${pages.length} >>\nendobj\n`
);
objects.push(
`3 0 obj\n<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>\nendobj\n`
);
objects.push(
`4 0 obj\n<< /Title (${escapePdfString(title)}) /Author (${escapePdfString(
author
)}) >>\nendobj\n`
);
for (let i = 0; i < pages.length; i++) {
const pageNum = 5 + i * 2;
const contentNum = 6 + i * 2;
const stream = `BT /F1 18 Tf 72 720 Td (${escapePdfString(
pages[i]
)}) Tj ET\n`;
const streamLen = Buffer.byteLength(stream, "utf8");
objects.push(
`${pageNum} 0 obj\n<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 3 0 R >> >> /Contents ${contentNum} 0 R >>\nendobj\n`
);
objects.push(
`${contentNum} 0 obj\n<< /Length ${streamLen} >>\nstream\n${stream}endstream\nendobj\n`
);
}
let body = "%PDF-1.4\n";
const offsets = [0];
for (const obj of objects) {
offsets.push(Buffer.byteLength(body, "utf8"));
body += obj;
}
const xrefOffset = Buffer.byteLength(body, "utf8");
let xref = `xref\n0 ${offsets.length}\n`;
xref += "0000000000 65535 f \n";
for (let i = 1; i < offsets.length; i++) {
xref += `${String(offsets[i]).padStart(10, "0")} 00000 n \n`;
}
const trailer = `trailer\n<< /Size ${offsets.length} /Root 1 0 R /Info 4 0 R >>\nstartxref\n${xrefOffset}\n%%EOF\n`;
return new Uint8Array(Buffer.from(body + xref + trailer, "utf8"));
}
/**
* Inspect a PDF from binary Uint8Array data using pdfjs-dist in Node.js.
* @param {Uint8Array} data
*/
export async function inspectPdf(data) {
const loadingTask = pdfjsLib.getDocument({
data,
verbosity: pdfjsLib.VerbosityLevel.ERRORS,
});
const doc = await loadingTask.promise;
try {
const metadata = await doc.getMetadata();
const pages = [];
for (let pageNumber = 1; pageNumber <= doc.numPages; pageNumber++) {
const page = await doc.getPage(pageNumber);
const viewport = page.getViewport({ scale: 1 });
const textContent = await page.getTextContent();
const text = textContent.items
.map((item) => ("str" in item ? item.str : ""))
.join("")
.trim();
pages.push({
pageNumber,
width: viewport.width,
height: viewport.height,
text,
});
page.cleanup();
}
return {
version: pdfjsLib.version,
numPages: doc.numPages,
info: metadata.info,
hasDocDestroy: typeof doc.destroy === "function",
hasLoadingTaskDestroy: typeof doc.loadingTask.destroy === "function",
pages,
};
} finally {
await loadingTask.destroy();
}
}
export { pdfjsLib };
import assert from "node:assert/strict";
import { buildMinimalPdf, inspectPdf, pdfjsLib } from "../src/index.mjs";
// 1. Verify library version export
assert.equal(pdfjsLib.version, "6.5.438");
// 2. Parse a valid multi-page in-memory PDF (Uint8Array) and extract metadata, viewports, and text
const pdfBytes = buildMinimalPdf({
title: "Sample Contract Document",
author: "Clean Room Spec",
pages: ["Hello PDF.js 6.5", "Second page content"],
});
const result = await inspectPdf(pdfBytes);
assert.equal(result.version, "6.5.438");
assert.equal(result.numPages, 2);
assert.equal(result.info.Title, "Sample Contract Document");
assert.equal(result.info.Author, "Clean Room Spec");
assert.equal(result.hasDocDestroy, false, "PDFDocumentProxy.destroy() is removed in pdfjs-dist v6");
assert.equal(result.hasLoadingTaskDestroy, true, "use loadingTask.destroy() to tear down document and worker");
assert.deepEqual(result.pages, [
{ pageNumber: 1, width: 612, height: 792, text: "Hello PDF.js 6.5" },
{ pageNumber: 2, width: 612, height: 792, text: "Second page content" },
]);
// 3. Reject Node.js Buffer input directly (pdfjs-dist requires Uint8Array, not Buffer)
const pdfBuffer = Buffer.from(
buildMinimalPdf({
title: "Buffer Check",
author: "Clean Room Spec",
pages: ["Buffer test"],
})
);
let bufferError = null;
try {
await pdfjsLib.getDocument({
data: pdfBuffer,
verbosity: pdfjsLib.VerbosityLevel.ERRORS,
}).promise;
} catch (err) {
bufferError = err;
}
assert.ok(bufferError instanceof Error, "expected error for Buffer input");
assert.match(bufferError.message, /Uint8Array/i);
// 4. Reject invalid PDF bytes with InvalidPDFException
const invalidBytes = new Uint8Array(Buffer.from("not a valid pdf file", "utf8"));
await assert.rejects(
() =>
pdfjsLib.getDocument({
data: invalidBytes,
verbosity: pdfjsLib.VerbosityLevel.ERRORS,
}).promise,
(err) => {
assert.ok(err instanceof pdfjsLib.InvalidPDFException);
assert.equal(err.name, "InvalidPDFException");
return true;
}
);
console.log("PASS: pdfjs-dist@6.5.438 contract verified");
Seeder d'origine
anonyme