@frontegg/redux-store 5.44.0 → 5.45.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/index.d.ts +2 -0
- package/auth/index.d.ts +1 -0
- package/auth/index.js +53 -4
- package/auth/reducer.d.ts +1 -0
- package/node/auth/index.js +1 -1
- package/node/{index-813fbf47.js → index-28ae5ca1.js} +53 -4
- package/node/index.js +1 -1
- package/node/toolkit/index.js +1 -1
- package/package.json +1 -1
|
@@ -73,6 +73,7 @@ declare const reducers: {
|
|
|
73
73
|
};
|
|
74
74
|
declare const actions: {
|
|
75
75
|
requestAuthorize: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(boolean | undefined)?], boolean, string, never, never>;
|
|
76
|
+
requestAuthorizeSSR: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[string], string, string, never, never>;
|
|
76
77
|
requestHostedLoginAuthorize: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
77
78
|
handleHostedLoginCallback: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[HostedLoginCallback], HostedLoginCallback, string, never, never>;
|
|
78
79
|
afterAuthNavigation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
@@ -106,6 +107,7 @@ declare type DispatchedActions = {
|
|
|
106
107
|
setLoginState: (state: Partial<LoginState>) => void;
|
|
107
108
|
resetLoginState: () => void;
|
|
108
109
|
requestAuthorize: (payload?: boolean) => void;
|
|
110
|
+
requestAuthorizeSSR: (payload: string) => void;
|
|
109
111
|
requestHostedLoginAuthorize: () => void;
|
|
110
112
|
handleHostedLoginCallback: (payload: HostedLoginCallback) => void;
|
|
111
113
|
afterAuthNavigation: () => void;
|
package/auth/index.d.ts
CHANGED
|
@@ -242,6 +242,7 @@ declare const _default: {
|
|
|
242
242
|
loginViaSocialLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./SocialLogins/interfaces").ILoginViaSocialLoginPayload], import("./SocialLogins/interfaces").ILoginViaSocialLoginPayload, string, never, never>;
|
|
243
243
|
setSocialLoginError: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").ISetSocialLoginError], import("@frontegg/rest-api").ISetSocialLoginError, string, never, never>;
|
|
244
244
|
requestAuthorize: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(boolean | undefined)?], boolean, string, never, never>;
|
|
245
|
+
requestAuthorizeSSR: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[string], string, string, never, never>;
|
|
245
246
|
requestHostedLoginAuthorize: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
246
247
|
handleHostedLoginCallback: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./LoginState/interfaces").HostedLoginCallback], import("./LoginState/interfaces").HostedLoginCallback, string, never, never>;
|
|
247
248
|
afterAuthNavigation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
package/auth/index.js
CHANGED
|
@@ -66,6 +66,7 @@ const reducers$f = {
|
|
|
66
66
|
};
|
|
67
67
|
const actions$g = {
|
|
68
68
|
requestAuthorize: createAction(`${authStoreName}/requestAuthorize`, (payload = false) => ({ payload })),
|
|
69
|
+
requestAuthorizeSSR: createAction(`${authStoreName}/requestAuthorizeSSR`, (payload) => ({ payload })),
|
|
69
70
|
requestHostedLoginAuthorize: createAction(`${authStoreName}/requestHostedLoginAuthorize`),
|
|
70
71
|
handleHostedLoginCallback: createAction(`${authStoreName}/handleHostedLoginCallback`, (payload) => ({ payload })),
|
|
71
72
|
afterAuthNavigation: createAction(`${authStoreName}/afterAuthNavigation`),
|
|
@@ -1006,6 +1007,45 @@ function* requestAuthorize({ payload: firstTime }) {
|
|
|
1006
1007
|
yield all(calls);
|
|
1007
1008
|
yield put(actions.setState({ isLoading: false }));
|
|
1008
1009
|
}
|
|
1010
|
+
function* refreshTokenSSR(accessToken) {
|
|
1011
|
+
if (!accessToken) {
|
|
1012
|
+
ContextHolder.setAccessToken(null);
|
|
1013
|
+
ContextHolder.setUser(null);
|
|
1014
|
+
yield put(actions.setState({ user: undefined, isAuthenticated: false }));
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
try {
|
|
1018
|
+
const onRedirectTo = ContextHolder.onRedirectTo;
|
|
1019
|
+
const { routes } = yield select((state) => state.auth);
|
|
1020
|
+
const { user, tenants } = yield call(api.auth.generateLoginResponseV2, { accessToken });
|
|
1021
|
+
if (isMfaRequired(user)) {
|
|
1022
|
+
const mfaRequiredState = yield getMfaRequiredState(user);
|
|
1023
|
+
yield put(actions.setState(mfaRequiredState));
|
|
1024
|
+
onRedirectTo(routes.loginUrl, { preserveQueryParams: true });
|
|
1025
|
+
}
|
|
1026
|
+
else {
|
|
1027
|
+
yield put(actions.setTenantsState({ tenants, loading: false }));
|
|
1028
|
+
yield put(actions.setState({ user, isAuthenticated: true }));
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
catch (e) {
|
|
1032
|
+
ContextHolder.setAccessToken(null);
|
|
1033
|
+
ContextHolder.setUser(null);
|
|
1034
|
+
yield put(actions.setState({ user: undefined, isAuthenticated: false }));
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
function* requestAuthorizeSSR({ payload: accessToken }) {
|
|
1038
|
+
const calls = [];
|
|
1039
|
+
yield put(actions.setState({ isLoading: true }));
|
|
1040
|
+
yield put(actions.loadSocialLoginsConfigurationV2());
|
|
1041
|
+
calls.push(call(loadAllowSignUps));
|
|
1042
|
+
calls.push(call(loadSSOPublicConfigurationFunction));
|
|
1043
|
+
calls.push(call(loadVendorPublicInfo));
|
|
1044
|
+
calls.push(call(refreshMetadata));
|
|
1045
|
+
calls.push(call(refreshTokenSSR, accessToken));
|
|
1046
|
+
yield all(calls);
|
|
1047
|
+
yield put(actions.setState({ isLoading: false }));
|
|
1048
|
+
}
|
|
1009
1049
|
function* requestHostedLoginAuthorize() {
|
|
1010
1050
|
const { routes, context, onRedirectTo } = yield select((state) => ({
|
|
1011
1051
|
routes: state.auth.routes,
|
|
@@ -1060,11 +1100,19 @@ function* passwordlessPreLogin(_a) {
|
|
|
1060
1100
|
const preloginRes = yield call(api.auth.passwordlessPreLogin, payload);
|
|
1061
1101
|
const step = authStrategyLoginStepMap[payload.type];
|
|
1062
1102
|
if (step === LoginStep.loginWithSmsOtc && preloginRes.resetPhoneNumberToken) {
|
|
1063
|
-
yield put(actions.setResetPhoneNumberState({
|
|
1103
|
+
yield put(actions.setResetPhoneNumberState({
|
|
1104
|
+
resetPhoneNumberToken: preloginRes.resetPhoneNumberToken,
|
|
1105
|
+
step: ResetPhoneNumberStep.VerifyResetPhoneNumber,
|
|
1106
|
+
}));
|
|
1064
1107
|
onRedirectTo(routes.resetPhoneNumberUrl);
|
|
1065
1108
|
return;
|
|
1066
1109
|
}
|
|
1067
|
-
yield put(actions.setLoginState({
|
|
1110
|
+
yield put(actions.setLoginState({
|
|
1111
|
+
step,
|
|
1112
|
+
loading: false,
|
|
1113
|
+
email: payload.email,
|
|
1114
|
+
phoneNumber: preloginRes === null || preloginRes === void 0 ? void 0 : preloginRes.phoneNumber,
|
|
1115
|
+
}));
|
|
1068
1116
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
1069
1117
|
}
|
|
1070
1118
|
catch (e) {
|
|
@@ -1125,7 +1173,7 @@ function* verifyInviteToken({ payload }) {
|
|
|
1125
1173
|
yield put(actions.setLoginState({ loading: false }));
|
|
1126
1174
|
}
|
|
1127
1175
|
}
|
|
1128
|
-
function* preLogin({ payload: { email, recaptchaToken, invitationToken, callback } }) {
|
|
1176
|
+
function* preLogin({ payload: { email, recaptchaToken, invitationToken, callback, }, }) {
|
|
1129
1177
|
yield put(actions.setLoginState({ loading: true }));
|
|
1130
1178
|
try {
|
|
1131
1179
|
const onRedirectTo = yield select(({ auth: { onRedirectTo } }) => onRedirectTo);
|
|
@@ -1188,7 +1236,7 @@ function* postLogin({ payload }) {
|
|
|
1188
1236
|
yield put(actions.setLoginState({ step: LoginStep.loginWithSSOFailed, loading: false }));
|
|
1189
1237
|
}
|
|
1190
1238
|
}
|
|
1191
|
-
function* login({ payload: { email, password, recaptchaToken, invitationToken, callback } }) {
|
|
1239
|
+
function* login({ payload: { email, password, recaptchaToken, invitationToken, callback, }, }) {
|
|
1192
1240
|
yield put(actions.setLoginState({ loading: true }));
|
|
1193
1241
|
try {
|
|
1194
1242
|
const user = yield call(api.auth.login, {
|
|
@@ -1303,6 +1351,7 @@ function* silentLogout({ payload }) {
|
|
|
1303
1351
|
}
|
|
1304
1352
|
function* loginSagas() {
|
|
1305
1353
|
yield takeLeading(actions.requestAuthorize, requestAuthorize);
|
|
1354
|
+
yield takeLeading(actions.requestAuthorizeSSR, requestAuthorizeSSR);
|
|
1306
1355
|
yield takeLeading(actions.requestHostedLoginAuthorize, requestHostedLoginAuthorize);
|
|
1307
1356
|
yield takeLeading(actions.handleHostedLoginCallback, handleHostedLoginCallback);
|
|
1308
1357
|
yield takeLeading(actions.preLogin, preLogin);
|
package/auth/reducer.d.ts
CHANGED
|
@@ -215,6 +215,7 @@ declare const actions: {
|
|
|
215
215
|
loginViaSocialLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import(".").ILoginViaSocialLoginPayload], import(".").ILoginViaSocialLoginPayload, string, never, never>;
|
|
216
216
|
setSocialLoginError: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").ISetSocialLoginError], import("@frontegg/rest-api").ISetSocialLoginError, string, never, never>;
|
|
217
217
|
requestAuthorize: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(boolean | undefined)?], boolean, string, never, never>;
|
|
218
|
+
requestAuthorizeSSR: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[string], string, string, never, never>;
|
|
218
219
|
requestHostedLoginAuthorize: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
219
220
|
handleHostedLoginCallback: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import(".").HostedLoginCallback], import(".").HostedLoginCallback, string, never, never>;
|
|
220
221
|
afterAuthNavigation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
package/node/auth/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var auth_index = require('../index-
|
|
5
|
+
var auth_index = require('../index-28ae5ca1.js');
|
|
6
6
|
var constants = require('../constants-52e37c08.js');
|
|
7
7
|
var restApi = require('@frontegg/rest-api');
|
|
8
8
|
require('@reduxjs/toolkit');
|
|
@@ -75,6 +75,7 @@ const reducers$f = {
|
|
|
75
75
|
};
|
|
76
76
|
const actions$g = {
|
|
77
77
|
requestAuthorize: toolkit.createAction(`${constants.authStoreName}/requestAuthorize`, (payload = false) => ({ payload })),
|
|
78
|
+
requestAuthorizeSSR: toolkit.createAction(`${constants.authStoreName}/requestAuthorizeSSR`, (payload) => ({ payload })),
|
|
78
79
|
requestHostedLoginAuthorize: toolkit.createAction(`${constants.authStoreName}/requestHostedLoginAuthorize`),
|
|
79
80
|
handleHostedLoginCallback: toolkit.createAction(`${constants.authStoreName}/handleHostedLoginCallback`, (payload) => ({ payload })),
|
|
80
81
|
afterAuthNavigation: toolkit.createAction(`${constants.authStoreName}/afterAuthNavigation`),
|
|
@@ -1015,6 +1016,45 @@ function* requestAuthorize({ payload: firstTime }) {
|
|
|
1015
1016
|
yield effects.all(calls);
|
|
1016
1017
|
yield effects.put(actions.setState({ isLoading: false }));
|
|
1017
1018
|
}
|
|
1019
|
+
function* refreshTokenSSR(accessToken) {
|
|
1020
|
+
if (!accessToken) {
|
|
1021
|
+
restApi.ContextHolder.setAccessToken(null);
|
|
1022
|
+
restApi.ContextHolder.setUser(null);
|
|
1023
|
+
yield effects.put(actions.setState({ user: undefined, isAuthenticated: false }));
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
try {
|
|
1027
|
+
const onRedirectTo = restApi.ContextHolder.onRedirectTo;
|
|
1028
|
+
const { routes } = yield effects.select((state) => state.auth);
|
|
1029
|
+
const { user, tenants } = yield effects.call(restApi.api.auth.generateLoginResponseV2, { accessToken });
|
|
1030
|
+
if (isMfaRequired(user)) {
|
|
1031
|
+
const mfaRequiredState = yield getMfaRequiredState(user);
|
|
1032
|
+
yield effects.put(actions.setState(mfaRequiredState));
|
|
1033
|
+
onRedirectTo(routes.loginUrl, { preserveQueryParams: true });
|
|
1034
|
+
}
|
|
1035
|
+
else {
|
|
1036
|
+
yield effects.put(actions.setTenantsState({ tenants, loading: false }));
|
|
1037
|
+
yield effects.put(actions.setState({ user, isAuthenticated: true }));
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
catch (e) {
|
|
1041
|
+
restApi.ContextHolder.setAccessToken(null);
|
|
1042
|
+
restApi.ContextHolder.setUser(null);
|
|
1043
|
+
yield effects.put(actions.setState({ user: undefined, isAuthenticated: false }));
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
function* requestAuthorizeSSR({ payload: accessToken }) {
|
|
1047
|
+
const calls = [];
|
|
1048
|
+
yield effects.put(actions.setState({ isLoading: true }));
|
|
1049
|
+
yield effects.put(actions.loadSocialLoginsConfigurationV2());
|
|
1050
|
+
calls.push(effects.call(loadAllowSignUps));
|
|
1051
|
+
calls.push(effects.call(loadSSOPublicConfigurationFunction));
|
|
1052
|
+
calls.push(effects.call(vendor_index.loadVendorPublicInfo));
|
|
1053
|
+
calls.push(effects.call(refreshMetadata));
|
|
1054
|
+
calls.push(effects.call(refreshTokenSSR, accessToken));
|
|
1055
|
+
yield effects.all(calls);
|
|
1056
|
+
yield effects.put(actions.setState({ isLoading: false }));
|
|
1057
|
+
}
|
|
1018
1058
|
function* requestHostedLoginAuthorize() {
|
|
1019
1059
|
const { routes, context, onRedirectTo } = yield effects.select((state) => ({
|
|
1020
1060
|
routes: state.auth.routes,
|
|
@@ -1069,11 +1109,19 @@ function* passwordlessPreLogin(_a) {
|
|
|
1069
1109
|
const preloginRes = yield effects.call(restApi.api.auth.passwordlessPreLogin, payload);
|
|
1070
1110
|
const step = authStrategyLoginStepMap[payload.type];
|
|
1071
1111
|
if (step === exports.LoginStep.loginWithSmsOtc && preloginRes.resetPhoneNumberToken) {
|
|
1072
|
-
yield effects.put(actions.setResetPhoneNumberState({
|
|
1112
|
+
yield effects.put(actions.setResetPhoneNumberState({
|
|
1113
|
+
resetPhoneNumberToken: preloginRes.resetPhoneNumberToken,
|
|
1114
|
+
step: exports.ResetPhoneNumberStep.VerifyResetPhoneNumber,
|
|
1115
|
+
}));
|
|
1073
1116
|
onRedirectTo(routes.resetPhoneNumberUrl);
|
|
1074
1117
|
return;
|
|
1075
1118
|
}
|
|
1076
|
-
yield effects.put(actions.setLoginState({
|
|
1119
|
+
yield effects.put(actions.setLoginState({
|
|
1120
|
+
step,
|
|
1121
|
+
loading: false,
|
|
1122
|
+
email: payload.email,
|
|
1123
|
+
phoneNumber: preloginRes === null || preloginRes === void 0 ? void 0 : preloginRes.phoneNumber,
|
|
1124
|
+
}));
|
|
1077
1125
|
callback === null || callback === void 0 ? void 0 : callback();
|
|
1078
1126
|
}
|
|
1079
1127
|
catch (e) {
|
|
@@ -1134,7 +1182,7 @@ function* verifyInviteToken({ payload }) {
|
|
|
1134
1182
|
yield effects.put(actions.setLoginState({ loading: false }));
|
|
1135
1183
|
}
|
|
1136
1184
|
}
|
|
1137
|
-
function* preLogin({ payload: { email, recaptchaToken, invitationToken, callback } }) {
|
|
1185
|
+
function* preLogin({ payload: { email, recaptchaToken, invitationToken, callback, }, }) {
|
|
1138
1186
|
yield effects.put(actions.setLoginState({ loading: true }));
|
|
1139
1187
|
try {
|
|
1140
1188
|
const onRedirectTo = yield effects.select(({ auth: { onRedirectTo } }) => onRedirectTo);
|
|
@@ -1197,7 +1245,7 @@ function* postLogin({ payload }) {
|
|
|
1197
1245
|
yield effects.put(actions.setLoginState({ step: exports.LoginStep.loginWithSSOFailed, loading: false }));
|
|
1198
1246
|
}
|
|
1199
1247
|
}
|
|
1200
|
-
function* login({ payload: { email, password, recaptchaToken, invitationToken, callback } }) {
|
|
1248
|
+
function* login({ payload: { email, password, recaptchaToken, invitationToken, callback, }, }) {
|
|
1201
1249
|
yield effects.put(actions.setLoginState({ loading: true }));
|
|
1202
1250
|
try {
|
|
1203
1251
|
const user = yield effects.call(restApi.api.auth.login, {
|
|
@@ -1312,6 +1360,7 @@ function* silentLogout({ payload }) {
|
|
|
1312
1360
|
}
|
|
1313
1361
|
function* loginSagas() {
|
|
1314
1362
|
yield effects.takeLeading(actions.requestAuthorize, requestAuthorize);
|
|
1363
|
+
yield effects.takeLeading(actions.requestAuthorizeSSR, requestAuthorizeSSR);
|
|
1315
1364
|
yield effects.takeLeading(actions.requestHostedLoginAuthorize, requestHostedLoginAuthorize);
|
|
1316
1365
|
yield effects.takeLeading(actions.handleHostedLoginCallback, handleHostedLoginCallback);
|
|
1317
1366
|
yield effects.takeLeading(actions.preLogin, preLogin);
|
package/node/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var auth_index = require('./index-
|
|
5
|
+
var auth_index = require('./index-28ae5ca1.js');
|
|
6
6
|
var audits_index = require('./audits/index.js');
|
|
7
7
|
var connectivity_index = require('./connectivity/index.js');
|
|
8
8
|
var subscriptions_index = require('./subscriptions/index.js');
|
package/node/toolkit/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var auth_index = require('../index-
|
|
5
|
+
var auth_index = require('../index-28ae5ca1.js');
|
|
6
6
|
var toolkit = require('@reduxjs/toolkit');
|
|
7
7
|
var createSagaMiddleware = require('redux-saga');
|
|
8
8
|
var effects = require('redux-saga/effects');
|