Napolean Paced Mischeviously

    TypeScript icon, indicating that this package has built-in type declarations

    0.0.6 • Public • Published

    Web Bundles

    This is a Node.js module for serializing and parsing the application/webbundle format defined in the Web Bundles draft spec.

    Currently this library doesn't support origin-signed bundles, but bundles generated by this library can be signed with the sign-bundle Go tool.


    Using npm:

    npm install wbn


    Please be aware that the API is not yet stable and is subject to change any time.

    Creating a Bundle:

    const wbn = require('wbn');
    const fs = require('fs');
    const builder = new wbn.BundleBuilder();
        exampleURL,                          // URL
        200,                                 // response code
        {'Content-Type': 'text/html'},       // response headers
        '<html>Hello, Web Bundle!</html>');  // response body (string or Uint8Array)
    // Have as many builder.addExchange() for resource URLs as needed for the package.
    fs.writeFileSync('out.wbn', builder.createBundle());

    Reading a Bundle:

    const wbn = require('wbn');
    const fs = require('fs');
    const buf = fs.readFileSync('out.wbn');
    const bundle = new wbn.Bundle(buf);
    const exchanges = [];
    for (const url of bundle.urls) {
      const resp = bundle.getResponse(url);
        status: resp.status,
        headers: resp.headers,
        body: resp.body.toString('utf-8')
      version: bundle.version,  // format version
    }, null, 2));


    This package also includes wbn command which lets you build a web bundle from a local directory. For example, if you have all the necessary files for in static/ directory, run the following command:

    $ wbn --dir static \
          --baseURL \
          --output out.wbn

    Run wbn --help for full options.

    Note: currently this CLI only covers a subset of the functionality offered by gen-bundle Go tool.

    Backwards compatibility

    This module supports creating and parsing Web Bundles that follow different draft versions of the format specification. In particular:

    To create a new bundle with the b1 format, pass the version value to the constructor:

    const builder = (new wbn.BundleBuilder('b1'))
    fs.writeFileSync('out_b1.wbn', builder.createBundle());

    Likewise, the wbn command can optionally take a --formatVersion b1 parameter when creating a new Web Bundle.

    This module also takes care of selecting the right format version automatically when reading a bundle. Check the property bundle.version to know the decoded bundle's format version.

    Using Bundles

    Generated bundles can be opened with web browsers supporting web bundles.

    Chrome (79+) experimentally supports navigation to Web Bundles with some limitations. See this document for more details.

    Chrome (90+) experimentally supports subresource loading with Web Bundles. See this document for more details.

    Release Notes



    npm i wbn

    DownloadsWeekly Downloads






    Unpacked Size

    29.1 kB

    Total Files


    Last publish


    • google-wombot
    • ksakamoto