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