Skip to content

Commit ff74518

Browse files
feat: Upgrade core dependencies and regenerate documentation (#856)
### Key Changes: * **Dependency Upgrades:** Core packages have been updated to their latest versions, including: * `@auth0/auth0-spa-js` to `^2.2.0` * `typescript` to `^5.8.3` * `typedoc` to `^0.28.7` * `react` and `react-dom` to `^19.1.0` * Testing libraries like `jest` and `@testing-library/*` * Linting tools like `@typescript-eslint/*` to `^8.x` * **Documentation Regeneration:** As a result of the `typedoc` upgrade, the entire `/docs` directory has been regenerated. This brings in a modern theme, an improved structure, and new features like a hierarchy view for better API exploration. * **Enhanced Type Safety:** The project's `tsconfig.json` has been configured with stricter type-checking rules, including `exactOptionalPropertyTypes` and `noUncheckedIndexedAccess`. The codebase has been updated to conform to these rules, leading to more precise and safer type definitions. * **Code Modernization:** The codebase has been refactored to use modern JavaScript syntax, such as nullish coalescing (`??`) and optional chaining (`?.`). * **Test Suite Improvements:** * Comprehensive unit tests have been added for an internal utility function. * Asynchronous tests have been updated to correctly use `await act()`, ensuring more stable and reliable test execution.
1 parent 4630a16 commit ff74518

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2926
-2312
lines changed

__tests__/auth-reducer.test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('reducer', () => {
1919
it('should initialise when not authenticated', async () => {
2020
const payload = {
2121
isAuthenticated: false,
22+
user: undefined,
2223
};
2324
expect(
2425
reducer(initialAuthState, { type: 'INITIALISED', ...payload })

__tests__/utils.test.tsx

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
1-
import { hasAuthParams, loginError, tokenError } from '../src/utils';
1+
import { hasAuthParams, loginError, tokenError, deprecateRedirectUri } from '../src/utils';
22
import { OAuthError } from '../src/errors';
33

4+
// Define interfaces for testing deprecateRedirectUri function
5+
interface TestOptionsWithRedirectUri {
6+
redirectUri?: string;
7+
authorizationParams?: {
8+
redirect_uri?: string;
9+
scope?: string;
10+
};
11+
}
12+
13+
interface TestOptionsWithAuthorizationParams {
14+
authorizationParams: {
15+
redirectUri?: string;
16+
redirect_uri?: string;
17+
scope?: string;
18+
};
19+
}
20+
21+
interface TestOptionsWithBothRedirectUri {
22+
redirectUri?: string;
23+
authorizationParams: {
24+
scope: string;
25+
redirect_uri?: string;
26+
};
27+
}
28+
429
describe('utils hasAuthParams', () => {
530
it('should not recognise only the code param', async () => {
631
['?code=1', '?foo=1&code=2', '?code=1&foo=2'].forEach((search) =>
@@ -62,3 +87,75 @@ describe('utils error', () => {
6287
}).toThrowError('Login failed');
6388
});
6489
});
90+
91+
describe('utils deprecateRedirectUri', () => {
92+
let consoleSpy: jest.SpyInstance;
93+
94+
beforeEach(() => {
95+
consoleSpy = jest.spyOn(console, 'warn').mockImplementation(() => {});
96+
});
97+
98+
afterEach(() => {
99+
consoleSpy.mockRestore();
100+
});
101+
102+
it('should handle options with redirectUri', () => {
103+
const options: TestOptionsWithRedirectUri = {
104+
redirectUri: 'https://example.com/callback',
105+
};
106+
107+
deprecateRedirectUri(options);
108+
109+
expect(consoleSpy).toHaveBeenCalledWith(
110+
'Using `redirectUri` has been deprecated, please use `authorizationParams.redirect_uri` instead as `redirectUri` will be no longer supported in a future version'
111+
);
112+
expect(options.authorizationParams?.redirect_uri).toBe('https://example.com/callback');
113+
expect(options.redirectUri).toBeUndefined();
114+
});
115+
116+
it('should handle options with authorizationParams.redirectUri', () => {
117+
const options: TestOptionsWithAuthorizationParams = {
118+
authorizationParams: {
119+
redirectUri: 'https://example.com/callback',
120+
},
121+
};
122+
123+
deprecateRedirectUri(options);
124+
125+
expect(consoleSpy).toHaveBeenCalledWith(
126+
'Using `authorizationParams.redirectUri` has been deprecated, please use `authorizationParams.redirect_uri` instead as `authorizationParams.redirectUri` will be removed in a future version'
127+
);
128+
expect(options.authorizationParams.redirect_uri).toBe('https://example.com/callback');
129+
expect(options.authorizationParams.redirectUri).toBeUndefined();
130+
});
131+
132+
it('should handle options with both redirectUri and existing authorizationParams', () => {
133+
const options: TestOptionsWithBothRedirectUri = {
134+
redirectUri: 'https://example.com/callback',
135+
authorizationParams: {
136+
scope: 'openid profile',
137+
},
138+
};
139+
140+
deprecateRedirectUri(options);
141+
142+
expect(options.authorizationParams.redirect_uri).toBe('https://example.com/callback');
143+
expect(options.authorizationParams.scope).toBe('openid profile');
144+
expect(options.redirectUri).toBeUndefined();
145+
});
146+
147+
it('should handle undefined options', () => {
148+
deprecateRedirectUri(undefined);
149+
expect(consoleSpy).not.toHaveBeenCalled();
150+
});
151+
152+
it('should handle options without redirectUri properties', () => {
153+
const options = {
154+
domain: 'example.auth0.com',
155+
clientId: 'client-id',
156+
};
157+
158+
deprecateRedirectUri(options);
159+
expect(consoleSpy).not.toHaveBeenCalled();
160+
});
161+
});

docs/assets/hierarchy.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/icons.js

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

docs/assets/icons.svg

Lines changed: 1 addition & 1 deletion
Loading

docs/assets/main.js

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

docs/assets/navigation.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)