@frontegg/redux-store 5.19.0 → 5.20.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.
@@ -1,5 +1,5 @@
1
1
  import { IActivateAccount, IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse, IResendActivationEmail } from '@frontegg/rest-api';
2
- import { ActivateAccountState, ActivateAccountStrategyState } from './interfaces';
2
+ import { ActivateAccountState, ActivateAccountStrategyState, IPreActivateAccount } from './interfaces';
3
3
  import { WithCallback } from '../../interfaces';
4
4
  declare const activateState: ActivateAccountState;
5
5
  declare const reducers: {
@@ -106,6 +106,7 @@ declare const reducers: {
106
106
  };
107
107
  declare const actions: {
108
108
  activateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IActivateAccount, boolean>], WithCallback<IActivateAccount, boolean>, string, never, never>;
109
+ preActivateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[IPreActivateAccount], IPreActivateAccount, string, never, never>;
109
110
  getActivateAccountStrategy: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse>], WithCallback<IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse>, string, never, never>;
110
111
  resendActivationEmail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[IResendActivationEmail], IResendActivationEmail, string, never, never>;
111
112
  };
@@ -118,6 +119,7 @@ declare type DispatchedActions = {
118
119
  resetActivateState: () => void;
119
120
  setActivateStrategyState: (state: Partial<ActivateAccountStrategyState>) => void;
120
121
  activateAccount: (payload: WithCallback<IActivateAccount>) => void;
122
+ preActivateAccount: (payload: IPreActivateAccount) => void;
121
123
  resendActivationEmail: (payload: IResendActivationEmail) => void;
122
124
  getActivateAccountStrategy: (payload: WithCallback<IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse>) => void;
123
125
  };
@@ -3,7 +3,8 @@ import { WithStatus } from '../../interfaces';
3
3
  export declare enum ActivateAccountStep {
4
4
  'activating' = "activating",
5
5
  'success' = "success",
6
- 'resend' = "resend"
6
+ 'resend' = "resend",
7
+ 'activatingForm' = "activatingForm"
7
8
  }
8
9
  export interface ActivateAccountState {
9
10
  loading: boolean;
@@ -12,6 +13,10 @@ export interface ActivateAccountState {
12
13
  resentEmail: boolean;
13
14
  activationStrategy: ActivateAccountStrategyState;
14
15
  }
16
+ export declare type IPreActivateAccount = {
17
+ userId: string;
18
+ token: string;
19
+ };
15
20
  export declare type ActivateAccountStrategyState = WithStatus & {
16
21
  strategy?: IGetActivateAccountStrategyResponse;
17
22
  };
package/auth/index.d.ts CHANGED
@@ -223,6 +223,7 @@ declare const _default: {
223
223
  loadPasswordConfig: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(import("@frontegg/rest-api").IGetUserPasswordConfig | undefined)?], import("@frontegg/rest-api").IGetUserPasswordConfig | undefined, string, never, never>;
224
224
  acceptInvitation: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").IAcceptInvitation], import("@frontegg/rest-api").IAcceptInvitation, string, never, never>;
225
225
  activateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IActivateAccount, boolean>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IActivateAccount, boolean>, string, never, never>;
226
+ preActivateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./ActivateState/interfaces").IPreActivateAccount], import("./ActivateState/interfaces").IPreActivateAccount, string, never, never>;
226
227
  getActivateAccountStrategy: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IGetActivateAccountStrategy, import("@frontegg/rest-api").IGetActivateAccountStrategyResponse>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IGetActivateAccountStrategy, import("@frontegg/rest-api").IGetActivateAccountStrategyResponse>, string, never, never>;
227
228
  resendActivationEmail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").IResendActivationEmail], import("@frontegg/rest-api").IResendActivationEmail, string, never, never>;
228
229
  loadSocialLoginsConfiguration: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
package/auth/index.js CHANGED
@@ -86,6 +86,7 @@ var ActivateAccountStep;
86
86
  ActivateAccountStep["activating"] = "activating";
87
87
  ActivateAccountStep["success"] = "success";
88
88
  ActivateAccountStep["resend"] = "resend";
89
+ ActivateAccountStep["activatingForm"] = "activatingForm";
89
90
  })(ActivateAccountStep || (ActivateAccountStep = {}));
90
91
 
91
92
  const activateState = {
@@ -103,6 +104,7 @@ const reducers$d = {
103
104
  };
104
105
  const actions$e = {
105
106
  activateAccount: createAction(`${authStoreName}/activateAccount`, (payload) => ({ payload })),
107
+ preActivateAccount: createAction(`${authStoreName}/preActivateAccount`, (payload) => ({ payload })),
106
108
  getActivateAccountStrategy: createAction(`${authStoreName}/getActivateAccountStrategy`, (payload) => ({ payload })),
107
109
  resendActivationEmail: createAction(`${authStoreName}/resendActivationEmail`, (payload) => ({
108
110
  payload,
@@ -916,8 +918,8 @@ function* refreshToken() {
916
918
  else {
917
919
  yield put(actions.setTenantsState({ tenants, loading: false }));
918
920
  yield put(actions.setState({ user, isAuthenticated: true }));
919
- if ([routes.loginUrl, routes.socialLoginCallbackUrl, routes.signUpUrl, routes.oidcRedirectUrl, routes.samlCallbackUrl].some(url => url && window.location.pathname.endsWith(url)) ||
920
- (window.location.pathname.endsWith(routes.activateUrl) && user.verified)) {
921
+ if ([routes.loginUrl, routes.socialLoginCallbackUrl, routes.signUpUrl, routes.oidcRedirectUrl, routes.samlCallbackUrl]
922
+ .some(url => url && window.location.pathname.endsWith(url))) {
921
923
  if (loginState.isNewUser && routes.signUpSuccessUrl && routes.socialLoginCallbackUrl === window.location.pathname) {
922
924
  onRedirectTo(routes.signUpSuccessUrl, { refresh: routes.signUpSuccessUrl.startsWith('http') });
923
925
  }
@@ -2111,6 +2113,23 @@ function* forgotPasswordSagas() {
2111
2113
  yield takeLeading(actions.loadPasswordConfig, loadPasswordConfig);
2112
2114
  }
2113
2115
 
2116
+ function* preActivateAccount({ payload: { userId, token } }) {
2117
+ yield put(actions.setActivateState({ loading: true, step: ActivateAccountStep.activating }));
2118
+ try {
2119
+ const { isAuthenticated } = yield select((state) => state.auth);
2120
+ if (isAuthenticated) {
2121
+ yield put(actions.silentLogout());
2122
+ }
2123
+ const strategy = yield call(api.auth.getActivateAccountStrategy, { userId, token });
2124
+ yield put(actions.setActivateStrategyState({ strategy, loading: false, error: undefined }));
2125
+ if (strategy.shouldSetPassword) {
2126
+ yield put(actions.setActivateState({ loading: false, step: ActivateAccountStep.activatingForm }));
2127
+ }
2128
+ }
2129
+ catch (e) {
2130
+ yield put(actions.setActivateState({ loading: false, error: e.message }));
2131
+ }
2132
+ }
2114
2133
  function* activateAccount(_a) {
2115
2134
  var _b = _a.payload, { callback } = _b, payload = __rest(_b, ["callback"]);
2116
2135
  yield put(actions.setActivateState({ loading: true }));
@@ -2168,6 +2187,7 @@ function* resendActivationEmailFunction({ payload }) {
2168
2187
  }
2169
2188
  function* activateSagas() {
2170
2189
  yield takeLeading(actions.activateAccount, activateAccount);
2190
+ yield takeLeading(actions.preActivateAccount, preActivateAccount);
2171
2191
  yield takeLeading(actions.getActivateAccountStrategy, getActivateAccountStrategy);
2172
2192
  yield takeLeading(actions.resendActivationEmail, resendActivationEmailFunction);
2173
2193
  }
package/auth/reducer.d.ts CHANGED
@@ -197,6 +197,7 @@ declare const actions: {
197
197
  loadPasswordConfig: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(import("@frontegg/rest-api").IGetUserPasswordConfig | undefined)?], import("@frontegg/rest-api").IGetUserPasswordConfig | undefined, string, never, never>;
198
198
  acceptInvitation: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").IAcceptInvitation], import("@frontegg/rest-api").IAcceptInvitation, string, never, never>;
199
199
  activateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IActivateAccount, boolean>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IActivateAccount, boolean>, string, never, never>;
200
+ preActivateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import(".").IPreActivateAccount], import(".").IPreActivateAccount, string, never, never>;
200
201
  getActivateAccountStrategy: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IGetActivateAccountStrategy, import("@frontegg/rest-api").IGetActivateAccountStrategyResponse>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IGetActivateAccountStrategy, import("@frontegg/rest-api").IGetActivateAccountStrategyResponse>, string, never, never>;
201
202
  resendActivationEmail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").IResendActivationEmail], import("@frontegg/rest-api").IResendActivationEmail, string, never, never>;
202
203
  loadSocialLoginsConfiguration: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
@@ -88,6 +88,7 @@ exports.ActivateAccountStep = void 0;
88
88
  ActivateAccountStep["activating"] = "activating";
89
89
  ActivateAccountStep["success"] = "success";
90
90
  ActivateAccountStep["resend"] = "resend";
91
+ ActivateAccountStep["activatingForm"] = "activatingForm";
91
92
  })(exports.ActivateAccountStep || (exports.ActivateAccountStep = {}));
92
93
 
93
94
  const activateState = {
@@ -105,6 +106,7 @@ const reducers$d = {
105
106
  };
106
107
  const actions$e = {
107
108
  activateAccount: toolkit.createAction(`${constants.authStoreName}/activateAccount`, (payload) => ({ payload })),
109
+ preActivateAccount: toolkit.createAction(`${constants.authStoreName}/preActivateAccount`, (payload) => ({ payload })),
108
110
  getActivateAccountStrategy: toolkit.createAction(`${constants.authStoreName}/getActivateAccountStrategy`, (payload) => ({ payload })),
109
111
  resendActivationEmail: toolkit.createAction(`${constants.authStoreName}/resendActivationEmail`, (payload) => ({
110
112
  payload,
@@ -918,8 +920,8 @@ function* refreshToken() {
918
920
  else {
919
921
  yield effects.put(actions.setTenantsState({ tenants, loading: false }));
920
922
  yield effects.put(actions.setState({ user, isAuthenticated: true }));
921
- if ([routes.loginUrl, routes.socialLoginCallbackUrl, routes.signUpUrl, routes.oidcRedirectUrl, routes.samlCallbackUrl].some(url => url && window.location.pathname.endsWith(url)) ||
922
- (window.location.pathname.endsWith(routes.activateUrl) && user.verified)) {
923
+ if ([routes.loginUrl, routes.socialLoginCallbackUrl, routes.signUpUrl, routes.oidcRedirectUrl, routes.samlCallbackUrl]
924
+ .some(url => url && window.location.pathname.endsWith(url))) {
923
925
  if (loginState.isNewUser && routes.signUpSuccessUrl && routes.socialLoginCallbackUrl === window.location.pathname) {
924
926
  onRedirectTo(routes.signUpSuccessUrl, { refresh: routes.signUpSuccessUrl.startsWith('http') });
925
927
  }
@@ -2113,6 +2115,23 @@ function* forgotPasswordSagas() {
2113
2115
  yield effects.takeLeading(actions.loadPasswordConfig, loadPasswordConfig);
2114
2116
  }
2115
2117
 
2118
+ function* preActivateAccount({ payload: { userId, token } }) {
2119
+ yield effects.put(actions.setActivateState({ loading: true, step: exports.ActivateAccountStep.activating }));
2120
+ try {
2121
+ const { isAuthenticated } = yield effects.select((state) => state.auth);
2122
+ if (isAuthenticated) {
2123
+ yield effects.put(actions.silentLogout());
2124
+ }
2125
+ const strategy = yield effects.call(restApi.api.auth.getActivateAccountStrategy, { userId, token });
2126
+ yield effects.put(actions.setActivateStrategyState({ strategy, loading: false, error: undefined }));
2127
+ if (strategy.shouldSetPassword) {
2128
+ yield effects.put(actions.setActivateState({ loading: false, step: exports.ActivateAccountStep.activatingForm }));
2129
+ }
2130
+ }
2131
+ catch (e) {
2132
+ yield effects.put(actions.setActivateState({ loading: false, error: e.message }));
2133
+ }
2134
+ }
2116
2135
  function* activateAccount(_a) {
2117
2136
  var _b = _a.payload, { callback } = _b, payload = tslib.__rest(_b, ["callback"]);
2118
2137
  yield effects.put(actions.setActivateState({ loading: true }));
@@ -2170,6 +2189,7 @@ function* resendActivationEmailFunction({ payload }) {
2170
2189
  }
2171
2190
  function* activateSagas() {
2172
2191
  yield effects.takeLeading(actions.activateAccount, activateAccount);
2192
+ yield effects.takeLeading(actions.preActivateAccount, preActivateAccount);
2173
2193
  yield effects.takeLeading(actions.getActivateAccountStrategy, getActivateAccountStrategy);
2174
2194
  yield effects.takeLeading(actions.resendActivationEmail, resendActivationEmailFunction);
2175
2195
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
3
  "libName": "FronteggReduxStore",
4
- "version": "5.19.0",
4
+ "version": "5.20.0",
5
5
  "author": "Frontegg LTD",
6
6
  "main": "./node/index.js",
7
7
  "module": "./index.js",