@frontegg/redux-store 6.69.0 → 6.70.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.
Files changed (254) hide show
  1. package/audits/AuditLogsState/index.js +1 -1
  2. package/audits/AuditLogsState/saga.js +1 -18
  3. package/audits/AuditsMetadataState/index.js +1 -1
  4. package/audits/AuditsMetadataState/saga.js +1 -5
  5. package/audits/backward-compatibility/saga.js +0 -18
  6. package/audits/dummy.js +0 -16
  7. package/audits/index.js +4 -2
  8. package/audits/reducer.js +0 -2
  9. package/auth/AcceptInvitationState/index.d.ts +2 -0
  10. package/auth/AcceptInvitationState/index.js +1 -1
  11. package/auth/AcceptInvitationState/interfaces.js +0 -1
  12. package/auth/AcceptInvitationState/saga.js +0 -3
  13. package/auth/AccountSettingsState/index.d.ts +2 -0
  14. package/auth/AccountSettingsState/index.js +1 -1
  15. package/auth/AccountSettingsState/interfaces.d.ts +2 -0
  16. package/auth/AccountSettingsState/saga.js +1 -11
  17. package/auth/ActivateState/index.d.ts +3 -0
  18. package/auth/ActivateState/index.js +1 -1
  19. package/auth/ActivateState/interfaces.js +0 -1
  20. package/auth/ActivateState/saga.js +14 -34
  21. package/auth/ApiTokensState/index.d.ts +2 -0
  22. package/auth/ApiTokensState/index.js +1 -1
  23. package/auth/ApiTokensState/interfaces.d.ts +1 -0
  24. package/auth/ApiTokensState/interfaces.js +0 -1
  25. package/auth/ApiTokensState/saga.js +1 -44
  26. package/auth/ForgotPasswordState/index.d.ts +2 -0
  27. package/auth/ForgotPasswordState/index.js +1 -1
  28. package/auth/ForgotPasswordState/interfaces.js +0 -1
  29. package/auth/ForgotPasswordState/saga.js +5 -12
  30. package/auth/ImpersonationState/index.d.ts +2 -0
  31. package/auth/ImpersonationState/index.js +1 -1
  32. package/auth/ImpersonationState/interfaces.js +0 -1
  33. package/auth/ImpersonationState/saga.js +5 -9
  34. package/auth/LoginState/index.d.ts +2 -0
  35. package/auth/LoginState/index.js +1 -1
  36. package/auth/LoginState/interfaces.js +0 -6
  37. package/auth/LoginState/saga.d.ts +2 -38
  38. package/auth/LoginState/saga.js +132 -292
  39. package/auth/MfaState/index.d.ts +4 -2
  40. package/auth/MfaState/index.js +1 -1
  41. package/auth/MfaState/interfaces.d.ts +2 -2
  42. package/auth/MfaState/interfaces.js +0 -1
  43. package/auth/MfaState/saga.js +64 -143
  44. package/auth/ProfileState/index.d.ts +2 -0
  45. package/auth/ProfileState/index.js +1 -1
  46. package/auth/ProfileState/saga.js +22 -50
  47. package/auth/Provisioning/index.d.ts +2 -0
  48. package/auth/Provisioning/index.js +1 -1
  49. package/auth/Provisioning/saga.js +11 -23
  50. package/auth/ResetPhoneNumberState/index.d.ts +2 -0
  51. package/auth/ResetPhoneNumberState/index.js +1 -1
  52. package/auth/ResetPhoneNumberState/interfaces.js +0 -1
  53. package/auth/ResetPhoneNumberState/saga.js +17 -26
  54. package/auth/RestrictionsState/index.d.ts +3 -0
  55. package/auth/RestrictionsState/index.js +1 -1
  56. package/auth/RestrictionsState/saga.js +52 -105
  57. package/auth/RolesState/index.d.ts +2 -0
  58. package/auth/RolesState/index.js +1 -1
  59. package/auth/RolesState/saga.js +30 -51
  60. package/auth/SSOState/index.d.ts +2 -0
  61. package/auth/SSOState/index.js +1 -1
  62. package/auth/SSOState/interfaces.js +0 -3
  63. package/auth/SSOState/saga.js +10 -58
  64. package/auth/SSOState/saga.v2.js +13 -49
  65. package/auth/SecurityPolicyState/index.d.ts +13 -0
  66. package/auth/SecurityPolicyState/index.js +1 -1
  67. package/auth/SecurityPolicyState/saga.js +36 -90
  68. package/auth/SessionsPolicyState/index.d.ts +2 -0
  69. package/auth/SessionsPolicyState/index.js +1 -1
  70. package/auth/SessionsPolicyState/saga.js +7 -19
  71. package/auth/SessionsState/index.d.ts +2 -0
  72. package/auth/SessionsState/index.js +1 -1
  73. package/auth/SessionsState/saga.js +1 -15
  74. package/auth/SignUp/index.d.ts +2 -0
  75. package/auth/SignUp/index.js +1 -1
  76. package/auth/SignUp/interfaces.js +0 -1
  77. package/auth/SignUp/saga.js +6 -15
  78. package/auth/SocialLogins/index.d.ts +2 -0
  79. package/auth/SocialLogins/index.js +1 -1
  80. package/auth/SocialLogins/saga.js +10 -20
  81. package/auth/TeamState/index.d.ts +2 -0
  82. package/auth/TeamState/index.js +1 -1
  83. package/auth/TeamState/interfaces.js +0 -1
  84. package/auth/TeamState/saga.js +85 -205
  85. package/auth/TenantsState/index.d.ts +2 -0
  86. package/auth/TenantsState/index.js +1 -1
  87. package/auth/TenantsState/saga.js +1 -17
  88. package/auth/index.d.ts +2 -2
  89. package/auth/index.js +4 -3
  90. package/auth/interfaces.d.ts +2 -1
  91. package/auth/interfaces.js +0 -6
  92. package/auth/reducer.d.ts +2 -2
  93. package/auth/reducer.js +0 -2
  94. package/auth/saga.js +2 -1
  95. package/auth/utils.d.ts +4 -0
  96. package/auth/utils.js +7 -21
  97. package/connectivity/ConnectivityState/index.d.ts +9 -0
  98. package/connectivity/ConnectivityState/index.js +1 -1
  99. package/connectivity/consts.js +0 -5
  100. package/connectivity/index.js +4 -2
  101. package/connectivity/interfaces.d.ts +1 -0
  102. package/connectivity/reducer.js +0 -2
  103. package/connectivity/saga.js +48 -85
  104. package/helpers.js +4 -7
  105. package/index.js +1 -1
  106. package/node/audits/AuditLogsState/index.js +1 -8
  107. package/node/audits/AuditLogsState/saga.js +1 -26
  108. package/node/audits/AuditsMetadataState/index.js +1 -8
  109. package/node/audits/AuditsMetadataState/saga.js +1 -10
  110. package/node/audits/backward-compatibility/index.js +0 -8
  111. package/node/audits/backward-compatibility/reducer.js +0 -5
  112. package/node/audits/backward-compatibility/saga.js +0 -23
  113. package/node/audits/dummy.js +0 -19
  114. package/node/audits/index.js +0 -14
  115. package/node/audits/initialState.js +0 -3
  116. package/node/audits/reducer.js +0 -8
  117. package/node/audits/saga.js +0 -5
  118. package/node/audits/utils.js +0 -4
  119. package/node/auth/AcceptInvitationState/index.js +1 -7
  120. package/node/auth/AcceptInvitationState/interfaces.js +0 -1
  121. package/node/auth/AcceptInvitationState/saga.js +0 -7
  122. package/node/auth/AccountSettingsState/index.js +1 -6
  123. package/node/auth/AccountSettingsState/saga.js +1 -16
  124. package/node/auth/ActivateState/index.js +1 -7
  125. package/node/auth/ActivateState/interfaces.js +0 -1
  126. package/node/auth/ActivateState/saga.js +14 -41
  127. package/node/auth/ApiTokensState/index.js +1 -6
  128. package/node/auth/ApiTokensState/interfaces.js +0 -1
  129. package/node/auth/ApiTokensState/saga.js +1 -51
  130. package/node/auth/ForgotPasswordState/index.js +1 -7
  131. package/node/auth/ForgotPasswordState/interfaces.js +0 -1
  132. package/node/auth/ForgotPasswordState/saga.js +5 -19
  133. package/node/auth/ImpersonationState/index.js +1 -7
  134. package/node/auth/ImpersonationState/interfaces.js +0 -1
  135. package/node/auth/ImpersonationState/saga.js +5 -15
  136. package/node/auth/LoginState/index.js +1 -7
  137. package/node/auth/LoginState/interfaces.js +0 -7
  138. package/node/auth/LoginState/saga.js +132 -322
  139. package/node/auth/MfaState/index.js +1 -7
  140. package/node/auth/MfaState/interfaces.js +0 -1
  141. package/node/auth/MfaState/saga.js +64 -137
  142. package/node/auth/ProfileState/index.js +1 -6
  143. package/node/auth/ProfileState/saga.js +22 -58
  144. package/node/auth/Provisioning/index.js +1 -6
  145. package/node/auth/Provisioning/saga.js +11 -28
  146. package/node/auth/ResetPhoneNumberState/index.js +1 -7
  147. package/node/auth/ResetPhoneNumberState/interfaces.js +0 -1
  148. package/node/auth/ResetPhoneNumberState/saga.js +17 -32
  149. package/node/auth/RestrictionsState/index.js +1 -7
  150. package/node/auth/RestrictionsState/saga.js +52 -109
  151. package/node/auth/RolesState/index.js +1 -6
  152. package/node/auth/RolesState/saga.js +30 -54
  153. package/node/auth/SSOState/index.js +1 -6
  154. package/node/auth/SSOState/interfaces.js +0 -3
  155. package/node/auth/SSOState/saga.js +10 -63
  156. package/node/auth/SSOState/saga.v2.js +13 -53
  157. package/node/auth/SecurityPolicyState/index.js +1 -6
  158. package/node/auth/SecurityPolicyState/saga.js +36 -89
  159. package/node/auth/SessionsPolicyState/index.js +1 -6
  160. package/node/auth/SessionsPolicyState/saga.js +7 -24
  161. package/node/auth/SessionsState/index.js +1 -6
  162. package/node/auth/SessionsState/saga.js +1 -22
  163. package/node/auth/SignUp/index.js +1 -7
  164. package/node/auth/SignUp/interfaces.js +0 -1
  165. package/node/auth/SignUp/saga.js +6 -30
  166. package/node/auth/SocialLogins/index.js +1 -6
  167. package/node/auth/SocialLogins/saga.js +10 -33
  168. package/node/auth/TeamState/index.js +1 -6
  169. package/node/auth/TeamState/interfaces.js +0 -1
  170. package/node/auth/TeamState/saga.js +86 -190
  171. package/node/auth/TenantsState/index.js +1 -6
  172. package/node/auth/TenantsState/saga.js +1 -24
  173. package/node/auth/dummy.js +0 -5
  174. package/node/auth/index.js +0 -90
  175. package/node/auth/initialState.js +0 -23
  176. package/node/auth/interfaces.js +0 -6
  177. package/node/auth/reducer.js +0 -28
  178. package/node/auth/saga.js +2 -26
  179. package/node/auth/utils.js +7 -42
  180. package/node/connectivity/ConnectivityState/index.js +1 -7
  181. package/node/connectivity/consts.js +1 -7
  182. package/node/connectivity/index.js +0 -5
  183. package/node/connectivity/reducer.js +0 -6
  184. package/node/connectivity/saga.js +47 -91
  185. package/node/helpers.js +2 -14
  186. package/node/index.js +1 -17
  187. package/node/subscriptions/Billing/Information/index.js +0 -7
  188. package/node/subscriptions/Billing/Information/saga.js +1 -25
  189. package/node/subscriptions/Billing/Invoices/index.js +0 -6
  190. package/node/subscriptions/Billing/Invoices/saga.js +1 -13
  191. package/node/subscriptions/Billing/PaymentMethod/index.js +2 -8
  192. package/node/subscriptions/Billing/PaymentMethod/interfaces.js +0 -1
  193. package/node/subscriptions/Billing/PaymentMethod/saga.js +1 -17
  194. package/node/subscriptions/Billing/Subscription/index.js +0 -6
  195. package/node/subscriptions/Billing/Subscription/saga.js +3 -23
  196. package/node/subscriptions/Billing/index.js +0 -6
  197. package/node/subscriptions/Billing/interfaces.js +0 -8
  198. package/node/subscriptions/Billing/saga.js +0 -7
  199. package/node/subscriptions/Checkout/index.js +0 -6
  200. package/node/subscriptions/Checkout/saga.js +2 -22
  201. package/node/subscriptions/Config/index.js +0 -6
  202. package/node/subscriptions/Config/saga.js +1 -12
  203. package/node/subscriptions/Plans/index.js +0 -6
  204. package/node/subscriptions/Plans/saga.js +1 -13
  205. package/node/subscriptions/Stripe/index.js +0 -6
  206. package/node/subscriptions/Stripe/saga.js +0 -8
  207. package/node/subscriptions/VendorPublicConfig/index.js +0 -6
  208. package/node/subscriptions/VendorPublicConfig/saga.js +1 -9
  209. package/node/subscriptions/dummy.js +2 -4
  210. package/node/subscriptions/general.interfaces.js +0 -5
  211. package/node/subscriptions/index.js +0 -5
  212. package/node/subscriptions/interfaces.js +0 -14
  213. package/node/subscriptions/mapper.js +0 -11
  214. package/node/subscriptions/reducer.js +0 -9
  215. package/node/subscriptions/saga.js +0 -9
  216. package/node/subscriptions/utils.js +0 -6
  217. package/node/toolkit/index.js +0 -31
  218. package/node/toolkit/redux-saga.js +0 -3
  219. package/node/toolkit/redux.js +0 -1
  220. package/node/vendor/VendorState/index.js +1 -7
  221. package/node/vendor/index.js +0 -5
  222. package/node/vendor/reducer.js +0 -6
  223. package/node/vendor/saga.js +1 -9
  224. package/package.json +1 -1
  225. package/subscriptions/Billing/Information/index.js +0 -4
  226. package/subscriptions/Billing/Information/saga.js +1 -12
  227. package/subscriptions/Billing/Invoices/index.js +0 -4
  228. package/subscriptions/Billing/Invoices/saga.js +1 -5
  229. package/subscriptions/Billing/PaymentMethod/index.js +2 -6
  230. package/subscriptions/Billing/PaymentMethod/interfaces.js +1 -1
  231. package/subscriptions/Billing/PaymentMethod/saga.js +1 -9
  232. package/subscriptions/Billing/Subscription/index.js +0 -4
  233. package/subscriptions/Billing/Subscription/saga.js +3 -17
  234. package/subscriptions/Billing/interfaces.js +1 -0
  235. package/subscriptions/Checkout/index.js +0 -4
  236. package/subscriptions/Checkout/saga.js +2 -12
  237. package/subscriptions/Config/index.js +0 -4
  238. package/subscriptions/Config/saga.js +1 -7
  239. package/subscriptions/Plans/index.js +0 -2
  240. package/subscriptions/Plans/saga.js +1 -6
  241. package/subscriptions/Stripe/index.js +0 -4
  242. package/subscriptions/Stripe/saga.js +0 -4
  243. package/subscriptions/VendorPublicConfig/index.js +0 -2
  244. package/subscriptions/VendorPublicConfig/saga.js +1 -4
  245. package/subscriptions/dummy.js +3 -2
  246. package/subscriptions/general.interfaces.js +0 -5
  247. package/subscriptions/index.js +3 -1
  248. package/subscriptions/mapper.js +0 -5
  249. package/toolkit/index.d.ts +1 -1
  250. package/toolkit/index.js +0 -9
  251. package/vendor/VendorState/index.js +1 -0
  252. package/vendor/index.js +4 -2
  253. package/vendor/reducer.js +0 -2
  254. package/vendor/saga.js +1 -2
@@ -1,23 +1,23 @@
1
1
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  const _excluded = ["callback"],
4
- _excluded2 = ["callback"],
5
- _excluded3 = ["callback"],
6
- _excluded4 = ["callback"],
7
- _excluded5 = ["callback", "events"],
8
- _excluded6 = ["callback"],
9
- _excluded7 = ["callback"],
10
- _excluded8 = ["callback"],
11
- _excluded9 = ["callback"],
12
- _excluded10 = ["callback"],
13
- _excluded11 = ["callback"],
14
- _excluded12 = ["callback"],
15
- _excluded13 = ["callback"],
16
- _excluded14 = ["callback"],
17
- _excluded15 = ["callback", "deviceId"],
18
- _excluded16 = ["callback", "deviceId"],
19
- _excluded17 = ["callback", "deviceId"],
20
- _excluded18 = ["callback", "deviceId"];
4
+ _excluded2 = ["callback"],
5
+ _excluded3 = ["callback"],
6
+ _excluded4 = ["callback"],
7
+ _excluded5 = ["callback", "events"],
8
+ _excluded6 = ["callback"],
9
+ _excluded7 = ["callback"],
10
+ _excluded8 = ["callback"],
11
+ _excluded9 = ["callback"],
12
+ _excluded10 = ["callback"],
13
+ _excluded11 = ["callback"],
14
+ _excluded12 = ["callback"],
15
+ _excluded13 = ["callback"],
16
+ _excluded14 = ["callback"],
17
+ _excluded15 = ["callback", "deviceId"],
18
+ _excluded16 = ["callback", "deviceId"],
19
+ _excluded17 = ["callback", "deviceId"],
20
+ _excluded18 = ["callback", "deviceId"];
21
21
  import { all, call, delay, put, select, takeLeading } from 'redux-saga/effects';
22
22
  import { api, AuthStrategyEnum, ContextHolder, fetch, MFAStrategyEnum } from '@frontegg/rest-api';
23
23
  import { actions } from '../reducer';
@@ -41,7 +41,6 @@ const authStrategyLoginStepMap = {
41
41
  };
42
42
  export function* afterAuthNavigation() {
43
43
  var _window;
44
-
45
44
  const onRedirectTo = ContextHolder.onRedirectTo;
46
45
  const {
47
46
  routes,
@@ -57,41 +56,33 @@ export function* afterAuthNavigation() {
57
56
  authenticatedUrl
58
57
  } = routes;
59
58
  const afterAuthRedirect = window.localStorage.getItem(FRONTEGG_AFTER_AUTH_REDIRECT_URL);
60
-
61
59
  if (afterAuthRedirect && ![loginUrl, logoutUrl, socialLoginCallbackUrl, activateUrl].includes(afterAuthRedirect)) {
62
60
  authenticatedUrl = afterAuthRedirect;
63
61
  }
64
-
65
62
  window.localStorage.removeItem(FRONTEGG_AFTER_AUTH_REDIRECT_URL);
66
63
  yield delay(200);
67
64
  put(actions.resetLoginState());
68
65
  const url = new URL((_window = window) == null ? void 0 : _window.location.href);
69
66
  let redirectUrl = authenticatedUrl;
70
-
71
67
  if (url.searchParams.get('redirectUrl')) {
72
68
  var _url$searchParams$get;
73
-
74
69
  redirectUrl = (_url$searchParams$get = url.searchParams.get('redirectUrl')) != null ? _url$searchParams$get : authenticatedUrl;
75
70
  } else if (includeQueryParam) {
76
71
  redirectUrl += window.location.search;
77
72
  }
78
-
79
73
  onRedirectTo(redirectUrl, {
80
74
  refresh: redirectUrl.startsWith('http')
81
75
  });
82
76
  }
83
77
  export function* refreshMetadata() {
84
78
  let ssoACS;
85
-
86
79
  try {
87
80
  var _metadata$configurati;
88
-
89
81
  const metadata = yield call(api.metadata.getSamlMetadata);
90
82
  ssoACS = metadata == null ? void 0 : (_metadata$configurati = metadata.configuration) == null ? void 0 : _metadata$configurati.acsUrl;
91
83
  } catch (e) {
92
84
  console.error(e);
93
85
  }
94
-
95
86
  yield put(actions.setState({
96
87
  ssoACS
97
88
  }));
@@ -119,7 +110,6 @@ export const isMfaRequired = user => {
119
110
  return false;
120
111
  }
121
112
  };
122
-
123
113
  const getNumberOfMfaDevices = mfaDevices => {
124
114
  const numberOfWebAuthnDevices = +Boolean(mfaDevices.webauthn.length);
125
115
  const numberOfPhoneDevices = +Boolean(mfaDevices.phones.length);
@@ -132,14 +122,12 @@ const getNumberOfMfaDevices = mfaDevices => {
132
122
  totalDevices
133
123
  };
134
124
  };
135
-
136
125
  const getMfaStepForEnrolledUsers = mfaDevices => {
137
126
  const {
138
127
  numberOfPhoneDevices,
139
128
  numberOfAuthenticators,
140
129
  totalDevices
141
130
  } = getNumberOfMfaDevices(mfaDevices);
142
-
143
131
  if (totalDevices === 1) {
144
132
  if (numberOfAuthenticators) {
145
133
  return MFAStep.authenticatorApp;
@@ -147,24 +135,19 @@ const getMfaStepForEnrolledUsers = mfaDevices => {
147
135
  return MFAStep.smsVerifyCode;
148
136
  }
149
137
  }
150
-
151
138
  return MFAStep.verify;
152
139
  };
153
-
154
140
  const getMfaStepForNotEnrolledUsers = mfaStrategies => {
155
141
  if (mfaStrategies.length === 1) {
156
142
  const [strategy] = mfaStrategies;
157
-
158
143
  if (strategy === MFAStrategyEnum.AuthenticatorApp) {
159
144
  return MFAStep.authenticatorApp;
160
145
  } else if (strategy === MFAStrategyEnum.SMS) {
161
146
  return MFAStep.smsSetPhoneNumber;
162
147
  }
163
148
  }
164
-
165
149
  return MFAStep.verify;
166
150
  };
167
-
168
151
  export function* getMfaRequiredState(user) {
169
152
  let step = LoginStep.loginWithTwoFactor;
170
153
  let mfaState = {};
@@ -176,7 +159,6 @@ export function* getMfaRequiredState(user) {
176
159
  mfaDeviceExpiration
177
160
  } = yield call(api.auth.checkIfAllowToRememberMfaDevice, user.mfaToken);
178
161
  const isEnrolled = !(user.hasOwnProperty('mfaEnrolled') && !user.mfaEnrolled);
179
-
180
162
  if (isEnrolled) {
181
163
  mfaState = {
182
164
  mfaDevices: user.mfaDevices,
@@ -193,17 +175,14 @@ export function* getMfaRequiredState(user) {
193
175
  };
194
176
  step = LoginStep.forceTwoFactor;
195
177
  }
196
-
197
178
  let quickLoginState = {};
198
179
  const quickLoginToRegister = localStorage.getItem('register-quick-login');
199
-
200
180
  if (quickLoginToRegister) {
201
181
  quickLoginState = {
202
182
  quickLoginToRegister,
203
183
  flow: LoginFlow.RegisterQuickLogin
204
184
  };
205
185
  }
206
-
207
186
  return {
208
187
  user: undefined,
209
188
  isAuthenticated: false,
@@ -226,19 +205,16 @@ export function* refreshToken() {
226
205
  const {
227
206
  hostedLoginBox
228
207
  } = yield select(state => state.auth);
229
-
230
208
  if (hostedLoginBox) {
231
209
  yield call(refreshTokenHosted);
232
210
  } else {
233
211
  yield call(refreshTokenEmbedded);
234
212
  }
235
213
  }
236
-
237
214
  function* refreshTokenHosted() {
238
215
  const {
239
216
  user
240
217
  } = yield select(state => state.auth);
241
-
242
218
  if (!(user != null && user.refreshToken)) {
243
219
  ContextHolder.setAccessToken(null);
244
220
  ContextHolder.setUser(null);
@@ -248,7 +224,6 @@ function* refreshTokenHosted() {
248
224
  }));
249
225
  return;
250
226
  }
251
-
252
227
  try {
253
228
  const body = {
254
229
  grant_type: 'refresh_token',
@@ -269,7 +244,6 @@ function* refreshTokenHosted() {
269
244
  }));
270
245
  }
271
246
  }
272
-
273
247
  function* refreshTokenEmbedded() {
274
248
  try {
275
249
  const onRedirectTo = ContextHolder.onRedirectTo;
@@ -281,7 +255,6 @@ function* refreshTokenEmbedded() {
281
255
  user,
282
256
  tenants
283
257
  } = yield call(api.auth.refreshTokenV2);
284
-
285
258
  if (isMfaRequired(user)) {
286
259
  const mfaRequiredState = yield getMfaRequiredState(user);
287
260
  yield put(actions.setState(mfaRequiredState));
@@ -290,11 +263,9 @@ function* refreshTokenEmbedded() {
290
263
  });
291
264
  } else {
292
265
  var _ref, _window2;
293
-
294
266
  if (user.id) {
295
267
  localStorage.setItem('userId', user.id);
296
268
  }
297
-
298
269
  const quickLoginToRegister = (_ref = localStorage.getItem('register-quick-login')) != null ? _ref : loginState.quickLoginToRegister;
299
270
  const shouldNavigateToRegisterQuickLogin = quickLoginToRegister && localStorage.getItem(`${user.id}-${quickLoginToRegister}`) !== 'true' && !window.location.pathname.endsWith(routes.logoutUrl);
300
271
  yield put(actions.setTenantsState({
@@ -312,11 +283,9 @@ function* refreshTokenEmbedded() {
312
283
  const url = new URL((_window2 = window) == null ? void 0 : _window2.location.href);
313
284
  const invitationToken = url.searchParams.get('invitationToken');
314
285
  const redirectRoutes = [routes.socialLoginCallbackUrl, routes.oidcRedirectUrl, routes.samlCallbackUrl];
315
-
316
286
  if (!invitationToken) {
317
287
  redirectRoutes.push(routes.loginUrl, routes.signUpUrl);
318
288
  }
319
-
320
289
  if (shouldNavigateToRegisterQuickLogin) {
321
290
  onRedirectTo(routes.loginUrl);
322
291
  } else if (redirectRoutes.some(url => url && window.location.pathname.endsWith(url))) {
@@ -338,7 +307,6 @@ function* refreshTokenEmbedded() {
338
307
  }));
339
308
  }
340
309
  }
341
-
342
310
  function* getUserIP({
343
311
  payload: {
344
312
  callback
@@ -356,12 +324,10 @@ function* getUserIP({
356
324
  callback == null ? void 0 : callback(false);
357
325
  }
358
326
  }
359
-
360
327
  function* requestAuthorize({
361
328
  payload: firstTime
362
329
  }) {
363
330
  const calls = [];
364
-
365
331
  if (firstTime) {
366
332
  yield put(actions.setState({
367
333
  isLoading: true
@@ -373,14 +339,12 @@ function* requestAuthorize({
373
339
  calls.push(call(loadVendorPublicInfo));
374
340
  calls.push(call(refreshMetadata));
375
341
  }
376
-
377
342
  calls.push(call(refreshToken));
378
343
  yield all(calls);
379
344
  yield put(actions.setState({
380
345
  isLoading: false
381
346
  }));
382
347
  }
383
-
384
348
  function* isMFARequiredSSR({
385
349
  accessToken,
386
350
  user
@@ -392,12 +356,10 @@ function* isMFARequiredSSR({
392
356
  }));
393
357
  return;
394
358
  }
395
-
396
359
  const onRedirectTo = ContextHolder.onRedirectTo;
397
360
  const {
398
361
  routes
399
362
  } = yield select(state => state.auth);
400
-
401
363
  if (isMfaRequired(user)) {
402
364
  const mfaRequiredState = yield getMfaRequiredState(user);
403
365
  yield put(actions.setState(mfaRequiredState));
@@ -406,7 +368,6 @@ function* isMFARequiredSSR({
406
368
  });
407
369
  }
408
370
  }
409
-
410
371
  function* requestAuthorizeSSR({
411
372
  payload
412
373
  }) {
@@ -419,17 +380,13 @@ function* requestAuthorizeSSR({
419
380
  calls.push(call(isMFARequiredSSR, payload));
420
381
  yield all(calls);
421
382
  }
422
-
423
383
  const getUri = urlStrategy => {
424
384
  if (urlStrategy === 'path') {
425
385
  var _window3;
426
-
427
386
  return ((_window3 = window) != null ? _window3 : document).location.pathname;
428
387
  } else {
429
388
  var _window4;
430
-
431
- let uri = (((_window4 = window) != null ? _window4 : document).location.hash || '#').substring(1);
432
-
389
+ const uri = (((_window4 = window) != null ? _window4 : document).location.hash || '#').substring(1);
433
390
  if (uri.indexOf('?') !== -1) {
434
391
  return uri.substring(0, uri.indexOf('?'));
435
392
  } else {
@@ -437,10 +394,8 @@ const getUri = urlStrategy => {
437
394
  }
438
395
  }
439
396
  };
440
-
441
397
  function* requestHostedLoginSilentAuthorize() {
442
398
  const user = yield call(api.auth.silentOAuthRefreshToken);
443
-
444
399
  if (user) {
445
400
  yield put(actions.setState({
446
401
  user,
@@ -454,7 +409,6 @@ function* requestHostedLoginSilentAuthorize() {
454
409
  throw new Error(`couldn't refresh user token with oauth service`);
455
410
  }
456
411
  }
457
-
458
412
  function* refreshOrRequestHostedLoginAuthorize({
459
413
  payload: additionalParams
460
414
  }) {
@@ -463,18 +417,15 @@ function* refreshOrRequestHostedLoginAuthorize({
463
417
  } = yield select(state => ({
464
418
  disableSilentRefresh: state.auth.disableSilentRefresh
465
419
  }));
466
-
467
420
  try {
468
421
  if (disableSilentRefresh) {
469
422
  throw new Error('silent refresh is disabled');
470
423
  }
471
-
472
424
  yield requestHostedLoginSilentAuthorize();
473
425
  } catch (e) {
474
426
  yield requestHostedLoginAuthorize(additionalParams);
475
427
  }
476
428
  }
477
-
478
429
  function* requestHostedLoginAuthorize(additionalParams) {
479
430
  const {
480
431
  routes,
@@ -488,26 +439,24 @@ function* requestHostedLoginAuthorize(additionalParams) {
488
439
  urlStrategy: state.root.urlStrategy
489
440
  }));
490
441
  const activeUri = getUri(urlStrategy);
491
-
492
442
  if (activeUri === routes.hostedLoginRedirectUrl) {
493
443
  console.debug('Calling loginWithRedirect while in hostedLoginCallback route');
494
444
  return;
495
445
  }
496
-
497
446
  yield put(actions.setState({
498
447
  isLoading: true
499
- })); // Generate the relevant params for the redirect
500
-
448
+ }));
449
+ // Generate the relevant params for the redirect
501
450
  const nonce = createRandomString();
502
451
  const code_verifier = createRandomString();
503
- const code_challenge = yield call(generateCodeChallenge, code_verifier); // We are saving the verifier in session storage to be able to validate the response
452
+ const code_challenge = yield call(generateCodeChallenge, code_verifier);
504
453
 
454
+ // We are saving the verifier in session storage to be able to validate the response
505
455
  localStorage.setItem(HOSTED_LOGIN_VERIFIER_KEY, code_verifier);
506
456
  const redirectUrl = `${window.location.origin}${urlStrategy === 'path' ? '' : '#'}${routes.hostedLoginRedirectUrl}`;
507
- const baseUrl = fetch.getBaseUrl(context, '/oauth/authorize'); // Hard coded for now
508
-
457
+ const baseUrl = fetch.getBaseUrl(context, '/oauth/authorize');
458
+ // Hard coded for now
509
459
  const oauthUrl = `${baseUrl}/oauth/authorize`;
510
-
511
460
  const params = _extends({
512
461
  response_type: 'code',
513
462
  client_id: context.clientId || 'INVALID-CLIENT-ID',
@@ -517,14 +466,12 @@ function* requestHostedLoginAuthorize(additionalParams) {
517
466
  code_challenge_method: 'S256',
518
467
  nonce
519
468
  }, additionalParams);
520
-
521
469
  const searchParams = new URLSearchParams(params);
522
470
  const url = `${oauthUrl}?${searchParams.toString()}`;
523
471
  onRedirectTo(url, {
524
472
  refresh: true
525
473
  });
526
474
  }
527
-
528
475
  function* handleHostedLoginCallback({
529
476
  payload
530
477
  }) {
@@ -544,9 +491,9 @@ function* handleHostedLoginCallback({
544
491
  code_verifier,
545
492
  grant_type: 'authorization_code'
546
493
  };
547
-
548
494
  try {
549
- const user = yield call(api.auth.exchangeOAuthTokens, body); // TODO: Validate nonce and aud
495
+ const user = yield call(api.auth.exchangeOAuthTokens, body);
496
+ // TODO: Validate nonce and aud
550
497
 
551
498
  yield put(actions.setState({
552
499
  user,
@@ -559,15 +506,13 @@ function* handleHostedLoginCallback({
559
506
  yield afterAuthNavigation();
560
507
  }
561
508
  }
562
-
563
509
  function* changePhoneNumberWithVerification(_ref2) {
564
510
  let {
565
- payload: {
566
- callback
567
- }
568
- } = _ref2,
569
- payload = _objectWithoutPropertiesLoose(_ref2.payload, _excluded);
570
-
511
+ payload: {
512
+ callback
513
+ }
514
+ } = _ref2,
515
+ payload = _objectWithoutPropertiesLoose(_ref2.payload, _excluded);
571
516
  try {
572
517
  yield put(actions.setLoginState({
573
518
  loading: true
@@ -588,15 +533,13 @@ function* changePhoneNumberWithVerification(_ref2) {
588
533
  }));
589
534
  }
590
535
  }
591
-
592
536
  function* verifyChangePhoneNumber(_ref3) {
593
537
  let {
594
- payload: {
595
- callback
596
- }
597
- } = _ref3,
598
- payload = _objectWithoutPropertiesLoose(_ref3.payload, _excluded2);
599
-
538
+ payload: {
539
+ callback
540
+ }
541
+ } = _ref3,
542
+ payload = _objectWithoutPropertiesLoose(_ref3.payload, _excluded2);
600
543
  try {
601
544
  yield put(actions.setLoginState({
602
545
  loading: true
@@ -613,21 +556,20 @@ function* verifyChangePhoneNumber(_ref3) {
613
556
  }));
614
557
  }
615
558
  }
616
-
617
559
  function* quickSmsPasswordlessPreLogin(_ref4) {
618
560
  let {
619
- payload: {
620
- callback
621
- }
622
- } = _ref4,
623
- payload = _objectWithoutPropertiesLoose(_ref4.payload, _excluded3);
624
-
561
+ payload: {
562
+ callback
563
+ }
564
+ } = _ref4,
565
+ payload = _objectWithoutPropertiesLoose(_ref4.payload, _excluded3);
625
566
  try {
626
567
  yield put(actions.setLoginState({
627
568
  loading: true
628
- })); // TODO: [Typescript 4.8] fix @frontegg/rest-api return value
629
- // @ts-ignore
569
+ }));
630
570
 
571
+ // TODO: [Typescript 4.8] fix @frontegg/rest-api return value
572
+ // @ts-ignore
631
573
  const preloginRes = yield call(api.auth.passwordlessPreLogin, _extends({}, payload, {
632
574
  type: AuthStrategyEnum.SmsCode
633
575
  }));
@@ -646,15 +588,13 @@ function* quickSmsPasswordlessPreLogin(_ref4) {
646
588
  callback == null ? void 0 : callback(e);
647
589
  }
648
590
  }
649
-
650
591
  function* passwordlessPreLogin(_ref5) {
651
592
  let {
652
- payload: {
653
- callback
654
- }
655
- } = _ref5,
656
- payload = _objectWithoutPropertiesLoose(_ref5.payload, _excluded4);
657
-
593
+ payload: {
594
+ callback
595
+ }
596
+ } = _ref5,
597
+ payload = _objectWithoutPropertiesLoose(_ref5.payload, _excluded4);
658
598
  try {
659
599
  const {
660
600
  onRedirectTo,
@@ -670,12 +610,12 @@ function* passwordlessPreLogin(_ref5) {
670
610
  }));
671
611
  yield put(actions.setLoginState({
672
612
  loading: true
673
- })); // TODO: [Typescript 4.8] fix @frontegg/rest-api return value
674
- // @ts-ignore
613
+ }));
675
614
 
615
+ // TODO: [Typescript 4.8] fix @frontegg/rest-api return value
616
+ // @ts-ignore
676
617
  const preloginRes = yield call(api.auth.passwordlessPreLogin, payload);
677
618
  const step = authStrategyLoginStepMap[payload.type];
678
-
679
619
  if (step === LoginStep.loginWithSmsOtc && preloginRes.resetPhoneNumberToken) {
680
620
  yield put(actions.setResetPhoneNumberState({
681
621
  resetPhoneNumberToken: preloginRes.resetPhoneNumberToken,
@@ -684,7 +624,6 @@ function* passwordlessPreLogin(_ref5) {
684
624
  onRedirectTo(routes.resetPhoneNumberUrl);
685
625
  return;
686
626
  }
687
-
688
627
  yield put(actions.setLoginState({
689
628
  step,
690
629
  loading: false,
@@ -701,16 +640,14 @@ function* passwordlessPreLogin(_ref5) {
701
640
  callback == null ? void 0 : callback();
702
641
  }
703
642
  }
704
-
705
643
  function* passwordlessPostLogin(_ref6) {
706
644
  let {
707
- payload: {
708
- callback,
709
- events
710
- }
711
- } = _ref6,
712
- payload = _objectWithoutPropertiesLoose(_ref6.payload, _excluded5);
713
-
645
+ payload: {
646
+ callback,
647
+ events
648
+ }
649
+ } = _ref6,
650
+ payload = _objectWithoutPropertiesLoose(_ref6.payload, _excluded5);
714
651
  try {
715
652
  yield put(actions.setLoginState({
716
653
  loading: true
@@ -720,7 +657,6 @@ function* passwordlessPostLogin(_ref6) {
720
657
  const {
721
658
  routes
722
659
  } = yield select(state => state.auth);
723
-
724
660
  if (isMfaRequired(data)) {
725
661
  const mfaRequiredState = yield getMfaRequiredState(data);
726
662
  yield put(actions.setState(mfaRequiredState));
@@ -732,10 +668,8 @@ function* passwordlessPostLogin(_ref6) {
732
668
  loginState
733
669
  } = yield select(state => state.auth);
734
670
  const user = yield call(api.auth.generateLoginResponse, data);
735
-
736
671
  if (data.emailVerified) {
737
672
  var _events$userVerified;
738
-
739
673
  events == null ? void 0 : (_events$userVerified = events.userVerified) == null ? void 0 : _events$userVerified.call(events, {
740
674
  email: user.email,
741
675
  origin: UserVeirifedOriginTypes.PASSWORDLESS,
@@ -745,11 +679,9 @@ function* passwordlessPostLogin(_ref6) {
745
679
  name: user.name
746
680
  });
747
681
  }
748
-
749
682
  if (user.id) {
750
683
  localStorage.setItem('userId', user.id);
751
684
  }
752
-
753
685
  yield put(actions.setState({
754
686
  user,
755
687
  isAuthenticated: true
@@ -758,7 +690,6 @@ function* passwordlessPostLogin(_ref6) {
758
690
  error: undefined
759
691
  }));
760
692
  yield put(actions.loadTenants());
761
-
762
693
  if (loginState.flow === LoginFlow.Login) {
763
694
  yield afterAuthNavigation();
764
695
  } else {
@@ -766,13 +697,11 @@ function* passwordlessPostLogin(_ref6) {
766
697
  preserveQueryParams: true
767
698
  });
768
699
  }
769
-
770
700
  localStorage.removeItem('register-quick-login');
771
701
  callback == null ? void 0 : callback(true);
772
702
  }
773
703
  } catch (e) {
774
704
  var _e$message;
775
-
776
705
  yield put(actions.setLoginState({
777
706
  error: (_e$message = e.message) != null ? _e$message : 'Failed to authenticate'
778
707
  }));
@@ -782,7 +711,6 @@ function* passwordlessPostLogin(_ref6) {
782
711
  }));
783
712
  }
784
713
  }
785
-
786
714
  function* verifyInviteToken({
787
715
  payload
788
716
  }) {
@@ -798,7 +726,6 @@ function* verifyInviteToken({
798
726
  }));
799
727
  } catch (e) {
800
728
  var _e$message2;
801
-
802
729
  console.error(e);
803
730
  yield put(actions.setLoginState({
804
731
  inviteTokenError: (_e$message2 = e.message) != null ? _e$message2 : `We couldn't verify your invitation`
@@ -809,7 +736,6 @@ function* verifyInviteToken({
809
736
  }));
810
737
  }
811
738
  }
812
-
813
739
  function* preLogin({
814
740
  payload: {
815
741
  email,
@@ -821,7 +747,6 @@ function* preLogin({
821
747
  yield put(actions.setLoginState({
822
748
  loading: true
823
749
  }));
824
-
825
750
  try {
826
751
  const onRedirectTo = yield select(({
827
752
  auth: {
@@ -834,7 +759,6 @@ function* preLogin({
834
759
  } = yield call(api.auth.preLoginV2, {
835
760
  email
836
761
  });
837
-
838
762
  if (address) {
839
763
  if (idpType === SamlVendors.Oidc && !address.includes('redirect_uri')) {
840
764
  const {
@@ -850,7 +774,6 @@ function* preLogin({
850
774
  }));
851
775
  address += `&redirect_uri=${window.location.origin}${oidcRedirectUrl}`;
852
776
  }
853
-
854
777
  yield put(actions.setLoginState({
855
778
  step: LoginStep.redirectToSSO,
856
779
  loading: false,
@@ -878,13 +801,11 @@ function* preLogin({
878
801
  });
879
802
  }
880
803
  }
881
-
882
804
  function* ssoPreloginFailed(_ref7) {
883
805
  let {
884
- callback
885
- } = _ref7,
886
- body = _objectWithoutPropertiesLoose(_ref7, _excluded6);
887
-
806
+ callback
807
+ } = _ref7,
808
+ body = _objectWithoutPropertiesLoose(_ref7, _excluded6);
888
809
  const publicPolicy = yield select(({
889
810
  auth: {
890
811
  securityPolicyState: {
@@ -894,7 +815,6 @@ function* ssoPreloginFailed(_ref7) {
894
815
  }
895
816
  }
896
817
  }) => publicPolicy);
897
-
898
818
  if (!(publicPolicy != null && publicPolicy.authStrategy)) {
899
819
  yield put(actions.setLoginState({
900
820
  step: LoginStep.loginWithPassword,
@@ -903,7 +823,6 @@ function* ssoPreloginFailed(_ref7) {
903
823
  callback == null ? void 0 : callback();
904
824
  return;
905
825
  }
906
-
907
826
  if ((publicPolicy == null ? void 0 : publicPolicy.authStrategy) === AuthStrategyEnum.EmailAndPassword) {
908
827
  yield put(actions.setLoginState({
909
828
  step: LoginStep.loginWithPassword,
@@ -923,7 +842,6 @@ function* ssoPreloginFailed(_ref7) {
923
842
  callback == null ? void 0 : callback();
924
843
  }
925
844
  }
926
-
927
845
  function* webAuthnCreateNewDeviceSession({
928
846
  payload: {
929
847
  callback
@@ -951,15 +869,13 @@ function* webAuthnCreateNewDeviceSession({
951
869
  }));
952
870
  }
953
871
  }
954
-
955
872
  function* webAuthnVerifyNewDeviceSession(_ref8) {
956
873
  let {
957
- payload: {
958
- callback
959
- }
960
- } = _ref8,
961
- body = _objectWithoutPropertiesLoose(_ref8.payload, _excluded7);
962
-
874
+ payload: {
875
+ callback
876
+ }
877
+ } = _ref8,
878
+ body = _objectWithoutPropertiesLoose(_ref8.payload, _excluded7);
963
879
  try {
964
880
  yield put(actions.setLoginState({
965
881
  loading: true
@@ -981,18 +897,15 @@ function* webAuthnVerifyNewDeviceSession(_ref8) {
981
897
  }));
982
898
  }
983
899
  }
984
-
985
900
  function* webAuthnPrelogin(_ref9) {
986
901
  let {
987
- payload: {
988
- callback
989
- }
990
- } = _ref9,
991
- body = _objectWithoutPropertiesLoose(_ref9.payload, _excluded8);
992
-
902
+ payload: {
903
+ callback
904
+ }
905
+ } = _ref9,
906
+ body = _objectWithoutPropertiesLoose(_ref9.payload, _excluded8);
993
907
  try {
994
908
  var _options$allowCredent;
995
-
996
909
  yield put(actions.setLoginState({
997
910
  loading: true
998
911
  }));
@@ -1018,18 +931,15 @@ function* webAuthnPrelogin(_ref9) {
1018
931
  }));
1019
932
  }
1020
933
  }
1021
-
1022
934
  function* webAuthnPostLogin(_ref10) {
1023
935
  let {
1024
- payload: {
1025
- callback
1026
- }
1027
- } = _ref10,
1028
- body = _objectWithoutPropertiesLoose(_ref10.payload, _excluded9);
1029
-
936
+ payload: {
937
+ callback
938
+ }
939
+ } = _ref10,
940
+ body = _objectWithoutPropertiesLoose(_ref10.payload, _excluded9);
1030
941
  try {
1031
942
  var _publicKey$response$u;
1032
-
1033
943
  yield put(actions.setLoginState({
1034
944
  loading: true
1035
945
  }));
@@ -1041,7 +951,6 @@ function* webAuthnPostLogin(_ref10) {
1041
951
  recaptchaToken: body.recaptchaToken,
1042
952
  invitationToken: body.invitationToken
1043
953
  }));
1044
-
1045
954
  if (isMfaRequired(data)) {
1046
955
  const onRedirectTo = ContextHolder.onRedirectTo;
1047
956
  const {
@@ -1054,11 +963,9 @@ function* webAuthnPostLogin(_ref10) {
1054
963
  });
1055
964
  } else {
1056
965
  const user = yield call(api.auth.generateLoginResponse, data);
1057
-
1058
966
  if (user.id) {
1059
967
  localStorage.setItem('userId', user.id);
1060
968
  }
1061
-
1062
969
  yield put(actions.loadTenants());
1063
970
  yield put(actions.setState({
1064
971
  user,
@@ -1067,11 +974,11 @@ function* webAuthnPostLogin(_ref10) {
1067
974
  yield put(actions.setLoginState({
1068
975
  error: undefined
1069
976
  }));
1070
- yield afterAuthNavigation(); // TODO: Itamar why moving callback to inside the else block
1071
-
977
+ yield afterAuthNavigation();
978
+ // TODO: Itamar why moving callback to inside the else block
1072
979
  callback == null ? void 0 : callback(true);
1073
- } // callback?.(true);
1074
-
980
+ }
981
+ // callback?.(true);
1075
982
  } catch (e) {
1076
983
  yield put(actions.setLoginState({
1077
984
  error: e.message
@@ -1083,7 +990,6 @@ function* webAuthnPostLogin(_ref10) {
1083
990
  }));
1084
991
  }
1085
992
  }
1086
-
1087
993
  function* postLogin({
1088
994
  payload
1089
995
  }) {
@@ -1102,7 +1008,6 @@ function* postLogin({
1102
1008
  yield put(actions.setLoginState({
1103
1009
  loading: true
1104
1010
  }));
1105
-
1106
1011
  try {
1107
1012
  const user = yield call(api.auth.postLogin, payload);
1108
1013
  ContextHolder.setAccessToken(user.accessToken);
@@ -1122,7 +1027,6 @@ function* postLogin({
1122
1027
  }));
1123
1028
  }
1124
1029
  }
1125
-
1126
1030
  function* login({
1127
1031
  payload: {
1128
1032
  email,
@@ -1135,7 +1039,6 @@ function* login({
1135
1039
  yield put(actions.setLoginState({
1136
1040
  loading: true
1137
1041
  }));
1138
-
1139
1042
  try {
1140
1043
  const user = yield call(api.auth.login, {
1141
1044
  email,
@@ -1149,7 +1052,6 @@ function* login({
1149
1052
  const {
1150
1053
  routes
1151
1054
  } = yield select(state => state.auth);
1152
-
1153
1055
  if (isMfaRequired(user)) {
1154
1056
  const mfaRequiredState = yield getMfaRequiredState(user);
1155
1057
  yield put(actions.setState(mfaRequiredState));
@@ -1161,11 +1063,9 @@ function* login({
1161
1063
  loginState
1162
1064
  } = yield select(state => state.auth);
1163
1065
  const isAuthenticated = !!user.accessToken;
1164
-
1165
1066
  if (user.id) {
1166
1067
  localStorage.setItem('userId', user.id);
1167
1068
  }
1168
-
1169
1069
  yield put(actions.setState({
1170
1070
  user,
1171
1071
  isAuthenticated,
@@ -1182,13 +1082,12 @@ function* login({
1182
1082
  }
1183
1083
  }));
1184
1084
  yield put(actions.loadTenants());
1185
-
1186
1085
  if (isAuthenticated && loginState.flow === LoginFlow.Login) {
1187
1086
  yield afterAuthNavigation();
1188
1087
  }
1189
- } // TODO: extract item name to constants
1190
-
1088
+ }
1191
1089
 
1090
+ // TODO: extract item name to constants
1192
1091
  localStorage.removeItem('register-quick-login');
1193
1092
  callback == null ? void 0 : callback(true);
1194
1093
  } catch (e) {
@@ -1201,7 +1100,6 @@ function* login({
1201
1100
  }));
1202
1101
  }
1203
1102
  }
1204
-
1205
1103
  function* loginWithMfa({
1206
1104
  payload: {
1207
1105
  mfaToken,
@@ -1213,7 +1111,6 @@ function* loginWithMfa({
1213
1111
  yield put(actions.setLoginState({
1214
1112
  loading: true
1215
1113
  }));
1216
-
1217
1114
  try {
1218
1115
  const user = yield call(api.auth.loginWithMfa, {
1219
1116
  mfaToken,
@@ -1237,21 +1134,17 @@ function* loginWithMfa({
1237
1134
  user,
1238
1135
  isAuthenticated: true
1239
1136
  }));
1240
-
1241
1137
  if (user.id) {
1242
1138
  localStorage.setItem('userId', user.id);
1243
1139
  }
1244
-
1245
1140
  yield put(actions.loadTenants());
1246
1141
  yield put(actions.setLoginState({
1247
1142
  error: undefined,
1248
1143
  loading: false
1249
1144
  }));
1250
-
1251
1145
  if (loginState.flow === LoginFlow.Login) {
1252
1146
  yield afterAuthNavigation();
1253
1147
  }
1254
-
1255
1148
  callback == null ? void 0 : callback(true);
1256
1149
  } catch (e) {
1257
1150
  yield put(actions.setLoginState({
@@ -1261,14 +1154,12 @@ function* loginWithMfa({
1261
1154
  callback == null ? void 0 : callback(false, e);
1262
1155
  }
1263
1156
  }
1264
-
1265
1157
  function* recoverMfa({
1266
1158
  payload
1267
1159
  }) {
1268
1160
  yield put(actions.setLoginState({
1269
1161
  loading: true
1270
1162
  }));
1271
-
1272
1163
  try {
1273
1164
  yield call(api.auth.recoverMfaToken, payload);
1274
1165
  yield put(actions.setLoginState({
@@ -1287,7 +1178,6 @@ function* recoverMfa({
1287
1178
  }));
1288
1179
  }
1289
1180
  }
1290
-
1291
1181
  function* logout({
1292
1182
  payload
1293
1183
  }) {
@@ -1297,7 +1187,6 @@ function* logout({
1297
1187
  yield put(actions.setState({
1298
1188
  isLoading: true
1299
1189
  }));
1300
-
1301
1190
  try {
1302
1191
  if (hostedLoginBox) {
1303
1192
  yield call(api.auth.OAuthLogout);
@@ -1305,28 +1194,22 @@ function* logout({
1305
1194
  yield call(api.auth.logout);
1306
1195
  }
1307
1196
  } catch {}
1308
-
1309
1197
  yield put(actions.resetState());
1310
1198
  yield put(actions.requestAuthorize(true));
1311
1199
  payload == null ? void 0 : payload();
1312
1200
  }
1313
-
1314
1201
  function* silentLogout({
1315
1202
  payload
1316
1203
  }) {
1317
1204
  var _payload$callbackTime;
1318
-
1319
1205
  try {
1320
1206
  yield call(api.auth.logout);
1321
1207
  } catch {}
1322
-
1323
1208
  setTimeout(() => {
1324
1209
  var _payload$callback;
1325
-
1326
1210
  return payload == null ? void 0 : (_payload$callback = payload.callback) == null ? void 0 : _payload$callback.call(payload, true);
1327
1211
  }, (_payload$callbackTime = payload == null ? void 0 : payload.callbackTimeout) != null ? _payload$callbackTime : 500);
1328
1212
  }
1329
-
1330
1213
  function* handleEnrollMFAResponse({
1331
1214
  user,
1332
1215
  tenants
@@ -1337,23 +1220,19 @@ function* handleEnrollMFAResponse({
1337
1220
  error: undefined,
1338
1221
  saving: false
1339
1222
  };
1340
-
1341
1223
  if (user != null && user.recoveryCode) {
1342
1224
  mfaState.recoveryCode = user.recoveryCode;
1343
1225
  }
1344
-
1345
1226
  yield put(actions.setMfaState(mfaState));
1346
1227
  yield put(actions.setUser(user));
1347
1228
  yield put(actions.setTenantsState({
1348
1229
  tenants,
1349
1230
  loading: false
1350
1231
  }));
1351
-
1352
1232
  if (user.id) {
1353
1233
  localStorage.setItem('userId', user.id);
1354
1234
  }
1355
1235
  }
1356
-
1357
1236
  function* handleVerifyMFAResponse({
1358
1237
  user,
1359
1238
  tenants
@@ -1366,32 +1245,26 @@ function* handleVerifyMFAResponse({
1366
1245
  tenants,
1367
1246
  loading: false
1368
1247
  }));
1369
-
1370
1248
  if (user.id) {
1371
1249
  localStorage.setItem('userId', user.id);
1372
1250
  }
1373
-
1374
1251
  if (loginState.flow === LoginFlow.Login) {
1375
1252
  yield afterAuthNavigation();
1376
1253
  }
1377
-
1378
1254
  yield put(actions.setState({
1379
1255
  isAuthenticated: true
1380
1256
  }));
1381
1257
  }
1382
-
1383
1258
  function* preEnrollMFASMSForLogin(_ref11) {
1384
1259
  let {
1385
- payload: {
1386
- callback
1387
- }
1388
- } = _ref11,
1389
- payload = _objectWithoutPropertiesLoose(_ref11.payload, _excluded10);
1390
-
1260
+ payload: {
1261
+ callback
1262
+ }
1263
+ } = _ref11,
1264
+ payload = _objectWithoutPropertiesLoose(_ref11.payload, _excluded10);
1391
1265
  yield put(actions.setLoginState({
1392
1266
  loading: true
1393
1267
  }));
1394
-
1395
1268
  try {
1396
1269
  const data = yield call(api.auth.preEnrollMFASMSForLogin, payload);
1397
1270
  yield put(actions.setMfaState({
@@ -1411,19 +1284,16 @@ function* preEnrollMFASMSForLogin(_ref11) {
1411
1284
  callback == null ? void 0 : callback(null);
1412
1285
  }
1413
1286
  }
1414
-
1415
1287
  function* enrollMFASMSForLogin(_ref12) {
1416
1288
  let {
1417
- payload: {
1418
- callback
1419
- }
1420
- } = _ref12,
1421
- payload = _objectWithoutPropertiesLoose(_ref12.payload, _excluded11);
1422
-
1289
+ payload: {
1290
+ callback
1291
+ }
1292
+ } = _ref12,
1293
+ payload = _objectWithoutPropertiesLoose(_ref12.payload, _excluded11);
1423
1294
  yield put(actions.setLoginState({
1424
1295
  loading: true
1425
1296
  }));
1426
-
1427
1297
  try {
1428
1298
  const data = yield call(api.auth.enrollMFASMSForLogin, payload);
1429
1299
  const response = yield call(api.auth.generateLoginResponseV2, data);
@@ -1440,24 +1310,19 @@ function* enrollMFASMSForLogin(_ref12) {
1440
1310
  callback == null ? void 0 : callback(null);
1441
1311
  }
1442
1312
  }
1443
-
1444
1313
  function* preEnrollMFAWebAuthnForLogin(_ref13) {
1445
1314
  let {
1446
- payload: {
1447
- callback
1448
- }
1449
- } = _ref13,
1450
- payload = _objectWithoutPropertiesLoose(_ref13.payload, _excluded12);
1451
-
1315
+ payload: {
1316
+ callback
1317
+ }
1318
+ } = _ref13,
1319
+ payload = _objectWithoutPropertiesLoose(_ref13.payload, _excluded12);
1452
1320
  yield put(actions.setLoginState({
1453
1321
  loading: true
1454
1322
  }));
1455
-
1456
1323
  try {
1457
1324
  var _data$options$exclude;
1458
-
1459
1325
  const data = yield call(api.auth.preEnrollMFAWebAuthnForLogin, payload);
1460
-
1461
1326
  const options = _extends({}, data.options, {
1462
1327
  challenge: base64urlDecode(data.options.challenge),
1463
1328
  user: _extends({}, data.options.user, {
@@ -1467,7 +1332,6 @@ function* preEnrollMFAWebAuthnForLogin(_ref13) {
1467
1332
  id: base64urlDecode(credentials.id)
1468
1333
  }))
1469
1334
  });
1470
-
1471
1335
  yield put(actions.setLoginState({
1472
1336
  loading: false
1473
1337
  }));
@@ -1483,19 +1347,16 @@ function* preEnrollMFAWebAuthnForLogin(_ref13) {
1483
1347
  callback == null ? void 0 : callback(null);
1484
1348
  }
1485
1349
  }
1486
-
1487
1350
  function* enrollMFAWebAuthnForLogin(_ref14) {
1488
1351
  let {
1489
- payload: {
1490
- callback
1491
- }
1492
- } = _ref14,
1493
- payload = _objectWithoutPropertiesLoose(_ref14.payload, _excluded13);
1494
-
1352
+ payload: {
1353
+ callback
1354
+ }
1355
+ } = _ref14,
1356
+ payload = _objectWithoutPropertiesLoose(_ref14.payload, _excluded13);
1495
1357
  yield put(actions.setLoginState({
1496
1358
  loading: true
1497
1359
  }));
1498
-
1499
1360
  try {
1500
1361
  const publicKey = publicKeyCredentialToJSON(payload.publicKey);
1501
1362
  const data = yield call(api.auth.enrollMFAWebAuthnForLogin, _extends({}, payload, {
@@ -1515,19 +1376,16 @@ function* enrollMFAWebAuthnForLogin(_ref14) {
1515
1376
  callback == null ? void 0 : callback(null);
1516
1377
  }
1517
1378
  }
1518
-
1519
1379
  function* enrollMFAAuthenticatorAppForLogin(_ref15) {
1520
1380
  let {
1521
- payload: {
1522
- callback
1523
- }
1524
- } = _ref15,
1525
- payload = _objectWithoutPropertiesLoose(_ref15.payload, _excluded14);
1526
-
1381
+ payload: {
1382
+ callback
1383
+ }
1384
+ } = _ref15,
1385
+ payload = _objectWithoutPropertiesLoose(_ref15.payload, _excluded14);
1527
1386
  yield put(actions.setLoginState({
1528
1387
  loading: true
1529
1388
  }));
1530
-
1531
1389
  try {
1532
1390
  const data = yield call(api.auth.enrollMFAAuthenticatorAppForLogin, payload);
1533
1391
  const response = yield call(api.auth.generateLoginResponseV2, data);
@@ -1544,20 +1402,17 @@ function* enrollMFAAuthenticatorAppForLogin(_ref15) {
1544
1402
  callback == null ? void 0 : callback(null);
1545
1403
  }
1546
1404
  }
1547
-
1548
1405
  function* preVerifyMFASMSForLogin(_ref16) {
1549
1406
  let {
1550
- payload: {
1551
- callback,
1552
- deviceId
1553
- }
1554
- } = _ref16,
1555
- payload = _objectWithoutPropertiesLoose(_ref16.payload, _excluded15);
1556
-
1407
+ payload: {
1408
+ callback,
1409
+ deviceId
1410
+ }
1411
+ } = _ref16,
1412
+ payload = _objectWithoutPropertiesLoose(_ref16.payload, _excluded15);
1557
1413
  yield put(actions.setLoginState({
1558
1414
  loading: true
1559
1415
  }));
1560
-
1561
1416
  try {
1562
1417
  const data = yield call(api.auth.preVerifyMFASMSForLogin, deviceId, payload);
1563
1418
  yield put(actions.setMfaState({
@@ -1577,20 +1432,17 @@ function* preVerifyMFASMSForLogin(_ref16) {
1577
1432
  callback == null ? void 0 : callback(null);
1578
1433
  }
1579
1434
  }
1580
-
1581
1435
  function* verifyMFASMSForLogin(_ref17) {
1582
1436
  let {
1583
- payload: {
1584
- callback,
1585
- deviceId
1586
- }
1587
- } = _ref17,
1588
- payload = _objectWithoutPropertiesLoose(_ref17.payload, _excluded16);
1589
-
1437
+ payload: {
1438
+ callback,
1439
+ deviceId
1440
+ }
1441
+ } = _ref17,
1442
+ payload = _objectWithoutPropertiesLoose(_ref17.payload, _excluded16);
1590
1443
  yield put(actions.setLoginState({
1591
1444
  loading: true
1592
1445
  }));
1593
-
1594
1446
  try {
1595
1447
  const data = yield call(api.auth.verifyMFASMSForLogin, deviceId, payload);
1596
1448
  const response = yield call(api.auth.generateLoginResponseV2, data);
@@ -1607,32 +1459,26 @@ function* verifyMFASMSForLogin(_ref17) {
1607
1459
  callback == null ? void 0 : callback(null);
1608
1460
  }
1609
1461
  }
1610
-
1611
1462
  function* preVerifyMFAWebAuthnForLogin(_ref18) {
1612
1463
  let {
1613
- payload: {
1614
- callback,
1615
- deviceId
1616
- }
1617
- } = _ref18,
1618
- payload = _objectWithoutPropertiesLoose(_ref18.payload, _excluded17);
1619
-
1464
+ payload: {
1465
+ callback,
1466
+ deviceId
1467
+ }
1468
+ } = _ref18,
1469
+ payload = _objectWithoutPropertiesLoose(_ref18.payload, _excluded17);
1620
1470
  yield put(actions.setLoginState({
1621
1471
  loading: true
1622
1472
  }));
1623
-
1624
1473
  try {
1625
1474
  var _data$options$allowCr;
1626
-
1627
1475
  const data = yield call(api.auth.preVerifyMFAWebAuthnForLogin, deviceId, payload);
1628
-
1629
1476
  const options = _extends({}, data.options, {
1630
1477
  challenge: base64urlDecode(data.options.challenge),
1631
1478
  allowCredentials: (_data$options$allowCr = data.options.allowCredentials) == null ? void 0 : _data$options$allowCr.map(credentials => _extends({}, credentials, {
1632
1479
  id: base64urlDecode(credentials.id)
1633
1480
  }))
1634
1481
  });
1635
-
1636
1482
  yield put(actions.setLoginState({
1637
1483
  loading: false
1638
1484
  }));
@@ -1648,20 +1494,17 @@ function* preVerifyMFAWebAuthnForLogin(_ref18) {
1648
1494
  callback == null ? void 0 : callback(null);
1649
1495
  }
1650
1496
  }
1651
-
1652
1497
  function* verifyMFAWebAuthnForLogin(_ref19) {
1653
1498
  let {
1654
- payload: {
1655
- callback,
1656
- deviceId
1657
- }
1658
- } = _ref19,
1659
- payload = _objectWithoutPropertiesLoose(_ref19.payload, _excluded18);
1660
-
1499
+ payload: {
1500
+ callback,
1501
+ deviceId
1502
+ }
1503
+ } = _ref19,
1504
+ payload = _objectWithoutPropertiesLoose(_ref19.payload, _excluded18);
1661
1505
  yield put(actions.setLoginState({
1662
1506
  loading: true
1663
1507
  }));
1664
-
1665
1508
  try {
1666
1509
  const publicKey = publicKeyCredentialToJSON(payload.publicKey);
1667
1510
  const data = yield call(api.auth.verifyMFAWebAuthnForLogin, deviceId, _extends({}, payload, {
@@ -1681,7 +1524,6 @@ function* verifyMFAWebAuthnForLogin(_ref19) {
1681
1524
  callback == null ? void 0 : callback(null);
1682
1525
  }
1683
1526
  }
1684
-
1685
1527
  export function* loginSagas() {
1686
1528
  yield takeLeading(actions.requestAuthorize, requestAuthorize);
1687
1529
  yield takeLeading(actions.requestAuthorizeSSR, requestAuthorizeSSR);
@@ -1716,6 +1558,7 @@ export function* loginSagas() {
1716
1558
  yield takeLeading(actions.preVerifyMFAWebAuthnForLogin, preVerifyMFAWebAuthnForLogin);
1717
1559
  yield takeLeading(actions.verifyMFAWebAuthnForLogin, verifyMFAWebAuthnForLogin);
1718
1560
  }
1561
+
1719
1562
  /*********************************
1720
1563
  * Preview Sagas
1721
1564
  *********************************/
@@ -1728,7 +1571,6 @@ function* requestAuthorizeMock({
1728
1571
  isLoading: true
1729
1572
  }));
1730
1573
  }
1731
-
1732
1574
  const user = userDemo;
1733
1575
  yield put(actions.loadTenants());
1734
1576
  yield put(actions.setState({
@@ -1737,7 +1579,6 @@ function* requestAuthorizeMock({
1737
1579
  isLoading: false
1738
1580
  }));
1739
1581
  }
1740
-
1741
1582
  function* getUserIPMock({
1742
1583
  payload: {
1743
1584
  callback
@@ -1755,7 +1596,6 @@ function* getUserIPMock({
1755
1596
  callback == null ? void 0 : callback(false, e);
1756
1597
  }
1757
1598
  }
1758
-
1759
1599
  export function* loginSagasMock() {
1760
1600
  yield takeLeading(actions.requestAuthorize, requestAuthorizeMock);
1761
1601
  yield takeLeading(actions.afterAuthNavigation, afterAuthNavigation);