@frontegg/rest-api 6.0.1-alpha.4 → 7.28.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BaseApiClient.d.ts +16 -0
- package/BaseApiClient.js +30 -0
- package/ContextHolder/index.d.ts +160 -0
- package/ContextHolder/index.js +278 -0
- package/ContextHolder/package.json +6 -0
- package/FetchClient.d.ts +42 -0
- package/FetchClient.js +260 -0
- package/account-settings/index.d.ts +21 -7
- package/account-settings/index.js +25 -6
- package/account-settings/interfaces.d.ts +9 -2
- package/applications/index.d.ts +51 -0
- package/applications/index.js +55 -0
- package/applications/interfaces.d.ts +49 -0
- package/applications/interfaces.js +5 -0
- package/applications/package.json +6 -0
- package/audits/index.d.ts +27 -15
- package/audits/index.js +29 -16
- package/audits/interfaces.d.ts +3 -2
- package/auth/constants.d.ts +5 -0
- package/auth/constants.js +5 -0
- package/auth/enums.d.ts +8 -1
- package/auth/enums.js +9 -4
- package/auth/index.d.ts +833 -428
- package/auth/index.js +768 -385
- package/auth/interfaces.d.ts +341 -39
- package/auth/interfaces.js +19 -9
- package/auth/secutiry-poilicy/index.d.ts +60 -41
- package/auth/secutiry-poilicy/index.js +99 -45
- package/auth/secutiry-poilicy/interfaces.d.ts +62 -2
- package/auth/secutiry-poilicy/interfaces.js +5 -1
- package/auth/utils.d.ts +10 -0
- package/auth/utils.js +35 -0
- package/connectivity/index.d.ts +126 -27
- package/connectivity/index.js +120 -114
- package/constants.d.ts +115 -0
- package/constants.js +122 -5
- package/directory/index.d.ts +32 -0
- package/directory/index.js +30 -0
- package/directory/interfaces.d.ts +30 -0
- package/directory/interfaces.js +7 -0
- package/directory/package.json +6 -0
- package/entitlements/index.d.ts +15 -0
- package/entitlements/index.js +20 -0
- package/entitlements/interfaces.d.ts +13 -0
- package/entitlements/interfaces.js +11 -0
- package/entitlements/package.json +6 -0
- package/error.js +0 -2
- package/feature-flags/index.d.ts +18 -0
- package/feature-flags/index.js +44 -0
- package/feature-flags/interfaces.d.ts +5 -0
- package/feature-flags/interfaces.js +1 -0
- package/feature-flags/package.json +6 -0
- package/groups/enums.d.ts +9 -0
- package/groups/enums.js +11 -0
- package/groups/index.d.ts +73 -0
- package/groups/index.js +62 -0
- package/groups/interfaces.d.ts +64 -0
- package/groups/interfaces.js +1 -0
- package/groups/package.json +6 -0
- package/impersonate/index.d.ts +17 -0
- package/impersonate/index.js +23 -0
- package/impersonate/interfaces.d.ts +12 -0
- package/impersonate/interfaces.js +1 -0
- package/impersonate/package.json +6 -0
- package/index.d.ts +148 -53
- package/index.js +103 -31
- package/interfaces.d.ts +82 -1
- package/interfaces.js +28 -1
- package/jwt.js +19 -20
- package/metadata/index.d.ts +68 -5
- package/metadata/index.js +53 -23
- package/metadata/interfaces.d.ts +10 -2
- package/node/BaseApiClient.js +37 -0
- package/node/ContextHolder/index.js +286 -0
- package/node/FetchClient.js +268 -0
- package/node/account-settings/index.js +26 -11
- package/node/applications/index.js +62 -0
- package/node/applications/interfaces.js +12 -0
- package/node/audits/index.js +32 -27
- package/node/auth/constants.js +13 -0
- package/node/auth/enums.js +11 -5
- package/node/auth/index.js +807 -644
- package/node/auth/interfaces.js +27 -13
- package/node/auth/secutiry-poilicy/index.js +100 -66
- package/node/auth/secutiry-poilicy/interfaces.js +8 -1
- package/node/auth/utils.js +44 -0
- package/node/connectivity/index.js +123 -197
- package/node/constants.js +124 -6
- package/node/directory/index.js +37 -0
- package/node/directory/interfaces.js +14 -0
- package/node/entitlements/index.js +27 -0
- package/node/entitlements/interfaces.js +18 -0
- package/node/error.js +0 -4
- package/node/feature-flags/index.js +54 -0
- package/node/feature-flags/interfaces.js +5 -0
- package/node/groups/enums.js +19 -0
- package/node/groups/index.js +70 -0
- package/node/groups/interfaces.js +5 -0
- package/node/impersonate/index.js +29 -0
- package/node/impersonate/interfaces.js +5 -0
- package/node/index.js +324 -94
- package/node/interfaces.js +34 -1
- package/node/jwt.js +19 -25
- package/node/metadata/index.js +57 -38
- package/node/notifications/index.js +34 -31
- package/node/reports/index.js +79 -83
- package/node/roles/index.js +55 -60
- package/node/roles/interfaces.js +9 -1
- package/node/routers.js +52 -6
- package/node/security-center/index.js +26 -0
- package/node/security-center/interfaces.js +74 -0
- package/node/sub-tenants/index.js +82 -29
- package/node/sub-tenants/interfaces.js +9 -1
- package/node/subscriptions/enums.js +13 -9
- package/node/subscriptions/index.js +64 -109
- package/node/subscriptions/interfaces.js +0 -2
- package/node/subscriptions/invoices.js +20 -21
- package/node/subscriptions/managedSubscriptions.js +28 -33
- package/node/subscriptions/paymentMethods.js +23 -27
- package/node/subscriptions/paymentProviders.js +11 -8
- package/node/subscriptions/plans.js +13 -12
- package/node/subscriptions/providers/stripe/index.js +22 -27
- package/node/subscriptions/subscriptions.js +28 -33
- package/node/subscriptions/summaries.js +11 -8
- package/node/subscriptions/tenantConfiguration.js +13 -12
- package/node/subscriptions/vendorPublicConfigurations.js +17 -0
- package/node/teams/index.js +108 -121
- package/node/teams/interfaces.js +8 -1
- package/node/tenants/index.js +63 -21
- package/node/tenants/interfaces.js +18 -1
- package/node/user-phone-numbers/index.js +38 -0
- package/node/user-phone-numbers/interfaces.js +5 -0
- package/node/users/index.js +64 -0
- package/node/users/interfaces.js +27 -0
- package/node/velo/index.js +75 -0
- package/node/velo/interfaces.js +5 -0
- package/node/vendor/index.js +16 -8
- package/notifications/index.d.ts +22 -16
- package/notifications/index.js +33 -22
- package/package.json +4 -2
- package/reports/index.d.ts +50 -44
- package/reports/index.js +77 -68
- package/reports/interfaces.d.ts +2 -2
- package/roles/index.d.ts +45 -34
- package/roles/index.js +52 -41
- package/roles/interfaces.d.ts +25 -9
- package/roles/interfaces.js +6 -1
- package/routers.d.ts +6 -1
- package/routers.js +45 -2
- package/security-center/index.d.ts +15 -0
- package/security-center/index.js +19 -0
- package/security-center/interfaces.d.ts +115 -0
- package/security-center/interfaces.js +63 -0
- package/security-center/package.json +6 -0
- package/sub-tenants/index.d.ts +57 -8
- package/sub-tenants/index.js +84 -19
- package/sub-tenants/interfaces.d.ts +68 -10
- package/sub-tenants/interfaces.js +6 -1
- package/subscriptions/enums.d.ts +7 -0
- package/subscriptions/enums.js +10 -8
- package/subscriptions/index.d.ts +55 -9
- package/subscriptions/index.js +56 -9
- package/subscriptions/interfaces.d.ts +7 -3
- package/subscriptions/interfaces.js +1 -1
- package/subscriptions/invoices.d.ts +16 -13
- package/subscriptions/invoices.js +19 -14
- package/subscriptions/managedSubscriptions.d.ts +18 -15
- package/subscriptions/managedSubscriptions.js +27 -22
- package/subscriptions/paymentMethods.d.ts +16 -13
- package/subscriptions/paymentMethods.js +22 -18
- package/subscriptions/paymentProviders.d.ts +8 -5
- package/subscriptions/paymentProviders.js +9 -4
- package/subscriptions/plans.d.ts +11 -8
- package/subscriptions/plans.js +11 -6
- package/subscriptions/providers/stripe/index.d.ts +24 -21
- package/subscriptions/providers/stripe/index.js +21 -16
- package/subscriptions/subscriptions.d.ts +24 -21
- package/subscriptions/subscriptions.js +27 -22
- package/subscriptions/summaries.d.ts +7 -4
- package/subscriptions/summaries.js +8 -3
- package/subscriptions/tenantConfiguration.d.ts +6 -3
- package/subscriptions/tenantConfiguration.js +12 -7
- package/subscriptions/vendorPublicConfigurations.d.ts +5 -0
- package/subscriptions/vendorPublicConfigurations.js +10 -0
- package/teams/index.d.ts +38 -115
- package/teams/index.js +105 -79
- package/teams/interfaces.d.ts +47 -42
- package/teams/interfaces.js +5 -1
- package/tenants/index.d.ts +25 -26
- package/tenants/index.js +61 -12
- package/tenants/interfaces.d.ts +85 -0
- package/tenants/interfaces.js +14 -1
- package/user-phone-numbers/index.d.ts +32 -0
- package/user-phone-numbers/index.js +31 -0
- package/user-phone-numbers/interfaces.d.ts +32 -0
- package/user-phone-numbers/interfaces.js +1 -0
- package/user-phone-numbers/package.json +6 -0
- package/users/index.d.ts +24 -0
- package/users/index.js +55 -0
- package/users/interfaces.d.ts +144 -0
- package/users/interfaces.js +18 -0
- package/users/package.json +6 -0
- package/velo/index.d.ts +46 -0
- package/velo/index.js +68 -0
- package/velo/interfaces.d.ts +108 -0
- package/velo/interfaces.js +1 -0
- package/velo/package.json +6 -0
- package/vendor/index.d.ts +12 -6
- package/vendor/index.js +15 -4
- package/ContextHolder.d.ts +0 -29
- package/ContextHolder.js +0 -80
- package/fetch.d.ts +0 -19
- package/fetch.js +0 -203
- package/node/ContextHolder.js +0 -90
- package/node/fetch.js +0 -234
- 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,260 @@
|
|
|
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
|
+
|
|
7
|
+
/**
|
|
8
|
+
* FetchClient is a class that wrap around the fetch API to make requests.
|
|
9
|
+
* It is used by the BaseApiClient to make requests to the server
|
|
10
|
+
*/
|
|
11
|
+
export class FetchClient {
|
|
12
|
+
constructor(appName) {
|
|
13
|
+
this.appName = void 0;
|
|
14
|
+
this.getFronteggContext = () => {
|
|
15
|
+
return ContextHolder.for(this.appName);
|
|
16
|
+
};
|
|
17
|
+
this.prepareUrl = async (url, params) => {
|
|
18
|
+
const context = this.getFronteggContext().getContext();
|
|
19
|
+
const baseUrl = this.getContextBaseUrl(url);
|
|
20
|
+
const paramsToSend = await this.buildQueryParams(context, params);
|
|
21
|
+
let finalUrl = url.startsWith('http') ? url : `${baseUrl}${url}`;
|
|
22
|
+
const hasKeys = Object.keys(paramsToSend).length > 0;
|
|
23
|
+
if (paramsToSend && hasKeys) {
|
|
24
|
+
const urlParams = new URLSearchParams(paramsToSend);
|
|
25
|
+
finalUrl += `?${urlParams}`;
|
|
26
|
+
}
|
|
27
|
+
return finalUrl;
|
|
28
|
+
};
|
|
29
|
+
this.buildQueryParams = async (context, params) => {
|
|
30
|
+
if (!params) {
|
|
31
|
+
params = {};
|
|
32
|
+
}
|
|
33
|
+
const additionalQueryParams = await this.getAdditionalQueryParams(context);
|
|
34
|
+
for (const queryParam of additionalQueryParams) {
|
|
35
|
+
params[queryParam.key] = queryParam.value;
|
|
36
|
+
}
|
|
37
|
+
const keys = Object.keys(params);
|
|
38
|
+
for (const key of keys) {
|
|
39
|
+
const value = params[key];
|
|
40
|
+
params[key] = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
41
|
+
}
|
|
42
|
+
return params;
|
|
43
|
+
};
|
|
44
|
+
this.getAdditionalQueryParams = async context => {
|
|
45
|
+
let output = [];
|
|
46
|
+
if (context.additionalQueryParamsResolver) {
|
|
47
|
+
output = await context.additionalQueryParamsResolver();
|
|
48
|
+
}
|
|
49
|
+
return output;
|
|
50
|
+
};
|
|
51
|
+
this.getAdditionalHeaders = async context => {
|
|
52
|
+
let output = [];
|
|
53
|
+
if (context.additionalHeadersResolver) {
|
|
54
|
+
output = await context.additionalHeadersResolver();
|
|
55
|
+
}
|
|
56
|
+
if (context.tenantResolver) {
|
|
57
|
+
const resolvedTenantResult = await context.tenantResolver();
|
|
58
|
+
if (!!(resolvedTenantResult != null && resolvedTenantResult.tenant)) {
|
|
59
|
+
output.push({
|
|
60
|
+
key: 'frontegg-login-alias',
|
|
61
|
+
value: resolvedTenantResult.tenant
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (context.appId) {
|
|
66
|
+
output.push({
|
|
67
|
+
key: 'frontegg-requested-application-id',
|
|
68
|
+
value: context.appId
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return output;
|
|
72
|
+
};
|
|
73
|
+
this.buildRequestHeaders = async contentType => {
|
|
74
|
+
var _context$tokenResolve;
|
|
75
|
+
const fronteggContext = this.getFronteggContext();
|
|
76
|
+
const context = fronteggContext.getContext();
|
|
77
|
+
const headers = FetchClient.getMetadataHeaders(context);
|
|
78
|
+
const authToken = await ((_context$tokenResolve = context == null ? void 0 : context.tokenResolver) != null ? _context$tokenResolve : fronteggContext.getAccessToken)();
|
|
79
|
+
const requestSource = fronteggContext.getRequestSource();
|
|
80
|
+
const scopedTenant = FetchClient.getScopedTenant();
|
|
81
|
+
if (contentType) {
|
|
82
|
+
headers[fronteggHeaders.contentType] = contentType;
|
|
83
|
+
}
|
|
84
|
+
if (requestSource) {
|
|
85
|
+
headers[fronteggHeaders.source] = requestSource;
|
|
86
|
+
}
|
|
87
|
+
if (authToken) {
|
|
88
|
+
headers.Authorization = `Bearer ${authToken}`;
|
|
89
|
+
}
|
|
90
|
+
if (scopedTenant) {
|
|
91
|
+
headers[fronteggHeaders.scopedTenant] = scopedTenant;
|
|
92
|
+
}
|
|
93
|
+
for (const additionalHeader of await this.getAdditionalHeaders(context)) {
|
|
94
|
+
headers[`${additionalHeader.key}`] = `${additionalHeader.value}`;
|
|
95
|
+
}
|
|
96
|
+
return headers;
|
|
97
|
+
};
|
|
98
|
+
this.sendRequest = async opts => {
|
|
99
|
+
var _opts$method, _ref, _opts$credentials;
|
|
100
|
+
const context = this.getFronteggContext().getContext();
|
|
101
|
+
const headers = await this.buildRequestHeaders(opts.contentType);
|
|
102
|
+
const url = await this.prepareUrl(opts.url, opts.params);
|
|
103
|
+
const interceptor = context.beforeRequestInterceptor;
|
|
104
|
+
const initialRequestOptions = {
|
|
105
|
+
body: opts.body ? opts.contentType === 'application/json' ? JSON.stringify(opts.body) : opts.body : null,
|
|
106
|
+
method: (_opts$method = opts.method) != null ? _opts$method : 'GET',
|
|
107
|
+
headers: _extends({}, headers, opts.headers),
|
|
108
|
+
credentials: (_ref = (_opts$credentials = opts.credentials) != null ? _opts$credentials : context.requestCredentials) != null ? _ref : 'same-origin'
|
|
109
|
+
};
|
|
110
|
+
const requestOptions = interceptor ? interceptor(initialRequestOptions, url) : initialRequestOptions;
|
|
111
|
+
const response = await fetch(url, requestOptions);
|
|
112
|
+
if (response.status === 302) {
|
|
113
|
+
window.location.href = await response.text();
|
|
114
|
+
return new Promise(() => {});
|
|
115
|
+
}
|
|
116
|
+
if (!response.ok) {
|
|
117
|
+
var _context$logLevel, _context$logLevel2;
|
|
118
|
+
if (response.status === 413) {
|
|
119
|
+
throw new FronteggApiError('Error request is too large', response.status);
|
|
120
|
+
}
|
|
121
|
+
let errorMessage;
|
|
122
|
+
let isJsonResponse = true;
|
|
123
|
+
try {
|
|
124
|
+
errorMessage = await response.text();
|
|
125
|
+
errorMessage = JSON.parse(errorMessage);
|
|
126
|
+
} catch (e) {
|
|
127
|
+
isJsonResponse = false;
|
|
128
|
+
}
|
|
129
|
+
if (errorMessage.errors) {
|
|
130
|
+
errorMessage = errorMessage.errors.join(', ');
|
|
131
|
+
} else if (typeof errorMessage !== 'string') {
|
|
132
|
+
errorMessage = `Error ${response.status} - ${response.statusText}`;
|
|
133
|
+
}
|
|
134
|
+
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);
|
|
135
|
+
throw new FronteggApiError(isJsonResponse ? errorMessage : GENERIC_ERROR_MESSAGE, response.status);
|
|
136
|
+
}
|
|
137
|
+
if (opts.responseType === 'stream') {
|
|
138
|
+
return response.body;
|
|
139
|
+
}
|
|
140
|
+
if (!opts.responseType || opts.responseType === 'json') {
|
|
141
|
+
try {
|
|
142
|
+
return await response.json();
|
|
143
|
+
} catch (e) {
|
|
144
|
+
return {};
|
|
145
|
+
}
|
|
146
|
+
} else if (opts.responseType === 'blob') {
|
|
147
|
+
const {
|
|
148
|
+
outputFileName
|
|
149
|
+
} = opts.params;
|
|
150
|
+
return await response.blob().then(blob => URL.createObjectURL(blob)).then(url => {
|
|
151
|
+
const tempLink = document.createElement('a');
|
|
152
|
+
tempLink.href = url;
|
|
153
|
+
tempLink.setAttribute('download', outputFileName || 'output');
|
|
154
|
+
tempLink.click();
|
|
155
|
+
});
|
|
156
|
+
} else {
|
|
157
|
+
return await response.text();
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
this.get = async (url, params, opts) => this.sendRequest(_extends({
|
|
161
|
+
url,
|
|
162
|
+
method: 'GET',
|
|
163
|
+
contentType: 'application/json',
|
|
164
|
+
params
|
|
165
|
+
}, opts));
|
|
166
|
+
this.post = async (url, body, opts) => this.sendRequest(_extends({
|
|
167
|
+
url,
|
|
168
|
+
method: 'POST',
|
|
169
|
+
contentType: 'application/json',
|
|
170
|
+
body
|
|
171
|
+
}, opts));
|
|
172
|
+
this.patch = async (url, body, opts) => this.sendRequest(_extends({
|
|
173
|
+
url,
|
|
174
|
+
method: 'PATCH',
|
|
175
|
+
contentType: 'application/json',
|
|
176
|
+
body
|
|
177
|
+
}, opts));
|
|
178
|
+
this.put = async (url, body, opts) => this.sendRequest(_extends({
|
|
179
|
+
url,
|
|
180
|
+
method: 'PUT',
|
|
181
|
+
contentType: 'application/json',
|
|
182
|
+
body
|
|
183
|
+
}, opts));
|
|
184
|
+
this.delete = async (url, body, opts) => this.sendRequest(_extends({
|
|
185
|
+
url,
|
|
186
|
+
method: 'DELETE',
|
|
187
|
+
contentType: 'application/json',
|
|
188
|
+
body
|
|
189
|
+
}, opts));
|
|
190
|
+
this.postDownload = async (url, body, params, opts) => this.sendRequest(_extends({
|
|
191
|
+
url,
|
|
192
|
+
method: 'POST',
|
|
193
|
+
contentType: 'application/json',
|
|
194
|
+
responseType: 'blob',
|
|
195
|
+
body,
|
|
196
|
+
params
|
|
197
|
+
}, opts));
|
|
198
|
+
this.extractHeadersFromOptions = (options = {}) => _extends({}, options.jwt ? {
|
|
199
|
+
Authorization: options.jwt
|
|
200
|
+
} : {});
|
|
201
|
+
this.getBaseUrl = (context, url, withFronteggPrefix = true) => {
|
|
202
|
+
return FetchClient.getBaseUrl(context, url, withFronteggPrefix);
|
|
203
|
+
};
|
|
204
|
+
this.getContextBaseUrl = (url, withFronteggPrefix = true) => {
|
|
205
|
+
const context = this.getFronteggContext().getContext();
|
|
206
|
+
return this.getBaseUrl(context, url, withFronteggPrefix);
|
|
207
|
+
};
|
|
208
|
+
this.getMetadataHeaders = context => {
|
|
209
|
+
return FetchClient.getMetadataHeaders(context);
|
|
210
|
+
};
|
|
211
|
+
this.getContextMetadataHeaders = () => {
|
|
212
|
+
const context = this.getFronteggContext().getContext();
|
|
213
|
+
return FetchClient.getMetadataHeaders(context);
|
|
214
|
+
};
|
|
215
|
+
this.appName = appName;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* import FetchClient and use it to make requests to the server for specific application
|
|
221
|
+
* @param appName - the application name to make requests for
|
|
222
|
+
* @deprecated - use FetchClient directly
|
|
223
|
+
*/
|
|
224
|
+
FetchClient.getBaseUrl = (context, url, withFronteggPrefix = true) => {
|
|
225
|
+
let baseUrl;
|
|
226
|
+
if (typeof context.baseUrl === 'function') {
|
|
227
|
+
baseUrl = context.baseUrl(url);
|
|
228
|
+
} else {
|
|
229
|
+
baseUrl = context.baseUrl;
|
|
230
|
+
}
|
|
231
|
+
const prefix = context.urlPrefix || 'frontegg';
|
|
232
|
+
const removePrefix = prefix === 'frontegg' && !withFronteggPrefix;
|
|
233
|
+
if (!baseUrl.endsWith('/')) {
|
|
234
|
+
baseUrl += '/';
|
|
235
|
+
}
|
|
236
|
+
if (!baseUrl.endsWith(prefix) && !removePrefix) {
|
|
237
|
+
baseUrl += prefix;
|
|
238
|
+
}
|
|
239
|
+
return baseUrl;
|
|
240
|
+
};
|
|
241
|
+
FetchClient.getMetadataHeaders = context => {
|
|
242
|
+
var _context$metadataHead, _context$metadataHead2;
|
|
243
|
+
const headers = {};
|
|
244
|
+
if (context != null && (_context$metadataHead = context.metadataHeaders) != null && _context$metadataHead.fronteggSdkVersion) {
|
|
245
|
+
headers[fronteggHeaders.fronteggSdkVersion] = context.metadataHeaders.fronteggSdkVersion;
|
|
246
|
+
}
|
|
247
|
+
if (context != null && (_context$metadataHead2 = context.metadataHeaders) != null && _context$metadataHead2.framework) {
|
|
248
|
+
headers[fronteggHeaders.frameWork] = context.metadataHeaders.framework;
|
|
249
|
+
}
|
|
250
|
+
return headers;
|
|
251
|
+
};
|
|
252
|
+
FetchClient.getScopedTenant = () => {
|
|
253
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
254
|
+
const scopedTenant = urlParams.get('tenantId');
|
|
255
|
+
if (scopedTenant) {
|
|
256
|
+
return scopedTenant;
|
|
257
|
+
}
|
|
258
|
+
return null;
|
|
259
|
+
};
|
|
260
|
+
export default new FetchClient('default');
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import { ISettingsResponse, IUpdateSettings } from './interfaces';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { IPublicSettingsResponse, ISettingsResponse, IUpdateSettings } from './interfaces';
|
|
2
|
+
import { UserJwtOptions } from '../interfaces';
|
|
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) => Promise<ISettingsResponse>;
|
|
11
|
+
/**
|
|
12
|
+
* Get account settings for a tenant.
|
|
13
|
+
*/
|
|
14
|
+
getSettings: (options?: UserJwtOptions) => Promise<ISettingsResponse>;
|
|
15
|
+
/**
|
|
16
|
+
* Get public account settings.
|
|
17
|
+
*/
|
|
18
|
+
getPublicSettings: () => Promise<IPublicSettingsResponse>;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: AccountSettingsApi;
|
|
21
|
+
export default _default;
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import { urls } from '../constants';
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
2
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
3
|
+
export class AccountSettingsApi extends BaseApiClient {
|
|
4
|
+
constructor(appName) {
|
|
5
|
+
super(appName);
|
|
6
|
+
this.updateSettings = async (body, options) => {
|
|
7
|
+
return this.put(urls.tenants.accountSettings.v1, body, {
|
|
8
|
+
headers: this.extractHeadersFromOptions(options)
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
this.getSettings = async options => {
|
|
12
|
+
return this.get(urls.tenants.accountSettings.v1, undefined, {
|
|
13
|
+
headers: this.extractHeadersFromOptions(options)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
this.getPublicSettings = async () => {
|
|
17
|
+
return this.get(`${urls.tenants.accountSettings.v1}/public`);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Update account settings for a tenant.
|
|
23
|
+
* TenantId is calculated in the backend from context of the `authorized user`.
|
|
24
|
+
*/
|
|
5
25
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
26
|
+
|
|
27
|
+
export default new AccountSettingsApi('default');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface ISettingsResponse {
|
|
1
|
+
export interface ISettingsResponse extends Partial<IPublicSettingsResponse> {
|
|
2
2
|
address?: string;
|
|
3
3
|
timezone?: string;
|
|
4
4
|
dateFormat?: string;
|
|
@@ -6,4 +6,11 @@ export interface ISettingsResponse {
|
|
|
6
6
|
currency?: string;
|
|
7
7
|
logo?: string;
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export interface IPublicSettingsResponse {
|
|
10
|
+
tenantId: string;
|
|
11
|
+
applicationUrl?: string;
|
|
12
|
+
loginUrl?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface IUpdateSettings extends ISettingsResponse {
|
|
15
|
+
name?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
2
|
+
import { IUserApplicationsIdPayload, IUserApplicationsDataPayload, IApplicationsResponse, IAssignUserToApplicationsBody, IUsersApplicationsIdPayload, IUsersOfApplicationsResponse, ITenantApplicationsResponse, IGetUsersOfApplicationsQuery, IUsersApplicationsIdsResponse } from './interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* UsersApplicationsApi class for handling applications-related operations.
|
|
5
|
+
*/
|
|
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;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { urls } from '../constants';
|
|
2
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
3
|
+
/**
|
|
4
|
+
* UsersApplicationsApi class for handling applications-related operations.
|
|
5
|
+
*/
|
|
6
|
+
export class ApplicationsApi extends BaseApiClient {
|
|
7
|
+
constructor(appName) {
|
|
8
|
+
super(appName);
|
|
9
|
+
this.getUserApplicationsId = async ({
|
|
10
|
+
userId
|
|
11
|
+
}) => {
|
|
12
|
+
return this.get(`${urls.identity.applications.v1}/${userId}/apps`);
|
|
13
|
+
};
|
|
14
|
+
this.getUsersApplicationsId = async ({
|
|
15
|
+
userIds
|
|
16
|
+
}) => {
|
|
17
|
+
return this.get(`${urls.identity.applications.v1}/users-apps`, {
|
|
18
|
+
userIds: userIds.join(',')
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
this.getTenantsApplications = async () => {
|
|
22
|
+
return this.get(urls.applications.tenant.v1);
|
|
23
|
+
};
|
|
24
|
+
this.getApplicationsData = async ({
|
|
25
|
+
appIds,
|
|
26
|
+
includeFreeAccess = true
|
|
27
|
+
}) => {
|
|
28
|
+
return this.get(urls.applications.v1, {
|
|
29
|
+
ids: appIds.join(','),
|
|
30
|
+
_includeFreeAccess: includeFreeAccess
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
this.assignUserToApplications = async body => {
|
|
34
|
+
return this.post(`${urls.identity.applications.v1}/apps-user`, body);
|
|
35
|
+
};
|
|
36
|
+
this.unassignUserFromApplications = async body => {
|
|
37
|
+
return this.delete(`${urls.identity.applications.v1}/user-apps`, body);
|
|
38
|
+
};
|
|
39
|
+
this.getUsersOfApplications = async ({
|
|
40
|
+
appIds
|
|
41
|
+
}) => {
|
|
42
|
+
return this.get(`${urls.identity.applications.v1}/apps-users`, {
|
|
43
|
+
appIds: appIds.join(',')
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Get applications id array for a single user by user id.
|
|
50
|
+
* @param {IUserApplicationsIdPayload} param0 - user id to find their applications id array.
|
|
51
|
+
* @returns {Promise<string[]>} all app ids as string[].
|
|
52
|
+
*/
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default new ApplicationsApi('default');
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export type IUserApplicationsIdPayload = {
|
|
2
|
+
userId: string;
|
|
3
|
+
};
|
|
4
|
+
export type IUsersApplicationsIdPayload = {
|
|
5
|
+
userIds: string[];
|
|
6
|
+
};
|
|
7
|
+
export type IGetUsersOfApplicationsQuery = {
|
|
8
|
+
appIds: string[];
|
|
9
|
+
};
|
|
10
|
+
export type IUserApplicationsDataPayload = IGetUsersOfApplicationsQuery & {
|
|
11
|
+
includeFreeAccess?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type IUsersOfApplicationsResponse = {
|
|
14
|
+
appId: string;
|
|
15
|
+
userIds: string[];
|
|
16
|
+
};
|
|
17
|
+
export type IAssignUserToApplicationsBody = {
|
|
18
|
+
userId: string;
|
|
19
|
+
tenantId: string;
|
|
20
|
+
appIds: string[];
|
|
21
|
+
};
|
|
22
|
+
export declare enum ApplicationAccessType {
|
|
23
|
+
FREE_ACCESS = "FREE_ACCESS",
|
|
24
|
+
MANAGED_ACCESS = "MANAGED_ACCESS"
|
|
25
|
+
}
|
|
26
|
+
export type IApplicationsResponse = {
|
|
27
|
+
id: string;
|
|
28
|
+
accessType: ApplicationAccessType;
|
|
29
|
+
appURL: string;
|
|
30
|
+
loginURL: string;
|
|
31
|
+
isDefault: boolean;
|
|
32
|
+
isActive: boolean;
|
|
33
|
+
name: string;
|
|
34
|
+
logoURL: string;
|
|
35
|
+
createdAt: string;
|
|
36
|
+
updatedAt: string;
|
|
37
|
+
type: string;
|
|
38
|
+
frontendStack: string;
|
|
39
|
+
description: string;
|
|
40
|
+
integrationFinishedAt: string;
|
|
41
|
+
};
|
|
42
|
+
export type ITenantApplicationsResponse = {
|
|
43
|
+
tenantId: string;
|
|
44
|
+
appIds?: string[];
|
|
45
|
+
};
|
|
46
|
+
export type IUsersApplicationsIdsResponse = {
|
|
47
|
+
userId: string;
|
|
48
|
+
appIds: string[];
|
|
49
|
+
};
|
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,34 @@
|
|
|
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
|
-
|
|
4
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
5
|
+
export class AuditsApi extends BaseApiClient {
|
|
6
|
+
constructor(appName) {
|
|
7
|
+
super(appName);
|
|
8
|
+
this.getAudits = async params => {
|
|
9
|
+
return this.get(urls.audits.v1, params);
|
|
10
|
+
};
|
|
11
|
+
this.getAuditsStats = async params => {
|
|
12
|
+
return this.get(`${urls.audits.v1}/stats`, params);
|
|
13
|
+
};
|
|
14
|
+
this.exportAudits = async params => {
|
|
15
|
+
const {
|
|
16
|
+
endpoint,
|
|
17
|
+
headerProps
|
|
18
|
+
} = params,
|
|
16
19
|
restParams = _objectWithoutPropertiesLoose(params, _excluded);
|
|
20
|
+
return this.postDownload(`${urls.audits.v1}/export/${endpoint}`, {
|
|
21
|
+
properties: headerProps
|
|
22
|
+
}, restParams);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetches audit logs based on the provided parameters.
|
|
28
|
+
*
|
|
29
|
+
* @param params - Parameters to filter and paginate audits.
|
|
30
|
+
* @returns A promise that resolves to the list of audits.
|
|
31
|
+
*/
|
|
32
|
+
}
|
|
17
33
|
|
|
18
|
-
|
|
19
|
-
properties: headerProps
|
|
20
|
-
}, restParams);
|
|
21
|
-
}
|
|
34
|
+
export default new AuditsApi('default');
|
package/audits/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type SortDirectionType = 'asc' | 'desc';
|
|
2
2
|
export interface AuditRowData {
|
|
3
3
|
_id: string;
|
|
4
4
|
ip: string;
|
|
@@ -13,6 +13,7 @@ export interface AuditRowData {
|
|
|
13
13
|
tenantId: string;
|
|
14
14
|
createdAt: string;
|
|
15
15
|
updatedAt: string;
|
|
16
|
+
actorMail?: string;
|
|
16
17
|
__v: number;
|
|
17
18
|
}
|
|
18
19
|
export interface IGetAuditsParams {
|
|
@@ -36,7 +37,7 @@ export interface IAuditsStats {
|
|
|
36
37
|
totalToday: number;
|
|
37
38
|
severeThisWeek: number;
|
|
38
39
|
}
|
|
39
|
-
export
|
|
40
|
+
export type TExportAudits = 'csv' | 'pdf' | 'csv/v2';
|
|
40
41
|
export interface IExportAudits {
|
|
41
42
|
headerProps: HeaderProps[];
|
|
42
43
|
sortDirection: SortDirectionType;
|
package/auth/enums.d.ts
CHANGED
|
@@ -2,7 +2,10 @@ export declare enum SocialLoginProviders {
|
|
|
2
2
|
Microsoft = "microsoft",
|
|
3
3
|
Facebook = "facebook",
|
|
4
4
|
Google = "google",
|
|
5
|
-
Github = "github"
|
|
5
|
+
Github = "github",
|
|
6
|
+
Slack = "slack",
|
|
7
|
+
Apple = "apple",
|
|
8
|
+
Linkedin = "linkedin"
|
|
6
9
|
}
|
|
7
10
|
export declare enum AuthStrategyEnum {
|
|
8
11
|
EmailAndPassword = "EmailAndPassword",
|
|
@@ -11,3 +14,7 @@ export declare enum AuthStrategyEnum {
|
|
|
11
14
|
NoLocalAuthentication = "NoLocalAuthentication",
|
|
12
15
|
SmsCode = "SmsCode"
|
|
13
16
|
}
|
|
17
|
+
export declare enum MachineToMachineAuthStrategy {
|
|
18
|
+
ClientCredentials = "ClientCredentials",
|
|
19
|
+
AccessToken = "AccessToken"
|
|
20
|
+
}
|