• Stars
    star
    2,520
  • Rank 18,198 (Top 0.4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 10 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple extensive tar-like archive format with indexing

@electron/asar - Electron Archive

CircleCI build status npm version

Asar is a simple extensive archive format, it works like tar that concatenates all files together without compression, while having random access support.

Features

  • Support random access
  • Use JSON to store files' information
  • Very easy to write a parser

Command line utility

Install

This module requires Node 10 or later.

$ npm install --engine-strict @electron/asar

Usage

$ asar --help

  Usage: asar [options] [command]

  Commands:

    pack|p <dir> <output>
       create asar archive

    list|l <archive>
       list files of asar archive

    extract-file|ef <archive> <filename>
       extract one file from archive

    extract|e <archive> <dest>
       extract archive


  Options:

    -h, --help     output usage information
    -V, --version  output the version number

Excluding multiple resources from being packed

Given:

    app
(a) β”œβ”€β”€ x1
(b) β”œβ”€β”€ x2
(c) β”œβ”€β”€ y3
(d) β”‚Β Β  β”œβ”€β”€ x1
(e) β”‚Β Β  └── z1
(f) β”‚Β Β      └── x2
(g) └── z4
(h)     └── w1

Exclude: a, b

$ asar pack app app.asar --unpack-dir "{x1,x2}"

Exclude: a, b, d, f

$ asar pack app app.asar --unpack-dir "**/{x1,x2}"

Exclude: a, b, d, f, h

$ asar pack app app.asar --unpack-dir "{**/x1,**/x2,z4/w1}"

Using programatically

Example

const asar = require('@electron/asar');

const src = 'some/path/';
const dest = 'name.asar';

await asar.createPackage(src, dest);
console.log('done.');

Please note that there is currently no error handling provided!

Transform

You can pass in a transform option, that is a function, which either returns nothing, or a stream.Transform. The latter will be used on files that will be in the .asar file to transform them (e.g. compress).

const asar = require('@electron/asar');

const src = 'some/path/';
const dest = 'name.asar';

function transform (filename) {
  return new CustomTransformStream()
}

await asar.createPackageWithOptions(src, dest, { transform: transform });
console.log('done.');

Using with grunt

There is also an unofficial grunt plugin to generate asar archives at bwin/grunt-asar.

Format

Asar uses Pickle to safely serialize binary value to file.

The format of asar is very flat:

| UInt32: header_size | String: header | Bytes: file1 | ... | Bytes: file42 |

The header_size and header are serialized with Pickle class, and header_size's Pickle object is 8 bytes.

The header is a JSON string, and the header_size is the size of header's Pickle object.

Structure of header is something like this:

{
   "files": {
      "tmp": {
         "files": {}
      },
      "usr" : {
         "files": {
           "bin": {
             "files": {
               "ls": {
                 "offset": "0",
                 "size": 100,
                 "executable": true,
                 "integrity": {
                   "algorithm": "SHA256",
                   "hash": "...",
                   "blockSize": 1024,
                   "blocks": ["...", "..."]
                 }
               },
               "cd": {
                 "offset": "100",
                 "size": 100,
                 "executable": true,
                 "integrity": {
                   "algorithm": "SHA256",
                   "hash": "...",
                   "blockSize": 1024,
                   "blocks": ["...", "..."]
                 }
               }
             }
           }
         }
      },
      "etc": {
         "files": {
           "hosts": {
             "offset": "200",
             "size": 32,
             "integrity": {
                "algorithm": "SHA256",
                "hash": "...",
                "blockSize": 1024,
                "blocks": ["...", "..."]
              }
           }
         }
      }
   }
}

offset and size records the information to read the file from archive, the offset starts from 0 so you have to manually add the size of header_size and header to the offset to get the real offset of the file.

offset is a UINT64 number represented in string, because there is no way to precisely represent UINT64 in JavaScript Number. size is a JavaScript Number that is no larger than Number.MAX_SAFE_INTEGER, which has a value of 9007199254740991 and is about 8PB in size. We didn't store size in UINT64 because file size in Node.js is represented as Number and it is not safe to convert Number to UINT64.

integrity is an object consisting of a few keys:

  • A hashing algorithm, currently only SHA256 is supported.
  • A hex encoded hash value representing the hash of the entire file.
  • 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.
  • A integer value blockSize representing the size in bytes of each block in the blocks hashes above

More Repositories

1

electron

:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
C++
113,167
star
2

electron-quick-start

Clone to try a simple Electron app
JavaScript
11,060
star
3

electron-api-demos

Explore the Electron APIs
HTML
10,247
star
4

fiddle

:electron: πŸš€ The easiest way to get started with Electron
TypeScript
7,414
star
5

forge

:electron: A complete tool for building and publishing Electron applications
TypeScript
6,371
star
6

apps

A collection of apps built on Electron
JavaScript
1,674
star
7

rcedit

Command line tool to edit resources of exe
C++
1,642
star
8

electronjs.org-old

Electron website
Handlebars
1,603
star
9

windows-installer

Build Windows Installers for Electron apps
TypeScript
1,559
star
10

electron-quick-start-typescript

Clone to try a simple Electron app (in TypeScript)
TypeScript
1,181
star
11

rebuild

Package to rebuild native Node.js modules against the currently installed Electron version
TypeScript
1,008
star
12

update-electron-app

🌲 A drop-in module that adds autoUpdating capabilities to Electron apps
TypeScript
729
star
13

i18n

🌍 The home of Electron's translated documentation
TypeScript
625
star
14

simple-samples

Minimal Electron applications with ideas for taking them further
JavaScript
610
star
15

update.electronjs.org

πŸ“‘ A free service that makes it easy for open-source Electron apps to update themselves.
JavaScript
601
star
16

osx-sign

Codesign Electron macOS apps
TypeScript
559
star
17

libchromiumcontent

Shared library build of Chromium’s Content module
Python
485
star
18

remote

Bridge JavaScript objects from the main process to the renderer process in Electron.
TypeScript
369
star
19

get

Download Electron release artifacts
TypeScript
336
star
20

build-tools

The GN scripts to use for Electron dev-flows
JavaScript
254
star
21

releases

πŸ“¦ Complete and up-to-date info about every release of Electron
JavaScript
244
star
22

mini-breakpad-server

Minimum breakpad crash reports collecting server
CoffeeScript
243
star
23

node

Node fork to make it suitable for embedding in Electron
234
star
24

node-rcedit

Node module to edit resources of exe
JavaScript
186
star
25

node-abi

🐒 πŸš€ Get the Node.js and Electron ABI for a given target and runtime
JavaScript
159
star
26

packager

Customize and package your Electron app with OS-specific bundles (.app, .exe, etc.) via JS or CLI
TypeScript
154
star
27

governance

Public repository for governance issues and documents
Shell
138
star
28

sheriff

Controls and monitors organization permissions across GitHub, Slack and GSuite. Built with ❀️ by The Electron Team
TypeScript
138
star
29

chromedriver

Download ChromeDriver for Electron
JavaScript
129
star
30

notarize

Notarize your macOS Electron Apps
TypeScript
129
star
31

typescript-definitions

Convert the Electron API JSON file to electron.d.ts
TypeScript
125
star
32

universal

Create Universal macOS applications from two x64 and arm64 Electron applications
TypeScript
112
star
33

website

:electron: The Electron website
TypeScript
108
star
34

mksnapshot

Electron mksnapshot binaries
JavaScript
102
star
35

trop

automate the backporting process
TypeScript
72
star
36

node-minidump

Node module to process minidump files
JavaScript
67
star
37

pdf-viewer

Fork of Chrome pdf extension to work as webui page in Electron
JavaScript
51
star
38

clerk

Verify PRs have release notes
TypeScript
48
star
39

hubdown

Convert markdown to GitHub-style HTML using a common set of remark plugins
JavaScript
39
star
40

native-mate

Fork of Chromium's gin library that makes it easier to marshal types between C++ and JavaScript.
C++
38
star
41

fuses

TypeScript
35
star
42

download-stats

⬇️ Download stats for Electron. Updated daily.
JavaScript
35
star
43

onboarding-guide

or, "So You Want to Be an Electron Hacker"
34
star
44

crashpad

Electron fork of crashpad
C++
32
star
45

symbolicate-mac

Symbolicate macOS Electron crash reports
JavaScript
30
star
46

chromium-breakpad

GitHub clone of the breakpad used by Chromium
C++
29
star
47

node-chromium-pickle-js

Binary value packing and unpacking library compatible with Chromium's Pickle class
JavaScript
22
star
48

electron-docs-linter

Parse and validate Electron's API documentation
JavaScript
21
star
49

windows-sign

Codesign Electron apps for Windows
TypeScript
20
star
50

docs-parser

Parse Electron docs in a lossless way into a JSON file
TypeScript
20
star
51

nightlies

Nightly release store
19
star
52

be

Scripts to help building Electron
JavaScript
18
star
53

dependent-repos

Public GitHub repos that depend on Electron. spiritual successor to https://github.com/electron/repos-using-electron
JavaScript
18
star
54

season-of-docs-2020

πŸ“– Project repository for Electron's possible participation in Google's Season of Docs
18
star
55

debian-sysroot-image-creator

Scripts to create debian sysroot image for building electron
Python
18
star
56

asar-require

Enable "require" scripts in asar archives
CoffeeScript
18
star
57

cation

Electron's PR monitoring bot
TypeScript
17
star
58

packages

A collection of all npm packages that mention `electron` in their package.json
JavaScript
17
star
59

symbol-server

Electron symbol server
TypeScript
16
star
60

unreleased

Checks for and reports commits unreleased for a specific release branch.
JavaScript
13
star
61

archaeologist

Digging up your artifacts since 2018
TypeScript
13
star
62

algolia-indices

Algolia search index data for Electron APIs, Tutorials, Packages, and Repos
JavaScript
13
star
63

fiddle-core

Run fiddles from anywhere, on any Electron release
TypeScript
13
star
64

github-app-auth

Gets an auth token for a repo via a GitHub app installation
TypeScript
11
star
65

electron-frameworks

Frameworks used by Electron
11
star
66

search-with-your-keyboard

Add keyboard navigation to your existing client-side search interface.
JavaScript
10
star
67

build-images

Base docker image used to build Electron on CI
Shell
10
star
68

electron-api-historian

Find the birthday of every Electron API
JavaScript
9
star
69

gyp

Python
9
star
70

electron-api-docs

πŸ“ Electron's API documentation in a structured JSON format [ARCHIVED]
JavaScript
9
star
71

build-tools-installer

Installer for Electron's wrapper toolkit for working with Electron.js source code
JavaScript
9
star
72

electron-docs

Fetch Electron documentation as raw markdown strings
JavaScript
8
star
73

.github

organization-wide defaults for all electron/* repos
7
star
74

rfcs

7
star
75

bugbot

Making life easier for people who report or triage Electron issues.
TypeScript
6
star
76

node-is-valid-window

Validates if a pointer to window is valid.
C++
5
star
77

electron-translators

Everyone who has helped translate Electron's documentation into different languages.
JavaScript
5
star
78

eslint-config

ESLint config used by Electron and Electron maintained modules
JavaScript
5
star
79

circleci-oidc-secret-exchange

Provides dynamic access to secrets in exchange for a valid OIDC token
TypeScript
5
star
80

electron-userland-reports

Slices of data about packages, repos, and users in Electron userland. Collected from the GitHub API, npm registry, and libraries.io
JavaScript
5
star
81

lint-roller

JavaScript
4
star
82

roller

🎡rollin on upstream 🎡
TypeScript
4
star
83

github-app-auth-action

TypeScript
3
star
84

tweets

3
star
85

electron-website-updater

JavaScript
3
star
86

zoilist

Nag @electron/api-wg to do API reviews
TypeScript
3
star
87

libcc-check

A little tool for checking up on libchromiumcontent builds.
JavaScript
2
star
88

slack-chromium-helper

Slack bot to unfurl Chromium development URLs
TypeScript
2
star
89

release-status

Public facing release status information
JavaScript
2
star
90

electron-issues

An experiment to better understand the issues filed on the electron/electron repo
JavaScript
2
star
91

hippo

TypeScript
2
star
92

ventifact

TypeScript
2
star
93

node-orb

Shell
1
star
94

electron-notarize

Notarize your macOS Electron Apps
TypeScript
1
star
95

docs-reviewer

TypeScript
1
star