[backport rh-test] remove auth service worker (rh-test) (#6296)

## Summary
- remove auth service worker bundle and registration code
- drop config ignores referencing removed assets

## Testing
- lint-staged (eslint, prettier)

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-6296-backport-rh-test-remove-auth-service-worker-rh-test-2986d73d36508118b8cdf1472577175f)
by [Unito](https://www.unito.io)
This commit is contained in:
Christian Byrne
2025-10-25 23:56:26 -07:00
committed by GitHub
parent 09bad9c1e8
commit aa5a8fcb95
6 changed files with 1 additions and 238 deletions

View File

@@ -1,9 +0,0 @@
import { isCloud } from '@/platform/distribution/types'
/**
* Auth service worker registration (cloud-only).
* Tree-shaken for desktop/localhost builds via compile-time constant.
*/
if (isCloud) {
void import('./register')
}

View File

@@ -1,57 +0,0 @@
import { watch } from 'vue'
import { useCurrentUser } from '@/composables/auth/useCurrentUser'
import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
/**
* Registers the authentication service worker for cloud distribution.
* Intercepts /api/view requests to add auth headers for browser-native requests.
*/
async function registerAuthServiceWorker(): Promise<void> {
if (!('serviceWorker' in navigator)) {
return
}
try {
await navigator.serviceWorker.register('/auth-sw.js')
setupAuthHeaderProvider()
setupCacheInvalidation()
} catch (error) {
console.error('[Auth SW] Registration failed:', error)
}
}
/**
* Listens for auth header requests from the service worker
*/
function setupAuthHeaderProvider(): void {
navigator.serviceWorker.addEventListener('message', async (event) => {
if (event.data.type === 'REQUEST_AUTH_HEADER') {
const firebaseAuthStore = useFirebaseAuthStore()
const authHeader = await firebaseAuthStore.getAuthHeader()
event.ports[0].postMessage({
type: 'AUTH_HEADER_RESPONSE',
authHeader
})
}
})
}
/**
* Invalidates cached auth header when user logs in/out
*/
function setupCacheInvalidation(): void {
const { isLoggedIn } = useCurrentUser()
watch(isLoggedIn, (newValue, oldValue) => {
if (newValue !== oldValue) {
navigator.serviceWorker.controller?.postMessage({
type: 'INVALIDATE_AUTH_HEADER'
})
}
})
}
void registerAuthServiceWorker()