@frontegg/redux-store 6.197.0 → 6.198.0-alpha.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/auth/AccountSettingsState/saga.js +26 -0
- package/auth/ActivateState/saga.js +4 -2
- package/auth/CustomLoginState/saga.d.ts +1 -1
- package/auth/CustomLoginState/saga.js +2 -1
- package/auth/Entitlements/utils.js +3 -2
- package/auth/LoginState/saga.d.ts +1 -0
- package/auth/LoginState/saga.js +57 -33
- package/auth/LoginState/sagas/afterAuthNavigation.saga.d.ts +1 -1
- package/auth/LoginState/sagas/afterAuthNavigation.saga.js +2 -1
- package/auth/LoginState/utils.d.ts +1 -1
- package/auth/LoginState/utils.js +6 -5
- package/auth/MSP/AllAccountsState/allAccountsDialogsState.d.ts +113 -1
- package/auth/MSP/AllAccountsState/allAccountsDialogsState.js +14 -0
- package/auth/MSP/AllAccountsState/index.d.ts +2 -0
- package/auth/MSP/AllAccountsState/index.js +3 -0
- package/auth/MSP/AllAccountsState/saga.js +76 -2
- package/auth/MSP/AllAccountsState/types/dialogsStateTypes.d.ts +7 -1
- package/auth/MSP/AllAccountsState/types/stateTypes.d.ts +4 -1
- package/auth/MSP/AllAccountsState/types/stateTypes.js +1 -0
- package/auth/MSP/AllAccountsState/utils/getAccountsWithUsersCount.d.ts +1 -0
- package/auth/MSP/AllAccountsState/utils/getAccountsWithUsersCount.js +2 -1
- package/auth/MSP/AllAccountsState/utils/updateNodeSubAccountAccessType.d.ts +3 -0
- package/auth/MSP/AllAccountsState/utils/updateNodeSubAccountAccessType.js +13 -0
- package/auth/SignUp/saga.js +5 -3
- package/auth/SocialLogins/saga.d.ts +1 -1
- package/auth/SocialLogins/saga.js +4 -2
- package/auth/StepUpState/generateStepUpSession.saga.js +3 -1
- package/auth/StepUpState/stepUpHostedLogin.saga.d.ts +1 -0
- package/auth/TenantsState/saga.js +3 -2
- package/auth/index.d.ts +3 -0
- package/auth/reducer.d.ts +3 -0
- package/index.js +1 -1
- package/node/auth/AccountSettingsState/saga.js +26 -0
- package/node/auth/ActivateState/saga.js +4 -2
- package/node/auth/CustomLoginState/saga.js +2 -1
- package/node/auth/Entitlements/utils.js +3 -2
- package/node/auth/LoginState/saga.js +56 -32
- package/node/auth/LoginState/sagas/afterAuthNavigation.saga.js +2 -1
- package/node/auth/LoginState/utils.js +6 -5
- package/node/auth/MSP/AllAccountsState/allAccountsDialogsState.js +14 -0
- package/node/auth/MSP/AllAccountsState/index.js +3 -0
- package/node/auth/MSP/AllAccountsState/saga.js +76 -2
- package/node/auth/MSP/AllAccountsState/types/stateTypes.js +1 -0
- package/node/auth/MSP/AllAccountsState/utils/getAccountsWithUsersCount.js +2 -1
- package/node/auth/MSP/AllAccountsState/utils/updateNodeSubAccountAccessType.js +21 -0
- package/node/auth/SignUp/saga.js +5 -3
- package/node/auth/SocialLogins/saga.js +3 -1
- package/node/auth/StepUpState/generateStepUpSession.saga.js +3 -1
- package/node/auth/TenantsState/saga.js +2 -1
- package/node/index.js +1 -1
- package/node/toolkit/index.js +2 -2
- package/package.json +2 -2
- package/toolkit/index.js +2 -2
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["activeTenant", "tenants"];
|
|
2
4
|
import { call, put, select, takeLeading } from 'redux-saga/effects';
|
|
3
5
|
import { actions } from '../reducer';
|
|
4
6
|
import { api } from '@frontegg/rest-api';
|
|
5
7
|
import { delay } from '../utils';
|
|
6
8
|
import { errorHandler } from '../../utils';
|
|
9
|
+
function* updateTenantState({
|
|
10
|
+
newSettingValues
|
|
11
|
+
}) {
|
|
12
|
+
const _yield$select = yield select(({
|
|
13
|
+
auth
|
|
14
|
+
}) => {
|
|
15
|
+
var _auth$tenantsState;
|
|
16
|
+
return (_auth$tenantsState = auth.tenantsState) != null ? _auth$tenantsState : {};
|
|
17
|
+
}),
|
|
18
|
+
{
|
|
19
|
+
activeTenant,
|
|
20
|
+
tenants
|
|
21
|
+
} = _yield$select,
|
|
22
|
+
rest = _objectWithoutPropertiesLoose(_yield$select, _excluded);
|
|
23
|
+
const updatedTenants = tenants.map(tenant => tenant.id !== (activeTenant == null ? void 0 : activeTenant.id) ? tenant : _extends({}, tenant, newSettingValues));
|
|
24
|
+
const updatedActiveTenant = _extends({}, activeTenant, newSettingValues);
|
|
25
|
+
yield put(actions.setTenantsState(_extends({}, rest, {
|
|
26
|
+
tenants: updatedTenants,
|
|
27
|
+
activeTenant: updatedActiveTenant
|
|
28
|
+
})));
|
|
29
|
+
}
|
|
7
30
|
function* saveAccountSettings({
|
|
8
31
|
payload
|
|
9
32
|
}) {
|
|
@@ -31,6 +54,9 @@ function* saveAccountSettings({
|
|
|
31
54
|
currency,
|
|
32
55
|
logo
|
|
33
56
|
}, payload));
|
|
57
|
+
yield updateTenantState({
|
|
58
|
+
newSettingValues: body
|
|
59
|
+
});
|
|
34
60
|
yield put(actions.setAccountSettingsState(_extends({}, body, {
|
|
35
61
|
loading: false
|
|
36
62
|
})));
|
|
@@ -66,7 +66,9 @@ function* activateAccount(_ref) {
|
|
|
66
66
|
loading: true
|
|
67
67
|
}));
|
|
68
68
|
try {
|
|
69
|
-
const
|
|
69
|
+
const appName = yield select(state => state.root.appName);
|
|
70
|
+
const contextHolder = ContextHolder.for(appName);
|
|
71
|
+
const onRedirectTo = contextHolder.onRedirectTo;
|
|
70
72
|
const {
|
|
71
73
|
routes
|
|
72
74
|
} = yield select(state => state.auth);
|
|
@@ -79,7 +81,7 @@ function* activateAccount(_ref) {
|
|
|
79
81
|
window.location.href = user.redirectLocation;
|
|
80
82
|
return;
|
|
81
83
|
}
|
|
82
|
-
if (isMfaRequired(user)) {
|
|
84
|
+
if (isMfaRequired(user, appName)) {
|
|
83
85
|
yield put(actions.setActivateState({
|
|
84
86
|
step: ActivateAccountStep.success
|
|
85
87
|
}));
|
|
@@ -4,7 +4,7 @@ import { AuthState } from '../interfaces';
|
|
|
4
4
|
export declare function loadTenantMetadata(): Generator<import("redux-saga/effects").PutEffect<{
|
|
5
5
|
payload: Partial<CustomLoginState>;
|
|
6
6
|
type: string;
|
|
7
|
-
}> | import("redux-saga/effects").CallEffect<
|
|
7
|
+
}> | import("redux-saga/effects").CallEffect<unknown>, void, any>;
|
|
8
8
|
export declare function customLoginEnabled(): Generator<import("redux-saga/effects").CallEffect<Generator<import("redux-saga/effects").SelectEffect | ResolvedTenantResult | Promise<ResolvedTenantResult>, string | undefined, ResolvedTenantResult & {
|
|
9
9
|
customLoginAlias?: string | undefined;
|
|
10
10
|
hasCustomLogin?: boolean | undefined;
|
|
@@ -64,7 +64,8 @@ export function* customLoginEnabled() {
|
|
|
64
64
|
return !!customLoginAlias;
|
|
65
65
|
}
|
|
66
66
|
export function* getCustomLoginAlias() {
|
|
67
|
-
const
|
|
67
|
+
const appName = yield select(state => state.root.appName);
|
|
68
|
+
const context = ContextHolder.for(appName).getContext();
|
|
68
69
|
if (!(context != null && context.tenantResolver)) {
|
|
69
70
|
return;
|
|
70
71
|
}
|
|
@@ -4,10 +4,11 @@ const ENTITLEMENTS_NOT_ENABLED_EXCEPTION_TEXT = 'You must first enable entitleme
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Guard entitlements feature by checking if it is enabled by the vendor
|
|
7
|
+
* @param appName - the app name to check entitlements for
|
|
7
8
|
* @throws when entitlement is not enabled via frontegg options
|
|
8
9
|
*/
|
|
9
|
-
const guardEntitlementsUsage = () => {
|
|
10
|
-
if (ContextHolder.shouldLoadEntitlements()) return;
|
|
10
|
+
const guardEntitlementsUsage = (appName = 'default') => {
|
|
11
|
+
if (ContextHolder.for(appName).shouldLoadEntitlements()) return;
|
|
11
12
|
throw new Error(ENTITLEMENTS_NOT_ENABLED_EXCEPTION_TEXT);
|
|
12
13
|
};
|
|
13
14
|
|
|
@@ -26,6 +26,7 @@ export declare function requestHostedLoginAuthorize(additionalParams?: Record<st
|
|
|
26
26
|
context: any;
|
|
27
27
|
onRedirectTo: any;
|
|
28
28
|
urlStrategy: any;
|
|
29
|
+
appName: any;
|
|
29
30
|
} & string>;
|
|
30
31
|
export declare function loginSagas(): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
|
|
31
32
|
export { afterAuthNavigation } from './sagas/afterAuthNavigation.saga';
|
package/auth/LoginState/saga.js
CHANGED
|
@@ -16,7 +16,7 @@ const _excluded = ["callback"],
|
|
|
16
16
|
_excluded14 = ["callback"],
|
|
17
17
|
_excluded15 = ["callback"];
|
|
18
18
|
import { all, call, put, select, takeLeading } from 'redux-saga/effects';
|
|
19
|
-
import { api, AuthStrategyEnum, ContextHolder,
|
|
19
|
+
import { api, AuthStrategyEnum, ContextHolder, WebAuthnDeviceType, FetchClient } from '@frontegg/rest-api';
|
|
20
20
|
import { actions } from '../reducer';
|
|
21
21
|
import { HOSTED_LOGIN_VERIFIER_KEY } from '../../constants';
|
|
22
22
|
import { UserVeirifedOriginTypes } from '../interfaces';
|
|
@@ -128,9 +128,11 @@ function* refreshTokenHosted() {
|
|
|
128
128
|
const {
|
|
129
129
|
user
|
|
130
130
|
} = yield select(state => state.auth);
|
|
131
|
+
const appName = yield select(state => state.root.appName);
|
|
132
|
+
const contextHolder = ContextHolder.for(appName);
|
|
131
133
|
if (!(user != null && user.refreshToken)) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
+
contextHolder.setAccessToken(null);
|
|
135
|
+
contextHolder.setUser(null);
|
|
134
136
|
yield put(actions.setState({
|
|
135
137
|
user: null,
|
|
136
138
|
isAuthenticated: false
|
|
@@ -150,8 +152,8 @@ function* refreshTokenHosted() {
|
|
|
150
152
|
isAuthenticated: true
|
|
151
153
|
});
|
|
152
154
|
} catch (e) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
+
contextHolder.setAccessToken(null);
|
|
156
|
+
contextHolder.setUser(null);
|
|
155
157
|
yield put(actions.setState({
|
|
156
158
|
user: null,
|
|
157
159
|
isAuthenticated: false
|
|
@@ -162,9 +164,11 @@ function* refreshTokenHostedSocialLogins() {
|
|
|
162
164
|
const {
|
|
163
165
|
user: currentUser
|
|
164
166
|
} = yield select(state => state.auth);
|
|
167
|
+
const appName = yield select(state => state.root.appName);
|
|
168
|
+
const contextHolder = ContextHolder.for(appName);
|
|
165
169
|
if (!(currentUser != null && currentUser.refreshToken)) {
|
|
166
|
-
|
|
167
|
-
|
|
170
|
+
contextHolder.setAccessToken(null);
|
|
171
|
+
contextHolder.setUser(null);
|
|
168
172
|
yield put(actions.setState({
|
|
169
173
|
user: null,
|
|
170
174
|
isAuthenticated: false
|
|
@@ -184,8 +188,8 @@ function* refreshTokenHostedSocialLogins() {
|
|
|
184
188
|
isAuthenticated: true
|
|
185
189
|
});
|
|
186
190
|
} catch (e) {
|
|
187
|
-
|
|
188
|
-
|
|
191
|
+
contextHolder.setAccessToken(null);
|
|
192
|
+
contextHolder.setUser(null);
|
|
189
193
|
yield put(actions.setState({
|
|
190
194
|
user: null,
|
|
191
195
|
isAuthenticated: false
|
|
@@ -193,8 +197,10 @@ function* refreshTokenHostedSocialLogins() {
|
|
|
193
197
|
}
|
|
194
198
|
}
|
|
195
199
|
function* refreshTokenEmbedded() {
|
|
200
|
+
const appName = yield select(state => state.root.appName);
|
|
201
|
+
const contextHolder = ContextHolder.for(appName);
|
|
196
202
|
try {
|
|
197
|
-
const onRedirectTo =
|
|
203
|
+
const onRedirectTo = contextHolder.onRedirectTo;
|
|
198
204
|
const {
|
|
199
205
|
routes,
|
|
200
206
|
loginState
|
|
@@ -204,7 +210,7 @@ function* refreshTokenEmbedded() {
|
|
|
204
210
|
tenants = [],
|
|
205
211
|
activeTenant
|
|
206
212
|
} = yield call(api.auth.refreshTokenV3);
|
|
207
|
-
if (isMfaRequired(user)) {
|
|
213
|
+
if (isMfaRequired(user, appName)) {
|
|
208
214
|
const mfaRequiredState = yield getMfaRequiredState(user);
|
|
209
215
|
yield put(actions.setState(mfaRequiredState));
|
|
210
216
|
onRedirectTo(routes.loginUrl, {
|
|
@@ -232,8 +238,8 @@ function* refreshTokenEmbedded() {
|
|
|
232
238
|
yield handleRedirectRefreshToken(shouldNavigateToRegisterQuickLogin);
|
|
233
239
|
}
|
|
234
240
|
} catch (e) {
|
|
235
|
-
|
|
236
|
-
|
|
241
|
+
contextHolder.setAccessToken(null);
|
|
242
|
+
contextHolder.setUser(null);
|
|
237
243
|
yield put(actions.setState({
|
|
238
244
|
user: undefined,
|
|
239
245
|
isAuthenticated: false
|
|
@@ -241,8 +247,10 @@ function* refreshTokenEmbedded() {
|
|
|
241
247
|
}
|
|
242
248
|
}
|
|
243
249
|
function* refreshTokenEmbeddedSocialLogins() {
|
|
250
|
+
const appName = yield select(state => state.root.appName);
|
|
251
|
+
const contextHolder = ContextHolder.for(appName);
|
|
244
252
|
try {
|
|
245
|
-
const onRedirectTo =
|
|
253
|
+
const onRedirectTo = contextHolder.onRedirectTo;
|
|
246
254
|
const {
|
|
247
255
|
routes,
|
|
248
256
|
loginState
|
|
@@ -252,7 +260,7 @@ function* refreshTokenEmbeddedSocialLogins() {
|
|
|
252
260
|
tenants = [],
|
|
253
261
|
activeTenant
|
|
254
262
|
} = yield call(api.auth.refreshTokenV3);
|
|
255
|
-
if (isMfaRequired(user)) {
|
|
263
|
+
if (isMfaRequired(user, appName)) {
|
|
256
264
|
const mfaRequiredState = yield getMfaRequiredState(user);
|
|
257
265
|
yield put(actions.setState(mfaRequiredState));
|
|
258
266
|
onRedirectTo(routes.loginUrl, {
|
|
@@ -298,8 +306,8 @@ function* refreshTokenEmbeddedSocialLogins() {
|
|
|
298
306
|
}
|
|
299
307
|
}
|
|
300
308
|
} catch (e) {
|
|
301
|
-
|
|
302
|
-
|
|
309
|
+
contextHolder.setAccessToken(null);
|
|
310
|
+
contextHolder.setUser(null);
|
|
303
311
|
yield put(actions.setState({
|
|
304
312
|
user: undefined,
|
|
305
313
|
isAuthenticated: false
|
|
@@ -308,8 +316,10 @@ function* refreshTokenEmbeddedSocialLogins() {
|
|
|
308
316
|
}
|
|
309
317
|
function* handleRedirectRefreshToken(shouldNavigateToRegisterQuickLogin) {
|
|
310
318
|
var _window;
|
|
319
|
+
const appName = yield select(state => state.root.appName);
|
|
320
|
+
const contextHolder = ContextHolder.for(appName);
|
|
311
321
|
const url = new URL((_window = window) == null ? void 0 : _window.location.href);
|
|
312
|
-
const onRedirectTo =
|
|
322
|
+
const onRedirectTo = contextHolder.onRedirectTo;
|
|
313
323
|
const {
|
|
314
324
|
routes,
|
|
315
325
|
loginState
|
|
@@ -390,11 +400,12 @@ function* isMFARequiredSSR({
|
|
|
390
400
|
}));
|
|
391
401
|
return;
|
|
392
402
|
}
|
|
393
|
-
const
|
|
403
|
+
const appName = yield select(state => state.root.appName);
|
|
404
|
+
const onRedirectTo = ContextHolder.for(appName).onRedirectTo;
|
|
394
405
|
const {
|
|
395
406
|
routes
|
|
396
407
|
} = yield select(state => state.auth);
|
|
397
|
-
if (isMfaRequired(user)) {
|
|
408
|
+
if (isMfaRequired(user, appName)) {
|
|
398
409
|
const mfaRequiredState = yield getMfaRequiredState(user);
|
|
399
410
|
yield put(actions.setState(mfaRequiredState));
|
|
400
411
|
onRedirectTo(routes.loginUrl, {
|
|
@@ -522,12 +533,14 @@ export function* requestHostedLoginAuthorize(additionalParams) {
|
|
|
522
533
|
routes,
|
|
523
534
|
context,
|
|
524
535
|
onRedirectTo,
|
|
525
|
-
urlStrategy
|
|
536
|
+
urlStrategy,
|
|
537
|
+
appName
|
|
526
538
|
} = yield select(state => ({
|
|
527
539
|
routes: state.auth.routes,
|
|
528
540
|
onRedirectTo: state.auth.onRedirectTo,
|
|
529
541
|
context: state.root.context,
|
|
530
|
-
urlStrategy: state.root.urlStrategy
|
|
542
|
+
urlStrategy: state.root.urlStrategy,
|
|
543
|
+
appName: state.root.appName
|
|
531
544
|
}));
|
|
532
545
|
const activeUri = getUri(urlStrategy);
|
|
533
546
|
if (activeUri === routes.hostedLoginRedirectUrl) {
|
|
@@ -556,7 +569,7 @@ export function* requestHostedLoginAuthorize(additionalParams) {
|
|
|
556
569
|
}
|
|
557
570
|
redirectUrl += customLoginSearchParam;
|
|
558
571
|
}
|
|
559
|
-
const baseUrl =
|
|
572
|
+
const baseUrl = new FetchClient(appName).getContextBaseUrl('/oauth/authorize');
|
|
560
573
|
// Hard coded for now
|
|
561
574
|
const oauthUrl = `${baseUrl}/oauth/authorize`;
|
|
562
575
|
const params = _extends({
|
|
@@ -770,16 +783,18 @@ function* passwordlessPostLogin(_ref8) {
|
|
|
770
783
|
yield put(actions.setLoginState({
|
|
771
784
|
loading: true
|
|
772
785
|
}));
|
|
786
|
+
const appName = yield select(state => state.root.appName);
|
|
787
|
+
const contextHolder = ContextHolder.for(appName);
|
|
773
788
|
const {
|
|
774
789
|
user,
|
|
775
790
|
tenants = [],
|
|
776
791
|
activeTenant
|
|
777
792
|
} = yield call(api.auth.passwordlessPostLoginV2, payload);
|
|
778
|
-
const onRedirectTo =
|
|
793
|
+
const onRedirectTo = contextHolder.onRedirectTo;
|
|
779
794
|
const {
|
|
780
795
|
routes
|
|
781
796
|
} = yield select(state => state.auth);
|
|
782
|
-
if (isMfaRequired(user)) {
|
|
797
|
+
if (isMfaRequired(user, appName)) {
|
|
783
798
|
const mfaRequiredState = yield getMfaRequiredState(user);
|
|
784
799
|
yield put(actions.setState(mfaRequiredState));
|
|
785
800
|
onRedirectTo(routes.loginUrl, {
|
|
@@ -1096,6 +1111,8 @@ function* webAuthnPostLogin(_ref12) {
|
|
|
1096
1111
|
body = _objectWithoutPropertiesLoose(_ref12.payload, _excluded9);
|
|
1097
1112
|
try {
|
|
1098
1113
|
var _publicKey$response$u;
|
|
1114
|
+
const appName = yield select(state => state.root.appName);
|
|
1115
|
+
const contextHolder = ContextHolder.for(appName);
|
|
1099
1116
|
yield put(actions.setPasskeysState({
|
|
1100
1117
|
loading: true
|
|
1101
1118
|
}));
|
|
@@ -1114,8 +1131,8 @@ function* webAuthnPostLogin(_ref12) {
|
|
|
1114
1131
|
user
|
|
1115
1132
|
} = _yield$call,
|
|
1116
1133
|
rest = _objectWithoutPropertiesLoose(_yield$call, _excluded10);
|
|
1117
|
-
if (isMfaRequired(user)) {
|
|
1118
|
-
const onRedirectTo =
|
|
1134
|
+
if (isMfaRequired(user, appName)) {
|
|
1135
|
+
const onRedirectTo = contextHolder.onRedirectTo;
|
|
1119
1136
|
const {
|
|
1120
1137
|
routes
|
|
1121
1138
|
} = yield select(state => state.auth);
|
|
@@ -1202,6 +1219,8 @@ function* login({
|
|
|
1202
1219
|
yield put(actions.setLoginState({
|
|
1203
1220
|
loading: true
|
|
1204
1221
|
}));
|
|
1222
|
+
const appName = yield select(state => state.root.appName);
|
|
1223
|
+
const contextHolder = ContextHolder.for(appName);
|
|
1205
1224
|
try {
|
|
1206
1225
|
const {
|
|
1207
1226
|
user,
|
|
@@ -1213,11 +1232,12 @@ function* login({
|
|
|
1213
1232
|
recaptchaToken,
|
|
1214
1233
|
invitationToken
|
|
1215
1234
|
});
|
|
1216
|
-
const onRedirectTo =
|
|
1235
|
+
const onRedirectTo = contextHolder.onRedirectTo;
|
|
1217
1236
|
const {
|
|
1218
1237
|
routes
|
|
1219
1238
|
} = yield select(state => state.auth);
|
|
1220
|
-
|
|
1239
|
+
const appName = yield select(state => state.root.appName);
|
|
1240
|
+
if (isMfaRequired(user, appName)) {
|
|
1221
1241
|
const mfaRequiredState = yield getMfaRequiredState(user);
|
|
1222
1242
|
yield put(actions.setState(mfaRequiredState));
|
|
1223
1243
|
onRedirectTo(routes.loginUrl, {
|
|
@@ -1280,8 +1300,8 @@ function* login({
|
|
|
1280
1300
|
localStorage.removeItem('register-quick-login');
|
|
1281
1301
|
callback == null ? void 0 : callback(true);
|
|
1282
1302
|
} catch (e) {
|
|
1283
|
-
|
|
1284
|
-
|
|
1303
|
+
contextHolder.setAccessToken(null);
|
|
1304
|
+
contextHolder.setUser(null);
|
|
1285
1305
|
callback == null ? void 0 : callback(false, e);
|
|
1286
1306
|
yield put(actions.setLoginState({
|
|
1287
1307
|
email,
|
|
@@ -1324,6 +1344,8 @@ function* logout({
|
|
|
1324
1344
|
const {
|
|
1325
1345
|
hostedLoginBox
|
|
1326
1346
|
} = yield select(state => state.auth);
|
|
1347
|
+
const appName = yield select(state => state.root.appName);
|
|
1348
|
+
const contextHolder = ContextHolder.for(appName);
|
|
1327
1349
|
yield put(actions.setState({
|
|
1328
1350
|
isLoading: true
|
|
1329
1351
|
}));
|
|
@@ -1334,7 +1356,7 @@ function* logout({
|
|
|
1334
1356
|
yield call(api.auth.logout);
|
|
1335
1357
|
}
|
|
1336
1358
|
} catch {}
|
|
1337
|
-
if (
|
|
1359
|
+
if (contextHolder.isSessionPerTenantEnabled()) {
|
|
1338
1360
|
removeTabTenantFromSessionStorage();
|
|
1339
1361
|
}
|
|
1340
1362
|
yield put(actions.resetState());
|
|
@@ -1345,10 +1367,12 @@ function* silentLogout({
|
|
|
1345
1367
|
payload
|
|
1346
1368
|
}) {
|
|
1347
1369
|
var _payload$callbackTime;
|
|
1370
|
+
const appName = yield select(state => state.root.appName);
|
|
1371
|
+
const contextHolder = ContextHolder.for(appName);
|
|
1348
1372
|
try {
|
|
1349
1373
|
yield call(api.auth.logout);
|
|
1350
1374
|
} catch {}
|
|
1351
|
-
if (
|
|
1375
|
+
if (contextHolder.isSessionPerTenantEnabled()) {
|
|
1352
1376
|
removeTabTenantFromSessionStorage();
|
|
1353
1377
|
}
|
|
1354
1378
|
setTimeout(() => {
|
|
@@ -12,7 +12,7 @@ interface AfterAuthNavigationUtilOptions {
|
|
|
12
12
|
* @param customLoginAuthenticatedUrl custom login authenticated url if exists
|
|
13
13
|
* @param shouldStepUpDuringLogin true when it's login after step up flow
|
|
14
14
|
*/
|
|
15
|
-
export declare function afterAuthNavigationUtil(resetStateAction: () => Action, { customLoginAuthenticatedUrl, forceStepUpUrl, shouldStepUpDuringLogin, preventRedirectUrlOriginCleaning, }?: 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, preventRedirectUrlOriginCleaning, }?: AfterAuthNavigationUtilOptions): Generator<import("redux-saga/effects").SelectEffect | import("redux-saga/effects").CallEffect<true> | import("redux-saga/effects").CallEffect<string>, void, string | undefined>;
|
|
16
16
|
/**
|
|
17
17
|
* After auth navigation for login flow
|
|
18
18
|
* Handling also step up scenario when user silently logout to continue to step up
|
|
@@ -74,7 +74,8 @@ export function* afterAuthNavigationUtil(resetStateAction, {
|
|
|
74
74
|
shouldStepUpDuringLogin,
|
|
75
75
|
preventRedirectUrlOriginCleaning = false
|
|
76
76
|
} = {}) {
|
|
77
|
-
const
|
|
77
|
+
const appName = yield select(state => state.root.appName);
|
|
78
|
+
const onRedirectTo = ContextHolder.for(appName).onRedirectTo;
|
|
78
79
|
let redirectUrl = undefined;
|
|
79
80
|
if (forceStepUpUrl) {
|
|
80
81
|
// scenario to get to here: invalid max age, try to step up -> logout, login with magic code/link -> redirect to step up page for email code as the second factor
|
|
@@ -16,7 +16,7 @@ export declare const getPathAndSearchParamsFromUrl: (url: string) => string;
|
|
|
16
16
|
*/
|
|
17
17
|
export declare const getSearchParam: (key: string) => string | undefined;
|
|
18
18
|
export declare const TENANT_ID_PARAM_KEY = "tenantId";
|
|
19
|
-
export declare const isMfaRequired: (user: ILoginResponse) => boolean;
|
|
19
|
+
export declare const isMfaRequired: (user: ILoginResponse, appName: string) => boolean;
|
|
20
20
|
export declare const getNumberOfMfaDevices: (mfaDevices: UserMFADevicesResponse) => {
|
|
21
21
|
numberOfWebAuthnDevices: number;
|
|
22
22
|
numberOfPhoneDevices: number;
|
package/auth/LoginState/utils.js
CHANGED
|
@@ -70,14 +70,15 @@ export const getSearchParam = key => {
|
|
|
70
70
|
return param != null ? param : undefined;
|
|
71
71
|
};
|
|
72
72
|
export const TENANT_ID_PARAM_KEY = 'tenantId';
|
|
73
|
-
export const isMfaRequired = user => {
|
|
73
|
+
export const isMfaRequired = (user, appName) => {
|
|
74
|
+
const contextHolder = ContextHolder.for(appName);
|
|
74
75
|
if (user.mfaRequired && user.mfaToken) {
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
contextHolder.setAccessToken(null);
|
|
77
|
+
contextHolder.setUser(null);
|
|
77
78
|
return true;
|
|
78
79
|
} else {
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
contextHolder.setAccessToken(user.accessToken);
|
|
81
|
+
contextHolder.setUser(user);
|
|
81
82
|
return false;
|
|
82
83
|
}
|
|
83
84
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IAllAccountsDialogsState } from './types';
|
|
2
|
-
import { TAddUsersToSubAccountDialogState, TCreateSubAccountDialogState, TDeleteSubAccountDialogState, TDeleteUserFromSubAccountDialogState, TEditUserRolesDialogState, TUpdateAccountDialogState, TUpdateSubAccountManagementState } from './types/dialogsStateTypes';
|
|
2
|
+
import { TAddUsersToSubAccountDialogState, TCreateSubAccountDialogState, TDeleteSubAccountDialogState, TDeleteUserFromSubAccountDialogState, TEditUserRolesDialogState, TUpdateAccountDialogState, TUpdateSubAccountHierarchySettingsDialogState, TUpdateSubAccountManagementState } from './types/dialogsStateTypes';
|
|
3
3
|
declare const allAccountsDialogsState: IAllAccountsDialogsState;
|
|
4
4
|
declare const reducers: {
|
|
5
5
|
setAllAccountDialogsState: {
|
|
@@ -686,6 +686,116 @@ declare const reducers: {
|
|
|
686
686
|
header?: any;
|
|
687
687
|
loaderComponent?: any;
|
|
688
688
|
};
|
|
689
|
+
openUpdateSubAccountHierarchySettingsDialog: {
|
|
690
|
+
prepare: (payload: Partial<TUpdateSubAccountHierarchySettingsDialogState>) => {
|
|
691
|
+
payload: Partial<TUpdateSubAccountHierarchySettingsDialogState>;
|
|
692
|
+
};
|
|
693
|
+
reducer: (state: import("../..").AuthState, { payload }: {
|
|
694
|
+
payload: Partial<TUpdateSubAccountHierarchySettingsDialogState>;
|
|
695
|
+
type: string;
|
|
696
|
+
}) => {
|
|
697
|
+
onRedirectTo: (path: string, opts?: import("@frontegg/rest-api").RedirectOptions | undefined) => void;
|
|
698
|
+
error?: any;
|
|
699
|
+
isAuthenticated: boolean;
|
|
700
|
+
userIp?: string | undefined;
|
|
701
|
+
isLoading: boolean;
|
|
702
|
+
keepSessionAlive?: boolean | undefined;
|
|
703
|
+
socialLoginOptions?: {
|
|
704
|
+
promptConsent?: boolean | undefined;
|
|
705
|
+
} | undefined;
|
|
706
|
+
user?: import("../..").User | null | undefined;
|
|
707
|
+
isSSOAuth: boolean;
|
|
708
|
+
ssoACS?: string | undefined;
|
|
709
|
+
includeQueryParam?: boolean | undefined;
|
|
710
|
+
loginState: import("../..").LoginState;
|
|
711
|
+
activateState: import("../..").ActivateAccountState;
|
|
712
|
+
acceptInvitationState: import("../..").AcceptInvitationState;
|
|
713
|
+
forgotPasswordState: import("../..").ForgotPasswordState;
|
|
714
|
+
resetPhoneNumberState: import("../..").ResetPhoneNumberState;
|
|
715
|
+
ssoState: import("../..").SSOState;
|
|
716
|
+
profileState: import("../..").ProfileState;
|
|
717
|
+
mfaState: import("../..").MFAState;
|
|
718
|
+
teamState: import("../..").TeamState;
|
|
719
|
+
groupsState: import("../..").GroupsState;
|
|
720
|
+
groupsDialogsState: import("../..").GroupsDialogsState;
|
|
721
|
+
socialLoginState: import("../..").SocialLoginState;
|
|
722
|
+
signUpState: import("../..").SignUpState;
|
|
723
|
+
apiTokensState: import("../..").ApiTokensState;
|
|
724
|
+
securityPolicyState: import("../..").SecurityPolicyState;
|
|
725
|
+
restrictionsState: import("../..").RestrictionsState;
|
|
726
|
+
provisioningState: import("../..").ProvisioningState;
|
|
727
|
+
accountSettingsState: import("../..").AccountSettingsState;
|
|
728
|
+
tenantsState: import("../..").TenantsState;
|
|
729
|
+
rolesState: import("../..").RolesState;
|
|
730
|
+
sessionsState: import("../..").SessionsState;
|
|
731
|
+
hostedLoginBox?: boolean | undefined;
|
|
732
|
+
disableSilentRefresh?: boolean | undefined;
|
|
733
|
+
sessionsPolicyState: import("../..").SessionsPolicyState;
|
|
734
|
+
impersonateState?: import("../..").ImpersonateState | undefined;
|
|
735
|
+
passkeysState?: import("../..").PasskeysState | undefined;
|
|
736
|
+
customLoginState?: import("../..").CustomLoginState | undefined;
|
|
737
|
+
allAccountsState?: import("./types").IAllAccountsState | undefined;
|
|
738
|
+
allAccountsDialogsState?: IAllAccountsDialogsState | undefined;
|
|
739
|
+
securityCenterState?: import("../..").SecurityCenterState | undefined;
|
|
740
|
+
smsState?: import("../..").SmsState | undefined;
|
|
741
|
+
stepUpState?: import("../..").StepUpState | undefined;
|
|
742
|
+
applicationsState?: import("../..").ApplicationsState | undefined;
|
|
743
|
+
routes: import("../..").AuthPageRoutes;
|
|
744
|
+
header?: any;
|
|
745
|
+
loaderComponent?: any;
|
|
746
|
+
};
|
|
747
|
+
};
|
|
748
|
+
closeUpdateSubAccountHierarchySettingsDialog: (state: import("../..").AuthState) => {
|
|
749
|
+
onRedirectTo: (path: string, opts?: import("@frontegg/rest-api").RedirectOptions | undefined) => void;
|
|
750
|
+
error?: any;
|
|
751
|
+
isAuthenticated: boolean;
|
|
752
|
+
userIp?: string | undefined;
|
|
753
|
+
isLoading: boolean;
|
|
754
|
+
keepSessionAlive?: boolean | undefined;
|
|
755
|
+
socialLoginOptions?: {
|
|
756
|
+
promptConsent?: boolean | undefined;
|
|
757
|
+
} | undefined;
|
|
758
|
+
user?: import("../..").User | null | undefined;
|
|
759
|
+
isSSOAuth: boolean;
|
|
760
|
+
ssoACS?: string | undefined;
|
|
761
|
+
includeQueryParam?: boolean | undefined;
|
|
762
|
+
loginState: import("../..").LoginState;
|
|
763
|
+
activateState: import("../..").ActivateAccountState;
|
|
764
|
+
acceptInvitationState: import("../..").AcceptInvitationState;
|
|
765
|
+
forgotPasswordState: import("../..").ForgotPasswordState;
|
|
766
|
+
resetPhoneNumberState: import("../..").ResetPhoneNumberState;
|
|
767
|
+
ssoState: import("../..").SSOState;
|
|
768
|
+
profileState: import("../..").ProfileState;
|
|
769
|
+
mfaState: import("../..").MFAState;
|
|
770
|
+
teamState: import("../..").TeamState;
|
|
771
|
+
groupsState: import("../..").GroupsState;
|
|
772
|
+
groupsDialogsState: import("../..").GroupsDialogsState;
|
|
773
|
+
socialLoginState: import("../..").SocialLoginState;
|
|
774
|
+
signUpState: import("../..").SignUpState;
|
|
775
|
+
apiTokensState: import("../..").ApiTokensState;
|
|
776
|
+
securityPolicyState: import("../..").SecurityPolicyState;
|
|
777
|
+
restrictionsState: import("../..").RestrictionsState;
|
|
778
|
+
provisioningState: import("../..").ProvisioningState;
|
|
779
|
+
accountSettingsState: import("../..").AccountSettingsState;
|
|
780
|
+
tenantsState: import("../..").TenantsState;
|
|
781
|
+
rolesState: import("../..").RolesState;
|
|
782
|
+
sessionsState: import("../..").SessionsState;
|
|
783
|
+
hostedLoginBox?: boolean | undefined;
|
|
784
|
+
disableSilentRefresh?: boolean | undefined;
|
|
785
|
+
sessionsPolicyState: import("../..").SessionsPolicyState;
|
|
786
|
+
impersonateState?: import("../..").ImpersonateState | undefined;
|
|
787
|
+
passkeysState?: import("../..").PasskeysState | undefined;
|
|
788
|
+
customLoginState?: import("../..").CustomLoginState | undefined;
|
|
789
|
+
allAccountsState?: import("./types").IAllAccountsState | undefined;
|
|
790
|
+
allAccountsDialogsState?: IAllAccountsDialogsState | undefined;
|
|
791
|
+
securityCenterState?: import("../..").SecurityCenterState | undefined;
|
|
792
|
+
smsState?: import("../..").SmsState | undefined;
|
|
793
|
+
stepUpState?: import("../..").StepUpState | undefined;
|
|
794
|
+
applicationsState?: import("../..").ApplicationsState | undefined;
|
|
795
|
+
routes: import("../..").AuthPageRoutes;
|
|
796
|
+
header?: any;
|
|
797
|
+
loaderComponent?: any;
|
|
798
|
+
};
|
|
689
799
|
openAddUsersToAccountDialog: {
|
|
690
800
|
prepare: (payload: Partial<import("../../..").WithCallback<import("./types").TUserJwtPayload & import("./types").BaseAllAccountsDialogState & {
|
|
691
801
|
accountName: string;
|
|
@@ -1054,6 +1164,8 @@ declare type DispatchedActions = {
|
|
|
1054
1164
|
closeCreateSubAccountDialog: () => void;
|
|
1055
1165
|
openUpdateSubAccountDialog: (payload: Partial<TUpdateAccountDialogState>) => void;
|
|
1056
1166
|
closeUpdateSubAccountDialog: () => void;
|
|
1167
|
+
openUpdateSubAccountHierarchySettingsDialog: (payload: Partial<TUpdateSubAccountHierarchySettingsDialogState>) => void;
|
|
1168
|
+
closeUpdateSubAccountHierarchySettingsDialog: () => void;
|
|
1057
1169
|
openEnableSubAccountManagementDialog: (payload: Partial<TUpdateSubAccountManagementState>) => void;
|
|
1058
1170
|
closeEnableSubAccountManagementDialog: () => void;
|
|
1059
1171
|
openDisableSubAccountManagementDialog: (payload: Partial<TUpdateSubAccountManagementState>) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { dialogStateForKey, dialogStateForKeyWithoutPayload, resetStateByKey, typeReducerForKey } from '../../utils';
|
|
2
|
+
import { SubAccountAccessTypeEnum } from '@frontegg/rest-api';
|
|
2
3
|
const allAccountsDialogsState = {
|
|
3
4
|
createSubAccountDialog: {
|
|
4
5
|
loading: false,
|
|
@@ -29,6 +30,14 @@ const allAccountsDialogsState = {
|
|
|
29
30
|
open: false,
|
|
30
31
|
error: false
|
|
31
32
|
},
|
|
33
|
+
updateSubAccountHierarchySettingsDialog: {
|
|
34
|
+
accountId: '',
|
|
35
|
+
accountName: '',
|
|
36
|
+
subAccountAccessType: SubAccountAccessTypeEnum.DEFAULT_OFF,
|
|
37
|
+
loading: false,
|
|
38
|
+
open: false,
|
|
39
|
+
error: false
|
|
40
|
+
},
|
|
32
41
|
deleteSubAccountDialog: {
|
|
33
42
|
accountId: '',
|
|
34
43
|
accountName: '',
|
|
@@ -94,6 +103,11 @@ const reducers = {
|
|
|
94
103
|
open: true
|
|
95
104
|
}),
|
|
96
105
|
closeEnableSubAccountManagementDialog: dialogStateForKeyWithoutPayload('allAccountsDialogsState', 'enableSubAccountManagementDialog', allAccountsDialogsState.enableSubAccountManagementDialog),
|
|
106
|
+
// Update sub account hierarchy settings dialog
|
|
107
|
+
openUpdateSubAccountHierarchySettingsDialog: dialogStateForKey('allAccountsDialogsState', 'updateSubAccountHierarchySettingsDialog', {
|
|
108
|
+
open: true
|
|
109
|
+
}),
|
|
110
|
+
closeUpdateSubAccountHierarchySettingsDialog: dialogStateForKeyWithoutPayload('allAccountsDialogsState', 'updateSubAccountHierarchySettingsDialog', allAccountsDialogsState.updateSubAccountHierarchySettingsDialog),
|
|
97
111
|
// Add users to account dialog
|
|
98
112
|
openAddUsersToAccountDialog: dialogStateForKey('allAccountsDialogsState', 'addUsersToAccountDialog', {
|
|
99
113
|
open: true
|
|
@@ -216,6 +216,7 @@ declare const actions: {
|
|
|
216
216
|
}, boolean>, string, never, never>;
|
|
217
217
|
deleteSubAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../../../interfaces").WithCallback<import("@frontegg/rest-api").RemoveUserFromSubTenantsRequestTenantDto & import("./types").TUserJwtPayload, boolean>], import("../../../interfaces").WithCallback<import("@frontegg/rest-api").RemoveUserFromSubTenantsRequestTenantDto & import("./types").TUserJwtPayload, boolean>, string, never, never>;
|
|
218
218
|
updateSubAccountSettings: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../../../interfaces").WithCallback<import("@frontegg/rest-api").UpdateSubTenantRequestParams & import("@frontegg/rest-api").UpdateSubTenantRequest & import("./types").TUserJwtPayload, boolean>], import("../../../interfaces").WithCallback<import("@frontegg/rest-api").UpdateSubTenantRequestParams & import("@frontegg/rest-api").UpdateSubTenantRequest & import("./types").TUserJwtPayload, boolean>, string, never, never>;
|
|
219
|
+
updateSubAccountHierarchySettings: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../../../interfaces").WithCallback<import("@frontegg/rest-api").UpdateSubTenantRequestParams & import("@frontegg/rest-api").UpdateSubTenantHierarchySettingsRequest & import("./types").TUserJwtPayload, boolean>], import("../../../interfaces").WithCallback<import("@frontegg/rest-api").UpdateSubTenantRequestParams & import("@frontegg/rest-api").UpdateSubTenantHierarchySettingsRequest & import("./types").TUserJwtPayload, boolean>, string, never, never>;
|
|
219
220
|
addUsersToAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../../../interfaces").WithCallback<import("@frontegg/rest-api").AddUsersToSubTenantRequest & import("./types").TUserJwtPayload, boolean>], import("../../../interfaces").WithCallback<import("@frontegg/rest-api").AddUsersToSubTenantRequest & import("./types").TUserJwtPayload, boolean>, string, never, never>;
|
|
220
221
|
getAccountUsers: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../../../interfaces").WithCallback<import("@frontegg/rest-api").ISearchUserQueryParamsV3 & import("./types").TUserJwtPayload, boolean>], import("../../../interfaces").WithCallback<import("@frontegg/rest-api").ISearchUserQueryParamsV3 & import("./types").TUserJwtPayload, boolean>, string, never, never>;
|
|
221
222
|
deleteUsersFromAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../../../interfaces").WithCallback<import("@frontegg/rest-api").RemoveUserFromSubTenantsRequest & import("./types").TUserJwtPayload, boolean>], import("../../../interfaces").WithCallback<import("@frontegg/rest-api").RemoveUserFromSubTenantsRequest & import("./types").TUserJwtPayload, boolean>, string, never, never>;
|
|
@@ -243,6 +244,7 @@ declare type DispatchedActions = {
|
|
|
243
244
|
deleteSubAccount: (payload: IAllAccountsStateActionsPayloads['deleteSubAccount']) => void;
|
|
244
245
|
updateSubAccountSettings: (payload: IAllAccountsStateActionsPayloads['updateSubAccountSettings']) => void;
|
|
245
246
|
updateSubAccountManagement: (payload: IAllAccountsStateActionsPayloads['updateSubAccountManagement']) => void;
|
|
247
|
+
updateSubAccountHierarchySettings: (payload: IAllAccountsStateActionsPayloads['updateSubAccountHierarchySettings']) => void;
|
|
246
248
|
addUsersToAccount: (payload: IAllAccountsStateActionsPayloads['addUsersToAccount']) => void;
|
|
247
249
|
getAccountUsers: (payload: IAllAccountsStateActionsPayloads['getAccountUsers']) => void;
|
|
248
250
|
deleteUsersFromAccount: (payload: IAllAccountsStateActionsPayloads['deleteUsersFromAccount']) => void;
|
|
@@ -72,6 +72,9 @@ const actions = {
|
|
|
72
72
|
updateSubAccountSettings: createAction(`${authStoreName}/updateSubAccountSettings`, payload => ({
|
|
73
73
|
payload
|
|
74
74
|
})),
|
|
75
|
+
updateSubAccountHierarchySettings: createAction(`${authStoreName}/updateSubAccountHierarchySettings`, payload => ({
|
|
76
|
+
payload
|
|
77
|
+
})),
|
|
75
78
|
addUsersToAccount: createAction(`${authStoreName}/addUsersToAccount`, payload => ({
|
|
76
79
|
payload
|
|
77
80
|
})),
|