Skip to content

Commit 4cb7607

Browse files
fix: add fetch polyfill and update types for auth0-spa-js v2.10.0
- Added cross-fetch polyfill to test-setup.ts to support fetch API in tests - Updated handleRedirectCallback return type to include ConnectAccountRedirectResult - Updated test mocks to support new return types - Required for compatibility with @auth0/auth0-spa-js v2.10.0
1 parent 0595c48 commit 4cb7607

File tree

5 files changed

+107
-10
lines changed

5 files changed

+107
-10
lines changed

package-lock.json

Lines changed: 95 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"@angular/platform-browser": "^18.2.13",
3333
"@angular/platform-browser-dynamic": "^18.2.13",
3434
"@angular/router": "^18.2.13",
35-
"@auth0/auth0-spa-js": "^2.1.3",
35+
"@auth0/auth0-spa-js": "^2.10.0",
3636
"rxjs": "^6.6.7",
3737
"tslib": "^2.8.1",
3838
"zone.js": "~0.14.10"
@@ -57,6 +57,7 @@
5757
"browserstack-cypress-cli": "^1.32.8",
5858
"concurrently": "^6.2.0",
5959
"cors": "^2.8.5",
60+
"cross-fetch": "^4.1.0",
6061
"cypress": "^13.17.0",
6162
"eslint": "^8.57.0",
6263
"eslint-plugin-import": "latest",

projects/auth0-angular/src/lib/auth.service.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ describe('AuthService', () => {
5858
clientId: '',
5959
});
6060

61-
jest.spyOn(auth0Client, 'handleRedirectCallback').mockResolvedValue({});
61+
jest.spyOn(auth0Client, 'handleRedirectCallback').mockResolvedValue({
62+
appState: undefined,
63+
} as any);
6264
jest.spyOn(auth0Client, 'loginWithRedirect').mockResolvedValue();
6365
jest.spyOn(auth0Client, 'loginWithPopup').mockResolvedValue();
6466
jest.spyOn(auth0Client, 'checkSession').mockResolvedValue();

projects/auth0-angular/src/lib/auth.service.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
GetTokenWithPopupOptions,
99
RedirectLoginResult,
1010
GetTokenSilentlyVerboseResponse,
11+
ConnectAccountRedirectResult,
1112
} from '@auth0/auth0-spa-js';
1213

1314
import {
@@ -304,7 +305,9 @@ export class AuthService<TAppState extends AppState = AppState>
304305
*/
305306
handleRedirectCallback(
306307
url?: string
307-
): Observable<RedirectLoginResult<TAppState>> {
308+
): Observable<
309+
RedirectLoginResult<TAppState> | ConnectAccountRedirectResult<AppState>
310+
> {
308311
return defer(() =>
309312
this.auth0Client.handleRedirectCallback<TAppState>(url)
310313
).pipe(
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
import { setupZoneTestEnv } from 'jest-preset-angular/setup-env/zone';
22

33
setupZoneTestEnv();
4+
5+
// Provides fetch, Headers, Response, Request — works in Node + JSDOM
6+
import 'cross-fetch/polyfill';

0 commit comments

Comments
 (0)