Some checks failed
CI / go-lint (pull_request) Failing after 17s
CI / python-lint (pull_request) Failing after 12s
CI / nodejs-lint (pull_request) Failing after 7s
CI / test-go-consent (pull_request) Failing after 11s
CI / test-python-voice (pull_request) Failing after 11s
CI / test-bqas (pull_request) Failing after 11s
CI / Deploy (pull_request) Has been skipped
Implement a complete investor access system for the pitch deck: - Passwordless magic link auth (jose JWT + nodemailer SMTP) - Per-investor audit logging (slide views, assumption changes, chat) - Financial model snapshot persistence (auto-save/restore per investor) - PWA support (manifest, service worker, offline caching, icons) - Security safeguards (watermark overlay, rate limiting, anti-scraping headers, content protection, single-session enforcement) - Admin API for invite/revoke/audit-log management - Integrated into docker-compose.coolify.yml for production deployment Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
71 lines
1.9 KiB
JavaScript
71 lines
1.9 KiB
JavaScript
const CACHE_NAME = 'breakpilot-pitch-v1'
|
|
const STATIC_ASSETS = [
|
|
'/',
|
|
'/manifest.json',
|
|
]
|
|
|
|
// Install: cache the app shell
|
|
self.addEventListener('install', (event) => {
|
|
event.waitUntil(
|
|
caches.open(CACHE_NAME).then((cache) => cache.addAll(STATIC_ASSETS))
|
|
)
|
|
self.skipWaiting()
|
|
})
|
|
|
|
// Activate: clean old caches
|
|
self.addEventListener('activate', (event) => {
|
|
event.waitUntil(
|
|
caches.keys().then((keys) =>
|
|
Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k)))
|
|
)
|
|
)
|
|
self.clients.claim()
|
|
})
|
|
|
|
// Fetch: network-first for API, cache-first for static assets
|
|
self.addEventListener('fetch', (event) => {
|
|
const url = new URL(event.request.url)
|
|
|
|
// Skip non-GET requests
|
|
if (event.request.method !== 'GET') return
|
|
|
|
// Network-first for API routes and auth
|
|
if (url.pathname.startsWith('/api/') || url.pathname.startsWith('/auth')) {
|
|
event.respondWith(
|
|
fetch(event.request).catch(() => caches.match(event.request))
|
|
)
|
|
return
|
|
}
|
|
|
|
// Cache-first for static assets (JS, CSS, images, fonts)
|
|
if (
|
|
url.pathname.startsWith('/_next/static/') ||
|
|
url.pathname.startsWith('/icons/') ||
|
|
url.pathname.endsWith('.js') ||
|
|
url.pathname.endsWith('.css')
|
|
) {
|
|
event.respondWith(
|
|
caches.match(event.request).then((cached) => {
|
|
if (cached) return cached
|
|
return fetch(event.request).then((response) => {
|
|
const clone = response.clone()
|
|
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone))
|
|
return response
|
|
})
|
|
})
|
|
)
|
|
return
|
|
}
|
|
|
|
// Network-first for everything else (HTML pages)
|
|
event.respondWith(
|
|
fetch(event.request)
|
|
.then((response) => {
|
|
const clone = response.clone()
|
|
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone))
|
|
return response
|
|
})
|
|
.catch(() => caches.match(event.request))
|
|
)
|
|
})
|