CodeSampleX

Sample

@electron/asar 3.4.1: uncacheAll

Verified sample for npm @electron/asar 3.4.1: uncacheAll. The contract ran on node 22 · linux debian/x64 · docker and passed: uncacheAll is exported as a…

sha256:716661936666a4cedccdbc7d862f26ada3b87b97dad65b61087b84f40700d368

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 debian/x64 · docker ed25519:c1973797be207ac4 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2…
2026-09-05

Case

HOW
Goal
verify @electron/asar.uncacheAll in pkg:npm/%40electron/asar@3.4.1
Packages
Symbols
  • @electron/asar.uncacheAll
Created
2026-09-05T17:24:59Z

Contract

  1. uncacheAll is exported as a function by @electron/asar
  2. uncacheAll executes safely without throwing when cache is empty
  3. accessing archive metadata or contents caches filesystem records for multiple archives
  4. uncacheAll clears all cached filesystem entries across all archives in a single call
  5. uncacheAll invalidates stale filesystem headers when an archive file is modified on disk
  6. uncacheAll allows subsequent archive reads to succeed and re-populate the cache

Files

  • PROMPT.md
  • csx.json
  • index.mjs
  • 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 @electron/asar.uncacheAll in pkg:npm/%40electron/asar@3.4.1
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:npm/%40electron/asar@3.4.1
Demonstrate these symbols/APIs:
  - @electron/asar.uncacheAll

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:fbadd6dde751f7b60395557500f3d2310c214ef6fd4da3af777ef3307dabaa28","contract":["uncacheAll is exported as a function by @electron/asar","uncacheAll executes safely without throwing when cache is empty","accessing archive metadata or contents caches filesystem records for multiple archives","uncacheAll clears all cached filesystem entries across all archives in a single call","uncacheAll invalidates stale filesystem headers when an archive file is modified on disk","uncacheAll allows subsequent archive reads to succeed and re-populate the cache"],"goal":"verify @electron/asar.uncacheAll in pkg:npm/%40electron/asar@3.4.1","kind":"HOW","packages":["pkg:npm/%40electron/asar@3.4.1"],"schemaVersion":1,"symbols":["@electron/asar.uncacheAll"]},"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/%40electron/asar@3.4.1"],"schemaVersion":1,"subject":"pkg:npm/%40electron/asar@3.4.1","symbols":["@electron/asar.uncacheAll"],"verifierAdapter":"node-typescript@1"}
index.mjs
import asar from '@electron/asar';

export const {
  createPackage,
  createPackageWithOptions,
  createPackageFromFiles,
  createPackageFromStreams,
  statFile,
  listPackage,
  extractFile,
  extractAll,
  uncache,
  uncacheAll
} = asar;

/**
 * Purges all cached filesystem headers from internal asar cache.
 */
export function clearAllCaches() {
  uncacheAll();
}

export default asar;
package-lock.json
{
  "name": "sample-asar-uncache-all",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "sample-asar-uncache-all",
      "version": "1.0.0",
      "license": "MIT-0",
      "dependencies": {
        "@electron/asar": "3.4.1"
      }
    },
    "node_modules/@electron/asar": {
      "version": "3.4.1",
      "resolved": "https://registry.npmjs.org/@electron/asar/-/asar-3.4.1.tgz",
      "integrity": "sha512-i4/rNPRS84t0vSRa2HorerGRXWyF4vThfHesw0dmcWHp+cspK743UanA0suA5Q5y8kzY2y6YKrvbIUn69BCAiA==",
      "license": "MIT",
      "dependencies": {
        "commander": "^5.0.0",
        "glob": "^7.1.6",
        "minimatch": "^3.0.4"
      },
      "bin": {
        "asar": "bin/asar.js"
      },
      "engines": {
        "node": ">=10.12.0"
      }
    },
    "node_modules/balanced-match": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
      "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
      "license": "MIT"
    },
    "node_modules/brace-expansion": {
      "version": "1.1.18",
      "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
      "integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
      "license": "MIT",
      "dependencies": {
        "balanced-match": "^1.0.0",
        "concat-map": "0.0.1"
      }
    },
    "node_modules/commander": {
      "version": "5.1.0",
      "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz",
      "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==",
      "license": "MIT",
      "engines": {
        "node": ">= 6"
      }
    },
    "node_modules/concat-map": {
      "version": "0.0.1",
      "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
      "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
      "license": "MIT"
    },
    "node_modules/fs.realpath": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
      "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
      "license": "ISC"
    },
    "node_modules/glob": {
      "version": "7.2.3",
      "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
      "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
      "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me",
      "license": "ISC",
      "dependencies": {
        "fs.realpath": "^1.0.0",
        "inflight": "^1.0.4",
        "inherits": "2",
        "minimatch": "^3.1.1",
        "once": "^1.3.0",
        "path-is-absolute": "^1.0.0"
      },
      "engines": {
        "node": "*"
      },
      "funding": {
        "url": "https://github.com/sponsors/isaacs"
      }
    },
    "node_modules/inflight": {
      "version": "1.0.6",
      "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
      "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
      "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.",
      "license": "ISC",
      "dependencies": {
        "once": "^1.3.0",
        "wrappy": "1"
      }
    },
    "node_modules/inherits": {
      "version": "2.0.4",
      "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
      "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
      "license": "ISC"
    },
    "node_modules/minimatch": {
      "version": "3.1.5",
      "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz",
      "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==",
      "license": "ISC",
      "dependencies": {
        "brace-expansion": "^1.1.7"
      },
      "engines": {
        "node": "*"
      }
    },
    "node_modules/once": {
      "version": "1.4.0",
      "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
      "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
      "license": "ISC",
      "dependencies": {
        "wrappy": "1"
      }
    },
    "node_modules/path-is-absolute": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
      "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
      "license": "MIT",
      "engines": {
        "node": ">=0.10.0"
      }
    },
    "node_modules/wrappy": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
      "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
      "license": "ISC"
    }
  }
}
package.json
{
  "name": "sample-asar-uncache-all",
  "version": "1.0.0",
  "type": "module",
  "private": true,
  "license": "MIT-0",
  "dependencies": {
    "@electron/asar": "3.4.1"
  }
}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify @electron/asar.uncacheAll in pkg:npm/%40electron/asar@3.4.1",
  "kind": "HOW",
  "packages": [
    "pkg:npm/%40electron/asar@3.4.1"
  ],
  "symbols": [
    "@electron/asar.uncacheAll"
  ]
}
test/contract.mjs
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import os from 'node:os';
import asar, {
  uncacheAll,
  uncache,
  createPackage,
  statFile,
  extractFile,
  listPackage,
  clearAllCaches
} from '../index.mjs';

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'asar-contract-'));

try {
  // Contract 1: uncacheAll is exported as a function by @electron/asar
  {
    assert.strictEqual(typeof uncacheAll, 'function', 'uncacheAll must be a function');
    assert.strictEqual(typeof asar.uncacheAll, 'function', 'asar.uncacheAll must be a function');
    assert.strictEqual(uncacheAll, asar.uncacheAll, 'named export must match default property');
    assert.strictEqual(typeof clearAllCaches, 'function', 'clearAllCaches wrapper must be a function');
  }

  // Contract 2: uncacheAll executes safely without throwing when cache is empty
  {
    assert.doesNotThrow(() => {
      uncacheAll();
    }, 'calling uncacheAll with empty cache must not throw');
  }

  // Prepare two independent test packages
  const src1 = path.join(tempDir, 'src1');
  const src2 = path.join(tempDir, 'src2');
  fs.mkdirSync(src1, { recursive: true });
  fs.mkdirSync(src2, { recursive: true });

  fs.writeFileSync(path.join(src1, 'file1.txt'), 'content of archive 1');
  fs.writeFileSync(path.join(src2, 'file2.txt'), 'content of archive 2');

  const archive1 = path.join(tempDir, 'pkg1.asar');
  const archive2 = path.join(tempDir, 'pkg2.asar');

  await createPackage(src1, archive1);
  await createPackage(src2, archive2);

  // Contract 3: accessing archive metadata or contents caches filesystem records for multiple archives
  {
    assert.strictEqual(uncache(archive1), false, 'archive1 must not be cached initially');
    assert.strictEqual(uncache(archive2), false, 'archive2 must not be cached initially');

    const stat1 = statFile(archive1, 'file1.txt');
    assert.strictEqual(stat1.size, 20);

    const buf2 = extractFile(archive2, 'file2.txt');
    assert.strictEqual(buf2.toString(), 'content of archive 2');

    // Both archives should now be cached; uncache returns true when entry is removed
    assert.strictEqual(uncache(archive1), true, 'archive1 must have been cached');
    assert.strictEqual(uncache(archive2), true, 'archive2 must have been cached');
  }

  // Contract 4: uncacheAll clears all cached filesystem entries across all archives in a single call
  {
    // Re-populate cache for both archives
    statFile(archive1, 'file1.txt');
    statFile(archive2, 'file2.txt');

    // Clear all cached filesystem instances
    uncacheAll();

    // Verify neither archive is cached anymore
    assert.strictEqual(uncache(archive1), false, 'archive1 must not be cached after uncacheAll');
    assert.strictEqual(uncache(archive2), false, 'archive2 must not be cached after uncacheAll');
  }

  // Contract 5: uncacheAll invalidates stale filesystem headers when an archive file is modified on disk
  {
    // Read and cache initial archive1 state
    const initialList = listPackage(archive1);
    assert.deepEqual(initialList, ['/file1.txt']);
    const initialContent = extractFile(archive1, 'file1.txt').toString();
    assert.strictEqual(initialContent, 'content of archive 1');

    // Add a second file and rebuild archive1
    fs.writeFileSync(path.join(src1, 'extra.txt'), 'extra newly added file');
    await createPackage(src1, archive1);

    // Stale cached header does not reflect newly added file
    const staleList = listPackage(archive1);
    assert.deepEqual(staleList, ['/file1.txt'], 'cached header still returns old file list');

    // Purge cache with clearAllCaches wrapper
    clearAllCaches();

    // Fresh read from disk reflects updated archive header
    const freshList = listPackage(archive1);
    assert.deepEqual(freshList.sort(), ['/extra.txt', '/file1.txt'], 'fresh header reflects new files');
    const extraContent = extractFile(archive1, 'extra.txt').toString();
    assert.strictEqual(extraContent, 'extra newly added file');
  }

  // Contract 6: uncacheAll allows subsequent archive reads to succeed and re-populate the cache
  {
    uncacheAll();
    assert.strictEqual(uncache(archive1), false);

    const reStat = statFile(archive1, 'file1.txt');
    assert.strictEqual(reStat.size, 20);

    // Cache should be populated again
    assert.strictEqual(uncache(archive1), true, 'subsequent read re-populated cache');
  }

  console.log('All contract assertions passed successfully.');
} finally {
  fs.rmSync(tempDir, { recursive: true, force: true });
}

Origin Seeder

anonymous