@versini/auth0-react-thin 2.22.1 → 2.24.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/README.md +1 -1
- package/dist/auth0-context.d.ts +9 -0
- package/dist/auth0-context.d.ts.map +1 -1
- package/dist/auth0-provider.d.ts +5 -0
- package/dist/auth0-provider.d.ts.map +1 -1
- package/dist/auth0-react.cjs.js +173 -42
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +160 -48
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +172 -42
- 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 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/use-auth0-suspense.d.ts +35 -0
- package/dist/use-auth0-suspense.d.ts.map +1 -0
- package/dist/with-authentication-required.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/auth0-context.tsx +10 -0
- package/src/auth0-provider.tsx +87 -10
- package/src/index.tsx +4 -0
- package/src/use-auth0-suspense.tsx +71 -0
- package/src/with-authentication-required.tsx +8 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **Unofficial, community-maintained fork of [`@auth0/auth0-react`](https://www.npmjs.com/package/@auth0/auth0-react) — NOT affiliated with, endorsed by, sponsored by, or supported by Auth0 or Okta.**
|
|
4
4
|
|
|
5
|
-
This is [`@auth0/auth0-react@2.
|
|
5
|
+
This is [`@auth0/auth0-react@2.24.0`](https://www.npmjs.com/package/@auth0/auth0-react/v/2.24.0)
|
|
6
6
|
rebuilt with a single one-line Rollup change (`external: ['@auth0/auth0-spa-js']`) so it no
|
|
7
7
|
longer inlines that dependency. That drops ~26 KB gzip of first-paint weight for apps that use
|
|
8
8
|
only basic Auth0 login (no MFA/Passkey/MyAccount/DPoP). The public runtime API is otherwise
|
package/dist/auth0-context.d.ts
CHANGED
|
@@ -412,6 +412,15 @@ export interface Auth0ContextInterface<TUser extends User = User> extends AuthSt
|
|
|
412
412
|
* ```
|
|
413
413
|
*/
|
|
414
414
|
myAccount: MyAccountApiClient;
|
|
415
|
+
/**
|
|
416
|
+
* Internal. A promise that resolves when Auth0 initialization completes and
|
|
417
|
+
* rejects with the initialization error if it fails. Consumed by
|
|
418
|
+
* `useAuth0Suspense`, which also treats its absence as "no provider" — do not
|
|
419
|
+
* add a stub value for this field to `initialContext`. Not part of the
|
|
420
|
+
* supported public API.
|
|
421
|
+
* @ignore
|
|
422
|
+
*/
|
|
423
|
+
_initPromise?: Promise<void>;
|
|
415
424
|
}
|
|
416
425
|
/**
|
|
417
426
|
* @ignore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0-context.d.ts","sourceRoot":"","sources":["../src/auth0-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,OAAO,EACP,aAAa,IAAI,gBAAgB,EACjC,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,IAAI,EACJ,+BAA+B,EAC/B,oBAAoB,IAAI,uBAAuB,EAC/C,KAAK,WAAW,EAChB,6BAA6B,EAC7B,4BAA4B,EAC5B,0BAA0B,EAC1B,qBAAqB,EACrB,KAAK,yBAAyB,EAC9B,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAoB,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC;CAAG;AAE9E,MAAM,WAAW,oBAAoB,CAAC,SAAS,GAAG,QAAQ,CACxD,SAAQ,IAAI,CAAC,uBAAuB,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC;CAAG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AAe,YAAY,CAAC"}
|
package/dist/auth0-provider.d.ts
CHANGED
|
@@ -90,6 +90,11 @@ export type Auth0ProviderOptions<TUser extends User = User> = Auth0ProviderWithC
|
|
|
90
90
|
* ```
|
|
91
91
|
*
|
|
92
92
|
* Provides the Auth0Context to its child components.
|
|
93
|
+
*
|
|
94
|
+
* The SDK is a client-only module (its published ESM and CommonJS bundles ship the
|
|
95
|
+
* `'use client'` directive), so in a Next.js App Router app you can import and render
|
|
96
|
+
* `Auth0Provider` directly from a Server Component such as `app/layout.tsx`.
|
|
97
|
+
* Components that call hooks like `useAuth0` must still be Client Components.
|
|
93
98
|
*/
|
|
94
99
|
declare const Auth0Provider: <TUser extends User = User>(opts: Auth0ProviderOptions<TUser>) => React.JSX.Element;
|
|
95
100
|
export default Auth0Provider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth0-provider.d.ts","sourceRoot":"","sources":["../src/auth0-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AACf,OAAO,EACL,WAAW,EACX,kBAAkB,EAMlB,IAAI,EAEJ,4BAA4B,EAC5B,YAAY,EAOb,MAAM,qBAAqB,CAAC;AAC7B,OAAqB,EACnB,qBAAqB,EAGtB,MAAM,iBAAiB,CAAC;AAUzB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,4BAA4B,EAAE,UAAU,GAAG,eAAe,CAAC,CAAC;AAEhG;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,aAAa,CAAC,EAAE,YAAY,CAAC;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAC;AAEF,KAAK,wBAAwB,CAAC,KAAK,SAAS,IAAI,GAAG,IAAI,IAAI;IACzD;;OAEG;IACH,QAAQ,CAAC,EAAE,KAAK,CAA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K,CAAC,sBA+XlF,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/dist/auth0-react.cjs.js
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
4
|
var React = require('react');
|
|
4
5
|
var auth0SpaJs = require('@auth0/auth0-spa-js');
|
|
5
6
|
|
|
7
|
+
function _interopNamespaceDefault(e) {
|
|
8
|
+
var n = Object.create(null);
|
|
9
|
+
if (e) {
|
|
10
|
+
Object.keys(e).forEach(function (k) {
|
|
11
|
+
if (k !== 'default') {
|
|
12
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return e[k]; }
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
n.default = e;
|
|
21
|
+
return Object.freeze(n);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
25
|
+
|
|
6
26
|
/******************************************************************************
|
|
7
27
|
Copyright (c) Microsoft Corporation.
|
|
8
28
|
|
|
@@ -255,7 +275,7 @@ var toAuth0ClientOptions = function (opts) {
|
|
|
255
275
|
deprecateRedirectUri(opts);
|
|
256
276
|
return __assign(__assign({}, opts), { auth0Client: {
|
|
257
277
|
name: 'auth0-react',
|
|
258
|
-
version: '2.
|
|
278
|
+
version: '2.24.0',
|
|
259
279
|
} });
|
|
260
280
|
};
|
|
261
281
|
/**
|
|
@@ -265,6 +285,22 @@ var defaultOnRedirectCallback = function (appState) {
|
|
|
265
285
|
var _a;
|
|
266
286
|
window.history.replaceState({}, document.title, (_a = appState.returnTo) !== null && _a !== void 0 ? _a : window.location.pathname);
|
|
267
287
|
};
|
|
288
|
+
/**
|
|
289
|
+
* @ignore
|
|
290
|
+
*/
|
|
291
|
+
var createInitDeferred = function () {
|
|
292
|
+
var resolve;
|
|
293
|
+
var reject;
|
|
294
|
+
var promise = new Promise(function (res, rej) {
|
|
295
|
+
resolve = res;
|
|
296
|
+
reject = rej;
|
|
297
|
+
});
|
|
298
|
+
// Avoid unhandled-rejection warnings when no one is consuming the promise
|
|
299
|
+
// (i.e. useAuth0Suspense is not used). useAuth0Suspense attaches its own
|
|
300
|
+
// handler via use().
|
|
301
|
+
promise.catch(function () { return undefined; });
|
|
302
|
+
return { promise: promise, resolve: resolve, reject: reject };
|
|
303
|
+
};
|
|
268
304
|
/**
|
|
269
305
|
* ```jsx
|
|
270
306
|
* <Auth0Provider
|
|
@@ -276,6 +312,11 @@ var defaultOnRedirectCallback = function (appState) {
|
|
|
276
312
|
* ```
|
|
277
313
|
*
|
|
278
314
|
* Provides the Auth0Context to its child components.
|
|
315
|
+
*
|
|
316
|
+
* The SDK is a client-only module (its published ESM and CommonJS bundles ship the
|
|
317
|
+
* `'use client'` directive), so in a Next.js App Router app you can import and render
|
|
318
|
+
* `Auth0Provider` directly from a Server Component such as `app/layout.tsx`.
|
|
319
|
+
* Components that call hooks like `useAuth0` must still be Client Components.
|
|
279
320
|
*/
|
|
280
321
|
var Auth0Provider = function (opts) {
|
|
281
322
|
var _a = opts, children = _a.children, skipRedirectCallback = _a.skipRedirectCallback, _b = _a.onRedirectCallback, onRedirectCallback = _b === void 0 ? defaultOnRedirectCallback : _b, _c = _a.context, context = _c === void 0 ? Auth0Context : _c, providedClient = _a.client, clientOpts = __rest(_a, ["children", "skipRedirectCallback", "onRedirectCallback", "context", "client"]);
|
|
@@ -286,55 +327,94 @@ var Auth0Provider = function (opts) {
|
|
|
286
327
|
}
|
|
287
328
|
var client = React.useState(function () { return providedClient !== null && providedClient !== void 0 ? providedClient : new auth0SpaJs.Auth0Client(toAuth0ClientOptions(clientOpts)); })[0];
|
|
288
329
|
var _d = React.useReducer((reducer), initialAuthState), state = _d[0], dispatch = _d[1];
|
|
330
|
+
// In state so the init retry below can swap in a fresh, non-rejected promise.
|
|
331
|
+
// Without that swap the first rejection would re-throw on every later render,
|
|
332
|
+
// making Error Boundary retries useless.
|
|
333
|
+
var _e = React.useState(createInitDeferred), initDeferred = _e[0], setInitDeferred = _e[1];
|
|
334
|
+
// Set only once initialization has genuinely rejected. State, not a ref, so
|
|
335
|
+
// the retry effect re-evaluates when init fails *after* the app has become
|
|
336
|
+
// authenticated by some other means.
|
|
337
|
+
var _f = React.useState(false), initFailed = _f[0], setInitFailed = _f[1];
|
|
338
|
+
// Guards against retrying more than once: a retry that also fails would
|
|
339
|
+
// otherwise re-trigger the effect for as long as the user stays signed in.
|
|
340
|
+
var initRetried = React.useRef(false);
|
|
289
341
|
var didInitialise = React.useRef(false);
|
|
290
342
|
var handleError = React.useCallback(function (error) {
|
|
291
343
|
dispatch({ type: 'ERROR', error: error });
|
|
292
344
|
return error;
|
|
293
345
|
}, []);
|
|
346
|
+
// Settles `deferred` according to what initialization actually did, so
|
|
347
|
+
// `_initPromise` never claims success that did not happen. `allowRedirect`
|
|
348
|
+
// is false on a retry: the redirect callback is single-use, so a retry can
|
|
349
|
+
// only re-verify the session.
|
|
350
|
+
var runInit = React.useCallback(function (deferred, allowRedirect) { return __awaiter(void 0, void 0, void 0, function () {
|
|
351
|
+
var user, _a, _b, appState, response_type, result, error_1, err;
|
|
352
|
+
return __generator(this, function (_c) {
|
|
353
|
+
switch (_c.label) {
|
|
354
|
+
case 0:
|
|
355
|
+
_c.trys.push([0, 7, , 8]);
|
|
356
|
+
user = void 0;
|
|
357
|
+
if (!(allowRedirect && hasAuthParams() && !skipRedirectCallback)) return [3 /*break*/, 3];
|
|
358
|
+
return [4 /*yield*/, client.handleRedirectCallback()];
|
|
359
|
+
case 1:
|
|
360
|
+
_a = _c.sent(), _b = _a.appState, appState = _b === void 0 ? {} : _b, response_type = _a.response_type, result = __rest(_a, ["appState", "response_type"]);
|
|
361
|
+
return [4 /*yield*/, client.getUser()];
|
|
362
|
+
case 2:
|
|
363
|
+
user = _c.sent();
|
|
364
|
+
appState.response_type = response_type;
|
|
365
|
+
if (response_type === auth0SpaJs.ResponseType.ConnectCode) {
|
|
366
|
+
appState.connectedAccount = result;
|
|
367
|
+
}
|
|
368
|
+
onRedirectCallback(appState, user);
|
|
369
|
+
return [3 /*break*/, 6];
|
|
370
|
+
case 3: return [4 /*yield*/, client.checkSession()];
|
|
371
|
+
case 4:
|
|
372
|
+
_c.sent();
|
|
373
|
+
return [4 /*yield*/, client.getUser()];
|
|
374
|
+
case 5:
|
|
375
|
+
user = _c.sent();
|
|
376
|
+
_c.label = 6;
|
|
377
|
+
case 6:
|
|
378
|
+
dispatch({ type: 'INITIALISED', user: user });
|
|
379
|
+
deferred.resolve();
|
|
380
|
+
return [3 /*break*/, 8];
|
|
381
|
+
case 7:
|
|
382
|
+
error_1 = _c.sent();
|
|
383
|
+
err = loginError(error_1);
|
|
384
|
+
handleError(err);
|
|
385
|
+
setInitFailed(true);
|
|
386
|
+
deferred.reject(err);
|
|
387
|
+
return [3 /*break*/, 8];
|
|
388
|
+
case 8: return [2 /*return*/];
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
}); }, [client, onRedirectCallback, skipRedirectCallback, handleError]);
|
|
294
392
|
React.useEffect(function () {
|
|
295
393
|
if (didInitialise.current) {
|
|
296
394
|
return;
|
|
297
395
|
}
|
|
298
396
|
didInitialise.current = true;
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
case 4:
|
|
321
|
-
_c.sent();
|
|
322
|
-
return [4 /*yield*/, client.getUser()];
|
|
323
|
-
case 5:
|
|
324
|
-
user = _c.sent();
|
|
325
|
-
_c.label = 6;
|
|
326
|
-
case 6:
|
|
327
|
-
dispatch({ type: 'INITIALISED', user: user });
|
|
328
|
-
return [3 /*break*/, 8];
|
|
329
|
-
case 7:
|
|
330
|
-
error_1 = _c.sent();
|
|
331
|
-
handleError(loginError(error_1));
|
|
332
|
-
return [3 /*break*/, 8];
|
|
333
|
-
case 8: return [2 /*return*/];
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
}); })();
|
|
337
|
-
}, [client, onRedirectCallback, skipRedirectCallback, handleError]);
|
|
397
|
+
// Always the first deferred: `didInitialise` means this only ever runs once,
|
|
398
|
+
// so a later swap by the retry effect re-runs this effect but returns above.
|
|
399
|
+
void runInit(initDeferred, true);
|
|
400
|
+
}, [runInit, initDeferred]);
|
|
401
|
+
// A rejected promise stays rejected forever, so React.use() would re-throw on
|
|
402
|
+
// every later render and an Error Boundary retry could never recover. Once
|
|
403
|
+
// init has failed but the app has since become authenticated by some other
|
|
404
|
+
// means (loginWithPopup, a silent token, a passkey login), re-run the session
|
|
405
|
+
// check against a fresh deferred. The promise then reflects a real
|
|
406
|
+
// checkSession() outcome rather than an assumption that things are fine --
|
|
407
|
+
// if the session is still bad it rejects again and the boundary keeps showing
|
|
408
|
+
// the error.
|
|
409
|
+
React.useEffect(function () {
|
|
410
|
+
if (!initFailed || initRetried.current || !state.isAuthenticated) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
initRetried.current = true;
|
|
414
|
+
var retry = createInitDeferred();
|
|
415
|
+
setInitDeferred(retry);
|
|
416
|
+
void runInit(retry, false);
|
|
417
|
+
}, [initFailed, state.isAuthenticated, runInit]);
|
|
338
418
|
var loginWithRedirect = React.useCallback(function (opts) {
|
|
339
419
|
deprecateRedirectUri(opts);
|
|
340
420
|
return client.loginWithRedirect(opts);
|
|
@@ -618,7 +698,7 @@ var Auth0Provider = function (opts) {
|
|
|
618
698
|
}); }, [client]);
|
|
619
699
|
var passkey = React.useMemo(function () { return ({ signup: passkeySignup, login: passkeyLogin }); }, [passkeySignup, passkeyLogin]);
|
|
620
700
|
var contextValue = React.useMemo(function () {
|
|
621
|
-
return __assign(__assign({}, state), { getAccessTokenSilently: getAccessTokenSilently, getAccessTokenWithPopup: getAccessTokenWithPopup, getIdTokenClaims: getIdTokenClaims, loginWithCustomTokenExchange: loginWithCustomTokenExchange, customTokenExchange: customTokenExchange, exchangeToken: exchangeToken, loginWithRedirect: loginWithRedirect, loginWithPopup: loginWithPopup, connectAccountWithRedirect: connectAccountWithRedirect, logout: logout, revokeRefreshToken: revokeRefreshToken, handleRedirectCallback: handleRedirectCallback, getDpopNonce: getDpopNonce, setDpopNonce: setDpopNonce, generateDpopProof: generateDpopProof, createFetcher: createFetcher, getConfiguration: getConfiguration, mfa: mfa, passkey: passkey, myAccount: myAccount });
|
|
701
|
+
return __assign(__assign({}, state), { getAccessTokenSilently: getAccessTokenSilently, getAccessTokenWithPopup: getAccessTokenWithPopup, getIdTokenClaims: getIdTokenClaims, loginWithCustomTokenExchange: loginWithCustomTokenExchange, customTokenExchange: customTokenExchange, exchangeToken: exchangeToken, loginWithRedirect: loginWithRedirect, loginWithPopup: loginWithPopup, connectAccountWithRedirect: connectAccountWithRedirect, logout: logout, revokeRefreshToken: revokeRefreshToken, handleRedirectCallback: handleRedirectCallback, getDpopNonce: getDpopNonce, setDpopNonce: setDpopNonce, generateDpopProof: generateDpopProof, createFetcher: createFetcher, getConfiguration: getConfiguration, mfa: mfa, passkey: passkey, myAccount: myAccount, _initPromise: initDeferred.promise });
|
|
622
702
|
}, [
|
|
623
703
|
state,
|
|
624
704
|
getAccessTokenSilently,
|
|
@@ -641,6 +721,7 @@ var Auth0Provider = function (opts) {
|
|
|
641
721
|
mfa,
|
|
642
722
|
passkey,
|
|
643
723
|
myAccount,
|
|
724
|
+
initDeferred,
|
|
644
725
|
]);
|
|
645
726
|
return React.createElement(context.Provider, { value: contextValue }, children);
|
|
646
727
|
};
|
|
@@ -674,6 +755,50 @@ var useAuth0 = function (context) {
|
|
|
674
755
|
return React.useContext(context);
|
|
675
756
|
};
|
|
676
757
|
|
|
758
|
+
/**
|
|
759
|
+
* ```jsx
|
|
760
|
+
* <Suspense fallback={<Spinner />}>
|
|
761
|
+
* <Profile />
|
|
762
|
+
* </Suspense>
|
|
763
|
+
*
|
|
764
|
+
* function Profile() {
|
|
765
|
+
* const { user, isAuthenticated } = useAuth0Suspense();
|
|
766
|
+
* return isAuthenticated ? <p>Hello {user.name}</p> : <p>Please log in</p>;
|
|
767
|
+
* }
|
|
768
|
+
* ```
|
|
769
|
+
*
|
|
770
|
+
* Suspense-enabled variant of `useAuth0`. Suspends the component until Auth0
|
|
771
|
+
* initialization completes (letting the nearest `<Suspense>` fallback render),
|
|
772
|
+
* and throws initialization errors so the nearest Error Boundary can handle
|
|
773
|
+
* them. Requires React 19 or later.
|
|
774
|
+
*
|
|
775
|
+
* If initialization fails and the app later becomes authenticated by other
|
|
776
|
+
* means, the session is re-checked once; retrying the Error Boundary then
|
|
777
|
+
* renders if that check succeeded, or throws again if it did not.
|
|
778
|
+
*
|
|
779
|
+
* TUser is an optional type param to provide a type to the `user` field.
|
|
780
|
+
*/
|
|
781
|
+
var useAuth0Suspense = function (context) {
|
|
782
|
+
if (context === void 0) { context = Auth0Context; }
|
|
783
|
+
if (typeof React__namespace.use !== 'function') {
|
|
784
|
+
throw new Error('useAuth0Suspense requires React 19 or later (React.use is unavailable).');
|
|
785
|
+
}
|
|
786
|
+
var ctx = React__namespace.useContext(context);
|
|
787
|
+
if (!ctx._initPromise) {
|
|
788
|
+
throw new Error('useAuth0Suspense must be used within an <Auth0Provider>.');
|
|
789
|
+
}
|
|
790
|
+
// Suspends until the init promise resolves; re-throws if it rejected.
|
|
791
|
+
React__namespace.use(ctx._initPromise);
|
|
792
|
+
// Memoized so the returned object is referentially stable across renders,
|
|
793
|
+
// matching useAuth0, which hands back the provider's memoized context.
|
|
794
|
+
// Without this, `useEffect(..., [auth])` in a consumer re-runs every render.
|
|
795
|
+
return React__namespace.useMemo(function () {
|
|
796
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
797
|
+
ctx.isLoading; ctx._initPromise; var rest = __rest(ctx, ["isLoading", "_initPromise"]);
|
|
798
|
+
return rest;
|
|
799
|
+
}, [ctx]);
|
|
800
|
+
};
|
|
801
|
+
|
|
677
802
|
/**
|
|
678
803
|
* ```jsx
|
|
679
804
|
* class MyComponent extends Component {
|
|
@@ -713,7 +838,12 @@ var defaultOnBeforeAuthentication = function () { return __awaiter(void 0, void
|
|
|
713
838
|
* @ignore
|
|
714
839
|
*/
|
|
715
840
|
var defaultReturnTo = function () {
|
|
716
|
-
|
|
841
|
+
// Normalize the pathname to prevent protocol-relative open redirects.
|
|
842
|
+
// A URL like https://app.example.com//evil.com produces a pathname of
|
|
843
|
+
// //evil.com, which routers (react-router, next.js, gatsby) interpret as a
|
|
844
|
+
// protocol-relative URL and redirect the user to an external host.
|
|
845
|
+
var pathname = window.location.pathname.replace(/^\/\/+/, '/');
|
|
846
|
+
return "".concat(pathname).concat(window.location.search);
|
|
717
847
|
};
|
|
718
848
|
/**
|
|
719
849
|
* ```js
|
|
@@ -876,6 +1006,7 @@ exports.Auth0Provider = Auth0Provider;
|
|
|
876
1006
|
exports.OAuthError = OAuthError;
|
|
877
1007
|
exports.initialContext = initialContext;
|
|
878
1008
|
exports.useAuth0 = useAuth0;
|
|
1009
|
+
exports.useAuth0Suspense = useAuth0Suspense;
|
|
879
1010
|
exports.withAuth0 = withAuth0;
|
|
880
1011
|
exports.withAuthenticationRequired = withAuthenticationRequired;
|
|
881
1012
|
//# sourceMappingURL=auth0-react.cjs.js.map
|