Understand the Service Worker Message envelope
mainEvery message sent to the service worker must follow the ServiceWorkerMessage interface. Messages are communicated via a MessageChannel, and the service worker responds on port2 exactly once. Responses include a configurationName and may include an error field if the request fails.
Message Structure:
interface ServiceWorkerMessage {
type: ServiceWorkerMessageTypeValue; // The wire value (e.g., 'init', 'getState')
configurationName: string; // OIDC configuration identifier
data: object | null; // Payload (varies by type)
tabId?: string; // Optional tab ID (defaults to "default")
}interface ServiceWorkerMessage {
type: ServiceWorkerMessageTypeValue;
configurationName: string;
data: object | null;
tabId?: string;
}