@frontegg/redux-store 6.129.0-alpha.0 → 6.129.0-alpha.2
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/index.d.ts +16 -2
- package/auth/LoginState/index.js +3 -0
- package/auth/LoginState/saga.js +48 -2
- package/auth/LoginState/utils.d.ts +1 -0
- package/auth/LoginState/utils.js +3 -0
- package/auth/index.d.ts +9 -0
- package/auth/reducer.d.ts +9 -0
- package/index.js +1 -1
- package/node/auth/LoginState/index.js +3 -0
- package/node/auth/LoginState/saga.js +47 -1
- package/node/auth/LoginState/utils.js +6 -2
- package/node/index.js +1 -1
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ declare const reducers: {
|
|
|
25
25
|
loginState: LoginState;
|
|
26
26
|
activateState: import("..").ActivateAccountState;
|
|
27
27
|
acceptInvitationState: import("..").AcceptInvitationState;
|
|
28
|
-
forgotPasswordState: import("
|
|
28
|
+
forgotPasswordState: import("..").ForgotPasswordState;
|
|
29
29
|
resetPhoneNumberState: import("..").ResetPhoneNumberState;
|
|
30
30
|
ssoState: import("..").SSOState;
|
|
31
31
|
profileState: import("..").ProfileState;
|
|
@@ -71,7 +71,7 @@ declare const reducers: {
|
|
|
71
71
|
loginState: LoginState;
|
|
72
72
|
activateState: import("..").ActivateAccountState;
|
|
73
73
|
acceptInvitationState: import("..").AcceptInvitationState;
|
|
74
|
-
forgotPasswordState: import("
|
|
74
|
+
forgotPasswordState: import("..").ForgotPasswordState;
|
|
75
75
|
resetPhoneNumberState: import("..").ResetPhoneNumberState;
|
|
76
76
|
ssoState: import("..").SSOState;
|
|
77
77
|
profileState: import("..").ProfileState;
|
|
@@ -107,6 +107,15 @@ declare const actions: {
|
|
|
107
107
|
requestAuthorize: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(boolean | undefined)?], boolean, string, never, never>;
|
|
108
108
|
requestAuthorizeSSR: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[FronteggNextJSSession], FronteggNextJSSession, string, never, never>;
|
|
109
109
|
requestHostedLoginAuthorize: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Record<string, string> | undefined)?], Record<string, string> | undefined, string, never, never>;
|
|
110
|
+
requestHostedLoginAuthorizeV2: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[({
|
|
111
|
+
additionalParams?: Record<string, string> | undefined;
|
|
112
|
+
shouldRedirectToLogin?: boolean | undefined;
|
|
113
|
+
firstTime?: boolean | undefined;
|
|
114
|
+
} | undefined)?], {
|
|
115
|
+
additionalParams?: Record<string, string> | undefined;
|
|
116
|
+
shouldRedirectToLogin?: boolean | undefined;
|
|
117
|
+
firstTime?: boolean | undefined;
|
|
118
|
+
} | undefined, string, never, never>;
|
|
110
119
|
handleHostedLoginCallback: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[HostedLoginCallback], HostedLoginCallback, string, never, never>;
|
|
111
120
|
afterAuthNavigation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
112
121
|
preLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IPreLogin & {
|
|
@@ -173,6 +182,11 @@ declare type DispatchedActions = {
|
|
|
173
182
|
requestAuthorize: (payload?: boolean) => void;
|
|
174
183
|
requestAuthorizeSSR: (payload: FronteggNextJSSession) => void;
|
|
175
184
|
requestHostedLoginAuthorize: (payload?: Record<string, string>) => void;
|
|
185
|
+
requestHostedLoginAuthorizeV2: (payload?: {
|
|
186
|
+
additionalParams?: Record<string, string>;
|
|
187
|
+
shouldRedirectToLogin?: boolean;
|
|
188
|
+
firstTime?: boolean;
|
|
189
|
+
}) => void;
|
|
176
190
|
handleHostedLoginCallback: (payload: HostedLoginCallback) => void;
|
|
177
191
|
afterAuthNavigation: () => void;
|
|
178
192
|
preLogin: (payload: WithCallback<IPreLogin & {
|
package/auth/LoginState/index.js
CHANGED
|
@@ -25,6 +25,9 @@ const actions = {
|
|
|
25
25
|
requestHostedLoginAuthorize: createAction(`${authStoreName}/requestHostedLoginAuthorize`, payload => ({
|
|
26
26
|
payload
|
|
27
27
|
})),
|
|
28
|
+
requestHostedLoginAuthorizeV2: createAction(`${authStoreName}/requestHostedLoginAuthorizeV2`, payload => ({
|
|
29
|
+
payload
|
|
30
|
+
})),
|
|
28
31
|
handleHostedLoginCallback: createAction(`${authStoreName}/handleHostedLoginCallback`, payload => ({
|
|
29
32
|
payload
|
|
30
33
|
})),
|
package/auth/LoginState/saga.js
CHANGED
|
@@ -37,7 +37,7 @@ import { ResetPhoneNumberStep } from '../ResetPhoneNumberState/interfaces';
|
|
|
37
37
|
import { base64urlDecode, delay, publicKeyCredentialToJSON } from '../utils';
|
|
38
38
|
import { loadPublicAuthStrategiesPolicy } from '../SecurityPolicyState/saga';
|
|
39
39
|
import { getPasskeysVendorPolicy } from '../PasskeysState/helpers';
|
|
40
|
-
import { getPathAndSearchParamsFromUrl, getRedirectUrl, getSearchParam, TENANT_ID_PARAM_KEY, getMfaStepForEnrolledUsers, getMfaStepForNotEnrolledUsers, isMfaRequired } from './utils';
|
|
40
|
+
import { getPathAndSearchParamsFromUrl, getRedirectUrl, getSearchParam, TENANT_ID_PARAM_KEY, getMfaStepForEnrolledUsers, getMfaStepForNotEnrolledUsers, isMfaRequired, isOauthCallbackRoute } from './utils';
|
|
41
41
|
import { errorHandler } from '../../utils';
|
|
42
42
|
import { authStrategyLoginStepMap } from './consts';
|
|
43
43
|
import { isEntitlementsDeeplyEqual } from '../Entitlements';
|
|
@@ -564,6 +564,47 @@ function* refreshOrRequestHostedLoginAuthorize({
|
|
|
564
564
|
yield requestHostedLoginAuthorize(additionalParams);
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
|
+
function* refreshOrRequestHostedLoginAuthorizeV2({
|
|
568
|
+
payload: {
|
|
569
|
+
additionalParams,
|
|
570
|
+
shouldRedirectToLogin,
|
|
571
|
+
firstTime
|
|
572
|
+
}
|
|
573
|
+
}) {
|
|
574
|
+
if (firstTime) {
|
|
575
|
+
const {
|
|
576
|
+
urlStrategy
|
|
577
|
+
} = yield select(state => ({
|
|
578
|
+
urlStrategy: state.root.urlStrategy
|
|
579
|
+
}));
|
|
580
|
+
const activeUri = getUri(urlStrategy);
|
|
581
|
+
yield put(actions.setState({
|
|
582
|
+
isLoading: true
|
|
583
|
+
}));
|
|
584
|
+
if (isOauthCallbackRoute(activeUri)) {
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
const {
|
|
589
|
+
disableSilentRefresh
|
|
590
|
+
} = yield select(state => ({
|
|
591
|
+
disableSilentRefresh: state.auth.disableSilentRefresh
|
|
592
|
+
}));
|
|
593
|
+
try {
|
|
594
|
+
if (disableSilentRefresh) {
|
|
595
|
+
throw new Error('silent refresh is disabled');
|
|
596
|
+
}
|
|
597
|
+
yield requestHostedLoginSilentAuthorize();
|
|
598
|
+
} catch (e) {
|
|
599
|
+
if (!shouldRedirectToLogin) {
|
|
600
|
+
yield put(actions.setState({
|
|
601
|
+
isLoading: false
|
|
602
|
+
}));
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
yield requestHostedLoginAuthorize(additionalParams);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
567
608
|
function* requestHostedLoginAuthorize(additionalParams) {
|
|
568
609
|
const {
|
|
569
610
|
routes,
|
|
@@ -665,9 +706,13 @@ function* handleHostedLoginCallback({
|
|
|
665
706
|
try {
|
|
666
707
|
const response = yield call(api.auth.exchangeOAuthTokensV2, body);
|
|
667
708
|
yield call(afterAuthenticationStateUpdate, response, {
|
|
668
|
-
isAuthenticated: true
|
|
709
|
+
isAuthenticated: true,
|
|
710
|
+
isLoading: false
|
|
669
711
|
});
|
|
670
712
|
} catch (e) {
|
|
713
|
+
yield put(actions.setState({
|
|
714
|
+
isLoading: false
|
|
715
|
+
}));
|
|
671
716
|
console.error('Failed to exchangeOAuthTokens', e);
|
|
672
717
|
} finally {
|
|
673
718
|
yield afterAuthNavigation();
|
|
@@ -1894,6 +1939,7 @@ export function* loginSagas() {
|
|
|
1894
1939
|
yield takeLeading(actions.requestAuthorize, requestAuthorize);
|
|
1895
1940
|
yield takeLeading(actions.requestAuthorizeSSR, requestAuthorizeSSR);
|
|
1896
1941
|
yield takeLeading(actions.requestHostedLoginAuthorize, refreshOrRequestHostedLoginAuthorize);
|
|
1942
|
+
yield takeLeading(actions.requestHostedLoginAuthorizeV2, refreshOrRequestHostedLoginAuthorizeV2);
|
|
1897
1943
|
yield takeLeading(actions.handleHostedLoginCallback, handleHostedLoginCallback);
|
|
1898
1944
|
yield takeLeading(actions.preLogin, preLogin);
|
|
1899
1945
|
yield takeLeading(actions.postLogin, postLogin);
|
|
@@ -24,3 +24,4 @@ export declare const getNumberOfMfaDevices: (mfaDevices: UserMFADevicesResponse)
|
|
|
24
24
|
};
|
|
25
25
|
export declare const getMfaStepForEnrolledUsers: (mfaDevices: UserMFADevicesResponse) => MFAStep.verify | MFAStep.authenticatorApp | MFAStep.smsVerifyCode;
|
|
26
26
|
export declare const getMfaStepForNotEnrolledUsers: (mfaStrategies: MFAStrategyEnum[]) => MFAStep.verify | MFAStep.authenticatorApp | MFAStep.smsSetPhoneNumber | MFAStep.emailVerifyCode;
|
|
27
|
+
export declare const isOauthCallbackRoute: (activeUri: string) => boolean;
|
package/auth/LoginState/utils.js
CHANGED
package/auth/index.d.ts
CHANGED
|
@@ -472,6 +472,15 @@ declare const _default: {
|
|
|
472
472
|
requestAuthorize: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(boolean | undefined)?], boolean, string, never, never>;
|
|
473
473
|
requestAuthorizeSSR: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./LoginState/interfaces").FronteggNextJSSession], import("./LoginState/interfaces").FronteggNextJSSession, string, never, never>;
|
|
474
474
|
requestHostedLoginAuthorize: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Record<string, string> | undefined)?], Record<string, string> | undefined, string, never, never>;
|
|
475
|
+
requestHostedLoginAuthorizeV2: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[({
|
|
476
|
+
additionalParams?: Record<string, string> | undefined;
|
|
477
|
+
shouldRedirectToLogin?: boolean | undefined;
|
|
478
|
+
firstTime?: boolean | undefined;
|
|
479
|
+
} | undefined)?], {
|
|
480
|
+
additionalParams?: Record<string, string> | undefined;
|
|
481
|
+
shouldRedirectToLogin?: boolean | undefined;
|
|
482
|
+
firstTime?: boolean | undefined;
|
|
483
|
+
} | undefined, string, never, never>;
|
|
475
484
|
handleHostedLoginCallback: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./LoginState/interfaces").HostedLoginCallback], import("./LoginState/interfaces").HostedLoginCallback, string, never, never>;
|
|
476
485
|
afterAuthNavigation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
477
486
|
preLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<import("@frontegg/rest-api").IPreLogin & {
|
package/auth/reducer.d.ts
CHANGED
|
@@ -432,6 +432,15 @@ declare const actions: {
|
|
|
432
432
|
requestAuthorize: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(boolean | undefined)?], boolean, string, never, never>;
|
|
433
433
|
requestAuthorizeSSR: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import(".").FronteggNextJSSession], import(".").FronteggNextJSSession, string, never, never>;
|
|
434
434
|
requestHostedLoginAuthorize: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(Record<string, string> | undefined)?], Record<string, string> | undefined, string, never, never>;
|
|
435
|
+
requestHostedLoginAuthorizeV2: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[({
|
|
436
|
+
additionalParams?: Record<string, string> | undefined;
|
|
437
|
+
shouldRedirectToLogin?: boolean | undefined;
|
|
438
|
+
firstTime?: boolean | undefined;
|
|
439
|
+
} | undefined)?], {
|
|
440
|
+
additionalParams?: Record<string, string> | undefined;
|
|
441
|
+
shouldRedirectToLogin?: boolean | undefined;
|
|
442
|
+
firstTime?: boolean | undefined;
|
|
443
|
+
} | undefined, string, never, never>;
|
|
435
444
|
handleHostedLoginCallback: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import(".").HostedLoginCallback], import(".").HostedLoginCallback, string, never, never>;
|
|
436
445
|
afterAuthNavigation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
437
446
|
preLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("..").WithCallback<import("@frontegg/rest-api").IPreLogin & {
|
package/index.js
CHANGED
|
@@ -40,6 +40,9 @@ const actions = {
|
|
|
40
40
|
requestHostedLoginAuthorize: (0, _toolkit.createAction)(`${_constants.authStoreName}/requestHostedLoginAuthorize`, payload => ({
|
|
41
41
|
payload
|
|
42
42
|
})),
|
|
43
|
+
requestHostedLoginAuthorizeV2: (0, _toolkit.createAction)(`${_constants.authStoreName}/requestHostedLoginAuthorizeV2`, payload => ({
|
|
44
|
+
payload
|
|
45
|
+
})),
|
|
43
46
|
handleHostedLoginCallback: (0, _toolkit.createAction)(`${_constants.authStoreName}/handleHostedLoginCallback`, payload => ({
|
|
44
47
|
payload
|
|
45
48
|
})),
|
|
@@ -579,6 +579,47 @@ function* refreshOrRequestHostedLoginAuthorize({
|
|
|
579
579
|
yield requestHostedLoginAuthorize(additionalParams);
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
|
+
function* refreshOrRequestHostedLoginAuthorizeV2({
|
|
583
|
+
payload: {
|
|
584
|
+
additionalParams,
|
|
585
|
+
shouldRedirectToLogin,
|
|
586
|
+
firstTime
|
|
587
|
+
}
|
|
588
|
+
}) {
|
|
589
|
+
if (firstTime) {
|
|
590
|
+
const {
|
|
591
|
+
urlStrategy
|
|
592
|
+
} = yield (0, _effects.select)(state => ({
|
|
593
|
+
urlStrategy: state.root.urlStrategy
|
|
594
|
+
}));
|
|
595
|
+
const activeUri = getUri(urlStrategy);
|
|
596
|
+
yield (0, _effects.put)(_reducer.actions.setState({
|
|
597
|
+
isLoading: true
|
|
598
|
+
}));
|
|
599
|
+
if ((0, _utils2.isOauthCallbackRoute)(activeUri)) {
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
const {
|
|
604
|
+
disableSilentRefresh
|
|
605
|
+
} = yield (0, _effects.select)(state => ({
|
|
606
|
+
disableSilentRefresh: state.auth.disableSilentRefresh
|
|
607
|
+
}));
|
|
608
|
+
try {
|
|
609
|
+
if (disableSilentRefresh) {
|
|
610
|
+
throw new Error('silent refresh is disabled');
|
|
611
|
+
}
|
|
612
|
+
yield requestHostedLoginSilentAuthorize();
|
|
613
|
+
} catch (e) {
|
|
614
|
+
if (!shouldRedirectToLogin) {
|
|
615
|
+
yield (0, _effects.put)(_reducer.actions.setState({
|
|
616
|
+
isLoading: false
|
|
617
|
+
}));
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
yield requestHostedLoginAuthorize(additionalParams);
|
|
621
|
+
}
|
|
622
|
+
}
|
|
582
623
|
function* requestHostedLoginAuthorize(additionalParams) {
|
|
583
624
|
const {
|
|
584
625
|
routes,
|
|
@@ -680,9 +721,13 @@ function* handleHostedLoginCallback({
|
|
|
680
721
|
try {
|
|
681
722
|
const response = yield (0, _effects.call)(_restApi.api.auth.exchangeOAuthTokensV2, body);
|
|
682
723
|
yield (0, _effects.call)(afterAuthenticationStateUpdate, response, {
|
|
683
|
-
isAuthenticated: true
|
|
724
|
+
isAuthenticated: true,
|
|
725
|
+
isLoading: false
|
|
684
726
|
});
|
|
685
727
|
} catch (e) {
|
|
728
|
+
yield (0, _effects.put)(_reducer.actions.setState({
|
|
729
|
+
isLoading: false
|
|
730
|
+
}));
|
|
686
731
|
console.error('Failed to exchangeOAuthTokens', e);
|
|
687
732
|
} finally {
|
|
688
733
|
yield afterAuthNavigation();
|
|
@@ -1909,6 +1954,7 @@ function* loginSagas() {
|
|
|
1909
1954
|
yield (0, _effects.takeLeading)(_reducer.actions.requestAuthorize, requestAuthorize);
|
|
1910
1955
|
yield (0, _effects.takeLeading)(_reducer.actions.requestAuthorizeSSR, requestAuthorizeSSR);
|
|
1911
1956
|
yield (0, _effects.takeLeading)(_reducer.actions.requestHostedLoginAuthorize, refreshOrRequestHostedLoginAuthorize);
|
|
1957
|
+
yield (0, _effects.takeLeading)(_reducer.actions.requestHostedLoginAuthorizeV2, refreshOrRequestHostedLoginAuthorizeV2);
|
|
1912
1958
|
yield (0, _effects.takeLeading)(_reducer.actions.handleHostedLoginCallback, handleHostedLoginCallback);
|
|
1913
1959
|
yield (0, _effects.takeLeading)(_reducer.actions.preLogin, preLogin);
|
|
1914
1960
|
yield (0, _effects.takeLeading)(_reducer.actions.postLogin, postLogin);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isMfaRequired = exports.getSearchParamsFromUrl = exports.getSearchParam = exports.getRedirectUrl = exports.getPathAndSearchParamsFromUrl = exports.getNumberOfMfaDevices = exports.getMfaStepForNotEnrolledUsers = exports.getMfaStepForEnrolledUsers = exports.TENANT_ID_PARAM_KEY = void 0;
|
|
6
|
+
exports.isOauthCallbackRoute = exports.isMfaRequired = exports.getSearchParamsFromUrl = exports.getSearchParam = exports.getRedirectUrl = exports.getPathAndSearchParamsFromUrl = exports.getNumberOfMfaDevices = exports.getMfaStepForNotEnrolledUsers = exports.getMfaStepForEnrolledUsers = exports.TENANT_ID_PARAM_KEY = void 0;
|
|
7
7
|
var _restApi = require("@frontegg/rest-api");
|
|
8
8
|
var _interfaces = require("../MfaState/interfaces");
|
|
9
9
|
const isAbsoluteUrl = path => {
|
|
@@ -135,4 +135,8 @@ const getMfaStepForNotEnrolledUsers = mfaStrategies => {
|
|
|
135
135
|
}
|
|
136
136
|
return _interfaces.MFAStep.verify;
|
|
137
137
|
};
|
|
138
|
-
exports.getMfaStepForNotEnrolledUsers = getMfaStepForNotEnrolledUsers;
|
|
138
|
+
exports.getMfaStepForNotEnrolledUsers = getMfaStepForNotEnrolledUsers;
|
|
139
|
+
const isOauthCallbackRoute = activeUri => {
|
|
140
|
+
return activeUri === '/oauth/callback';
|
|
141
|
+
};
|
|
142
|
+
exports.isOauthCallbackRoute = isOauthCallbackRoute;
|
package/node/index.js
CHANGED