@frontegg/redux-store 6.7.0 → 6.8.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/AcceptInvitationState/index.d.ts +4 -0
- package/auth/AccountSettingsState/index.d.ts +12 -0
- package/auth/ActivateState/index.d.ts +9 -12
- package/auth/ApiTokensState/index.d.ts +4 -0
- package/auth/ForgotPasswordState/index.d.ts +4 -0
- package/auth/LoginState/index.d.ts +10 -0
- package/auth/LoginState/index.js +3 -0
- package/auth/LoginState/saga.js +39 -1
- package/auth/MfaState/index.d.ts +6 -8
- package/auth/ProfileState/index.d.ts +4 -0
- package/auth/ResetPhoneNumberState/index.d.ts +4 -0
- package/auth/RestrictionsState/index.d.ts +124 -0
- package/auth/RestrictionsState/index.js +49 -0
- package/auth/RestrictionsState/interfaces.d.ts +14 -0
- package/auth/RestrictionsState/interfaces.js +1 -0
- package/auth/RestrictionsState/saga.d.ts +2 -0
- package/auth/RestrictionsState/saga.js +464 -0
- package/auth/RolesState/index.d.ts +4 -0
- package/auth/SSOState/index.d.ts +4 -0
- package/auth/SecurityPolicyState/index.d.ts +22 -0
- package/auth/SessionsPolicyState/index.d.ts +4 -0
- package/auth/SessionsState/index.d.ts +4 -8
- package/auth/SignUp/index.d.ts +4 -0
- package/auth/SocialLogins/index.d.ts +4 -0
- package/auth/TeamState/index.d.ts +4 -0
- package/auth/TenantsState/index.d.ts +4 -0
- package/auth/dummy.d.ts +3 -1
- package/auth/dummy.js +39 -2
- package/auth/index.d.ts +23 -0
- package/auth/index.js +2 -0
- package/auth/initialState.js +3 -1
- package/auth/interfaces.d.ts +3 -0
- package/auth/reducer.d.ts +23 -1
- package/auth/reducer.js +3 -2
- package/auth/saga.js +3 -2
- package/auth/utils.d.ts +8 -0
- package/index.js +1 -1
- package/node/auth/LoginState/index.js +3 -0
- package/node/auth/LoginState/saga.js +38 -0
- package/node/auth/RestrictionsState/index.js +62 -0
- package/node/auth/RestrictionsState/interfaces.js +5 -0
- package/node/auth/RestrictionsState/saga.js +478 -0
- package/node/auth/dummy.js +41 -2
- package/node/auth/index.js +28 -0
- package/node/auth/initialState.js +4 -1
- package/node/auth/reducer.js +4 -2
- package/node/auth/saga.js +4 -2
- package/node/index.js +1 -1
- package/package.json +2 -2
- package/toolkit/index.d.ts +1 -1
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.restrictionsState = exports.restrictionsReducers = exports.restrictionsActions = void 0;
|
|
7
|
+
|
|
8
|
+
var _toolkit = require("@reduxjs/toolkit");
|
|
9
|
+
|
|
10
|
+
var _utils = require("../utils");
|
|
11
|
+
|
|
12
|
+
var _constants = require("../../constants");
|
|
13
|
+
|
|
14
|
+
var _restApi = require("@frontegg/rest-api");
|
|
15
|
+
|
|
16
|
+
const restrictionsState = {
|
|
17
|
+
ipRestrictions: {
|
|
18
|
+
loading: false,
|
|
19
|
+
pagination: {
|
|
20
|
+
_offset: 0,
|
|
21
|
+
_limit: 4,
|
|
22
|
+
_filter: _restApi.RestrictionType.ALLOW
|
|
23
|
+
},
|
|
24
|
+
totalPages: 1,
|
|
25
|
+
userIpValid: false
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
exports.restrictionsState = restrictionsState;
|
|
29
|
+
const reducers = {
|
|
30
|
+
setRestrictionsState: (0, _utils.typeReducerForKey)('restrictionsState'),
|
|
31
|
+
setIpRestrictionsState: (0, _utils.typeReducerNestedKey)('restrictionsState', 'ipRestrictions')
|
|
32
|
+
};
|
|
33
|
+
exports.restrictionsReducers = reducers;
|
|
34
|
+
const actions = {
|
|
35
|
+
checkIfUserIpValid: (0, _toolkit.createAction)(`${_constants.authStoreName}/checkIfUserIpValid`),
|
|
36
|
+
addCurrentUserIpAndActivate: (0, _toolkit.createAction)(`${_constants.authStoreName}/addCurrentUserIpAndActivate`, payload => ({
|
|
37
|
+
payload
|
|
38
|
+
})),
|
|
39
|
+
loadIpRestrictions: (0, _toolkit.createAction)(`${_constants.authStoreName}/loadIpRestrictions`),
|
|
40
|
+
saveIpRestriction: (0, _toolkit.createAction)(`${_constants.authStoreName}/saveIpRestriction`, payload => ({
|
|
41
|
+
payload
|
|
42
|
+
})),
|
|
43
|
+
saveIpRestrictionsConfig: (0, _toolkit.createAction)(`${_constants.authStoreName}/saveIpRestrictionsConfig`, payload => ({
|
|
44
|
+
payload
|
|
45
|
+
})),
|
|
46
|
+
deleteIpRestriction: (0, _toolkit.createAction)(`${_constants.authStoreName}/deleteIpRestriction`, payload => ({
|
|
47
|
+
payload
|
|
48
|
+
}))
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* To be used for actions types after dispatch, and should contains
|
|
52
|
+
* the reducers and actions as standalone function
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
exports.restrictionsActions = actions;
|
|
56
|
+
// noinspection JSUnusedLocalSymbols
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* if you see error in matcher that's mean the DispatchAction does not
|
|
60
|
+
* contains the same functions in reducers and actions
|
|
61
|
+
*/
|
|
62
|
+
const Matcher = {};
|
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.restrictionsSagaMock = restrictionsSagaMock;
|
|
9
|
+
exports.restrictionsSagas = restrictionsSagas;
|
|
10
|
+
|
|
11
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
12
|
+
|
|
13
|
+
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
14
|
+
|
|
15
|
+
var _effects = require("redux-saga/effects");
|
|
16
|
+
|
|
17
|
+
var _restApi = require("@frontegg/rest-api");
|
|
18
|
+
|
|
19
|
+
var _reducer = require("../reducer");
|
|
20
|
+
|
|
21
|
+
var _constants = require("../../constants");
|
|
22
|
+
|
|
23
|
+
var _dummy = require("../dummy");
|
|
24
|
+
|
|
25
|
+
const _excluded = ["callback"],
|
|
26
|
+
_excluded2 = ["callback"],
|
|
27
|
+
_excluded3 = ["callback"],
|
|
28
|
+
_excluded4 = ["callback"];
|
|
29
|
+
|
|
30
|
+
const selectIpRestrictionsState = () => (0, _effects.select)(_ => _[_constants.authStoreName].restrictionsState.ipRestrictions);
|
|
31
|
+
|
|
32
|
+
const selectUserIp = () => (0, _effects.select)(_ => _[_constants.authStoreName].userIp);
|
|
33
|
+
|
|
34
|
+
const getPagination = statePagination => {
|
|
35
|
+
var _statePagination$_fil, _statePagination$_lim, _statePagination$_off;
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
_filter: (_statePagination$_fil = statePagination == null ? void 0 : statePagination._filter) != null ? _statePagination$_fil : _restApi.RestrictionType.ALLOW,
|
|
39
|
+
_limit: (_statePagination$_lim = statePagination == null ? void 0 : statePagination._limit) != null ? _statePagination$_lim : 10,
|
|
40
|
+
_offset: (_statePagination$_off = statePagination == null ? void 0 : statePagination._offset) != null ? _statePagination$_off : 0
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function* loadIpRestrictions() {
|
|
45
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
46
|
+
loading: true,
|
|
47
|
+
error: null
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const ipRestrictionState = yield selectIpRestrictionsState();
|
|
52
|
+
const restrictionsConfig = yield (0, _effects.call)(_restApi.api.auth.getIPRestrictionsConfig);
|
|
53
|
+
const pagination = getPagination({
|
|
54
|
+
_filter: restrictionsConfig.strategy,
|
|
55
|
+
_limit: ipRestrictionState.pagination._limit,
|
|
56
|
+
_offset: ipRestrictionState.pagination._offset
|
|
57
|
+
});
|
|
58
|
+
const {
|
|
59
|
+
items: restrictions,
|
|
60
|
+
_metadata: {
|
|
61
|
+
totalPages
|
|
62
|
+
}
|
|
63
|
+
} = yield (0, _effects.call)(_restApi.api.auth.getIPRestrictions, pagination);
|
|
64
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
65
|
+
data: {
|
|
66
|
+
restrictions: restrictions,
|
|
67
|
+
config: restrictionsConfig
|
|
68
|
+
},
|
|
69
|
+
totalPages,
|
|
70
|
+
pagination,
|
|
71
|
+
loading: false
|
|
72
|
+
}));
|
|
73
|
+
} catch (e) {
|
|
74
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
75
|
+
error: e.message,
|
|
76
|
+
loading: false
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function* checkIfUserIpValid() {
|
|
82
|
+
try {
|
|
83
|
+
const {
|
|
84
|
+
valid: userIpValid
|
|
85
|
+
} = yield (0, _effects.call)(_restApi.api.auth.testCurrentIpInAllowList);
|
|
86
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
87
|
+
userIpValid
|
|
88
|
+
}));
|
|
89
|
+
} catch (e) {
|
|
90
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
91
|
+
error: e.message
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function* addCurrentUserIpAndActivate({
|
|
97
|
+
payload: {
|
|
98
|
+
callback
|
|
99
|
+
}
|
|
100
|
+
}) {
|
|
101
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
102
|
+
saving: true,
|
|
103
|
+
error: null
|
|
104
|
+
}));
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
const userIp = yield selectUserIp();
|
|
108
|
+
yield (0, _effects.all)([(0, _effects.call)(_restApi.api.auth.createIPRestriction, {
|
|
109
|
+
ip: userIp,
|
|
110
|
+
isActive: true,
|
|
111
|
+
description: 'My IP',
|
|
112
|
+
strategy: _restApi.RestrictionType.ALLOW
|
|
113
|
+
}), (0, _effects.call)(_restApi.api.auth.updateIPRestrictionConfig, {
|
|
114
|
+
isActive: true
|
|
115
|
+
})]);
|
|
116
|
+
const ipRestrictionState = yield selectIpRestrictionsState();
|
|
117
|
+
const pagination = getPagination(ipRestrictionState.pagination);
|
|
118
|
+
const {
|
|
119
|
+
items: restrictions,
|
|
120
|
+
_metadata: {
|
|
121
|
+
totalPages
|
|
122
|
+
}
|
|
123
|
+
} = yield (0, _effects.call)(_restApi.api.auth.getIPRestrictions, pagination);
|
|
124
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
125
|
+
data: {
|
|
126
|
+
config: {
|
|
127
|
+
isActive: true,
|
|
128
|
+
strategy: _restApi.RestrictionType.ALLOW
|
|
129
|
+
},
|
|
130
|
+
restrictions
|
|
131
|
+
},
|
|
132
|
+
userIpValid: true,
|
|
133
|
+
pagination,
|
|
134
|
+
totalPages,
|
|
135
|
+
saving: false
|
|
136
|
+
}));
|
|
137
|
+
callback == null ? void 0 : callback(true);
|
|
138
|
+
} catch (e) {
|
|
139
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
140
|
+
saving: false,
|
|
141
|
+
error: e
|
|
142
|
+
}));
|
|
143
|
+
callback == null ? void 0 : callback(false, e);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function* saveIpRestriction(_ref) {
|
|
148
|
+
let {
|
|
149
|
+
payload: {
|
|
150
|
+
callback
|
|
151
|
+
}
|
|
152
|
+
} = _ref,
|
|
153
|
+
newRestriction = (0, _objectWithoutPropertiesLoose2.default)(_ref.payload, _excluded);
|
|
154
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
155
|
+
saving: true,
|
|
156
|
+
error: null
|
|
157
|
+
}));
|
|
158
|
+
const ipRestrictionsState = yield selectIpRestrictionsState();
|
|
159
|
+
|
|
160
|
+
try {
|
|
161
|
+
var _ipRestrictionsState$, _ipRestrictionsState$2;
|
|
162
|
+
|
|
163
|
+
yield (0, _effects.call)(_restApi.api.auth.createIPRestriction, newRestriction);
|
|
164
|
+
const ipRestrictionState = yield selectIpRestrictionsState();
|
|
165
|
+
const pagination = getPagination(ipRestrictionState.pagination);
|
|
166
|
+
const {
|
|
167
|
+
items: restrictions,
|
|
168
|
+
_metadata: {
|
|
169
|
+
totalPages
|
|
170
|
+
}
|
|
171
|
+
} = yield (0, _effects.call)(_restApi.api.auth.getIPRestrictions, pagination);
|
|
172
|
+
yield checkIfUserIpValid();
|
|
173
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
174
|
+
data: {
|
|
175
|
+
config: (_ipRestrictionsState$ = (_ipRestrictionsState$2 = ipRestrictionsState.data) == null ? void 0 : _ipRestrictionsState$2.config) != null ? _ipRestrictionsState$ : {
|
|
176
|
+
isActive: false,
|
|
177
|
+
strategy: _restApi.RestrictionType.ALLOW
|
|
178
|
+
},
|
|
179
|
+
restrictions
|
|
180
|
+
},
|
|
181
|
+
pagination,
|
|
182
|
+
totalPages,
|
|
183
|
+
saving: false
|
|
184
|
+
}));
|
|
185
|
+
callback == null ? void 0 : callback(true);
|
|
186
|
+
} catch (e) {
|
|
187
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
188
|
+
saving: false,
|
|
189
|
+
error: e.message
|
|
190
|
+
}));
|
|
191
|
+
callback == null ? void 0 : callback(null, e);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function* saveIpRestrictionsConfig(_ref2) {
|
|
196
|
+
let {
|
|
197
|
+
payload: {
|
|
198
|
+
callback
|
|
199
|
+
}
|
|
200
|
+
} = _ref2,
|
|
201
|
+
config = (0, _objectWithoutPropertiesLoose2.default)(_ref2.payload, _excluded2);
|
|
202
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
203
|
+
saving: true,
|
|
204
|
+
error: null
|
|
205
|
+
}));
|
|
206
|
+
|
|
207
|
+
try {
|
|
208
|
+
yield (0, _effects.call)(_restApi.api.auth.updateIPRestrictionConfig, config);
|
|
209
|
+
const ipRestrictionState = yield selectIpRestrictionsState();
|
|
210
|
+
const restrictionsConfig = yield (0, _effects.call)(_restApi.api.auth.getIPRestrictionsConfig);
|
|
211
|
+
const pagination = getPagination((0, _extends2.default)({}, ipRestrictionState.pagination, {
|
|
212
|
+
_filter: restrictionsConfig.strategy
|
|
213
|
+
}));
|
|
214
|
+
const {
|
|
215
|
+
items: restrictions,
|
|
216
|
+
_metadata: {
|
|
217
|
+
totalPages
|
|
218
|
+
}
|
|
219
|
+
} = yield (0, _effects.call)(_restApi.api.auth.getIPRestrictions, pagination);
|
|
220
|
+
yield checkIfUserIpValid();
|
|
221
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
222
|
+
data: {
|
|
223
|
+
config: restrictionsConfig,
|
|
224
|
+
restrictions
|
|
225
|
+
},
|
|
226
|
+
pagination,
|
|
227
|
+
totalPages,
|
|
228
|
+
saving: false
|
|
229
|
+
}));
|
|
230
|
+
callback == null ? void 0 : callback(true);
|
|
231
|
+
} catch (e) {
|
|
232
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
233
|
+
saving: false,
|
|
234
|
+
error: e.message
|
|
235
|
+
}));
|
|
236
|
+
callback == null ? void 0 : callback(null, e);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function* deleteIpRestriction({
|
|
241
|
+
payload: {
|
|
242
|
+
id,
|
|
243
|
+
callback
|
|
244
|
+
}
|
|
245
|
+
}) {
|
|
246
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
247
|
+
saving: true,
|
|
248
|
+
error: null
|
|
249
|
+
}));
|
|
250
|
+
const ipRestrictionsState = yield selectIpRestrictionsState();
|
|
251
|
+
|
|
252
|
+
try {
|
|
253
|
+
var _ipRestrictionsState$3;
|
|
254
|
+
|
|
255
|
+
yield (0, _effects.call)(_restApi.api.auth.deleteIPRestriction, id);
|
|
256
|
+
const ipRestrictionState = yield selectIpRestrictionsState();
|
|
257
|
+
const pagination = getPagination(ipRestrictionState.pagination);
|
|
258
|
+
const {
|
|
259
|
+
items: restrictions,
|
|
260
|
+
_metadata: {
|
|
261
|
+
totalPages
|
|
262
|
+
}
|
|
263
|
+
} = yield (0, _effects.call)(_restApi.api.auth.getIPRestrictions, pagination);
|
|
264
|
+
yield checkIfUserIpValid();
|
|
265
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
266
|
+
data: {
|
|
267
|
+
config: ((_ipRestrictionsState$3 = ipRestrictionsState.data) == null ? void 0 : _ipRestrictionsState$3.config) || {
|
|
268
|
+
isActive: false,
|
|
269
|
+
strategy: _restApi.RestrictionType.ALLOW
|
|
270
|
+
},
|
|
271
|
+
restrictions
|
|
272
|
+
},
|
|
273
|
+
pagination,
|
|
274
|
+
totalPages,
|
|
275
|
+
saving: false
|
|
276
|
+
}));
|
|
277
|
+
callback == null ? void 0 : callback(true);
|
|
278
|
+
} catch (e) {
|
|
279
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
280
|
+
saving: false,
|
|
281
|
+
error: e.message
|
|
282
|
+
}));
|
|
283
|
+
callback == null ? void 0 : callback(null, e);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function* restrictionsSagas() {
|
|
288
|
+
yield (0, _effects.takeLeading)(_reducer.actions.loadIpRestrictions, loadIpRestrictions);
|
|
289
|
+
yield (0, _effects.takeEvery)(_reducer.actions.saveIpRestriction, saveIpRestriction);
|
|
290
|
+
yield (0, _effects.takeEvery)(_reducer.actions.saveIpRestrictionsConfig, saveIpRestrictionsConfig);
|
|
291
|
+
yield (0, _effects.takeEvery)(_reducer.actions.deleteIpRestriction, deleteIpRestriction);
|
|
292
|
+
yield (0, _effects.takeEvery)(_reducer.actions.checkIfUserIpValid, checkIfUserIpValid);
|
|
293
|
+
yield (0, _effects.takeEvery)(_reducer.actions.addCurrentUserIpAndActivate, addCurrentUserIpAndActivate);
|
|
294
|
+
}
|
|
295
|
+
/*********************************
|
|
296
|
+
* Preview Sagas
|
|
297
|
+
*********************************/
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
function* loadIpRestrictionsMock() {
|
|
301
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
302
|
+
loading: true,
|
|
303
|
+
error: null
|
|
304
|
+
}));
|
|
305
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
306
|
+
data: {
|
|
307
|
+
restrictions: _dummy.dummyIps.filter(ip => ip.strategy === _dummy.dummyIpConfig.strategy),
|
|
308
|
+
config: _dummy.dummyIpConfig
|
|
309
|
+
},
|
|
310
|
+
totalPages: 1,
|
|
311
|
+
pagination: {
|
|
312
|
+
_filter: _restApi.RestrictionType.ALLOW,
|
|
313
|
+
_limit: 50,
|
|
314
|
+
_offset: 0
|
|
315
|
+
},
|
|
316
|
+
loading: false
|
|
317
|
+
}));
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function* checkIfUserIpValidMock() {
|
|
321
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
322
|
+
loading: true,
|
|
323
|
+
error: null
|
|
324
|
+
}));
|
|
325
|
+
|
|
326
|
+
try {
|
|
327
|
+
const ipRestrictionState = yield selectIpRestrictionsState();
|
|
328
|
+
const userIp = _dummy.dummyIps[0].ip;
|
|
329
|
+
const userIpValid = !!ipRestrictionState.data.restrictions.find(restriction => restriction.isActive && restriction.ip === userIp);
|
|
330
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
331
|
+
userIpValid,
|
|
332
|
+
loading: false
|
|
333
|
+
}));
|
|
334
|
+
} catch (e) {
|
|
335
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
336
|
+
error: e.message,
|
|
337
|
+
loading: false
|
|
338
|
+
}));
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
function* saveIpRestrictionMock(_ref3) {
|
|
343
|
+
var _ipRestrictionsState$4, _ipRestrictionsState$5;
|
|
344
|
+
|
|
345
|
+
let {
|
|
346
|
+
payload: {
|
|
347
|
+
callback
|
|
348
|
+
}
|
|
349
|
+
} = _ref3,
|
|
350
|
+
newRestriction = (0, _objectWithoutPropertiesLoose2.default)(_ref3.payload, _excluded3);
|
|
351
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
352
|
+
saving: true,
|
|
353
|
+
error: null
|
|
354
|
+
}));
|
|
355
|
+
const ipRestrictionsState = yield selectIpRestrictionsState();
|
|
356
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
357
|
+
data: {
|
|
358
|
+
config: (_ipRestrictionsState$4 = (_ipRestrictionsState$5 = ipRestrictionsState.data) == null ? void 0 : _ipRestrictionsState$5.config) != null ? _ipRestrictionsState$4 : {
|
|
359
|
+
isActive: false,
|
|
360
|
+
strategy: _restApi.RestrictionType.ALLOW
|
|
361
|
+
},
|
|
362
|
+
restrictions: [...ipRestrictionsState.data.restrictions, (0, _extends2.default)({}, newRestriction, {
|
|
363
|
+
createdAt: new Date(),
|
|
364
|
+
updatedAt: new Date(),
|
|
365
|
+
id: '123',
|
|
366
|
+
isActive: true,
|
|
367
|
+
strategy: ipRestrictionsState.data.config.strategy
|
|
368
|
+
})]
|
|
369
|
+
},
|
|
370
|
+
totalPages: 1,
|
|
371
|
+
pagination: {
|
|
372
|
+
_filter: _restApi.RestrictionType.ALLOW,
|
|
373
|
+
_limit: 50,
|
|
374
|
+
_offset: 0
|
|
375
|
+
},
|
|
376
|
+
saving: false
|
|
377
|
+
}));
|
|
378
|
+
callback == null ? void 0 : callback(true);
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function* saveIpRestrictionsConfigMock(_ref4) {
|
|
382
|
+
let {
|
|
383
|
+
payload: {
|
|
384
|
+
callback
|
|
385
|
+
}
|
|
386
|
+
} = _ref4,
|
|
387
|
+
config = (0, _objectWithoutPropertiesLoose2.default)(_ref4.payload, _excluded4);
|
|
388
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
389
|
+
saving: true,
|
|
390
|
+
error: null
|
|
391
|
+
}));
|
|
392
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
393
|
+
data: {
|
|
394
|
+
config,
|
|
395
|
+
restrictions: _dummy.dummyIps.filter(ip => ip.strategy === config.strategy)
|
|
396
|
+
},
|
|
397
|
+
pagination: {
|
|
398
|
+
_filter: _restApi.RestrictionType.ALLOW,
|
|
399
|
+
_limit: 50,
|
|
400
|
+
_offset: 0
|
|
401
|
+
},
|
|
402
|
+
totalPages: 1,
|
|
403
|
+
saving: false
|
|
404
|
+
}));
|
|
405
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
406
|
+
saving: false,
|
|
407
|
+
error: null
|
|
408
|
+
}));
|
|
409
|
+
callback == null ? void 0 : callback(true);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function* deleteIpRestrictionMock({
|
|
413
|
+
payload: {
|
|
414
|
+
id
|
|
415
|
+
}
|
|
416
|
+
}) {
|
|
417
|
+
var _ipRestrictionsState$6;
|
|
418
|
+
|
|
419
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
420
|
+
saving: true,
|
|
421
|
+
error: null
|
|
422
|
+
}));
|
|
423
|
+
const ipRestrictionsState = yield selectIpRestrictionsState();
|
|
424
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
425
|
+
data: {
|
|
426
|
+
config: ((_ipRestrictionsState$6 = ipRestrictionsState.data) == null ? void 0 : _ipRestrictionsState$6.config) || {
|
|
427
|
+
isActive: false,
|
|
428
|
+
strategy: _restApi.RestrictionType.ALLOW
|
|
429
|
+
},
|
|
430
|
+
restrictions: ipRestrictionsState.data.restrictions.filter(ip => ip.id !== id)
|
|
431
|
+
},
|
|
432
|
+
pagination: {
|
|
433
|
+
_filter: _restApi.RestrictionType.ALLOW,
|
|
434
|
+
_limit: 50,
|
|
435
|
+
_offset: 0
|
|
436
|
+
},
|
|
437
|
+
totalPages: 1,
|
|
438
|
+
saving: false
|
|
439
|
+
}));
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function* addCurrentUserIpAndActivateMock({
|
|
443
|
+
payload: {
|
|
444
|
+
callback
|
|
445
|
+
}
|
|
446
|
+
}) {
|
|
447
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
448
|
+
saving: true,
|
|
449
|
+
error: null
|
|
450
|
+
}));
|
|
451
|
+
|
|
452
|
+
try {
|
|
453
|
+
const userIp = yield selectUserIp();
|
|
454
|
+
yield (0, _effects.put)(_reducer.actions.saveIpRestriction({
|
|
455
|
+
ip: userIp,
|
|
456
|
+
description: 'My IP',
|
|
457
|
+
isActive: true
|
|
458
|
+
}));
|
|
459
|
+
yield (0, _effects.put)(_reducer.actions.saveIpRestrictionsConfig({
|
|
460
|
+
isActive: true
|
|
461
|
+
}));
|
|
462
|
+
callback == null ? void 0 : callback(true);
|
|
463
|
+
} catch (e) {
|
|
464
|
+
yield (0, _effects.put)(_reducer.actions.setIpRestrictionsState({
|
|
465
|
+
saving: false,
|
|
466
|
+
error: e
|
|
467
|
+
}));
|
|
468
|
+
callback == null ? void 0 : callback(false, e);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function* restrictionsSagaMock() {
|
|
473
|
+
yield (0, _effects.takeLeading)(_reducer.actions.loadIpRestrictions, loadIpRestrictionsMock);
|
|
474
|
+
yield (0, _effects.takeEvery)(_reducer.actions.saveIpRestriction, saveIpRestrictionMock);
|
|
475
|
+
yield (0, _effects.takeEvery)(_reducer.actions.saveIpRestrictionsConfig, saveIpRestrictionsConfigMock);
|
|
476
|
+
yield (0, _effects.takeEvery)(_reducer.actions.deleteIpRestriction, deleteIpRestrictionMock);
|
|
477
|
+
yield (0, _effects.takeEvery)(_reducer.actions.checkIfUserIpValid, checkIfUserIpValidMock);
|
|
478
|
+
}
|
package/node/auth/dummy.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.usersDemo = exports.userTeamDemo2 = exports.userTeamDemo = exports.userSubTenantDemo = exports.userProfileDemo = exports.userDemo = exports.tenantsDemo = exports.ssoStateDemo = exports.sessionsMock = exports.sessionsConfigDummies = exports.samlMetadataDemo = exports.samlConfigurationDemo = exports.rolesDemo = exports.rolePermissionDemo = exports.roleDemo = exports.publicSecurityPolicy = exports.profileStateDemo = exports.policyPasswordHistoryDemo = exports.policyMfaDemo = exports.policyLockoutDemo = exports.policyDemo = exports.permissionsDemo = exports.apiTokensDataTenantDemo = exports.apiTokensDataDemo = exports.allUsersDemo = void 0;
|
|
8
|
+
exports.usersDemo = exports.userTeamDemo2 = exports.userTeamDemo = exports.userSubTenantDemo = exports.userProfileDemo = exports.userDemo = exports.tenantsDemo = exports.ssoStateDemo = exports.sessionsMock = exports.sessionsConfigDummies = exports.samlMetadataDemo = exports.samlConfigurationDemo = exports.rolesDemo = exports.rolePermissionDemo = exports.roleDemo = exports.publicSecurityPolicy = exports.profileStateDemo = exports.policyPasswordHistoryDemo = exports.policyMfaDemo = exports.policyLockoutDemo = exports.policyDemo = exports.permissionsDemo = exports.dummyIps = exports.dummyIpConfig = exports.apiTokensDataTenantDemo = exports.apiTokensDataDemo = exports.allUsersDemo = void 0;
|
|
9
9
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
|
|
@@ -316,4 +316,43 @@ const sessionsConfigDummies = {
|
|
|
316
316
|
timeout: 86400
|
|
317
317
|
}
|
|
318
318
|
};
|
|
319
|
-
exports.sessionsConfigDummies = sessionsConfigDummies;
|
|
319
|
+
exports.sessionsConfigDummies = sessionsConfigDummies;
|
|
320
|
+
const dummyIpConfig = {
|
|
321
|
+
isActive: true,
|
|
322
|
+
strategy: _restApi.RestrictionType.ALLOW
|
|
323
|
+
};
|
|
324
|
+
exports.dummyIpConfig = dummyIpConfig;
|
|
325
|
+
const dummyIps = [{
|
|
326
|
+
updatedAt: new Date(),
|
|
327
|
+
createdAt: new Date(),
|
|
328
|
+
id: '1',
|
|
329
|
+
ip: '255.255.255.255',
|
|
330
|
+
isActive: true,
|
|
331
|
+
strategy: _restApi.RestrictionType.ALLOW,
|
|
332
|
+
description: 'My IP'
|
|
333
|
+
}, {
|
|
334
|
+
updatedAt: new Date(),
|
|
335
|
+
createdAt: new Date(),
|
|
336
|
+
id: '2',
|
|
337
|
+
ip: '255.255.255.254',
|
|
338
|
+
isActive: true,
|
|
339
|
+
strategy: _restApi.RestrictionType.ALLOW,
|
|
340
|
+
description: 'IP 2'
|
|
341
|
+
}, {
|
|
342
|
+
updatedAt: new Date(),
|
|
343
|
+
createdAt: new Date(),
|
|
344
|
+
id: '3',
|
|
345
|
+
ip: '255.255.255.253',
|
|
346
|
+
isActive: true,
|
|
347
|
+
strategy: _restApi.RestrictionType.BLOCK,
|
|
348
|
+
description: 'IP 3'
|
|
349
|
+
}, {
|
|
350
|
+
updatedAt: new Date(),
|
|
351
|
+
createdAt: new Date(),
|
|
352
|
+
id: '4',
|
|
353
|
+
ip: '255.255.255.253',
|
|
354
|
+
isActive: true,
|
|
355
|
+
strategy: _restApi.RestrictionType.BLOCK,
|
|
356
|
+
description: 'IP 4'
|
|
357
|
+
}];
|
|
358
|
+
exports.dummyIps = dummyIps;
|
package/node/auth/index.js
CHANGED
|
@@ -574,6 +574,34 @@ Object.keys(_interfaces19).forEach(function (key) {
|
|
|
574
574
|
}
|
|
575
575
|
});
|
|
576
576
|
});
|
|
577
|
+
|
|
578
|
+
var _RestrictionsState = require("./RestrictionsState");
|
|
579
|
+
|
|
580
|
+
Object.keys(_RestrictionsState).forEach(function (key) {
|
|
581
|
+
if (key === "default" || key === "__esModule") return;
|
|
582
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
583
|
+
if (key in exports && exports[key] === _RestrictionsState[key]) return;
|
|
584
|
+
Object.defineProperty(exports, key, {
|
|
585
|
+
enumerable: true,
|
|
586
|
+
get: function () {
|
|
587
|
+
return _RestrictionsState[key];
|
|
588
|
+
}
|
|
589
|
+
});
|
|
590
|
+
});
|
|
591
|
+
|
|
592
|
+
var _interfaces20 = require("./RestrictionsState/interfaces");
|
|
593
|
+
|
|
594
|
+
Object.keys(_interfaces20).forEach(function (key) {
|
|
595
|
+
if (key === "default" || key === "__esModule") return;
|
|
596
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
597
|
+
if (key in exports && exports[key] === _interfaces20[key]) return;
|
|
598
|
+
Object.defineProperty(exports, key, {
|
|
599
|
+
enumerable: true,
|
|
600
|
+
get: function () {
|
|
601
|
+
return _interfaces20[key];
|
|
602
|
+
}
|
|
603
|
+
});
|
|
604
|
+
});
|
|
577
605
|
// export types
|
|
578
606
|
// export store
|
|
579
607
|
var _default = {
|
|
@@ -45,6 +45,8 @@ var _SessionsState = require("./SessionsState");
|
|
|
45
45
|
|
|
46
46
|
var _SessionsPolicyState = require("./SessionsPolicyState");
|
|
47
47
|
|
|
48
|
+
var _RestrictionsState = require("./RestrictionsState");
|
|
49
|
+
|
|
48
50
|
const reinitializeState = {
|
|
49
51
|
isAuthenticated: false,
|
|
50
52
|
isLoading: true,
|
|
@@ -67,7 +69,8 @@ const reinitializeState = {
|
|
|
67
69
|
rolesState: _RolesState.rolesState,
|
|
68
70
|
resetPhoneNumberState: _ResetPhoneNumberState.resetPhoneNumberState,
|
|
69
71
|
sessionsState: _SessionsState.sessionsState,
|
|
70
|
-
sessionsPolicyState: _SessionsPolicyState.sessionsPolicyState
|
|
72
|
+
sessionsPolicyState: _SessionsPolicyState.sessionsPolicyState,
|
|
73
|
+
restrictionsState: _RestrictionsState.restrictionsState
|
|
71
74
|
};
|
|
72
75
|
exports.reinitializeState = reinitializeState;
|
|
73
76
|
const initialState = (0, _extends2.default)({
|
package/node/auth/reducer.js
CHANGED
|
@@ -53,6 +53,8 @@ var _SessionsState = require("./SessionsState");
|
|
|
53
53
|
|
|
54
54
|
var _SessionsPolicyState = require("./SessionsPolicyState");
|
|
55
55
|
|
|
56
|
+
var _RestrictionsState = require("./RestrictionsState");
|
|
57
|
+
|
|
56
58
|
const {
|
|
57
59
|
reducer,
|
|
58
60
|
actions: sliceActions
|
|
@@ -65,8 +67,8 @@ const {
|
|
|
65
67
|
payload
|
|
66
68
|
}) => (0, _extends2.default)({}, state, payload),
|
|
67
69
|
setUser: (0, _utils.typeReducer)('user')
|
|
68
|
-
}, _LoginState.loginReducers, _SocialLogins.socialLoginsReducer, _ActivateState.activateAccountReducers, _AcceptInvitationState.acceptInvitationReducers, _ForgotPasswordState.forgotPasswordReducers, _ResetPhoneNumberState.resetPhoneNumberReducers, _SignUp.signUpReducers, _ProfileState.profileReducers, _SSOState.ssoReducers, _MfaState.mfaReducers, _TeamState.teamReducers, _ApiTokensState.apiTokensReducers, _SecurityPolicyState.securityPolicyReducers, _AccountSettingsState.accountSettingsReducers, _TenantsState.tenantsReducers, _RolesState.rolesReducers, _SessionsState.sessionsReducers, _SessionsPolicyState.sessionsPolicyReducers)
|
|
70
|
+
}, _LoginState.loginReducers, _SocialLogins.socialLoginsReducer, _ActivateState.activateAccountReducers, _AcceptInvitationState.acceptInvitationReducers, _ForgotPasswordState.forgotPasswordReducers, _ResetPhoneNumberState.resetPhoneNumberReducers, _SignUp.signUpReducers, _ProfileState.profileReducers, _SSOState.ssoReducers, _MfaState.mfaReducers, _TeamState.teamReducers, _ApiTokensState.apiTokensReducers, _SecurityPolicyState.securityPolicyReducers, _AccountSettingsState.accountSettingsReducers, _TenantsState.tenantsReducers, _RolesState.rolesReducers, _SessionsState.sessionsReducers, _SessionsPolicyState.sessionsPolicyReducers, _RestrictionsState.restrictionsReducers)
|
|
69
71
|
});
|
|
70
72
|
exports.reducer = reducer;
|
|
71
|
-
const actions = (0, _extends2.default)({}, sliceActions, _LoginState.loginActions, _SocialLogins.socialLoginsActions, _ActivateState.activateAccountActions, _AcceptInvitationState.acceptInvitationActions, _ForgotPasswordState.forgotPasswordActions, _ResetPhoneNumberState.resetPhoneNumberActions, _SignUp.signUpActions, _ProfileState.profileActions, _SSOState.ssoActions, _MfaState.mfaActions, _TeamState.teamActions, _ApiTokensState.apiTokensActions, _SecurityPolicyState.securityPolicyActions, _AccountSettingsState.accountSettingsActions, _TenantsState.tenantsActions, _RolesState.rolesActions, _SessionsState.sessionsActions, _SessionsPolicyState.sessionsPolicyActions);
|
|
73
|
+
const actions = (0, _extends2.default)({}, sliceActions, _LoginState.loginActions, _SocialLogins.socialLoginsActions, _ActivateState.activateAccountActions, _AcceptInvitationState.acceptInvitationActions, _ForgotPasswordState.forgotPasswordActions, _ResetPhoneNumberState.resetPhoneNumberActions, _SignUp.signUpActions, _ProfileState.profileActions, _SSOState.ssoActions, _MfaState.mfaActions, _TeamState.teamActions, _ApiTokensState.apiTokensActions, _SecurityPolicyState.securityPolicyActions, _AccountSettingsState.accountSettingsActions, _TenantsState.tenantsActions, _RolesState.rolesActions, _SessionsState.sessionsActions, _SessionsPolicyState.sessionsPolicyActions, _RestrictionsState.restrictionsActions);
|
|
72
74
|
exports.actions = actions;
|