From 3b5c003def01ab16777cff9273ee20373960550e Mon Sep 17 00:00:00 2001 From: Yogesh Chaudhary Date: Wed, 2 Dec 2026 09:41:10 +0530 Subject: [PATCH 1/3] feat: export NetworkError from auth0-spa-js Re-exports NetworkError, which auth0-spa-js 2.31.0 throws when a token request fails at the network level, so apps can import it from @auth0/auth0-angular. Bumps @auth0/auth0-spa-js to ^2.31.0. Co-Authored-By: Claude --- EXAMPLES.md | 14 ++++++++++++++ package-lock.json | 6 +++--- package.json | 2 +- projects/auth0-angular/package.json | 2 +- projects/auth0-angular/src/public-api.spec.ts | 13 +++++++++++++ projects/auth0-angular/src/public-api.ts | 1 + 6 files changed, 33 insertions(+), 5 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index 24d975ec..d3856a3d 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -443,6 +443,20 @@ ngOnInit() { } ``` +If the request to Auth0's token endpoint fails (for example, the device is offline or a browser extension blocks it), the SDK emits a `NetworkError` after retrying. If the request times out, it emits a `TimeoutError` instead. Without refresh tokens, the SDK first loads an iframe, which can't detect network failures, so being offline usually gives a `TimeoutError`. + +These errors don't mean the user's session is invalid, so show an offline message or retry later instead of asking the user to log in again: + +```ts +ngOnInit() { + this.authService.error$.pipe( + filter((e) => e instanceof NetworkError || e instanceof TimeoutError) + ).subscribe(() => { + // temporary network issue: show an offline message or retry later + }); +} +``` + ## Organizations [Organizations](https://auth0.com/docs/organizations) is a set of features that provide better support for developers who build and maintain SaaS and Business-to-Business (B2B) applications. diff --git a/package-lock.json b/package-lock.json index 1f2ef30b..942641de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@angular/core": "^20.3.35", "@angular/platform-browser": "^20.3.35", "@angular/router": "^20.3.35", - "@auth0/auth0-spa-js": "^2.30.0", + "@auth0/auth0-spa-js": "^2.31.0", "rxjs": "^6.6.7", "tslib": "^2.9.1", "zone.js": "~0.15.1" @@ -1011,8 +1011,8 @@ } }, "node_modules/@auth0/auth0-spa-js": { - "version": "2.30.0", - "integrity": "sha512-jqsVox2+TiBZf0Zh5h9iITh7W6a/WCGAMLuqniz+PTg2afVggbOBDmieo1zwOp8zQoY3RPguN4l5mvLDmxu7EQ==", + "version": "2.31.0", + "integrity": "sha512-/9HaDEuJtOm15IB1EyXMyvYr1b2IMzg6TvnVKgB0B592h9or2SH9/6w4vJnR2NkKoKYLk7aL9fQrTVIfHhHSNQ==", "license": "MIT", "dependencies": { "@auth0/auth0-auth-js": "^1.17.0", diff --git a/package.json b/package.json index b7f5a37e..10283170 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "@angular/core": "^20.3.35", "@angular/platform-browser": "^20.3.35", "@angular/router": "^20.3.35", - "@auth0/auth0-spa-js": "^2.30.0", + "@auth0/auth0-spa-js": "^2.31.0", "rxjs": "^6.6.7", "tslib": "^2.9.1", "zone.js": "~0.15.1" diff --git a/projects/auth0-angular/package.json b/projects/auth0-angular/package.json index feb69ce2..b424e4d3 100644 --- a/projects/auth0-angular/package.json +++ b/projects/auth0-angular/package.json @@ -32,7 +32,7 @@ }, "dependencies": { "tslib": "^2.0.0", - "@auth0/auth0-spa-js": "^2.30.0" + "@auth0/auth0-spa-js": "^2.31.0" }, "schematics": "./schematics/collection.json" } diff --git a/projects/auth0-angular/src/public-api.spec.ts b/projects/auth0-angular/src/public-api.spec.ts index 5544d48f..4a1814ef 100644 --- a/projects/auth0-angular/src/public-api.spec.ts +++ b/projects/auth0-angular/src/public-api.spec.ts @@ -16,6 +16,7 @@ vi.mock('@auth0/auth0-spa-js', async (importOriginal) => { import { GenericError, isFederatedDomain, + NetworkError, PasskeyVerificationRequiredError, } from './public-api'; @@ -63,4 +64,16 @@ describe('public-api', () => { expect(error.verificationRequired).toEqual(['email']); }); }); + + describe('Network errors', () => { + it('re-exports NetworkError from spa-js, so instanceof checks match', async () => { + const spa = await import('@auth0/auth0-spa-js'); + const error = new spa.NetworkError('Failed to fetch'); + + expect(NetworkError).toBe(spa.NetworkError); + expect(error).toBeInstanceOf(NetworkError); + expect(error).toBeInstanceOf(GenericError); + expect(error.error).toBe('network_error'); + }); + }); }); diff --git a/projects/auth0-angular/src/public-api.ts b/projects/auth0-angular/src/public-api.ts index 1203e4d8..3fbc2c57 100644 --- a/projects/auth0-angular/src/public-api.ts +++ b/projects/auth0-angular/src/public-api.ts @@ -31,6 +31,7 @@ export { User, GenericError, TimeoutError, + NetworkError, MfaRequiredError, PopupTimeoutError, PopupOpenError, From db4b689118f233adf463be5c1a78857658e4ea8c Mon Sep 17 00:00:00 2001 From: Yogesh Chaudhary Date: Wed, 2 Dec 2026 10:23:30 +0530 Subject: [PATCH 2/3] docs: clarify when NetworkError reaches error$ and skip popup timeouts The example now says it covers token requests from getAccessTokenSilently and AuthHttpInterceptor, shows its imports, and leaves out PopupTimeoutError, which is a TimeoutError but not a network issue. Co-Authored-By: Claude --- EXAMPLES.md | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/EXAMPLES.md b/EXAMPLES.md index d3856a3d..55d08a9e 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -443,14 +443,25 @@ ngOnInit() { } ``` -If the request to Auth0's token endpoint fails (for example, the device is offline or a browser extension blocks it), the SDK emits a `NetworkError` after retrying. If the request times out, it emits a `TimeoutError` instead. Without refresh tokens, the SDK first loads an iframe, which can't detect network failures, so being offline usually gives a `TimeoutError`. +If a token request from `getAccessTokenSilently` or `AuthHttpInterceptor` fails (for example, the device is offline or a browser extension blocks it), the SDK emits a `NetworkError` after retrying. If the request times out, it emits a `TimeoutError` instead. Without refresh tokens, the SDK first loads an iframe, which can't detect network failures, so being offline usually gives a `TimeoutError`. -These errors don't mean the user's session is invalid, so show an offline message or retry later instead of asking the user to log in again: +These errors don't mean the user's session is invalid, so show an offline message or retry later instead of asking the user to log in again. `PopupTimeoutError` is also a `TimeoutError`, but it means the user didn't finish a popup login in time, so the example leaves it out: ```ts +import { filter } from 'rxjs/operators'; +import { + NetworkError, + PopupTimeoutError, + TimeoutError, +} from '@auth0/auth0-angular'; + ngOnInit() { this.authService.error$.pipe( - filter((e) => e instanceof NetworkError || e instanceof TimeoutError) + filter( + (e) => + (e instanceof NetworkError || e instanceof TimeoutError) && + !(e instanceof PopupTimeoutError) + ) ).subscribe(() => { // temporary network issue: show an offline message or retry later }); From b665d91feab25b1025564f7b36a4aa273fc444f1 Mon Sep 17 00:00:00 2001 From: Yogesh Chaudhary Date: Wed, 2 Dec 2026 18:08:55 +0530 Subject: [PATCH 3/3] docs: note that login callback network errors can't be retried Co-Authored-By: Claude --- EXAMPLES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/EXAMPLES.md b/EXAMPLES.md index 55d08a9e..8d92f2c5 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -468,6 +468,8 @@ ngOnInit() { } ``` +If the login callback fails this way, `error$` also emits a `NetworkError` or `TimeoutError`, and the SDK navigates to `errorPath` (or `/` if it isn't set). The login can't be retried, so call `loginWithRedirect` once the network is back. + ## Organizations [Organizations](https://auth0.com/docs/organizations) is a set of features that provide better support for developers who build and maintain SaaS and Business-to-Business (B2B) applications.