@frontegg/rest-api 3.1.74-alpha.9437937621 → 3.1.74

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 (122) hide show
  1. package/ContextHolder/index.d.ts +27 -108
  2. package/ContextHolder/index.js +50 -155
  3. package/account-settings/index.d.ts +7 -19
  4. package/account-settings/index.js +13 -23
  5. package/applications/index.d.ts +44 -49
  6. package/applications/index.js +37 -51
  7. package/audits/index.d.ts +15 -27
  8. package/audits/index.js +17 -27
  9. package/auth/index.d.ts +768 -817
  10. package/auth/index.js +721 -902
  11. package/auth/secutiry-poilicy/index.d.ts +102 -58
  12. package/auth/secutiry-poilicy/index.js +90 -122
  13. package/auth/utils.d.ts +2 -2
  14. package/auth/utils.js +8 -9
  15. package/connectivity/index.d.ts +26 -125
  16. package/connectivity/index.js +114 -147
  17. package/directory/index.d.ts +22 -31
  18. package/directory/index.js +15 -27
  19. package/entitlements/index.d.ts +8 -14
  20. package/entitlements/index.js +4 -12
  21. package/feature-flags/index.d.ts +2 -8
  22. package/feature-flags/index.js +8 -16
  23. package/fetch.d.ts +24 -0
  24. package/fetch.js +265 -0
  25. package/groups/index.d.ts +49 -73
  26. package/groups/index.js +45 -64
  27. package/impersonate/index.d.ts +6 -15
  28. package/impersonate/index.js +5 -13
  29. package/index.d.ts +108 -154
  30. package/index.js +78 -109
  31. package/interfaces.d.ts +0 -10
  32. package/metadata/index.d.ts +7 -67
  33. package/metadata/index.js +32 -52
  34. package/node/ContextHolder/index.js +50 -155
  35. package/node/account-settings/index.js +16 -27
  36. package/node/applications/index.js +44 -51
  37. package/node/audits/index.js +20 -31
  38. package/node/auth/index.js +1035 -768
  39. package/node/auth/secutiry-poilicy/index.js +136 -125
  40. package/node/auth/utils.js +7 -9
  41. package/node/connectivity/index.js +187 -148
  42. package/node/directory/index.js +20 -29
  43. package/node/entitlements/index.js +5 -18
  44. package/node/feature-flags/index.js +9 -21
  45. package/node/fetch.js +306 -0
  46. package/node/groups/index.js +63 -65
  47. package/node/impersonate/index.js +5 -18
  48. package/node/index.js +71 -116
  49. package/node/metadata/index.js +52 -61
  50. package/node/notifications/index.js +27 -37
  51. package/node/reports/index.js +70 -78
  52. package/node/roles/index.js +51 -56
  53. package/node/security-center/index.js +9 -21
  54. package/node/sub-tenants/index.js +89 -90
  55. package/node/subscriptions/index.js +107 -79
  56. package/node/subscriptions/invoices.js +17 -25
  57. package/node/subscriptions/managedSubscriptions.js +27 -32
  58. package/node/subscriptions/paymentMethods.js +20 -27
  59. package/node/subscriptions/paymentProviders.js +6 -15
  60. package/node/subscriptions/plans.js +9 -17
  61. package/node/subscriptions/providers/index.js +18 -0
  62. package/node/subscriptions/providers/stripe/index.js +21 -26
  63. package/node/subscriptions/subscriptions.js +27 -32
  64. package/node/subscriptions/summaries.js +6 -15
  65. package/node/subscriptions/tenantConfiguration.js +9 -17
  66. package/node/subscriptions/vendorPublicConfigurations.js +6 -15
  67. package/node/teams/index.js +138 -130
  68. package/node/tenants/index.js +60 -65
  69. package/node/user-phone-numbers/index.js +24 -32
  70. package/node/users/index.js +53 -58
  71. package/node/vendor/index.js +6 -17
  72. package/notifications/index.d.ts +16 -22
  73. package/notifications/index.js +22 -33
  74. package/package.json +1 -1
  75. package/reports/index.d.ts +44 -50
  76. package/reports/index.js +62 -75
  77. package/roles/index.d.ts +38 -44
  78. package/roles/index.js +41 -57
  79. package/security-center/index.d.ts +2 -14
  80. package/security-center/index.js +6 -15
  81. package/sub-tenants/index.d.ts +15 -57
  82. package/sub-tenants/index.js +68 -88
  83. package/subscriptions/index.d.ts +11 -56
  84. package/subscriptions/index.js +11 -68
  85. package/subscriptions/invoices.d.ts +13 -16
  86. package/subscriptions/invoices.js +14 -24
  87. package/subscriptions/managedSubscriptions.d.ts +15 -18
  88. package/subscriptions/managedSubscriptions.js +22 -33
  89. package/subscriptions/paymentMethods.d.ts +13 -16
  90. package/subscriptions/paymentMethods.js +17 -26
  91. package/subscriptions/paymentProviders.d.ts +5 -8
  92. package/subscriptions/paymentProviders.js +4 -11
  93. package/subscriptions/plans.d.ts +8 -11
  94. package/subscriptions/plans.js +6 -14
  95. package/subscriptions/providers/index.d.ts +1 -0
  96. package/subscriptions/providers/index.js +1 -0
  97. package/subscriptions/providers/stripe/index.d.ts +21 -24
  98. package/subscriptions/providers/stripe/index.js +16 -27
  99. package/subscriptions/subscriptions.d.ts +21 -24
  100. package/subscriptions/subscriptions.js +22 -33
  101. package/subscriptions/summaries.d.ts +4 -7
  102. package/subscriptions/summaries.js +3 -10
  103. package/subscriptions/tenantConfiguration.d.ts +3 -6
  104. package/subscriptions/tenantConfiguration.js +7 -15
  105. package/subscriptions/vendorPublicConfigurations.d.ts +2 -5
  106. package/subscriptions/vendorPublicConfigurations.js +4 -11
  107. package/teams/index.d.ts +131 -35
  108. package/teams/index.js +93 -122
  109. package/tenants/index.d.ts +37 -25
  110. package/tenants/index.js +46 -62
  111. package/user-phone-numbers/index.d.ts +26 -32
  112. package/user-phone-numbers/index.js +19 -32
  113. package/users/index.d.ts +15 -21
  114. package/users/index.js +44 -60
  115. package/vendor/index.d.ts +6 -12
  116. package/vendor/index.js +4 -11
  117. package/BaseApiClient.d.ts +0 -16
  118. package/BaseApiClient.js +0 -39
  119. package/FetchClient.d.ts +0 -42
  120. package/FetchClient.js +0 -308
  121. package/node/BaseApiClient.js +0 -49
  122. package/node/FetchClient.js +0 -326
package/auth/index.js CHANGED
@@ -3,947 +3,766 @@ import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  const _excluded = ["type"],
4
4
  _excluded2 = ["type"],
5
5
  _excluded3 = ["type"];
6
+ import { getTenants } from "../tenants";
6
7
  export * from "./secutiry-poilicy";
7
8
  export * from "./enums";
8
9
  export { FRONTEGG_SEPARATE_TABS_BY_TENANT } from "./constants";
9
10
  export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage, getCurrentUserTenantsFunction, removeTabTenantFromSessionStorage } from './utils';
10
11
  import { urls } from "../constants";
12
+ import { ContextHolder } from "../ContextHolder";
13
+ import { Delete, Get, Patch, Post, Put } from "../fetch";
11
14
  import { jwtDecode } from "../jwt";
12
15
  import { LOAD_AUTHORIZATION_FF } from './interfaces';
16
+ import { loadEntitlementsV2 } from '../entitlements';
13
17
  import { ADMIN_PORTAL_ENTITLEMENTS_FF } from '../entitlements/interfaces';
14
18
  import { FeatureFlags } from "../feature-flags";
15
19
  import { executeConditionalPromise, getCurrentUserTenantsFunction, getTabTenantFromSessionStorage, setTabTenantInSessionStorage } from "./utils";
16
- import { TenantsApi } from "../tenants";
17
- import { BaseApiClient } from '../BaseApiClient';
18
- import { EntitlementsApi } from '../entitlements';
19
- import { ContextHolder } from '../ContextHolder';
20
- import { SecurityPolicyApi } from './secutiry-poilicy';
21
- export class AuthenticationApi extends BaseApiClient {
22
- constructor(appName) {
23
- super(appName);
24
- this.tenantsApi = new TenantsApi(this.appName);
25
- this.entitlementsApi = new EntitlementsApi(this.appName);
26
- this.securityPolicy = new SecurityPolicyApi(this.appName);
27
-
28
- this.generateLoginResponse = async loginResponse => {
29
- if (!loginResponse.accessToken) {
30
- return loginResponse;
31
- }
32
-
33
- const contextHolder = ContextHolder.for(this.appName);
34
- contextHolder.setAccessToken(loginResponse.accessToken);
35
- const me = await this.getMeAndEntitlements();
36
- const decodedContent = loginResponse.accessToken ? jwtDecode(loginResponse.accessToken) : {};
37
-
38
- const user = _extends({}, loginResponse, decodedContent, me);
39
-
40
- contextHolder.setUser(user);
41
- return user;
42
- };
43
-
44
- this.generateLoginResponseV2 = async loginResponse => {
45
- if (!loginResponse.accessToken) {
46
- return {
47
- user: loginResponse
48
- };
49
- }
50
-
51
- const contextHolder = ContextHolder.for(this.appName);
52
- contextHolder.setAccessToken(loginResponse.accessToken);
53
- const [me, tenants] = await Promise.all([this.getMeAndEntitlements(), this.tenantsApi.getTenants()]);
54
- const decodedContent = loginResponse.accessToken ? jwtDecode(loginResponse.accessToken) : {};
55
-
56
- const user = _extends({}, loginResponse, decodedContent, me);
57
-
58
- contextHolder.setUser(user);
59
- return {
60
- user,
61
- tenants
62
- };
63
- };
64
-
65
- this.generateLoginResponseV3 = async loginResponse => {
66
- const {
67
- accessToken
68
- } = loginResponse;
69
-
70
- if (!accessToken) {
71
- return {
72
- user: loginResponse
73
- };
74
- }
75
-
76
- const contextHolder = ContextHolder.for(this.appName);
77
- contextHolder.setAccessToken(accessToken);
78
- const [me, currentUserTenants] = await Promise.all([this.getMeAndEntitlements(), getCurrentUserTenantsFunction(this.appName)()]);
79
- const decodedContent = accessToken ? jwtDecode(accessToken) : {};
80
-
81
- const user = _extends({}, loginResponse, decodedContent, me);
82
-
83
- if (contextHolder.isSessionPerTenantEnabled()) {
84
- setTabTenantInSessionStorage(user.tenantId);
85
- }
86
-
87
- contextHolder.setUser(user);
88
- return {
89
- user,
90
- tenants: currentUserTenants.tenants,
91
- activeTenant: currentUserTenants.activeTenant
92
- };
93
- };
94
-
95
- this.generateLoginResponseFromOAuthResponse = async oauthResponse => {
96
- const contextHolder = ContextHolder.for(this.appName);
97
- contextHolder.setAccessToken(oauthResponse.id_token);
98
- const me = await this.getMeAndEntitlements();
99
- const decodedContent = oauthResponse.id_token ? jwtDecode(oauthResponse.id_token) : {};
100
-
101
- const user = _extends({
102
- mfaRequired: false,
103
- accessToken: oauthResponse.id_token,
104
- refreshToken: oauthResponse.refresh_token
105
- }, decodedContent, me, {
106
- expiresIn: oauthResponse.expires_in || 300
107
- });
108
-
109
- contextHolder.setUser(user);
110
- return user;
111
- };
112
-
113
- this.generateLoginResponseFromOAuthResponseV2 = async oauthResponse => {
114
- const contextHolder = ContextHolder.for(this.appName);
115
- contextHolder.setAccessToken(oauthResponse.id_token);
116
- const [me, currentUserTenants] = await Promise.all([this.getMeAndEntitlements(), getCurrentUserTenantsFunction(this.appName)()]);
117
- const decodedContent = oauthResponse.id_token ? jwtDecode(oauthResponse.id_token) : {};
118
-
119
- const user = _extends({
120
- mfaRequired: false,
121
- accessToken: oauthResponse.id_token,
122
- refreshToken: oauthResponse.refresh_token
123
- }, decodedContent, me, {
124
- expiresIn: oauthResponse.expires_in || 300
125
- });
126
-
127
- if (contextHolder.isSessionPerTenantEnabled()) {
128
- setTabTenantInSessionStorage(user.tenantId);
129
- }
130
-
131
- contextHolder.setUser(user);
132
- return {
133
- user,
134
- tenants: currentUserTenants.tenants,
135
- activeTenant: currentUserTenants.activeTenant
136
- };
137
- };
138
-
139
- this.preLogin = async body => {
140
- try {
141
- const {
142
- address
143
- } = await this.post(`${urls.identity.auth.v1}/user/saml/prelogin`, body);
144
- return address;
145
- } catch {
146
- return null;
147
- }
148
- };
149
-
150
- this.preLoginWithIdpType = async body => {
151
- return this.post(`${urls.identity.auth.v1}/user/saml/prelogin`, body);
152
- };
153
-
154
- this.postLogin = async body => {
155
- const data = await this.post(`${urls.identity.auth.v1}/user/saml/postlogin`, body);
156
- return this.generateLoginResponse(data);
157
- };
158
-
159
- this.oidcPostLogin = async body => {
160
- const data = await this.post(`${urls.identity.auth.v1}/user/oidc/postlogin`, body);
161
- return this.generateLoginResponse(data);
162
- };
163
-
164
- this.login = async body => {
165
- const data = await this.post(`${urls.identity.auth.v1}/user`, body);
166
- return this.generateLoginResponse(data);
167
- };
168
-
169
- this.loginv2 = async body => {
170
- const data = await this.post(`${urls.identity.auth.v1}/user`, body);
171
- return this.generateLoginResponseV3(data);
172
- };
173
-
174
- this.loginWithMfa = async body => {
175
- const data = await this.post(`${urls.identity.auth.v1}/user/mfa/verify`, body);
176
- return this.generateLoginResponse(data);
177
- };
178
-
179
- this.loginWithMfaV2 = async body => {
180
- const data = await this.post(`${urls.identity.auth.v1}/user/mfa/verify`, body);
181
- return this.generateLoginResponseV3(data);
182
- };
183
-
184
- this.activateAccount = async body => {
185
- return this.post(`${urls.identity.users.v1}/activate`, body);
186
- };
187
-
188
- this.activateAccountV2 = async body => {
189
- const data = await this.post(`${urls.identity.users.v1}/activate`, body);
190
- return this.generateLoginResponseV3(data);
191
- };
192
-
193
- this.getActivateAccountStrategy = async params => {
194
- return this.get(`${urls.identity.users.v1}/activate/strategy`, params);
195
- };
196
-
197
- this.resendActivationEmail = async body => {
198
- return this.post(`${urls.identity.users.v1}/activate/reset`, body);
199
- };
200
-
201
- this.resendInvitationEmail = async body => {
202
- return this.post(`${urls.identity.users.v1}/invitation/reset`, body);
203
- };
204
-
205
- this.acceptInvitation = async body => {
206
- return this.post(`${urls.identity.users.v1}/invitation/accept`, body);
207
- };
208
-
209
- this.refreshToken = async () => {
210
- const tabTenantId = getTabTenantFromSessionStorage(this.appName);
211
- const data = await this.post(`${urls.identity.auth.v1}/user/token/refresh`, {
212
- tenantId: tabTenantId
213
- });
214
- return this.generateLoginResponse(data);
215
- };
216
-
217
- this.refreshTokenV2 = async () => {
218
- const tabTenantId = getTabTenantFromSessionStorage(this.appName);
219
- const data = await this.post(`${urls.identity.auth.v1}/user/token/refresh`, {
220
- tenantId: tabTenantId
221
- });
222
- return this.generateLoginResponseV2(data);
223
- };
224
-
225
- this.refreshTokenV3 = async () => {
226
- const tabTenantId = getTabTenantFromSessionStorage(this.appName);
227
- const data = await this.post(`${urls.identity.auth.v1}/user/token/refresh`, {
228
- tenantId: tabTenantId
229
- });
230
- return this.generateLoginResponseV3(data);
231
- };
232
-
233
- this.logout = async () => {
234
- return this.post(`${urls.identity.auth.v1}/logout`);
235
- };
236
-
237
- this.OAuthLogout = async params => {
238
- return this.get(`${urls.oauth.v1}/logout`, params);
239
- };
240
-
241
- this.forgotPassword = async body => {
242
- return this.post(`${urls.identity.users.v1}/passwords/reset`, body);
243
- };
244
-
245
- this.resetPassword = async body => {
246
- return this.post(`${urls.identity.users.v1}/passwords/reset/verify`, body);
247
- };
248
-
249
- this.loadPasswordConfig = async params => {
250
- return this.get(`${urls.identity.users.v1}/passwords/config`, params);
251
- };
252
-
253
- this.recoverMfaToken = async body => {
254
- return this.post(`${urls.identity.auth.v1}/user/mfa/recover`, body);
255
- };
256
-
257
- this.enrollMfa = async () => {
258
- return this.post(`${urls.identity.users.v1}/mfa/enroll`);
259
- };
260
-
261
- this.preEnrollMFAAuthenticatorApp = async () => {
262
- return this.post(`${urls.identity.users.v1}/mfa/authenticator/enroll`);
263
- };
264
-
265
- this.enrollMFAAuthenticatorApp = async body => {
266
- return this.post(`${urls.identity.users.v1}/mfa/authenticator/enroll/verify`, body);
267
- };
268
-
269
- this.preEnrollMFASMS = async body => {
270
- return this.post(`${urls.identity.users.v1}/mfa/sms/enroll`, body);
271
- };
272
-
273
- this.enrollMFASMS = async body => {
274
- return this.post(`${urls.identity.users.v1}/mfa/sms/enroll/verify`, body);
275
- };
276
-
277
- this.preEnrollMFAWebAuthn = async () => {
278
- return this.post(`${urls.identity.users.v1}/mfa/webauthn/enroll`);
279
- };
280
-
281
- this.enrollMFAWebAuthn = async body => {
282
- return this.post(`${urls.identity.users.v1}/mfa/webauthn/enroll/verify`, body);
283
- };
284
-
285
- this.verifyMfa = async body => {
286
- return this.post(`${urls.identity.users.v1}/mfa/enroll/verify`, body);
287
- };
288
-
289
- this.disableMfa = async body => {
290
- return this.post(`${urls.identity.users.v1}/mfa/disable`, body);
291
- };
292
-
293
- this.disableMFAAuthenticatorApp = async (deviceId, body) => {
294
- return this.post(`${urls.identity.users.v1}/mfa/authenticator/${deviceId}/disable/verify`, body);
295
- };
296
-
297
- this.preDisableMFASMS = async deviceId => {
298
- return this.post(`${urls.identity.users.v1}/mfa/sms/${deviceId}/disable`);
299
- };
300
-
301
- this.disableMFASMS = async (deviceId, body) => {
302
- return this.post(`${urls.identity.users.v1}/mfa/sms/${deviceId}/disable/verify`, body);
303
- };
304
-
305
- this.preDisableMFAWebAuthn = async deviceId => {
306
- return this.post(`${urls.identity.users.v1}/mfa/webauthn/${deviceId}/disable`);
307
- };
308
-
309
- this.disableMFAWebAuthn = async (deviceId, body) => {
310
- return this.post(`${urls.identity.users.v1}/mfa/webauthn/${deviceId}/disable/verify`, body);
311
- };
312
-
313
- this.getMFADevices = async () => {
314
- return this.get(`${urls.identity.users.v1}/mfa/devices`);
315
- };
316
-
317
- this.preEnrollMFAAuthenticatorAppForLogin = async body => {
318
- return this.post(`${urls.identity.auth.v1}/user/mfa/authenticator/enroll`, body);
319
- };
320
-
321
- this.enrollMFAAuthenticatorAppForLogin = async body => {
322
- return this.post(`${urls.identity.auth.v1}/user/mfa/authenticator/enroll/verify`, body);
323
- };
324
-
325
- this.enrollMFAAuthenticatorAppForLoginV2 = async body => {
326
- const data = await this.post(`${urls.identity.auth.v1}/user/mfa/authenticator/enroll/verify`, body);
327
- return this.generateLoginResponseV3(data);
328
- };
329
-
330
- this.verifyMFAAuthenticatorAppForLogin = async (deviceId, body) => {
331
- return this.post(`${urls.identity.auth.v1}/user/mfa/authenticator/${deviceId}/verify`, body);
332
- };
333
-
334
- this.preVerifyMFAEmailCode = async body => {
335
- return this.post(`${urls.identity.auth.v1}/user/mfa/emailcode`, body);
336
- };
337
-
338
- this.verifyMFAEmailCode = async body => {
339
- return this.post(`${urls.identity.auth.v1}/user/mfa/emailcode/verify`, body);
340
- };
341
-
342
- this.verifyMFAEmailCodeV2 = async body => {
343
- const data = await this.post(`${urls.identity.auth.v1}/user/mfa/emailcode/verify`, body);
344
- return this.generateLoginResponseV3(data);
345
- };
346
-
347
- this.preEnrollMFASMSForLogin = async body => {
348
- return this.post(`${urls.identity.auth.v1}/user/mfa/sms/enroll`, body);
349
- };
350
-
351
- this.enrollMFASMSForLogin = async body => {
352
- return this.post(`${urls.identity.auth.v1}/user/mfa/sms/enroll/verify`, body);
353
- };
354
-
355
- this.enrollMFASMSForLoginV2 = async body => {
356
- const data = await this.post(`${urls.identity.auth.v1}/user/mfa/sms/enroll/verify`, body);
357
- return this.generateLoginResponseV3(data);
358
- };
359
-
360
- this.preVerifyMFASMSForLogin = async (deviceId, body) => {
361
- return this.post(`${urls.identity.auth.v1}/user/mfa/sms/${deviceId}`, body);
362
- };
363
-
364
- this.verifyMFASMSForLogin = async (deviceId, body) => {
365
- return this.post(`${urls.identity.auth.v1}/user/mfa/sms/${deviceId}/verify`, body);
366
- };
367
-
368
- this.verifyMFASMSForLoginV2 = async (deviceId, body) => {
369
- const data = await this.post(`${urls.identity.auth.v1}/user/mfa/sms/${deviceId}/verify`, body);
370
- return this.generateLoginResponseV3(data);
371
- };
372
-
373
- this.preEnrollMFAWebAuthnForLogin = async body => {
374
- return this.post(`${urls.identity.auth.v1}/user/mfa/webauthn/enroll`, body);
375
- };
376
-
377
- this.enrollMFAWebAuthnForLogin = async body => {
378
- return this.post(`${urls.identity.auth.v1}/user/mfa/webauthn/enroll/verify`, body);
379
- };
380
-
381
- this.enrollMFAWebAuthnForLoginV2 = async body => {
382
- const data = await this.post(`${urls.identity.auth.v1}/user/mfa/webauthn/enroll/verify`, body);
383
- return this.generateLoginResponseV3(data);
384
- };
385
-
386
- this.preVerifyMFAWebAuthnForLogin = async (deviceId, body) => {
387
- return this.post(`${urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}`, body);
388
- };
389
-
390
- this.verifyMFAWebAuthnForLogin = async (deviceId, body) => {
391
- return this.post(`${urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}/verify`, body);
392
- };
393
-
394
- this.verifyMFAWebAuthnForLoginV2 = async (deviceId, body) => {
395
- const data = await this.post(`${urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}/verify`, body);
396
- return this.generateLoginResponseV3(data);
397
- };
398
-
399
- this.getSamlConfiguration = async () => {
400
- return this.get(`${urls.team.sso.v1}/saml/configurations`);
401
- };
402
-
403
- this.updateSamlConfiguration = async body => {
404
- return this.post(`${urls.team.sso.v1}/saml/configurations`, body);
405
- };
406
-
407
- this.getSamlVendorConfiguration = async () => {
408
- return this.get(`${urls.team.sso.v1}/saml/configurations/vendor-config`);
409
- };
410
-
411
- this.updateSamlVendorMetadata = async body => {
412
- return this.put(`${urls.team.sso.v1}/saml/configurations/metadata`, body);
413
- };
414
-
415
- this.validateSamlDomain = async () => {
416
- return this.put(`${urls.team.sso.v1}/saml/validations/domain`);
417
- };
418
-
419
- this.getSamlRoles = async () => {
420
- return this.get(`${urls.team.sso.v1}/saml/configurations/roles/default`);
421
- };
422
-
423
- this.getSamlRolesGroups = async () => {
424
- return this.get(`${urls.team.sso.v2}/saml/configurations/groups`);
425
- };
426
-
427
- this.updateSamlRoles = async ({
428
- roleIds
429
- }) => {
430
- return this.post(`${urls.team.sso.v1}/saml/configurations/roles/default`, {
431
- roleIds
432
- });
433
- };
434
-
435
- this.createSamlGroup = async ({
436
- roleIds,
437
- group
438
- }) => {
439
- return this.post(`${urls.team.sso.v2}/saml/configurations/groups`, {
440
- group,
441
- roleIds
442
- });
443
- };
444
-
445
- this.updateSamlGroup = async ({
446
- roleIds,
447
- group,
448
- id
449
- }) => {
450
- return this.patch(`${urls.team.sso.v2}/saml/configurations/groups/${id}`, {
451
- group,
452
- roleIds
453
- });
454
- };
455
-
456
- this.deleteSamlGroup = async ({
457
- id
458
- }) => {
459
- return this.delete(`${urls.team.sso.v2}/saml/configurations/groups/${id}`);
460
- };
461
-
462
- this.getOidcConfiguration = async () => {
463
- return this.get(`${urls.team.sso.v1}/oidc/configurations`);
464
- };
465
-
466
- this.getSSOPublicConfiguration = async () => {
467
- return this.get(`${urls.team.sso.v2}/configurations/public`);
468
- };
469
-
470
- this.getSocialLoginProviders = async () => {
471
- return this.get(urls.identity.sso.v1);
472
- };
473
-
474
- this.getSocialLoginProvidersV2 = async () => {
475
- return this.get(urls.identity.sso.v2);
476
- };
477
-
478
- this.getSocialLoginProvidersV2ForAuthenticatedUser = async () => {
479
- return this.get(`${urls.identity.sso.v2}/authenticated`);
480
- };
481
-
482
- this.getCustomSocialLoginProvidersV1 = async () => {
483
- return this.get(urls.identity.sso.custom.v1);
484
- };
485
-
486
- this.loginViaSocialLogin = async params => {
487
- const queryParams = {};
488
-
489
- if (params.code) {
490
- queryParams.code = params.code;
491
- }
492
-
493
- if (params.idToken) {
494
- queryParams.id_token = params.idToken;
495
- }
496
-
497
- if (params.redirectUri) {
498
- queryParams.redirectUri = params.redirectUri;
499
- }
500
-
501
- if (params.codeVerifier) {
502
- queryParams.code_verifier = params.codeVerifier;
503
- }
504
-
505
- if (params.state) {
506
- queryParams.state = params.state;
507
- }
508
-
509
- return this.post(`${urls.identity.auth.v1}/user/sso/${params.provider}/postlogin`, {
510
- metadata: params.metadata,
511
- invitationToken: params.invitationToken
512
- }, {
513
- params: queryParams
514
- });
515
- };
516
-
517
- this.getVendorConfig = async () => {
518
- return this.get(`${urls.identity.configurations.v1}/public`);
519
- };
520
-
521
- this.signUpUser = async body => {
522
- const {
523
- shouldActivate,
524
- authResponse,
525
- userId,
526
- tenantId
527
- } = await this.post(`${urls.identity.users.v1}/signUp`, body);
528
- const response = {
529
- shouldActivate,
530
- userId,
531
- tenantId
532
- };
533
-
534
- if (!shouldActivate && authResponse) {
535
- const {
536
- user,
537
- tenants,
538
- activeTenant
539
- } = await this.generateLoginResponseV3(authResponse);
540
- return _extends({}, response, {
541
- user,
542
- tenants,
543
- activeTenant
544
- });
545
- }
546
-
547
- return response;
548
- };
549
-
550
- this.getCurrentUserSessions = async () => {
551
- return this.get(urls.identity.users.sessions.currentUser.v1);
552
- };
553
-
554
- this.getCurrentUserSession = async () => {
555
- return this.get(`${urls.identity.users.sessions.currentUser.v1}/current`);
556
- };
557
-
558
- this.revokeSessionsForUser = async userId => {
559
- return this.post(`${urls.identity.users.sessions.v1}/revoke`, {
560
- userId
561
- });
562
- };
563
-
564
- this.getSessionConfigurations = async () => {
565
- return this.get(urls.identity.users.sessions.configurations.v1);
566
- };
567
-
568
- this.createOrUpdateSessionConfigrations = async body => {
569
- await this.post(urls.identity.users.sessions.configurations.v1, body);
570
- };
571
-
572
- this.deleteSessionForUser = async id => {
573
- await this.delete(`${urls.identity.users.sessions.currentUser.v1}/${id}`);
574
- };
575
-
576
- this.deleteAllSessionsForUser = async () => {
577
- await this.delete(`${urls.identity.users.sessions.currentUser.v1}/all`);
578
- };
579
-
580
- this.getUserAccessTokensData = async () => {
581
- return this.get(urls.identity.users.accessTokens.v1);
582
- };
583
-
584
- this.getTenantAccessTokensData = async () => {
585
- return this.get(urls.identity.tenants.accessTokens.v1);
586
- };
587
-
588
- this.deleteTenantAccessToken = async ({
589
- id
590
- }) => {
591
- await this.delete(`${urls.identity.tenants.accessTokens.v1}/${id}`);
592
- };
593
-
594
- this.deleteUserAccessToken = async ({
595
- id
596
- }) => {
597
- await this.delete(`${urls.identity.users.accessTokens.v1}/${id}`);
598
- };
599
-
600
- this.createUserAccessToken = async body => {
601
- return this.post(urls.identity.users.accessTokens.v1, body);
602
- };
603
-
604
- this.createTenantAccessToken = async body => {
605
- return this.post(urls.identity.tenants.accessTokens.v1, body);
606
- };
607
-
608
- this.getUserApiTokensData = async () => {
609
- return this.get(urls.identity.users.apiTokens.v1);
610
- };
611
-
612
- this.getTenantApiTokensData = async () => {
613
- return this.get(urls.identity.tenants.apiTokens.v1);
614
- };
615
-
616
- this.updateUserApiTokensData = async body => {
617
- return this.post(urls.identity.users.apiTokens.v1, body);
618
- };
619
-
620
- this.updateTenantApiTokensData = async body => {
621
- return this.post(urls.identity.tenants.apiTokens.v2, body);
622
- };
623
-
624
- this.deleteTenantApiToken = async ({
625
- tokenId
626
- }) => {
627
- await this.delete(`${urls.identity.tenants.apiTokens.v1}/${tokenId}`);
628
- };
629
-
630
- this.deleteUserApiToken = async ({
631
- tokenId
632
- }) => {
633
- await this.delete(`${urls.identity.users.apiTokens.v1}/${tokenId}`);
634
- };
635
-
636
- this.getUserById = async ({
637
- userId
638
- }) => {
639
- return this.get(`${urls.identity.users.v1}/${userId}`);
640
- };
641
-
642
- this.checkIfAllowToRememberMfaDevice = async mfaToken => {
643
- return this.get(`${urls.identity.configurations.v1}/mfa-policy/allow-remember-device`, {
644
- mfaToken
645
- });
646
- };
647
-
648
- this.passwordlessPreLogin = async _ref => {
649
- let {
650
- type
651
- } = _ref,
652
- body = _objectWithoutPropertiesLoose(_ref, _excluded);
653
-
654
- return this.post(`${urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/prelogin`, body);
655
- };
656
-
657
- this.passwordlessPostLoginV2 = async _ref2 => {
658
- let {
659
- type
660
- } = _ref2,
661
- body = _objectWithoutPropertiesLoose(_ref2, _excluded2);
662
-
663
- const data = await this.post(`${urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/postlogin`, body);
664
- return this.generateLoginResponseV3(data);
665
- };
666
-
667
- this.passwordlessPostLogin = async _ref3 => {
668
- let {
669
- type
670
- } = _ref3,
671
- body = _objectWithoutPropertiesLoose(_ref3, _excluded3);
672
-
673
- return this.post(`${urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/postlogin`, body);
674
- };
675
-
676
- this.verifyInviteToken = async ({
677
- token
678
- }) => {
679
- return this.post(urls.identity.tenants.invites.verify.v1, {
680
- token
681
- });
682
- };
683
-
684
- this.getSSOConfigurations = async () => {
685
- return this.get(`${urls.team.sso.v1}/configurations`);
686
- };
687
-
688
- this.createSSOConfiguration = async body => {
689
- return this.post(`${urls.team.sso.v1}/configurations`, body);
690
- };
691
-
692
- this.updateSSOConfiguration = async (ssoConfigId, body) => {
693
- return this.patch(`${urls.team.sso.v1}/configurations/${ssoConfigId}`, body);
694
- };
695
-
696
- this.deleteSSOConfiguration = async ssoConfigId => {
697
- await this.delete(`${urls.team.sso.v1}/configurations/${ssoConfigId}`);
698
- };
699
-
700
- this.createSSOConfigurationByMetadata = async body => {
701
- return this.post(`${urls.team.sso.v1}/configurations/metadata`, body);
702
- };
703
-
704
- this.updateSSOConfigurationByMetadata = async (ssoConfigId, body) => {
705
- return this.put(`${urls.team.sso.v1}/configurations/${ssoConfigId}/metadata`, body);
706
- };
707
-
708
- this.createSSOConfigurationByMetadataUrl = async body => {
709
- return this.post(`${urls.team.sso.v1}/configurations/metadata-url`, body);
710
- };
711
-
712
- this.updateSSOConfigurationByMetadataUrl = async (ssoConfigId, body) => {
713
- return this.put(`${urls.team.sso.v1}/configurations/${ssoConfigId}/metadata-url`, body);
714
- };
715
-
716
- this.createSSODomain = async (ssoConfigId, body) => {
717
- return this.post(`${urls.team.sso.v1}/configurations/${ssoConfigId}/domains`, body);
718
- };
719
-
720
- this.deleteSSODomain = async (ssoConfigId, domainId) => {
721
- return this.delete(`${urls.team.sso.v1}/configurations/${ssoConfigId}/domains/${domainId}`);
722
- };
723
-
724
- this.validateSSODomain = async (ssoConfigId, domainId) => {
725
- return this.put(`${urls.team.sso.v1}/configurations/${ssoConfigId}/domains/${domainId}/validate`);
726
- };
727
-
728
- this.validateSSODomainV2 = async (ssoConfigId, domainId) => {
729
- return this.put(`${urls.team.sso.v2}/configurations/${ssoConfigId}/domains/${domainId}/validate`);
730
- };
731
-
732
- this.getSSODefaultRoles = async ssoConfigId => {
733
- return this.get(`${urls.team.sso.v1}/configurations/${ssoConfigId}/roles`);
734
- };
735
-
736
- this.setSSODefaultRoles = async (ssoConfigId, body) => {
737
- return this.put(`${urls.team.sso.v1}/configurations/${ssoConfigId}/roles`, body);
738
- };
739
-
740
- this.createSSOGroup = async (ssoConfigId, body) => {
741
- return this.post(`${urls.team.sso.v1}/configurations/${ssoConfigId}/groups`, body);
742
- };
743
-
744
- this.updateSSOGroup = async (ssoConfigId, {
745
- roleIds,
746
- group,
747
- id
748
- }) => {
749
- return this.patch(`${urls.team.sso.v1}/configurations/${ssoConfigId}/groups/${id}`, {
750
- group,
751
- roleIds
752
- });
753
- };
754
-
755
- this.deleteSSOGroup = async (ssoConfigId, groupId) => {
756
- return this.delete(`${urls.team.sso.v1}/configurations/${ssoConfigId}/groups/${groupId}`);
757
- };
758
-
759
- this.getSSOGroups = async ssoConfigId => {
760
- return this.get(`${urls.team.sso.v1}/configurations/${ssoConfigId}/groups`);
761
- };
762
-
763
- this.preLoginV2 = async body => {
764
- return this.post(`${urls.identity.auth.v2}/user/sso/prelogin`, body);
765
- };
766
-
767
- this.oidcPostLoginV2 = async body => {
768
- const data = await this.post(`${urls.identity.auth.v2}/user/oidc/postlogin`, body);
769
- return this.generateLoginResponse(data);
770
- };
771
-
772
- this.exchangeOAuthTokensV2 = async body => {
773
- const data = await this.post(`${urls.oauth.v1}/token`, body);
774
- return this.generateLoginResponseFromOAuthResponseV2(data);
775
- };
20
+ export async function generateLoginResponse(loginResponse) {
21
+ if (!loginResponse.accessToken) {
22
+ return loginResponse;
23
+ }
776
24
 
777
- this.silentOAuthRefreshTokenV2 = async () => {
778
- const tabTenantId = getTabTenantFromSessionStorage(this.appName);
779
- const data = await this.post(`${urls.oauth.v1}/authorize/silent`, {
780
- tenantId: tabTenantId
781
- });
782
- return this.generateLoginResponseFromOAuthResponseV2(data);
783
- };
25
+ ContextHolder.setAccessToken(loginResponse.accessToken);
26
+ const me = await getMeAndEntitlements();
27
+ const decodedContent = loginResponse.accessToken ? jwtDecode(loginResponse.accessToken) : {};
784
28
 
785
- this.exchangeOAuthTokens = async body => {
786
- const data = await this.post(`${urls.oauth.v1}/token`, body);
787
- return this.generateLoginResponseFromOAuthResponse(data);
788
- };
29
+ const user = _extends({}, loginResponse, decodedContent, me);
789
30
 
790
- this.silentOAuthRefreshToken = async () => {
791
- const tabTenantId = getTabTenantFromSessionStorage(this.appName);
792
- const data = await this.post(`${urls.oauth.v1}/authorize/silent`, {
793
- tenantId: tabTenantId
794
- });
795
- return this.generateLoginResponseFromOAuthResponse(data);
31
+ ContextHolder.setUser(user);
32
+ return user;
33
+ }
34
+ export async function generateLoginResponseV2(loginResponse) {
35
+ if (!loginResponse.accessToken) {
36
+ return {
37
+ user: loginResponse
796
38
  };
39
+ }
797
40
 
798
- this.resetPhoneNumber = async body => {
799
- return this.post(`${urls.identity.users.v1}/phone/reset`, body);
800
- };
41
+ ContextHolder.setAccessToken(loginResponse.accessToken);
42
+ const [me, tenants] = await Promise.all([getMeAndEntitlements(), getTenants()]);
43
+ const decodedContent = loginResponse.accessToken ? jwtDecode(loginResponse.accessToken) : {};
801
44
 
802
- this.verifyResetPhoneNumber = async body => {
803
- return this.post(`${urls.identity.users.v1}/phone/reset/verify`, body);
804
- };
45
+ const user = _extends({}, loginResponse, decodedContent, me);
805
46
 
806
- this.changePhoneNumberWithVerification = async body => {
807
- return this.post(`${urls.identity.users.v1}/phone`, body);
808
- };
47
+ ContextHolder.setUser(user);
48
+ return {
49
+ user,
50
+ tenants
51
+ };
52
+ }
809
53
 
810
- this.verifyChangePhoneNumber = async body => {
811
- return this.post(`${urls.identity.users.v1}/phone/verify`, body);
812
- };
54
+ function shouldLoadEntitlements() {
55
+ if (!ContextHolder.shouldLoadEntitlements()) {
56
+ return false;
57
+ }
813
58
 
814
- this.changePhoneNumber = async body => {
815
- return this.put(`${urls.identity.users.v1}/phone/change`, body);
816
- };
59
+ const [isEntitlementsFFOn] = FeatureFlags.getFeatureFlags([ADMIN_PORTAL_ENTITLEMENTS_FF], ContextHolder.getAppName() || '');
60
+ return isEntitlementsFFOn;
61
+ }
817
62
 
818
- this.webAuthnPreLogin = async body => {
819
- return this.post(`${urls.identity.auth.v1}/webauthn/prelogin`, body);
820
- };
63
+ function shouldLoadMeAuthorization() {
64
+ const [shouldLoadAuthorization] = FeatureFlags.getFeatureFlags([LOAD_AUTHORIZATION_FF], ContextHolder.getAppName() || '');
65
+ return shouldLoadAuthorization;
66
+ }
821
67
 
822
- this.webAuthnPostLogin = async body => {
823
- return this.post(`${urls.identity.auth.v1}/webauthn/postlogin`, body);
824
- };
68
+ export async function generateLoginResponseV3(loginResponse) {
69
+ const {
70
+ accessToken
71
+ } = loginResponse;
825
72
 
826
- this.webAuthnPostLoginV2 = async body => {
827
- const data = await this.post(`${urls.identity.auth.v1}/webauthn/postlogin`, body);
828
- return this.generateLoginResponseV3(data);
73
+ if (!accessToken) {
74
+ return {
75
+ user: loginResponse
829
76
  };
77
+ }
830
78
 
831
- this.webAuthnCreateNewDeviceSession = async () => {
832
- return this.post(urls.identity.webAuthnDevices.v1);
833
- };
79
+ ContextHolder.setAccessToken(accessToken);
80
+ const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), getCurrentUserTenantsFunction()()]);
81
+ const decodedContent = accessToken ? jwtDecode(accessToken) : {};
834
82
 
835
- this.getWebAuthnDevices = async () => {
836
- return this.get(urls.identity.webAuthnDevices.v1);
837
- };
83
+ const user = _extends({}, loginResponse, decodedContent, me);
838
84
 
839
- this.deleteWebAuthnDevice = async deviceId => {
840
- return this.delete(`${urls.identity.webAuthnDevices.v1}/${deviceId}`);
841
- };
842
-
843
- this.verifyNewDeviceSession = async body => {
844
- return this.post(`${urls.identity.webAuthnDevices.v1}/verify`, body);
845
- };
85
+ if (ContextHolder.isSessionPerTenantEnabled()) {
86
+ setTabTenantInSessionStorage(user.tenantId);
87
+ }
846
88
 
847
- this.getVendorPublicAuthStrategiesConfig = async () => {
848
- return this.get(`${urls.identity.configurations.v1}/auth/strategies/public`);
849
- };
89
+ ContextHolder.setUser(user);
90
+ return {
91
+ user,
92
+ tenants: currentUserTenants.tenants,
93
+ activeTenant: currentUserTenants.activeTenant
94
+ };
95
+ }
96
+ export async function generateLoginResponseFromOAuthResponse(oauthResponse) {
97
+ ContextHolder.setAccessToken(oauthResponse.id_token);
98
+ const me = await getMeAndEntitlements();
99
+ const decodedContent = oauthResponse.id_token ? jwtDecode(oauthResponse.id_token) : {};
100
+
101
+ const user = _extends({
102
+ mfaRequired: false,
103
+ accessToken: oauthResponse.id_token,
104
+ refreshToken: oauthResponse.refresh_token
105
+ }, decodedContent, me, {
106
+ expiresIn: oauthResponse.expires_in || 300
107
+ });
108
+
109
+ ContextHolder.setUser(user);
110
+ return user;
111
+ }
112
+ export async function generateLoginResponseFromOAuthResponseV2(oauthResponse) {
113
+ ContextHolder.setAccessToken(oauthResponse.id_token);
114
+ const [me, currentUserTenants] = await Promise.all([getMeAndEntitlements(), getCurrentUserTenantsFunction()()]);
115
+ const decodedContent = oauthResponse.id_token ? jwtDecode(oauthResponse.id_token) : {};
116
+
117
+ const user = _extends({
118
+ mfaRequired: false,
119
+ accessToken: oauthResponse.id_token,
120
+ refreshToken: oauthResponse.refresh_token
121
+ }, decodedContent, me, {
122
+ expiresIn: oauthResponse.expires_in || 300
123
+ });
124
+
125
+ if (ContextHolder.isSessionPerTenantEnabled()) {
126
+ setTabTenantInSessionStorage(user.tenantId);
127
+ }
850
128
 
851
- this.getPublicAuthStrategiesConfigForAuthenticatedUser = async () => {
852
- return this.get(`${urls.identity.configurations.v1}/auth/strategies`);
853
- };
129
+ ContextHolder.setUser(user);
130
+ return {
131
+ user,
132
+ tenants: currentUserTenants.tenants,
133
+ activeTenant: currentUserTenants.activeTenant
134
+ };
135
+ }
136
+ export async function preLogin(body) {
137
+ try {
138
+ const {
139
+ address
140
+ } = await Post(`${urls.identity.auth.v1}/user/saml/prelogin`, body);
141
+ return address;
142
+ } catch {
143
+ return null;
144
+ }
145
+ }
146
+ export async function preLoginWithIdpType(body) {
147
+ return Post(`${urls.identity.auth.v1}/user/saml/prelogin`, body);
148
+ }
149
+ export async function postLogin(body) {
150
+ const data = await Post(`${urls.identity.auth.v1}/user/saml/postlogin`, body);
151
+ return generateLoginResponse(data);
152
+ }
153
+ export async function oidcPostLogin(body) {
154
+ const data = await Post(`${urls.identity.auth.v1}/user/oidc/postlogin`, body);
155
+ return generateLoginResponse(data);
156
+ }
157
+ export async function login(body) {
158
+ const data = await Post(`${urls.identity.auth.v1}/user`, body);
159
+ return generateLoginResponse(data);
160
+ }
161
+ export async function loginv2(body) {
162
+ const data = await Post(`${urls.identity.auth.v1}/user`, body);
163
+ return generateLoginResponseV3(data);
164
+ }
165
+ export async function loginWithMfa(body) {
166
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/verify`, body);
167
+ return generateLoginResponse(data);
168
+ }
169
+ export async function loginWithMfaV2(body) {
170
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/verify`, body);
171
+ return generateLoginResponseV3(data);
172
+ }
173
+ export async function activateAccount(body) {
174
+ return Post(`${urls.identity.users.v1}/activate`, body);
175
+ }
176
+ export async function activateAccountV2(body) {
177
+ const data = await Post(`${urls.identity.users.v1}/activate`, body);
178
+ return generateLoginResponseV3(data);
179
+ }
180
+ export async function getActivateAccountStrategy(params) {
181
+ return Get(`${urls.identity.users.v1}/activate/strategy`, params);
182
+ }
183
+ export async function resendActivationEmail(body) {
184
+ return Post(`${urls.identity.users.v1}/activate/reset`, body);
185
+ }
186
+ export async function resendInvitationEmail(body) {
187
+ return Post(`${urls.identity.users.v1}/invitation/reset`, body);
188
+ }
189
+ export async function acceptInvitation(body) {
190
+ return Post(`${urls.identity.users.v1}/invitation/accept`, body);
191
+ }
192
+ export async function refreshToken() {
193
+ const tabTenantId = getTabTenantFromSessionStorage();
194
+ const data = await Post(`${urls.identity.auth.v1}/user/token/refresh`, {
195
+ tenantId: tabTenantId
196
+ });
197
+ return generateLoginResponse(data);
198
+ }
199
+ export async function refreshTokenV2() {
200
+ const tabTenantId = getTabTenantFromSessionStorage();
201
+ const data = await Post(`${urls.identity.auth.v1}/user/token/refresh`, {
202
+ tenantId: tabTenantId
203
+ });
204
+ return generateLoginResponseV2(data);
205
+ }
206
+ export async function refreshTokenV3() {
207
+ const tabTenantId = getTabTenantFromSessionStorage();
208
+ const data = await Post(`${urls.identity.auth.v1}/user/token/refresh`, {
209
+ tenantId: tabTenantId
210
+ });
211
+ return generateLoginResponseV3(data);
212
+ }
213
+ export async function logout() {
214
+ return Post(`${urls.identity.auth.v1}/logout`);
215
+ }
216
+ export async function OAuthLogout(params) {
217
+ return Get(`${urls.oauth.v1}/logout`, params);
218
+ }
219
+ export async function forgotPassword(body) {
220
+ return Post(`${urls.identity.users.v1}/passwords/reset`, body);
221
+ }
222
+ export async function resetPassword(body) {
223
+ return Post(`${urls.identity.users.v1}/passwords/reset/verify`, body);
224
+ }
225
+ export async function loadPasswordConfig(params) {
226
+ return Get(`${urls.identity.users.v1}/passwords/config`, params);
227
+ }
228
+ export async function recoverMfaToken(body) {
229
+ return Post(`${urls.identity.auth.v1}/user/mfa/recover`, body);
230
+ }
231
+ export async function enrollMfa() {
232
+ return Post(`${urls.identity.users.v1}/mfa/enroll`);
233
+ }
234
+ export async function preEnrollMFAAuthenticatorApp() {
235
+ return Post(`${urls.identity.users.v1}/mfa/authenticator/enroll`);
236
+ }
237
+ export async function enrollMFAAuthenticatorApp(body) {
238
+ return Post(`${urls.identity.users.v1}/mfa/authenticator/enroll/verify`, body);
239
+ }
240
+ export async function preEnrollMFASMS(body) {
241
+ return Post(`${urls.identity.users.v1}/mfa/sms/enroll`, body);
242
+ }
243
+ export async function enrollMFASMS(body) {
244
+ return Post(`${urls.identity.users.v1}/mfa/sms/enroll/verify`, body);
245
+ }
246
+ export async function preEnrollMFAWebAuthn() {
247
+ return Post(`${urls.identity.users.v1}/mfa/webauthn/enroll`);
248
+ }
249
+ export async function enrollMFAWebAuthn(body) {
250
+ return Post(`${urls.identity.users.v1}/mfa/webauthn/enroll/verify`, body);
251
+ }
252
+ export async function verifyMfa(body) {
253
+ return Post(`${urls.identity.users.v1}/mfa/enroll/verify`, body);
254
+ }
255
+ export async function disableMfa(body) {
256
+ return Post(`${urls.identity.users.v1}/mfa/disable`, body);
257
+ }
258
+ export async function disableMFAAuthenticatorApp(deviceId, body) {
259
+ return Post(`${urls.identity.users.v1}/mfa/authenticator/${deviceId}/disable/verify`, body);
260
+ }
261
+ export async function preDisableMFASMS(deviceId) {
262
+ return Post(`${urls.identity.users.v1}/mfa/sms/${deviceId}/disable`);
263
+ }
264
+ export async function disableMFASMS(deviceId, body) {
265
+ return Post(`${urls.identity.users.v1}/mfa/sms/${deviceId}/disable/verify`, body);
266
+ }
267
+ export async function preDisableMFAWebAuthn(deviceId) {
268
+ return Post(`${urls.identity.users.v1}/mfa/webauthn/${deviceId}/disable`);
269
+ }
270
+ export async function disableMFAWebAuthn(deviceId, body) {
271
+ return Post(`${urls.identity.users.v1}/mfa/webauthn/${deviceId}/disable/verify`, body);
272
+ }
273
+ export async function getMFADevices() {
274
+ return Get(`${urls.identity.users.v1}/mfa/devices`);
275
+ }
276
+ export async function preEnrollMFAAuthenticatorAppForLogin(body) {
277
+ return Post(`${urls.identity.auth.v1}/user/mfa/authenticator/enroll`, body);
278
+ }
279
+ export async function enrollMFAAuthenticatorAppForLogin(body) {
280
+ return Post(`${urls.identity.auth.v1}/user/mfa/authenticator/enroll/verify`, body);
281
+ }
282
+ export async function enrollMFAAuthenticatorAppForLoginV2(body) {
283
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/authenticator/enroll/verify`, body);
284
+ return generateLoginResponseV3(data);
285
+ }
286
+ export async function verifyMFAAuthenticatorAppForLogin(deviceId, body) {
287
+ return Post(`${urls.identity.auth.v1}/user/mfa/authenticator/${deviceId}/verify`, body);
288
+ }
289
+ export async function preVerifyMFAEmailCode(body) {
290
+ return Post(`${urls.identity.auth.v1}/user/mfa/emailcode`, body);
291
+ }
292
+ export async function verifyMFAEmailCode(body) {
293
+ return Post(`${urls.identity.auth.v1}/user/mfa/emailcode/verify`, body);
294
+ }
295
+ export async function verifyMFAEmailCodeV2(body) {
296
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/emailcode/verify`, body);
297
+ return generateLoginResponseV3(data);
298
+ }
299
+ export async function preEnrollMFASMSForLogin(body) {
300
+ return Post(`${urls.identity.auth.v1}/user/mfa/sms/enroll`, body);
301
+ }
302
+ export async function enrollMFASMSForLogin(body) {
303
+ return Post(`${urls.identity.auth.v1}/user/mfa/sms/enroll/verify`, body);
304
+ }
305
+ export async function enrollMFASMSForLoginV2(body) {
306
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/sms/enroll/verify`, body);
307
+ return generateLoginResponseV3(data);
308
+ }
309
+ export async function preVerifyMFASMSForLogin(deviceId, body) {
310
+ return Post(`${urls.identity.auth.v1}/user/mfa/sms/${deviceId}`, body);
311
+ }
312
+ export async function verifyMFASMSForLogin(deviceId, body) {
313
+ return Post(`${urls.identity.auth.v1}/user/mfa/sms/${deviceId}/verify`, body);
314
+ }
315
+ export async function verifyMFASMSForLoginV2(deviceId, body) {
316
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/sms/${deviceId}/verify`, body);
317
+ return generateLoginResponseV3(data);
318
+ }
319
+ export async function preEnrollMFAWebAuthnForLogin(body) {
320
+ return Post(`${urls.identity.auth.v1}/user/mfa/webauthn/enroll`, body);
321
+ }
322
+ export async function enrollMFAWebAuthnForLogin(body) {
323
+ return Post(`${urls.identity.auth.v1}/user/mfa/webauthn/enroll/verify`, body);
324
+ }
325
+ export async function enrollMFAWebAuthnForLoginV2(body) {
326
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/webauthn/enroll/verify`, body);
327
+ return generateLoginResponseV3(data);
328
+ }
329
+ export async function preVerifyMFAWebAuthnForLogin(deviceId, body) {
330
+ return Post(`${urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}`, body);
331
+ }
332
+ export async function verifyMFAWebAuthnForLogin(deviceId, body) {
333
+ return Post(`${urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}/verify`, body);
334
+ }
335
+ export async function verifyMFAWebAuthnForLoginV2(deviceId, body) {
336
+ const data = await Post(`${urls.identity.auth.v1}/user/mfa/webauthn/${deviceId}/verify`, body);
337
+ return generateLoginResponseV3(data);
338
+ }
339
+ export async function getSamlConfiguration() {
340
+ return Get(`${urls.team.sso.v1}/saml/configurations`);
341
+ }
342
+ export async function updateSamlConfiguration(body) {
343
+ return Post(`${urls.team.sso.v1}/saml/configurations`, body);
344
+ }
345
+ export async function getSamlVendorConfiguration() {
346
+ return Get(`${urls.team.sso.v1}/saml/configurations/vendor-config`);
347
+ }
348
+ export async function updateSamlVendorMetadata(body) {
349
+ return Put(`${urls.team.sso.v1}/saml/configurations/metadata`, body);
350
+ }
351
+ export async function validateSamlDomain() {
352
+ return Put(`${urls.team.sso.v1}/saml/validations/domain`);
353
+ }
354
+ export async function getSamlRoles() {
355
+ return Get(`${urls.team.sso.v1}/saml/configurations/roles/default`);
356
+ }
357
+ export async function getSamlRolesGroups() {
358
+ return Get(`${urls.team.sso.v2}/saml/configurations/groups`);
359
+ }
360
+ export async function updateSamlRoles({
361
+ roleIds
362
+ }) {
363
+ return Post(`${urls.team.sso.v1}/saml/configurations/roles/default`, {
364
+ roleIds
365
+ });
366
+ }
367
+ export async function createSamlGroup({
368
+ roleIds,
369
+ group
370
+ }) {
371
+ return Post(`${urls.team.sso.v2}/saml/configurations/groups`, {
372
+ group,
373
+ roleIds
374
+ });
375
+ }
376
+ export async function updateSamlGroup({
377
+ roleIds,
378
+ group,
379
+ id
380
+ }) {
381
+ return Patch(`${urls.team.sso.v2}/saml/configurations/groups/${id}`, {
382
+ group,
383
+ roleIds
384
+ });
385
+ }
386
+ export async function deleteSamlGroup({
387
+ id
388
+ }) {
389
+ return Delete(`${urls.team.sso.v2}/saml/configurations/groups/${id}`);
390
+ }
391
+ export async function getOidcConfiguration() {
392
+ return Get(`${urls.team.sso.v1}/oidc/configurations`);
393
+ }
394
+ export async function getSSOPublicConfiguration() {
395
+ return Get(`${urls.team.sso.v2}/configurations/public`);
396
+ }
397
+ export async function getSocialLoginProviders() {
398
+ return Get(urls.identity.sso.v1);
399
+ }
400
+ export async function getSocialLoginProvidersV2() {
401
+ return Get(urls.identity.sso.v2);
402
+ }
403
+ export async function getSocialLoginProvidersV2ForAuthenticatedUser() {
404
+ return Get(`${urls.identity.sso.v2}/authenticated`);
405
+ }
406
+ export async function getCustomSocialLoginProvidersV1() {
407
+ return Get(urls.identity.sso.custom.v1);
408
+ }
409
+ export async function loginViaSocialLogin({
410
+ provider,
411
+ code,
412
+ idToken,
413
+ redirectUri,
414
+ codeVerifier,
415
+ metadata,
416
+ invitationToken,
417
+ state
418
+ }) {
419
+ const params = {};
420
+
421
+ if (code) {
422
+ params.code = code;
423
+ }
854
424
 
855
- this.getMFAStrategiesConfig = async () => {
856
- return this.get(`${urls.identity.configurations.v1}/mfa/strategies`);
857
- };
425
+ if (idToken) {
426
+ params.id_token = idToken;
427
+ }
858
428
 
859
- this.getUserAuthorization = async () => {
860
- return this.get(`${urls.identity.users.authorization.v1}`);
861
- };
429
+ if (redirectUri) {
430
+ params.redirectUri = redirectUri;
431
+ }
862
432
 
863
- this.getMeV2 = async () => {
864
- return this.get(`${urls.identity.users.v2}/me`);
865
- };
433
+ if (codeVerifier) {
434
+ params.code_verifier = codeVerifier;
435
+ }
866
436
 
867
- this.noThrowLoadEntitlements = async () => {
868
- try {
869
- return await this.entitlementsApi.loadEntitlementsV2();
870
- } catch (e) {}
871
- };
437
+ if (state) {
438
+ params.state = state;
439
+ }
872
440
 
873
- this.getMeAndEntitlements = async () => {
874
- const actions = [{
875
- action: this.getMeV2,
876
- shouldLoad: true
877
- }, {
878
- action: this.noThrowLoadEntitlements,
879
- shouldLoad: this.shouldLoadEntitlements()
880
- }, {
881
- action: this.getUserAuthorization,
882
- shouldLoad: this.shouldLoadMeAuthorization()
883
- }];
884
- const promises = actions.map(action => executeConditionalPromise(action));
885
- const [me, entitlements, authorization] = await Promise.all(promises);
886
- const tabTenant = getTabTenantFromSessionStorage(this.appName);
887
-
888
- if (tabTenant) {
889
- me.tenantId = tabTenant;
890
- }
891
-
892
- return _extends({}, me, authorization != null ? authorization : {}, {
893
- entitlements
894
- });
895
- };
441
+ return Post(`${urls.identity.auth.v1}/user/sso/${provider}/postlogin`, {
442
+ metadata,
443
+ invitationToken
444
+ }, {
445
+ params
446
+ });
447
+ }
448
+ export async function getVendorConfig() {
449
+ return Get(`${urls.identity.configurations.v1}/public`);
450
+ }
451
+ export async function signUpUser(body) {
452
+ const {
453
+ shouldActivate,
454
+ authResponse,
455
+ userId,
456
+ tenantId
457
+ } = await Post(`${urls.identity.users.v1}/signUp`, body);
458
+ const response = {
459
+ shouldActivate,
460
+ userId,
461
+ tenantId
462
+ };
463
+
464
+ if (!shouldActivate && authResponse) {
465
+ const {
466
+ user,
467
+ tenants,
468
+ activeTenant
469
+ } = await generateLoginResponseV3(authResponse);
470
+ return _extends({}, response, {
471
+ user,
472
+ tenants,
473
+ activeTenant
474
+ });
475
+ }
896
476
 
897
- this.generateStepupSession = async body => {
898
- const data = await this.post(`${urls.identity.auth.v1}/user/step-up/generate`, body);
477
+ return response;
478
+ }
479
+ export async function getCurrentUserSessions() {
480
+ return Get(urls.identity.users.sessions.currentUser.v1);
481
+ }
482
+ export async function getCurrentUserSession() {
483
+ return Get(`${urls.identity.users.sessions.currentUser.v1}/current`);
484
+ }
485
+ export async function revokeSessionsForUser(userId) {
486
+ return Post(`${urls.identity.users.sessions.v1}/revoke`, {
487
+ userId
488
+ });
489
+ }
490
+ export async function getSessionConfigurations() {
491
+ return Get(urls.identity.users.sessions.configurations.v1);
492
+ }
493
+ export async function createOrUpdateSessionConfigrations(body) {
494
+ await Post(urls.identity.users.sessions.configurations.v1, body);
495
+ }
496
+ export async function deleteSessionForUser(id) {
497
+ await Delete(`${urls.identity.users.sessions.currentUser.v1}/${id}`);
498
+ }
499
+ export async function deleteAllSessionsForUser() {
500
+ await Delete(`${urls.identity.users.sessions.currentUser.v1}/all`);
501
+ }
502
+ export async function getUserAccessTokensData() {
503
+ return Get(urls.identity.users.accessTokens.v1);
504
+ }
505
+ export async function getTenantAccessTokensData() {
506
+ return Get(urls.identity.tenants.accessTokens.v1);
507
+ }
508
+ export async function deleteTenantAccessToken({
509
+ id
510
+ }) {
511
+ return Delete(`${urls.identity.tenants.accessTokens.v1}/${id}`);
512
+ }
513
+ export async function deleteUserAccessToken({
514
+ id
515
+ }) {
516
+ return Delete(`${urls.identity.users.accessTokens.v1}/${id}`);
517
+ }
518
+ export async function createUserAccessToken(body) {
519
+ return Post(urls.identity.users.accessTokens.v1, body);
520
+ }
521
+ export async function createTenantAccessToken(body) {
522
+ return Post(urls.identity.tenants.accessTokens.v1, body);
523
+ }
524
+ export async function getUserApiTokensData() {
525
+ return Get(urls.identity.users.apiTokens.v1);
526
+ }
527
+ export async function getTenantApiTokensData() {
528
+ return Get(urls.identity.tenants.apiTokens.v1);
529
+ }
530
+ export async function updateUserApiTokensData(body) {
531
+ return Post(urls.identity.users.apiTokens.v1, body);
532
+ }
533
+ export async function updateTenantApiTokensData(body) {
534
+ return Post(urls.identity.tenants.apiTokens.v2, body);
535
+ }
536
+ export async function deleteTenantApiToken({
537
+ tokenId
538
+ }) {
539
+ return Delete(`${urls.identity.tenants.apiTokens.v1}/${tokenId}`);
540
+ }
541
+ export async function deleteUserApiToken({
542
+ tokenId
543
+ }) {
544
+ return Delete(`${urls.identity.users.apiTokens.v1}/${tokenId}`);
545
+ }
546
+ export async function getUserById({
547
+ userId
548
+ }) {
549
+ return Get(`${urls.identity.users.v1}/${userId}`);
550
+ }
551
+ export async function checkIfAllowToRememberMfaDevice(mfaToken) {
552
+ return Get(`${urls.identity.configurations.v1}/mfa-policy/allow-remember-device`, {
553
+ mfaToken
554
+ });
555
+ }
556
+ export async function passwordlessPreLogin(_ref) {
557
+ let {
558
+ type
559
+ } = _ref,
560
+ body = _objectWithoutPropertiesLoose(_ref, _excluded);
899
561
 
900
- if (!data.accessToken) {
901
- return data;
902
- }
562
+ return Post(`${urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/prelogin`, body);
563
+ }
564
+ export async function passwordlessPostLoginV2(_ref2) {
565
+ let {
566
+ type
567
+ } = _ref2,
568
+ body = _objectWithoutPropertiesLoose(_ref2, _excluded2);
569
+
570
+ const data = await Post(`${urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/postlogin`, body);
571
+ return generateLoginResponseV3(data);
572
+ }
573
+ export async function passwordlessPostLogin(_ref3) {
574
+ let {
575
+ type
576
+ } = _ref3,
577
+ body = _objectWithoutPropertiesLoose(_ref3, _excluded3);
903
578
 
904
- return this.generateLoginResponseV3(data);
905
- };
579
+ return Post(`${urls.identity.auth.v1}/passwordless/${type.toLocaleLowerCase()}/postlogin`, body);
580
+ }
581
+ export async function verifyInviteToken({
582
+ token
583
+ }) {
584
+ return Post(urls.identity.tenants.invites.verify.v1, {
585
+ token
586
+ });
587
+ }
588
+ export async function getSSOConfigurations() {
589
+ return Get(`${urls.team.sso.v1}/configurations`);
590
+ }
591
+ export async function createSSOConfiguration(body) {
592
+ return Post(`${urls.team.sso.v1}/configurations`, body);
593
+ }
594
+ export async function updateSSOConfiguration(ssoConfigId, body) {
595
+ return Patch(`${urls.team.sso.v1}/configurations/${ssoConfigId}`, body);
596
+ }
597
+ export async function deleteSSOConfiguration(ssoConfigId) {
598
+ return Delete(`${urls.team.sso.v1}/configurations/${ssoConfigId}`);
599
+ }
600
+ export async function createSSOConfigurationByMetadata(body) {
601
+ return Post(`${urls.team.sso.v1}/configurations/metadata`, body);
602
+ }
603
+ export async function updateSSOConfigurationByMetadata(ssoConfigId, body) {
604
+ return Put(`${urls.team.sso.v1}/configurations/${ssoConfigId}/metadata`, body);
605
+ }
606
+ export async function createSSOConfigurationByMetadataUrl(body) {
607
+ return Post(`${urls.team.sso.v1}/configurations/metadata-url`, body);
608
+ }
609
+ export async function updateSSOConfigurationByMetadataUrl(ssoConfigId, body) {
610
+ return Put(`${urls.team.sso.v1}/configurations/${ssoConfigId}/metadata-url`, body);
611
+ }
612
+ export async function createSSODomain(ssoConfigId, body) {
613
+ return Post(`${urls.team.sso.v1}/configurations/${ssoConfigId}/domains`, body);
614
+ }
615
+ export async function deleteSSODomain(ssoConfigId, domainId) {
616
+ return Delete(`${urls.team.sso.v1}/configurations/${ssoConfigId}/domains/${domainId}`);
617
+ }
618
+ export async function validateSSODomain(ssoConfigId, domainId) {
619
+ return Put(`${urls.team.sso.v1}/configurations/${ssoConfigId}/domains/${domainId}/validate`);
620
+ }
621
+ export async function validateSSODomainV2(ssoConfigId, domainId) {
622
+ return Put(`${urls.team.sso.v2}/configurations/${ssoConfigId}/domains/${domainId}/validate`);
623
+ }
624
+ export async function getSSODefaultRoles(ssoConfigId) {
625
+ return Get(`${urls.team.sso.v1}/configurations/${ssoConfigId}/roles`);
626
+ }
627
+ export async function setSSODefaultRoles(ssoConfigId, body) {
628
+ return Put(`${urls.team.sso.v1}/configurations/${ssoConfigId}/roles`, body);
629
+ }
630
+ export async function createSSOGroup(ssoConfigId, body) {
631
+ return Post(`${urls.team.sso.v1}/configurations/${ssoConfigId}/groups`, body);
632
+ }
633
+ export async function updateSSOGroup(ssoConfigId, {
634
+ roleIds,
635
+ group,
636
+ id
637
+ }) {
638
+ return Patch(`${urls.team.sso.v1}/configurations/${ssoConfigId}/groups/${id}`, {
639
+ group,
640
+ roleIds
641
+ });
642
+ }
643
+ export async function deleteSSOGroup(ssoConfigId, groupId) {
644
+ return Delete(`${urls.team.sso.v1}/configurations/${ssoConfigId}/groups/${groupId}`);
645
+ }
646
+ export async function getSSOGroups(ssoConfigId) {
647
+ return Get(`${urls.team.sso.v1}/configurations/${ssoConfigId}/groups`);
648
+ }
649
+ export async function preLoginV2(body) {
650
+ return Post(`${urls.identity.auth.v2}/user/sso/prelogin`, body);
651
+ }
652
+ export async function oidcPostLoginV2(body) {
653
+ const data = await Post(`${urls.identity.auth.v2}/user/oidc/postlogin`, body);
654
+ return generateLoginResponse(data);
655
+ }
656
+ export async function exchangeOAuthTokensV2(body) {
657
+ const data = await Post(`${urls.oauth.v1}/token`, body);
658
+ return generateLoginResponseFromOAuthResponseV2(data);
659
+ }
660
+ export async function silentOAuthRefreshTokenV2() {
661
+ const tabTenantId = getTabTenantFromSessionStorage();
662
+ const data = await Post(`${urls.oauth.v1}/authorize/silent`, {
663
+ tenantId: tabTenantId
664
+ });
665
+ return generateLoginResponseFromOAuthResponseV2(data);
666
+ }
667
+ export async function exchangeOAuthTokens(body) {
668
+ const data = await Post(`${urls.oauth.v1}/token`, body);
669
+ return generateLoginResponseFromOAuthResponse(data);
670
+ }
671
+ export async function silentOAuthRefreshToken() {
672
+ const tabTenantId = getTabTenantFromSessionStorage();
673
+ const data = await Post(`${urls.oauth.v1}/authorize/silent`, {
674
+ tenantId: tabTenantId
675
+ });
676
+ return generateLoginResponseFromOAuthResponse(data);
677
+ }
678
+ export async function resetPhoneNumber(body) {
679
+ return Post(`${urls.identity.users.v1}/phone/reset`, body);
680
+ }
681
+ export async function verifyResetPhoneNumber(body) {
682
+ return Post(`${urls.identity.users.v1}/phone/reset/verify`, body);
683
+ }
684
+ export async function changePhoneNumberWithVerification(body) {
685
+ return Post(`${urls.identity.users.v1}/phone`, body);
686
+ }
687
+ export async function verifyChangePhoneNumber(body) {
688
+ return Post(`${urls.identity.users.v1}/phone/verify`, body);
689
+ }
690
+ export async function changePhoneNumber(body) {
691
+ return Put(`${urls.identity.users.v1}/phone/change`, body);
692
+ }
693
+ export async function webAuthnPreLogin(body) {
694
+ return Post(`${urls.identity.auth.v1}/webauthn/prelogin`, body);
695
+ }
696
+ export async function webAuthnPostLogin(body) {
697
+ return Post(`${urls.identity.auth.v1}/webauthn/postlogin`, body);
698
+ }
699
+ export async function webAuthnPostLoginV2(body) {
700
+ const data = await Post(`${urls.identity.auth.v1}/webauthn/postlogin`, body);
701
+ return generateLoginResponseV3(data);
702
+ }
703
+ export async function webAuthnCreateNewDeviceSession() {
704
+ return Post(urls.identity.webAuthnDevices.v1);
705
+ }
706
+ export async function getWebAuthnDevices() {
707
+ return Get(urls.identity.webAuthnDevices.v1);
708
+ }
709
+ export async function deleteWebAuthnDevice(deviceId) {
710
+ return Delete(`${urls.identity.webAuthnDevices.v1}/${deviceId}`);
711
+ }
712
+ export async function verifyNewDeviceSession(body) {
713
+ return Post(`${urls.identity.webAuthnDevices.v1}/verify`, body);
714
+ }
715
+ export async function getVendorPublicAuthStrategiesConfig() {
716
+ return Get(`${urls.identity.configurations.v1}/auth/strategies/public`);
717
+ }
718
+ export async function getPublicAuthStrategiesConfigForAuthenticatedUser() {
719
+ return Get(`${urls.identity.configurations.v1}/auth/strategies`);
720
+ }
721
+ export async function getMFAStrategiesConfig() {
722
+ return Get(`${urls.identity.configurations.v1}/mfa/strategies`);
723
+ }
724
+ export async function getUserAuthorization() {
725
+ return Get(`${urls.identity.users.authorization.v1}`);
726
+ }
727
+ export async function getMeV2() {
728
+ return Get(`${urls.identity.users.v2}/me`);
729
+ }
906
730
 
907
- this.getGlobalSecurityPolicy = this.securityPolicy.getGlobalSecurityPolicy.bind(this.securityPolicy);
908
- this.getMfaPolicy = this.securityPolicy.getMfaPolicy.bind(this.securityPolicy);
909
- this.getVendorMfaPolicy = this.securityPolicy.getVendorMfaPolicy.bind(this.securityPolicy);
910
- this.saveMfaPolicy = this.securityPolicy.saveMfaPolicy.bind(this.securityPolicy);
911
- this.getLockoutPolicy = this.securityPolicy.getLockoutPolicy.bind(this.securityPolicy);
912
- this.getVendorLockoutPolicy = this.securityPolicy.getVendorLockoutPolicy.bind(this.securityPolicy);
913
- this.saveLockoutPolicy = this.securityPolicy.saveLockoutPolicy.bind(this.securityPolicy);
914
- this.getCaptchaPolicy = this.securityPolicy.getCaptchaPolicy.bind(this.securityPolicy);
915
- this.getPasswordHistoryPolicy = this.securityPolicy.getPasswordHistoryPolicy.bind(this.securityPolicy);
916
- this.getVendorPasswordHistoryPolicy = this.securityPolicy.getVendorPasswordHistoryPolicy.bind(this.securityPolicy);
917
- this.savePasswordHistoryPolicy = this.securityPolicy.savePasswordHistoryPolicy.bind(this.securityPolicy);
918
- this.getPasswordConfigPolicy = this.securityPolicy.getPasswordConfigPolicy.bind(this.securityPolicy);
919
- this.getDomainRestrictions = this.securityPolicy.getDomainRestrictions.bind(this.securityPolicy);
920
- this.getDomainRestrictionsConfig = this.securityPolicy.getDomainRestrictionsConfig.bind(this.securityPolicy);
921
- this.createDomainRestriction = this.securityPolicy.createDomainRestriction.bind(this.securityPolicy);
922
- this.updateDomainRestrictionConfig = this.securityPolicy.updateDomainRestrictionConfig.bind(this.securityPolicy);
923
- this.deleteDomainRestriction = this.securityPolicy.deleteDomainRestriction.bind(this.securityPolicy);
924
- this.getIPRestrictions = this.securityPolicy.getIPRestrictions.bind(this.securityPolicy);
925
- this.getIPRestrictionsConfig = this.securityPolicy.getIPRestrictionsConfig.bind(this.securityPolicy);
926
- this.createIPRestriction = this.securityPolicy.createIPRestriction.bind(this.securityPolicy);
927
- this.bulkCreateIPRestriction = this.securityPolicy.bulkCreateIPRestriction.bind(this.securityPolicy);
928
- this.updateIPRestrictionConfig = this.securityPolicy.updateIPRestrictionConfig.bind(this.securityPolicy);
929
- this.deleteIPRestriction = this.securityPolicy.deleteIPRestriction.bind(this.securityPolicy);
930
- this.testCurrentIp = this.securityPolicy.testCurrentIp.bind(this.securityPolicy);
931
- this.testCurrentIpInAllowList = this.securityPolicy.testCurrentIpInAllowList.bind(this.securityPolicy);
731
+ const noThrowLoadEntitlements = async () => {
732
+ try {
733
+ return await loadEntitlementsV2();
734
+ } catch (e) {}
735
+ };
736
+
737
+ export async function getMeAndEntitlements() {
738
+ const actions = [{
739
+ action: getMeV2,
740
+ shouldLoad: true
741
+ }, {
742
+ action: noThrowLoadEntitlements,
743
+ shouldLoad: shouldLoadEntitlements()
744
+ }, {
745
+ action: getUserAuthorization,
746
+ shouldLoad: shouldLoadMeAuthorization()
747
+ }];
748
+ const promises = actions.map(action => executeConditionalPromise(action));
749
+ const [me, entitlements, authorization] = await Promise.all(promises);
750
+ const tabTenant = getTabTenantFromSessionStorage();
751
+
752
+ if (tabTenant) {
753
+ me.tenantId = tabTenant;
932
754
  }
933
755
 
934
- shouldLoadEntitlements() {
935
- if (!ContextHolder.for(this.appName).shouldLoadEntitlements()) {
936
- return false;
937
- }
938
-
939
- const [isEntitlementsFFOn] = FeatureFlags.getFeatureFlags([ADMIN_PORTAL_ENTITLEMENTS_FF], this.appName || '');
940
- return isEntitlementsFFOn;
941
- }
756
+ return _extends({}, me, authorization != null ? authorization : {}, {
757
+ entitlements
758
+ });
759
+ }
760
+ export async function generateStepupSession(body) {
761
+ const data = await Post(`${urls.identity.auth.v1}/user/step-up/generate`, body);
942
762
 
943
- shouldLoadMeAuthorization() {
944
- const [shouldLoadAuthorization] = FeatureFlags.getFeatureFlags([LOAD_AUTHORIZATION_FF], this.appName);
945
- return shouldLoadAuthorization;
763
+ if (!data.accessToken) {
764
+ return data;
946
765
  }
947
766
 
948
- }
949
- export default new AuthenticationApi('default');
767
+ return generateLoginResponseV3(data);
768
+ }