@frontegg/rest-api 3.1.74 → 3.1.76-alpha.9502349697
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.
- package/BaseApiClient.d.ts +16 -0
- package/BaseApiClient.js +39 -0
- package/ContextHolder/index.d.ts +108 -27
- package/ContextHolder/index.js +155 -50
- package/FetchClient.d.ts +42 -0
- package/FetchClient.js +308 -0
- package/account-settings/index.d.ts +19 -7
- package/account-settings/index.js +23 -13
- package/applications/index.d.ts +49 -44
- package/applications/index.js +51 -37
- package/audits/index.d.ts +27 -15
- package/audits/index.js +27 -17
- package/auth/index.d.ts +817 -768
- package/auth/index.js +902 -721
- package/auth/secutiry-poilicy/index.d.ts +58 -102
- package/auth/secutiry-poilicy/index.js +122 -90
- package/auth/utils.d.ts +2 -2
- package/auth/utils.js +9 -8
- package/connectivity/index.d.ts +126 -27
- package/connectivity/index.js +147 -114
- package/directory/index.d.ts +31 -22
- package/directory/index.js +27 -15
- package/entitlements/index.d.ts +14 -8
- package/entitlements/index.js +12 -4
- package/feature-flags/index.d.ts +8 -2
- package/feature-flags/index.js +16 -8
- package/groups/index.d.ts +73 -49
- package/groups/index.js +64 -45
- package/impersonate/index.d.ts +15 -6
- package/impersonate/index.js +13 -5
- package/index.d.ts +154 -108
- package/index.js +109 -78
- package/interfaces.d.ts +10 -0
- package/metadata/index.d.ts +67 -7
- package/metadata/index.js +52 -32
- package/node/BaseApiClient.js +49 -0
- package/node/ContextHolder/index.js +155 -50
- package/node/FetchClient.js +326 -0
- package/node/account-settings/index.js +27 -16
- package/node/applications/index.js +51 -44
- package/node/audits/index.js +31 -20
- package/node/auth/index.js +768 -1035
- package/node/auth/secutiry-poilicy/index.js +125 -136
- package/node/auth/utils.js +9 -7
- package/node/connectivity/index.js +148 -187
- package/node/directory/index.js +29 -20
- package/node/entitlements/index.js +18 -5
- package/node/feature-flags/index.js +21 -9
- package/node/groups/index.js +65 -63
- package/node/impersonate/index.js +18 -5
- package/node/index.js +116 -71
- package/node/metadata/index.js +61 -52
- package/node/notifications/index.js +37 -27
- package/node/reports/index.js +78 -70
- package/node/roles/index.js +56 -51
- package/node/security-center/index.js +21 -9
- package/node/sub-tenants/index.js +90 -89
- package/node/subscriptions/index.js +69 -107
- package/node/subscriptions/invoices.js +25 -17
- package/node/subscriptions/managedSubscriptions.js +32 -27
- package/node/subscriptions/paymentMethods.js +27 -20
- package/node/subscriptions/paymentProviders.js +15 -6
- package/node/subscriptions/plans.js +17 -9
- package/node/subscriptions/providers/stripe/index.js +26 -21
- package/node/subscriptions/subscriptions.js +32 -27
- package/node/subscriptions/summaries.js +15 -6
- package/node/subscriptions/tenantConfiguration.js +17 -9
- package/node/subscriptions/vendorPublicConfigurations.js +15 -6
- package/node/teams/index.js +130 -138
- package/node/tenants/index.js +65 -60
- package/node/user-phone-numbers/index.js +32 -24
- package/node/users/index.js +58 -53
- package/node/vendor/index.js +17 -6
- package/notifications/index.d.ts +22 -16
- package/notifications/index.js +33 -22
- package/package.json +1 -1
- package/reports/index.d.ts +50 -44
- package/reports/index.js +75 -62
- package/roles/index.d.ts +44 -38
- package/roles/index.js +57 -41
- package/security-center/index.d.ts +14 -2
- package/security-center/index.js +15 -6
- package/sub-tenants/index.d.ts +57 -15
- package/sub-tenants/index.js +88 -68
- package/subscriptions/index.d.ts +56 -11
- package/subscriptions/index.js +58 -11
- package/subscriptions/invoices.d.ts +16 -13
- package/subscriptions/invoices.js +24 -14
- package/subscriptions/managedSubscriptions.d.ts +18 -15
- package/subscriptions/managedSubscriptions.js +33 -22
- package/subscriptions/paymentMethods.d.ts +16 -13
- package/subscriptions/paymentMethods.js +26 -17
- package/subscriptions/paymentProviders.d.ts +8 -5
- package/subscriptions/paymentProviders.js +11 -4
- package/subscriptions/plans.d.ts +11 -8
- package/subscriptions/plans.js +14 -6
- package/subscriptions/providers/stripe/index.d.ts +24 -21
- package/subscriptions/providers/stripe/index.js +27 -16
- package/subscriptions/subscriptions.d.ts +24 -21
- package/subscriptions/subscriptions.js +33 -22
- package/subscriptions/summaries.d.ts +7 -4
- package/subscriptions/summaries.js +10 -3
- package/subscriptions/tenantConfiguration.d.ts +6 -3
- package/subscriptions/tenantConfiguration.js +15 -7
- package/subscriptions/vendorPublicConfigurations.d.ts +5 -2
- package/subscriptions/vendorPublicConfigurations.js +11 -4
- package/teams/index.d.ts +35 -131
- package/teams/index.js +122 -93
- package/tenants/index.d.ts +25 -37
- package/tenants/index.js +62 -46
- package/tenants/interfaces.d.ts +2 -0
- package/user-phone-numbers/index.d.ts +32 -26
- package/user-phone-numbers/index.js +32 -19
- package/users/index.d.ts +21 -15
- package/users/index.js +60 -44
- package/vendor/index.d.ts +12 -6
- package/vendor/index.js +11 -4
- package/fetch.d.ts +0 -24
- package/fetch.js +0 -265
- package/node/fetch.js +0 -306
- package/node/subscriptions/providers/index.js +0 -18
- package/subscriptions/providers/index.d.ts +0 -1
- package/subscriptions/providers/index.js +0 -1
package/FetchClient.js
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { ContextHolder } from './ContextHolder';
|
|
3
|
+
import { FronteggApiError } from './error';
|
|
4
|
+
import { GENERIC_ERROR_MESSAGE } from './constants';
|
|
5
|
+
import { fronteggHeaders } from './interfaces';
|
|
6
|
+
export class FetchClient {
|
|
7
|
+
constructor(appName) {
|
|
8
|
+
this.appName = void 0;
|
|
9
|
+
|
|
10
|
+
this.getFronteggContext = () => {
|
|
11
|
+
return ContextHolder.for(this.appName);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
this.prepareUrl = async (url, params) => {
|
|
15
|
+
const context = this.getFronteggContext().getContext();
|
|
16
|
+
const baseUrl = this.getContextBaseUrl(url);
|
|
17
|
+
const paramsToSend = await this.buildQueryParams(context, params);
|
|
18
|
+
let finalUrl = url.startsWith('http') ? url : `${baseUrl}${url}`;
|
|
19
|
+
const hasKeys = Object.keys(paramsToSend).length > 0;
|
|
20
|
+
|
|
21
|
+
if (paramsToSend && hasKeys) {
|
|
22
|
+
const urlParams = new URLSearchParams(paramsToSend);
|
|
23
|
+
finalUrl += `?${urlParams}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return finalUrl;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
this.buildQueryParams = async (context, params) => {
|
|
30
|
+
if (!params) {
|
|
31
|
+
params = {};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const additionalQueryParams = await this.getAdditionalQueryParams(context);
|
|
35
|
+
|
|
36
|
+
for (const queryParam of additionalQueryParams) {
|
|
37
|
+
params[queryParam.key] = queryParam.value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const keys = Object.keys(params);
|
|
41
|
+
|
|
42
|
+
for (const key of keys) {
|
|
43
|
+
const value = params[key];
|
|
44
|
+
params[key] = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return params;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
this.getAdditionalQueryParams = async context => {
|
|
51
|
+
let output = [];
|
|
52
|
+
|
|
53
|
+
if (context.additionalQueryParamsResolver) {
|
|
54
|
+
output = await context.additionalQueryParamsResolver();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return output;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
this.getAdditionalHeaders = async context => {
|
|
61
|
+
let output = [];
|
|
62
|
+
|
|
63
|
+
if (context.additionalHeadersResolver) {
|
|
64
|
+
output = await context.additionalHeadersResolver();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (context.tenantResolver) {
|
|
68
|
+
const resolvedTenantResult = await context.tenantResolver();
|
|
69
|
+
|
|
70
|
+
if (!!(resolvedTenantResult != null && resolvedTenantResult.tenant)) {
|
|
71
|
+
output.push({
|
|
72
|
+
key: 'frontegg-login-alias',
|
|
73
|
+
value: resolvedTenantResult.tenant
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (context.appId) {
|
|
79
|
+
output.push({
|
|
80
|
+
key: 'frontegg-requested-application-id',
|
|
81
|
+
value: context.appId
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return output;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
this.buildRequestHeaders = async contentType => {
|
|
89
|
+
var _context$tokenResolve;
|
|
90
|
+
|
|
91
|
+
const fronteggContext = this.getFronteggContext();
|
|
92
|
+
const context = fronteggContext.getContext();
|
|
93
|
+
const headers = FetchClient.getMetadataHeaders(context);
|
|
94
|
+
const authToken = await ((_context$tokenResolve = context == null ? void 0 : context.tokenResolver) != null ? _context$tokenResolve : fronteggContext.getAccessToken)();
|
|
95
|
+
const requestSource = fronteggContext.getRequestSource();
|
|
96
|
+
const scopedTenant = FetchClient.getScopedTenant();
|
|
97
|
+
|
|
98
|
+
if (contentType) {
|
|
99
|
+
headers[fronteggHeaders.contentType] = contentType;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (requestSource) {
|
|
103
|
+
headers[fronteggHeaders.source] = requestSource;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (authToken) {
|
|
107
|
+
headers.Authorization = `Bearer ${authToken}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (scopedTenant) {
|
|
111
|
+
headers[fronteggHeaders.scopedTenant] = scopedTenant;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
for (const additionalHeader of await this.getAdditionalHeaders(context)) {
|
|
115
|
+
headers[`${additionalHeader.key}`] = `${additionalHeader.value}`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return headers;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
this.sendRequest = async opts => {
|
|
122
|
+
var _opts$method, _ref, _opts$credentials;
|
|
123
|
+
|
|
124
|
+
const context = this.getFronteggContext().getContext();
|
|
125
|
+
const headers = await this.buildRequestHeaders(opts.contentType);
|
|
126
|
+
const url = await this.prepareUrl(opts.url, opts.params);
|
|
127
|
+
const response = await fetch(url, {
|
|
128
|
+
body: opts.body ? opts.contentType === 'application/json' ? JSON.stringify(opts.body) : opts.body : null,
|
|
129
|
+
method: (_opts$method = opts.method) != null ? _opts$method : 'GET',
|
|
130
|
+
headers: _extends({}, headers, opts.headers),
|
|
131
|
+
credentials: (_ref = (_opts$credentials = opts.credentials) != null ? _opts$credentials : context.requestCredentials) != null ? _ref : 'same-origin'
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
if (response.status === 302) {
|
|
135
|
+
window.location.href = await response.text();
|
|
136
|
+
return new Promise(() => {});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (!response.ok) {
|
|
140
|
+
var _context$logLevel, _context$logLevel2;
|
|
141
|
+
|
|
142
|
+
if (response.status === 413) {
|
|
143
|
+
throw new FronteggApiError('Error request is too large', response.status);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
let errorMessage;
|
|
147
|
+
let isJsonResponse = true;
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
errorMessage = await response.text();
|
|
151
|
+
errorMessage = JSON.parse(errorMessage);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
isJsonResponse = false;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (errorMessage.errors) {
|
|
157
|
+
errorMessage = errorMessage.errors.join(', ');
|
|
158
|
+
} else if (typeof errorMessage !== 'string') {
|
|
159
|
+
errorMessage = `Error ${response.status} - ${response.statusText}`;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (response.status >= 400 && response.status < 500 && ['warn'].includes((_context$logLevel = context.logLevel) != null ? _context$logLevel : '')) console.warn(errorMessage);else if (response.status === 500 && ['warn', 'error'].includes((_context$logLevel2 = context.logLevel) != null ? _context$logLevel2 : '')) console.error(errorMessage);
|
|
163
|
+
throw new FronteggApiError(isJsonResponse ? errorMessage : GENERIC_ERROR_MESSAGE, response.status);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (!opts.responseType || opts.responseType === 'json') {
|
|
167
|
+
try {
|
|
168
|
+
return await response.json();
|
|
169
|
+
} catch (e) {
|
|
170
|
+
return {};
|
|
171
|
+
}
|
|
172
|
+
} else if (opts.responseType === 'blob') {
|
|
173
|
+
const {
|
|
174
|
+
outputFileName
|
|
175
|
+
} = opts.params;
|
|
176
|
+
return await response.blob().then(blob => URL.createObjectURL(blob)).then(url => {
|
|
177
|
+
const tempLink = document.createElement('a');
|
|
178
|
+
tempLink.href = url;
|
|
179
|
+
tempLink.setAttribute('download', outputFileName || 'output');
|
|
180
|
+
tempLink.click();
|
|
181
|
+
});
|
|
182
|
+
} else {
|
|
183
|
+
return await response.text();
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
this.get = async (url, params, opts) => this.sendRequest(_extends({
|
|
188
|
+
url,
|
|
189
|
+
method: 'GET',
|
|
190
|
+
contentType: 'application/json',
|
|
191
|
+
params
|
|
192
|
+
}, opts));
|
|
193
|
+
|
|
194
|
+
this.post = async (url, body, opts) => this.sendRequest(_extends({
|
|
195
|
+
url,
|
|
196
|
+
method: 'POST',
|
|
197
|
+
contentType: 'application/json',
|
|
198
|
+
body
|
|
199
|
+
}, opts));
|
|
200
|
+
|
|
201
|
+
this.patch = async (url, body, opts) => this.sendRequest(_extends({
|
|
202
|
+
url,
|
|
203
|
+
method: 'PATCH',
|
|
204
|
+
contentType: 'application/json',
|
|
205
|
+
body
|
|
206
|
+
}, opts));
|
|
207
|
+
|
|
208
|
+
this.put = async (url, body, opts) => this.sendRequest(_extends({
|
|
209
|
+
url,
|
|
210
|
+
method: 'PUT',
|
|
211
|
+
contentType: 'application/json',
|
|
212
|
+
body
|
|
213
|
+
}, opts));
|
|
214
|
+
|
|
215
|
+
this.delete = async (url, body, opts) => this.sendRequest(_extends({
|
|
216
|
+
url,
|
|
217
|
+
method: 'DELETE',
|
|
218
|
+
contentType: 'application/json',
|
|
219
|
+
body
|
|
220
|
+
}, opts));
|
|
221
|
+
|
|
222
|
+
this.postDownload = async (url, body, params, opts) => this.sendRequest(_extends({
|
|
223
|
+
url,
|
|
224
|
+
method: 'POST',
|
|
225
|
+
contentType: 'application/json',
|
|
226
|
+
responseType: 'blob',
|
|
227
|
+
body,
|
|
228
|
+
params
|
|
229
|
+
}, opts));
|
|
230
|
+
|
|
231
|
+
this.extractHeadersFromOptions = (options = {}) => _extends({}, options.jwt ? {
|
|
232
|
+
Authorization: options.jwt
|
|
233
|
+
} : {});
|
|
234
|
+
|
|
235
|
+
this.getBaseUrl = (context, url, withFronteggPrefix = true) => {
|
|
236
|
+
return FetchClient.getBaseUrl(context, url, withFronteggPrefix);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
this.getContextBaseUrl = (url, withFronteggPrefix = true) => {
|
|
240
|
+
const context = this.getFronteggContext().getContext();
|
|
241
|
+
return this.getBaseUrl(context, url, withFronteggPrefix);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
this.getMetadataHeaders = context => {
|
|
245
|
+
return FetchClient.getMetadataHeaders(context);
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
this.getContextMetadataHeaders = () => {
|
|
249
|
+
const context = this.getFronteggContext().getContext();
|
|
250
|
+
return FetchClient.getMetadataHeaders(context);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
this.appName = appName;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
FetchClient.getBaseUrl = (context, url, withFronteggPrefix = true) => {
|
|
259
|
+
let baseUrl;
|
|
260
|
+
|
|
261
|
+
if (typeof context.baseUrl === 'function') {
|
|
262
|
+
baseUrl = context.baseUrl(url);
|
|
263
|
+
} else {
|
|
264
|
+
baseUrl = context.baseUrl;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const prefix = context.urlPrefix || 'frontegg';
|
|
268
|
+
const removePrefix = prefix === 'frontegg' && !withFronteggPrefix;
|
|
269
|
+
|
|
270
|
+
if (!baseUrl.endsWith('/')) {
|
|
271
|
+
baseUrl += '/';
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (!baseUrl.endsWith(prefix) && !removePrefix) {
|
|
275
|
+
baseUrl += prefix;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return baseUrl;
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
FetchClient.getMetadataHeaders = context => {
|
|
282
|
+
var _context$metadataHead, _context$metadataHead2;
|
|
283
|
+
|
|
284
|
+
const headers = {};
|
|
285
|
+
|
|
286
|
+
if (context != null && (_context$metadataHead = context.metadataHeaders) != null && _context$metadataHead.fronteggSdkVersion) {
|
|
287
|
+
headers[fronteggHeaders.fronteggSdkVersion] = context.metadataHeaders.fronteggSdkVersion;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (context != null && (_context$metadataHead2 = context.metadataHeaders) != null && _context$metadataHead2.framework) {
|
|
291
|
+
headers[fronteggHeaders.frameWork] = context.metadataHeaders.framework;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return headers;
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
FetchClient.getScopedTenant = () => {
|
|
298
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
299
|
+
const scopedTenant = urlParams.get('tenantId');
|
|
300
|
+
|
|
301
|
+
if (scopedTenant) {
|
|
302
|
+
return scopedTenant;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return null;
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
export default new FetchClient('default');
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { IPublicSettingsResponse, ISettingsResponse, IUpdateSettings } from "./interfaces";
|
|
2
2
|
import { UserJwtOptions } from "../interfaces";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
4
|
+
export declare class AccountSettingsApi extends BaseApiClient {
|
|
5
|
+
constructor(appName: string);
|
|
6
|
+
/**
|
|
7
|
+
* Update account settings for a tenant.
|
|
8
|
+
* TenantId is calculated in the backend from context of the `authorized user`.
|
|
9
|
+
*/
|
|
10
|
+
updateSettings: (body: IUpdateSettings, options?: UserJwtOptions | undefined) => Promise<ISettingsResponse>;
|
|
11
|
+
/**
|
|
12
|
+
* Get account settings for a tenant.
|
|
13
|
+
*/
|
|
14
|
+
getSettings: (options?: UserJwtOptions | undefined) => Promise<ISettingsResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Get public account settings.
|
|
17
|
+
*/
|
|
18
|
+
getPublicSettings: () => Promise<IPublicSettingsResponse>;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: AccountSettingsApi;
|
|
21
|
+
export default _default;
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import { urls } from "../constants";
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
3
|
+
export class AccountSettingsApi extends BaseApiClient {
|
|
4
|
+
constructor(appName) {
|
|
5
|
+
super(appName);
|
|
6
|
+
|
|
7
|
+
this.updateSettings = async (body, options) => {
|
|
8
|
+
return this.put(urls.tenants.accountSettings.v1, body, {
|
|
9
|
+
headers: this.extractHeadersFromOptions(options)
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
this.getSettings = async options => {
|
|
14
|
+
return this.get(urls.tenants.accountSettings.v1, undefined, {
|
|
15
|
+
headers: this.extractHeadersFromOptions(options)
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
this.getPublicSettings = async () => {
|
|
20
|
+
return this.get(`${urls.tenants.accountSettings.v1}/public`);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
7
24
|
}
|
|
8
|
-
export
|
|
9
|
-
return Get(urls.tenants.accountSettings.v1, undefined, {
|
|
10
|
-
headers: extractHeadersFromOptions(options)
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
export async function getPublicSettings() {
|
|
14
|
-
return Get(`${urls.tenants.accountSettings.v1}/public`);
|
|
15
|
-
}
|
|
25
|
+
export default new AccountSettingsApi('default');
|
package/applications/index.d.ts
CHANGED
|
@@ -1,46 +1,51 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
2
|
+
import { IUserApplicationsIdPayload, IUserApplicationsDataPayload, IApplicationsResponse, IAssignUserToApplicationsBody, IUsersApplicationsIdPayload, IUsersOfApplicationsResponse, ITenantApplicationsResponse, IGetUsersOfApplicationsQuery, IUsersApplicationsIdsResponse } from './interfaces';
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param userId - user id to find his applications id array
|
|
5
|
-
* @returns all app ids as string[]
|
|
4
|
+
* UsersApplicationsApi class for handling applications-related operations.
|
|
6
5
|
*/
|
|
7
|
-
export declare
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
6
|
+
export declare class ApplicationsApi extends BaseApiClient {
|
|
7
|
+
constructor(appName: string);
|
|
8
|
+
/**
|
|
9
|
+
* Get applications id array for a single user by user id.
|
|
10
|
+
* @param {IUserApplicationsIdPayload} param0 - user id to find their applications id array.
|
|
11
|
+
* @returns {Promise<string[]>} all app ids as string[].
|
|
12
|
+
*/
|
|
13
|
+
getUserApplicationsId: ({ userId }: IUserApplicationsIdPayload) => Promise<string[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Get applications id array for multiple users by user id array.
|
|
16
|
+
* @param {IUsersApplicationsIdPayload} param0 - array of all user ids.
|
|
17
|
+
* @returns {Promise<IUsersApplicationsIdsResponse[]>} object that maps every user id to its applications id array.
|
|
18
|
+
*/
|
|
19
|
+
getUsersApplicationsId: ({ userIds }: IUsersApplicationsIdPayload) => Promise<IUsersApplicationsIdsResponse[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Get applications data array for a specific tenant.
|
|
22
|
+
* @returns {Promise<ITenantApplicationsResponse[]>} array of objects with tenant id and its applications id array.
|
|
23
|
+
*/
|
|
24
|
+
getTenantsApplications: () => Promise<ITenantApplicationsResponse[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Get applications data by array of application ids.
|
|
27
|
+
* @param {IUserApplicationsDataPayload} param0 - array of application ids.
|
|
28
|
+
* @returns {Promise<IApplicationsResponse[]>} array of application data.
|
|
29
|
+
*/
|
|
30
|
+
getApplicationsData: ({ appIds, includeFreeAccess }: IUserApplicationsDataPayload) => Promise<IApplicationsResponse[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Assign user to multiple applications.
|
|
33
|
+
* @param {IAssignUserToApplicationsBody} body - assignment details.
|
|
34
|
+
* @returns {Promise<void>}
|
|
35
|
+
*/
|
|
36
|
+
assignUserToApplications: (body: IAssignUserToApplicationsBody) => Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Unassign user from multiple applications.
|
|
39
|
+
* @param {IAssignUserToApplicationsBody} body - unassignment details.
|
|
40
|
+
* @returns {Promise<void>}
|
|
41
|
+
*/
|
|
42
|
+
unassignUserFromApplications: (body: IAssignUserToApplicationsBody) => Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Get users array for each application for an array of applications.
|
|
45
|
+
* @param {IGetUsersOfApplicationsQuery} param0 - array of applications.
|
|
46
|
+
* @returns {Promise<IUsersOfApplicationsResponse[]>} array of objects with application id and its users array.
|
|
47
|
+
*/
|
|
48
|
+
getUsersOfApplications: ({ appIds }: IGetUsersOfApplicationsQuery) => Promise<IUsersOfApplicationsResponse[]>;
|
|
49
|
+
}
|
|
50
|
+
declare const _default: ApplicationsApi;
|
|
51
|
+
export default _default;
|
package/applications/index.js
CHANGED
|
@@ -1,39 +1,53 @@
|
|
|
1
1
|
import { urls } from "../constants";
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
3
|
+
export class ApplicationsApi extends BaseApiClient {
|
|
4
|
+
constructor(appName) {
|
|
5
|
+
super(appName);
|
|
6
|
+
|
|
7
|
+
this.getUserApplicationsId = async ({
|
|
8
|
+
userId
|
|
9
|
+
}) => {
|
|
10
|
+
return this.get(`${urls.identity.applications.v1}/${userId}/apps`);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
this.getUsersApplicationsId = async ({
|
|
14
|
+
userIds
|
|
15
|
+
}) => {
|
|
16
|
+
return this.get(`${urls.identity.applications.v1}/users-apps`, {
|
|
17
|
+
userIds: userIds.join(',')
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
this.getTenantsApplications = async () => {
|
|
22
|
+
return this.get(urls.applications.tenant.v1);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
this.getApplicationsData = async ({
|
|
26
|
+
appIds,
|
|
27
|
+
includeFreeAccess = true
|
|
28
|
+
}) => {
|
|
29
|
+
return this.get(urls.applications.v1, {
|
|
30
|
+
ids: appIds.join(','),
|
|
31
|
+
_includeFreeAccess: includeFreeAccess
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
this.assignUserToApplications = async body => {
|
|
36
|
+
return this.post(`${urls.identity.applications.v1}/apps-user`, body);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
this.unassignUserFromApplications = async body => {
|
|
40
|
+
return this.delete(`${urls.identity.applications.v1}/user-apps`, body);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
this.getUsersOfApplications = async ({
|
|
44
|
+
appIds
|
|
45
|
+
}) => {
|
|
46
|
+
return this.get(`${urls.identity.applications.v1}/apps-users`, {
|
|
47
|
+
appIds: appIds.join(',')
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
7
52
|
}
|
|
8
|
-
export
|
|
9
|
-
userIds
|
|
10
|
-
}) {
|
|
11
|
-
return Get(`${urls.identity.applications.v1}/users-apps`, {
|
|
12
|
-
userIds: userIds.join(',')
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
export async function getTenantsApplications() {
|
|
16
|
-
return Get(urls.applications.tenant.v1);
|
|
17
|
-
}
|
|
18
|
-
export async function getApplicationsData({
|
|
19
|
-
appIds,
|
|
20
|
-
includeFreeAccess = true
|
|
21
|
-
}) {
|
|
22
|
-
return Get(urls.applications.v1, {
|
|
23
|
-
ids: appIds.join(','),
|
|
24
|
-
_includeFreeAccess: includeFreeAccess
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
export async function assignUserToApplications(body) {
|
|
28
|
-
return Post(`${urls.identity.applications.v1}/apps-user`, body);
|
|
29
|
-
}
|
|
30
|
-
export async function unassignUserFromApplications(body) {
|
|
31
|
-
return Delete(`${urls.identity.applications.v1}/user-apps`, body);
|
|
32
|
-
}
|
|
33
|
-
export async function getUsersOfApplications({
|
|
34
|
-
appIds
|
|
35
|
-
}) {
|
|
36
|
-
return Get(`${urls.identity.applications.v1}/apps-users`, {
|
|
37
|
-
appIds: appIds.join(',')
|
|
38
|
-
});
|
|
39
|
-
}
|
|
53
|
+
export default new ApplicationsApi('default');
|
package/audits/index.d.ts
CHANGED
|
@@ -1,16 +1,28 @@
|
|
|
1
1
|
import { IAudits, IAuditsStats, IGetAuditsParams, IGetAuditsStatsParams, IExportAudits } from './interfaces';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
3
|
+
export declare class AuditsApi extends BaseApiClient {
|
|
4
|
+
constructor(appName: string);
|
|
5
|
+
/**
|
|
6
|
+
* Fetches audit logs based on the provided parameters.
|
|
7
|
+
*
|
|
8
|
+
* @param params - Parameters to filter and paginate audits.
|
|
9
|
+
* @returns A promise that resolves to the list of audits.
|
|
10
|
+
*/
|
|
11
|
+
getAudits: (params: IGetAuditsParams) => Promise<IAudits>;
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves audit statistics based on the provided parameters.
|
|
14
|
+
*
|
|
15
|
+
* @param params - Parameters to filter and define the scope of the stats.
|
|
16
|
+
* @returns A promise that resolves to the audits statistics.
|
|
17
|
+
*/
|
|
18
|
+
getAuditsStats: (params: IGetAuditsStatsParams) => Promise<IAuditsStats>;
|
|
19
|
+
/**
|
|
20
|
+
* Exports audit logs based on the provided parameters.
|
|
21
|
+
*
|
|
22
|
+
* @param params - Parameters including endpoint, header properties, and other request specifics.
|
|
23
|
+
* @returns A promise that initiates a download for the exported audits.
|
|
24
|
+
*/
|
|
25
|
+
exportAudits: (params: IExportAudits) => Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
declare const _default: AuditsApi;
|
|
28
|
+
export default _default;
|
package/audits/index.js
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
2
2
|
const _excluded = ["endpoint", "headerProps"];
|
|
3
|
-
import { Get, PostDownload } from '../fetch';
|
|
4
3
|
import { urls } from '../constants';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
5
|
+
export class AuditsApi extends BaseApiClient {
|
|
6
|
+
constructor(appName) {
|
|
7
|
+
super(appName);
|
|
8
|
+
|
|
9
|
+
this.getAudits = async params => {
|
|
10
|
+
return this.get(urls.audits.v1, params);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
this.getAuditsStats = async params => {
|
|
14
|
+
return this.get(`${urls.audits.v1}/stats`, params);
|
|
15
|
+
};
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
this.exportAudits = async params => {
|
|
18
|
+
const {
|
|
19
|
+
endpoint,
|
|
20
|
+
headerProps
|
|
21
|
+
} = params,
|
|
22
|
+
restParams = _objectWithoutPropertiesLoose(params, _excluded);
|
|
23
|
+
|
|
24
|
+
return this.postDownload(`${urls.audits.v1}/export/${endpoint}`, {
|
|
25
|
+
properties: headerProps
|
|
26
|
+
}, restParams);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
export default new AuditsApi('default');
|