From 3c97ea271f5583e434368272b4827cab16c527a0 Mon Sep 17 00:00:00 2001 From: Blake Niemyjski Date: Sun, 29 Nov 2026 22:21:54 -0600 Subject: [PATCH 1/2] Reproduce OAuth popup security error logging --- .../src/lib/features/auth/microsoft.test.ts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/auth/microsoft.test.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/auth/microsoft.test.ts index 6efb5c902c..1c98d72283 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/auth/microsoft.test.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/auth/microsoft.test.ts @@ -45,8 +45,55 @@ describe('microsoftLogin', () => { afterEach(() => { vi.useRealTimers(); vi.unstubAllGlobals(); + vi.restoreAllMocks(); }); + it('waits for the callback without logging expected cross-origin access errors', async () => { + // Arrange + vi.stubGlobal('crypto', { randomUUID: () => 'synthetic-state' }); + const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {}); + const blockedRead = vi.spyOn(popup.location, 'href', 'get').mockImplementation(() => { + throw new DOMException('Synthetic cross-origin popup read', 'SecurityError'); + }); + + // Act + const login = microsoftLogin(); + await vi.advanceTimersByTimeAsync(1000); + const exchangesBeforeCallback = postJSON.mock.calls.length; + popup.location = new URL('http://localhost:7131/?code=synthetic-code&state=synthetic-state'); + await vi.advanceTimersByTimeAsync(500); + await login; + + // Assert + expect(blockedRead).toHaveBeenCalledTimes(2); + expect(consoleError).not.toHaveBeenCalled(); + expect(exchangesBeforeCallback).toBe(0); + expect(postJSON).toHaveBeenCalledOnce(); + expect(popup.close).toHaveBeenCalledOnce(); + }); + + it.each([new DOMException('Synthetic unrelated DOM error', 'InvalidStateError'), Object.assign(new Error('Synthetic error'), { name: 'SecurityError' })])( + 'logs an unexpected popup error (%s)', + async (error) => { + // Arrange + vi.stubGlobal('crypto', { randomUUID: () => 'synthetic-state' }); + const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {}); + vi.spyOn(popup.location, 'href', 'get').mockImplementationOnce(() => { + throw error; + }); + + // Act + const login = microsoftLogin(); + await vi.advanceTimersByTimeAsync(500); + popup.location = new URL('http://localhost:7131/?code=synthetic-code&state=synthetic-state'); + await vi.advanceTimersByTimeAsync(500); + await login; + + // Assert + expect(consoleError).toHaveBeenCalledExactlyOnceWith(error); + } + ); + it.each([true, false])('validates state and preserves invitation and redirect with randomUUID available: %s', async (hasRandomUUID) => { const getRandomValues = vi.fn((bytes: Uint8Array) => bytes.fill(10)); vi.stubGlobal('crypto', { getRandomValues, randomUUID: hasRandomUUID ? () => 'oauth-state' : undefined }); From 99076df40e2918ad1b71b543a33614e82075a56f Mon Sep 17 00:00:00 2001 From: Blake Niemyjski Date: Sun, 29 Nov 2026 22:24:08 -0600 Subject: [PATCH 2/2] fix(auth): stop logging expected OAuth popup errors --- .../ClientApp/src/lib/features/auth/index.svelte.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Exceptionless.Web/ClientApp/src/lib/features/auth/index.svelte.ts b/src/Exceptionless.Web/ClientApp/src/lib/features/auth/index.svelte.ts index 2ff0f366ad..ee01bc4e54 100644 --- a/src/Exceptionless.Web/ClientApp/src/lib/features/auth/index.svelte.ts +++ b/src/Exceptionless.Web/ClientApp/src/lib/features/auth/index.svelte.ts @@ -280,9 +280,9 @@ function waitForUrl(popup: Window, redirectUri: string): Promise