@frontegg/redux-store 6.48.0 → 6.49.0-alpha.1
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/interfaces.d.ts +2 -1
- package/auth/LoginState/saga.js +15 -51
- package/auth/MfaState/index.d.ts +37 -4
- package/auth/MfaState/index.js +28 -1
- package/auth/MfaState/interfaces.d.ts +12 -1
- package/auth/MfaState/saga.js +385 -32
- package/auth/index.d.ts +22 -0
- package/auth/reducer.d.ts +22 -0
- package/index.js +1 -1
- package/node/auth/LoginState/saga.js +15 -55
- package/node/auth/MfaState/index.js +28 -1
- package/node/auth/MfaState/saga.js +374 -31
- package/node/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthStrategyEnum, IEnrollMFAWebAuthn, IPasswordlessPostLogin, ITenantsResponse, IVerifyMFAWebAuthn, IVerifyNewWebAuthnDevice, IWebAuthnPostLogin } from '@frontegg/rest-api';
|
|
1
|
+
import { AuthStrategyEnum, IEnrollMFAWebAuthn, ILoginResponse, IPasswordlessPostLogin, ITenantsResponse, IVerifyMFAWebAuthn, IVerifyNewWebAuthnDevice, IWebAuthnPostLogin } from '@frontegg/rest-api';
|
|
2
2
|
import { WithCallback } from '../../interfaces';
|
|
3
3
|
import { CustomEventsOptions } from '../interfaces';
|
|
4
4
|
export declare enum LoginStep {
|
|
@@ -53,6 +53,7 @@ export interface HostedLoginCallback {
|
|
|
53
53
|
export interface FronteggNextJSSession {
|
|
54
54
|
accessToken: string;
|
|
55
55
|
refreshToken?: string;
|
|
56
|
+
user: ILoginResponse;
|
|
56
57
|
}
|
|
57
58
|
export interface IQuickSmsPasswordlessPreLoginPayload {
|
|
58
59
|
userId: string;
|
package/auth/LoginState/saga.js
CHANGED
|
@@ -381,13 +381,11 @@ function* requestAuthorize({
|
|
|
381
381
|
}));
|
|
382
382
|
}
|
|
383
383
|
|
|
384
|
-
function*
|
|
384
|
+
function* isMFARequiredSSR({
|
|
385
385
|
accessToken,
|
|
386
|
-
|
|
386
|
+
user
|
|
387
387
|
}) {
|
|
388
388
|
if (!accessToken) {
|
|
389
|
-
ContextHolder.setAccessToken(null);
|
|
390
|
-
ContextHolder.setUser(null);
|
|
391
389
|
yield put(actions.setState({
|
|
392
390
|
user: undefined,
|
|
393
391
|
isAuthenticated: false
|
|
@@ -395,43 +393,17 @@ function* refreshTokenSSR({
|
|
|
395
393
|
return;
|
|
396
394
|
}
|
|
397
395
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
} = yield select(state => state.auth);
|
|
403
|
-
const {
|
|
404
|
-
user,
|
|
405
|
-
tenants
|
|
406
|
-
} = yield call(api.auth.generateLoginResponseV2, {
|
|
407
|
-
accessToken
|
|
408
|
-
});
|
|
396
|
+
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
397
|
+
const {
|
|
398
|
+
routes
|
|
399
|
+
} = yield select(state => state.auth);
|
|
409
400
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
} else {
|
|
417
|
-
yield put(actions.setTenantsState({
|
|
418
|
-
tenants,
|
|
419
|
-
loading: false
|
|
420
|
-
}));
|
|
421
|
-
yield put(actions.setState({
|
|
422
|
-
user: _extends({}, user, {
|
|
423
|
-
refreshToken
|
|
424
|
-
}),
|
|
425
|
-
isAuthenticated: true
|
|
426
|
-
}));
|
|
427
|
-
}
|
|
428
|
-
} catch (e) {
|
|
429
|
-
ContextHolder.setAccessToken(null);
|
|
430
|
-
ContextHolder.setUser(null);
|
|
431
|
-
yield put(actions.setState({
|
|
432
|
-
user: undefined,
|
|
433
|
-
isAuthenticated: false
|
|
434
|
-
}));
|
|
401
|
+
if (isMfaRequired(user)) {
|
|
402
|
+
const mfaRequiredState = yield getMfaRequiredState(user);
|
|
403
|
+
yield put(actions.setState(mfaRequiredState));
|
|
404
|
+
onRedirectTo(routes.loginUrl, {
|
|
405
|
+
preserveQueryParams: true
|
|
406
|
+
});
|
|
435
407
|
}
|
|
436
408
|
}
|
|
437
409
|
|
|
@@ -439,19 +411,13 @@ function* requestAuthorizeSSR({
|
|
|
439
411
|
payload
|
|
440
412
|
}) {
|
|
441
413
|
const calls = [];
|
|
442
|
-
yield put(actions.setState({
|
|
443
|
-
isLoading: true
|
|
444
|
-
}));
|
|
445
414
|
yield put(actions.loadSocialLoginsConfigurationV2());
|
|
446
415
|
calls.push(call(loadAllowSignUps));
|
|
447
416
|
calls.push(call(loadSSOPublicConfigurationFunction));
|
|
448
417
|
calls.push(call(loadVendorPublicInfo));
|
|
449
418
|
calls.push(call(refreshMetadata));
|
|
450
|
-
calls.push(call(
|
|
419
|
+
calls.push(call(isMFARequiredSSR, payload));
|
|
451
420
|
yield all(calls);
|
|
452
|
-
yield put(actions.setState({
|
|
453
|
-
isLoading: false
|
|
454
|
-
}));
|
|
455
421
|
}
|
|
456
422
|
|
|
457
423
|
const getUri = urlStrategy => {
|
|
@@ -1361,7 +1327,8 @@ function* handleEnrollMFAResponse({
|
|
|
1361
1327
|
const mfaState = {
|
|
1362
1328
|
step: MFAStep.recoveryCode,
|
|
1363
1329
|
loading: false,
|
|
1364
|
-
error: undefined
|
|
1330
|
+
error: undefined,
|
|
1331
|
+
saving: false
|
|
1365
1332
|
};
|
|
1366
1333
|
|
|
1367
1334
|
if (user != null && user.recoveryCode) {
|
|
@@ -1689,9 +1656,6 @@ function* verifyMFAWebAuthnForLogin(_ref19) {
|
|
|
1689
1656
|
}));
|
|
1690
1657
|
|
|
1691
1658
|
try {
|
|
1692
|
-
const {
|
|
1693
|
-
loginState
|
|
1694
|
-
} = yield select(state => state.auth);
|
|
1695
1659
|
const publicKey = publicKeyCredentialToJSON(payload.publicKey);
|
|
1696
1660
|
const data = yield call(api.auth.verifyMFAWebAuthnForLogin, deviceId, _extends({}, payload, {
|
|
1697
1661
|
options: publicKey
|
package/auth/MfaState/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IDisableMfa, ILoginWithMfa, IVerifyMfa } from '@frontegg/rest-api';
|
|
2
|
-
import { MFAState } from './interfaces';
|
|
1
|
+
import { IDisableMfa, IDisableMFASMS, ILoginWithMfa, IVerifyMfa } from '@frontegg/rest-api';
|
|
2
|
+
import { IDisableMFAWebAuthnPayload, IUserEnrollMFASMSPayload, IUserEnrollMFAWebAuthnPayload, IUserPreEnrollMFASMSPayload, MFAState } from './interfaces';
|
|
3
3
|
import { WithCallback } from '../../interfaces';
|
|
4
|
+
import { IPreEnrollMFAWebAuthNForLoginResponse, IPreVerifyMFAWebAuthNForLoginResponse, WithDeviceId } from '../LoginState/interfaces';
|
|
4
5
|
declare const mfaState: MFAState;
|
|
5
6
|
declare const reducers: {
|
|
6
7
|
setMfaState: {
|
|
@@ -20,7 +21,7 @@ declare const reducers: {
|
|
|
20
21
|
user?: import("..").User | null | undefined;
|
|
21
22
|
isSSOAuth: boolean;
|
|
22
23
|
ssoACS?: string | undefined;
|
|
23
|
-
loginState: import("
|
|
24
|
+
loginState: import("../LoginState/interfaces").LoginState;
|
|
24
25
|
activateState: import("..").ActivateAccountState;
|
|
25
26
|
acceptInvitationState: import("..").AcceptInvitationState;
|
|
26
27
|
forgotPasswordState: import("..").ForgotPasswordState;
|
|
@@ -56,7 +57,7 @@ declare const reducers: {
|
|
|
56
57
|
user?: import("..").User | null | undefined;
|
|
57
58
|
isSSOAuth: boolean;
|
|
58
59
|
ssoACS?: string | undefined;
|
|
59
|
-
loginState: import("
|
|
60
|
+
loginState: import("../LoginState/interfaces").LoginState;
|
|
60
61
|
activateState: import("..").ActivateAccountState;
|
|
61
62
|
acceptInvitationState: import("..").AcceptInvitationState;
|
|
62
63
|
forgotPasswordState: import("..").ForgotPasswordState;
|
|
@@ -84,9 +85,31 @@ declare const reducers: {
|
|
|
84
85
|
};
|
|
85
86
|
declare const actions: {
|
|
86
87
|
enrollMfa: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
88
|
+
getMFADevices: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
89
|
+
getMFAStrategies: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
87
90
|
verifyMfa: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IVerifyMfa, string | undefined>], WithCallback<IVerifyMfa, string | undefined>, string, never, never>;
|
|
88
91
|
verifyMfaAfterForce: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<ILoginWithMfa, string | undefined>], WithCallback<ILoginWithMfa, string | undefined>, string, never, never>;
|
|
89
92
|
disableMfa: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IDisableMfa, boolean>], WithCallback<IDisableMfa, boolean>, string, never, never>;
|
|
93
|
+
preDisableMfaSms: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<{
|
|
94
|
+
deviceId: string;
|
|
95
|
+
}, boolean>], WithCallback<{
|
|
96
|
+
deviceId: string;
|
|
97
|
+
}, boolean>, string, never, never>;
|
|
98
|
+
disableMfaSms: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<WithDeviceId<IDisableMFASMS>, boolean>], WithCallback<WithDeviceId<IDisableMFASMS>, boolean>, string, never, never>;
|
|
99
|
+
preEnrollMfaSms: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<Pick<import("@frontegg/rest-api").IPreEnrollMFASMS, "mfaToken" | "phoneNumber">, boolean>], WithCallback<Pick<import("@frontegg/rest-api").IPreEnrollMFASMS, "mfaToken" | "phoneNumber">, boolean>, string, never, never>;
|
|
100
|
+
enrollMfaSms: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<Pick<import("@frontegg/rest-api").IEnrollMFASMS, "mfaToken" | "otcToken" | "code">, string | undefined>], WithCallback<Pick<import("@frontegg/rest-api").IEnrollMFASMS, "mfaToken" | "otcToken" | "code">, string | undefined>, string, never, never>;
|
|
101
|
+
preEnrollMfaWebAuthn: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[{
|
|
102
|
+
callback?: ((data: IPreEnrollMFAWebAuthNForLoginResponse | null, error?: string | undefined) => void) | undefined;
|
|
103
|
+
}], {
|
|
104
|
+
callback?: ((data: IPreEnrollMFAWebAuthNForLoginResponse | null, error?: string | undefined) => void) | undefined;
|
|
105
|
+
}, string, never, never>;
|
|
106
|
+
enrollMfaWebAuthn: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[IUserEnrollMFAWebAuthnPayload], IUserEnrollMFAWebAuthnPayload, string, never, never>;
|
|
107
|
+
preDisableMfaWebAuthn: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<{
|
|
108
|
+
deviceId: string;
|
|
109
|
+
}, IPreVerifyMFAWebAuthNForLoginResponse>], WithCallback<{
|
|
110
|
+
deviceId: string;
|
|
111
|
+
}, IPreVerifyMFAWebAuthNForLoginResponse>, string, never, never>;
|
|
112
|
+
disableMfaWebAuthn: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[IDisableMFAWebAuthnPayload], IDisableMFAWebAuthnPayload, string, never, never>;
|
|
90
113
|
};
|
|
91
114
|
/**
|
|
92
115
|
* To be used for actions types after dispatch, and should contains
|
|
@@ -96,9 +119,19 @@ declare type DispatchedActions = {
|
|
|
96
119
|
setMfaState: (state: Partial<MFAState>) => void;
|
|
97
120
|
resetMfaState: () => void;
|
|
98
121
|
enrollMfa: () => void;
|
|
122
|
+
getMFADevices: () => void;
|
|
123
|
+
getMFAStrategies: () => void;
|
|
99
124
|
verifyMfa: (payload: WithCallback<IVerifyMfa, string | undefined>) => void;
|
|
100
125
|
verifyMfaAfterForce: (payload: WithCallback<ILoginWithMfa, string | undefined>) => void;
|
|
101
126
|
disableMfa: (payload: WithCallback<IDisableMfa>) => void;
|
|
127
|
+
preDisableMfaSms: (payload: WithCallback<WithDeviceId<{}>>) => void;
|
|
128
|
+
disableMfaSms: (payload: WithCallback<WithDeviceId<IDisableMFASMS>>) => void;
|
|
129
|
+
preEnrollMfaSms: (payload: IUserPreEnrollMFASMSPayload) => void;
|
|
130
|
+
enrollMfaSms: (payload: IUserEnrollMFASMSPayload) => void;
|
|
131
|
+
preEnrollMfaWebAuthn: (payload: WithCallback<{}, IPreEnrollMFAWebAuthNForLoginResponse>) => void;
|
|
132
|
+
enrollMfaWebAuthn: (payload: IUserEnrollMFAWebAuthnPayload) => void;
|
|
133
|
+
preDisableMfaWebAuthn: (payload: WithCallback<WithDeviceId<{}>, IPreVerifyMFAWebAuthNForLoginResponse>) => void;
|
|
134
|
+
disableMfaWebAuthn: (payload: IDisableMFAWebAuthnPayload) => void;
|
|
102
135
|
};
|
|
103
136
|
export declare type MfaActions = DispatchedActions;
|
|
104
137
|
export { mfaState, reducers as mfaReducers, actions as mfaActions };
|
package/auth/MfaState/index.js
CHANGED
|
@@ -4,7 +4,8 @@ import { resetStateByKey, typeReducerForKey } from '../utils';
|
|
|
4
4
|
import { authStoreName } from '../../constants';
|
|
5
5
|
const mfaState = {
|
|
6
6
|
step: MFAStep.verify,
|
|
7
|
-
loading: false
|
|
7
|
+
loading: false,
|
|
8
|
+
saving: false
|
|
8
9
|
};
|
|
9
10
|
const reducers = {
|
|
10
11
|
setMfaState: typeReducerForKey('mfaState'),
|
|
@@ -14,6 +15,8 @@ const reducers = {
|
|
|
14
15
|
};
|
|
15
16
|
const actions = {
|
|
16
17
|
enrollMfa: createAction(`${authStoreName}/enrollMfa`),
|
|
18
|
+
getMFADevices: createAction(`${authStoreName}/getMFADevices`),
|
|
19
|
+
getMFAStrategies: createAction(`${authStoreName}/getMFAStrategies`),
|
|
17
20
|
verifyMfa: createAction(`${authStoreName}/verifyMfa`, payload => ({
|
|
18
21
|
payload
|
|
19
22
|
})),
|
|
@@ -22,6 +25,30 @@ const actions = {
|
|
|
22
25
|
})),
|
|
23
26
|
disableMfa: createAction(`${authStoreName}/disableMfa`, payload => ({
|
|
24
27
|
payload
|
|
28
|
+
})),
|
|
29
|
+
preDisableMfaSms: createAction(`${authStoreName}/preDisableMfaSms`, payload => ({
|
|
30
|
+
payload
|
|
31
|
+
})),
|
|
32
|
+
disableMfaSms: createAction(`${authStoreName}/disableMfaSms`, payload => ({
|
|
33
|
+
payload
|
|
34
|
+
})),
|
|
35
|
+
preEnrollMfaSms: createAction(`${authStoreName}/preEnrollMfaSms`, payload => ({
|
|
36
|
+
payload
|
|
37
|
+
})),
|
|
38
|
+
enrollMfaSms: createAction(`${authStoreName}/enrollMfaSms`, payload => ({
|
|
39
|
+
payload
|
|
40
|
+
})),
|
|
41
|
+
preEnrollMfaWebAuthn: createAction(`${authStoreName}/preEnrollMfaWebAuthn`, payload => ({
|
|
42
|
+
payload
|
|
43
|
+
})),
|
|
44
|
+
enrollMfaWebAuthn: createAction(`${authStoreName}/enrollMfaWebAuthn`, payload => ({
|
|
45
|
+
payload
|
|
46
|
+
})),
|
|
47
|
+
preDisableMfaWebAuthn: createAction(`${authStoreName}/preDisableMfaWebAuthn`, payload => ({
|
|
48
|
+
payload
|
|
49
|
+
})),
|
|
50
|
+
disableMfaWebAuthn: createAction(`${authStoreName}/disableMfaWebAuthn`, payload => ({
|
|
51
|
+
payload
|
|
25
52
|
}))
|
|
26
53
|
};
|
|
27
54
|
/**
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { MFAStrategyEnum, UserMFADevicesResponse } from '@frontegg/rest-api';
|
|
1
|
+
import { IEnrollMFASMS, IEnrollMFAWebAuthn, IPreEnrollMFASMS, MFAStrategyEnum, UserMFADevicesResponse } from '@frontegg/rest-api';
|
|
2
|
+
import { WithCallback } from '../../interfaces';
|
|
3
|
+
import { IVerifyMFAWebAuthnPayload } from '../LoginState/interfaces';
|
|
2
4
|
export declare enum MFAStep {
|
|
3
5
|
'verify' = "verify",
|
|
4
6
|
'recoveryCode' = "recoveryCode",
|
|
@@ -9,6 +11,7 @@ export declare enum MFAStep {
|
|
|
9
11
|
export interface MFAState {
|
|
10
12
|
step: MFAStep;
|
|
11
13
|
loading: boolean;
|
|
14
|
+
saving: boolean;
|
|
12
15
|
error?: any;
|
|
13
16
|
recoveryCode?: string;
|
|
14
17
|
qrCode?: string | null;
|
|
@@ -18,3 +21,11 @@ export interface MFAState {
|
|
|
18
21
|
mfaStrategies?: MFAStrategyEnum[];
|
|
19
22
|
mfaDevices?: UserMFADevicesResponse;
|
|
20
23
|
}
|
|
24
|
+
export declare type IUserPreEnrollMFASMSPayload = WithCallback<Omit<IPreEnrollMFASMS, 'maToken' | 'rememberDevice'>>;
|
|
25
|
+
export declare type IUserEnrollMFASMSPayload = WithCallback<Omit<IEnrollMFASMS, 'maToken' | 'rememberDevice'>, string | undefined>;
|
|
26
|
+
export declare type IUserEnrollMFAWebAuthnPayload = WithCallback<Omit<IEnrollMFAWebAuthn, 'options' | 'mfaToken' | 'rememberDevice'>, string | undefined> & {
|
|
27
|
+
publicKey: Credential;
|
|
28
|
+
};
|
|
29
|
+
export declare type IDisableMFAWebAuthnPayload = WithCallback<Omit<IVerifyMFAWebAuthnPayload, 'options' | 'mfaToken' | 'rememberDevice'>> & {
|
|
30
|
+
publicKey: Credential;
|
|
31
|
+
};
|