Skip to content
Browser JavaScript binding for ZboxFS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
scripts
src
test
zbox_wasm
.gitignore
.npmignore
LICENSE
README.md
package-lock.json
package.json
webpack.config.js

README.md

zbox-browser

This package is browser javascript binding for ZboxFS.

ZboxFS is a zero-details, privacy-focused in-app file system. Its goal is to help application store files securely, privately and reliably. Check more details about ZboxFS.

Get Started

Installation

  1. Download zbox-browser-0.3.0.tar.gz from latest release
  2. Extract it to your website's static or public folder
  3. Import it using <script> tag
<script src="zbox-browser-0.3.0/index.js"></script>

Note: because of same-origin policy restriction, use this package as a cross-origin script won't work.

Hello World Example

Visit https://zbox.io/try to create a test repo. Copy its URI and replace [your_repo_uri] in below.

<script src="zbox-browser-0.3.0/index.js"></script>

<script>
  (async () => {
    // create a Zbox instance
    const zbox = new Zbox();

    // initialise environment, called once before using Zbox
    await zbox.initEnv({ log: { level: 'debug' } });

    // open the repo
    var repo = await zbox.openRepo({
      uri: '[your_repo_uri]',
      pwd: 'secret password',
      opts: { create: true }
    });

    // create a file
    let file = await repo.createFile('/hello_world.txt');

    // write content to file
    await file.writeOnce('Hello, World!');

    // seek to the beginning of file
    await file.seek({ from: Zbox.SeekFrom.Start, offset: 0 });

    // read all content as string
    const str = await file.readAllString()
    console.log(str);

    // close file, repo and exit Zbox
    await file.close();
    await repo.close();
    await zbox.exit();
  })();
</script>

API Documentation

Check the API documentation at https://docs.zbox.io/api/.

How to Build

This is for advanced users who want to build this package by themselves.

You need Docker to build this package.

Build WebAssembly

npm run build-wasm

After this command completed, wasm file will generate in src/wasm folder.

Build Package

npm run build

After running this command, release lib files will be created in lib folder and ready to be released to GitHub.

How to Release

To release this package to GitHub, you need a Personal access tokens.

export ZBOX_BROWSER_GITHUB_TOKEN=[your Personal access token]
npm run release

After running this command, release tarball will be created in dist folder and uploaded to GitHub. A draft release will be created as well if it is not there yet.

Latest code will also be committed, tagged and pushed to GitHub.

License

This package is licensed under the Apache 2.0 License - see the LICENSE file for details.

You can’t perform that action at this time.