mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-06 21:50:05 +00:00
[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:
@@ -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')
|
||||
}
|
||||
@@ -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()
|
||||
Reference in New Issue
Block a user