refactor(sse): narrow canonical audience scopes

This commit is contained in:
2026-03-31 22:56:12 +02:00
parent a76b173f4b
commit ac29ce3567
5 changed files with 64 additions and 24 deletions
@@ -265,4 +265,24 @@ describe("event-bus debounce", () => {
unsubscribeManager();
unsubscribeResource();
});
it("rejects invalid subscription audiences", () => {
expect(() =>
eventBus.subscribe(
() => undefined,
{
audiences: ["chapter:capex" as never],
includeUnscoped: false,
},
)).toThrowError("Invalid SSE audience: chapter:capex");
});
it("rejects invalid emitted audiences", () => {
expect(() =>
eventBus.emit(
SSE_EVENT_TYPES.NOTIFICATION_CREATED,
{ notificationId: "n1" },
["user:" as never],
)).toThrowError("Invalid SSE audience: user:");
});
});