samizdapp / herakles

slaying the hydra of IP/NAT/DNS/TLS/AppStore
2 stars 1 forks source link

Service worker doesn't update if registration URL not accessible #112

Closed JoshuaCWebDeveloper closed 1 year ago

JoshuaCWebDeveloper commented 1 year ago

Problem

The browser attempts to update the service worker by fetching the script url. This url will be the original url of the script at the time of registration.

The fetch request will not be handled by the service worker:

Set request’s service-workers mode to "none".

https://w3c.github.io/ServiceWorker/#update-algorithm

This means that unless the browser can directly access the script via the original URL, no update will happen.

Solution

Create a bootloader service worker that gets updated rarely. It fetches the full worker script and loads and executes it.

Design Criteria

Some of the work in the planned status update concerning worker versions should be implemented as a part of this solution (assuming this gets done before the status update).

How to (Currently) Update the Service Worker

The steps for updating the service worker are more or less the same as the steps for installing the client.

These steps will likely still apply assuming we go with the above solution. They will also have to be done in order to migrate over to the above solution.

Chrome/Brave on Desktop

The worker should automatically update following normal worker update rules.

Chrome/Brave on Android

For Android versions less than 12

  1. Ensure your box is connected via ethernet (required).
  2. Restart your box by powering it off and on again.
  3. Connect your device to your box's WiFi network: i. In your device's list of available WiFi networks, select the network named "SamizdApp". ii. Enter the security key: samizdapp.
  4. If you unset the #unsafely-treat-insecure-origin-as-secure flag, you'll need to set it again.
  5. Navigate to http://samizdapp.local/smz/pwa. Refresh the page.
  6. Wait for the message saying "Install the PWA to continue."

For all other Android versions

The worker should automatically update following normal worker update rules.

Safari on iOS

Use the Shortcut again?