|
1 |
| -# isomorphic-pgp |
| 1 | +# @isomorphic-git/lightning-fs |
2 | 2 |
|
3 |
| -A lightweight library for creating and verifying OpenPGP signatures |
| 3 | +A lean and fast 'fs' for the browser |
4 | 4 |
|
5 | 5 | ## Motivation
|
6 | 6 |
|
7 |
| -PGP is the cryptographic standard used to sign git commits, and I wanted to provide `isomorphic-git` users a way |
8 |
| -to tap into that power without sacrificing bundle size or worrying about LGPL restrictions. |
9 |
| -So I wrote an entirely new JavaScript library with that narrow use case in mind. |
| 7 | +I wanted to see if I could make something faster than [BrowserFS](https://github.com/jvilk/BrowserFS) or [filer](https://github.com/filerjs/filer) that still implements enough of the `fs` API to run the [`isomorphic-git`](https://github.com/isomorphic-git/isomorphic-git) test suite in browsers. |
10 | 8 |
|
11 |
| -## IMPORTANT!!! |
| 9 | +## Comparison with other libraries |
12 | 10 |
|
13 |
| -Please read and understand the limitations of the [`sign-and-verify`](https://github.com/wmhilton/isomorphic-pgp/tree/master/src/sign-and-verify) module before using it. |
| 11 | +This library does not even come close to implementing the full [`fs`](https://nodejs.org/api/fs.html) API. |
| 12 | +Instead, it only implements [the subset used by isomorphic-git 'fs' plugin interface](https://isomorphic-git.org/docs/en/plugin_fs). |
14 | 13 |
|
15 |
| -## Comparison with other libraries |
| 14 | +Unlike BrowserFS, which has a dozen backends and is highly configurable, `lightning-fs` has a single configuration that should Just Work for most users. |
16 | 15 |
|
17 |
| -This library does not implement encryption or decryption - only signing and verifying signatures. |
| 16 | +## Philosophy |
18 | 17 |
|
19 |
| -| | Size | License | Sign | Verify | Encrypt | Decrypt | |
20 |
| -|---|------|---------|------|--------|---------|---------| |
21 |
| -| isomorphic-pgp | [~17 kb ](https://bundlephobia.com/result?p=@isomorphic-git/[email protected]) | MIT | 🗹 | 🗹 | ☐ | ☐ | |
22 |
| -| OpenPGP.js | [~170 kb ](https://bundlephobia.com/[email protected]) | LGPL | 🗹 | 🗹 | 🗹 | 🗹 | |
23 |
| -| kbpgp | [~160 kb ](https://bundlephobia.com/[email protected]) | BSD | 🗹 | 🗹 | 🗹 | 🗹 | |
| 18 | +### Basic requirements: |
24 | 19 |
|
25 |
| -## Usage |
| 20 | +1. needs to work in all modern browsers |
| 21 | +2. needs to work with large-ish files and directories |
| 22 | +3. needs to persist data |
| 23 | +4. needs to enable performant web apps |
| 24 | + |
| 25 | +Req #3 excludes pure in-memory solutions. Req #4 excludes `localStorage` because it blocks the DOM and cannot be run in a webworker. Req #1 excludes WebSQL and Chrome's FileSystem API. So that leaves us with IndexedDB as the only usable storage technology. |
| 26 | + |
| 27 | +### Optimization targets (in order of priority): |
26 | 28 |
|
27 |
| -See individual READMEs for each package: |
| 29 | +1. speed (time it takes to execute file system operations) |
| 30 | +2. bundle size (time it takes to download the library) |
| 31 | +3. memory usage (will it work on mobile) |
| 32 | + |
| 33 | +In order to get improve #1, I ended up making a hybrid in-memory / IndexedDB system: |
| 34 | +- `mkdir`, `rmdir`, `readdir`, and `stat` are pure in-memory operations that take 0ms |
| 35 | +- `writeFile`, `readFile`, and `unlink` are throttled by IndexedDB |
| 36 | + |
| 37 | +The in-memory portion of the filesystem is persisted to IndexedDB with a debounce of 500ms. |
| 38 | +The files themselves are not currently cached in memory, because I don't want to waste a lot of memory. |
| 39 | +Applications can always *add* an LRU cache on top of `lightning-fs` - if I add one internally and it isn't tuned well for your application, it might be much harder to work around. |
| 40 | + |
| 41 | +## Usage |
28 | 42 |
|
29 |
| -- [parser](https://github.com/wmhilton/isomorphic-pgp/tree/master/src/parser) |
30 |
| -- [util](https://github.com/wmhilton/isomorphic-pgp/tree/master/src/util) |
31 |
| -- [sign-and-verify](https://github.com/wmhilton/isomorphic-pgp/tree/master/src/sign-and-verify) |
32 |
| -- [generate](https://github.com/wmhilton/isomorphic-pgp/tree/master/src/generate) |
| 43 | +TODO |
33 | 44 |
|
34 | 45 | ## License
|
35 | 46 |
|
|
0 commit comments