@auth0/auth0-react 2.11.0 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth0-context.d.ts +72 -7
- package/dist/auth0-context.d.ts.map +1 -1
- package/dist/auth0-provider.d.ts.map +1 -1
- package/dist/auth0-react.cjs.js +35 -26
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +25 -16
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +35 -26
- package/dist/auth0-react.js.map +1 -1
- package/dist/auth0-react.min.js +1 -1
- package/dist/auth0-react.min.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/use-auth0.d.ts +2 -1
- package/dist/use-auth0.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/auth0-context.tsx +77 -8
- package/src/auth0-provider.tsx +23 -5
- package/src/index.tsx +2 -1
- package/src/use-auth0.tsx +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ export { default as useAuth0 } from './use-auth0';
|
|
|
3
3
|
export { default as withAuth0, WithAuth0Props } from './with-auth0';
|
|
4
4
|
export { default as withAuthenticationRequired, WithAuthenticationRequiredOptions, } from './with-authentication-required';
|
|
5
5
|
export { default as Auth0Context, Auth0ContextInterface, initialContext, LogoutOptions, RedirectLoginOptions, } from './auth0-context';
|
|
6
|
-
export { AuthorizationParams, PopupLoginOptions, PopupConfigOptions, GetTokenWithPopupOptions, LogoutUrlOptions, CacheLocation, GetTokenSilentlyOptions, IdToken, User, ICache, InMemoryCache, LocalStorageCache, Cacheable, TimeoutError, MfaRequiredError, PopupCancelledError, PopupTimeoutError, AuthenticationError, MissingRefreshTokenError, GenericError, UseDpopNonceError, type FetcherConfig, RedirectConnectAccountOptions, ConnectAccountRedirectResult, ResponseType, ConnectError, CustomTokenExchangeOptions, TokenEndpointResponse } from '@auth0/auth0-spa-js';
|
|
6
|
+
export { AuthorizationParams, PopupLoginOptions, PopupConfigOptions, GetTokenWithPopupOptions, LogoutUrlOptions, CacheLocation, GetTokenSilentlyOptions, IdToken, User, ICache, InMemoryCache, LocalStorageCache, Cacheable, TimeoutError, MfaRequiredError, PopupCancelledError, PopupTimeoutError, AuthenticationError, MissingRefreshTokenError, GenericError, UseDpopNonceError, type FetcherConfig, RedirectConnectAccountOptions, ConnectAccountRedirectResult, ResponseType, ConnectError, CustomTokenExchangeOptions, TokenEndpointResponse, ClientConfiguration, } from '@auth0/auth0-spa-js';
|
|
7
7
|
export { OAuthError } from './errors';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,aAAa,EACxB,oBAAoB,EACpB,QAAQ,EACR,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,OAAO,IAAI,0BAA0B,EACrC,iCAAiC,GAClC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,OAAO,IAAI,YAAY,EACvB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACvB,OAAO,EACP,IAAI,EACJ,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,EACjB,KAAK,aAAa,EAClB,6BAA6B,EAC7B,4BAA4B,EAC5B,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,aAAa,EACxB,oBAAoB,EACpB,QAAQ,EACR,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EACL,OAAO,IAAI,0BAA0B,EACrC,iCAAiC,GAClC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,OAAO,IAAI,YAAY,EACvB,qBAAqB,EACrB,cAAc,EACd,aAAa,EACb,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACvB,OAAO,EACP,IAAI,EACJ,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,EACjB,KAAK,aAAa,EAClB,6BAA6B,EAC7B,4BAA4B,EAC5B,YAAY,EACZ,YAAY,EACZ,0BAA0B,EAC1B,qBAAqB,EACrB,mBAAmB,GACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/use-auth0.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ import { Auth0ContextInterface } from './auth0-context';
|
|
|
12
12
|
* getAccessTokenSilently,
|
|
13
13
|
* getAccessTokenWithPopup,
|
|
14
14
|
* getIdTokenClaims,
|
|
15
|
-
*
|
|
15
|
+
* loginWithCustomTokenExchange,
|
|
16
|
+
* exchangeToken, // deprecated - use loginWithCustomTokenExchange
|
|
16
17
|
* loginWithRedirect,
|
|
17
18
|
* loginWithPopup,
|
|
18
19
|
* logout,
|
package/dist/use-auth0.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-auth0.d.ts","sourceRoot":"","sources":["../src/use-auth0.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAqB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAEtE
|
|
1
|
+
{"version":3,"file":"use-auth0.d.ts","sourceRoot":"","sources":["../src/use-auth0.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAqB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,QAAA,MAAM,QAAQ,GAAI,KAAK,SAAS,IAAI,GAAG,IAAI,EACzC,8DAAsB,KACrB,qBAAqB,CAAC,KAAK,CACuB,CAAC;AAEtD,eAAe,QAAQ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Auth0",
|
|
3
3
|
"name": "@auth0/auth0-react",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.13.0",
|
|
5
5
|
"description": "Auth0 SDK for React Single Page Applications (SPA)",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"auth0",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"@rollup/plugin-replace": "^5.0.1",
|
|
56
56
|
"@rollup/plugin-terser": "^0.4.3",
|
|
57
57
|
"@testing-library/dom": "^10.4.0",
|
|
58
|
-
"@testing-library/jest-dom": "6.
|
|
59
|
-
"@testing-library/react": "16.3.
|
|
58
|
+
"@testing-library/jest-dom": "6.9.1",
|
|
59
|
+
"@testing-library/react": "16.3.2",
|
|
60
60
|
"@types/jest": "^29.5.14",
|
|
61
|
-
"@types/react": "19.
|
|
62
|
-
"@types/react-dom": "19.
|
|
61
|
+
"@types/react": "19.2.11",
|
|
62
|
+
"@types/react-dom": "19.2.3",
|
|
63
63
|
"@typescript-eslint/eslint-plugin": "^8.36.0",
|
|
64
64
|
"@typescript-eslint/parser": "^8.36.0",
|
|
65
65
|
"browserstack-cypress-cli": "^1.19.1",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"oidc-provider": "^8.8.1",
|
|
75
75
|
"prettier": "^2.8.1",
|
|
76
76
|
"pretty-quick": "^3.1.3",
|
|
77
|
-
"react": "19.
|
|
78
|
-
"react-dom": "19.
|
|
77
|
+
"react": "19.2.4",
|
|
78
|
+
"react-dom": "19.2.4",
|
|
79
79
|
"rollup": "^3.7.0",
|
|
80
80
|
"rollup-plugin-analyzer": "^4.0.0",
|
|
81
81
|
"rollup-plugin-delete": "^2.0.0",
|
|
@@ -95,6 +95,6 @@
|
|
|
95
95
|
"react-dom": "^16.11.0 || ^17 || ^18 || ~19.0.1 || ~19.1.2 || ^19.2.1"
|
|
96
96
|
},
|
|
97
97
|
"dependencies": {
|
|
98
|
-
"@auth0/auth0-spa-js": "^2.
|
|
98
|
+
"@auth0/auth0-spa-js": "^2.14.0"
|
|
99
99
|
}
|
|
100
100
|
}
|
package/src/auth0-context.tsx
CHANGED
|
@@ -93,6 +93,60 @@ export interface Auth0ContextInterface<TUser extends User = User>
|
|
|
93
93
|
getIdTokenClaims: () => Promise<IdToken | undefined>;
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
+
* ```js
|
|
97
|
+
* await loginWithCustomTokenExchange(options);
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* Exchanges an external subject token for Auth0 tokens and logs the user in.
|
|
101
|
+
* This method implements the Custom Token Exchange grant as specified in RFC 8693.
|
|
102
|
+
*
|
|
103
|
+
* The exchanged tokens are automatically cached, establishing an authenticated session.
|
|
104
|
+
* After calling this method, you can use `getUser()`, `getIdTokenClaims()`, and
|
|
105
|
+
* `getTokenSilently()` to access the user's information and tokens.
|
|
106
|
+
*
|
|
107
|
+
* @param options - The options required to perform the token exchange.
|
|
108
|
+
*
|
|
109
|
+
* @returns A promise that resolves to the token endpoint response,
|
|
110
|
+
* which contains the issued Auth0 tokens (access_token, id_token, etc.).
|
|
111
|
+
*
|
|
112
|
+
* The request includes the following parameters:
|
|
113
|
+
* - `grant_type`: "urn:ietf:params:oauth:grant-type:token-exchange"
|
|
114
|
+
* - `subject_token`: The external token to exchange
|
|
115
|
+
* - `subject_token_type`: The type identifier of the external token
|
|
116
|
+
* - `scope`: Merged scopes from the request and SDK defaults
|
|
117
|
+
* - `audience`: Target audience (defaults to SDK configuration)
|
|
118
|
+
* - `organization`: Optional organization ID/name for org-scoped authentication
|
|
119
|
+
*
|
|
120
|
+
* **Example Usage:**
|
|
121
|
+
*
|
|
122
|
+
* ```js
|
|
123
|
+
* const options = {
|
|
124
|
+
* subject_token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp...',
|
|
125
|
+
* subject_token_type: 'urn:acme:legacy-system-token',
|
|
126
|
+
* scope: 'openid profile email',
|
|
127
|
+
* audience: 'https://api.example.com',
|
|
128
|
+
* organization: 'org_12345'
|
|
129
|
+
* };
|
|
130
|
+
*
|
|
131
|
+
* try {
|
|
132
|
+
* const tokenResponse = await loginWithCustomTokenExchange(options);
|
|
133
|
+
* console.log('Access token:', tokenResponse.access_token);
|
|
134
|
+
*
|
|
135
|
+
* // User is now logged in - access user info
|
|
136
|
+
* const user = await getUser();
|
|
137
|
+
* console.log('Logged in user:', user);
|
|
138
|
+
* } catch (error) {
|
|
139
|
+
* console.error('Token exchange failed:', error);
|
|
140
|
+
* }
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
loginWithCustomTokenExchange: (
|
|
144
|
+
options: CustomTokenExchangeOptions
|
|
145
|
+
) => Promise<TokenEndpointResponse>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* @deprecated Use `loginWithCustomTokenExchange()` instead. This method will be removed in the next major version.
|
|
149
|
+
*
|
|
96
150
|
* ```js
|
|
97
151
|
* const tokenResponse = await exchangeToken({
|
|
98
152
|
* subject_token: 'external_token_value',
|
|
@@ -101,18 +155,20 @@ export interface Auth0ContextInterface<TUser extends User = User>
|
|
|
101
155
|
* });
|
|
102
156
|
* ```
|
|
103
157
|
*
|
|
104
|
-
* Exchanges an external subject token for Auth0 tokens
|
|
158
|
+
* Exchanges an external subject token for Auth0 tokens and logs the user in.
|
|
105
159
|
*
|
|
106
160
|
* This method implements the token exchange grant as specified in RFC 8693.
|
|
107
161
|
* It performs a token exchange by sending a request to the `/oauth/token` endpoint
|
|
108
162
|
* with the external token and returns Auth0 tokens (access token, ID token, etc.).
|
|
109
163
|
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
164
|
+
* **Example:**
|
|
165
|
+
* ```js
|
|
166
|
+
* // Instead of:
|
|
167
|
+
* const tokens = await exchangeToken(options);
|
|
168
|
+
*
|
|
169
|
+
* // Use:
|
|
170
|
+
* const tokens = await loginWithCustomTokenExchange(options);
|
|
171
|
+
* ```
|
|
116
172
|
*
|
|
117
173
|
* @param options - The options required to perform the token exchange
|
|
118
174
|
* @returns A promise that resolves to the token endpoint response containing Auth0 tokens
|
|
@@ -237,10 +293,21 @@ export interface Auth0ContextInterface<TUser extends User = User>
|
|
|
237
293
|
* This is a drop-in replacement for the Fetch API's `fetch()` method, but will
|
|
238
294
|
* handle certain authentication logic for you, like building the proper auth
|
|
239
295
|
* headers or managing DPoP nonces and retries automatically.
|
|
240
|
-
*
|
|
296
|
+
*
|
|
241
297
|
* Check the `EXAMPLES.md` file for a deeper look into this method.
|
|
242
298
|
*/
|
|
243
299
|
createFetcher: Auth0Client['createFetcher'];
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* ```js
|
|
303
|
+
* const config = getConfiguration();
|
|
304
|
+
* // { domain: 'tenant.auth0.com', clientId: 'abc123' }
|
|
305
|
+
* ```
|
|
306
|
+
*
|
|
307
|
+
* Returns a readonly copy of the initialization configuration
|
|
308
|
+
* containing the domain and clientId.
|
|
309
|
+
*/
|
|
310
|
+
getConfiguration: Auth0Client['getConfiguration'];
|
|
244
311
|
}
|
|
245
312
|
|
|
246
313
|
/**
|
|
@@ -260,6 +327,7 @@ export const initialContext = {
|
|
|
260
327
|
getAccessTokenSilently: stub,
|
|
261
328
|
getAccessTokenWithPopup: stub,
|
|
262
329
|
getIdTokenClaims: stub,
|
|
330
|
+
loginWithCustomTokenExchange: stub,
|
|
263
331
|
exchangeToken: stub,
|
|
264
332
|
loginWithRedirect: stub,
|
|
265
333
|
loginWithPopup: stub,
|
|
@@ -270,6 +338,7 @@ export const initialContext = {
|
|
|
270
338
|
setDpopNonce: stub,
|
|
271
339
|
generateDpopProof: stub,
|
|
272
340
|
createFetcher: stub,
|
|
341
|
+
getConfiguration: stub,
|
|
273
342
|
};
|
|
274
343
|
|
|
275
344
|
/**
|
package/src/auth0-provider.tsx
CHANGED
|
@@ -279,19 +279,19 @@ const Auth0Provider = <TUser extends User = User>(opts: Auth0ProviderOptions<TUs
|
|
|
279
279
|
[client]
|
|
280
280
|
);
|
|
281
281
|
|
|
282
|
-
const
|
|
282
|
+
const loginWithCustomTokenExchange = useCallback(
|
|
283
283
|
async (
|
|
284
284
|
options: CustomTokenExchangeOptions
|
|
285
285
|
): Promise<TokenEndpointResponse> => {
|
|
286
286
|
let tokenResponse;
|
|
287
287
|
try {
|
|
288
|
-
tokenResponse = await client.
|
|
288
|
+
tokenResponse = await client.loginWithCustomTokenExchange(options);
|
|
289
289
|
} catch (error) {
|
|
290
290
|
throw tokenError(error);
|
|
291
291
|
} finally {
|
|
292
|
-
// We dispatch the standard GET_ACCESS_TOKEN_COMPLETE action here to maintain
|
|
293
|
-
// backward compatibility and consistency with the getAccessTokenSilently flow.
|
|
294
|
-
// This ensures the SDK's internal state lifecycle (loading/user updates) remains
|
|
292
|
+
// We dispatch the standard GET_ACCESS_TOKEN_COMPLETE action here to maintain
|
|
293
|
+
// backward compatibility and consistency with the getAccessTokenSilently flow.
|
|
294
|
+
// This ensures the SDK's internal state lifecycle (loading/user updates) remains
|
|
295
295
|
// identical regardless of whether the token was retrieved via silent auth or CTE.
|
|
296
296
|
dispatch({
|
|
297
297
|
type: 'GET_ACCESS_TOKEN_COMPLETE',
|
|
@@ -303,6 +303,15 @@ const Auth0Provider = <TUser extends User = User>(opts: Auth0ProviderOptions<TUs
|
|
|
303
303
|
[client]
|
|
304
304
|
);
|
|
305
305
|
|
|
306
|
+
const exchangeToken = useCallback(
|
|
307
|
+
async (
|
|
308
|
+
options: CustomTokenExchangeOptions
|
|
309
|
+
): Promise<TokenEndpointResponse> => {
|
|
310
|
+
return loginWithCustomTokenExchange(options);
|
|
311
|
+
},
|
|
312
|
+
[loginWithCustomTokenExchange]
|
|
313
|
+
);
|
|
314
|
+
|
|
306
315
|
const handleRedirectCallback = useCallback(
|
|
307
316
|
async (
|
|
308
317
|
url?: string
|
|
@@ -341,12 +350,18 @@ const Auth0Provider = <TUser extends User = User>(opts: Auth0ProviderOptions<TUs
|
|
|
341
350
|
[client]
|
|
342
351
|
);
|
|
343
352
|
|
|
353
|
+
const getConfiguration = useCallback<Auth0Client['getConfiguration']>(
|
|
354
|
+
() => client.getConfiguration(),
|
|
355
|
+
[client]
|
|
356
|
+
);
|
|
357
|
+
|
|
344
358
|
const contextValue = useMemo<Auth0ContextInterface<TUser>>(() => {
|
|
345
359
|
return {
|
|
346
360
|
...state,
|
|
347
361
|
getAccessTokenSilently,
|
|
348
362
|
getAccessTokenWithPopup,
|
|
349
363
|
getIdTokenClaims,
|
|
364
|
+
loginWithCustomTokenExchange,
|
|
350
365
|
exchangeToken,
|
|
351
366
|
loginWithRedirect,
|
|
352
367
|
loginWithPopup,
|
|
@@ -357,12 +372,14 @@ const Auth0Provider = <TUser extends User = User>(opts: Auth0ProviderOptions<TUs
|
|
|
357
372
|
setDpopNonce,
|
|
358
373
|
generateDpopProof,
|
|
359
374
|
createFetcher,
|
|
375
|
+
getConfiguration,
|
|
360
376
|
};
|
|
361
377
|
}, [
|
|
362
378
|
state,
|
|
363
379
|
getAccessTokenSilently,
|
|
364
380
|
getAccessTokenWithPopup,
|
|
365
381
|
getIdTokenClaims,
|
|
382
|
+
loginWithCustomTokenExchange,
|
|
366
383
|
exchangeToken,
|
|
367
384
|
loginWithRedirect,
|
|
368
385
|
loginWithPopup,
|
|
@@ -373,6 +390,7 @@ const Auth0Provider = <TUser extends User = User>(opts: Auth0ProviderOptions<TUs
|
|
|
373
390
|
setDpopNonce,
|
|
374
391
|
generateDpopProof,
|
|
375
392
|
createFetcher,
|
|
393
|
+
getConfiguration,
|
|
376
394
|
]);
|
|
377
395
|
|
|
378
396
|
return <context.Provider value={contextValue}>{children}</context.Provider>;
|
package/src/index.tsx
CHANGED
package/src/use-auth0.tsx
CHANGED
|
@@ -14,7 +14,8 @@ import Auth0Context, { Auth0ContextInterface } from './auth0-context';
|
|
|
14
14
|
* getAccessTokenSilently,
|
|
15
15
|
* getAccessTokenWithPopup,
|
|
16
16
|
* getIdTokenClaims,
|
|
17
|
-
*
|
|
17
|
+
* loginWithCustomTokenExchange,
|
|
18
|
+
* exchangeToken, // deprecated - use loginWithCustomTokenExchange
|
|
18
19
|
* loginWithRedirect,
|
|
19
20
|
* loginWithPopup,
|
|
20
21
|
* logout,
|