Skip to content

openziti/ziti-browzer-sw-workbox-strategies

Repository files navigation

@openziti/ziti-browzer-sw-workbox-strategies

This component contains a sub-component of 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-workbox-strategies 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-workbox-strategies

The the ziti-http-agent serves the contents of ziti-browzer-sw (and ziti-browzer-sw-workbox-strategies which is embedded within 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

Custom Workbox Strategies used as part of the OpenZiti browZer stack

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published