@frontegg/redux-store 7.75.0 → 7.76.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/LoginState/actions/handleVerifyMFAResponse.actions.js +3 -3
- package/auth/LoginState/actions/index.js +35 -16
- package/auth/LoginState/actions/mfaWithAuthenticator.actions.js +3 -3
- package/auth/LoginState/helpers.d.ts +2 -1
- package/auth/LoginState/helpers.js +4 -1
- package/auth/UsernamesState/actions.d.ts +9 -0
- package/auth/UsernamesState/actions.js +100 -0
- package/auth/UsernamesState/index.d.ts +3 -0
- package/auth/UsernamesState/index.js +3 -0
- package/auth/UsernamesState/interfaces.d.ts +7 -0
- package/auth/UsernamesState/interfaces.js +1 -0
- package/auth/UsernamesState/state.d.ts +4 -0
- package/auth/UsernamesState/state.js +8 -0
- package/auth/index.d.ts +5 -1
- package/auth/index.js +5 -0
- package/auth/interfaces.d.ts +2 -0
- package/index.js +1 -1
- package/mocks/auth-mocks/index.js +4 -1
- package/node/auth/LoginState/actions/handleVerifyMFAResponse.actions.js +3 -3
- package/node/auth/LoginState/actions/index.js +34 -15
- package/node/auth/LoginState/actions/mfaWithAuthenticator.actions.js +3 -3
- package/node/auth/LoginState/helpers.js +7 -2
- package/node/auth/UsernamesState/actions.js +107 -0
- package/node/auth/UsernamesState/index.js +20 -0
- package/node/auth/UsernamesState/interfaces.js +5 -0
- package/node/auth/UsernamesState/state.js +16 -0
- package/node/auth/index.js +18 -2
- package/node/index.js +1 -1
- package/node/mocks/auth-mocks/index.js +4 -1
- package/node/toolkit/FronteggNativeModule.js +3 -3
- package/package.json +2 -2
- package/toolkit/FronteggNativeModule.d.ts +1 -1
- package/toolkit/FronteggNativeModule.js +3 -3
|
@@ -29,7 +29,7 @@ export default function (store, api, sharedActions) {
|
|
|
29
29
|
const postHandleVerifyMFAResponseForLogin = async (isAuthenticated, user) => {
|
|
30
30
|
const loginState = store.auth.loginState;
|
|
31
31
|
const mfaStep = store.auth.mfaState.step;
|
|
32
|
-
const [securityCenterLoginFlows
|
|
32
|
+
const [securityCenterLoginFlows] = await actions.getFeatureFlags(['security-center-show-login-flows']);
|
|
33
33
|
if (loginState.flow === LoginFlow.Login) {
|
|
34
34
|
if (securityCenterLoginFlows && loginState.isBreachedPassword && !isAuthenticated) {
|
|
35
35
|
actions.setLoginState({
|
|
@@ -38,7 +38,7 @@ export default function (store, api, sharedActions) {
|
|
|
38
38
|
});
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
if (
|
|
41
|
+
if (isResetPasswordRequired(user, store.root.appName)) {
|
|
42
42
|
actions.setLoginState({
|
|
43
43
|
step: LoginStep.passwordRotationExpired,
|
|
44
44
|
loading: false,
|
|
@@ -47,7 +47,7 @@ export default function (store, api, sharedActions) {
|
|
|
47
47
|
});
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
if (
|
|
50
|
+
if (shouldShowPasswordRotationPromptFunc(user)) {
|
|
51
51
|
actions.setLoginState({
|
|
52
52
|
step: LoginStep.passwordRotationNotification,
|
|
53
53
|
loading: false
|
|
@@ -25,7 +25,7 @@ import mfaWithWebAuthnActions from './mfaWithWebAuthn.actions';
|
|
|
25
25
|
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
|
-
import { getSearchParam, isEmailPayload, shouldShowPasswordRotationPromptFunc, TENANT_ID_PARAM_KEY } from '../helpers';
|
|
28
|
+
import { getSearchParam, isEmailPayload, isUsernamePayload, shouldShowPasswordRotationPromptFunc, TENANT_ID_PARAM_KEY } from '../helpers';
|
|
29
29
|
import { AuthStrategyEnum, ContextHolder, removeTabTenantFromSessionStorage, WebAuthnDeviceType } from '@frontegg/rest-api';
|
|
30
30
|
import hostedLoginAuthorizeActions from './hostedLoginAuthorize.actions';
|
|
31
31
|
import { FronteggNativeModule, isEntitlementsDeeplyEqual } from '../../../toolkit';
|
|
@@ -347,6 +347,7 @@ export default ((store, api, sharedActions) => {
|
|
|
347
347
|
const preLogin = async payload => {
|
|
348
348
|
const {
|
|
349
349
|
email,
|
|
350
|
+
username,
|
|
350
351
|
recaptchaToken,
|
|
351
352
|
invitationToken,
|
|
352
353
|
callback
|
|
@@ -357,10 +358,13 @@ export default ((store, api, sharedActions) => {
|
|
|
357
358
|
try {
|
|
358
359
|
const onRedirectTo = store.auth.onRedirectTo;
|
|
359
360
|
const tenantId = getSearchParam(TENANT_ID_PARAM_KEY);
|
|
360
|
-
const preLoginResult = await api.auth.preLoginV2({
|
|
361
|
-
email
|
|
361
|
+
const preLoginResult = await api.auth.preLoginV2(_extends({}, email ? {
|
|
362
|
+
email
|
|
363
|
+
} : {}, username ? {
|
|
364
|
+
username
|
|
365
|
+
} : {}, {
|
|
362
366
|
tenantId
|
|
363
|
-
});
|
|
367
|
+
}));
|
|
364
368
|
const {
|
|
365
369
|
address,
|
|
366
370
|
idpType
|
|
@@ -374,7 +378,8 @@ export default ((store, api, sharedActions) => {
|
|
|
374
378
|
ssoRedirectUrl += `&redirect_uri=${window.location.origin}${oidcRedirectUrl}`;
|
|
375
379
|
}
|
|
376
380
|
if (FronteggNativeModule.isLoginWithSSOAvailable()) {
|
|
377
|
-
|
|
381
|
+
var _ref4;
|
|
382
|
+
FronteggNativeModule.loginWithSSO((_ref4 = email != null ? email : username) != null ? _ref4 : '');
|
|
378
383
|
setLoginState({
|
|
379
384
|
loading: false
|
|
380
385
|
});
|
|
@@ -392,16 +397,18 @@ export default ((store, api, sharedActions) => {
|
|
|
392
397
|
}, 2000);
|
|
393
398
|
}
|
|
394
399
|
} else {
|
|
400
|
+
var _ref5;
|
|
395
401
|
await ssoPreloginFailed({
|
|
396
|
-
email,
|
|
402
|
+
email: (_ref5 = email != null ? email : username) != null ? _ref5 : '',
|
|
397
403
|
recaptchaToken,
|
|
398
404
|
callback,
|
|
399
405
|
invitationToken
|
|
400
406
|
});
|
|
401
407
|
}
|
|
402
408
|
} catch (e) {
|
|
409
|
+
var _ref6;
|
|
403
410
|
await ssoPreloginFailed({
|
|
404
|
-
email,
|
|
411
|
+
email: (_ref6 = email != null ? email : username) != null ? _ref6 : '',
|
|
405
412
|
recaptchaToken,
|
|
406
413
|
callback,
|
|
407
414
|
invitationToken,
|
|
@@ -437,6 +444,7 @@ export default ((store, api, sharedActions) => {
|
|
|
437
444
|
const login = async payload => {
|
|
438
445
|
const {
|
|
439
446
|
email,
|
|
447
|
+
username,
|
|
440
448
|
password,
|
|
441
449
|
recaptchaToken,
|
|
442
450
|
invitationToken,
|
|
@@ -450,12 +458,15 @@ export default ((store, api, sharedActions) => {
|
|
|
450
458
|
user,
|
|
451
459
|
tenants = [],
|
|
452
460
|
activeTenant
|
|
453
|
-
} = await api.auth.loginv2({
|
|
454
|
-
email
|
|
461
|
+
} = await api.auth.loginv2(_extends({}, email ? {
|
|
462
|
+
email
|
|
463
|
+
} : {}, username ? {
|
|
464
|
+
username
|
|
465
|
+
} : {}, {
|
|
455
466
|
password,
|
|
456
467
|
recaptchaToken,
|
|
457
468
|
invitationToken
|
|
458
|
-
});
|
|
469
|
+
}));
|
|
459
470
|
const {
|
|
460
471
|
onRedirectTo,
|
|
461
472
|
routes
|
|
@@ -467,8 +478,8 @@ export default ((store, api, sharedActions) => {
|
|
|
467
478
|
preserveQueryParams: true
|
|
468
479
|
});
|
|
469
480
|
} else {
|
|
470
|
-
const [securityCenterLoginFlows
|
|
471
|
-
if (
|
|
481
|
+
const [securityCenterLoginFlows] = await actions.getFeatureFlags(['security-center-show-login-flows']);
|
|
482
|
+
if (isResetPasswordRequired(user, store.root.appName)) {
|
|
472
483
|
setLoginState({
|
|
473
484
|
step: LoginStep.passwordRotationExpired,
|
|
474
485
|
loading: false,
|
|
@@ -509,7 +520,7 @@ export default ((store, api, sharedActions) => {
|
|
|
509
520
|
} else {
|
|
510
521
|
if (isAuthenticated) {
|
|
511
522
|
const shouldShowPasswordRotationPrompt = shouldShowPasswordRotationPromptFunc(user);
|
|
512
|
-
if (
|
|
523
|
+
if (shouldShowPasswordRotationPrompt) {
|
|
513
524
|
setLoginState({
|
|
514
525
|
step: LoginStep.passwordRotationNotification,
|
|
515
526
|
loading: false
|
|
@@ -695,6 +706,7 @@ export default ((store, api, sharedActions) => {
|
|
|
695
706
|
} = _payload,
|
|
696
707
|
payload = _objectWithoutPropertiesLoose(_payload, _excluded5);
|
|
697
708
|
try {
|
|
709
|
+
var _username;
|
|
698
710
|
setLoginState({
|
|
699
711
|
loading: true
|
|
700
712
|
});
|
|
@@ -702,9 +714,16 @@ export default ((store, api, sharedActions) => {
|
|
|
702
714
|
if (isEmailPayload(payload)) {
|
|
703
715
|
email = payload.email;
|
|
704
716
|
}
|
|
717
|
+
let username;
|
|
718
|
+
if (isUsernamePayload(payload)) {
|
|
719
|
+
username = payload.username;
|
|
720
|
+
}
|
|
705
721
|
// TODO: [Typescript 4.8] fix @frontegg/rest-api return value
|
|
706
722
|
// @ts-ignore
|
|
707
|
-
const preloginRes = await api.auth.passwordlessPreLogin(payload
|
|
723
|
+
const preloginRes = await api.auth.passwordlessPreLogin(_extends({}, payload, {
|
|
724
|
+
email,
|
|
725
|
+
username: (_username = username) != null ? _username : ''
|
|
726
|
+
}));
|
|
708
727
|
// @ts-ignore
|
|
709
728
|
const step = authStrategyLoginStepMap[payload.type];
|
|
710
729
|
setLoginState({
|
|
@@ -1296,11 +1315,11 @@ export default ((store, api, sharedActions) => {
|
|
|
1296
1315
|
preserveQueryParams: true
|
|
1297
1316
|
});
|
|
1298
1317
|
} else {
|
|
1299
|
-
var
|
|
1318
|
+
var _ref7;
|
|
1300
1319
|
if (user.id) {
|
|
1301
1320
|
localStorage.setItem('userId', user.id);
|
|
1302
1321
|
}
|
|
1303
|
-
const quickLoginToRegister = (
|
|
1322
|
+
const quickLoginToRegister = (_ref7 = localStorage.getItem('register-quick-login')) != null ? _ref7 : loginState.quickLoginToRegister;
|
|
1304
1323
|
const shouldNavigateToRegisterQuickLogin = __shouldNavigateToRegisterQuickLogin(user);
|
|
1305
1324
|
actions.afterAuthenticationStateUpdate({
|
|
1306
1325
|
user: updatedUser,
|
|
@@ -42,7 +42,7 @@ export default ((store, api, sharedActions) => {
|
|
|
42
42
|
async function __postLoginMfaAuthenticator(isAuthenticated, user, callback) {
|
|
43
43
|
const loginState = store.auth.loginState;
|
|
44
44
|
if (loginState.flow !== LoginFlow.Login) return;
|
|
45
|
-
const [securityCenterLoginFlows
|
|
45
|
+
const [securityCenterLoginFlows] = await actions.getFeatureFlags(['security-center-show-login-flows']);
|
|
46
46
|
if (securityCenterLoginFlows && loginState.isBreachedPassword && !isAuthenticated) {
|
|
47
47
|
actions.setLoginState({
|
|
48
48
|
step: LoginStep.breachedPassword,
|
|
@@ -51,7 +51,7 @@ export default ((store, api, sharedActions) => {
|
|
|
51
51
|
callback == null ? void 0 : callback(true);
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
if (
|
|
54
|
+
if (isResetPasswordRequired(user, store.root.appName)) {
|
|
55
55
|
actions.setLoginState({
|
|
56
56
|
step: LoginStep.passwordRotationExpired,
|
|
57
57
|
loading: false,
|
|
@@ -62,7 +62,7 @@ export default ((store, api, sharedActions) => {
|
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
const shouldShowPasswordRotationPrompt = shouldShowPasswordRotationPromptFunc(user);
|
|
65
|
-
if (
|
|
65
|
+
if (shouldShowPasswordRotationPrompt) {
|
|
66
66
|
actions.setLoginState({
|
|
67
67
|
step: LoginStep.passwordRotationNotification,
|
|
68
68
|
loading: false
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IEmailPasswordlessPreLogin, ILoginResponse, IPasswordlessPreLogin, MFAStrategyEnum, UserMFADevicesResponse } from '@frontegg/rest-api';
|
|
1
|
+
import { IEmailPasswordlessPreLogin, ILoginResponse, IPasswordlessPreLogin, IUsernamePasswordlessPreLogin, MFAStrategyEnum, UserMFADevicesResponse } from '@frontegg/rest-api';
|
|
2
2
|
import { FronteggState } from '../../interfaces';
|
|
3
3
|
import { User } from '../interfaces';
|
|
4
4
|
import { MFAStep } from '../MfaState/interfaces';
|
|
@@ -29,5 +29,6 @@ export declare const getMfaStepForEnrolledUsers: (mfaDevices: UserMFADevicesResp
|
|
|
29
29
|
export declare const getMfaStepForNotEnrolledUsers: (mfaStrategies: MFAStrategyEnum[]) => MFAStep.verify | MFAStep.authenticatorApp | MFAStep.smsSetPhoneNumber | MFAStep.emailVerifyCode;
|
|
30
30
|
export declare const isOauthCallbackRoute: (activeUri: string) => boolean;
|
|
31
31
|
export declare function isEmailPayload(payload: IPasswordlessPreLogin): payload is IEmailPasswordlessPreLogin;
|
|
32
|
+
export declare function isUsernamePayload(payload: IPasswordlessPreLogin): payload is IUsernamePasswordlessPreLogin;
|
|
32
33
|
export declare const getBaseNameWithoutSlashSuffix: (state: FronteggState) => string | null;
|
|
33
34
|
export declare const shouldShowPasswordRotationPromptFunc: (user: ILoginResponse | User) => boolean;
|
|
@@ -124,7 +124,10 @@ export const isOauthCallbackRoute = activeUri => {
|
|
|
124
124
|
return activeUri === '/oauth/callback';
|
|
125
125
|
};
|
|
126
126
|
export function isEmailPayload(payload) {
|
|
127
|
-
return 'email' in payload;
|
|
127
|
+
return 'email' in payload && typeof payload['email'] === 'string';
|
|
128
|
+
}
|
|
129
|
+
export function isUsernamePayload(payload) {
|
|
130
|
+
return 'username' in payload && typeof payload['username'] === 'string';
|
|
128
131
|
}
|
|
129
132
|
export const getBaseNameWithoutSlashSuffix = state => {
|
|
130
133
|
const basename = ContextHolder.for(state.root.appName).getBasename();
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ICreateUsername } from '@frontegg/rest-api/usernames/interfaces';
|
|
2
|
+
import { FronteggState, RestApi, SharedActions, WithCallback } from '../../interfaces';
|
|
3
|
+
declare const _default: (store: FronteggState, api: RestApi, sharedActions: SharedActions) => {
|
|
4
|
+
resetUsernamesState: () => void;
|
|
5
|
+
loadUserOwnUsername: () => Promise<void>;
|
|
6
|
+
saveUserUsername: (payload: WithCallback<ICreateUsername, void>) => Promise<void>;
|
|
7
|
+
deleteUserUsername: (username: string) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { deepResetState, errorHandler } from '../../helpers';
|
|
2
|
+
import { initialState } from './state';
|
|
3
|
+
export default ((store, api, sharedActions) => {
|
|
4
|
+
const setUsernamesState = state => {
|
|
5
|
+
Object.assign(store.auth.usernamesState, state);
|
|
6
|
+
};
|
|
7
|
+
const resetUsernamesState = () => {
|
|
8
|
+
deepResetState(store, ['auth', 'usernamesState'], initialState);
|
|
9
|
+
};
|
|
10
|
+
const loadUserOwnUsername = async () => {
|
|
11
|
+
setUsernamesState({
|
|
12
|
+
loading: true
|
|
13
|
+
});
|
|
14
|
+
try {
|
|
15
|
+
const response = await api.usernames.getUserOwnUsername();
|
|
16
|
+
setUsernamesState({
|
|
17
|
+
username: response == null ? void 0 : response.username,
|
|
18
|
+
loading: false,
|
|
19
|
+
fetching: false
|
|
20
|
+
});
|
|
21
|
+
} catch (e) {
|
|
22
|
+
setUsernamesState({
|
|
23
|
+
error: errorHandler(e),
|
|
24
|
+
fetching: false
|
|
25
|
+
});
|
|
26
|
+
} finally {
|
|
27
|
+
setUsernamesState({
|
|
28
|
+
loading: false,
|
|
29
|
+
fetching: false
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const saveUserUsername = async payload => {
|
|
34
|
+
setUsernamesState({
|
|
35
|
+
loading: true
|
|
36
|
+
});
|
|
37
|
+
try {
|
|
38
|
+
if (store.auth.usernamesState.username === payload.username) {
|
|
39
|
+
var _payload$callback;
|
|
40
|
+
(_payload$callback = payload.callback) == null ? void 0 : _payload$callback.call(payload);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (store.auth.usernamesState.username && store.auth.usernamesState.username !== payload.username) {
|
|
44
|
+
await deleteUserUsername(store.auth.usernamesState.username);
|
|
45
|
+
if (!payload.username) {
|
|
46
|
+
var _payload$callback2;
|
|
47
|
+
setUsernamesState({
|
|
48
|
+
username: undefined,
|
|
49
|
+
loading: false
|
|
50
|
+
});
|
|
51
|
+
(_payload$callback2 = payload.callback) == null ? void 0 : _payload$callback2.call(payload);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!!payload.username) {
|
|
56
|
+
var _payload$callback3;
|
|
57
|
+
await api.usernames.createUsername(payload);
|
|
58
|
+
setUsernamesState({
|
|
59
|
+
username: payload.username,
|
|
60
|
+
loading: false
|
|
61
|
+
});
|
|
62
|
+
(_payload$callback3 = payload.callback) == null ? void 0 : _payload$callback3.call(payload);
|
|
63
|
+
}
|
|
64
|
+
} catch (e) {
|
|
65
|
+
setUsernamesState({
|
|
66
|
+
error: errorHandler(e)
|
|
67
|
+
});
|
|
68
|
+
} finally {
|
|
69
|
+
setUsernamesState({
|
|
70
|
+
loading: false
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const deleteUserUsername = async username => {
|
|
75
|
+
setUsernamesState({
|
|
76
|
+
loading: true
|
|
77
|
+
});
|
|
78
|
+
try {
|
|
79
|
+
await api.usernames.deleteUsername(username);
|
|
80
|
+
setUsernamesState({
|
|
81
|
+
username: undefined,
|
|
82
|
+
loading: false
|
|
83
|
+
});
|
|
84
|
+
} catch (e) {
|
|
85
|
+
setUsernamesState({
|
|
86
|
+
error: errorHandler(e)
|
|
87
|
+
});
|
|
88
|
+
} finally {
|
|
89
|
+
setUsernamesState({
|
|
90
|
+
loading: false
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
resetUsernamesState,
|
|
96
|
+
loadUserOwnUsername,
|
|
97
|
+
saveUserUsername,
|
|
98
|
+
deleteUserUsername
|
|
99
|
+
};
|
|
100
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/auth/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ import { buildSSOActions } from './SSOState';
|
|
|
33
33
|
import { buildStepUpActions } from './StepUpState';
|
|
34
34
|
import { buildTeamActions } from './TeamState';
|
|
35
35
|
import { buildTenantsActions } from './TenantsState';
|
|
36
|
+
import { buildUsernamesActions } from './UsernamesState';
|
|
36
37
|
import { buildUserEmailPolicyActions } from './UsersEmailsPolicyState';
|
|
37
38
|
import { buildEntitlementsActions } from './Entitlements';
|
|
38
39
|
export * from './AcceptInvitationState/interfaces';
|
|
@@ -69,6 +70,7 @@ export * from './SSOState/interfaces';
|
|
|
69
70
|
export * from './StepUpState/interfaces';
|
|
70
71
|
export * from './TeamState/interfaces';
|
|
71
72
|
export * from './TenantsState/interfaces';
|
|
73
|
+
export * from './UsernamesState/interfaces';
|
|
72
74
|
export * from './UsersEmailsPolicyState/interfaces';
|
|
73
75
|
export * from './interfaces';
|
|
74
76
|
export declare const createAuthState: (_overrideState?: DeepPartial<AuthState>) => AuthState;
|
|
@@ -107,6 +109,7 @@ export type SSOActions = ReturnType<typeof buildSSOActions>;
|
|
|
107
109
|
export type StepUpActions = ReturnType<typeof buildStepUpActions>;
|
|
108
110
|
export type TeamActions = ReturnType<typeof buildTeamActions>;
|
|
109
111
|
export type TenantsActions = ReturnType<typeof buildTenantsActions>;
|
|
112
|
+
export type UsernamesActions = ReturnType<typeof buildUsernamesActions>;
|
|
110
113
|
export type UsersEmailPolicyActions = ReturnType<typeof buildUserEmailPolicyActions>;
|
|
111
114
|
export type AuthStateActions = {
|
|
112
115
|
acceptInvitationActions: AcceptInvitationActions;
|
|
@@ -143,6 +146,7 @@ export type AuthStateActions = {
|
|
|
143
146
|
stepUpActions: StepUpActions;
|
|
144
147
|
teamActions: TeamActions;
|
|
145
148
|
tenantsActions: TenantsActions;
|
|
149
|
+
usernamesActions: UsernamesActions;
|
|
146
150
|
usersEmailsPolicyActions: UsersEmailPolicyActions;
|
|
147
151
|
};
|
|
148
152
|
export type AuthActions = {
|
|
@@ -152,4 +156,4 @@ export type AuthActions = {
|
|
|
152
156
|
setErrorByRequestName: (payload: SingleErrorByRequestDataPayload) => void;
|
|
153
157
|
resetAuthState: (state?: Partial<AuthState>) => void;
|
|
154
158
|
setUser: (user: User | null) => void;
|
|
155
|
-
} & AcceptInvitationActions & AccountSettingsActions & UnlockAccountActions & ActivateAccountActions & ApiTokensActions & ApplicationsActions & CustomLoginActions & EntitlementsActions & ForgotPasswordActions & PasswordRotationActions & GroupsActions & GroupsDialogsActions & ImpersonateActions & LoginActions & MfaActions & AllAccountsActions & AllAccountsDialogActions & PasskeysActions & ProfileActions & ProvisioningActions & ResetPhoneNumberActions & RolesActions & RestrictionsActions & SecurityCenterActions & SecurityPolicyActions & SessionsPolicyActions & SessionsActions & SignUpActions & SmsActions & SocialLoginActions & SSOActions & StepUpActions & TeamActions & TenantsActions & UsersEmailPolicyActions;
|
|
159
|
+
} & AcceptInvitationActions & AccountSettingsActions & UnlockAccountActions & ActivateAccountActions & ApiTokensActions & ApplicationsActions & CustomLoginActions & EntitlementsActions & ForgotPasswordActions & PasswordRotationActions & GroupsActions & GroupsDialogsActions & ImpersonateActions & LoginActions & MfaActions & AllAccountsActions & AllAccountsDialogActions & PasskeysActions & ProfileActions & ProvisioningActions & ResetPhoneNumberActions & RolesActions & RestrictionsActions & SecurityCenterActions & SecurityPolicyActions & SessionsPolicyActions & SessionsActions & SignUpActions & SmsActions & SocialLoginActions & SSOActions & StepUpActions & TeamActions & TenantsActions & UsernamesActions & UsersEmailPolicyActions;
|
package/auth/index.js
CHANGED
|
@@ -34,6 +34,7 @@ import { buildSSOActions, createSSOState } from './SSOState';
|
|
|
34
34
|
import { buildStepUpActions, createStepUpState } from './StepUpState';
|
|
35
35
|
import { buildTeamActions, createTeamState } from './TeamState';
|
|
36
36
|
import { buildTenantsActions, createTenantsState } from './TenantsState';
|
|
37
|
+
import { buildUsernamesActions, createUsernamesState } from './UsernamesState';
|
|
37
38
|
import { buildUserEmailPolicyActions, createUserEmailPolicyState } from './UsersEmailsPolicyState';
|
|
38
39
|
import { defaultFronteggRoutes } from './LoginState/consts';
|
|
39
40
|
import { deepResetState, isProxy } from '../helpers';
|
|
@@ -73,6 +74,7 @@ export * from './SSOState/interfaces';
|
|
|
73
74
|
export * from './StepUpState/interfaces';
|
|
74
75
|
export * from './TeamState/interfaces';
|
|
75
76
|
export * from './TenantsState/interfaces';
|
|
77
|
+
export * from './UsernamesState/interfaces';
|
|
76
78
|
export * from './UsersEmailsPolicyState/interfaces';
|
|
77
79
|
export * from './interfaces';
|
|
78
80
|
export const createAuthState = _overrideState => {
|
|
@@ -129,6 +131,7 @@ export const createAuthState = _overrideState => {
|
|
|
129
131
|
stepUpState: createStepUpState(overrideState == null ? void 0 : overrideState.stepUpState),
|
|
130
132
|
teamState: createTeamState(overrideState == null ? void 0 : overrideState.teamState),
|
|
131
133
|
tenantsState: createTenantsState(overrideState == null ? void 0 : overrideState.tenantsState),
|
|
134
|
+
usernamesState: createUsernamesState(overrideState == null ? void 0 : overrideState.usernamesState),
|
|
132
135
|
userEmailPolicyState: createUserEmailPolicyState(overrideState == null ? void 0 : overrideState.userEmailPolicyState)
|
|
133
136
|
}));
|
|
134
137
|
};
|
|
@@ -196,6 +199,7 @@ export const buildAuthActions = (store, api, actions, snapshotAuthState) => {
|
|
|
196
199
|
const stepUpActions = buildStepUpActions(store, api, actions);
|
|
197
200
|
const teamActions = buildTeamActions(store, api, actions);
|
|
198
201
|
const tenantsActions = buildTenantsActions(store, api, actions);
|
|
202
|
+
const usernamesActions = buildUsernamesActions(store, api, actions);
|
|
199
203
|
const usersEmailsPolicyActions = buildUserEmailPolicyActions(store, api, actions);
|
|
200
204
|
const stateActions = {
|
|
201
205
|
acceptInvitationActions,
|
|
@@ -232,6 +236,7 @@ export const buildAuthActions = (store, api, actions, snapshotAuthState) => {
|
|
|
232
236
|
stepUpActions,
|
|
233
237
|
teamActions,
|
|
234
238
|
tenantsActions,
|
|
239
|
+
usernamesActions,
|
|
235
240
|
usersEmailsPolicyActions
|
|
236
241
|
};
|
|
237
242
|
return [_extends({
|
package/auth/interfaces.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ import type { IAllAccountsDialogsState, IAllAccountsState } from './MSP/interfac
|
|
|
31
31
|
import { ApplicationsState } from './ApplicationsState/interfaces';
|
|
32
32
|
import { UnlockAccountState } from './UnlockAccountState/interfaces';
|
|
33
33
|
import { PasswordRotationState } from '../toolkit';
|
|
34
|
+
import { UsernamesState } from './UsernamesState/interfaces';
|
|
34
35
|
import { UserEmailPolicyState } from './UsersEmailsPolicyState/interfaces';
|
|
35
36
|
export declare enum REQUEST_NAME {
|
|
36
37
|
LOAD_FEATURE_FLAGS = "LOAD_FEATURE_FLAGS,",
|
|
@@ -108,6 +109,7 @@ export interface AuthState extends Routes, PluginOptions {
|
|
|
108
109
|
teamState: TeamState;
|
|
109
110
|
tenantsState: TenantsState;
|
|
110
111
|
applicationsState: ApplicationsState;
|
|
112
|
+
usernamesState: UsernamesState;
|
|
111
113
|
userEmailPolicyState: UserEmailPolicyState;
|
|
112
114
|
}
|
|
113
115
|
interface Actor {
|
package/index.js
CHANGED
|
@@ -39,6 +39,7 @@ import buildTenantsActions from './tenantsActions.mocks';
|
|
|
39
39
|
import buildUnlockAccountActions from './unlockAccountActions.mocks';
|
|
40
40
|
import buildUserEmailPolicyActions from './usersEmailsPolicyActions.mocks';
|
|
41
41
|
import { deepResetState, isProxy } from '../../helpers';
|
|
42
|
+
import { buildUsernamesActions } from '../../auth/UsernamesState';
|
|
42
43
|
export const buildAuthActions = (store, api, actions, snapshotAuthState) => {
|
|
43
44
|
const acceptInvitationActions = buildAcceptInvitationActions(store, api, actions);
|
|
44
45
|
const accountSettingsActions = buildAccountSettingsActions(store, api, actions);
|
|
@@ -74,6 +75,7 @@ export const buildAuthActions = (store, api, actions, snapshotAuthState) => {
|
|
|
74
75
|
const stepUpActions = buildStepUpActions(store, api, actions);
|
|
75
76
|
const teamActions = buildTeamActions(store, api, actions);
|
|
76
77
|
const tenantsActions = buildTenantsActions(store, api, actions);
|
|
78
|
+
const usernamesActions = buildUsernamesActions(store, api, actions);
|
|
77
79
|
const usersEmailsPolicyActions = buildUserEmailPolicyActions(store, api, actions);
|
|
78
80
|
const authStateActions = {
|
|
79
81
|
acceptInvitationActions,
|
|
@@ -110,6 +112,7 @@ export const buildAuthActions = (store, api, actions, snapshotAuthState) => {
|
|
|
110
112
|
stepUpActions,
|
|
111
113
|
teamActions,
|
|
112
114
|
tenantsActions,
|
|
115
|
+
usernamesActions,
|
|
113
116
|
usersEmailsPolicyActions
|
|
114
117
|
};
|
|
115
118
|
const setAuthState = state => {
|
|
@@ -148,7 +151,7 @@ export const buildAuthActions = (store, api, actions, snapshotAuthState) => {
|
|
|
148
151
|
setErrorByRequestName,
|
|
149
152
|
resetAuthState,
|
|
150
153
|
setUser
|
|
151
|
-
}, acceptInvitationActions, accountSettingsActions, activateAccountActions, unlockAccountActions, allAccountsActions, allAccountsDialogActions, apiTokensActions, applicationsActions, customLoginActions, entitlementsActions, forgotPasswordActions, passwordRotationActions, groupsActions, groupsDialogsActions, impersonateActions, loginActions, mfaActions, passkeysActions, profileActions, provisioningActions, resetPhoneNumberActions, restrictionsActions, rolesActions, securityCenterActions, securityPolicyActions, sessionsActions, sessionsPolicyActions, signUpActions, smsActions, socialLoginActions, ssoActions, stepUpActions, teamActions, tenantsActions, usersEmailsPolicyActions);
|
|
154
|
+
}, acceptInvitationActions, accountSettingsActions, activateAccountActions, unlockAccountActions, allAccountsActions, allAccountsDialogActions, apiTokensActions, applicationsActions, customLoginActions, entitlementsActions, forgotPasswordActions, passwordRotationActions, groupsActions, groupsDialogsActions, impersonateActions, loginActions, mfaActions, passkeysActions, profileActions, provisioningActions, resetPhoneNumberActions, restrictionsActions, rolesActions, securityCenterActions, securityPolicyActions, sessionsActions, sessionsPolicyActions, signUpActions, smsActions, socialLoginActions, ssoActions, stepUpActions, teamActions, tenantsActions, usernamesActions, usersEmailsPolicyActions);
|
|
152
155
|
return {
|
|
153
156
|
authActions,
|
|
154
157
|
authStateActions
|
|
@@ -35,7 +35,7 @@ function _default(store, api, sharedActions) {
|
|
|
35
35
|
const postHandleVerifyMFAResponseForLogin = async (isAuthenticated, user) => {
|
|
36
36
|
const loginState = store.auth.loginState;
|
|
37
37
|
const mfaStep = store.auth.mfaState.step;
|
|
38
|
-
const [securityCenterLoginFlows
|
|
38
|
+
const [securityCenterLoginFlows] = await actions.getFeatureFlags(['security-center-show-login-flows']);
|
|
39
39
|
if (loginState.flow === _interfaces2.LoginFlow.Login) {
|
|
40
40
|
if (securityCenterLoginFlows && loginState.isBreachedPassword && !isAuthenticated) {
|
|
41
41
|
actions.setLoginState({
|
|
@@ -44,7 +44,7 @@ function _default(store, api, sharedActions) {
|
|
|
44
44
|
});
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
if (
|
|
47
|
+
if ((0, _helpers.isResetPasswordRequired)(user, store.root.appName)) {
|
|
48
48
|
actions.setLoginState({
|
|
49
49
|
step: _interfaces2.LoginStep.passwordRotationExpired,
|
|
50
50
|
loading: false,
|
|
@@ -53,7 +53,7 @@ function _default(store, api, sharedActions) {
|
|
|
53
53
|
});
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
if (
|
|
56
|
+
if ((0, _helpers.shouldShowPasswordRotationPromptFunc)(user)) {
|
|
57
57
|
actions.setLoginState({
|
|
58
58
|
step: _interfaces2.LoginStep.passwordRotationNotification,
|
|
59
59
|
loading: false
|
|
@@ -354,6 +354,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
354
354
|
const preLogin = async payload => {
|
|
355
355
|
const {
|
|
356
356
|
email,
|
|
357
|
+
username,
|
|
357
358
|
recaptchaToken,
|
|
358
359
|
invitationToken,
|
|
359
360
|
callback
|
|
@@ -364,10 +365,13 @@ var _default = (store, api, sharedActions) => {
|
|
|
364
365
|
try {
|
|
365
366
|
const onRedirectTo = store.auth.onRedirectTo;
|
|
366
367
|
const tenantId = (0, _helpers2.getSearchParam)(_helpers2.TENANT_ID_PARAM_KEY);
|
|
367
|
-
const preLoginResult = await api.auth.preLoginV2({
|
|
368
|
-
email
|
|
368
|
+
const preLoginResult = await api.auth.preLoginV2((0, _extends2.default)({}, email ? {
|
|
369
|
+
email
|
|
370
|
+
} : {}, username ? {
|
|
371
|
+
username
|
|
372
|
+
} : {}, {
|
|
369
373
|
tenantId
|
|
370
|
-
});
|
|
374
|
+
}));
|
|
371
375
|
const {
|
|
372
376
|
address,
|
|
373
377
|
idpType
|
|
@@ -381,7 +385,8 @@ var _default = (store, api, sharedActions) => {
|
|
|
381
385
|
ssoRedirectUrl += `&redirect_uri=${window.location.origin}${oidcRedirectUrl}`;
|
|
382
386
|
}
|
|
383
387
|
if (_toolkit.FronteggNativeModule.isLoginWithSSOAvailable()) {
|
|
384
|
-
|
|
388
|
+
var _ref4;
|
|
389
|
+
_toolkit.FronteggNativeModule.loginWithSSO((_ref4 = email != null ? email : username) != null ? _ref4 : '');
|
|
385
390
|
setLoginState({
|
|
386
391
|
loading: false
|
|
387
392
|
});
|
|
@@ -399,16 +404,18 @@ var _default = (store, api, sharedActions) => {
|
|
|
399
404
|
}, 2000);
|
|
400
405
|
}
|
|
401
406
|
} else {
|
|
407
|
+
var _ref5;
|
|
402
408
|
await ssoPreloginFailed({
|
|
403
|
-
email,
|
|
409
|
+
email: (_ref5 = email != null ? email : username) != null ? _ref5 : '',
|
|
404
410
|
recaptchaToken,
|
|
405
411
|
callback,
|
|
406
412
|
invitationToken
|
|
407
413
|
});
|
|
408
414
|
}
|
|
409
415
|
} catch (e) {
|
|
416
|
+
var _ref6;
|
|
410
417
|
await ssoPreloginFailed({
|
|
411
|
-
email,
|
|
418
|
+
email: (_ref6 = email != null ? email : username) != null ? _ref6 : '',
|
|
412
419
|
recaptchaToken,
|
|
413
420
|
callback,
|
|
414
421
|
invitationToken,
|
|
@@ -444,6 +451,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
444
451
|
const login = async payload => {
|
|
445
452
|
const {
|
|
446
453
|
email,
|
|
454
|
+
username,
|
|
447
455
|
password,
|
|
448
456
|
recaptchaToken,
|
|
449
457
|
invitationToken,
|
|
@@ -457,12 +465,15 @@ var _default = (store, api, sharedActions) => {
|
|
|
457
465
|
user,
|
|
458
466
|
tenants = [],
|
|
459
467
|
activeTenant
|
|
460
|
-
} = await api.auth.loginv2({
|
|
461
|
-
email
|
|
468
|
+
} = await api.auth.loginv2((0, _extends2.default)({}, email ? {
|
|
469
|
+
email
|
|
470
|
+
} : {}, username ? {
|
|
471
|
+
username
|
|
472
|
+
} : {}, {
|
|
462
473
|
password,
|
|
463
474
|
recaptchaToken,
|
|
464
475
|
invitationToken
|
|
465
|
-
});
|
|
476
|
+
}));
|
|
466
477
|
const {
|
|
467
478
|
onRedirectTo,
|
|
468
479
|
routes
|
|
@@ -474,8 +485,8 @@ var _default = (store, api, sharedActions) => {
|
|
|
474
485
|
preserveQueryParams: true
|
|
475
486
|
});
|
|
476
487
|
} else {
|
|
477
|
-
const [securityCenterLoginFlows
|
|
478
|
-
if (
|
|
488
|
+
const [securityCenterLoginFlows] = await actions.getFeatureFlags(['security-center-show-login-flows']);
|
|
489
|
+
if ((0, _helpers3.isResetPasswordRequired)(user, store.root.appName)) {
|
|
479
490
|
setLoginState({
|
|
480
491
|
step: _interfaces.LoginStep.passwordRotationExpired,
|
|
481
492
|
loading: false,
|
|
@@ -516,7 +527,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
516
527
|
} else {
|
|
517
528
|
if (isAuthenticated) {
|
|
518
529
|
const shouldShowPasswordRotationPrompt = (0, _helpers2.shouldShowPasswordRotationPromptFunc)(user);
|
|
519
|
-
if (
|
|
530
|
+
if (shouldShowPasswordRotationPrompt) {
|
|
520
531
|
setLoginState({
|
|
521
532
|
step: _interfaces.LoginStep.passwordRotationNotification,
|
|
522
533
|
loading: false
|
|
@@ -702,6 +713,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
702
713
|
} = _payload,
|
|
703
714
|
payload = (0, _objectWithoutPropertiesLoose2.default)(_payload, _excluded5);
|
|
704
715
|
try {
|
|
716
|
+
var _username;
|
|
705
717
|
setLoginState({
|
|
706
718
|
loading: true
|
|
707
719
|
});
|
|
@@ -709,9 +721,16 @@ var _default = (store, api, sharedActions) => {
|
|
|
709
721
|
if ((0, _helpers2.isEmailPayload)(payload)) {
|
|
710
722
|
email = payload.email;
|
|
711
723
|
}
|
|
724
|
+
let username;
|
|
725
|
+
if ((0, _helpers2.isUsernamePayload)(payload)) {
|
|
726
|
+
username = payload.username;
|
|
727
|
+
}
|
|
712
728
|
// TODO: [Typescript 4.8] fix @frontegg/rest-api return value
|
|
713
729
|
// @ts-ignore
|
|
714
|
-
const preloginRes = await api.auth.passwordlessPreLogin(payload
|
|
730
|
+
const preloginRes = await api.auth.passwordlessPreLogin((0, _extends2.default)({}, payload, {
|
|
731
|
+
email,
|
|
732
|
+
username: (_username = username) != null ? _username : ''
|
|
733
|
+
}));
|
|
715
734
|
// @ts-ignore
|
|
716
735
|
const step = _consts.authStrategyLoginStepMap[payload.type];
|
|
717
736
|
setLoginState({
|
|
@@ -1303,11 +1322,11 @@ var _default = (store, api, sharedActions) => {
|
|
|
1303
1322
|
preserveQueryParams: true
|
|
1304
1323
|
});
|
|
1305
1324
|
} else {
|
|
1306
|
-
var
|
|
1325
|
+
var _ref7;
|
|
1307
1326
|
if (user.id) {
|
|
1308
1327
|
localStorage.setItem('userId', user.id);
|
|
1309
1328
|
}
|
|
1310
|
-
const quickLoginToRegister = (
|
|
1329
|
+
const quickLoginToRegister = (_ref7 = localStorage.getItem('register-quick-login')) != null ? _ref7 : loginState.quickLoginToRegister;
|
|
1311
1330
|
const shouldNavigateToRegisterQuickLogin = __shouldNavigateToRegisterQuickLogin(user);
|
|
1312
1331
|
actions.afterAuthenticationStateUpdate({
|
|
1313
1332
|
user: updatedUser,
|
|
@@ -49,7 +49,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
49
49
|
async function __postLoginMfaAuthenticator(isAuthenticated, user, callback) {
|
|
50
50
|
const loginState = store.auth.loginState;
|
|
51
51
|
if (loginState.flow !== _interfaces.LoginFlow.Login) return;
|
|
52
|
-
const [securityCenterLoginFlows
|
|
52
|
+
const [securityCenterLoginFlows] = await actions.getFeatureFlags(['security-center-show-login-flows']);
|
|
53
53
|
if (securityCenterLoginFlows && loginState.isBreachedPassword && !isAuthenticated) {
|
|
54
54
|
actions.setLoginState({
|
|
55
55
|
step: _interfaces.LoginStep.breachedPassword,
|
|
@@ -58,7 +58,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
58
58
|
callback == null ? void 0 : callback(true);
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
|
-
if (
|
|
61
|
+
if ((0, _helpers2.isResetPasswordRequired)(user, store.root.appName)) {
|
|
62
62
|
actions.setLoginState({
|
|
63
63
|
step: _interfaces.LoginStep.passwordRotationExpired,
|
|
64
64
|
loading: false,
|
|
@@ -69,7 +69,7 @@ var _default = (store, api, sharedActions) => {
|
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
71
|
const shouldShowPasswordRotationPrompt = (0, _helpers2.shouldShowPasswordRotationPromptFunc)(user);
|
|
72
|
-
if (
|
|
72
|
+
if (shouldShowPasswordRotationPrompt) {
|
|
73
73
|
actions.setLoginState({
|
|
74
74
|
step: _interfaces.LoginStep.passwordRotationNotification,
|
|
75
75
|
loading: false
|
|
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isAbsoluteUrl = exports.getSearchParamsFromUrl = exports.getSearchParam = exports.getRedirectUrl = exports.getPathAndSearchParamsFromUrl = exports.getNumberOfMfaDevices = exports.getMfaStepForNotEnrolledUsers = exports.getMfaStepForEnrolledUsers = exports.getBaseNameWithoutSlashSuffix = exports.TENANT_ID_PARAM_KEY = void 0;
|
|
7
7
|
exports.isEmailPayload = isEmailPayload;
|
|
8
|
-
exports.
|
|
8
|
+
exports.isOauthCallbackRoute = void 0;
|
|
9
|
+
exports.isUsernamePayload = isUsernamePayload;
|
|
10
|
+
exports.shouldShowPasswordRotationPromptFunc = void 0;
|
|
9
11
|
var _restApi = require("@frontegg/rest-api");
|
|
10
12
|
var _interfaces = require("../MfaState/interfaces");
|
|
11
13
|
const isAbsoluteUrl = path => {
|
|
@@ -142,7 +144,10 @@ const isOauthCallbackRoute = activeUri => {
|
|
|
142
144
|
};
|
|
143
145
|
exports.isOauthCallbackRoute = isOauthCallbackRoute;
|
|
144
146
|
function isEmailPayload(payload) {
|
|
145
|
-
return 'email' in payload;
|
|
147
|
+
return 'email' in payload && typeof payload['email'] === 'string';
|
|
148
|
+
}
|
|
149
|
+
function isUsernamePayload(payload) {
|
|
150
|
+
return 'username' in payload && typeof payload['username'] === 'string';
|
|
146
151
|
}
|
|
147
152
|
const getBaseNameWithoutSlashSuffix = state => {
|
|
148
153
|
const basename = _restApi.ContextHolder.for(state.root.appName).getBasename();
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _helpers = require("../../helpers");
|
|
8
|
+
var _state = require("./state");
|
|
9
|
+
var _default = (store, api, sharedActions) => {
|
|
10
|
+
const setUsernamesState = state => {
|
|
11
|
+
Object.assign(store.auth.usernamesState, state);
|
|
12
|
+
};
|
|
13
|
+
const resetUsernamesState = () => {
|
|
14
|
+
(0, _helpers.deepResetState)(store, ['auth', 'usernamesState'], _state.initialState);
|
|
15
|
+
};
|
|
16
|
+
const loadUserOwnUsername = async () => {
|
|
17
|
+
setUsernamesState({
|
|
18
|
+
loading: true
|
|
19
|
+
});
|
|
20
|
+
try {
|
|
21
|
+
const response = await api.usernames.getUserOwnUsername();
|
|
22
|
+
setUsernamesState({
|
|
23
|
+
username: response == null ? void 0 : response.username,
|
|
24
|
+
loading: false,
|
|
25
|
+
fetching: false
|
|
26
|
+
});
|
|
27
|
+
} catch (e) {
|
|
28
|
+
setUsernamesState({
|
|
29
|
+
error: (0, _helpers.errorHandler)(e),
|
|
30
|
+
fetching: false
|
|
31
|
+
});
|
|
32
|
+
} finally {
|
|
33
|
+
setUsernamesState({
|
|
34
|
+
loading: false,
|
|
35
|
+
fetching: false
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const saveUserUsername = async payload => {
|
|
40
|
+
setUsernamesState({
|
|
41
|
+
loading: true
|
|
42
|
+
});
|
|
43
|
+
try {
|
|
44
|
+
if (store.auth.usernamesState.username === payload.username) {
|
|
45
|
+
var _payload$callback;
|
|
46
|
+
(_payload$callback = payload.callback) == null ? void 0 : _payload$callback.call(payload);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (store.auth.usernamesState.username && store.auth.usernamesState.username !== payload.username) {
|
|
50
|
+
await deleteUserUsername(store.auth.usernamesState.username);
|
|
51
|
+
if (!payload.username) {
|
|
52
|
+
var _payload$callback2;
|
|
53
|
+
setUsernamesState({
|
|
54
|
+
username: undefined,
|
|
55
|
+
loading: false
|
|
56
|
+
});
|
|
57
|
+
(_payload$callback2 = payload.callback) == null ? void 0 : _payload$callback2.call(payload);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (!!payload.username) {
|
|
62
|
+
var _payload$callback3;
|
|
63
|
+
await api.usernames.createUsername(payload);
|
|
64
|
+
setUsernamesState({
|
|
65
|
+
username: payload.username,
|
|
66
|
+
loading: false
|
|
67
|
+
});
|
|
68
|
+
(_payload$callback3 = payload.callback) == null ? void 0 : _payload$callback3.call(payload);
|
|
69
|
+
}
|
|
70
|
+
} catch (e) {
|
|
71
|
+
setUsernamesState({
|
|
72
|
+
error: (0, _helpers.errorHandler)(e)
|
|
73
|
+
});
|
|
74
|
+
} finally {
|
|
75
|
+
setUsernamesState({
|
|
76
|
+
loading: false
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const deleteUserUsername = async username => {
|
|
81
|
+
setUsernamesState({
|
|
82
|
+
loading: true
|
|
83
|
+
});
|
|
84
|
+
try {
|
|
85
|
+
await api.usernames.deleteUsername(username);
|
|
86
|
+
setUsernamesState({
|
|
87
|
+
username: undefined,
|
|
88
|
+
loading: false
|
|
89
|
+
});
|
|
90
|
+
} catch (e) {
|
|
91
|
+
setUsernamesState({
|
|
92
|
+
error: (0, _helpers.errorHandler)(e)
|
|
93
|
+
});
|
|
94
|
+
} finally {
|
|
95
|
+
setUsernamesState({
|
|
96
|
+
loading: false
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
resetUsernamesState,
|
|
102
|
+
loadUserOwnUsername,
|
|
103
|
+
saveUserUsername,
|
|
104
|
+
deleteUserUsername
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
exports.default = _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
Object.defineProperty(exports, "buildUsernamesActions", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _actions.default;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "createUsernamesState", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () {
|
|
16
|
+
return _state.default;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
var _state = _interopRequireDefault(require("./state"));
|
|
20
|
+
var _actions = _interopRequireDefault(require("./actions"));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.initialState = exports.default = void 0;
|
|
7
|
+
var _proxy = require("../../toolkit/proxy");
|
|
8
|
+
const initialState = {
|
|
9
|
+
loading: false,
|
|
10
|
+
error: null,
|
|
11
|
+
username: undefined,
|
|
12
|
+
fetching: true
|
|
13
|
+
};
|
|
14
|
+
exports.initialState = initialState;
|
|
15
|
+
var _default = overrideState => (0, _proxy.createProxy)(initialState, overrideState);
|
|
16
|
+
exports.default = _default;
|
package/node/auth/index.js
CHANGED
|
@@ -43,6 +43,7 @@ var _SSOState = require("./SSOState");
|
|
|
43
43
|
var _StepUpState = require("./StepUpState");
|
|
44
44
|
var _TeamState = require("./TeamState");
|
|
45
45
|
var _TenantsState = require("./TenantsState");
|
|
46
|
+
var _UsernamesState = require("./UsernamesState");
|
|
46
47
|
var _UsersEmailsPolicyState = require("./UsersEmailsPolicyState");
|
|
47
48
|
var _consts = require("./LoginState/consts");
|
|
48
49
|
var _helpers = require("../helpers");
|
|
@@ -456,7 +457,7 @@ Object.keys(_interfaces33).forEach(function (key) {
|
|
|
456
457
|
}
|
|
457
458
|
});
|
|
458
459
|
});
|
|
459
|
-
var _interfaces34 = require("./
|
|
460
|
+
var _interfaces34 = require("./UsernamesState/interfaces");
|
|
460
461
|
Object.keys(_interfaces34).forEach(function (key) {
|
|
461
462
|
if (key === "default" || key === "__esModule") return;
|
|
462
463
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -468,7 +469,7 @@ Object.keys(_interfaces34).forEach(function (key) {
|
|
|
468
469
|
}
|
|
469
470
|
});
|
|
470
471
|
});
|
|
471
|
-
var _interfaces35 = require("./interfaces");
|
|
472
|
+
var _interfaces35 = require("./UsersEmailsPolicyState/interfaces");
|
|
472
473
|
Object.keys(_interfaces35).forEach(function (key) {
|
|
473
474
|
if (key === "default" || key === "__esModule") return;
|
|
474
475
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -480,6 +481,18 @@ Object.keys(_interfaces35).forEach(function (key) {
|
|
|
480
481
|
}
|
|
481
482
|
});
|
|
482
483
|
});
|
|
484
|
+
var _interfaces36 = require("./interfaces");
|
|
485
|
+
Object.keys(_interfaces36).forEach(function (key) {
|
|
486
|
+
if (key === "default" || key === "__esModule") return;
|
|
487
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
488
|
+
if (key in exports && exports[key] === _interfaces36[key]) return;
|
|
489
|
+
Object.defineProperty(exports, key, {
|
|
490
|
+
enumerable: true,
|
|
491
|
+
get: function () {
|
|
492
|
+
return _interfaces36[key];
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
});
|
|
483
496
|
const _excluded = ["routes"],
|
|
484
497
|
_excluded2 = ["requestName"];
|
|
485
498
|
const createAuthState = _overrideState => {
|
|
@@ -536,6 +549,7 @@ const createAuthState = _overrideState => {
|
|
|
536
549
|
stepUpState: (0, _StepUpState.createStepUpState)(overrideState == null ? void 0 : overrideState.stepUpState),
|
|
537
550
|
teamState: (0, _TeamState.createTeamState)(overrideState == null ? void 0 : overrideState.teamState),
|
|
538
551
|
tenantsState: (0, _TenantsState.createTenantsState)(overrideState == null ? void 0 : overrideState.tenantsState),
|
|
552
|
+
usernamesState: (0, _UsernamesState.createUsernamesState)(overrideState == null ? void 0 : overrideState.usernamesState),
|
|
539
553
|
userEmailPolicyState: (0, _UsersEmailsPolicyState.createUserEmailPolicyState)(overrideState == null ? void 0 : overrideState.userEmailPolicyState)
|
|
540
554
|
}));
|
|
541
555
|
};
|
|
@@ -604,6 +618,7 @@ const buildAuthActions = (store, api, actions, snapshotAuthState) => {
|
|
|
604
618
|
const stepUpActions = (0, _StepUpState.buildStepUpActions)(store, api, actions);
|
|
605
619
|
const teamActions = (0, _TeamState.buildTeamActions)(store, api, actions);
|
|
606
620
|
const tenantsActions = (0, _TenantsState.buildTenantsActions)(store, api, actions);
|
|
621
|
+
const usernamesActions = (0, _UsernamesState.buildUsernamesActions)(store, api, actions);
|
|
607
622
|
const usersEmailsPolicyActions = (0, _UsersEmailsPolicyState.buildUserEmailPolicyActions)(store, api, actions);
|
|
608
623
|
const stateActions = {
|
|
609
624
|
acceptInvitationActions,
|
|
@@ -640,6 +655,7 @@ const buildAuthActions = (store, api, actions, snapshotAuthState) => {
|
|
|
640
655
|
stepUpActions,
|
|
641
656
|
teamActions,
|
|
642
657
|
tenantsActions,
|
|
658
|
+
usernamesActions,
|
|
643
659
|
usersEmailsPolicyActions
|
|
644
660
|
};
|
|
645
661
|
return [(0, _extends2.default)({
|
package/node/index.js
CHANGED
|
@@ -43,6 +43,7 @@ var _tenantsActions = _interopRequireDefault(require("./tenantsActions.mocks"));
|
|
|
43
43
|
var _unlockAccountActions = _interopRequireDefault(require("./unlockAccountActions.mocks"));
|
|
44
44
|
var _usersEmailsPolicyActions = _interopRequireDefault(require("./usersEmailsPolicyActions.mocks"));
|
|
45
45
|
var _helpers = require("../../helpers");
|
|
46
|
+
var _UsernamesState = require("../../auth/UsernamesState");
|
|
46
47
|
const _excluded = ["requestName"];
|
|
47
48
|
const buildAuthActions = (store, api, actions, snapshotAuthState) => {
|
|
48
49
|
const acceptInvitationActions = (0, _acceptInvitationActions.default)(store, api, actions);
|
|
@@ -79,6 +80,7 @@ const buildAuthActions = (store, api, actions, snapshotAuthState) => {
|
|
|
79
80
|
const stepUpActions = (0, _stepUpActions.default)(store, api, actions);
|
|
80
81
|
const teamActions = (0, _teamActions.default)(store, api, actions);
|
|
81
82
|
const tenantsActions = (0, _tenantsActions.default)(store, api, actions);
|
|
83
|
+
const usernamesActions = (0, _UsernamesState.buildUsernamesActions)(store, api, actions);
|
|
82
84
|
const usersEmailsPolicyActions = (0, _usersEmailsPolicyActions.default)(store, api, actions);
|
|
83
85
|
const authStateActions = {
|
|
84
86
|
acceptInvitationActions,
|
|
@@ -115,6 +117,7 @@ const buildAuthActions = (store, api, actions, snapshotAuthState) => {
|
|
|
115
117
|
stepUpActions,
|
|
116
118
|
teamActions,
|
|
117
119
|
tenantsActions,
|
|
120
|
+
usernamesActions,
|
|
118
121
|
usersEmailsPolicyActions
|
|
119
122
|
};
|
|
120
123
|
const setAuthState = state => {
|
|
@@ -153,7 +156,7 @@ const buildAuthActions = (store, api, actions, snapshotAuthState) => {
|
|
|
153
156
|
setErrorByRequestName,
|
|
154
157
|
resetAuthState,
|
|
155
158
|
setUser
|
|
156
|
-
}, acceptInvitationActions, accountSettingsActions, activateAccountActions, unlockAccountActions, allAccountsActions, allAccountsDialogActions, apiTokensActions, applicationsActions, customLoginActions, entitlementsActions, forgotPasswordActions, passwordRotationActions, groupsActions, groupsDialogsActions, impersonateActions, loginActions, mfaActions, passkeysActions, profileActions, provisioningActions, resetPhoneNumberActions, restrictionsActions, rolesActions, securityCenterActions, securityPolicyActions, sessionsActions, sessionsPolicyActions, signUpActions, smsActions, socialLoginActions, ssoActions, stepUpActions, teamActions, tenantsActions, usersEmailsPolicyActions);
|
|
159
|
+
}, acceptInvitationActions, accountSettingsActions, activateAccountActions, unlockAccountActions, allAccountsActions, allAccountsDialogActions, apiTokensActions, applicationsActions, customLoginActions, entitlementsActions, forgotPasswordActions, passwordRotationActions, groupsActions, groupsDialogsActions, impersonateActions, loginActions, mfaActions, passkeysActions, profileActions, provisioningActions, resetPhoneNumberActions, restrictionsActions, rolesActions, securityCenterActions, securityPolicyActions, sessionsActions, sessionsPolicyActions, signUpActions, smsActions, socialLoginActions, ssoActions, stepUpActions, teamActions, tenantsActions, usernamesActions, usersEmailsPolicyActions);
|
|
157
160
|
return {
|
|
158
161
|
authActions,
|
|
159
162
|
authStateActions
|
|
@@ -6,16 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
class FronteggNativeModule {
|
|
8
8
|
constructor() {
|
|
9
|
-
this.loginWithSSO =
|
|
9
|
+
this.loginWithSSO = identifier => {
|
|
10
10
|
if (this.isIOSNativeBridgeAvailable()) {
|
|
11
11
|
var _window$webkit, _window$webkit$messag, _window$webkit$messag2;
|
|
12
12
|
(_window$webkit = window.webkit) == null ? void 0 : (_window$webkit$messag = _window$webkit.messageHandlers) == null ? void 0 : (_window$webkit$messag2 = _window$webkit$messag.FronteggNativeBridge) == null ? void 0 : _window$webkit$messag2.postMessage(JSON.stringify({
|
|
13
13
|
action: 'loginWithSSO',
|
|
14
|
-
payload:
|
|
14
|
+
payload: identifier
|
|
15
15
|
}));
|
|
16
16
|
} else if (this.isAndroidNativeBridgeAvailable()) {
|
|
17
17
|
var _window$FronteggNativ;
|
|
18
|
-
(_window$FronteggNativ = window.FronteggNativeBridge) == null ? void 0 : _window$FronteggNativ.loginWithSSO(
|
|
18
|
+
(_window$FronteggNativ = window.FronteggNativeBridge) == null ? void 0 : _window$FronteggNativ.loginWithSSO(identifier);
|
|
19
19
|
} else {
|
|
20
20
|
throw new Error('FronteggNativeBridge is not available');
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/redux-store",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.76.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.76.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",
|
|
@@ -30,7 +30,7 @@ declare class FronteggNativeModule {
|
|
|
30
30
|
isLoginWithSSOAvailable(): boolean;
|
|
31
31
|
isSuggestSavePasswordAvailable(): boolean;
|
|
32
32
|
isAvailable(method: string): boolean;
|
|
33
|
-
loginWithSSO: (
|
|
33
|
+
loginWithSSO: (identifier: string) => void;
|
|
34
34
|
/**
|
|
35
35
|
*
|
|
36
36
|
* @deprecated use loginWithSocialLoginProvider instead for pkce flow in mobile
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
class FronteggNativeModule {
|
|
2
2
|
constructor() {
|
|
3
|
-
this.loginWithSSO =
|
|
3
|
+
this.loginWithSSO = identifier => {
|
|
4
4
|
if (this.isIOSNativeBridgeAvailable()) {
|
|
5
5
|
var _window$webkit, _window$webkit$messag, _window$webkit$messag2;
|
|
6
6
|
(_window$webkit = window.webkit) == null ? void 0 : (_window$webkit$messag = _window$webkit.messageHandlers) == null ? void 0 : (_window$webkit$messag2 = _window$webkit$messag.FronteggNativeBridge) == null ? void 0 : _window$webkit$messag2.postMessage(JSON.stringify({
|
|
7
7
|
action: 'loginWithSSO',
|
|
8
|
-
payload:
|
|
8
|
+
payload: identifier
|
|
9
9
|
}));
|
|
10
10
|
} else if (this.isAndroidNativeBridgeAvailable()) {
|
|
11
11
|
var _window$FronteggNativ;
|
|
12
|
-
(_window$FronteggNativ = window.FronteggNativeBridge) == null ? void 0 : _window$FronteggNativ.loginWithSSO(
|
|
12
|
+
(_window$FronteggNativ = window.FronteggNativeBridge) == null ? void 0 : _window$FronteggNativ.loginWithSSO(identifier);
|
|
13
13
|
} else {
|
|
14
14
|
throw new Error('FronteggNativeBridge is not available');
|
|
15
15
|
}
|