@auth0/auth0-react 2.4.0 → 2.5.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/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 } 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 } from '@auth0/auth0-spa-js';
7
7
  export { OAuthError } from './errors';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -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,GACT,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,EACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,IAAI,aAAa,EACxB,oBAAoB,EACpB,QAAQ,GACT,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,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,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.0",
4
+ "version": "2.5.0",
5
5
  "description": "Auth0 SDK for React Single Page Applications (SPA)",
6
6
  "keywords": [
7
7
  "auth0",
@@ -56,7 +56,7 @@
56
56
  "@rollup/plugin-terser": "^0.4.3",
57
57
  "@testing-library/dom": "^10.4.0",
58
58
  "@testing-library/jest-dom": "6.6.3",
59
- "@testing-library/react": "16.1.0",
59
+ "@testing-library/react": "16.3.0",
60
60
  "@types/jest": "^29.5.14",
61
61
  "@types/react": "19.1.8",
62
62
  "@types/react-dom": "19.1.6",
@@ -95,6 +95,6 @@
95
95
  "react-dom": "^16.11.0 || ^17 || ^18 || ^19"
96
96
  },
97
97
  "dependencies": {
98
- "@auth0/auth0-spa-js": "^2.2.0"
98
+ "@auth0/auth0-spa-js": "^2.4.1"
99
99
  }
100
100
  }
@@ -9,6 +9,7 @@ import {
9
9
  User,
10
10
  GetTokenSilentlyVerboseResponse,
11
11
  RedirectLoginOptions as SPARedirectLoginOptions,
12
+ type Auth0Client,
12
13
  } from '@auth0/auth0-spa-js';
13
14
  import { createContext } from 'react';
14
15
  import { AuthState, initialAuthState } from './auth-state';
@@ -140,6 +141,51 @@ export interface Auth0ContextInterface<TUser extends User = User>
140
141
  * @param url The URL to that should be used to retrieve the `state` and `code` values. Defaults to `window.location.href` if not given.
141
142
  */
142
143
  handleRedirectCallback: (url?: string) => Promise<RedirectLoginResult>;
144
+
145
+ /**
146
+ * Returns the current DPoP nonce used for making requests to Auth0.
147
+ *
148
+ * It can return `undefined` because when starting fresh it will not
149
+ * be populated until after the first response from the server.
150
+ *
151
+ * It requires enabling the {@link Auth0ClientOptions.useDpop} option.
152
+ *
153
+ * @param nonce The nonce value.
154
+ * @param id The identifier of a nonce: if absent, it will get the nonce
155
+ * used for requests to Auth0. Otherwise, it will be used to
156
+ * select a specific non-Auth0 nonce.
157
+ */
158
+ getDpopNonce: Auth0Client['getDpopNonce'];
159
+
160
+ /**
161
+ * Sets the current DPoP nonce used for making requests to Auth0.
162
+ *
163
+ * It requires enabling the {@link Auth0ClientOptions.useDpop} option.
164
+ *
165
+ * @param nonce The nonce value.
166
+ * @param id The identifier of a nonce: if absent, it will set the nonce
167
+ * used for requests to Auth0. Otherwise, it will be used to
168
+ * select a specific non-Auth0 nonce.
169
+ */
170
+ setDpopNonce: Auth0Client['setDpopNonce'];
171
+
172
+ /**
173
+ * Returns a string to be used to demonstrate possession of the private
174
+ * key used to cryptographically bind access tokens with DPoP.
175
+ *
176
+ * It requires enabling the {@link Auth0ClientOptions.useDpop} option.
177
+ */
178
+ generateDpopProof: Auth0Client['generateDpopProof'];
179
+
180
+ /**
181
+ * Returns a new `Fetcher` class that will contain a `fetchWithAuth()` method.
182
+ * This is a drop-in replacement for the Fetch API's `fetch()` method, but will
183
+ * handle certain authentication logic for you, like building the proper auth
184
+ * headers or managing DPoP nonces and retries automatically.
185
+ *
186
+ * Check the `EXAMPLES.md` file for a deeper look into this method.
187
+ */
188
+ createFetcher: Auth0Client['createFetcher'];
143
189
  }
144
190
 
145
191
  /**
@@ -163,6 +209,10 @@ export const initialContext = {
163
209
  loginWithPopup: stub,
164
210
  logout: stub,
165
211
  handleRedirectCallback: stub,
212
+ getDpopNonce: stub,
213
+ setDpopNonce: stub,
214
+ generateDpopProof: stub,
215
+ createFetcher: stub,
166
216
  };
167
217
 
168
218
  /**
@@ -272,6 +272,26 @@ const Auth0Provider = <TUser extends User = User>(opts: Auth0ProviderOptions<TUs
272
272
  [client]
273
273
  );
274
274
 
275
+ const getDpopNonce = useCallback<Auth0Client['getDpopNonce']>(
276
+ (id) => client.getDpopNonce(id),
277
+ [client]
278
+ );
279
+
280
+ const setDpopNonce = useCallback<Auth0Client['setDpopNonce']>(
281
+ (nonce, id) => client.setDpopNonce(nonce, id),
282
+ [client]
283
+ );
284
+
285
+ const generateDpopProof = useCallback<Auth0Client['generateDpopProof']>(
286
+ (params) => client.generateDpopProof(params),
287
+ [client]
288
+ );
289
+
290
+ const createFetcher = useCallback<Auth0Client['createFetcher']>(
291
+ (config) => client.createFetcher(config),
292
+ [client]
293
+ );
294
+
275
295
  const contextValue = useMemo<Auth0ContextInterface<TUser>>(() => {
276
296
  return {
277
297
  ...state,
@@ -282,6 +302,10 @@ const Auth0Provider = <TUser extends User = User>(opts: Auth0ProviderOptions<TUs
282
302
  loginWithPopup,
283
303
  logout,
284
304
  handleRedirectCallback,
305
+ getDpopNonce,
306
+ setDpopNonce,
307
+ generateDpopProof,
308
+ createFetcher,
285
309
  };
286
310
  }, [
287
311
  state,
@@ -292,6 +316,10 @@ const Auth0Provider = <TUser extends User = User>(opts: Auth0ProviderOptions<TUs
292
316
  loginWithPopup,
293
317
  logout,
294
318
  handleRedirectCallback,
319
+ getDpopNonce,
320
+ setDpopNonce,
321
+ generateDpopProof,
322
+ createFetcher,
295
323
  ]);
296
324
 
297
325
  return <context.Provider value={contextValue}>{children}</context.Provider>;
package/src/index.tsx CHANGED
@@ -36,6 +36,8 @@ export {
36
36
  PopupTimeoutError,
37
37
  AuthenticationError,
38
38
  MissingRefreshTokenError,
39
- GenericError
39
+ GenericError,
40
+ UseDpopNonceError,
41
+ type FetcherConfig
40
42
  } from '@auth0/auth0-spa-js';
41
43
  export { OAuthError } from './errors';