Exemple
base64-js 1.5.1: toByteArray
Échantillon vérifié pour npm base64-js 1.5.1: toByteArray. Le contrat s'est exécuté sur node 22 · linux alpine/x64 · docker et a réussi.
sha256:a7030d7ff094896ed803b25ae855d0bc47c55066f08034477e687f90c5eac07f
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é
linux 24 · ubuntu · glibc 2.39 x64 npm
Environnements des exécutions de vérification
| Environnement | Contrat | Étapes | Exécution |
|---|---|---|---|
| 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 |
Cas
HOW- Objectif
- verify toByteArray in pkg:npm/base64-js@1.5.1
- Paquets
- Symboles
-
- toByteArray
- Créé
- 2026-08-26T11:24:52Z
Contrat
- toByteArray decodes standard base64 string into Uint8Array
- toByteArray decodes base64 string with double padding into Uint8Array
- toByteArray decodes base64 string with single padding into Uint8Array
- toByteArray decodes url-safe base64 string containing dash and underscore
- toByteArray returns empty Uint8Array for empty string
- toByteArray throws Error when base64 string length is not a multiple of 4
Fichiers
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- 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 toByteArray in pkg:npm/base64-js@1.5.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/base64-js@1.5.1
Demonstrate these symbols/APIs:
- toByteArray
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:a76a7b735cffb1498525dc32c4ec7f165cee9615783f7a08cffeb2b6c045cf4c","contract":["toByteArray decodes standard base64 string into Uint8Array","toByteArray decodes base64 string with double padding into Uint8Array","toByteArray decodes base64 string with single padding into Uint8Array","toByteArray decodes url-safe base64 string containing dash and underscore","toByteArray returns empty Uint8Array for empty string","toByteArray throws Error when base64 string length is not a multiple of 4"],"goal":"verify toByteArray in pkg:npm/base64-js@1.5.1","kind":"HOW","packages":["pkg:npm/base64-js@1.5.1"],"schemaVersion":1,"symbols":["toByteArray"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/base64-js@1.5.1"],"schemaVersion":1,"subject":"pkg:npm/base64-js@1.5.1","symbols":["toByteArray"],"verifierAdapter":"node-typescript@1"}
{
"name": "base64-js-verification",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "base64-js-verification",
"version": "1.0.0",
"dependencies": {
"base64-js": "1.5.1"
}
},
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
}
}
}
{
"name": "base64-js-verification",
"version": "1.0.0",
"private": true,
"description": "Clean-room verification for base64-js toByteArray",
"dependencies": {
"base64-js": "1.5.1"
}
}
{
"schemaVersion": 1,
"goal": "verify toByteArray in pkg:npm/base64-js@1.5.1",
"kind": "HOW",
"packages": [
"pkg:npm/base64-js@1.5.1"
],
"symbols": [
"toByteArray"
]
}
import assert from 'node:assert';
import base64 from 'base64-js';
const { toByteArray } = base64;
// 1. toByteArray decodes standard base64 string into Uint8Array
const standardBytes = toByteArray('Zm9vYmFy');
assert.ok(standardBytes instanceof Uint8Array);
assert.strictEqual(standardBytes.length, 6);
assert.deepStrictEqual(Array.from(standardBytes), [102, 111, 111, 98, 97, 114]);
// 2. toByteArray decodes base64 string with double padding into Uint8Array
const doublePadded = toByteArray('AQ==');
assert.ok(doublePadded instanceof Uint8Array);
assert.strictEqual(doublePadded.length, 1);
assert.deepStrictEqual(Array.from(doublePadded), [1]);
// 3. toByteArray decodes base64 string with single padding into Uint8Array
const singlePadded = toByteArray('AQI=');
assert.ok(singlePadded instanceof Uint8Array);
assert.strictEqual(singlePadded.length, 2);
assert.deepStrictEqual(Array.from(singlePadded), [1, 2]);
// 4. toByteArray decodes url-safe base64 string containing dash and underscore
const urlSafeBytes = toByteArray('-_8=');
assert.ok(urlSafeBytes instanceof Uint8Array);
assert.strictEqual(urlSafeBytes.length, 2);
assert.deepStrictEqual(Array.from(urlSafeBytes), [0xFB, 0xFF]);
// 5. toByteArray returns empty Uint8Array for empty string
const emptyBytes = toByteArray('');
assert.ok(emptyBytes instanceof Uint8Array);
assert.strictEqual(emptyBytes.length, 0);
// 6. toByteArray throws Error when base64 string length is not a multiple of 4
assert.throws(
() => toByteArray('abc'),
{
name: 'Error',
message: 'Invalid string. Length must be a multiple of 4'
}
);
Seeder d'origine
anonyme