From 52d09283a4f4e8e9e08e6793d550fdc3480b1f07 Mon Sep 17 00:00:00 2001 From: Ton Sharp Date: Sun, 25 Oct 2026 19:15:24 +0100 Subject: [PATCH 1/2] Enhance App Shell Service Worker v2 and bump version to 6.1.2 --- CHANGELOG.md | 6 + config/version.php | 4 +- templates/layout/default.php | 10 ++ templates/layout/login.php | 10 ++ webroot/service-worker.js | 209 +++++++++++++++++++++++++++++++++++ 5 files changed, 237 insertions(+), 2 deletions(-) create mode 100644 webroot/service-worker.js diff --git a/CHANGELOG.md b/CHANGELOG.md index fa28eb155a..66636dbfa0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [6.1.2] - 2026-10-25 +### Added +- Enhance App Shell Service Worker v2 with complete precache suite (api-vendors, api-triage, api-app, stylesheets) +- Implement quick network timeout and instant App Shell fallback to eliminate ERR_INTERNET_DISCONNECTED +- Register Service Worker across all layouts including login and default templates + ## [6.1.0] - 2026-10-15 ### Added - Add perpetual offline mode settings and defaults for unlimited session duration, retention, and items diff --git a/config/version.php b/config/version.php index 7d6698b435..dc8834c4c2 100644 --- a/config/version.php +++ b/config/version.php @@ -1,8 +1,8 @@ [ - 'version' => '6.1.0', - 'name' => 'Passly 6.1.0', + 'version' => '6.1.2', + 'name' => 'Passly 6.1.2', 'edition' => 'ce', ], 'php' => [ diff --git a/templates/layout/default.php b/templates/layout/default.php index daec152c4c..7a055cbfc1 100644 --- a/templates/layout/default.php +++ b/templates/layout/default.php @@ -30,5 +30,15 @@ fetch('content'); ?> fetch('scriptBottom'); ?> + diff --git a/templates/layout/login.php b/templates/layout/login.php index 47b6fc9996..88620f79f2 100644 --- a/templates/layout/login.php +++ b/templates/layout/login.php @@ -33,5 +33,15 @@ element('Footer/default'); ?> + diff --git a/webroot/service-worker.js b/webroot/service-worker.js new file mode 100644 index 0000000000..59bc3db4ff --- /dev/null +++ b/webroot/service-worker.js @@ -0,0 +1,209 @@ +/** + * Passly - Open source password manager for teams + * Copyright (c) 2026 Svaroh + * + * Licensed under GNU Affero General Public License version 3 of the or any later version. + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright (c) Svaroh + * @license https://opensource.org/licenses/AGPL-3.0 AGPL License + * @link https://passly.svaroh.net Passly + */ + +const CACHE_NAME = 'passly-app-shell-v2'; + +const PRECACHE_ASSETS = [ + '/', + '/auth/login', + '/app/passwords', + '/favicon.ico', + '/favicon.svg', + '/favicon_32.png', + '/favicon_57.png', + '/favicon_76.png', + '/favicon_96.png', + '/favicon_128.png', + '/favicon_192.png', + '/favicon_228.png', + '/js/app/stylesheet.js', + '/js/app/api-vendors.js', + '/js/app/api-triage.js', + '/js/app/api-app.js', + '/css/themes/default/api_main.min.css', + '/css/themes/default/api_authentication.min.css', + '/css/themes/default/ext_authentication.min.css', + '/css/themes/midgar/api_main.min.css', + '/css/themes/midgar/api_authentication.min.css' +]; + +self.addEventListener('install', (event) => { + self.skipWaiting(); + event.waitUntil( + caches.open(CACHE_NAME).then((cache) => { + return Promise.allSettled( + PRECACHE_ASSETS.map((url) => + cache.add(new Request(url, { credentials: 'same-origin' })).catch((err) => { + console.warn(`[ServiceWorker] Failed to precache asset ${url}:`, err); + }) + ) + ); + }) + ); +}); + +self.addEventListener('activate', (event) => { + event.waitUntil( + Promise.all([ + self.clients.claim(), + caches.keys().then((cacheNames) => + Promise.all( + cacheNames.map((name) => { + if (name.startsWith('passly-') && name !== CACHE_NAME) { + return caches.delete(name); + } + return null; + }) + ) + ) + ]) + ); +}); + +self.addEventListener('fetch', (event) => { + const request = event.request; + + // Only handle GET requests + if (request.method !== 'GET') { + return; + } + + const url = new URL(request.url); + + // Ignore cross-origin requests + if (url.origin !== self.location.origin) { + return; + } + + // API endpoints and dynamic json calls must not be served stale from cache + const isApiRequest = + url.pathname.endsWith('.json') || + url.pathname.startsWith('/auth/is-authenticated') || + url.pathname.startsWith('/auth/verify') || + url.pathname.startsWith('/healthcheck'); + + if (isApiRequest) { + event.respondWith( + fetch(request).catch(() => { + return new Response( + JSON.stringify({ + header: { + status: 'error', + title: 'Offline', + message: 'You are currently offline. Local replica and cached vault state are active.', + code: 503 + }, + body: { + isOffline: true + } + }), + { + status: 503, + headers: { 'Content-Type': 'application/json; charset=utf-8' } + } + ); + }) + ); + return; + } + + // Navigation requests: Network-First with quick timeout and fallback to cached App Shell + if ( + request.mode === 'navigate' || + (request.headers.get('accept') && request.headers.get('accept').includes('text/html')) + ) { + event.respondWith( + (async () => { + try { + const fetchPromise = fetch(request); + // 2.5s network timeout for sluggish/offline connections before falling back to cached shell + const timeoutPromise = new Promise((_, reject) => + setTimeout(() => reject(new Error('Network timeout')), 2500) + ); + + const networkResponse = await Promise.race([fetchPromise, timeoutPromise]); + if (networkResponse && networkResponse.status === 200) { + const cache = await caches.open(CACHE_NAME); + cache.put(request, networkResponse.clone()); + return networkResponse; + } + if (networkResponse && networkResponse.status >= 400) { + // In case server returns 404/500, check if we have a valid cached shell + const cache = await caches.open(CACHE_NAME); + const cached = (await cache.match(request)) || (await cache.match('/auth/login')) || (await cache.match('/')); + if (cached) { + return cached; + } + } + return networkResponse; + } catch (_err) { + // Network failed or offline: serve cached App Shell immediately + const cache = await caches.open(CACHE_NAME); + + // 1. Try exact match + const exactMatch = await cache.match(request); + if (exactMatch) { + return exactMatch; + } + + // 2. Route to relevant cached App Shell + if (url.pathname.startsWith('/auth/login') || url.pathname === '/') { + const loginPage = (await cache.match('/auth/login')) || (await cache.match('/')); + if (loginPage) { + return loginPage; + } + } + + const appShell = + (await cache.match('/app/passwords')) || + (await cache.match('/auth/login')) || + (await cache.match('/')); + + if (appShell) { + return appShell; + } + + return new Response( + 'Passly Offline

Passly Offline App Shell

Server is offline. Vault cache is available.

', + { + status: 200, + headers: { 'Content-Type': 'text/html; charset=utf-8' } + } + ); + } + })() + ); + return; + } + + // Static assets (CSS, JS, fonts, images): Cache-First with background revalidation + const isStaticAsset = url.pathname.match(/\.(css|js|png|svg|ico|woff|woff2|ttf|eot)$/i); + if (isStaticAsset) { + event.respondWith( + caches.open(CACHE_NAME).then(async (cache) => { + // Strip cache busters query string if needed for matching + const cachedResponse = (await cache.match(request)) || (await cache.match(url.pathname)); + const fetchPromise = fetch(request) + .then((networkResponse) => { + if (networkResponse && networkResponse.status === 200) { + cache.put(request, networkResponse.clone()); + } + return networkResponse; + }) + .catch(() => null); + + return cachedResponse || (await fetchPromise); + }) + ); + } +}); From 6d6561860474990ff2306b440607c0d1f6dac511 Mon Sep 17 00:00:00 2001 From: Ton Sharp Date: Mon, 26 Oct 2026 09:41:00 +0100 Subject: [PATCH 2/2] Fix ChangelogFileTest failure, synchronize release notes, and bump version to 6.1.3 --- .github/workflows/ci.yml | 3 +++ CHANGELOG.md | 5 +++++ RELEASE_NOTES.md | 20 +++++++++---------- config/version.php | 4 ++-- templates/layout/default.php | 11 +---------- templates/layout/login.php | 11 +---------- webroot/js/app/service-worker-register.js | 24 +++++++++++++++++++++++ webroot/service-worker.js | 3 ++- 8 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 webroot/js/app/service-worker-register.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5389475604..044ec64ee4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -237,6 +237,8 @@ jobs: done mysql -h "$DATASOURCES_TEST_HOST" -u root -p"$MYSQL_ROOT_PASSWORD" -e "ALTER USER '$DATASOURCES_TEST_USERNAME'@'%' IDENTIFIED BY '$DATASOURCES_TEST_PASSWORD';" mysql -h "$DATASOURCES_TEST_HOST" -u root -p"$MYSQL_ROOT_PASSWORD" -e "GRANT ALL ON *.* TO '$DATASOURCES_TEST_USERNAME'@'%';" + mysql -h "$DATASOURCES_TEST_HOST" -u root -p"$MYSQL_ROOT_PASSWORD" -e "GRANT PROCESS ON *.* TO '$DATASOURCES_TEST_USERNAME'@'%';" + mysql -h "$DATASOURCES_TEST_HOST" -u root -p"$MYSQL_ROOT_PASSWORD" -e "FLUSH PRIVILEGES;" mysql -h "$DATASOURCES_TEST_HOST" -u root -p"$MYSQL_ROOT_PASSWORD" -e "SET GLOBAL log_bin_trust_function_creators = 1;" env: MYSQL_ROOT_PASSWORD: testing-password2 @@ -547,6 +549,7 @@ jobs: mysql -h "$DATASOURCES_TEST_HOST" -u root -p"$MARIADB_ROOT_PASSWORD" -e "ALTER USER '$DATASOURCES_TEST_USERNAME'@'%' IDENTIFIED BY '$DATASOURCES_TEST_PASSWORD';" mysql -h "$DATASOURCES_TEST_HOST" -u root -p"$MARIADB_ROOT_PASSWORD" -e "GRANT ALL ON *.* TO '$DATASOURCES_TEST_USERNAME'@'%';" mysql -h "$DATASOURCES_TEST_HOST" -u root -p"$MARIADB_ROOT_PASSWORD" -e "GRANT PROCESS ON *.* TO '$DATASOURCES_TEST_USERNAME'@'%';" + mysql -h "$DATASOURCES_TEST_HOST" -u root -p"$MARIADB_ROOT_PASSWORD" -e "FLUSH PRIVILEGES;" mysql -h "$DATASOURCES_TEST_HOST" -u root -p"$MARIADB_ROOT_PASSWORD" -e "SET GLOBAL log_bin_trust_function_creators = 1;" env: MARIADB_ROOT_PASSWORD: testing-password2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 66636dbfa0..b65a554e45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [6.1.3] - 2026-10-26 +### Fixed +- Fix CSP violation by extracting Service Worker registration into standalone `/js/app/service-worker-register.js` +- Bump App Shell cache to `passly-app-shell-v3` with precache registration script + ## [6.1.2] - 2026-10-25 ### Added - Enhance App Shell Service Worker v2 with complete precache suite (api-vendors, api-triage, api-app, stylesheets) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4b442b7f7b..d1668f35fa 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,15 +1,15 @@ -Passly 6.1.0 introduces perpetual offline mode support, delta synchronization endpoints, recoverable resource trash API, and CakePHP 5.4 framework upgrades. +Passly 6.1.3 delivers standalone Service Worker registration conforming to strict Content Security Policies, App Shell precache enhancements, and offline resilience improvements. -This release delivers the backend capabilities for offline vault access with perpetual defaults (unlimited session duration, data retention, and item counts), high-efficiency sync endpoints (/sync/meta and /sync/changes) with change journaling, and recoverable trash for resources. - -## Highlights -Perpetual offline mode defaults are enabled, supporting unlimited session duration, unlimited data retention, and unlimited items. - -Delta synchronization endpoints (/sync/meta and /sync/changes) and change journal logging are introduced to accelerate client sync. - -Recoverable resource trash API allows moving resources to trash and restoring them. +## [6.1.3] - 2026-10-26 +### Fixed +- Fix CSP violation by extracting Service Worker registration into standalone `/js/app/service-worker-register.js` +- Bump App Shell cache to `passly-app-shell-v3` with precache registration script -Framework upgraded to CakePHP 5.4 with automatic Request to DTO mapping and refreshed upstream CE core logic. +## [6.1.2] - 2026-10-25 +### Added +- Enhance App Shell Service Worker v2 with complete precache suite (api-vendors, api-triage, api-app, stylesheets) +- Implement quick network timeout and instant App Shell fallback to eliminate ERR_INTERNET_DISCONNECTED +- Register Service Worker across all layouts including login and default templates ## [6.1.0] - 2026-10-15 ### Added diff --git a/config/version.php b/config/version.php index dc8834c4c2..c5420a7436 100644 --- a/config/version.php +++ b/config/version.php @@ -1,8 +1,8 @@ [ - 'version' => '6.1.2', - 'name' => 'Passly 6.1.2', + 'version' => '6.1.3', + 'name' => 'Passly 6.1.3', 'edition' => 'ce', ], 'php' => [ diff --git a/templates/layout/default.php b/templates/layout/default.php index 7a055cbfc1..a473e82ec4 100644 --- a/templates/layout/default.php +++ b/templates/layout/default.php @@ -30,15 +30,6 @@ fetch('content'); ?> fetch('scriptBottom'); ?> - + diff --git a/templates/layout/login.php b/templates/layout/login.php index 88620f79f2..6fcc7787ac 100644 --- a/templates/layout/login.php +++ b/templates/layout/login.php @@ -33,15 +33,6 @@ element('Footer/default'); ?> - + diff --git a/webroot/js/app/service-worker-register.js b/webroot/js/app/service-worker-register.js new file mode 100644 index 0000000000..0b036177c0 --- /dev/null +++ b/webroot/js/app/service-worker-register.js @@ -0,0 +1,24 @@ +/** + * Passly - Open source password manager for teams + * Copyright (c) 2026 Svaroh + * + * Licensed under GNU Affero General Public License version 3 of the or any later version. + * For full copyright and license information, please see the LICENSE.txt + * Redistributions of files must retain the above copyright notice. + * + * @copyright Copyright (c) Svaroh + * @license https://opensource.org/licenses/AGPL-3.0 AGPL License + * @link https://passly.svaroh.net Passly + */ + +if ('serviceWorker' in navigator) { + window.addEventListener('load', function() { + navigator.serviceWorker.register('/service-worker.js', { scope: '/' }) + .then(function(registration) { + console.debug('Passly App Shell Service Worker registered successfully with scope:', registration.scope); + }) + .catch(function(error) { + console.warn('Passly App Shell Service Worker registration failed:', error); + }); + }); +} diff --git a/webroot/service-worker.js b/webroot/service-worker.js index 59bc3db4ff..e010ff5b5b 100644 --- a/webroot/service-worker.js +++ b/webroot/service-worker.js @@ -11,7 +11,7 @@ * @link https://passly.svaroh.net Passly */ -const CACHE_NAME = 'passly-app-shell-v2'; +const CACHE_NAME = 'passly-app-shell-v3'; const PRECACHE_ASSETS = [ '/', @@ -26,6 +26,7 @@ const PRECACHE_ASSETS = [ '/favicon_128.png', '/favicon_192.png', '/favicon_228.png', + '/js/app/service-worker-register.js', '/js/app/stylesheet.js', '/js/app/api-vendors.js', '/js/app/api-triage.js',