@frontegg/redux-store 7.105.0-alpha.0 → 7.105.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.
@@ -26,7 +26,7 @@ import { LoginFlow, LoginStep } from '../interfaces';
26
26
  import { base64urlDecode, deepResetState, delay, errorHandler, errorTraceId, GTMEventAction, publicKeyCredentialToJSON, reportGTMEvent, retryIfNeeded, withRetryConfig } from '../../../helpers';
27
27
  import { initialState } from '../state';
28
28
  import { getSearchParam, isEmailPayload, isUsernamePayload, shouldShowPasswordRotationPromptFunc, TENANT_ID_PARAM_KEY } from '../helpers';
29
- import { AuthStrategyEnum, ContextHolder, FeatureFlags, getTabTenantFromSessionStorage, removeTabTenantFromSessionStorage, WebAuthnDeviceType } from '@frontegg/rest-api';
29
+ import { AuthStrategyEnum, ContextHolder, FeatureFlags, removeTabTenantFromSessionStorage, WebAuthnDeviceType } from '@frontegg/rest-api';
30
30
  import hostedLoginAuthorizeActions from './hostedLoginAuthorize.actions';
31
31
  import { FronteggNativeModule, isEntitlementsDeeplyEqual } from '../../../toolkit';
32
32
  import { REQUEST_NAME, UserVerifiedOriginTypes } from '../../interfaces';
@@ -51,13 +51,10 @@ export default ((store, api, sharedActions) => {
51
51
  return;
52
52
  }
53
53
  try {
54
- const tabTenantId = getTabTenantFromSessionStorage(store.root.appName);
55
- const body = _extends({
54
+ const body = {
56
55
  grant_type: 'refresh_token',
57
56
  refresh_token: user == null ? void 0 : user.refreshToken
58
- }, tabTenantId && {
59
- tenantId: tabTenantId
60
- });
57
+ };
61
58
  const response = await api.auth.exchangeOAuthTokensV2(body);
62
59
  const updatedUser = await __handleUnnecessaryEntitlementsUpdate(response.user);
63
60
  actions.afterAuthenticationStateUpdate(_extends({}, response, {
@@ -1315,13 +1312,10 @@ export default ((store, api, sharedActions) => {
1315
1312
  return;
1316
1313
  }
1317
1314
  try {
1318
- const tabTenantId = getTabTenantFromSessionStorage(store.root.appName);
1319
- const body = _extends({
1315
+ const body = {
1320
1316
  grant_type: 'refresh_token',
1321
1317
  refresh_token: currentUser == null ? void 0 : currentUser.refreshToken
1322
- }, tabTenantId && {
1323
- tenantId: tabTenantId
1324
- });
1318
+ };
1325
1319
  const response = await api.auth.exchangeOAuthTokensV2(body);
1326
1320
  const updatedUser = await __handleUnnecessaryEntitlementsUpdate(response.user);
1327
1321
  actions.afterAuthenticationStateUpdate(_extends({}, response, {
@@ -1,10 +1,11 @@
1
1
  import { FronteggState, RestApi, SharedActions, WithCallback } from '../../../interfaces';
2
- import { EmailDomainRestrictionsState, IPRestrictionsState, RestrictionsState, SaveEmailDomainRestrictionConfigPayload, SaveEmailDomainRestrictionsPayload } from './interfaces';
2
+ import { EmailDomainRestrictionsState, CountryRestrictionsState, IPRestrictionsState, RestrictionsState, SaveCountryRestrictionConfigPayload, SaveCountryRestrictionsPayload, SaveEmailDomainRestrictionConfigPayload, SaveEmailDomainRestrictionsPayload } from './interfaces';
3
3
  import { CreateIpRestriction, IPRestrictionsConfig } from '@frontegg/rest-api';
4
4
  declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {
5
5
  setRestrictionsState: (state: Partial<RestrictionsState>) => void;
6
6
  setIpRestrictionsState: (state: Partial<IPRestrictionsState>) => void;
7
7
  setEmailDomainRestrictionsState: (state: Partial<EmailDomainRestrictionsState>) => void;
8
+ setCountryRestrictionsState: (state: Partial<CountryRestrictionsState>) => void;
8
9
  __securityCenterSagaWrapper: <T>(action: T) => T;
9
10
  loadIpRestrictions: () => Promise<void>;
10
11
  saveIpRestriction: (payload: WithCallback<CreateIpRestriction>) => Promise<void>;
@@ -20,5 +21,8 @@ declare const _default: (store: FronteggState, api: RestApi, sharedActions: Shar
20
21
  deleteEmailDomainRestriction: (payload: {
21
22
  id: string;
22
23
  }) => Promise<void>;
24
+ loadCountryRestrictions: () => Promise<void>;
25
+ saveCountryRestrictionsConfig: (payload: SaveCountryRestrictionConfigPayload) => Promise<void>;
26
+ saveCountryRestrictions: (payload: SaveCountryRestrictionsPayload) => Promise<void>;
23
27
  };
24
28
  export default _default;
@@ -3,7 +3,8 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["callback"],
4
4
  _excluded2 = ["callback"],
5
5
  _excluded3 = ["callback"],
6
- _excluded4 = ["callback"];
6
+ _excluded4 = ["callback"],
7
+ _excluded5 = ["callback"];
7
8
  import { errorHandler, withRetryConfig } from '../../../helpers';
8
9
  import { RestrictionType } from '@frontegg/rest-api';
9
10
  export default ((store, api, sharedActions) => {
@@ -33,12 +34,9 @@ export default ((store, api, sharedActions) => {
33
34
  */
34
35
  const __securityCenterSagaWrapper = action => {
35
36
  return async (...args) => {
36
- const [securityCenterFeatureFlag] = await actions.getFeatureFlags(['security-center-admin-portal-major-version']);
37
37
  await action(...args);
38
- if (securityCenterFeatureFlag) {
39
- await actions.loadRecommendations(withRetryConfig());
40
- await actions.loadInsights(withRetryConfig());
41
- }
38
+ await actions.loadRecommendations(withRetryConfig());
39
+ await actions.loadInsights(withRetryConfig());
42
40
  };
43
41
  };
44
42
  const setRestrictionsState = state => {
@@ -50,6 +48,9 @@ export default ((store, api, sharedActions) => {
50
48
  const setEmailDomainRestrictionsState = state => {
51
49
  Object.assign(store.auth.restrictionsState.emailDomainRestrictions, state);
52
50
  };
51
+ const setCountryRestrictionsState = state => {
52
+ Object.assign(store.auth.restrictionsState.countryRestrictions, state);
53
+ };
53
54
  const loadIpRestrictions = async () => {
54
55
  setIpRestrictionsState({
55
56
  loading: true,
@@ -413,6 +414,97 @@ export default ((store, api, sharedActions) => {
413
414
  });
414
415
  }
415
416
  };
417
+ const loadCountryRestrictions = async () => {
418
+ setCountryRestrictionsState({
419
+ loading: true,
420
+ error: null
421
+ });
422
+ try {
423
+ const [config, restrictions] = await Promise.all([api.auth.getCountryRestrictionsConfig(), api.auth.getCountryRestrictions()]);
424
+ setCountryRestrictionsState({
425
+ data: {
426
+ config,
427
+ restrictions
428
+ },
429
+ loading: false
430
+ });
431
+ } catch (e) {
432
+ setCountryRestrictionsState({
433
+ error: errorHandler(e),
434
+ loading: false
435
+ });
436
+ }
437
+ };
438
+ const saveCountryRestrictionsConfig = async payload => {
439
+ var _countryRestrictionsS, _countryRestrictionsS2;
440
+ const {
441
+ callback
442
+ } = payload,
443
+ configOverrides = _objectWithoutPropertiesLoose(payload, _excluded5);
444
+ const countryRestrictionsState = store.auth.restrictionsState.countryRestrictions;
445
+ const currentConfig = (_countryRestrictionsS = (_countryRestrictionsS2 = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS2.config) != null ? _countryRestrictionsS : {
446
+ enabled: false,
447
+ action: RestrictionType.ALLOW,
448
+ failStrategy: RestrictionType.ALLOW,
449
+ shouldSendRestrictionEmail: false
450
+ };
451
+ const nextConfig = _extends({}, currentConfig, configOverrides);
452
+ setCountryRestrictionsState({
453
+ saving: true,
454
+ error: null
455
+ });
456
+ try {
457
+ await api.auth.updateCountryRestrictionsConfig(nextConfig);
458
+ const [config, restrictions] = await Promise.all([api.auth.getCountryRestrictionsConfig(), api.auth.getCountryRestrictions()]);
459
+ setCountryRestrictionsState({
460
+ data: {
461
+ config,
462
+ restrictions
463
+ },
464
+ saving: false
465
+ });
466
+ callback == null ? void 0 : callback(true);
467
+ } catch (e) {
468
+ setCountryRestrictionsState({
469
+ saving: false,
470
+ error: errorHandler(e)
471
+ });
472
+ callback == null ? void 0 : callback(null, e);
473
+ }
474
+ };
475
+ const saveCountryRestrictions = async payload => {
476
+ const {
477
+ callback,
478
+ countryCodes
479
+ } = payload;
480
+ setCountryRestrictionsState({
481
+ saving: true,
482
+ error: null
483
+ });
484
+ try {
485
+ const uniqueUpper = Array.from(new Set(countryCodes.map(code => code.toUpperCase())));
486
+ await api.auth.updateCountryRestrictions({
487
+ countries: uniqueUpper.map(countryCode => ({
488
+ countryCode
489
+ }))
490
+ });
491
+ const [config, restrictions] = await Promise.all([api.auth.getCountryRestrictionsConfig(), api.auth.getCountryRestrictions()]);
492
+ setCountryRestrictionsState({
493
+ data: {
494
+ config,
495
+ restrictions
496
+ },
497
+ saving: false
498
+ });
499
+ callback == null ? void 0 : callback(true);
500
+ } catch (e) {
501
+ setCountryRestrictionsState({
502
+ saving: false,
503
+ error: errorHandler(e)
504
+ });
505
+ callback == null ? void 0 : callback(null, e);
506
+ }
507
+ };
416
508
  const wrappedLoadIpRestrictions = __securityCenterSagaWrapper(loadIpRestrictions);
417
509
  const wrappedSaveIpRestriction = __securityCenterSagaWrapper(saveIpRestriction);
418
510
  const wrappedSaveIpRestrictionsConfig = __securityCenterSagaWrapper(saveIpRestrictionsConfig);
@@ -423,11 +515,15 @@ export default ((store, api, sharedActions) => {
423
515
  const wrappedSaveEmailDomainRestriction = __securityCenterSagaWrapper(saveEmailDomainRestriction);
424
516
  const wrappedSaveEmailDomainRestrictionsConfig = __securityCenterSagaWrapper(saveEmailDomainRestrictionsConfig);
425
517
  const wrappedDeleteEmailDomainRestriction = __securityCenterSagaWrapper(deleteEmailDomainRestriction);
518
+ const wrappedLoadCountryRestrictions = __securityCenterSagaWrapper(loadCountryRestrictions);
519
+ const wrappedSaveCountryRestrictionsConfig = __securityCenterSagaWrapper(saveCountryRestrictionsConfig);
520
+ const wrappedSaveCountryRestrictions = __securityCenterSagaWrapper(saveCountryRestrictions);
426
521
  return {
427
522
  // reducers
428
523
  setRestrictionsState,
429
524
  setIpRestrictionsState,
430
525
  setEmailDomainRestrictionsState,
526
+ setCountryRestrictionsState,
431
527
  __securityCenterSagaWrapper,
432
528
  // actions
433
529
  loadIpRestrictions: wrappedLoadIpRestrictions,
@@ -439,6 +535,9 @@ export default ((store, api, sharedActions) => {
439
535
  loadEmailDomainRestrictions: wrappedLoadEmailDomainRestrictions,
440
536
  saveEmailDomainRestriction: wrappedSaveEmailDomainRestriction,
441
537
  saveEmailDomainRestrictionsConfig: wrappedSaveEmailDomainRestrictionsConfig,
442
- deleteEmailDomainRestriction: wrappedDeleteEmailDomainRestriction
538
+ deleteEmailDomainRestriction: wrappedDeleteEmailDomainRestriction,
539
+ loadCountryRestrictions: wrappedLoadCountryRestrictions,
540
+ saveCountryRestrictionsConfig: wrappedSaveCountryRestrictionsConfig,
541
+ saveCountryRestrictions: wrappedSaveCountryRestrictions
443
542
  };
444
543
  });
@@ -1,5 +1,5 @@
1
1
  import { WithStatus, WithCallback } from '../../../interfaces';
2
- import { IPRestrictionsConfig, IpRestriction, GetIPRestrictionsParams, DomainRestriction, DomainRestrictionConfig, CreateDomainRestriction, UpdateDomainRestrictionsConfig } from '@frontegg/rest-api';
2
+ import { IPRestrictionsConfig, IpRestriction, GetIPRestrictionsParams, DomainRestriction, DomainRestrictionConfig, CreateDomainRestriction, UpdateDomainRestrictionsConfig, CountryRestrictionConfig, CountryRestrictionRule, UpdateCountryRestrictionConfig } from '@frontegg/rest-api';
3
3
  export type IPRestrictionsState = WithStatus & {
4
4
  data?: {
5
5
  config: IPRestrictionsConfig;
@@ -17,7 +17,18 @@ export type EmailDomainRestrictionsState = WithStatus & {
17
17
  };
18
18
  export type SaveEmailDomainRestrictionsPayload = WithCallback<CreateDomainRestriction>;
19
19
  export type SaveEmailDomainRestrictionConfigPayload = WithCallback<UpdateDomainRestrictionsConfig>;
20
+ export type CountryRestrictionsState = WithStatus & {
21
+ data?: {
22
+ config: CountryRestrictionConfig;
23
+ restrictions: CountryRestrictionRule[];
24
+ };
25
+ };
26
+ export type SaveCountryRestrictionConfigPayload = WithCallback<Partial<UpdateCountryRestrictionConfig>>;
27
+ export type SaveCountryRestrictionsPayload = WithCallback<{
28
+ countryCodes: string[];
29
+ }>;
20
30
  export interface RestrictionsState {
21
31
  ipRestrictions: IPRestrictionsState;
22
32
  emailDomainRestrictions: EmailDomainRestrictionsState;
33
+ countryRestrictions: CountryRestrictionsState;
23
34
  }
@@ -13,6 +13,9 @@ export const initialState = {
13
13
  },
14
14
  emailDomainRestrictions: {
15
15
  loading: false
16
+ },
17
+ countryRestrictions: {
18
+ loading: false
16
19
  }
17
20
  };
18
21
  export default (overrideState => createProxy(initialState, overrideState));
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.105.0-alpha.0
1
+ /** @license Frontegg v7.105.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -1,10 +1,12 @@
1
1
  import { FronteggState, RestApi, SharedActions, WithCallback } from '../../../interfaces';
2
2
  import { CreateIpRestriction, IPRestrictionsConfig } from '@frontegg/rest-api';
3
3
  import { SaveEmailDomainRestrictionConfigPayload, SaveEmailDomainRestrictionsPayload } from '../../../auth';
4
+ import { SaveCountryRestrictionConfigPayload, SaveCountryRestrictionsPayload } from '../../../auth/Security/RestrictionsState/interfaces';
4
5
  declare const _default: (store: FronteggState, api: RestApi, actions: SharedActions) => {
5
6
  setRestrictionsState: (state: Partial<import("../../../auth").RestrictionsState>) => void;
6
7
  setIpRestrictionsState: (state: Partial<import("../../../auth").IPRestrictionsState>) => void;
7
8
  setEmailDomainRestrictionsState: (state: Partial<import("../../../auth").EmailDomainRestrictionsState>) => void;
9
+ setCountryRestrictionsState: (state: Partial<import("../../../auth").CountryRestrictionsState>) => void;
8
10
  __securityCenterSagaWrapper: <T>(action: T) => T;
9
11
  loadIpRestrictions: () => Promise<void>;
10
12
  saveIpRestriction: (payload: WithCallback<CreateIpRestriction>) => Promise<void>;
@@ -20,5 +22,8 @@ declare const _default: (store: FronteggState, api: RestApi, actions: SharedActi
20
22
  deleteEmailDomainRestriction: (payload: {
21
23
  id: string;
22
24
  }) => Promise<void>;
25
+ loadCountryRestrictions: () => Promise<void>;
26
+ saveCountryRestrictionsConfig: (payload: SaveCountryRestrictionConfigPayload) => Promise<void>;
27
+ saveCountryRestrictions: (payload: SaveCountryRestrictionsPayload) => Promise<void>;
23
28
  };
24
29
  export default _default;
@@ -3,7 +3,8 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
3
3
  const _excluded = ["callback"],
4
4
  _excluded2 = ["callback"],
5
5
  _excluded3 = ["callback"],
6
- _excluded4 = ["callback"];
6
+ _excluded4 = ["callback"],
7
+ _excluded5 = ["callback"];
7
8
  import { buildRestrictionsActions } from '../../../auth/Security/RestrictionsState';
8
9
  import { RestrictionType } from '@frontegg/rest-api';
9
10
  import { delay, errorHandler } from '../../../helpers';
@@ -12,7 +13,7 @@ import { v4 as uuid } from 'uuid';
12
13
  import { mockActionsExpect } from '../../helpers';
13
14
  export default ((store, api, actions) => {
14
15
  const originalActions = buildRestrictionsActions(store, api, actions);
15
- const mockedActions = mockActionsExpect(originalActions, ['setRestrictionsState', 'setIpRestrictionsState', 'setEmailDomainRestrictionsState']);
16
+ const mockedActions = mockActionsExpect(originalActions, ['setRestrictionsState', 'setIpRestrictionsState', 'setEmailDomainRestrictionsState', 'setCountryRestrictionsState']);
16
17
  mockedActions.loadIpRestrictions = async () => {
17
18
  mockedActions.setIpRestrictionsState({
18
19
  loading: true,
@@ -53,6 +54,27 @@ export default ((store, api, actions) => {
53
54
  }
54
55
  });
55
56
  };
57
+ mockedActions.loadCountryRestrictions = async () => {
58
+ mockedActions.setCountryRestrictionsState({
59
+ loading: true,
60
+ error: null
61
+ });
62
+ mockedActions.setCountryRestrictionsState({
63
+ loading: false,
64
+ data: {
65
+ restrictions: [{
66
+ id: '1',
67
+ countryCode: 'US'
68
+ }],
69
+ config: {
70
+ enabled: true,
71
+ action: RestrictionType.ALLOW,
72
+ failStrategy: RestrictionType.ALLOW,
73
+ shouldSendRestrictionEmail: false
74
+ }
75
+ }
76
+ });
77
+ };
56
78
  mockedActions.saveIpRestriction = async payload => {
57
79
  var _ipRestrictionsState$, _ipRestrictionsState$2, _newRestriction$isAct;
58
80
  const {
@@ -221,6 +243,62 @@ export default ((store, api, actions) => {
221
243
  saving: false
222
244
  });
223
245
  };
246
+ mockedActions.saveCountryRestrictionsConfig = async payload => {
247
+ var _ref, _config$enabled, _countryRestrictionsS, _ref2, _config$action, _countryRestrictionsS2, _ref3, _config$failStrategy, _countryRestrictionsS3, _ref4, _config$shouldSendRes, _countryRestrictionsS4, _countryRestrictionsS5;
248
+ const {
249
+ callback
250
+ } = payload,
251
+ config = _objectWithoutPropertiesLoose(payload, _excluded5);
252
+ const countryRestrictionsState = store.auth.restrictionsState.countryRestrictions;
253
+ mockedActions.setCountryRestrictionsState({
254
+ saving: true,
255
+ error: null
256
+ });
257
+ await delay();
258
+ callback == null ? void 0 : callback(true);
259
+ mockedActions.setCountryRestrictionsState({
260
+ data: {
261
+ config: {
262
+ enabled: (_ref = (_config$enabled = config.enabled) != null ? _config$enabled : (_countryRestrictionsS = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS.config.enabled) != null ? _ref : false,
263
+ action: (_ref2 = (_config$action = config.action) != null ? _config$action : (_countryRestrictionsS2 = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS2.config.action) != null ? _ref2 : RestrictionType.ALLOW,
264
+ failStrategy: (_ref3 = (_config$failStrategy = config.failStrategy) != null ? _config$failStrategy : (_countryRestrictionsS3 = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS3.config.failStrategy) != null ? _ref3 : RestrictionType.ALLOW,
265
+ shouldSendRestrictionEmail: (_ref4 = (_config$shouldSendRes = config.shouldSendRestrictionEmail) != null ? _config$shouldSendRes : (_countryRestrictionsS4 = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS4.config.shouldSendRestrictionEmail) != null ? _ref4 : false
266
+ },
267
+ restrictions: [...(((_countryRestrictionsS5 = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS5.restrictions) || [])]
268
+ },
269
+ saving: false
270
+ });
271
+ };
272
+ mockedActions.saveCountryRestrictions = async payload => {
273
+ var _countryRestrictionsS6, _countryRestrictionsS7;
274
+ const {
275
+ callback,
276
+ countryCodes
277
+ } = payload;
278
+ const countryRestrictionsState = store.auth.restrictionsState.countryRestrictions;
279
+ mockedActions.setCountryRestrictionsState({
280
+ saving: true,
281
+ error: null
282
+ });
283
+ await delay();
284
+ callback == null ? void 0 : callback(true);
285
+ const restrictions = Array.from(new Set(countryCodes.map(code => code.toUpperCase()))).map((countryCode, index) => ({
286
+ id: `mock-${countryCode}-${index}`,
287
+ countryCode
288
+ }));
289
+ mockedActions.setCountryRestrictionsState({
290
+ data: {
291
+ config: (_countryRestrictionsS6 = (_countryRestrictionsS7 = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS7.config) != null ? _countryRestrictionsS6 : {
292
+ enabled: true,
293
+ action: RestrictionType.ALLOW,
294
+ failStrategy: RestrictionType.ALLOW,
295
+ shouldSendRestrictionEmail: false
296
+ },
297
+ restrictions
298
+ },
299
+ saving: false
300
+ });
301
+ };
224
302
  mockedActions.deleteEmailDomainRestriction = async payload => {
225
303
  var _emailDomainRestricti4, _emailDomainRestricti5;
226
304
  const {
@@ -58,13 +58,10 @@ var _default = (store, api, sharedActions) => {
58
58
  return;
59
59
  }
60
60
  try {
61
- const tabTenantId = (0, _restApi.getTabTenantFromSessionStorage)(store.root.appName);
62
- const body = (0, _extends2.default)({
61
+ const body = {
63
62
  grant_type: 'refresh_token',
64
63
  refresh_token: user == null ? void 0 : user.refreshToken
65
- }, tabTenantId && {
66
- tenantId: tabTenantId
67
- });
64
+ };
68
65
  const response = await api.auth.exchangeOAuthTokensV2(body);
69
66
  const updatedUser = await __handleUnnecessaryEntitlementsUpdate(response.user);
70
67
  actions.afterAuthenticationStateUpdate((0, _extends2.default)({}, response, {
@@ -1322,13 +1319,10 @@ var _default = (store, api, sharedActions) => {
1322
1319
  return;
1323
1320
  }
1324
1321
  try {
1325
- const tabTenantId = (0, _restApi.getTabTenantFromSessionStorage)(store.root.appName);
1326
- const body = (0, _extends2.default)({
1322
+ const body = {
1327
1323
  grant_type: 'refresh_token',
1328
1324
  refresh_token: currentUser == null ? void 0 : currentUser.refreshToken
1329
- }, tabTenantId && {
1330
- tenantId: tabTenantId
1331
- });
1325
+ };
1332
1326
  const response = await api.auth.exchangeOAuthTokensV2(body);
1333
1327
  const updatedUser = await __handleUnnecessaryEntitlementsUpdate(response.user);
1334
1328
  actions.afterAuthenticationStateUpdate((0, _extends2.default)({}, response, {
@@ -12,7 +12,8 @@ var _restApi = require("@frontegg/rest-api");
12
12
  const _excluded = ["callback"],
13
13
  _excluded2 = ["callback"],
14
14
  _excluded3 = ["callback"],
15
- _excluded4 = ["callback"];
15
+ _excluded4 = ["callback"],
16
+ _excluded5 = ["callback"];
16
17
  var _default = (store, api, sharedActions) => {
17
18
  const actions = sharedActions;
18
19
 
@@ -40,12 +41,9 @@ var _default = (store, api, sharedActions) => {
40
41
  */
41
42
  const __securityCenterSagaWrapper = action => {
42
43
  return async (...args) => {
43
- const [securityCenterFeatureFlag] = await actions.getFeatureFlags(['security-center-admin-portal-major-version']);
44
44
  await action(...args);
45
- if (securityCenterFeatureFlag) {
46
- await actions.loadRecommendations((0, _helpers.withRetryConfig)());
47
- await actions.loadInsights((0, _helpers.withRetryConfig)());
48
- }
45
+ await actions.loadRecommendations((0, _helpers.withRetryConfig)());
46
+ await actions.loadInsights((0, _helpers.withRetryConfig)());
49
47
  };
50
48
  };
51
49
  const setRestrictionsState = state => {
@@ -57,6 +55,9 @@ var _default = (store, api, sharedActions) => {
57
55
  const setEmailDomainRestrictionsState = state => {
58
56
  Object.assign(store.auth.restrictionsState.emailDomainRestrictions, state);
59
57
  };
58
+ const setCountryRestrictionsState = state => {
59
+ Object.assign(store.auth.restrictionsState.countryRestrictions, state);
60
+ };
60
61
  const loadIpRestrictions = async () => {
61
62
  setIpRestrictionsState({
62
63
  loading: true,
@@ -420,6 +421,97 @@ var _default = (store, api, sharedActions) => {
420
421
  });
421
422
  }
422
423
  };
424
+ const loadCountryRestrictions = async () => {
425
+ setCountryRestrictionsState({
426
+ loading: true,
427
+ error: null
428
+ });
429
+ try {
430
+ const [config, restrictions] = await Promise.all([api.auth.getCountryRestrictionsConfig(), api.auth.getCountryRestrictions()]);
431
+ setCountryRestrictionsState({
432
+ data: {
433
+ config,
434
+ restrictions
435
+ },
436
+ loading: false
437
+ });
438
+ } catch (e) {
439
+ setCountryRestrictionsState({
440
+ error: (0, _helpers.errorHandler)(e),
441
+ loading: false
442
+ });
443
+ }
444
+ };
445
+ const saveCountryRestrictionsConfig = async payload => {
446
+ var _countryRestrictionsS, _countryRestrictionsS2;
447
+ const {
448
+ callback
449
+ } = payload,
450
+ configOverrides = (0, _objectWithoutPropertiesLoose2.default)(payload, _excluded5);
451
+ const countryRestrictionsState = store.auth.restrictionsState.countryRestrictions;
452
+ const currentConfig = (_countryRestrictionsS = (_countryRestrictionsS2 = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS2.config) != null ? _countryRestrictionsS : {
453
+ enabled: false,
454
+ action: _restApi.RestrictionType.ALLOW,
455
+ failStrategy: _restApi.RestrictionType.ALLOW,
456
+ shouldSendRestrictionEmail: false
457
+ };
458
+ const nextConfig = (0, _extends2.default)({}, currentConfig, configOverrides);
459
+ setCountryRestrictionsState({
460
+ saving: true,
461
+ error: null
462
+ });
463
+ try {
464
+ await api.auth.updateCountryRestrictionsConfig(nextConfig);
465
+ const [config, restrictions] = await Promise.all([api.auth.getCountryRestrictionsConfig(), api.auth.getCountryRestrictions()]);
466
+ setCountryRestrictionsState({
467
+ data: {
468
+ config,
469
+ restrictions
470
+ },
471
+ saving: false
472
+ });
473
+ callback == null ? void 0 : callback(true);
474
+ } catch (e) {
475
+ setCountryRestrictionsState({
476
+ saving: false,
477
+ error: (0, _helpers.errorHandler)(e)
478
+ });
479
+ callback == null ? void 0 : callback(null, e);
480
+ }
481
+ };
482
+ const saveCountryRestrictions = async payload => {
483
+ const {
484
+ callback,
485
+ countryCodes
486
+ } = payload;
487
+ setCountryRestrictionsState({
488
+ saving: true,
489
+ error: null
490
+ });
491
+ try {
492
+ const uniqueUpper = Array.from(new Set(countryCodes.map(code => code.toUpperCase())));
493
+ await api.auth.updateCountryRestrictions({
494
+ countries: uniqueUpper.map(countryCode => ({
495
+ countryCode
496
+ }))
497
+ });
498
+ const [config, restrictions] = await Promise.all([api.auth.getCountryRestrictionsConfig(), api.auth.getCountryRestrictions()]);
499
+ setCountryRestrictionsState({
500
+ data: {
501
+ config,
502
+ restrictions
503
+ },
504
+ saving: false
505
+ });
506
+ callback == null ? void 0 : callback(true);
507
+ } catch (e) {
508
+ setCountryRestrictionsState({
509
+ saving: false,
510
+ error: (0, _helpers.errorHandler)(e)
511
+ });
512
+ callback == null ? void 0 : callback(null, e);
513
+ }
514
+ };
423
515
  const wrappedLoadIpRestrictions = __securityCenterSagaWrapper(loadIpRestrictions);
424
516
  const wrappedSaveIpRestriction = __securityCenterSagaWrapper(saveIpRestriction);
425
517
  const wrappedSaveIpRestrictionsConfig = __securityCenterSagaWrapper(saveIpRestrictionsConfig);
@@ -430,11 +522,15 @@ var _default = (store, api, sharedActions) => {
430
522
  const wrappedSaveEmailDomainRestriction = __securityCenterSagaWrapper(saveEmailDomainRestriction);
431
523
  const wrappedSaveEmailDomainRestrictionsConfig = __securityCenterSagaWrapper(saveEmailDomainRestrictionsConfig);
432
524
  const wrappedDeleteEmailDomainRestriction = __securityCenterSagaWrapper(deleteEmailDomainRestriction);
525
+ const wrappedLoadCountryRestrictions = __securityCenterSagaWrapper(loadCountryRestrictions);
526
+ const wrappedSaveCountryRestrictionsConfig = __securityCenterSagaWrapper(saveCountryRestrictionsConfig);
527
+ const wrappedSaveCountryRestrictions = __securityCenterSagaWrapper(saveCountryRestrictions);
433
528
  return {
434
529
  // reducers
435
530
  setRestrictionsState,
436
531
  setIpRestrictionsState,
437
532
  setEmailDomainRestrictionsState,
533
+ setCountryRestrictionsState,
438
534
  __securityCenterSagaWrapper,
439
535
  // actions
440
536
  loadIpRestrictions: wrappedLoadIpRestrictions,
@@ -446,7 +542,10 @@ var _default = (store, api, sharedActions) => {
446
542
  loadEmailDomainRestrictions: wrappedLoadEmailDomainRestrictions,
447
543
  saveEmailDomainRestriction: wrappedSaveEmailDomainRestriction,
448
544
  saveEmailDomainRestrictionsConfig: wrappedSaveEmailDomainRestrictionsConfig,
449
- deleteEmailDomainRestriction: wrappedDeleteEmailDomainRestriction
545
+ deleteEmailDomainRestriction: wrappedDeleteEmailDomainRestriction,
546
+ loadCountryRestrictions: wrappedLoadCountryRestrictions,
547
+ saveCountryRestrictionsConfig: wrappedSaveCountryRestrictionsConfig,
548
+ saveCountryRestrictions: wrappedSaveCountryRestrictions
450
549
  };
451
550
  };
452
551
  exports.default = _default;
@@ -19,6 +19,9 @@ const initialState = {
19
19
  },
20
20
  emailDomainRestrictions: {
21
21
  loading: false
22
+ },
23
+ countryRestrictions: {
24
+ loading: false
22
25
  }
23
26
  };
24
27
  exports.initialState = initialState;
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v7.105.0-alpha.0
1
+ /** @license Frontegg v7.105.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -16,10 +16,11 @@ var _helpers2 = require("../../helpers");
16
16
  const _excluded = ["callback"],
17
17
  _excluded2 = ["callback"],
18
18
  _excluded3 = ["callback"],
19
- _excluded4 = ["callback"];
19
+ _excluded4 = ["callback"],
20
+ _excluded5 = ["callback"];
20
21
  var _default = (store, api, actions) => {
21
22
  const originalActions = (0, _RestrictionsState.buildRestrictionsActions)(store, api, actions);
22
- const mockedActions = (0, _helpers2.mockActionsExpect)(originalActions, ['setRestrictionsState', 'setIpRestrictionsState', 'setEmailDomainRestrictionsState']);
23
+ const mockedActions = (0, _helpers2.mockActionsExpect)(originalActions, ['setRestrictionsState', 'setIpRestrictionsState', 'setEmailDomainRestrictionsState', 'setCountryRestrictionsState']);
23
24
  mockedActions.loadIpRestrictions = async () => {
24
25
  mockedActions.setIpRestrictionsState({
25
26
  loading: true,
@@ -60,6 +61,27 @@ var _default = (store, api, actions) => {
60
61
  }
61
62
  });
62
63
  };
64
+ mockedActions.loadCountryRestrictions = async () => {
65
+ mockedActions.setCountryRestrictionsState({
66
+ loading: true,
67
+ error: null
68
+ });
69
+ mockedActions.setCountryRestrictionsState({
70
+ loading: false,
71
+ data: {
72
+ restrictions: [{
73
+ id: '1',
74
+ countryCode: 'US'
75
+ }],
76
+ config: {
77
+ enabled: true,
78
+ action: _restApi.RestrictionType.ALLOW,
79
+ failStrategy: _restApi.RestrictionType.ALLOW,
80
+ shouldSendRestrictionEmail: false
81
+ }
82
+ }
83
+ });
84
+ };
63
85
  mockedActions.saveIpRestriction = async payload => {
64
86
  var _ipRestrictionsState$, _ipRestrictionsState$2, _newRestriction$isAct;
65
87
  const {
@@ -228,6 +250,62 @@ var _default = (store, api, actions) => {
228
250
  saving: false
229
251
  });
230
252
  };
253
+ mockedActions.saveCountryRestrictionsConfig = async payload => {
254
+ var _ref, _config$enabled, _countryRestrictionsS, _ref2, _config$action, _countryRestrictionsS2, _ref3, _config$failStrategy, _countryRestrictionsS3, _ref4, _config$shouldSendRes, _countryRestrictionsS4, _countryRestrictionsS5;
255
+ const {
256
+ callback
257
+ } = payload,
258
+ config = (0, _objectWithoutPropertiesLoose2.default)(payload, _excluded5);
259
+ const countryRestrictionsState = store.auth.restrictionsState.countryRestrictions;
260
+ mockedActions.setCountryRestrictionsState({
261
+ saving: true,
262
+ error: null
263
+ });
264
+ await (0, _helpers.delay)();
265
+ callback == null ? void 0 : callback(true);
266
+ mockedActions.setCountryRestrictionsState({
267
+ data: {
268
+ config: {
269
+ enabled: (_ref = (_config$enabled = config.enabled) != null ? _config$enabled : (_countryRestrictionsS = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS.config.enabled) != null ? _ref : false,
270
+ action: (_ref2 = (_config$action = config.action) != null ? _config$action : (_countryRestrictionsS2 = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS2.config.action) != null ? _ref2 : _restApi.RestrictionType.ALLOW,
271
+ failStrategy: (_ref3 = (_config$failStrategy = config.failStrategy) != null ? _config$failStrategy : (_countryRestrictionsS3 = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS3.config.failStrategy) != null ? _ref3 : _restApi.RestrictionType.ALLOW,
272
+ shouldSendRestrictionEmail: (_ref4 = (_config$shouldSendRes = config.shouldSendRestrictionEmail) != null ? _config$shouldSendRes : (_countryRestrictionsS4 = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS4.config.shouldSendRestrictionEmail) != null ? _ref4 : false
273
+ },
274
+ restrictions: [...(((_countryRestrictionsS5 = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS5.restrictions) || [])]
275
+ },
276
+ saving: false
277
+ });
278
+ };
279
+ mockedActions.saveCountryRestrictions = async payload => {
280
+ var _countryRestrictionsS6, _countryRestrictionsS7;
281
+ const {
282
+ callback,
283
+ countryCodes
284
+ } = payload;
285
+ const countryRestrictionsState = store.auth.restrictionsState.countryRestrictions;
286
+ mockedActions.setCountryRestrictionsState({
287
+ saving: true,
288
+ error: null
289
+ });
290
+ await (0, _helpers.delay)();
291
+ callback == null ? void 0 : callback(true);
292
+ const restrictions = Array.from(new Set(countryCodes.map(code => code.toUpperCase()))).map((countryCode, index) => ({
293
+ id: `mock-${countryCode}-${index}`,
294
+ countryCode
295
+ }));
296
+ mockedActions.setCountryRestrictionsState({
297
+ data: {
298
+ config: (_countryRestrictionsS6 = (_countryRestrictionsS7 = countryRestrictionsState.data) == null ? void 0 : _countryRestrictionsS7.config) != null ? _countryRestrictionsS6 : {
299
+ enabled: true,
300
+ action: _restApi.RestrictionType.ALLOW,
301
+ failStrategy: _restApi.RestrictionType.ALLOW,
302
+ shouldSendRestrictionEmail: false
303
+ },
304
+ restrictions
305
+ },
306
+ saving: false
307
+ });
308
+ };
231
309
  mockedActions.deleteEmailDomainRestriction = async payload => {
232
310
  var _emailDomainRestricti4, _emailDomainRestricti5;
233
311
  const {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
- "version": "7.105.0-alpha.0",
3
+ "version": "7.105.0",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "author": "Frontegg LTD",
7
7
  "dependencies": {
8
8
  "@babel/runtime": "^7.18.6",
9
9
  "@frontegg/entitlements-javascript-commons": "1.1.2",
10
- "@frontegg/rest-api": "7.105.0-alpha.0",
10
+ "@frontegg/rest-api": "7.105.0",
11
11
  "fast-deep-equal": "3.1.3",
12
12
  "get-value": "^3.0.1",
13
13
  "proxy-compare": "^3.0.0",