Commit c25cb38
authored
feat: add getConfiguration method to Auth0Client and updated documentation (#991)
## Summary
Adds a `getConfiguration()` method to the auth0-react SDK that exposes
the Auth0 domain and clientId configuration values. This method
delegates to the underlying `Auth0Client.getConfiguration()` from
`@auth0/auth0-spa-js`.
Developers need programmatic access to the SDK configuration they
provided during initialization. Without this, developers must manually
track domain and clientId values separately, leading to:
- Duplication of configuration values
- Potential inconsistencies
- Extra boilerplate for building custom Auth0-related URLs
## Changes
### New Feature
- **`getConfiguration()`** - Returns a readonly object containing `{
domain, clientId }` from the SDK initialization
## Usage
### With useAuth0 hook
```tsx
import { useAuth0 } from '@auth0/auth0-react';
const MyComponent = () => {
const { getConfiguration } = useAuth0();
const config = getConfiguration();
console.log(config.domain); // 'tenant.auth0.com'
console.log(config.clientId); // 'abc123'
};
```
### With withAuth0 HOC
```tsx
import { withAuth0, WithAuth0Props } from '@auth0/auth0-react';
class MyComponent extends Component<WithAuth0Props> {
render() {
const config = this.props.auth0.getConfiguration();
return <div>Domain: {config.domain}</div>;
}
}
export default withAuth0(MyComponent);
```
## Test Plan
- [x] Existing tests pass (102 tests)
- [x] 100% code coverage maintained
- [x] New relevant tests added:
- [x] Lint passes
- [x] Build succeeds
## Breaking Changes
None. This is a purely additive change.1 parent 1779641 commit c25cb38
File tree
8 files changed
+127
-9
lines changed- __mocks__/@auth0
- __tests__
- src
8 files changed
+127
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
737 | 738 | | |
738 | 739 | | |
739 | 740 | | |
740 | | - | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| 43 | + | |
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1257 | 1257 | | |
1258 | 1258 | | |
1259 | 1259 | | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
1260 | 1284 | | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
98 | | - | |
| 98 | + | |
99 | 99 | | |
100 | 100 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
240 | | - | |
| 240 | + | |
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
244 | 255 | | |
245 | 256 | | |
246 | 257 | | |
| |||
270 | 281 | | |
271 | 282 | | |
272 | 283 | | |
| 284 | + | |
273 | 285 | | |
274 | 286 | | |
275 | 287 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
344 | 349 | | |
345 | 350 | | |
346 | 351 | | |
| |||
357 | 362 | | |
358 | 363 | | |
359 | 364 | | |
| 365 | + | |
360 | 366 | | |
361 | 367 | | |
362 | 368 | | |
| |||
373 | 379 | | |
374 | 380 | | |
375 | 381 | | |
| 382 | + | |
376 | 383 | | |
377 | 384 | | |
378 | 385 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
0 commit comments