mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-04 08:15:41 +00:00
Input inside an iframe never reaches the host window, so the idle timeout signed users out while they worked in a plugin page, dialog or panel. The sandbox runtime now reports trusted input in its frame (the guard's own events, focus left out) through a MessagePort it hands the host with sandbox-ready, before any plugin code runs, at most once per 15 s. The host bridge passes it to a small notifier the session timeout guard counts like its own window's input, so it reaches the other tabs too.
31 lines
870 B
TypeScript
31 lines
870 B
TypeScript
/**
|
|
* User input inside plugin frames, for the idle timeout. Input in an iframe
|
|
* never reaches the host window, so the session timeout guard can't see it;
|
|
* the plugin sandbox runtime reports trusted input from its frame instead
|
|
* (lib/plugin-sandbox/runtime.tsx), the host bridge passes it on here, and
|
|
* the guard counts it like input in its own window.
|
|
*/
|
|
|
|
type Listener = () => void;
|
|
|
|
const listeners = new Set<Listener>();
|
|
|
|
/** Someone used a plugin frame just now. */
|
|
export function reportFrameActivity(): void {
|
|
for (const listener of listeners) {
|
|
try {
|
|
listener();
|
|
} catch {
|
|
/* a listener's own error */
|
|
}
|
|
}
|
|
}
|
|
|
|
/** Calls `listener` on every report; returns the unsubscribe. */
|
|
export function onFrameActivity(listener: Listener): () => void {
|
|
listeners.add(listener);
|
|
return () => {
|
|
listeners.delete(listener);
|
|
};
|
|
}
|