UNPKG

asarmor

Version:

Protect asar archive files from extraction

28 lines (27 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createBloatPatch = void 0; const crypto_1 = require("crypto"); const CHUNK_SIZE = 1024 * 1024 * 1024; /** * Upon extraction with `asar extract`, this patch will write empty zero-filled (0 bytes) files of the target size in chunks of `1 GB` to disk. Use at your own risk AND responsibility! * * Defaults to `100 GB`. */ function createBloatPatch(gigabytes = 100) { const files = {}; for (let i = 0; i < gigabytes; i++) { // generate unique but random string let filename = (0, crypto_1.randomBytes)(30).toString('hex'); while (Object.keys(files).indexOf(filename) > -1) filename = (0, crypto_1.randomBytes)(30).toString('hex'); const offset = Number.MAX_SAFE_INTEGER - CHUNK_SIZE; files[filename] = { offset: offset.toString(), size: CHUNK_SIZE }; } return { header: { files, }, }; } exports.createBloatPatch = createBloatPatch;