@frontegg/redux-store 6.34.0 → 6.35.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.
@@ -22,15 +22,165 @@ var _constants = require("../../constants");
22
22
 
23
23
  var _dummy = require("../dummy");
24
24
 
25
+ var _utils = require("../utils");
26
+
25
27
  const _excluded = ["callback"],
26
28
  _excluded2 = ["callback"],
27
29
  _excluded3 = ["callback"],
28
- _excluded4 = ["callback"];
30
+ _excluded4 = ["callback"],
31
+ _excluded5 = ["callback"],
32
+ _excluded6 = ["callback"],
33
+ _excluded7 = ["callback"],
34
+ _excluded8 = ["callback"];
29
35
 
30
36
  const selectIpRestrictionsState = () => (0, _effects.select)(_ => _[_constants.authStoreName].restrictionsState.ipRestrictions);
31
37
 
32
38
  const selectUserIp = () => (0, _effects.select)(_ => _[_constants.authStoreName].userIp);
33
39
 
40
+ const selectEmailDomainRestrictionsState = () => (0, _effects.select)(_ => _[_constants.authStoreName].restrictionsState.emailDomainRestrictions);
41
+
42
+ function* loadEmailDomainRestrictions() {
43
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
44
+ loading: true,
45
+ error: null
46
+ }));
47
+
48
+ try {
49
+ const restrictionsConfig = yield (0, _effects.call)(_restApi.api.auth.getDomainRestrictionsConfig);
50
+ const restrictions = yield (0, _effects.call)(_restApi.api.auth.getDomainRestrictions);
51
+ const filteredRestrictions = restrictions.items.filter(restriction => restriction.type === restrictionsConfig.listType);
52
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
53
+ data: {
54
+ restrictions: filteredRestrictions,
55
+ config: restrictionsConfig
56
+ },
57
+ loading: false
58
+ }));
59
+ } catch (e) {
60
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
61
+ error: e.message,
62
+ loading: false
63
+ }));
64
+ }
65
+ }
66
+
67
+ function* saveEmailDomainRestriction(_ref) {
68
+ let {
69
+ payload: {
70
+ callback
71
+ }
72
+ } = _ref,
73
+ newRestriction = (0, _objectWithoutPropertiesLoose2.default)(_ref.payload, _excluded);
74
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
75
+ saving: true,
76
+ error: null
77
+ }));
78
+ const emailDomainRestrictionsState = yield selectEmailDomainRestrictionsState();
79
+
80
+ try {
81
+ var _emailDomainRestricti2;
82
+
83
+ yield (0, _effects.call)(_restApi.api.auth.createDomainRestriction, newRestriction);
84
+ const restrictions = yield (0, _effects.call)(_restApi.api.auth.getDomainRestrictions);
85
+ const filteredRestrictions = restrictions.items.filter(restriction => {
86
+ var _emailDomainRestricti;
87
+
88
+ return restriction.type === ((_emailDomainRestricti = emailDomainRestrictionsState.data) == null ? void 0 : _emailDomainRestricti.config.listType);
89
+ });
90
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
91
+ data: {
92
+ config: ((_emailDomainRestricti2 = emailDomainRestrictionsState.data) == null ? void 0 : _emailDomainRestricti2.config) || {
93
+ active: false,
94
+ blockPublicDomains: false,
95
+ listType: newRestriction.type
96
+ },
97
+ restrictions: filteredRestrictions
98
+ },
99
+ saving: false
100
+ }));
101
+ callback == null ? void 0 : callback(true);
102
+ } catch (e) {
103
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
104
+ saving: false,
105
+ error: e.message
106
+ }));
107
+ callback == null ? void 0 : callback(null, e);
108
+ }
109
+ }
110
+
111
+ function* saveEmailDomainRestrictionConfig(_ref2) {
112
+ let {
113
+ payload: {
114
+ callback
115
+ }
116
+ } = _ref2,
117
+ config = (0, _objectWithoutPropertiesLoose2.default)(_ref2.payload, _excluded2);
118
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
119
+ saving: true,
120
+ error: null
121
+ }));
122
+
123
+ try {
124
+ const updatedConfig = yield (0, _effects.call)(_restApi.api.auth.updateDomainRestrictionConfig, config);
125
+ const restrictions = yield (0, _effects.call)(_restApi.api.auth.getDomainRestrictions);
126
+ const filteredRestrictions = restrictions.items.filter(restriction => restriction.type === updatedConfig.listType);
127
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
128
+ data: {
129
+ config: updatedConfig,
130
+ restrictions: filteredRestrictions
131
+ },
132
+ saving: false
133
+ }));
134
+ callback == null ? void 0 : callback(true);
135
+ } catch (e) {
136
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
137
+ saving: false,
138
+ error: e.message
139
+ }));
140
+ callback == null ? void 0 : callback(null, e);
141
+ }
142
+ }
143
+
144
+ function* deleteEmailDomainRestriction({
145
+ payload: {
146
+ id
147
+ }
148
+ }) {
149
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
150
+ saving: true,
151
+ error: null
152
+ }));
153
+ const emailDomainRestrictionsState = yield selectEmailDomainRestrictionsState();
154
+
155
+ try {
156
+ var _emailDomainRestricti4;
157
+
158
+ yield (0, _effects.call)(_restApi.api.auth.deleteDomainRestriction, id);
159
+ const restrictions = yield (0, _effects.call)(_restApi.api.auth.getDomainRestrictions);
160
+ const filteredRestrictions = restrictions.items.filter(restriction => {
161
+ var _emailDomainRestricti3;
162
+
163
+ return restriction.type === ((_emailDomainRestricti3 = emailDomainRestrictionsState.data) == null ? void 0 : _emailDomainRestricti3.config.listType);
164
+ });
165
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
166
+ data: {
167
+ config: ((_emailDomainRestricti4 = emailDomainRestrictionsState.data) == null ? void 0 : _emailDomainRestricti4.config) || {
168
+ active: false,
169
+ blockPublicDomains: false,
170
+ listType: _restApi.RestrictionType.ALLOW
171
+ },
172
+ restrictions: filteredRestrictions
173
+ },
174
+ saving: false
175
+ }));
176
+ } catch (e) {
177
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
178
+ saving: false,
179
+ error: e.message
180
+ }));
181
+ }
182
+ }
183
+
34
184
  const getPagination = statePagination => {
35
185
  var _statePagination$_fil, _statePagination$_lim, _statePagination$_off;
36
186
 
@@ -144,13 +294,13 @@ function* addCurrentUserIpAndActivate({
144
294
  }
145
295
  }
146
296
 
147
- function* saveIpRestriction(_ref) {
297
+ function* saveIpRestriction(_ref3) {
148
298
  let {
149
299
  payload: {
150
300
  callback
151
301
  }
152
- } = _ref,
153
- newRestriction = (0, _objectWithoutPropertiesLoose2.default)(_ref.payload, _excluded);
302
+ } = _ref3,
303
+ newRestriction = (0, _objectWithoutPropertiesLoose2.default)(_ref3.payload, _excluded3);
154
304
  yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
155
305
  saving: true,
156
306
  error: null
@@ -192,13 +342,13 @@ function* saveIpRestriction(_ref) {
192
342
  }
193
343
  }
194
344
 
195
- function* saveIpRestrictionsConfig(_ref2) {
345
+ function* saveIpRestrictionsConfig(_ref4) {
196
346
  let {
197
347
  payload: {
198
348
  callback
199
349
  }
200
- } = _ref2,
201
- config = (0, _objectWithoutPropertiesLoose2.default)(_ref2.payload, _excluded2);
350
+ } = _ref4,
351
+ config = (0, _objectWithoutPropertiesLoose2.default)(_ref4.payload, _excluded4);
202
352
  yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
203
353
  saving: true,
204
354
  error: null
@@ -286,11 +436,15 @@ function* deleteIpRestriction({
286
436
 
287
437
  function* restrictionsSagas() {
288
438
  yield (0, _effects.takeLeading)(_reducer.actions.loadIpRestrictions, loadIpRestrictions);
439
+ yield (0, _effects.takeLeading)(_reducer.actions.loadEmailDomainRestrictions, loadEmailDomainRestrictions);
289
440
  yield (0, _effects.takeEvery)(_reducer.actions.saveIpRestriction, saveIpRestriction);
290
441
  yield (0, _effects.takeEvery)(_reducer.actions.saveIpRestrictionsConfig, saveIpRestrictionsConfig);
291
442
  yield (0, _effects.takeEvery)(_reducer.actions.deleteIpRestriction, deleteIpRestriction);
292
443
  yield (0, _effects.takeEvery)(_reducer.actions.checkIfUserIpValid, checkIfUserIpValid);
293
444
  yield (0, _effects.takeEvery)(_reducer.actions.addCurrentUserIpAndActivate, addCurrentUserIpAndActivate);
445
+ yield (0, _effects.takeEvery)(_reducer.actions.saveEmailDomainRestriction, saveEmailDomainRestriction);
446
+ yield (0, _effects.takeEvery)(_reducer.actions.saveEmailDomainRestrictionsConfig, saveEmailDomainRestrictionConfig);
447
+ yield (0, _effects.takeEvery)(_reducer.actions.deleteEmailDomainRestriction, deleteEmailDomainRestriction);
294
448
  }
295
449
  /*********************************
296
450
  * Preview Sagas
@@ -339,15 +493,15 @@ function* checkIfUserIpValidMock() {
339
493
  }
340
494
  }
341
495
 
342
- function* saveIpRestrictionMock(_ref3) {
496
+ function* saveIpRestrictionMock(_ref5) {
343
497
  var _ipRestrictionsState$4, _ipRestrictionsState$5;
344
498
 
345
499
  let {
346
500
  payload: {
347
501
  callback
348
502
  }
349
- } = _ref3,
350
- newRestriction = (0, _objectWithoutPropertiesLoose2.default)(_ref3.payload, _excluded3);
503
+ } = _ref5,
504
+ newRestriction = (0, _objectWithoutPropertiesLoose2.default)(_ref5.payload, _excluded5);
351
505
  yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
352
506
  saving: true,
353
507
  error: null
@@ -378,13 +532,13 @@ function* saveIpRestrictionMock(_ref3) {
378
532
  callback == null ? void 0 : callback(true);
379
533
  }
380
534
 
381
- function* saveIpRestrictionsConfigMock(_ref4) {
535
+ function* saveIpRestrictionsConfigMock(_ref6) {
382
536
  let {
383
537
  payload: {
384
538
  callback
385
539
  }
386
- } = _ref4,
387
- config = (0, _objectWithoutPropertiesLoose2.default)(_ref4.payload, _excluded4);
540
+ } = _ref6,
541
+ config = (0, _objectWithoutPropertiesLoose2.default)(_ref6.payload, _excluded6);
388
542
  yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
389
543
  saving: true,
390
544
  error: null
@@ -469,10 +623,131 @@ function* addCurrentUserIpAndActivateMock({
469
623
  }
470
624
  }
471
625
 
626
+ function* loadEmailDomainRestrictionsMock() {
627
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
628
+ loading: true,
629
+ error: null
630
+ }));
631
+ yield (0, _utils.delay)();
632
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
633
+ loading: false,
634
+ data: {
635
+ restrictions: [{
636
+ domain: 'mock.com',
637
+ id: '1',
638
+ type: _restApi.RestrictionType.ALLOW
639
+ }],
640
+ config: {
641
+ active: true,
642
+ listType: _restApi.RestrictionType.ALLOW,
643
+ blockPublicDomains: false
644
+ }
645
+ }
646
+ }));
647
+ }
648
+
649
+ function* saveEmailDomainRestrictionMock(_ref7) {
650
+ var _emailDomainRestricti5, _emailDomainRestricti6;
651
+
652
+ let {
653
+ payload: {
654
+ callback
655
+ }
656
+ } = _ref7,
657
+ restriction = (0, _objectWithoutPropertiesLoose2.default)(_ref7.payload, _excluded7);
658
+ const emailDomainRestrictionsState = yield selectEmailDomainRestrictionsState();
659
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
660
+ saving: true,
661
+ error: null
662
+ }));
663
+ yield (0, _utils.delay)();
664
+ callback == null ? void 0 : callback(true);
665
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
666
+ data: {
667
+ config: ((_emailDomainRestricti5 = emailDomainRestrictionsState.data) == null ? void 0 : _emailDomainRestricti5.config) || {
668
+ active: false,
669
+ blockPublicDomains: false,
670
+ listType: restriction.type
671
+ },
672
+ restrictions: [...(((_emailDomainRestricti6 = emailDomainRestrictionsState.data) == null ? void 0 : _emailDomainRestricti6.restrictions) || []), (0, _extends2.default)({}, restriction, {
673
+ id: Date.now().toString()
674
+ })]
675
+ },
676
+ saving: false
677
+ }));
678
+ }
679
+
680
+ function* saveEmailDomainRestrictionConfigMock(_ref8) {
681
+ var _emailDomainRestricti7;
682
+
683
+ let {
684
+ payload: {
685
+ callback
686
+ }
687
+ } = _ref8,
688
+ config = (0, _objectWithoutPropertiesLoose2.default)(_ref8.payload, _excluded8);
689
+ const emailDomainRestrictionsState = yield selectEmailDomainRestrictionsState();
690
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
691
+ saving: true,
692
+ error: null
693
+ }));
694
+ yield (0, _utils.delay)();
695
+ callback == null ? void 0 : callback(true);
696
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
697
+ data: {
698
+ config: {
699
+ active: config.active,
700
+ blockPublicDomains: config.blockPublicDomains || false,
701
+ listType: config.type || _restApi.RestrictionType.ALLOW
702
+ },
703
+ restrictions: [...(((_emailDomainRestricti7 = emailDomainRestrictionsState.data) == null ? void 0 : _emailDomainRestricti7.restrictions) || [])]
704
+ },
705
+ saving: false
706
+ }));
707
+ }
708
+
709
+ function* deleteEmailDomainRestrictionMock({
710
+ payload: {
711
+ id
712
+ }
713
+ }) {
714
+ var _emailDomainRestricti8, _emailDomainRestricti9;
715
+
716
+ const emailDomainRestrictionsState = yield selectEmailDomainRestrictionsState();
717
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
718
+ saving: true,
719
+ error: null
720
+ }));
721
+ yield (0, _utils.delay)();
722
+ yield (0, _effects.put)(_reducer.actions.setEmailDomainRestrictionsState({
723
+ data: {
724
+ config: ((_emailDomainRestricti8 = emailDomainRestrictionsState.data) == null ? void 0 : _emailDomainRestricti8.config) || {
725
+ active: false,
726
+ blockPublicDomains: false,
727
+ listType: _restApi.RestrictionType.ALLOW
728
+ },
729
+ restrictions: (((_emailDomainRestricti9 = emailDomainRestrictionsState.data) == null ? void 0 : _emailDomainRestricti9.restrictions) || []).filter(restriction => restriction.id === id)
730
+ },
731
+ saving: false
732
+ }));
733
+ }
734
+
472
735
  function* restrictionsSagaMock() {
473
736
  yield (0, _effects.takeLeading)(_reducer.actions.loadIpRestrictions, loadIpRestrictionsMock);
737
+ yield (0, _effects.takeLeading)(_reducer.actions.loadEmailDomainRestrictions, loadEmailDomainRestrictionsMock);
474
738
  yield (0, _effects.takeEvery)(_reducer.actions.saveIpRestriction, saveIpRestrictionMock);
475
739
  yield (0, _effects.takeEvery)(_reducer.actions.saveIpRestrictionsConfig, saveIpRestrictionsConfigMock);
476
740
  yield (0, _effects.takeEvery)(_reducer.actions.deleteIpRestriction, deleteIpRestrictionMock);
477
741
  yield (0, _effects.takeEvery)(_reducer.actions.checkIfUserIpValid, checkIfUserIpValidMock);
478
- }
742
+ yield (0, _effects.takeEvery)(_reducer.actions.saveEmailDomainRestriction, saveEmailDomainRestrictionMock);
743
+ yield (0, _effects.takeEvery)(_reducer.actions.saveEmailDomainRestrictionsConfig, saveEmailDomainRestrictionConfigMock);
744
+ yield (0, _effects.takeEvery)(_reducer.actions.deleteEmailDomainRestriction, deleteEmailDomainRestrictionMock);
745
+ } // export function* restrictionsSagas() {
746
+ // yield takeLeading(actions.loadEmailDomainRestrictions, loadEmailDomainRestrictions);
747
+ // yield takeEvery(actions.saveEmailDomainRestriction, saveEmailDomainRestriction);
748
+ // yield takeEvery(actions.saveEmailDomainRestrictionsConfig, saveEmailDomainRestrictionConfig);
749
+ // yield takeEvery(actions.deleteEmailDomainRestriction, deleteEmailDomainRestriction);
750
+ // }
751
+ // /*********************************
752
+ // * Preview Sagas
753
+ // *********************************/
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.34.0
1
+ /** @license Frontegg v6.35.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.
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
- "version": "6.34.0",
3
+ "version": "6.35.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
- "@frontegg/rest-api": "3.0.30",
9
+ "@frontegg/rest-api": "3.0.31",
10
10
  "@reduxjs/toolkit": "^1.8.5",
11
11
  "redux-saga": "^1.2.1",
12
12
  "uuid": "^8.3.2"
@@ -15,7 +15,7 @@ export interface RootState {
15
15
  urlStrategy: 'hash' | 'path';
16
16
  previewMode?: boolean;
17
17
  }
18
- export declare const createFronteggStore: (rootInitialState: InitialState, storeHolder?: any, previewMode?: boolean, authInitialState?: (Partial<Pick<AuthState, "user" | "error" | "onRedirectTo" | "isAuthenticated" | "userIp" | "isLoading" | "keepSessionAlive" | "isSSOAuth" | "ssoACS" | "loginState" | "activateState" | "acceptInvitationState" | "forgotPasswordState" | "resetPhoneNumberState" | "ssoState" | "profileState" | "mfaState" | "teamState" | "socialLoginState" | "signUpState" | "apiTokensState" | "securityPolicyState" | "accountSettingsState" | "tenantsState" | "rolesState" | "sessionsState" | "hostedLoginBox" | "disableSilentRefresh" | "sessionsPolicyState" | "restrictionsState" | "header" | "loaderComponent">> & {
18
+ export declare const createFronteggStore: (rootInitialState: InitialState, storeHolder?: any, previewMode?: boolean, authInitialState?: (Partial<Pick<AuthState, "user" | "error" | "onRedirectTo" | "isAuthenticated" | "userIp" | "isLoading" | "keepSessionAlive" | "isSSOAuth" | "ssoACS" | "loginState" | "activateState" | "acceptInvitationState" | "forgotPasswordState" | "resetPhoneNumberState" | "ssoState" | "profileState" | "mfaState" | "teamState" | "socialLoginState" | "signUpState" | "apiTokensState" | "securityPolicyState" | "restrictionsState" | "accountSettingsState" | "tenantsState" | "rolesState" | "sessionsState" | "hostedLoginBox" | "disableSilentRefresh" | "sessionsPolicyState" | "header" | "loaderComponent">> & {
19
19
  routes?: Partial<AuthPageRoutes> | undefined;
20
20
  }) | undefined, overrideInitialState?: Partial<{
21
21
  auth: Partial<Omit<AuthState, 'routes'>> & {