@frontegg/redux-store 6.164.0 → 6.165.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/saga.d.ts +7 -1
- package/auth/LoginState/saga.js +1 -1
- package/auth/Security/RestrictionsState/index.d.ts +12 -0
- package/auth/StepUpState/consts.d.ts +4 -0
- package/auth/StepUpState/consts.js +6 -1
- package/auth/StepUpState/index.d.ts +4 -1
- package/auth/StepUpState/index.js +5 -1
- package/auth/StepUpState/interfaces.d.ts +12 -0
- package/auth/StepUpState/saga.js +2 -0
- package/auth/StepUpState/stepUpHostedLogin.saga.d.ts +13 -0
- package/auth/StepUpState/stepUpHostedLogin.saga.js +24 -0
- package/auth/StepUpState/utils.d.ts +18 -4
- package/auth/StepUpState/utils.js +32 -5
- package/auth/index.d.ts +1 -0
- package/auth/interfaces.d.ts +4 -0
- package/auth/reducer.d.ts +1 -0
- package/index.js +1 -1
- package/node/auth/LoginState/saga.js +1 -0
- package/node/auth/StepUpState/consts.js +8 -2
- package/node/auth/StepUpState/index.js +12 -1
- package/node/auth/StepUpState/saga.js +2 -0
- package/node/auth/StepUpState/stepUpHostedLogin.saga.js +29 -0
- package/node/auth/StepUpState/utils.js +35 -6
- package/node/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CallEffect } from 'redux-saga/effects';
|
|
2
|
-
import { ISamlMetadata } from '@frontegg/rest-api';
|
|
2
|
+
import { ISamlMetadata, ResolvedTenantResult } from '@frontegg/rest-api';
|
|
3
3
|
import { AuthState } from '../interfaces';
|
|
4
4
|
export declare function refreshMetadata(): Generator<import("redux-saga/effects").PutEffect<{
|
|
5
5
|
payload: Partial<AuthState>;
|
|
@@ -15,6 +15,12 @@ export declare function loadSSOPublicConfigurationFunction(): Generator<import("
|
|
|
15
15
|
}>;
|
|
16
16
|
export declare function refreshToken(): Generator<import("redux-saga/effects").SelectEffect | CallEffect<any>, void, AuthState>;
|
|
17
17
|
export declare function refreshTokenForSocialLogins(): Generator<import("redux-saga/effects").SelectEffect | CallEffect<any>, void, AuthState>;
|
|
18
|
+
export declare function requestHostedLoginAuthorize(additionalParams?: Record<string, string>): Generator<any, void, {
|
|
19
|
+
routes: any;
|
|
20
|
+
context: any;
|
|
21
|
+
onRedirectTo: any;
|
|
22
|
+
urlStrategy: any;
|
|
23
|
+
} & string & ResolvedTenantResult>;
|
|
18
24
|
export declare function loginSagas(): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
|
|
19
25
|
export { afterAuthNavigation } from './sagas/afterAuthNavigation.saga';
|
|
20
26
|
export { mfaWithAuthenticator } from './sagas/mfaWithAuthenticator.saga';
|
package/auth/LoginState/saga.js
CHANGED
|
@@ -510,7 +510,7 @@ function* refreshOrRequestHostedLoginAuthorizeV2({
|
|
|
510
510
|
yield requestHostedLoginAuthorize(additionalParams);
|
|
511
511
|
}
|
|
512
512
|
}
|
|
513
|
-
function* requestHostedLoginAuthorize(additionalParams) {
|
|
513
|
+
export function* requestHostedLoginAuthorize(additionalParams) {
|
|
514
514
|
const {
|
|
515
515
|
routes,
|
|
516
516
|
context,
|
|
@@ -42,6 +42,10 @@ declare const reducers: {
|
|
|
42
42
|
tenantsState: import("../..").TenantsState;
|
|
43
43
|
rolesState: import("../..").RolesState;
|
|
44
44
|
sessionsState: import("../..").SessionsState;
|
|
45
|
+
/**
|
|
46
|
+
* if you see error in matcher that's mean the DispatchAction does not
|
|
47
|
+
* contains the same functions in reducers and actions
|
|
48
|
+
*/
|
|
45
49
|
hostedLoginBox?: boolean | undefined;
|
|
46
50
|
disableSilentRefresh?: boolean | undefined;
|
|
47
51
|
sessionsPolicyState: import("../..").SessionsPolicyState;
|
|
@@ -97,6 +101,10 @@ declare const reducers: {
|
|
|
97
101
|
tenantsState: import("../..").TenantsState;
|
|
98
102
|
rolesState: import("../..").RolesState;
|
|
99
103
|
sessionsState: import("../..").SessionsState;
|
|
104
|
+
/**
|
|
105
|
+
* if you see error in matcher that's mean the DispatchAction does not
|
|
106
|
+
* contains the same functions in reducers and actions
|
|
107
|
+
*/
|
|
100
108
|
hostedLoginBox?: boolean | undefined;
|
|
101
109
|
disableSilentRefresh?: boolean | undefined;
|
|
102
110
|
sessionsPolicyState: import("../..").SessionsPolicyState;
|
|
@@ -152,6 +160,10 @@ declare const reducers: {
|
|
|
152
160
|
tenantsState: import("../..").TenantsState;
|
|
153
161
|
rolesState: import("../..").RolesState;
|
|
154
162
|
sessionsState: import("../..").SessionsState;
|
|
163
|
+
/**
|
|
164
|
+
* if you see error in matcher that's mean the DispatchAction does not
|
|
165
|
+
* contains the same functions in reducers and actions
|
|
166
|
+
*/
|
|
155
167
|
hostedLoginBox?: boolean | undefined;
|
|
156
168
|
disableSilentRefresh?: boolean | undefined;
|
|
157
169
|
sessionsPolicyState: import("../..").SessionsPolicyState;
|
|
@@ -15,3 +15,7 @@ export declare const AMR_ADDITIONAL_VALUE: string[];
|
|
|
15
15
|
* Used for scenarios when we logout for re-login and then should redirect to step up page
|
|
16
16
|
*/
|
|
17
17
|
export declare const SHOULD_STEP_UP_KEY = "SHOULD_STEP_UP";
|
|
18
|
+
/**
|
|
19
|
+
* The name of the query param that contains the max age of the step up
|
|
20
|
+
*/
|
|
21
|
+
export declare const STEP_UP_MAX_AGE_PARAM_NAME = "maxAge";
|
|
@@ -17,4 +17,9 @@ export const AMR_ADDITIONAL_VALUE = ['otp', 'sms', 'hwk'];
|
|
|
17
17
|
* SHOULD_STEP_UP_KEY local storage key
|
|
18
18
|
* Used for scenarios when we logout for re-login and then should redirect to step up page
|
|
19
19
|
*/
|
|
20
|
-
export const SHOULD_STEP_UP_KEY = 'SHOULD_STEP_UP';
|
|
20
|
+
export const SHOULD_STEP_UP_KEY = 'SHOULD_STEP_UP';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The name of the query param that contains the max age of the step up
|
|
24
|
+
*/
|
|
25
|
+
export const STEP_UP_MAX_AGE_PARAM_NAME = 'maxAge';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IPreVerifyMFA, IVerifyMFASMS, IVerifyMFAEmailCode } from '@frontegg/rest-api';
|
|
2
|
-
import { IGenerateStepUpSession, IStepUpWithAuthenticator, StepUpState } from './interfaces';
|
|
2
|
+
import { IGenerateStepUpSession, IStepUpHostedLogin, IStepUpWithAuthenticator, StepUpState } from './interfaces';
|
|
3
3
|
import { WithCallback } from '../../interfaces';
|
|
4
4
|
import { IPreVerifyMFAWebAuthNForLoginResponse, IVerifyMFAWebAuthnPayload, WithDeviceId } from '../LoginState/interfaces';
|
|
5
5
|
declare const stepUpState: StepUpState;
|
|
@@ -108,6 +108,7 @@ declare const reducers: {
|
|
|
108
108
|
};
|
|
109
109
|
};
|
|
110
110
|
declare const actions: {
|
|
111
|
+
stepUpHostedLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[IStepUpHostedLogin], IStepUpHostedLogin, string, never, never>;
|
|
111
112
|
generateStepUpSession: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IGenerateStepUpSession, boolean>], WithCallback<IGenerateStepUpSession, boolean>, string, never, never>;
|
|
112
113
|
stepUpWithAuthenticator: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IStepUpWithAuthenticator, boolean>], WithCallback<IStepUpWithAuthenticator, boolean>, string, never, never>;
|
|
113
114
|
preVerifyMFASMSForStepUp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<WithDeviceId<IPreVerifyMFA>, boolean>], WithCallback<WithDeviceId<IPreVerifyMFA>, boolean>, string, never, never>;
|
|
@@ -125,6 +126,7 @@ declare type DispatchedActions = {
|
|
|
125
126
|
setStepUpState: (state: Partial<StepUpState>) => void;
|
|
126
127
|
resetStepUpState: () => void;
|
|
127
128
|
generateStepUpSession: (payload: WithCallback<IGenerateStepUpSession>) => void;
|
|
129
|
+
stepUpHostedLogin: (payload: IStepUpHostedLogin) => void;
|
|
128
130
|
stepUpWithAuthenticator: (payload: WithCallback<IStepUpWithAuthenticator>) => void;
|
|
129
131
|
preVerifyMFASMSForStepUp: (payload: WithCallback<WithDeviceId<IPreVerifyMFA>>) => void;
|
|
130
132
|
verifyMFASMSForStepUp: (payload: WithCallback<WithDeviceId<IVerifyMFASMS>>) => void;
|
|
@@ -136,3 +138,4 @@ declare type DispatchedActions = {
|
|
|
136
138
|
export declare type StepUpActions = DispatchedActions;
|
|
137
139
|
export { stepUpState, reducers as stepUpReducers, actions as stepUpActions };
|
|
138
140
|
export * from './utils';
|
|
141
|
+
export { STEP_UP_MAX_AGE_PARAM_NAME } from './consts';
|
|
@@ -13,6 +13,9 @@ const reducers = {
|
|
|
13
13
|
})
|
|
14
14
|
};
|
|
15
15
|
const actions = {
|
|
16
|
+
stepUpHostedLogin: createAction(`${authStoreName}/stepUpHostedLogin`, payload => ({
|
|
17
|
+
payload
|
|
18
|
+
})),
|
|
16
19
|
generateStepUpSession: createAction(`${authStoreName}/generateStepUpSession`, payload => ({
|
|
17
20
|
payload
|
|
18
21
|
})),
|
|
@@ -51,4 +54,5 @@ const actions = {
|
|
|
51
54
|
*/
|
|
52
55
|
const Matcher = {};
|
|
53
56
|
export { stepUpState, reducers as stepUpReducers, actions as stepUpActions };
|
|
54
|
-
export * from './utils';
|
|
57
|
+
export * from './utils';
|
|
58
|
+
export { STEP_UP_MAX_AGE_PARAM_NAME } from './consts';
|
|
@@ -21,3 +21,15 @@ export interface IStepUpWithAuthenticator {
|
|
|
21
21
|
mfaToken: string;
|
|
22
22
|
value: string;
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Step up hosted login options
|
|
26
|
+
*/
|
|
27
|
+
export interface IStepUpHostedLogin {
|
|
28
|
+
maxAge?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Step up options (for stepUp function)
|
|
32
|
+
*/
|
|
33
|
+
export interface StepUpOptions {
|
|
34
|
+
maxAge?: number;
|
|
35
|
+
}
|
package/auth/StepUpState/saga.js
CHANGED
|
@@ -5,6 +5,7 @@ import { preVerifyMFASMS, verifyMFASMS } from '../LoginState/sagas/mfaWithSMS.sa
|
|
|
5
5
|
import { preVerifyMFAWebAuthn, verifyMFAWebAuthn } from '../LoginState/sagas/mfaWithWebAuthn.saga';
|
|
6
6
|
import { verifyMFAEmailCode, preVerifyMFAEmailCode } from '../LoginState/sagas/mfaWithEmailCode.saga';
|
|
7
7
|
import { generateStepUpSession } from './generateStepUpSession.saga';
|
|
8
|
+
import { stepUpHostedLogin } from './stepUpHostedLogin.saga';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Step up with authenticator app
|
|
@@ -93,6 +94,7 @@ export function* preVerifyMFAEmailCodeForStepUp({
|
|
|
93
94
|
yield preVerifyMFAEmailCode(payload, actions.setStepUpState);
|
|
94
95
|
}
|
|
95
96
|
export function* stepUpSagas() {
|
|
97
|
+
yield takeLeading(actions.stepUpHostedLogin, stepUpHostedLogin);
|
|
96
98
|
yield takeLeading(actions.generateStepUpSession, generateStepUpSession);
|
|
97
99
|
yield takeLeading(actions.stepUpWithAuthenticator, stepUpWithAuthenticator);
|
|
98
100
|
yield takeLeading(actions.preVerifyMFASMSForStepUp, preVerifyMFASMSForStepUp);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PayloadAction } from '@reduxjs/toolkit';
|
|
2
|
+
import { IStepUpHostedLogin } from './interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Step up for hosted login apps
|
|
5
|
+
* @param payload.maxAge
|
|
6
|
+
* @param payload.callback
|
|
7
|
+
*/
|
|
8
|
+
export declare function stepUpHostedLogin({ payload }: PayloadAction<IStepUpHostedLogin>): Generator<Generator<any, void, {
|
|
9
|
+
routes: any;
|
|
10
|
+
context: any;
|
|
11
|
+
onRedirectTo: any;
|
|
12
|
+
urlStrategy: any;
|
|
13
|
+
} & string & import("@frontegg/rest-api").ResolvedTenantResult>, void, unknown>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { requestHostedLoginAuthorize } from '../LoginState/saga';
|
|
2
|
+
import { ACR_VALUE } from './consts';
|
|
3
|
+
import { setAfterAuthRedirectUrlForStepUp } from './utils';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Step up for hosted login apps
|
|
7
|
+
* @param payload.maxAge
|
|
8
|
+
* @param payload.callback
|
|
9
|
+
*/
|
|
10
|
+
export function* stepUpHostedLogin({
|
|
11
|
+
payload
|
|
12
|
+
}) {
|
|
13
|
+
const params = {
|
|
14
|
+
acr_values: ACR_VALUE
|
|
15
|
+
};
|
|
16
|
+
const {
|
|
17
|
+
maxAge
|
|
18
|
+
} = payload || {};
|
|
19
|
+
if (maxAge !== undefined) {
|
|
20
|
+
params.max_age = maxAge.toString();
|
|
21
|
+
}
|
|
22
|
+
setAfterAuthRedirectUrlForStepUp();
|
|
23
|
+
yield requestHostedLoginAuthorize(params);
|
|
24
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { RedirectOptions } from '@frontegg/rest-api';
|
|
2
|
+
export interface IsSteppedUpOptions {
|
|
3
|
+
maxAge?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface SteppedUpJWTValues {
|
|
2
6
|
amr?: string[];
|
|
3
7
|
acr?: string;
|
|
4
8
|
auth_time?: number;
|
|
5
|
-
maxAge?: number;
|
|
6
9
|
}
|
|
7
10
|
/**
|
|
8
11
|
* @param options.amr
|
|
@@ -11,5 +14,16 @@ interface IsSteppedUpOptions {
|
|
|
11
14
|
* @param options.maxAge - max age of step up
|
|
12
15
|
* @returns true when the user is stepped up, false otherwise
|
|
13
16
|
*/
|
|
14
|
-
export declare const isSteppedUp: (
|
|
15
|
-
|
|
17
|
+
export declare const isSteppedUp: (user?: SteppedUpJWTValues | null | undefined, { maxAge }?: IsSteppedUpOptions) => boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Set the url and query params in the local storage FRONTEGG_AFTER_AUTH_REDIRECT_URL value
|
|
20
|
+
*/
|
|
21
|
+
export declare function setAfterAuthRedirectUrlForStepUp(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Redirects to the step up url with the max age param and set the redirect url in the local storage
|
|
24
|
+
* The redirect url will be used after the step up flow is done
|
|
25
|
+
* @param stepUpUrl - step up url to redirect to
|
|
26
|
+
* @param onRedirectTo - redirect to function
|
|
27
|
+
* @param maxAge - max age of step up
|
|
28
|
+
*/
|
|
29
|
+
export declare const redirectByStepUpUrl: (stepUpUrl: string, onRedirectTo: (path: string, opts?: RedirectOptions | undefined) => void, maxAge?: number | undefined) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FRONTEGG_AFTER_AUTH_REDIRECT_URL } from '../../constants';
|
|
2
|
+
import { ACR_VALUE, AMR_MFA_VALUE, AMR_ADDITIONAL_VALUE, STEP_UP_MAX_AGE_PARAM_NAME } from './consts';
|
|
2
3
|
/**
|
|
3
4
|
* @param options.amr
|
|
4
5
|
* @param options.acr
|
|
@@ -6,12 +7,15 @@ import { ACR_VALUE, AMR_MFA_VALUE, AMR_ADDITIONAL_VALUE } from './consts';
|
|
|
6
7
|
* @param options.maxAge - max age of step up
|
|
7
8
|
* @returns true when the user is stepped up, false otherwise
|
|
8
9
|
*/
|
|
9
|
-
export const isSteppedUp = ({
|
|
10
|
-
amr = [],
|
|
11
|
-
acr = '',
|
|
12
|
-
auth_time,
|
|
10
|
+
export const isSteppedUp = (user, {
|
|
13
11
|
maxAge
|
|
14
12
|
} = {}) => {
|
|
13
|
+
if (!user) return false;
|
|
14
|
+
const {
|
|
15
|
+
amr = [],
|
|
16
|
+
acr = '',
|
|
17
|
+
auth_time
|
|
18
|
+
} = user;
|
|
15
19
|
if (maxAge && auth_time) {
|
|
16
20
|
// when user is logged in for a long time (more than maxAge, but jwt is still valid because it's not refreshed yet)
|
|
17
21
|
const isMaxAgeValid = Date.now() / 1000 - auth_time <= maxAge;
|
|
@@ -21,4 +25,27 @@ export const isSteppedUp = ({
|
|
|
21
25
|
const isAMRIncludesMFA = amr.indexOf(AMR_MFA_VALUE) !== -1;
|
|
22
26
|
const isAMRIncludesMethod = AMR_ADDITIONAL_VALUE.find(method => amr.indexOf(method)) !== undefined;
|
|
23
27
|
return isACRValid && isAMRIncludesMFA && isAMRIncludesMethod;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Set the url and query params in the local storage FRONTEGG_AFTER_AUTH_REDIRECT_URL value
|
|
32
|
+
*/
|
|
33
|
+
export function setAfterAuthRedirectUrlForStepUp() {
|
|
34
|
+
const encodedRedirectUrl = window.location.pathname + window.location.search;
|
|
35
|
+
window.localStorage.setItem(FRONTEGG_AFTER_AUTH_REDIRECT_URL, encodedRedirectUrl);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Redirects to the step up url with the max age param and set the redirect url in the local storage
|
|
40
|
+
* The redirect url will be used after the step up flow is done
|
|
41
|
+
* @param stepUpUrl - step up url to redirect to
|
|
42
|
+
* @param onRedirectTo - redirect to function
|
|
43
|
+
* @param maxAge - max age of step up
|
|
44
|
+
*/
|
|
45
|
+
export const redirectByStepUpUrl = (stepUpUrl, onRedirectTo, maxAge) => {
|
|
46
|
+
setAfterAuthRedirectUrlForStepUp();
|
|
47
|
+
const maxAgePart = maxAge !== undefined ? `?${STEP_UP_MAX_AGE_PARAM_NAME}=${maxAge}` : '';
|
|
48
|
+
onRedirectTo(`${stepUpUrl}${maxAgePart}`, {
|
|
49
|
+
refresh: false
|
|
50
|
+
});
|
|
24
51
|
};
|
package/auth/index.d.ts
CHANGED
|
@@ -495,6 +495,7 @@ declare const _default: {
|
|
|
495
495
|
} | undefined, string, never, never>;
|
|
496
496
|
loginViaSocialLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./SocialLogins/interfaces").ILoginViaSocialLoginPayload], import("./SocialLogins/interfaces").ILoginViaSocialLoginPayload, string, never, never>;
|
|
497
497
|
setSocialLoginError: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").ISetSocialLoginError], import("@frontegg/rest-api").ISetSocialLoginError, string, never, never>;
|
|
498
|
+
stepUpHostedLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./StepUpState/interfaces").IStepUpHostedLogin], import("./StepUpState/interfaces").IStepUpHostedLogin, string, never, never>;
|
|
498
499
|
generateStepUpSession: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<import("./StepUpState/interfaces").IGenerateStepUpSession, boolean>], import("..").WithCallback<import("./StepUpState/interfaces").IGenerateStepUpSession, boolean>, string, never, never>;
|
|
499
500
|
stepUpWithAuthenticator: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<import("./StepUpState/interfaces").IStepUpWithAuthenticator, boolean>], import("..").WithCallback<import("./StepUpState/interfaces").IStepUpWithAuthenticator, boolean>, string, never, never>;
|
|
500
501
|
preVerifyMFASMSForStepUp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<import("./LoginState/interfaces").WithDeviceId<import("@frontegg/rest-api").IPreVerifyMFA>, boolean>], import("..").WithCallback<import("./LoginState/interfaces").WithDeviceId<import("@frontegg/rest-api").IPreVerifyMFA>, boolean>, string, never, never>;
|
package/auth/interfaces.d.ts
CHANGED
|
@@ -34,7 +34,11 @@ export interface User extends IUserProfile {
|
|
|
34
34
|
accessToken: string;
|
|
35
35
|
refreshToken?: string;
|
|
36
36
|
expiresIn: number;
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated use exp instead
|
|
39
|
+
*/
|
|
37
40
|
expires: string;
|
|
41
|
+
exp: number;
|
|
38
42
|
sid?: string;
|
|
39
43
|
act?: Actor;
|
|
40
44
|
subAccountAccessAllowed?: boolean;
|
package/auth/reducer.d.ts
CHANGED
|
@@ -453,6 +453,7 @@ declare const actions: {
|
|
|
453
453
|
} | undefined, string, never, never>;
|
|
454
454
|
loginViaSocialLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import(".").ILoginViaSocialLoginPayload], import(".").ILoginViaSocialLoginPayload, string, never, never>;
|
|
455
455
|
setSocialLoginError: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").ISetSocialLoginError], import("@frontegg/rest-api").ISetSocialLoginError, string, never, never>;
|
|
456
|
+
stepUpHostedLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import(".").IStepUpHostedLogin], import(".").IStepUpHostedLogin, string, never, never>;
|
|
456
457
|
generateStepUpSession: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<import(".").IGenerateStepUpSession, boolean>], import("..").WithCallback<import(".").IGenerateStepUpSession, boolean>, string, never, never>;
|
|
457
458
|
stepUpWithAuthenticator: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<import(".").IStepUpWithAuthenticator, boolean>], import("..").WithCallback<import(".").IStepUpWithAuthenticator, boolean>, string, never, never>;
|
|
458
459
|
preVerifyMFASMSForStepUp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<import(".").WithDeviceId<import("@frontegg/rest-api").IPreVerifyMFA>, boolean>], import("..").WithCallback<import(".").WithDeviceId<import("@frontegg/rest-api").IPreVerifyMFA>, boolean>, string, never, never>;
|
package/index.js
CHANGED
|
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "mfaWithAuthenticator", {
|
|
|
22
22
|
exports.refreshMetadata = refreshMetadata;
|
|
23
23
|
exports.refreshToken = refreshToken;
|
|
24
24
|
exports.refreshTokenForSocialLogins = refreshTokenForSocialLogins;
|
|
25
|
+
exports.requestHostedLoginAuthorize = requestHostedLoginAuthorize;
|
|
25
26
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
26
27
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
27
28
|
var _effects = require("redux-saga/effects");
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.SHOULD_STEP_UP_KEY = exports.AMR_MFA_VALUE = exports.AMR_ADDITIONAL_VALUE = exports.ACR_VALUE = void 0;
|
|
6
|
+
exports.STEP_UP_MAX_AGE_PARAM_NAME = exports.SHOULD_STEP_UP_KEY = exports.AMR_MFA_VALUE = exports.AMR_ADDITIONAL_VALUE = exports.ACR_VALUE = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* The required ACR (Authorization Context Reference) value for the step up flow
|
|
9
9
|
*/
|
|
@@ -27,4 +27,10 @@ const AMR_ADDITIONAL_VALUE = ['otp', 'sms', 'hwk'];
|
|
|
27
27
|
*/
|
|
28
28
|
exports.AMR_ADDITIONAL_VALUE = AMR_ADDITIONAL_VALUE;
|
|
29
29
|
const SHOULD_STEP_UP_KEY = 'SHOULD_STEP_UP';
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The name of the query param that contains the max age of the step up
|
|
33
|
+
*/
|
|
34
|
+
exports.SHOULD_STEP_UP_KEY = SHOULD_STEP_UP_KEY;
|
|
35
|
+
const STEP_UP_MAX_AGE_PARAM_NAME = 'maxAge';
|
|
36
|
+
exports.STEP_UP_MAX_AGE_PARAM_NAME = STEP_UP_MAX_AGE_PARAM_NAME;
|
|
@@ -6,8 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
stepUpState: true,
|
|
8
8
|
stepUpReducers: true,
|
|
9
|
-
stepUpActions: true
|
|
9
|
+
stepUpActions: true,
|
|
10
|
+
STEP_UP_MAX_AGE_PARAM_NAME: true
|
|
10
11
|
};
|
|
12
|
+
Object.defineProperty(exports, "STEP_UP_MAX_AGE_PARAM_NAME", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _consts.STEP_UP_MAX_AGE_PARAM_NAME;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
11
18
|
exports.stepUpState = exports.stepUpReducers = exports.stepUpActions = void 0;
|
|
12
19
|
var _toolkit = require("@reduxjs/toolkit");
|
|
13
20
|
var _utils = require("../utils");
|
|
@@ -24,6 +31,7 @@ Object.keys(_utils2).forEach(function (key) {
|
|
|
24
31
|
}
|
|
25
32
|
});
|
|
26
33
|
});
|
|
34
|
+
var _consts = require("./consts");
|
|
27
35
|
const stepUpState = {
|
|
28
36
|
loading: false,
|
|
29
37
|
mfaDevices: undefined,
|
|
@@ -38,6 +46,9 @@ const reducers = {
|
|
|
38
46
|
};
|
|
39
47
|
exports.stepUpReducers = reducers;
|
|
40
48
|
const actions = {
|
|
49
|
+
stepUpHostedLogin: (0, _toolkit.createAction)(`${_constants.authStoreName}/stepUpHostedLogin`, payload => ({
|
|
50
|
+
payload
|
|
51
|
+
})),
|
|
41
52
|
generateStepUpSession: (0, _toolkit.createAction)(`${_constants.authStoreName}/generateStepUpSession`, payload => ({
|
|
42
53
|
payload
|
|
43
54
|
})),
|
|
@@ -18,6 +18,7 @@ var _mfaWithSMS = require("../LoginState/sagas/mfaWithSMS.saga");
|
|
|
18
18
|
var _mfaWithWebAuthn = require("../LoginState/sagas/mfaWithWebAuthn.saga");
|
|
19
19
|
var _mfaWithEmailCode = require("../LoginState/sagas/mfaWithEmailCode.saga");
|
|
20
20
|
var _generateStepUpSession = require("./generateStepUpSession.saga");
|
|
21
|
+
var _stepUpHostedLogin = require("./stepUpHostedLogin.saga");
|
|
21
22
|
/**
|
|
22
23
|
* Step up with authenticator app
|
|
23
24
|
* @param payload.callback - callback function to be called after the verification is done
|
|
@@ -105,6 +106,7 @@ function* preVerifyMFAEmailCodeForStepUp({
|
|
|
105
106
|
yield (0, _mfaWithEmailCode.preVerifyMFAEmailCode)(payload, _reducer.actions.setStepUpState);
|
|
106
107
|
}
|
|
107
108
|
function* stepUpSagas() {
|
|
109
|
+
yield (0, _effects.takeLeading)(_reducer.actions.stepUpHostedLogin, _stepUpHostedLogin.stepUpHostedLogin);
|
|
108
110
|
yield (0, _effects.takeLeading)(_reducer.actions.generateStepUpSession, _generateStepUpSession.generateStepUpSession);
|
|
109
111
|
yield (0, _effects.takeLeading)(_reducer.actions.stepUpWithAuthenticator, stepUpWithAuthenticator);
|
|
110
112
|
yield (0, _effects.takeLeading)(_reducer.actions.preVerifyMFASMSForStepUp, preVerifyMFASMSForStepUp);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.stepUpHostedLogin = stepUpHostedLogin;
|
|
7
|
+
var _saga = require("../LoginState/saga");
|
|
8
|
+
var _consts = require("./consts");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
/**
|
|
11
|
+
* Step up for hosted login apps
|
|
12
|
+
* @param payload.maxAge
|
|
13
|
+
* @param payload.callback
|
|
14
|
+
*/
|
|
15
|
+
function* stepUpHostedLogin({
|
|
16
|
+
payload
|
|
17
|
+
}) {
|
|
18
|
+
const params = {
|
|
19
|
+
acr_values: _consts.ACR_VALUE
|
|
20
|
+
};
|
|
21
|
+
const {
|
|
22
|
+
maxAge
|
|
23
|
+
} = payload || {};
|
|
24
|
+
if (maxAge !== undefined) {
|
|
25
|
+
params.max_age = maxAge.toString();
|
|
26
|
+
}
|
|
27
|
+
(0, _utils.setAfterAuthRedirectUrlForStepUp)();
|
|
28
|
+
yield (0, _saga.requestHostedLoginAuthorize)(params);
|
|
29
|
+
}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isSteppedUp = void 0;
|
|
6
|
+
exports.redirectByStepUpUrl = exports.isSteppedUp = void 0;
|
|
7
|
+
exports.setAfterAuthRedirectUrlForStepUp = setAfterAuthRedirectUrlForStepUp;
|
|
8
|
+
var _constants = require("../../constants");
|
|
7
9
|
var _consts = require("./consts");
|
|
8
10
|
/**
|
|
9
11
|
* @param options.amr
|
|
@@ -12,12 +14,15 @@ var _consts = require("./consts");
|
|
|
12
14
|
* @param options.maxAge - max age of step up
|
|
13
15
|
* @returns true when the user is stepped up, false otherwise
|
|
14
16
|
*/
|
|
15
|
-
const isSteppedUp = ({
|
|
16
|
-
amr = [],
|
|
17
|
-
acr = '',
|
|
18
|
-
auth_time,
|
|
17
|
+
const isSteppedUp = (user, {
|
|
19
18
|
maxAge
|
|
20
19
|
} = {}) => {
|
|
20
|
+
if (!user) return false;
|
|
21
|
+
const {
|
|
22
|
+
amr = [],
|
|
23
|
+
acr = '',
|
|
24
|
+
auth_time
|
|
25
|
+
} = user;
|
|
21
26
|
if (maxAge && auth_time) {
|
|
22
27
|
// when user is logged in for a long time (more than maxAge, but jwt is still valid because it's not refreshed yet)
|
|
23
28
|
const isMaxAgeValid = Date.now() / 1000 - auth_time <= maxAge;
|
|
@@ -28,4 +33,28 @@ const isSteppedUp = ({
|
|
|
28
33
|
const isAMRIncludesMethod = _consts.AMR_ADDITIONAL_VALUE.find(method => amr.indexOf(method)) !== undefined;
|
|
29
34
|
return isACRValid && isAMRIncludesMFA && isAMRIncludesMethod;
|
|
30
35
|
};
|
|
31
|
-
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Set the url and query params in the local storage FRONTEGG_AFTER_AUTH_REDIRECT_URL value
|
|
39
|
+
*/
|
|
40
|
+
exports.isSteppedUp = isSteppedUp;
|
|
41
|
+
function setAfterAuthRedirectUrlForStepUp() {
|
|
42
|
+
const encodedRedirectUrl = window.location.pathname + window.location.search;
|
|
43
|
+
window.localStorage.setItem(_constants.FRONTEGG_AFTER_AUTH_REDIRECT_URL, encodedRedirectUrl);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Redirects to the step up url with the max age param and set the redirect url in the local storage
|
|
48
|
+
* The redirect url will be used after the step up flow is done
|
|
49
|
+
* @param stepUpUrl - step up url to redirect to
|
|
50
|
+
* @param onRedirectTo - redirect to function
|
|
51
|
+
* @param maxAge - max age of step up
|
|
52
|
+
*/
|
|
53
|
+
const redirectByStepUpUrl = (stepUpUrl, onRedirectTo, maxAge) => {
|
|
54
|
+
setAfterAuthRedirectUrlForStepUp();
|
|
55
|
+
const maxAgePart = maxAge !== undefined ? `?${_consts.STEP_UP_MAX_AGE_PARAM_NAME}=${maxAge}` : '';
|
|
56
|
+
onRedirectTo(`${stepUpUrl}${maxAgePart}`, {
|
|
57
|
+
refresh: false
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
exports.redirectByStepUpUrl = redirectByStepUpUrl;
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/redux-store",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.165.0-alpha.1",
|
|
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.0.1",
|
|
10
|
-
"@frontegg/rest-api": "3.1.
|
|
10
|
+
"@frontegg/rest-api": "3.1.55",
|
|
11
11
|
"@reduxjs/toolkit": "1.8.5",
|
|
12
12
|
"fast-deep-equal": "3.1.3",
|
|
13
13
|
"redux-saga": "^1.2.1",
|