CodeSampleX

Sample

base64-js 1.5.1: toByteArray

Verified sample for npm base64-js 1.5.1: toByteArray. The contract ran on node 22 · linux alpine/x64 · docker and passed: toByteArray decodes standard base64…

sha256:a7030d7ff094896ed803b25ae855d0bc47c55066f08034477e687f90c5eac07f

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
1
Signing keys that built it
1
Declared environment linux 24 · ubuntu · glibc 2.39 x64 npm

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

Case

HOW
Goal
verify toByteArray in pkg:npm/base64-js@1.5.1
Packages
Symbols
  • toByteArray
Created
2026-08-26T11:24:52Z

Contract

  1. toByteArray decodes standard base64 string into Uint8Array
  2. toByteArray decodes base64 string with double padding into Uint8Array
  3. toByteArray decodes base64 string with single padding into Uint8Array
  4. toByteArray decodes url-safe base64 string containing dash and underscore
  5. toByteArray returns empty Uint8Array for empty string
  6. toByteArray throws Error when base64 string length is not a multiple of 4

Files

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

Download the source artifact (tar.gz)

Source

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 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.
csx.json
{"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"}
package-lock.json
{
  "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"
    }
  }
}
package.json
{
  "name": "base64-js-verification",
  "version": "1.0.0",
  "private": true,
  "description": "Clean-room verification for base64-js toByteArray",
  "dependencies": {
    "base64-js": "1.5.1"
  }
}
spec.json
{
  "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"
  ]
}
test/contract.mjs
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'
  }
);

Origin Seeder

anonymous