@frontegg/redux-store 7.56.0-alpha.0 → 7.57.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/Security/SecurityPolicyState/actions.d.ts +2 -2
- package/auth/Security/SecurityPolicyState/actions.js +18 -14
- package/auth/Security/SecurityPolicyState/helpers/helpers.d.ts +12 -0
- package/auth/Security/SecurityPolicyState/helpers/helpers.js +25 -0
- package/auth/Security/SecurityPolicyState/interfaces.d.ts +2 -2
- package/index.js +1 -1
- package/node/auth/Security/SecurityPolicyState/actions.js +18 -14
- package/node/auth/Security/SecurityPolicyState/helpers/helpers.js +31 -0
- package/node/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FronteggState, RestApi, RetryConfig, SharedActions, WithCallback, WithRetryConfig } from '../../../interfaces';
|
|
2
|
-
import { CaptchaPolicyState, GlobalPolicyState, LockoutPolicyState, MfaPolicyState, PasswordHistoryPolicyState, PasswordRotationPolicyState, PasswordPolicyState, PublicAuthStrategyPolicyState, PublicPolicyState, SaveSecurityPolicyLockoutPayload, SaveSecurityPolicyMfaPayload, SaveSecurityPolicyPasswordHistoryPayload, SaveSecurityPolicyPasswordRotationPayload, SecurityPolicyState } from './interfaces';
|
|
3
1
|
import { IAuthStrategiesConfig, IVendorConfig, TestConfig } from '@frontegg/rest-api';
|
|
2
|
+
import { FronteggState, RestApi, RetryConfig, SharedActions, WithCallback, WithRetryConfig } from '../../../interfaces';
|
|
3
|
+
import { CaptchaPolicyState, GlobalPolicyState, LockoutPolicyState, MfaPolicyState, PasswordHistoryPolicyState, PasswordPolicyState, PasswordRotationPolicyState, PublicAuthStrategyPolicyState, PublicPolicyState, SaveSecurityPolicyLockoutPayload, SaveSecurityPolicyMfaPayload, SaveSecurityPolicyPasswordHistoryPayload, SaveSecurityPolicyPasswordRotationPayload, SecurityPolicyState } from './interfaces';
|
|
4
4
|
declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {
|
|
5
5
|
setSecurityPolicyState: (state: Partial<SecurityPolicyState>) => void;
|
|
6
6
|
setSecurityPolicyGlobalState: (state: Partial<GlobalPolicyState>) => void;
|
|
@@ -5,8 +5,8 @@ const _excluded = ["callback"],
|
|
|
5
5
|
_excluded3 = ["callback"],
|
|
6
6
|
_excluded4 = ["callback"];
|
|
7
7
|
import { deepResetState, errorHandler, retryIfNeeded } from '../../../helpers';
|
|
8
|
+
import { getTenantRotationPeriod } from './helpers/helpers';
|
|
8
9
|
import { initialState } from './state';
|
|
9
|
-
import { daysToMinutes, minutesToDays } from './helpers/timeConvertors';
|
|
10
10
|
export default ((store, api, sharedActions) => {
|
|
11
11
|
const actions = sharedActions;
|
|
12
12
|
|
|
@@ -308,15 +308,22 @@ export default ((store, api, sharedActions) => {
|
|
|
308
308
|
error: null
|
|
309
309
|
});
|
|
310
310
|
try {
|
|
311
|
-
const
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
311
|
+
const tenantPasswordRotationConfig = await api.securityPolicy.getPasswordRotationPolicy();
|
|
312
|
+
const vendorPasswordRotationConfig = await api.securityPolicy.getVendorPasswordRotationPolicy();
|
|
313
|
+
const data = {
|
|
314
|
+
passwordRotationVendorConfig: vendorPasswordRotationConfig
|
|
315
|
+
};
|
|
316
|
+
if (tenantPasswordRotationConfig) {
|
|
317
|
+
if (vendorPasswordRotationConfig != null && vendorPasswordRotationConfig.isActive) {
|
|
318
|
+
data.passwordRotationTenantConfig = tenantPasswordRotationConfig != null && tenantPasswordRotationConfig.isActive ? _extends({}, tenantPasswordRotationConfig, {
|
|
319
|
+
rotationPeriod: getTenantRotationPeriod(vendorPasswordRotationConfig.rotationPeriod, tenantPasswordRotationConfig.rotationPeriod)
|
|
320
|
+
}) : vendorPasswordRotationConfig;
|
|
321
|
+
} else {
|
|
322
|
+
data.passwordRotationTenantConfig = tenantPasswordRotationConfig;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
318
325
|
setSecurityPolicyPasswordRotationState({
|
|
319
|
-
policy,
|
|
326
|
+
policy: _extends({}, data),
|
|
320
327
|
loading: false
|
|
321
328
|
});
|
|
322
329
|
} catch (e) {
|
|
@@ -431,15 +438,12 @@ export default ((store, api, sharedActions) => {
|
|
|
431
438
|
error: null
|
|
432
439
|
});
|
|
433
440
|
try {
|
|
434
|
-
|
|
435
|
-
notificationPeriod: daysToMinutes(newSecurityPolicy.notificationPeriod),
|
|
436
|
-
rotationPeriod: daysToMinutes(newSecurityPolicy.rotationPeriod)
|
|
437
|
-
}));
|
|
441
|
+
await api.securityPolicy.savePasswordRotationPolicy(newSecurityPolicy.passwordRotationTenantConfig || {});
|
|
438
442
|
setSecurityPolicyPasswordRotationState({
|
|
439
443
|
policy: newSecurityPolicy,
|
|
440
444
|
saving: false
|
|
441
445
|
});
|
|
442
|
-
callback == null ? void 0 : callback(
|
|
446
|
+
callback == null ? void 0 : callback(newSecurityPolicy);
|
|
443
447
|
} catch (e) {
|
|
444
448
|
setSecurityPolicyPasswordRotationState({
|
|
445
449
|
saving: false,
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the tenant rotation period.
|
|
3
|
+
*
|
|
4
|
+
* Returns the minimum of vendor and tenant rotation periods if both are provided.
|
|
5
|
+
* If only one is provided, returns that one. Returns undefined if neither is provided.
|
|
6
|
+
* This calculation is made to get the stricter of the two rotation periods.
|
|
7
|
+
*
|
|
8
|
+
* @param vendorRotationPeriod - Vendor's rotation period (optional).
|
|
9
|
+
* @param tenantRotationPeriod - Tenant's rotation period (optional).
|
|
10
|
+
* @returns The rotation period, or undefined if neither is provided.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getTenantRotationPeriod(vendorRotationPeriod?: number, tenantRotationPeriod?: number): number | undefined;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates the tenant rotation period.
|
|
3
|
+
*
|
|
4
|
+
* Returns the minimum of vendor and tenant rotation periods if both are provided.
|
|
5
|
+
* If only one is provided, returns that one. Returns undefined if neither is provided.
|
|
6
|
+
* This calculation is made to get the stricter of the two rotation periods.
|
|
7
|
+
*
|
|
8
|
+
* @param vendorRotationPeriod - Vendor's rotation period (optional).
|
|
9
|
+
* @param tenantRotationPeriod - Tenant's rotation period (optional).
|
|
10
|
+
* @returns The rotation period, or undefined if neither is provided.
|
|
11
|
+
*/
|
|
12
|
+
export function getTenantRotationPeriod(vendorRotationPeriod, tenantRotationPeriod) {
|
|
13
|
+
const tenantRotationExists = tenantRotationPeriod !== null && tenantRotationPeriod !== undefined;
|
|
14
|
+
const vendorRotationExists = vendorRotationPeriod !== null && vendorRotationPeriod !== undefined;
|
|
15
|
+
if (!tenantRotationExists && !vendorRotationExists) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!tenantRotationExists) {
|
|
19
|
+
return vendorRotationPeriod;
|
|
20
|
+
}
|
|
21
|
+
if (!vendorRotationExists) {
|
|
22
|
+
return tenantRotationPeriod;
|
|
23
|
+
}
|
|
24
|
+
return Math.min(vendorRotationPeriod, tenantRotationPeriod);
|
|
25
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { IAuthStrategiesConfig, ISaveSecurityPolicyLockout, ISaveSecurityPolicyMfa, ISaveSecurityPolicyPasswordHistory, ISecurityPolicy, ISecurityPolicyCaptcha, ISecurityPolicyLockout, ISecurityPolicyMfa, ISecurityPolicyPasswordConfig, ISecurityPolicyPasswordHistory, ISecurityPolicyPasswordRotation, IVendorConfig } from '@frontegg/rest-api';
|
|
1
2
|
import { WithCallback, WithStatus } from '../../../interfaces';
|
|
2
|
-
import { ISaveSecurityPolicyLockout, ISaveSecurityPolicyMfa, ISaveSecurityPolicyPasswordHistory, ISaveSecurityPolicyPasswordRotation, ISecurityPolicy, ISecurityPolicyCaptcha, ISecurityPolicyLockout, ISecurityPolicyMfa, ISecurityPolicyPasswordHistory, ISecurityPolicyPasswordRotation, ISecurityPolicyPasswordConfig, IVendorConfig, IAuthStrategiesConfig } from '@frontegg/rest-api';
|
|
3
3
|
type PolicyState<T> = WithStatus & {
|
|
4
4
|
policy?: T;
|
|
5
5
|
};
|
|
@@ -29,5 +29,5 @@ export interface SecurityPolicyState {
|
|
|
29
29
|
export type SaveSecurityPolicyMfaPayload = WithCallback<ISaveSecurityPolicyMfa, ISecurityPolicyMfa>;
|
|
30
30
|
export type SaveSecurityPolicyLockoutPayload = WithCallback<ISaveSecurityPolicyLockout, ISecurityPolicyLockout>;
|
|
31
31
|
export type SaveSecurityPolicyPasswordHistoryPayload = WithCallback<ISaveSecurityPolicyPasswordHistory, ISecurityPolicyPasswordHistory>;
|
|
32
|
-
export type SaveSecurityPolicyPasswordRotationPayload = WithCallback<
|
|
32
|
+
export type SaveSecurityPolicyPasswordRotationPayload = WithCallback<ISecurityPolicyPasswordRotation, ISecurityPolicyPasswordRotation>;
|
|
33
33
|
export {};
|
package/index.js
CHANGED
|
@@ -8,8 +8,8 @@ exports.default = void 0;
|
|
|
8
8
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _helpers = require("../../../helpers");
|
|
11
|
+
var _helpers2 = require("./helpers/helpers");
|
|
11
12
|
var _state = require("./state");
|
|
12
|
-
var _timeConvertors = require("./helpers/timeConvertors");
|
|
13
13
|
const _excluded = ["callback"],
|
|
14
14
|
_excluded2 = ["callback"],
|
|
15
15
|
_excluded3 = ["callback"],
|
|
@@ -315,15 +315,22 @@ var _default = (store, api, sharedActions) => {
|
|
|
315
315
|
error: null
|
|
316
316
|
});
|
|
317
317
|
try {
|
|
318
|
-
const
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
318
|
+
const tenantPasswordRotationConfig = await api.securityPolicy.getPasswordRotationPolicy();
|
|
319
|
+
const vendorPasswordRotationConfig = await api.securityPolicy.getVendorPasswordRotationPolicy();
|
|
320
|
+
const data = {
|
|
321
|
+
passwordRotationVendorConfig: vendorPasswordRotationConfig
|
|
322
|
+
};
|
|
323
|
+
if (tenantPasswordRotationConfig) {
|
|
324
|
+
if (vendorPasswordRotationConfig != null && vendorPasswordRotationConfig.isActive) {
|
|
325
|
+
data.passwordRotationTenantConfig = tenantPasswordRotationConfig != null && tenantPasswordRotationConfig.isActive ? (0, _extends2.default)({}, tenantPasswordRotationConfig, {
|
|
326
|
+
rotationPeriod: (0, _helpers2.getTenantRotationPeriod)(vendorPasswordRotationConfig.rotationPeriod, tenantPasswordRotationConfig.rotationPeriod)
|
|
327
|
+
}) : vendorPasswordRotationConfig;
|
|
328
|
+
} else {
|
|
329
|
+
data.passwordRotationTenantConfig = tenantPasswordRotationConfig;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
325
332
|
setSecurityPolicyPasswordRotationState({
|
|
326
|
-
policy,
|
|
333
|
+
policy: (0, _extends2.default)({}, data),
|
|
327
334
|
loading: false
|
|
328
335
|
});
|
|
329
336
|
} catch (e) {
|
|
@@ -438,15 +445,12 @@ var _default = (store, api, sharedActions) => {
|
|
|
438
445
|
error: null
|
|
439
446
|
});
|
|
440
447
|
try {
|
|
441
|
-
|
|
442
|
-
notificationPeriod: (0, _timeConvertors.daysToMinutes)(newSecurityPolicy.notificationPeriod),
|
|
443
|
-
rotationPeriod: (0, _timeConvertors.daysToMinutes)(newSecurityPolicy.rotationPeriod)
|
|
444
|
-
}));
|
|
448
|
+
await api.securityPolicy.savePasswordRotationPolicy(newSecurityPolicy.passwordRotationTenantConfig || {});
|
|
445
449
|
setSecurityPolicyPasswordRotationState({
|
|
446
450
|
policy: newSecurityPolicy,
|
|
447
451
|
saving: false
|
|
448
452
|
});
|
|
449
|
-
callback == null ? void 0 : callback(
|
|
453
|
+
callback == null ? void 0 : callback(newSecurityPolicy);
|
|
450
454
|
} catch (e) {
|
|
451
455
|
setSecurityPolicyPasswordRotationState({
|
|
452
456
|
saving: false,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getTenantRotationPeriod = getTenantRotationPeriod;
|
|
7
|
+
/**
|
|
8
|
+
* Calculates the tenant rotation period.
|
|
9
|
+
*
|
|
10
|
+
* Returns the minimum of vendor and tenant rotation periods if both are provided.
|
|
11
|
+
* If only one is provided, returns that one. Returns undefined if neither is provided.
|
|
12
|
+
* This calculation is made to get the stricter of the two rotation periods.
|
|
13
|
+
*
|
|
14
|
+
* @param vendorRotationPeriod - Vendor's rotation period (optional).
|
|
15
|
+
* @param tenantRotationPeriod - Tenant's rotation period (optional).
|
|
16
|
+
* @returns The rotation period, or undefined if neither is provided.
|
|
17
|
+
*/
|
|
18
|
+
function getTenantRotationPeriod(vendorRotationPeriod, tenantRotationPeriod) {
|
|
19
|
+
const tenantRotationExists = tenantRotationPeriod !== null && tenantRotationPeriod !== undefined;
|
|
20
|
+
const vendorRotationExists = vendorRotationPeriod !== null && vendorRotationPeriod !== undefined;
|
|
21
|
+
if (!tenantRotationExists && !vendorRotationExists) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!tenantRotationExists) {
|
|
25
|
+
return vendorRotationPeriod;
|
|
26
|
+
}
|
|
27
|
+
if (!vendorRotationExists) {
|
|
28
|
+
return tenantRotationPeriod;
|
|
29
|
+
}
|
|
30
|
+
return Math.min(vendorRotationPeriod, tenantRotationPeriod);
|
|
31
|
+
}
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/redux-store",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.57.0-alpha.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.
|
|
10
|
+
"@frontegg/rest-api": "7.57.0-alpha.0",
|
|
11
11
|
"fast-deep-equal": "3.1.3",
|
|
12
12
|
"get-value": "^3.0.1",
|
|
13
13
|
"proxy-compare": "^3.0.0",
|