{"name":"@electron/asar","version":"4.1.1","license":"MIT","_id":"@electron/asar@4.1.1","maintainers":[{"name":"electron-cfa","email":"info+cfa-npm@electronjs.org"}],"homepage":"https://github.com/electron/asar","bugs":{"url":"https://github.com/electron/asar/issues"},"bin":{"asar":"bin/asar.mjs"},"dist":{"shasum":"9a00c1bc0cce0b793f6f142c72daad9ab23bb760","tarball":"http://registry-npm.ywwl.com/@electron/asar/download/@electron/asar-4.1.1.tgz","fileCount":28,"integrity":"sha512-grbomy1TPEauyu+N4UdRQqSjOhsm0ZoTbprLpvJWQGYeEIMVBwSPV3Rv3E3EfqU5iFSufd/k+2KZvTDbgfesnw==","signatures":[{"sig":"MEYCIQD9M0qZz+2YeRjaZqqkSL9FCXw6YJS7I5qgBXud4ILaYAIhAPezsy3i0au1B8wh77u+SQQfP9nr/tJ2ZSMUUUbrjCS8","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@electron%2fasar@4.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":118241,"size":27964,"noattachment":false,"key":"/@electron/asar/-/@electron/asar-4.1.1.tgz"},"type":"module","types":"./lib/asar.d.ts","engines":{"node":">=22.12.0"},"exports":"./lib/asar.js","gitHead":"f1f0a8f9a516860109234cbc3e6c1a4d0f690aa0","scripts":{"lint":"yarn prettier:check && yarn test:typecheck","test":"yarn lint && yarn vitest run && xvfb-maybe electron node_modules/vitest/vitest.mjs run","build":"tsc","prepack":"yarn build","prepare":"husky","test:ui":"vitest --ui","prettier":"prettier \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs}\"","build:docs":"typedoc src/asar.ts","test:watch":"vitest","prettier:check":"yarn prettier --check","prettier:write":"yarn prettier --write","test:typecheck":"cd test && tsc"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:fe3eb71f-9246-4fc3-9766-33cb53f71c7a"}},"repository":{"url":"git+https://github.com/electron/asar.git","type":"git"},"_npmVersion":"11.6.2","description":"Creating Electron app packages","directories":{},"lint-staged":{"*.{json,md}":"prettier --write --experimental-cli","*.{js,ts, cjs, mjs, cts, mts}":["prettier --write --experimental-cli"]},"_nodeVersion":"24.10.0","dependencies":{"glob":"^13.0.2","plist":"^3.1.0","commander":"^13.1.0","minimatch":"^10.0.1"},"publishConfig":{"provenance":true},"_hasShrinkwrap":false,"packageManager":"yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f","devDependencies":{"husky":"^9.1.7","semver":"^7.7.4","vitest":"^3.2.4","typedoc":"~0.25.13","electron":"^35.7.5","prettier":"^3.8.1","typescript":"^5.5.4","xvfb-maybe":"^0.2.1","@types/node":"^22.12.0","lint-staged":"^16.2.7","@types/plist":"^3.0.5","@electron/get":"^4.0.2","@types/semver":"^7.7.1","@electron/fuses":"^2.1.0","@tsconfig/node22":"^22.0.1"},"dependenciesMeta":{"electron":{"built":true}},"_npmOperationalInternal":{"tmp":"tmp/asar_4.1.1_1774373730656_0.22842656712505383","host":"s3://npm-registry-packages-npm-production"},"readme":"# @electron/asar - Electron Archive\n\n[![Test](https://github.com/electron/asar/actions/workflows/test.yml/badge.svg)](https://github.com/electron/asar/actions/workflows/test.yml)\n[![npm version](http://img.shields.io/npm/v/@electron/asar.svg)](https://npmjs.org/package/@electron/asar)\n[![API docs](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fregistry.npmjs.org%2F%40electron%2Fasar%2Flatest&query=%24.version&logo=typescript&logoColor=white&label=API%20Docs)](https://packages.electronjs.org/asar)\n\nASAR is a simple extensive archive format. It concatenates all files together without compression\n(like [`tar`](https://www.gnu.org/software/tar/)) while having random access support.\n\n## Features\n\n* Support random access\n* Use JSON to store file information\n* Very easy to write a parser\n* Store the contents of duplicated files only once\n\n## CLI\n\n### Install\n\nThis module requires Node 22.12.0 or later.\n\n```bash\nnpm install --engine-strict @electron/asar\n```\n\n### Usage\n\n```bash\n$ asar --help\n\n  Usage: asar [options] [command]\n\n  Commands:\n\n    pack|p <dir> <output>\n       create asar archive\n\n    list|l <archive>\n       list files of asar archive\n\n    extract-file|ef <archive> <filename>\n       extract one file from archive\n\n    extract|e <archive> <dest>\n       extract archive\n\n\n  Options:\n\n    -h, --help     output usage information\n    -V, --version  output the version number\n\n```\n\n#### Excluding multiple resources from being packed\n\nGiven:\n\n```text\n    app\n(a) ├── x1\n(b) ├── x2\n(c) ├── y3\n(d) │   ├── x1\n(e) │   └── z1\n(f) │       └── x2\n(g) └── z4\n(h)     └── w1\n```\n\nExclude: a, b\n\n```bash\nasar pack app app.asar --unpack-dir \"{x1,x2}\"\n```\n\nExclude: a, b, d, f\n\n```bash\nasar pack app app.asar --unpack-dir \"**/{x1,x2}\"\n```\n\nExclude: a, b, d, f, h\n\n```bash\nasar pack app app.asar --unpack-dir \"{**/x1,**/x2,z4/w1}\"\n```\n\n## Programmatic usage\n\nFor full API usage, see the [API documentation](https://packages.electronjs.org/asar).\n\n### Example\n\n```javascript\nimport { createPackage } from '@electron/asar';\n\nconst src = 'some/path/';\nconst dest = 'name.asar';\n\nawait createPackage(src, dest);\nconsole.log('done.');\n```\n\nPlease note that there is currently **no** error handling provided!\n\n### Deduplication\n\nFiles with identical contents are stored once and shared: the first copy is\nwritten into the archive and every other copy's header entry points at that same\n`offset`. Nothing changes for readers — each file still has its own entry, size,\nintegrity hash, and executable bit — but archives with duplicated contents (a\ncommon shape for bundled `node_modules`) get smaller and pack faster, since the\nredundant bytes are never written.\n\nUnpacked files (`unpack` / `unpackDir`) are always written out in full, because\nthey live on disk outside the archive.\n\n### Transform\n\nYou can pass in a `transform` option, that is a function, which either returns\nnothing, or a `stream.Transform`. The latter will be used on files that will be\nin the `.asar` file to transform them (e.g. compress).\n\n```javascript\nimport { createPackageWithOptions } from '@electron/asar';\n\nconst src = 'some/path/';\nconst dest = 'name.asar';\n\nfunction transform (filename) {\n  return new CustomTransformStream()\n}\n\nawait createPackageWithOptions(src, dest, { transform: transform });\nconsole.log('done.');\n```\n\n## Format\n\nAsar uses [Pickle][pickle] to safely serialize binary value to file.\n\nThe format of asar is very flat:\n\n```markdown\n| UInt32: header_size | String: header | Bytes: file1 | ... | Bytes: file42 |\n```\n\nThe `header_size` and `header` are serialized with [Pickle][pickle] class, and\n`header_size`'s [Pickle][pickle] object is 8 bytes.\n\nThe `header` is a JSON string, and the `header_size` is the size of `header`'s\n`Pickle` object.\n\nStructure of `header` is something like this:\n\n```json\n{\n   \"files\": {\n      \"tmp\": {\n         \"files\": {}\n      },\n      \"usr\" : {\n         \"files\": {\n           \"bin\": {\n             \"files\": {\n               \"ls\": {\n                 \"offset\": \"0\",\n                 \"size\": 100,\n                 \"executable\": true,\n                 \"integrity\": {\n                   \"algorithm\": \"SHA256\",\n                   \"hash\": \"...\",\n                   \"blockSize\": 1024,\n                   \"blocks\": [\"...\", \"...\"]\n                 }\n               },\n               \"cd\": {\n                 \"offset\": \"100\",\n                 \"size\": 100,\n                 \"executable\": true,\n                 \"integrity\": {\n                   \"algorithm\": \"SHA256\",\n                   \"hash\": \"...\",\n                   \"blockSize\": 1024,\n                   \"blocks\": [\"...\", \"...\"]\n                 }\n               }\n             }\n           }\n         }\n      },\n      \"etc\": {\n         \"files\": {\n           \"hosts\": {\n             \"offset\": \"200\",\n             \"size\": 32,\n             \"integrity\": {\n                \"algorithm\": \"SHA256\",\n                \"hash\": \"...\",\n                \"blockSize\": 1024,\n                \"blocks\": [\"...\", \"...\"]\n              }\n           }\n         }\n      }\n   }\n}\n```\n\n`offset` and `size` records the information to read the file from archive, the\n`offset` starts from 0 so you have to manually add the size of `header_size` and\n`header` to the `offset` to get the real offset of the file.\n\nFiles with identical contents share a single copy in the archive, so more than\none entry can point at the same `offset`.\n\n`offset` is a UINT64 number represented in string, because there is no way to\nprecisely represent UINT64 in JavaScript `Number`. `size` is a JavaScript\n`Number` that is no larger than `Number.MAX_SAFE_INTEGER`, which has a value of\n`9007199254740991` and is about 8PB in size. We didn't store `size` in UINT64\nbecause file size in Node.js is represented as `Number` and it is not safe to\nconvert `Number` to UINT64.\n\n`integrity` is an object consisting of a few keys:\n\n* A hashing `algorithm`, currently only `SHA256` is supported.\n* A hex encoded `hash` value representing the hash of the entire file.\n* An array of hex encoded hashes for the `blocks` of the file (i.e. for a blockSize of 4KB, this array contains the hash of every block if you split the file into N 4KB blocks).\n* A integer value `blockSize` representing the size in bytes of each block in the `blocks` hashes above.\n\n[pickle]: https://chromium.googlesource.com/chromium/src/+/main/base/pickle.h\n","publish_time":1774373730861,"_cnpm_publish_time":1774373730861,"dist-tags":{"latest":"4.3.2"}}