@auth0/auth0-react 2.0.2 → 2.1.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.
@@ -217,7 +217,7 @@ var toAuth0ClientOptions = function (opts) {
217
217
  deprecateRedirectUri(opts);
218
218
  return __assign(__assign({}, opts), { auth0Client: {
219
219
  name: 'auth0-react',
220
- version: '2.0.2',
220
+ version: '2.1.0',
221
221
  } });
222
222
  };
223
223
  /**
@@ -484,6 +484,12 @@ var withAuth0 = function (Component, context) {
484
484
  * @ignore
485
485
  */
486
486
  var defaultOnRedirecting = function () { return React.createElement(React.Fragment, null); };
487
+ /**
488
+ * @ignore
489
+ */
490
+ var defaultOnBeforeAuthentication = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
491
+ return [2 /*return*/];
492
+ }); }); };
487
493
  /**
488
494
  * @ignore
489
495
  */
@@ -502,8 +508,8 @@ var withAuthenticationRequired = function (Component, options) {
502
508
  if (options === void 0) { options = {}; }
503
509
  return function WithAuthenticationRequired(props) {
504
510
  var _this = this;
505
- var _a = options.returnTo, returnTo = _a === void 0 ? defaultReturnTo : _a, _b = options.onRedirecting, onRedirecting = _b === void 0 ? defaultOnRedirecting : _b, loginOptions = options.loginOptions, _c = options.context, context = _c === void 0 ? Auth0Context : _c;
506
- var _d = useAuth0(context), isAuthenticated = _d.isAuthenticated, isLoading = _d.isLoading, loginWithRedirect = _d.loginWithRedirect;
511
+ var _a = options.returnTo, returnTo = _a === void 0 ? defaultReturnTo : _a, _b = options.onRedirecting, onRedirecting = _b === void 0 ? defaultOnRedirecting : _b, _c = options.onBeforeAuthentication, onBeforeAuthentication = _c === void 0 ? defaultOnBeforeAuthentication : _c, loginOptions = options.loginOptions, _d = options.context, context = _d === void 0 ? Auth0Context : _d;
512
+ var _e = useAuth0(context), isAuthenticated = _e.isAuthenticated, isLoading = _e.isLoading, loginWithRedirect = _e.loginWithRedirect;
507
513
  useEffect(function () {
508
514
  if (isLoading || isAuthenticated) {
509
515
  return;
@@ -512,8 +518,11 @@ var withAuthenticationRequired = function (Component, options) {
512
518
  (function () { return __awaiter(_this, void 0, void 0, function () {
513
519
  return __generator(this, function (_a) {
514
520
  switch (_a.label) {
515
- case 0: return [4 /*yield*/, loginWithRedirect(opts)];
521
+ case 0: return [4 /*yield*/, onBeforeAuthentication()];
516
522
  case 1:
523
+ _a.sent();
524
+ return [4 /*yield*/, loginWithRedirect(opts)];
525
+ case 2:
517
526
  _a.sent();
518
527
  return [2 /*return*/];
519
528
  }
@@ -523,6 +532,7 @@ var withAuthenticationRequired = function (Component, options) {
523
532
  isLoading,
524
533
  isAuthenticated,
525
534
  loginWithRedirect,
535
+ onBeforeAuthentication,
526
536
  loginOptions,
527
537
  returnTo,
528
538
  ]);