@frontegg/redux-store 6.186.0-alpha.2 → 6.186.0-alpha.4
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/auth/ImpersonationState/saga.js +3 -1
- package/auth/LoginState/sagas/afterAuthNavigation.saga.d.ts +5 -2
- package/auth/LoginState/sagas/afterAuthNavigation.saga.js +16 -13
- package/index.js +1 -1
- package/node/auth/ImpersonationState/saga.js +3 -1
- package/node/auth/LoginState/sagas/afterAuthNavigation.saga.js +16 -13
- package/node/index.js +1 -1
- package/package.json +1 -1
|
@@ -26,7 +26,9 @@ function* impersonate(_ref) {
|
|
|
26
26
|
console.log('after setImpersonateState');
|
|
27
27
|
yield delay(1000);
|
|
28
28
|
console.log('after delay');
|
|
29
|
-
yield afterAuthNavigation(
|
|
29
|
+
yield afterAuthNavigation({
|
|
30
|
+
forceRefresh: true
|
|
31
|
+
});
|
|
30
32
|
console.log('after afterAuthNavigation');
|
|
31
33
|
yield put(actions.resetImpersonateState());
|
|
32
34
|
console.log('after resetImpersonateState');
|
|
@@ -4,6 +4,7 @@ interface AfterAuthNavigationUtilOptions {
|
|
|
4
4
|
customLoginAuthenticatedUrl?: string;
|
|
5
5
|
forceStepUpUrl?: string;
|
|
6
6
|
shouldStepUpDuringLogin?: boolean;
|
|
7
|
+
forceRefresh?: boolean;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
9
10
|
* Utility to share after auth navigation flow between login and step up
|
|
@@ -11,12 +12,14 @@ interface AfterAuthNavigationUtilOptions {
|
|
|
11
12
|
* @param customLoginAuthenticatedUrl custom login authenticated url if exists
|
|
12
13
|
* @param shouldStepUpDuringLogin true when it's login after step up flow
|
|
13
14
|
*/
|
|
14
|
-
export declare function afterAuthNavigationUtil(resetStateAction: () => Action, { customLoginAuthenticatedUrl, forceStepUpUrl, shouldStepUpDuringLogin }?: AfterAuthNavigationUtilOptions): Generator<import("redux-saga/effects").CallEffect<true> | import("redux-saga/effects").CallEffect<string>, void, string | undefined>;
|
|
15
|
+
export declare function afterAuthNavigationUtil(resetStateAction: () => Action, { customLoginAuthenticatedUrl, forceStepUpUrl, shouldStepUpDuringLogin, forceRefresh, }?: AfterAuthNavigationUtilOptions): Generator<import("redux-saga/effects").CallEffect<true> | import("redux-saga/effects").CallEffect<string>, void, string | undefined>;
|
|
15
16
|
/**
|
|
16
17
|
* After auth navigation for login flow
|
|
17
18
|
* Handling also step up scenario when user silently logout to continue to step up
|
|
18
19
|
*/
|
|
19
|
-
export declare function afterAuthNavigation(
|
|
20
|
+
export declare function afterAuthNavigation(payload?: {
|
|
21
|
+
forceRefresh?: boolean;
|
|
22
|
+
}): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").CallEffect<void>, void, {
|
|
20
23
|
routes: {
|
|
21
24
|
customLoginAuthenticatedUrl: any;
|
|
22
25
|
stepUpUrl: any;
|
|
@@ -12,11 +12,12 @@ import { SHOULD_STEP_UP_KEY } from '../../StepUpState/consts';
|
|
|
12
12
|
* @returns url without the origin if it's the same origin as the current window origin
|
|
13
13
|
*/
|
|
14
14
|
function cleanUrlIfSameOrigin(url) {
|
|
15
|
-
var _window, _window2;
|
|
15
|
+
var _window, _window2, _window3;
|
|
16
16
|
if (!url.startsWith((_window = window) == null ? void 0 : _window.location.origin)) {
|
|
17
17
|
return url;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
console.log('url.replace(window?.location.origin, )', url.replace((_window2 = window) == null ? void 0 : _window2.location.origin, ''));
|
|
20
|
+
return url.replace((_window3 = window) == null ? void 0 : _window3.location.origin, '') || '/';
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
/**
|
|
@@ -63,7 +64,8 @@ function* getUrlForAfterAuthNavigation(customLoginAuthenticatedUrl) {
|
|
|
63
64
|
export function* afterAuthNavigationUtil(resetStateAction, {
|
|
64
65
|
customLoginAuthenticatedUrl,
|
|
65
66
|
forceStepUpUrl,
|
|
66
|
-
shouldStepUpDuringLogin
|
|
67
|
+
shouldStepUpDuringLogin,
|
|
68
|
+
forceRefresh = false
|
|
67
69
|
} = {}) {
|
|
68
70
|
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
69
71
|
let redirectUrl = undefined;
|
|
@@ -72,7 +74,7 @@ export function* afterAuthNavigationUtil(resetStateAction, {
|
|
|
72
74
|
// we don't want to remove the FRONTEGG_AFTER_AUTH_REDIRECT_URL when we are in the step up flow
|
|
73
75
|
redirectUrl = forceStepUpUrl;
|
|
74
76
|
} else {
|
|
75
|
-
var
|
|
77
|
+
var _window4;
|
|
76
78
|
if (shouldStepUpDuringLogin) {
|
|
77
79
|
// getUrlForAfterAuthNavigation give priority to the redirectUrl
|
|
78
80
|
// avoiding use of getUrlForAfterAuthNavigation because we don't want to use the redirectUrl for magic link for example
|
|
@@ -84,16 +86,16 @@ export function* afterAuthNavigationUtil(resetStateAction, {
|
|
|
84
86
|
if (!redirectUrl) {
|
|
85
87
|
redirectUrl = yield call(getUrlForAfterAuthNavigation, customLoginAuthenticatedUrl);
|
|
86
88
|
}
|
|
87
|
-
(
|
|
89
|
+
(_window4 = window) == null ? void 0 : _window4.localStorage.removeItem(FRONTEGG_AFTER_AUTH_REDIRECT_URL);
|
|
88
90
|
}
|
|
89
91
|
console.log('afterAuthNavigationUtil redirectUrl', redirectUrl);
|
|
90
92
|
yield delay(200);
|
|
91
93
|
put(resetStateAction());
|
|
92
94
|
console.log('afterAuthNavigationUtil onRedirectTo', {
|
|
93
|
-
refresh: redirectUrl.startsWith('http')
|
|
95
|
+
refresh: redirectUrl.startsWith('http') || forceRefresh
|
|
94
96
|
});
|
|
95
97
|
onRedirectTo(redirectUrl, {
|
|
96
|
-
refresh: redirectUrl.startsWith('http')
|
|
98
|
+
refresh: redirectUrl.startsWith('http') || forceRefresh
|
|
97
99
|
});
|
|
98
100
|
}
|
|
99
101
|
|
|
@@ -101,8 +103,8 @@ export function* afterAuthNavigationUtil(resetStateAction, {
|
|
|
101
103
|
* After auth navigation for login flow
|
|
102
104
|
* Handling also step up scenario when user silently logout to continue to step up
|
|
103
105
|
*/
|
|
104
|
-
export function* afterAuthNavigation() {
|
|
105
|
-
var
|
|
106
|
+
export function* afterAuthNavigation(payload) {
|
|
107
|
+
var _window5, _payload$forceRefresh;
|
|
106
108
|
const {
|
|
107
109
|
routes: {
|
|
108
110
|
customLoginAuthenticatedUrl,
|
|
@@ -111,13 +113,13 @@ export function* afterAuthNavigation() {
|
|
|
111
113
|
} = yield select(state => state.auth);
|
|
112
114
|
|
|
113
115
|
// login with magic code, try to step up, no other mfa, invalid max age, force_enroll -> logout, login with first factor, not-stepped up jwt -> navigate to step up
|
|
114
|
-
const shouldStepUp = (
|
|
116
|
+
const shouldStepUp = (_window5 = window) == null ? void 0 : _window5.localStorage.getItem(SHOULD_STEP_UP_KEY);
|
|
115
117
|
const user = yield select(({
|
|
116
118
|
auth
|
|
117
119
|
}) => auth.user);
|
|
118
120
|
if (shouldStepUp) {
|
|
119
|
-
var
|
|
120
|
-
(
|
|
121
|
+
var _window6;
|
|
122
|
+
(_window6 = window) == null ? void 0 : _window6.localStorage.removeItem(SHOULD_STEP_UP_KEY);
|
|
121
123
|
}
|
|
122
124
|
if (stepUpUrl && shouldStepUp && !isSteppedUp(user)) {
|
|
123
125
|
yield call(afterAuthNavigationUtil, actions.resetLoginState, {
|
|
@@ -136,7 +138,8 @@ export function* afterAuthNavigation() {
|
|
|
136
138
|
console.log('call afterAuthNavigationUtil');
|
|
137
139
|
yield call(afterAuthNavigationUtil, actions.resetLoginState, {
|
|
138
140
|
customLoginAuthenticatedUrl: customLoginURL,
|
|
139
|
-
shouldStepUpDuringLogin: !!shouldStepUp
|
|
141
|
+
shouldStepUpDuringLogin: !!shouldStepUp,
|
|
142
|
+
forceRefresh: (_payload$forceRefresh = payload == null ? void 0 : payload.forceRefresh) != null ? _payload$forceRefresh : false
|
|
140
143
|
});
|
|
141
144
|
}
|
|
142
145
|
|
package/index.js
CHANGED
|
@@ -33,7 +33,9 @@ function* impersonate(_ref) {
|
|
|
33
33
|
console.log('after setImpersonateState');
|
|
34
34
|
yield (0, _effects.delay)(1000);
|
|
35
35
|
console.log('after delay');
|
|
36
|
-
yield (0, _saga.afterAuthNavigation)(
|
|
36
|
+
yield (0, _saga.afterAuthNavigation)({
|
|
37
|
+
forceRefresh: true
|
|
38
|
+
});
|
|
37
39
|
console.log('after afterAuthNavigation');
|
|
38
40
|
yield (0, _effects.put)(_reducer.actions.resetImpersonateState());
|
|
39
41
|
console.log('after resetImpersonateState');
|
|
@@ -19,11 +19,12 @@ var _consts = require("../../StepUpState/consts");
|
|
|
19
19
|
* @returns url without the origin if it's the same origin as the current window origin
|
|
20
20
|
*/
|
|
21
21
|
function cleanUrlIfSameOrigin(url) {
|
|
22
|
-
var _window, _window2;
|
|
22
|
+
var _window, _window2, _window3;
|
|
23
23
|
if (!url.startsWith((_window = window) == null ? void 0 : _window.location.origin)) {
|
|
24
24
|
return url;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
console.log('url.replace(window?.location.origin, )', url.replace((_window2 = window) == null ? void 0 : _window2.location.origin, ''));
|
|
27
|
+
return url.replace((_window3 = window) == null ? void 0 : _window3.location.origin, '') || '/';
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
/**
|
|
@@ -70,7 +71,8 @@ function* getUrlForAfterAuthNavigation(customLoginAuthenticatedUrl) {
|
|
|
70
71
|
function* afterAuthNavigationUtil(resetStateAction, {
|
|
71
72
|
customLoginAuthenticatedUrl,
|
|
72
73
|
forceStepUpUrl,
|
|
73
|
-
shouldStepUpDuringLogin
|
|
74
|
+
shouldStepUpDuringLogin,
|
|
75
|
+
forceRefresh = false
|
|
74
76
|
} = {}) {
|
|
75
77
|
const onRedirectTo = _restApi.ContextHolder.onRedirectTo;
|
|
76
78
|
let redirectUrl = undefined;
|
|
@@ -79,7 +81,7 @@ function* afterAuthNavigationUtil(resetStateAction, {
|
|
|
79
81
|
// we don't want to remove the FRONTEGG_AFTER_AUTH_REDIRECT_URL when we are in the step up flow
|
|
80
82
|
redirectUrl = forceStepUpUrl;
|
|
81
83
|
} else {
|
|
82
|
-
var
|
|
84
|
+
var _window4;
|
|
83
85
|
if (shouldStepUpDuringLogin) {
|
|
84
86
|
// getUrlForAfterAuthNavigation give priority to the redirectUrl
|
|
85
87
|
// avoiding use of getUrlForAfterAuthNavigation because we don't want to use the redirectUrl for magic link for example
|
|
@@ -91,16 +93,16 @@ function* afterAuthNavigationUtil(resetStateAction, {
|
|
|
91
93
|
if (!redirectUrl) {
|
|
92
94
|
redirectUrl = yield (0, _effects.call)(getUrlForAfterAuthNavigation, customLoginAuthenticatedUrl);
|
|
93
95
|
}
|
|
94
|
-
(
|
|
96
|
+
(_window4 = window) == null ? void 0 : _window4.localStorage.removeItem(_constants.FRONTEGG_AFTER_AUTH_REDIRECT_URL);
|
|
95
97
|
}
|
|
96
98
|
console.log('afterAuthNavigationUtil redirectUrl', redirectUrl);
|
|
97
99
|
yield (0, _effects.delay)(200);
|
|
98
100
|
(0, _effects.put)(resetStateAction());
|
|
99
101
|
console.log('afterAuthNavigationUtil onRedirectTo', {
|
|
100
|
-
refresh: redirectUrl.startsWith('http')
|
|
102
|
+
refresh: redirectUrl.startsWith('http') || forceRefresh
|
|
101
103
|
});
|
|
102
104
|
onRedirectTo(redirectUrl, {
|
|
103
|
-
refresh: redirectUrl.startsWith('http')
|
|
105
|
+
refresh: redirectUrl.startsWith('http') || forceRefresh
|
|
104
106
|
});
|
|
105
107
|
}
|
|
106
108
|
|
|
@@ -108,8 +110,8 @@ function* afterAuthNavigationUtil(resetStateAction, {
|
|
|
108
110
|
* After auth navigation for login flow
|
|
109
111
|
* Handling also step up scenario when user silently logout to continue to step up
|
|
110
112
|
*/
|
|
111
|
-
function* afterAuthNavigation() {
|
|
112
|
-
var
|
|
113
|
+
function* afterAuthNavigation(payload) {
|
|
114
|
+
var _window5, _payload$forceRefresh;
|
|
113
115
|
const {
|
|
114
116
|
routes: {
|
|
115
117
|
customLoginAuthenticatedUrl,
|
|
@@ -118,13 +120,13 @@ function* afterAuthNavigation() {
|
|
|
118
120
|
} = yield (0, _effects.select)(state => state.auth);
|
|
119
121
|
|
|
120
122
|
// login with magic code, try to step up, no other mfa, invalid max age, force_enroll -> logout, login with first factor, not-stepped up jwt -> navigate to step up
|
|
121
|
-
const shouldStepUp = (
|
|
123
|
+
const shouldStepUp = (_window5 = window) == null ? void 0 : _window5.localStorage.getItem(_consts.SHOULD_STEP_UP_KEY);
|
|
122
124
|
const user = yield (0, _effects.select)(({
|
|
123
125
|
auth
|
|
124
126
|
}) => auth.user);
|
|
125
127
|
if (shouldStepUp) {
|
|
126
|
-
var
|
|
127
|
-
(
|
|
128
|
+
var _window6;
|
|
129
|
+
(_window6 = window) == null ? void 0 : _window6.localStorage.removeItem(_consts.SHOULD_STEP_UP_KEY);
|
|
128
130
|
}
|
|
129
131
|
if (stepUpUrl && shouldStepUp && !(0, _StepUpState.isSteppedUp)(user)) {
|
|
130
132
|
yield (0, _effects.call)(afterAuthNavigationUtil, _reducer.actions.resetLoginState, {
|
|
@@ -143,7 +145,8 @@ function* afterAuthNavigation() {
|
|
|
143
145
|
console.log('call afterAuthNavigationUtil');
|
|
144
146
|
yield (0, _effects.call)(afterAuthNavigationUtil, _reducer.actions.resetLoginState, {
|
|
145
147
|
customLoginAuthenticatedUrl: customLoginURL,
|
|
146
|
-
shouldStepUpDuringLogin: !!shouldStepUp
|
|
148
|
+
shouldStepUpDuringLogin: !!shouldStepUp,
|
|
149
|
+
forceRefresh: (_payload$forceRefresh = payload == null ? void 0 : payload.forceRefresh) != null ? _payload$forceRefresh : false
|
|
147
150
|
});
|
|
148
151
|
}
|
|
149
152
|
|
package/node/index.js
CHANGED