@frontegg/redux-store 5.39.2 → 5.40.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
- import { IActivateAccount, IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse, IResendActivationEmail } from '@frontegg/rest-api';
2
- import { ActivateAccountState, ActivateAccountStrategyState, IPreActivateAccount } from './interfaces';
1
+ import { IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse, IResendActivationEmail } from '@frontegg/rest-api';
2
+ import { ActivateAccountState, ActivateAccountStrategyState, IActivateAccountPayload, IPreActivateAccount } from './interfaces';
3
3
  import { WithCallback } from '../../interfaces';
4
4
  declare const activateState: ActivateAccountState;
5
5
  declare const reducers: {
@@ -108,7 +108,7 @@ declare const reducers: {
108
108
  };
109
109
  };
110
110
  declare const actions: {
111
- activateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IActivateAccount, boolean>], WithCallback<IActivateAccount, boolean>, string, never, never>;
111
+ activateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IActivateAccountPayload, boolean>], WithCallback<IActivateAccountPayload, boolean>, string, never, never>;
112
112
  preActivateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[IPreActivateAccount], IPreActivateAccount, string, never, never>;
113
113
  getActivateAccountStrategy: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse>], WithCallback<IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse>, string, never, never>;
114
114
  resendActivationEmail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[IResendActivationEmail], IResendActivationEmail, string, never, never>;
@@ -121,7 +121,7 @@ declare type DispatchedActions = {
121
121
  setActivateState: (state: Partial<ActivateAccountState>) => void;
122
122
  resetActivateState: () => void;
123
123
  setActivateStrategyState: (state: Partial<ActivateAccountStrategyState>) => void;
124
- activateAccount: (payload: WithCallback<IActivateAccount>) => void;
124
+ activateAccount: (payload: WithCallback<IActivateAccountPayload>) => void;
125
125
  preActivateAccount: (payload: IPreActivateAccount) => void;
126
126
  resendActivationEmail: (payload: IResendActivationEmail) => void;
127
127
  getActivateAccountStrategy: (payload: WithCallback<IGetActivateAccountStrategy, IGetActivateAccountStrategyResponse>) => void;
@@ -1,5 +1,6 @@
1
- import { IGetActivateAccountStrategyResponse } from '@frontegg/rest-api';
1
+ import { IActivateAccount, IGetActivateAccountStrategyResponse } from '@frontegg/rest-api';
2
2
  import { WithStatus } from '../../interfaces';
3
+ import { CustomEventsOptions } from '../interfaces';
3
4
  export declare enum ActivateAccountStep {
4
5
  'activating' = "activating",
5
6
  'success' = "success",
@@ -17,6 +18,9 @@ export declare type IPreActivateAccount = {
17
18
  userId: string;
18
19
  token: string;
19
20
  };
21
+ export interface IActivateAccountPayload extends IActivateAccount {
22
+ events?: CustomEventsOptions;
23
+ }
20
24
  export declare type ActivateAccountStrategyState = WithStatus & {
21
25
  strategy?: IGetActivateAccountStrategyResponse;
22
26
  };
@@ -1,5 +1,5 @@
1
- import { ILogin, ILoginWithMfa, IPasswordlessPostLogin, IPasswordlessPreLogin, IPostLogin, IPreLogin, IRecoverMFAToken } from '@frontegg/rest-api';
2
- import { HostedLoginCallback, LoginState } from './interfaces';
1
+ import { ILogin, ILoginWithMfa, IPasswordlessPreLogin, IPostLogin, IPreLogin, IRecoverMFAToken } from '@frontegg/rest-api';
2
+ import { HostedLoginCallback, IPasswordlessPostLoginPayload, LoginState } from './interfaces';
3
3
  import { WithCallback } from '../../interfaces';
4
4
  import { IVerifyInviteToken } from '@frontegg/rest-api';
5
5
  declare const loginState: LoginState;
@@ -95,7 +95,7 @@ declare const actions: {
95
95
  mfaToken: string;
96
96
  }, string, never, never>;
97
97
  passwordlessPreLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IPasswordlessPreLogin, void>], WithCallback<IPasswordlessPreLogin, void>, string, never, never>;
98
- passwordlessPostLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IPasswordlessPostLogin, boolean>], WithCallback<IPasswordlessPostLogin, boolean>, string, never, never>;
98
+ passwordlessPostLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[WithCallback<IPasswordlessPostLoginPayload, boolean>], WithCallback<IPasswordlessPostLoginPayload, boolean>, string, never, never>;
99
99
  verifyInviteToken: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[IVerifyInviteToken], IVerifyInviteToken, string, never, never>;
100
100
  };
101
101
  /**
@@ -123,7 +123,7 @@ declare type DispatchedActions = {
123
123
  mfaToken: string;
124
124
  }) => void;
125
125
  passwordlessPreLogin: (payload: IPasswordlessPreLogin) => void;
126
- passwordlessPostLogin: (payload: WithCallback<IPasswordlessPostLogin>) => void;
126
+ passwordlessPostLogin: (payload: WithCallback<IPasswordlessPostLoginPayload>) => void;
127
127
  verifyInviteToken: (payload: IVerifyInviteToken) => void;
128
128
  };
129
129
  export declare type LoginActions = DispatchedActions;
@@ -1,4 +1,5 @@
1
- import { AuthStrategyEnum, ITenantsResponse } from '@frontegg/rest-api';
1
+ import { AuthStrategyEnum, IPasswordlessPostLogin, ITenantsResponse } from '@frontegg/rest-api';
2
+ import { CustomEventsOptions } from '../interfaces';
2
3
  export { AuthStrategyEnum };
3
4
  export declare enum LoginStep {
4
5
  'preLogin' = "preLogin",
@@ -35,3 +36,6 @@ export interface HostedLoginCallback {
35
36
  state?: string;
36
37
  nonce?: string;
37
38
  }
39
+ export interface IPasswordlessPostLoginPayload extends IPasswordlessPostLogin {
40
+ events?: CustomEventsOptions;
41
+ }
@@ -1,5 +1,4 @@
1
- import { ISignUpUser } from '@frontegg/rest-api';
2
- import { SignUpState } from './interfaces';
1
+ import { ISignUpUserPayload, SignUpState } from './interfaces';
3
2
  declare const signUpState: SignUpState;
4
3
  declare const reducers: {
5
4
  setSignUpState: {
@@ -70,7 +69,7 @@ declare const reducers: {
70
69
  };
71
70
  };
72
71
  declare const actions: {
73
- signUpUser: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[ISignUpUser], ISignUpUser, string, never, never>;
72
+ signUpUser: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[ISignUpUserPayload], ISignUpUserPayload, string, never, never>;
74
73
  resetSignUpStateSoft: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
75
74
  };
76
75
  /**
@@ -80,7 +79,7 @@ declare const actions: {
80
79
  declare type DispatchedActions = {
81
80
  setSignUpState: (state: Partial<SignUpState>) => void;
82
81
  resetSignUpState: () => void;
83
- signUpUser: (payload: ISignUpUser) => void;
82
+ signUpUser: (payload: ISignUpUserPayload) => void;
84
83
  resetSignUpStateSoft: () => void;
85
84
  };
86
85
  export declare type SignUpActions = DispatchedActions;
@@ -1,3 +1,5 @@
1
+ import { ISignUpUser } from '@frontegg/rest-api';
2
+ import { CustomEventsOptions } from '../interfaces';
1
3
  export interface SignUpState {
2
4
  loading: boolean;
3
5
  allowSignUps: boolean;
@@ -11,3 +13,7 @@ export declare enum SignUpStage {
11
13
  SignUp = "SignUp",
12
14
  SignUpSuccess = "SignUpSuccess"
13
15
  }
16
+ export interface ISignUpUserPayload extends ISignUpUser {
17
+ events?: CustomEventsOptions;
18
+ url?: URL;
19
+ }
@@ -1,5 +1,6 @@
1
1
  import { PayloadAction } from '@reduxjs/toolkit';
2
- import { ISignUpUser, IVendorConfig } from '@frontegg/rest-api';
2
+ import { IVendorConfig } from '@frontegg/rest-api';
3
+ import { ISignUpUserPayload } from './interfaces';
3
4
  export declare function loadAllowSignUps(): Generator<import("redux-saga/effects").PutEffect<{
4
5
  payload: Partial<import("./interfaces").SignUpState>;
5
6
  type: string;
@@ -9,7 +10,7 @@ export declare function loadAllowSignUps(): Generator<import("redux-saga/effects
9
10
  }>;
10
11
  type: string;
11
12
  }>, void, IVendorConfig>;
12
- export declare function signUpUser({ payload }: PayloadAction<ISignUpUser>): Generator<import("redux-saga/effects").PutEffect<{
13
+ export declare function signUpUser({ payload: { events, url, ...payload } }: PayloadAction<ISignUpUserPayload>): Generator<import("redux-saga/effects").PutEffect<{
13
14
  payload: Partial<import("./interfaces").SignUpState>;
14
15
  type: string;
15
16
  }> | import("redux-saga/effects").SelectEffect | import("redux-saga/effects").CallEffect<import("@frontegg/rest-api").ISignUpResponse> | import("redux-saga/effects").PutEffect<{
@@ -1,5 +1,5 @@
1
- import { ILoginViaSocialLogin, ISetSocialLoginError } from '@frontegg/rest-api';
2
- import { SocialLoginState } from './interfaces';
1
+ import { ISetSocialLoginError } from '@frontegg/rest-api';
2
+ import { ILoginViaSocialLoginPayload, SocialLoginState } from './interfaces';
3
3
  declare const socialLoginState: SocialLoginState;
4
4
  declare const reducers: {
5
5
  setSocialLoginsState: {
@@ -72,7 +72,7 @@ declare const reducers: {
72
72
  declare const actions: {
73
73
  loadSocialLoginsConfiguration: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
74
74
  loadSocialLoginsConfigurationV2: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
75
- loginViaSocialLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[ILoginViaSocialLogin], ILoginViaSocialLogin, string, never, never>;
75
+ loginViaSocialLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[ILoginViaSocialLoginPayload], ILoginViaSocialLoginPayload, string, never, never>;
76
76
  setSocialLoginError: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[ISetSocialLoginError], ISetSocialLoginError, string, never, never>;
77
77
  };
78
78
  /**
@@ -84,7 +84,7 @@ declare type DispatchedActions = {
84
84
  resetSocialLoginsState: () => void;
85
85
  loadSocialLoginsConfiguration: () => void;
86
86
  loadSocialLoginsConfigurationV2: () => void;
87
- loginViaSocialLogin: (payload: ILoginViaSocialLogin) => void;
87
+ loginViaSocialLogin: (payload: ILoginViaSocialLoginPayload) => void;
88
88
  setSocialLoginError: (payload: ISetSocialLoginError) => void;
89
89
  };
90
90
  export declare type SocialLoginActions = DispatchedActions;
@@ -1,4 +1,5 @@
1
- import { ISocialLoginProviderConfiguration, ISocialLoginProviderConfigurationV2 } from '@frontegg/rest-api';
1
+ import { ILoginViaSocialLogin, ISocialLoginProviderConfiguration, ISocialLoginProviderConfigurationV2 } from '@frontegg/rest-api';
2
+ import { CustomEventsOptions } from '../interfaces';
2
3
  export interface SocialLoginState {
3
4
  firstLoad: boolean;
4
5
  loading: boolean;
@@ -6,3 +7,7 @@ export interface SocialLoginState {
6
7
  socialLoginsConfigV2?: ISocialLoginProviderConfigurationV2[];
7
8
  error?: string;
8
9
  }
10
+ export interface ILoginViaSocialLoginPayload extends ILoginViaSocialLogin {
11
+ events?: CustomEventsOptions;
12
+ url?: URL;
13
+ }
@@ -6,5 +6,5 @@ export declare function loadSocialLoginsConfigurations(): Generator<import("redu
6
6
  export declare function loadSocialLoginsConfigurationsV2(): Generator<import("redux-saga/effects").PutEffect<{
7
7
  payload: Partial<import("./interfaces").SocialLoginState>;
8
8
  type: string;
9
- }> | import("redux-saga/effects").CallEffect<ISocialLoginProviderConfigurationV2[]>, void, ISocialLoginProviderConfigurationV2[]>;
9
+ }> | import("redux-saga/effects").SelectEffect | import("redux-saga/effects").CallEffect<ISocialLoginProviderConfigurationV2[]>, void, ISocialLoginProviderConfigurationV2[]>;
10
10
  export declare function socialLoginsSaga(): Generator<import("redux-saga/effects").ForkEffect<never>, void, unknown>;
package/auth/index.d.ts CHANGED
@@ -218,7 +218,7 @@ declare const _default: {
218
218
  loadProfile: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
219
219
  saveProfile: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("../interfaces").WithCallback<import("@frontegg/rest-api").IUserProfile, import("@frontegg/rest-api").IUserProfile>>], Partial<import("../interfaces").WithCallback<import("@frontegg/rest-api").IUserProfile, import("@frontegg/rest-api").IUserProfile>>, string, never, never>;
220
220
  changePassword: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IChangePassword, boolean>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IChangePassword, boolean>, string, never, never>;
221
- signUpUser: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").ISignUpUser], import("@frontegg/rest-api").ISignUpUser, string, never, never>;
221
+ signUpUser: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./SignUp/interfaces").ISignUpUserPayload], import("./SignUp/interfaces").ISignUpUserPayload, string, never, never>;
222
222
  resetSignUpStateSoft: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
223
223
  resetPhoneNumber: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IResetPhoneNumber, boolean>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IResetPhoneNumber, boolean>, string, never, never>;
224
224
  verifyResetPhoneNumber: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IVerifyResetPhoneNumber, boolean>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IVerifyResetPhoneNumber, boolean>, string, never, never>;
@@ -233,13 +233,13 @@ declare const _default: {
233
233
  resetPassword: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IResetPassword, boolean>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IResetPassword, boolean>, string, never, never>;
234
234
  loadPasswordConfig: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(import("@frontegg/rest-api").IGetUserPasswordConfig | undefined)?], import("@frontegg/rest-api").IGetUserPasswordConfig | undefined, string, never, never>;
235
235
  acceptInvitation: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").IAcceptInvitation], import("@frontegg/rest-api").IAcceptInvitation, string, never, never>;
236
- 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>;
236
+ activateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("./ActivateState/interfaces").IActivateAccountPayload, boolean>], import("../interfaces").WithCallback<import("./ActivateState/interfaces").IActivateAccountPayload, boolean>, string, never, never>;
237
237
  preActivateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("./ActivateState/interfaces").IPreActivateAccount], import("./ActivateState/interfaces").IPreActivateAccount, string, never, never>;
238
238
  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>;
239
239
  resendActivationEmail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").IResendActivationEmail], import("@frontegg/rest-api").IResendActivationEmail, string, never, never>;
240
240
  loadSocialLoginsConfiguration: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
241
241
  loadSocialLoginsConfigurationV2: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
242
- loginViaSocialLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").ILoginViaSocialLogin], import("@frontegg/rest-api").ILoginViaSocialLogin, string, never, never>;
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
245
  requestHostedLoginAuthorize: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
@@ -264,7 +264,7 @@ declare const _default: {
264
264
  mfaToken: string;
265
265
  }, string, never, never>;
266
266
  passwordlessPreLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IPasswordlessPreLogin, void>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IPasswordlessPreLogin, void>, string, never, never>;
267
- passwordlessPostLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IPasswordlessPostLogin, boolean>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IPasswordlessPostLogin, boolean>, string, never, never>;
267
+ passwordlessPostLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("./LoginState/interfaces").IPasswordlessPostLoginPayload, boolean>], import("../interfaces").WithCallback<import("./LoginState/interfaces").IPasswordlessPostLoginPayload, boolean>, string, never, never>;
268
268
  verifyInviteToken: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").IVerifyInviteToken], import("@frontegg/rest-api").IVerifyInviteToken, string, never, never>;
269
269
  setRolesState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("./RolesState/interfaces").RolesState>], Partial<import("./RolesState/interfaces").RolesState>, string, never, never>;
270
270
  resetRolesState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
package/auth/index.js CHANGED
@@ -792,6 +792,13 @@ const tenantsDemo = [
792
792
  },
793
793
  ];
794
794
 
795
+ var UserVeirifedOriginTypes;
796
+ (function (UserVeirifedOriginTypes) {
797
+ UserVeirifedOriginTypes["SOCIAL_LOGIN"] = "SOCIAL_LOGIN";
798
+ UserVeirifedOriginTypes["PASSWORDLESS"] = "PASSWORDLESS";
799
+ UserVeirifedOriginTypes["ACTIVATION_LINK"] = "ACTIVATION_LINK";
800
+ })(UserVeirifedOriginTypes || (UserVeirifedOriginTypes = {}));
801
+
795
802
  function* loadAllowSignUps() {
796
803
  yield put(actions.setSignUpState({ loading: true }));
797
804
  try {
@@ -804,11 +811,17 @@ function* loadAllowSignUps() {
804
811
  yield put(actions.setSignUpState({ loading: false, error: e.message, firstLoad: false }));
805
812
  }
806
813
  }
807
- function* signUpUser({ payload }) {
814
+ function* signUpUser(_a) {
815
+ var _b;
816
+ var _c = _a.payload, { events, url } = _c, payload = __rest(_c, ["events", "url"]);
808
817
  yield put(actions.setSignUpState({ loading: true }));
809
818
  try {
810
819
  const { routes, onRedirectTo } = yield select((state) => state.auth);
811
820
  const { shouldActivate, user } = yield call(api.auth.signUpUser, payload);
821
+ if (!payload.invitationToken) {
822
+ const { email, name, companyName } = payload;
823
+ (_b = events === null || events === void 0 ? void 0 : events.signUpComplete) === null || _b === void 0 ? void 0 : _b.call(events, { email, name, companyName, url });
824
+ }
812
825
  ContextHolder.setAccessToken(user === null || user === void 0 ? void 0 : user.accessToken);
813
826
  ContextHolder.setUser(user);
814
827
  if (!shouldActivate && (user === null || user === void 0 ? void 0 : user.mfaRequired) && (user === null || user === void 0 ? void 0 : user.mfaToken)) {
@@ -980,7 +993,11 @@ function* requestAuthorize({ payload: firstTime }) {
980
993
  yield put(actions.setState({ isLoading: false }));
981
994
  }
982
995
  function* requestHostedLoginAuthorize() {
983
- const { routes, baseUrl, clientId, onRedirectTo } = yield select((state) => (Object.assign({ routes: state.auth.routes, onRedirectTo: state.auth.onRedirectTo }, state.root.context)));
996
+ const { routes, context, onRedirectTo } = yield select((state) => ({
997
+ routes: state.auth.routes,
998
+ onRedirectTo: state.auth.onRedirectTo,
999
+ context: state.root.context,
1000
+ }));
984
1001
  // Generate the relevant params for the redirect
985
1002
  const nonce = createRandomString();
986
1003
  const code_verifier = createRandomString();
@@ -988,11 +1005,12 @@ function* requestHostedLoginAuthorize() {
988
1005
  // We are saving the verifier in session storage to be able to validate the response
989
1006
  localStorage.setItem(HOSTED_LOGIN_VERIFIER_KEY, code_verifier);
990
1007
  const redirectUrl = `${window.location.origin}${routes.hostedLoginRedirectUrl}`;
1008
+ const baseUrl = fetch.getBaseUrl(context, '/oauth/authorize');
991
1009
  // Hard coded for now
992
1010
  const oauthUrl = `${baseUrl}/oauth/authorize`;
993
1011
  const params = {
994
1012
  response_type: 'code',
995
- client_id: clientId || 'INVALID-CLIENT-ID',
1013
+ client_id: context.clientId || 'INVALID-CLIENT-ID',
996
1014
  scope: 'openid email profile',
997
1015
  redirect_uri: redirectUrl,
998
1016
  code_challenge: code_challenge,
@@ -1041,8 +1059,8 @@ function* passwordlessPreLogin(_a) {
1041
1059
  }
1042
1060
  }
1043
1061
  function* passwordlessPostLogin(_a) {
1044
- var _b;
1045
- var _c = _a.payload, { callback } = _c, payload = __rest(_c, ["callback"]);
1062
+ var _b, _c;
1063
+ var _d = _a.payload, { callback, events } = _d, payload = __rest(_d, ["callback", "events"]);
1046
1064
  try {
1047
1065
  yield put(actions.setLoginState({ loading: true }));
1048
1066
  const data = yield call(api.auth.passwordlessPostLogin, payload);
@@ -1055,6 +1073,9 @@ function* passwordlessPostLogin(_a) {
1055
1073
  }
1056
1074
  else {
1057
1075
  const user = yield call(api.auth.generateLoginResponse, data);
1076
+ if (data.emailVerified) {
1077
+ (_b = events === null || events === void 0 ? void 0 : events.userVerified) === null || _b === void 0 ? void 0 : _b.call(events, { email: user.email, origin: UserVeirifedOriginTypes.PASSWORDLESS });
1078
+ }
1058
1079
  yield put(actions.loadTenants());
1059
1080
  yield put(actions.setState({ user, isAuthenticated: true }));
1060
1081
  yield afterAuthNavigation();
@@ -1062,7 +1083,7 @@ function* passwordlessPostLogin(_a) {
1062
1083
  callback === null || callback === void 0 ? void 0 : callback(true);
1063
1084
  }
1064
1085
  catch (e) {
1065
- yield put(actions.setLoginState({ error: (_b = e.message) !== null && _b !== void 0 ? _b : 'Failed to authenticate' }));
1086
+ yield put(actions.setLoginState({ error: (_c = e.message) !== null && _c !== void 0 ? _c : 'Failed to authenticate' }));
1066
1087
  }
1067
1088
  finally {
1068
1089
  yield put(actions.setLoginState({ loading: false }));
@@ -2167,7 +2188,8 @@ function* preActivateAccount({ payload: { userId, token } }) {
2167
2188
  }
2168
2189
  }
2169
2190
  function* activateAccount(_a) {
2170
- var _b = _a.payload, { callback } = _b, payload = __rest(_b, ["callback"]);
2191
+ var _b;
2192
+ var _c = _a.payload, { callback, events } = _c, payload = __rest(_c, ["callback", "events"]);
2171
2193
  yield put(actions.setActivateState({ loading: true }));
2172
2194
  try {
2173
2195
  const onRedirectTo = ContextHolder.onRedirectTo;
@@ -2187,6 +2209,7 @@ function* activateAccount(_a) {
2187
2209
  else {
2188
2210
  yield put(actions.setActivateState({ step: ActivateAccountStep.success }));
2189
2211
  const { user, tenants } = yield call(api.auth.generateLoginResponseV2, data);
2212
+ (_b = events === null || events === void 0 ? void 0 : events.userVerified) === null || _b === void 0 ? void 0 : _b.call(events, { email: user.email, origin: UserVeirifedOriginTypes.ACTIVATION_LINK });
2190
2213
  yield put(actions.setTenantsState({ tenants, loading: false }));
2191
2214
  yield put(actions.setState({ user, isAuthenticated: true }));
2192
2215
  yield delay$1(1000);
@@ -2662,11 +2685,12 @@ function* loadSocialLoginsConfigurations() {
2662
2685
  }
2663
2686
  function* loadSocialLoginsConfigurationsV2() {
2664
2687
  try {
2688
+ const context = yield select((state) => state.root.context);
2665
2689
  yield put(actions.setSocialLoginsState({ loading: true }));
2666
2690
  const socialLoginsConfigV2 = yield call(api.auth.getSocialLoginProvidersV2);
2667
- const baseUrl = fetch.getBaseUrl(ContextHolder.getContext());
2668
2691
  const socialLoginsConfigWithFullUrl = socialLoginsConfigV2.map((_a) => {
2669
2692
  var { authorizationUrl } = _a, config = __rest(_a, ["authorizationUrl"]);
2693
+ const baseUrl = fetch.getBaseUrl(context, authorizationUrl !== null && authorizationUrl !== void 0 ? authorizationUrl : '');
2670
2694
  return (Object.assign(Object.assign({}, config), { authorizationUrl: authorizationUrl ? `${baseUrl}${authorizationUrl}` : null }));
2671
2695
  });
2672
2696
  yield put(actions.setSocialLoginsState({ socialLoginsConfigV2: socialLoginsConfigWithFullUrl, loading: false, firstLoad: false }));
@@ -2675,17 +2699,22 @@ function* loadSocialLoginsConfigurationsV2() {
2675
2699
  yield put(actions.setSocialLoginsState({ error: e.message, loading: false, firstLoad: false }));
2676
2700
  }
2677
2701
  }
2678
- function* loginViaSocialLogin({ payload }) {
2679
- var _a;
2702
+ function* loginViaSocialLogin(_a) {
2703
+ var _b, _c, _d;
2704
+ var _e = _a.payload, { events, url } = _e, payload = __rest(_e, ["events", "url"]);
2680
2705
  try {
2681
2706
  yield put(actions.setSocialLoginsState({ loading: true }));
2682
2707
  const { email, isNewUser } = yield call(api.auth.loginViaSocialLogin, payload);
2708
+ if (isNewUser) {
2709
+ (_b = events === null || events === void 0 ? void 0 : events.signUpComplete) === null || _b === void 0 ? void 0 : _b.call(events, { email, url });
2710
+ (_c = events === null || events === void 0 ? void 0 : events.userVerified) === null || _c === void 0 ? void 0 : _c.call(events, { email, origin: UserVeirifedOriginTypes.SOCIAL_LOGIN });
2711
+ }
2683
2712
  yield put(actions.setLoginState({ email, isNewUser }));
2684
2713
  yield refreshToken();
2685
2714
  yield put(actions.setSocialLoginsState({ loading: false }));
2686
2715
  }
2687
2716
  catch (e) {
2688
- yield put(actions.setSocialLoginsState({ loading: false, error: (_a = e.message) !== null && _a !== void 0 ? _a : 'Failed to authenticate', firstLoad: false }));
2717
+ yield put(actions.setSocialLoginsState({ loading: false, error: (_d = e.message) !== null && _d !== void 0 ? _d : 'Failed to authenticate', firstLoad: false }));
2689
2718
  }
2690
2719
  }
2691
2720
  function* setSocialLoginError({ payload }) {
@@ -3432,4 +3461,4 @@ var authStore = {
3432
3461
  actions,
3433
3462
  };
3434
3463
 
3435
- export { AcceptInvitationStep, ActivateAccountStep, ApiStateKeys, ForgotPasswordStep, LoginStep, MFAStep, ResetPhoneNumberStep, SSOStateKeys, SamlVendors, SignUpStage, TeamStateKeys, actions$e as acceptInvitationActions, reducers$d as acceptInvitationReducers, acceptInvitationState, actions$3 as accountSettingsActions, reducers$2 as accountSettingsReducers, accountSettingsState, actions$f as activateAccountActions, reducers$e as activateAccountReducers, activateState, actions$5 as apiTokensActions, reducers$4 as apiTokensReducers, apiTokensState, actions as authActions, initialState as authInitialState, mockSagas as authMockSagas, reducer as authReducers, sagas as authSagas, authStore as default, actions$d as forgotPasswordActions, reducers$c as forgotPasswordReducers, forgotPasswordState, actions$g as loginActions, reducers$f as loginReducers, loginState, actions$9 as mfaActions, reducers$8 as mfaReducers, mfaState, actions$a as profileActions, reducers$9 as profileReducers, profileState, actions$c as resetPhoneNumberActions, reducers$b as resetPhoneNumberReducers, resetPhoneNumberState, actions$1 as rolesActions, reducers as rolesReducers, rolesState, actions$4 as securityPolicyActions, reducers$3 as securityPolicyReducers, securityPolicyState, actions$6 as signUpActions, reducers$5 as signUpReducers, signUpState, socialLoginState, actions$7 as socialLoginsActions, reducers$6 as socialLoginsReducer, actions$b as ssoActions, reducers$a as ssoReducers, ssoState, actions$8 as teamActions, reducers$7 as teamReducers, teamState, actions$2 as tenantsActions, reducers$1 as tenantsReducers, tenantsState };
3464
+ export { AcceptInvitationStep, ActivateAccountStep, ApiStateKeys, ForgotPasswordStep, LoginStep, MFAStep, ResetPhoneNumberStep, SSOStateKeys, SamlVendors, SignUpStage, TeamStateKeys, UserVeirifedOriginTypes, actions$e as acceptInvitationActions, reducers$d as acceptInvitationReducers, acceptInvitationState, actions$3 as accountSettingsActions, reducers$2 as accountSettingsReducers, accountSettingsState, actions$f as activateAccountActions, reducers$e as activateAccountReducers, activateState, actions$5 as apiTokensActions, reducers$4 as apiTokensReducers, apiTokensState, actions as authActions, initialState as authInitialState, mockSagas as authMockSagas, reducer as authReducers, sagas as authSagas, authStore as default, actions$d as forgotPasswordActions, reducers$c as forgotPasswordReducers, forgotPasswordState, actions$g as loginActions, reducers$f as loginReducers, loginState, actions$9 as mfaActions, reducers$8 as mfaReducers, mfaState, actions$a as profileActions, reducers$9 as profileReducers, profileState, actions$c as resetPhoneNumberActions, reducers$b as resetPhoneNumberReducers, resetPhoneNumberState, actions$1 as rolesActions, reducers as rolesReducers, rolesState, actions$4 as securityPolicyActions, reducers$3 as securityPolicyReducers, securityPolicyState, actions$6 as signUpActions, reducers$5 as signUpReducers, signUpState, socialLoginState, actions$7 as socialLoginsActions, reducers$6 as socialLoginsReducer, actions$b as ssoActions, reducers$a as ssoReducers, ssoState, actions$8 as teamActions, reducers$7 as teamReducers, teamState, actions$2 as tenantsActions, reducers$1 as tenantsReducers, tenantsState };
@@ -101,16 +101,16 @@ export declare type AuthPageRoutes = {
101
101
  */
102
102
  signUpUrl: string;
103
103
  /**
104
- * oidc success redirect url
105
- */
104
+ * oidc success redirect url
105
+ */
106
106
  oidcRedirectUrl?: string;
107
107
  /**
108
- * magic link redirect url
109
- */
108
+ * magic link redirect url
109
+ */
110
110
  magicLinkCallbackUrl?: string;
111
111
  /**
112
- * after sign up success url, the order of urls read: (accountSignUpSuccessUrl or userSignUpSuccessUrl) / signupSuccessUrl / authenticationUrl
113
- */
112
+ * after sign up success url, the order of urls read: (accountSignUpSuccessUrl or userSignUpSuccessUrl) / signupSuccessUrl / authenticationUrl
113
+ */
114
114
  signUpSuccessUrl?: string;
115
115
  /**
116
116
  * after account sign up success url, the order of urls read: accountSignUpSuccessUrl / signupSuccessUrl / authenticationUrl
@@ -125,4 +125,23 @@ export declare type AuthPageRoutes = {
125
125
  */
126
126
  hostedLoginRedirectUrl?: string;
127
127
  };
128
+ export declare enum UserVeirifedOriginTypes {
129
+ SOCIAL_LOGIN = "SOCIAL_LOGIN",
130
+ PASSWORDLESS = "PASSWORDLESS",
131
+ ACTIVATION_LINK = "ACTIVATION_LINK"
132
+ }
133
+ export interface CustomEventsOptions {
134
+ userVerified?: (payload: IUserVerifiedPayload) => void;
135
+ signUpComplete?: (payload: ISignUpCompletePayload) => void;
136
+ }
137
+ export interface IUserVerifiedPayload {
138
+ email: string;
139
+ origin: UserVeirifedOriginTypes;
140
+ }
141
+ export interface ISignUpCompletePayload {
142
+ name?: string;
143
+ companyName?: string;
144
+ email: string;
145
+ url?: URL;
146
+ }
128
147
  export {};
package/auth/reducer.d.ts CHANGED
@@ -191,7 +191,7 @@ declare const actions: {
191
191
  loadProfile: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
192
192
  saveProfile: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import("../interfaces").WithCallback<import("@frontegg/rest-api").IUserProfile, import("@frontegg/rest-api").IUserProfile>>], Partial<import("../interfaces").WithCallback<import("@frontegg/rest-api").IUserProfile, import("@frontegg/rest-api").IUserProfile>>, string, never, never>;
193
193
  changePassword: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IChangePassword, boolean>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IChangePassword, boolean>, string, never, never>;
194
- signUpUser: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").ISignUpUser], import("@frontegg/rest-api").ISignUpUser, string, never, never>;
194
+ signUpUser: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import(".").ISignUpUserPayload], import(".").ISignUpUserPayload, string, never, never>;
195
195
  resetSignUpStateSoft: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
196
196
  resetPhoneNumber: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IResetPhoneNumber, boolean>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IResetPhoneNumber, boolean>, string, never, never>;
197
197
  verifyResetPhoneNumber: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IVerifyResetPhoneNumber, boolean>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IVerifyResetPhoneNumber, boolean>, string, never, never>;
@@ -206,13 +206,13 @@ declare const actions: {
206
206
  resetPassword: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IResetPassword, boolean>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IResetPassword, boolean>, string, never, never>;
207
207
  loadPasswordConfig: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[(import("@frontegg/rest-api").IGetUserPasswordConfig | undefined)?], import("@frontegg/rest-api").IGetUserPasswordConfig | undefined, string, never, never>;
208
208
  acceptInvitation: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").IAcceptInvitation], import("@frontegg/rest-api").IAcceptInvitation, string, never, never>;
209
- 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>;
209
+ activateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import(".").IActivateAccountPayload, boolean>], import("../interfaces").WithCallback<import(".").IActivateAccountPayload, boolean>, string, never, never>;
210
210
  preActivateAccount: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import(".").IPreActivateAccount], import(".").IPreActivateAccount, string, never, never>;
211
211
  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>;
212
212
  resendActivationEmail: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").IResendActivationEmail], import("@frontegg/rest-api").IResendActivationEmail, string, never, never>;
213
213
  loadSocialLoginsConfiguration: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
214
214
  loadSocialLoginsConfigurationV2: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
215
- loginViaSocialLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").ILoginViaSocialLogin], import("@frontegg/rest-api").ILoginViaSocialLogin, string, never, never>;
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
218
  requestHostedLoginAuthorize: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
@@ -237,7 +237,7 @@ declare const actions: {
237
237
  mfaToken: string;
238
238
  }, string, never, never>;
239
239
  passwordlessPreLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IPasswordlessPreLogin, void>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IPasswordlessPreLogin, void>, string, never, never>;
240
- passwordlessPostLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import("@frontegg/rest-api").IPasswordlessPostLogin, boolean>], import("../interfaces").WithCallback<import("@frontegg/rest-api").IPasswordlessPostLogin, boolean>, string, never, never>;
240
+ passwordlessPostLogin: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("../interfaces").WithCallback<import(".").IPasswordlessPostLoginPayload, boolean>], import("../interfaces").WithCallback<import(".").IPasswordlessPostLoginPayload, boolean>, string, never, never>;
241
241
  verifyInviteToken: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[import("@frontegg/rest-api").IVerifyInviteToken], import("@frontegg/rest-api").IVerifyInviteToken, string, never, never>;
242
242
  setRolesState: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[Partial<import(".").RolesState>], Partial<import(".").RolesState>, string, never, never>;
243
243
  resetRolesState: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { AcceptInvitationStep, ActivateAccountStep, ApiStateKeys, ForgotPasswordStep, LoginStep, MFAStep, ResetPhoneNumberStep, SSOStateKeys, SamlVendors, SignUpStage, TeamStateKeys, acceptInvitationActions, acceptInvitationReducers, acceptInvitationState, accountSettingsActions, accountSettingsReducers, accountSettingsState, activateAccountActions, activateAccountReducers, activateState, apiTokensActions, apiTokensReducers, apiTokensState, default as auth, authActions, authInitialState, authMockSagas, authReducers, authSagas, forgotPasswordActions, forgotPasswordReducers, forgotPasswordState, loginActions, loginReducers, loginState, mfaActions, mfaReducers, mfaState, profileActions, profileReducers, profileState, resetPhoneNumberActions, resetPhoneNumberReducers, resetPhoneNumberState, rolesActions, rolesReducers, rolesState, securityPolicyActions, securityPolicyReducers, securityPolicyState, signUpActions, signUpReducers, signUpState, socialLoginState, socialLoginsActions, socialLoginsReducer, ssoActions, ssoReducers, ssoState, teamActions, teamReducers, teamState, tenantsActions, tenantsReducers, tenantsState } from './auth/index.js';
1
+ export { AcceptInvitationStep, ActivateAccountStep, ApiStateKeys, ForgotPasswordStep, LoginStep, MFAStep, ResetPhoneNumberStep, SSOStateKeys, SamlVendors, SignUpStage, TeamStateKeys, UserVeirifedOriginTypes, acceptInvitationActions, acceptInvitationReducers, acceptInvitationState, accountSettingsActions, accountSettingsReducers, accountSettingsState, activateAccountActions, activateAccountReducers, activateState, apiTokensActions, apiTokensReducers, apiTokensState, default as auth, authActions, authInitialState, authMockSagas, authReducers, authSagas, forgotPasswordActions, forgotPasswordReducers, forgotPasswordState, loginActions, loginReducers, loginState, mfaActions, mfaReducers, mfaState, profileActions, profileReducers, profileState, resetPhoneNumberActions, resetPhoneNumberReducers, resetPhoneNumberState, rolesActions, rolesReducers, rolesState, securityPolicyActions, securityPolicyReducers, securityPolicyState, signUpActions, signUpReducers, signUpState, socialLoginState, socialLoginsActions, socialLoginsReducer, ssoActions, ssoReducers, ssoState, teamActions, teamReducers, teamState, tenantsActions, tenantsReducers, tenantsState } from './auth/index.js';
2
2
  export { auditLogsActions, auditLogsReducers, auditLogsState, default as audits, auditsActions, auditsInitialState, auditsMetadataActions, auditsMetadataReducers, auditsMetadataState, auditsMockSagas, auditsReducers, auditsSagas } from './audits/index.js';
3
3
  export { default as connectivity, connectivityActions, connectivityInitialState, connectivityReducers, connectivitySagas } from './connectivity/index.js';
4
4
  export { CheckoutEvent, CheckoutStatus, PaymentMethodType, PaymentProvider, SubscriptionCancellationPolicy, SubscriptionStatus, subscriptionActions, subscriptionInitialState, subscriptionReducers, subscriptionSagas, subscriptionSagasMock, default as subscriptions } from './subscriptions/index.js';
@@ -794,6 +794,13 @@ const tenantsDemo = [
794
794
  },
795
795
  ];
796
796
 
797
+ exports.UserVeirifedOriginTypes = void 0;
798
+ (function (UserVeirifedOriginTypes) {
799
+ UserVeirifedOriginTypes["SOCIAL_LOGIN"] = "SOCIAL_LOGIN";
800
+ UserVeirifedOriginTypes["PASSWORDLESS"] = "PASSWORDLESS";
801
+ UserVeirifedOriginTypes["ACTIVATION_LINK"] = "ACTIVATION_LINK";
802
+ })(exports.UserVeirifedOriginTypes || (exports.UserVeirifedOriginTypes = {}));
803
+
797
804
  function* loadAllowSignUps() {
798
805
  yield effects.put(actions.setSignUpState({ loading: true }));
799
806
  try {
@@ -806,11 +813,17 @@ function* loadAllowSignUps() {
806
813
  yield effects.put(actions.setSignUpState({ loading: false, error: e.message, firstLoad: false }));
807
814
  }
808
815
  }
809
- function* signUpUser({ payload }) {
816
+ function* signUpUser(_a) {
817
+ var _b;
818
+ var _c = _a.payload, { events, url } = _c, payload = tslib.__rest(_c, ["events", "url"]);
810
819
  yield effects.put(actions.setSignUpState({ loading: true }));
811
820
  try {
812
821
  const { routes, onRedirectTo } = yield effects.select((state) => state.auth);
813
822
  const { shouldActivate, user } = yield effects.call(restApi.api.auth.signUpUser, payload);
823
+ if (!payload.invitationToken) {
824
+ const { email, name, companyName } = payload;
825
+ (_b = events === null || events === void 0 ? void 0 : events.signUpComplete) === null || _b === void 0 ? void 0 : _b.call(events, { email, name, companyName, url });
826
+ }
814
827
  restApi.ContextHolder.setAccessToken(user === null || user === void 0 ? void 0 : user.accessToken);
815
828
  restApi.ContextHolder.setUser(user);
816
829
  if (!shouldActivate && (user === null || user === void 0 ? void 0 : user.mfaRequired) && (user === null || user === void 0 ? void 0 : user.mfaToken)) {
@@ -982,7 +995,11 @@ function* requestAuthorize({ payload: firstTime }) {
982
995
  yield effects.put(actions.setState({ isLoading: false }));
983
996
  }
984
997
  function* requestHostedLoginAuthorize() {
985
- const { routes, baseUrl, clientId, onRedirectTo } = yield effects.select((state) => (Object.assign({ routes: state.auth.routes, onRedirectTo: state.auth.onRedirectTo }, state.root.context)));
998
+ const { routes, context, onRedirectTo } = yield effects.select((state) => ({
999
+ routes: state.auth.routes,
1000
+ onRedirectTo: state.auth.onRedirectTo,
1001
+ context: state.root.context,
1002
+ }));
986
1003
  // Generate the relevant params for the redirect
987
1004
  const nonce = createRandomString();
988
1005
  const code_verifier = createRandomString();
@@ -990,11 +1007,12 @@ function* requestHostedLoginAuthorize() {
990
1007
  // We are saving the verifier in session storage to be able to validate the response
991
1008
  localStorage.setItem(constants.HOSTED_LOGIN_VERIFIER_KEY, code_verifier);
992
1009
  const redirectUrl = `${window.location.origin}${routes.hostedLoginRedirectUrl}`;
1010
+ const baseUrl = restApi.fetch.getBaseUrl(context, '/oauth/authorize');
993
1011
  // Hard coded for now
994
1012
  const oauthUrl = `${baseUrl}/oauth/authorize`;
995
1013
  const params = {
996
1014
  response_type: 'code',
997
- client_id: clientId || 'INVALID-CLIENT-ID',
1015
+ client_id: context.clientId || 'INVALID-CLIENT-ID',
998
1016
  scope: 'openid email profile',
999
1017
  redirect_uri: redirectUrl,
1000
1018
  code_challenge: code_challenge,
@@ -1043,8 +1061,8 @@ function* passwordlessPreLogin(_a) {
1043
1061
  }
1044
1062
  }
1045
1063
  function* passwordlessPostLogin(_a) {
1046
- var _b;
1047
- var _c = _a.payload, { callback } = _c, payload = tslib.__rest(_c, ["callback"]);
1064
+ var _b, _c;
1065
+ var _d = _a.payload, { callback, events } = _d, payload = tslib.__rest(_d, ["callback", "events"]);
1048
1066
  try {
1049
1067
  yield effects.put(actions.setLoginState({ loading: true }));
1050
1068
  const data = yield effects.call(restApi.api.auth.passwordlessPostLogin, payload);
@@ -1057,6 +1075,9 @@ function* passwordlessPostLogin(_a) {
1057
1075
  }
1058
1076
  else {
1059
1077
  const user = yield effects.call(restApi.api.auth.generateLoginResponse, data);
1078
+ if (data.emailVerified) {
1079
+ (_b = events === null || events === void 0 ? void 0 : events.userVerified) === null || _b === void 0 ? void 0 : _b.call(events, { email: user.email, origin: exports.UserVeirifedOriginTypes.PASSWORDLESS });
1080
+ }
1060
1081
  yield effects.put(actions.loadTenants());
1061
1082
  yield effects.put(actions.setState({ user, isAuthenticated: true }));
1062
1083
  yield afterAuthNavigation();
@@ -1064,7 +1085,7 @@ function* passwordlessPostLogin(_a) {
1064
1085
  callback === null || callback === void 0 ? void 0 : callback(true);
1065
1086
  }
1066
1087
  catch (e) {
1067
- yield effects.put(actions.setLoginState({ error: (_b = e.message) !== null && _b !== void 0 ? _b : 'Failed to authenticate' }));
1088
+ yield effects.put(actions.setLoginState({ error: (_c = e.message) !== null && _c !== void 0 ? _c : 'Failed to authenticate' }));
1068
1089
  }
1069
1090
  finally {
1070
1091
  yield effects.put(actions.setLoginState({ loading: false }));
@@ -2169,7 +2190,8 @@ function* preActivateAccount({ payload: { userId, token } }) {
2169
2190
  }
2170
2191
  }
2171
2192
  function* activateAccount(_a) {
2172
- var _b = _a.payload, { callback } = _b, payload = tslib.__rest(_b, ["callback"]);
2193
+ var _b;
2194
+ var _c = _a.payload, { callback, events } = _c, payload = tslib.__rest(_c, ["callback", "events"]);
2173
2195
  yield effects.put(actions.setActivateState({ loading: true }));
2174
2196
  try {
2175
2197
  const onRedirectTo = restApi.ContextHolder.onRedirectTo;
@@ -2189,6 +2211,7 @@ function* activateAccount(_a) {
2189
2211
  else {
2190
2212
  yield effects.put(actions.setActivateState({ step: exports.ActivateAccountStep.success }));
2191
2213
  const { user, tenants } = yield effects.call(restApi.api.auth.generateLoginResponseV2, data);
2214
+ (_b = events === null || events === void 0 ? void 0 : events.userVerified) === null || _b === void 0 ? void 0 : _b.call(events, { email: user.email, origin: exports.UserVeirifedOriginTypes.ACTIVATION_LINK });
2192
2215
  yield effects.put(actions.setTenantsState({ tenants, loading: false }));
2193
2216
  yield effects.put(actions.setState({ user, isAuthenticated: true }));
2194
2217
  yield effects.delay(1000);
@@ -2664,11 +2687,12 @@ function* loadSocialLoginsConfigurations() {
2664
2687
  }
2665
2688
  function* loadSocialLoginsConfigurationsV2() {
2666
2689
  try {
2690
+ const context = yield effects.select((state) => state.root.context);
2667
2691
  yield effects.put(actions.setSocialLoginsState({ loading: true }));
2668
2692
  const socialLoginsConfigV2 = yield effects.call(restApi.api.auth.getSocialLoginProvidersV2);
2669
- const baseUrl = restApi.fetch.getBaseUrl(restApi.ContextHolder.getContext());
2670
2693
  const socialLoginsConfigWithFullUrl = socialLoginsConfigV2.map((_a) => {
2671
2694
  var { authorizationUrl } = _a, config = tslib.__rest(_a, ["authorizationUrl"]);
2695
+ const baseUrl = restApi.fetch.getBaseUrl(context, authorizationUrl !== null && authorizationUrl !== void 0 ? authorizationUrl : '');
2672
2696
  return (Object.assign(Object.assign({}, config), { authorizationUrl: authorizationUrl ? `${baseUrl}${authorizationUrl}` : null }));
2673
2697
  });
2674
2698
  yield effects.put(actions.setSocialLoginsState({ socialLoginsConfigV2: socialLoginsConfigWithFullUrl, loading: false, firstLoad: false }));
@@ -2677,17 +2701,22 @@ function* loadSocialLoginsConfigurationsV2() {
2677
2701
  yield effects.put(actions.setSocialLoginsState({ error: e.message, loading: false, firstLoad: false }));
2678
2702
  }
2679
2703
  }
2680
- function* loginViaSocialLogin({ payload }) {
2681
- var _a;
2704
+ function* loginViaSocialLogin(_a) {
2705
+ var _b, _c, _d;
2706
+ var _e = _a.payload, { events, url } = _e, payload = tslib.__rest(_e, ["events", "url"]);
2682
2707
  try {
2683
2708
  yield effects.put(actions.setSocialLoginsState({ loading: true }));
2684
2709
  const { email, isNewUser } = yield effects.call(restApi.api.auth.loginViaSocialLogin, payload);
2710
+ if (isNewUser) {
2711
+ (_b = events === null || events === void 0 ? void 0 : events.signUpComplete) === null || _b === void 0 ? void 0 : _b.call(events, { email, url });
2712
+ (_c = events === null || events === void 0 ? void 0 : events.userVerified) === null || _c === void 0 ? void 0 : _c.call(events, { email, origin: exports.UserVeirifedOriginTypes.SOCIAL_LOGIN });
2713
+ }
2685
2714
  yield effects.put(actions.setLoginState({ email, isNewUser }));
2686
2715
  yield refreshToken();
2687
2716
  yield effects.put(actions.setSocialLoginsState({ loading: false }));
2688
2717
  }
2689
2718
  catch (e) {
2690
- yield effects.put(actions.setSocialLoginsState({ loading: false, error: (_a = e.message) !== null && _a !== void 0 ? _a : 'Failed to authenticate', firstLoad: false }));
2719
+ yield effects.put(actions.setSocialLoginsState({ loading: false, error: (_d = e.message) !== null && _d !== void 0 ? _d : 'Failed to authenticate', firstLoad: false }));
2691
2720
  }
2692
2721
  }
2693
2722
  function* setSocialLoginError({ payload }) {
package/node/index.js CHANGED
@@ -90,6 +90,12 @@ Object.defineProperty(exports, 'TeamStateKeys', {
90
90
  return auth_index.TeamStateKeys;
91
91
  }
92
92
  });
93
+ Object.defineProperty(exports, 'UserVeirifedOriginTypes', {
94
+ enumerable: true,
95
+ get: function () {
96
+ return auth_index.UserVeirifedOriginTypes;
97
+ }
98
+ });
93
99
  exports.acceptInvitationActions = auth_index.acceptInvitationActions;
94
100
  exports.acceptInvitationReducers = auth_index.acceptInvitationReducers;
95
101
  exports.acceptInvitationState = auth_index.acceptInvitationState;
@@ -276,19 +276,23 @@ const subscriptionResponseMock = {
276
276
  cancellation: null,
277
277
  currentPeriodStart: '2021-09-20T08:08:51.000Z',
278
278
  currentPeriodEnd: '2021-10-20T08:08:51.000Z',
279
- items: [
280
- {
281
- id: 'si_KGE0p5himocPXH',
282
- externalId: 'prod_J60fUEvI7qV1eL',
283
- planId: 'prod_J60fUEvI7qV1eL',
284
- price: {
285
- id: 'price_1IToe8Ewsu4qiqnndAV76J69',
286
- externalId: 'price_1IToe8Ewsu4qiqnndAV76J69',
287
- currency: 'usd',
288
- amount: 10000,
289
- },
290
- },
291
- ],
279
+ plan: {
280
+ // TODO: fix dummy data
281
+ slug: 'test'
282
+ }
283
+ // items: [
284
+ // {
285
+ // id: 'si_KGE0p5himocPXH',
286
+ // externalId: 'prod_J60fUEvI7qV1eL',
287
+ // planId: 'prod_J60fUEvI7qV1eL',
288
+ // price: {
289
+ // id: 'price_1IToe8Ewsu4qiqnndAV76J69',
290
+ // externalId: 'price_1IToe8Ewsu4qiqnndAV76J69',
291
+ // currency: 'usd',
292
+ // amount: 10000,
293
+ // },
294
+ // },
295
+ // ],
292
296
  };
293
297
  const planResponseMock = [
294
298
  {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@frontegg/redux-store",
3
3
  "libName": "FronteggReduxStore",
4
- "version": "5.39.2",
4
+ "version": "5.40.0",
5
5
  "author": "Frontegg LTD",
6
6
  "main": "./node/index.js",
7
7
  "module": "./index.js",
8
8
  "types": "./index.d.ts",
9
9
  "dependencies": {
10
- "@frontegg/rest-api": "2.10.61",
10
+ "@frontegg/rest-api": "2.10.62",
11
11
  "@reduxjs/toolkit": "^1.5.0",
12
12
  "redux-saga": "^1.1.0",
13
13
  "tslib": "^2.3.1",
@@ -273,19 +273,23 @@ const subscriptionResponseMock = {
273
273
  cancellation: null,
274
274
  currentPeriodStart: '2021-09-20T08:08:51.000Z',
275
275
  currentPeriodEnd: '2021-10-20T08:08:51.000Z',
276
- items: [
277
- {
278
- id: 'si_KGE0p5himocPXH',
279
- externalId: 'prod_J60fUEvI7qV1eL',
280
- planId: 'prod_J60fUEvI7qV1eL',
281
- price: {
282
- id: 'price_1IToe8Ewsu4qiqnndAV76J69',
283
- externalId: 'price_1IToe8Ewsu4qiqnndAV76J69',
284
- currency: 'usd',
285
- amount: 10000,
286
- },
287
- },
288
- ],
276
+ plan: {
277
+ // TODO: fix dummy data
278
+ slug: 'test'
279
+ }
280
+ // items: [
281
+ // {
282
+ // id: 'si_KGE0p5himocPXH',
283
+ // externalId: 'prod_J60fUEvI7qV1eL',
284
+ // planId: 'prod_J60fUEvI7qV1eL',
285
+ // price: {
286
+ // id: 'price_1IToe8Ewsu4qiqnndAV76J69',
287
+ // externalId: 'price_1IToe8Ewsu4qiqnndAV76J69',
288
+ // currency: 'usd',
289
+ // amount: 10000,
290
+ // },
291
+ // },
292
+ // ],
289
293
  };
290
294
  const planResponseMock = [
291
295
  {