Skip to content

Service Worker used as part of the OpenZiti browZer stack

License

Notifications You must be signed in to change notification settings

openziti/ziti-browzer-sw

Repository files navigation

@openziti/ziti-browzer-sw

This component contains the ServiceWorker used as part of the OpenZiti Zero Trust browZer stack


Are you interested in knowing how to easily embed programmable, high performance, zero trust networking into your app, on any internet connection, without VPNs?
Learn more about our OpenZiti project by clicking the image below:



Build CodeQL Issues License LOC PRs Welcome Contributor Covenant


Overview

coming soon...

Installation

The ziti-browzer-sw is intended to be consumed by the ziti-http-agent, not as a general purpose module in your build. It is available through npm, and installed via the following command:

npm i @openziti/ziti-browzer-sw

The the ziti-http-agent serves the contents of ziti-browzer-sw in response to HTTP requests originating from the ziti-browzer-runtime. It does so by using the code shown below:

// Locate the path to the ServiceWorker distro within the build of our running instance
let pathToZitiBrowzerSwModule = require.resolve('@openziti/ziti-browzer-sw');

pathToZitiBrowzerSwModule = pathToZitiBrowzerSwModule.substring(0, pathToZitiBrowzerSwModule.lastIndexOf('/'));

// Read the component off the disk
fs.readFile( path.join( pathToZitiBrowzerSwModule, outgoing.path.split("/").pop() ), (err, data) => {

if (err) {  // If we can't read the file from disk

    res.writeHead(500, { 'x-ziti-http-agent-err': err.message });
    res.end('');
    return;

} else {    // Emit the Service Worker onto the wire

    res.writeHead(200, { 
        'Content-Type': 'application/javascript',
        'Service-Worker-Allowed': '/',
        'x-ziti-http-agent-info': 'self-configured ziti service worker' 
    });

    res.write(data);  // the actual service worker code

    res.end('\n');
    return;
}

Contributing

AllContibs

Your Contributions are welcome! Please see our Contributing Guide for more details. Thanks to all our contributors!

Contibs

License

Apache 2.0

About

Service Worker used as part of the OpenZiti browZer stack

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •