@frontegg/rest-api 3.1.72 → 3.1.74-alpha.9436511986

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