@frontegg/rest-api 3.1.74-alpha.9437937621 → 3.1.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ContextHolder/index.d.ts +27 -108
- package/ContextHolder/index.js +50 -155
- package/account-settings/index.d.ts +7 -19
- package/account-settings/index.js +13 -23
- package/applications/index.d.ts +44 -49
- package/applications/index.js +37 -51
- package/audits/index.d.ts +15 -27
- package/audits/index.js +17 -27
- package/auth/index.d.ts +768 -817
- package/auth/index.js +721 -902
- package/auth/secutiry-poilicy/index.d.ts +102 -58
- package/auth/secutiry-poilicy/index.js +90 -122
- package/auth/utils.d.ts +2 -2
- package/auth/utils.js +8 -9
- package/connectivity/index.d.ts +26 -125
- package/connectivity/index.js +114 -147
- package/directory/index.d.ts +22 -31
- package/directory/index.js +15 -27
- package/entitlements/index.d.ts +8 -14
- package/entitlements/index.js +4 -12
- package/feature-flags/index.d.ts +2 -8
- package/feature-flags/index.js +8 -16
- package/fetch.d.ts +24 -0
- package/fetch.js +265 -0
- package/groups/index.d.ts +49 -73
- package/groups/index.js +45 -64
- package/impersonate/index.d.ts +6 -15
- package/impersonate/index.js +5 -13
- package/index.d.ts +108 -154
- package/index.js +78 -109
- package/interfaces.d.ts +0 -10
- package/metadata/index.d.ts +7 -67
- package/metadata/index.js +32 -52
- package/node/ContextHolder/index.js +50 -155
- package/node/account-settings/index.js +16 -27
- package/node/applications/index.js +44 -51
- package/node/audits/index.js +20 -31
- package/node/auth/index.js +1035 -768
- package/node/auth/secutiry-poilicy/index.js +136 -125
- package/node/auth/utils.js +7 -9
- package/node/connectivity/index.js +187 -148
- package/node/directory/index.js +20 -29
- package/node/entitlements/index.js +5 -18
- package/node/feature-flags/index.js +9 -21
- package/node/fetch.js +306 -0
- package/node/groups/index.js +63 -65
- package/node/impersonate/index.js +5 -18
- package/node/index.js +71 -116
- package/node/metadata/index.js +52 -61
- package/node/notifications/index.js +27 -37
- package/node/reports/index.js +70 -78
- package/node/roles/index.js +51 -56
- package/node/security-center/index.js +9 -21
- package/node/sub-tenants/index.js +89 -90
- package/node/subscriptions/index.js +107 -79
- package/node/subscriptions/invoices.js +17 -25
- package/node/subscriptions/managedSubscriptions.js +27 -32
- package/node/subscriptions/paymentMethods.js +20 -27
- package/node/subscriptions/paymentProviders.js +6 -15
- package/node/subscriptions/plans.js +9 -17
- package/node/subscriptions/providers/index.js +18 -0
- package/node/subscriptions/providers/stripe/index.js +21 -26
- package/node/subscriptions/subscriptions.js +27 -32
- package/node/subscriptions/summaries.js +6 -15
- package/node/subscriptions/tenantConfiguration.js +9 -17
- package/node/subscriptions/vendorPublicConfigurations.js +6 -15
- package/node/teams/index.js +138 -130
- package/node/tenants/index.js +60 -65
- package/node/user-phone-numbers/index.js +24 -32
- package/node/users/index.js +53 -58
- package/node/vendor/index.js +6 -17
- package/notifications/index.d.ts +16 -22
- package/notifications/index.js +22 -33
- package/package.json +1 -1
- package/reports/index.d.ts +44 -50
- package/reports/index.js +62 -75
- package/roles/index.d.ts +38 -44
- package/roles/index.js +41 -57
- package/security-center/index.d.ts +2 -14
- package/security-center/index.js +6 -15
- package/sub-tenants/index.d.ts +15 -57
- package/sub-tenants/index.js +68 -88
- package/subscriptions/index.d.ts +11 -56
- package/subscriptions/index.js +11 -68
- package/subscriptions/invoices.d.ts +13 -16
- package/subscriptions/invoices.js +14 -24
- package/subscriptions/managedSubscriptions.d.ts +15 -18
- package/subscriptions/managedSubscriptions.js +22 -33
- package/subscriptions/paymentMethods.d.ts +13 -16
- package/subscriptions/paymentMethods.js +17 -26
- package/subscriptions/paymentProviders.d.ts +5 -8
- package/subscriptions/paymentProviders.js +4 -11
- package/subscriptions/plans.d.ts +8 -11
- package/subscriptions/plans.js +6 -14
- package/subscriptions/providers/index.d.ts +1 -0
- package/subscriptions/providers/index.js +1 -0
- package/subscriptions/providers/stripe/index.d.ts +21 -24
- package/subscriptions/providers/stripe/index.js +16 -27
- package/subscriptions/subscriptions.d.ts +21 -24
- package/subscriptions/subscriptions.js +22 -33
- package/subscriptions/summaries.d.ts +4 -7
- package/subscriptions/summaries.js +3 -10
- package/subscriptions/tenantConfiguration.d.ts +3 -6
- package/subscriptions/tenantConfiguration.js +7 -15
- package/subscriptions/vendorPublicConfigurations.d.ts +2 -5
- package/subscriptions/vendorPublicConfigurations.js +4 -11
- package/teams/index.d.ts +131 -35
- package/teams/index.js +93 -122
- package/tenants/index.d.ts +37 -25
- package/tenants/index.js +46 -62
- package/user-phone-numbers/index.d.ts +26 -32
- package/user-phone-numbers/index.js +19 -32
- package/users/index.d.ts +15 -21
- package/users/index.js +44 -60
- package/vendor/index.d.ts +6 -12
- package/vendor/index.js +4 -11
- package/BaseApiClient.d.ts +0 -16
- package/BaseApiClient.js +0 -39
- package/FetchClient.d.ts +0 -42
- package/FetchClient.js +0 -308
- package/node/BaseApiClient.js +0 -49
- package/node/FetchClient.js +0 -326
package/node/FetchClient.js
DELETED
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = exports.FetchClient = void 0;
|
|
9
|
-
|
|
10
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
|
-
var _ContextHolder = require("./ContextHolder");
|
|
13
|
-
|
|
14
|
-
var _error = require("./error");
|
|
15
|
-
|
|
16
|
-
var _constants = require("./constants");
|
|
17
|
-
|
|
18
|
-
var _interfaces = require("./interfaces");
|
|
19
|
-
|
|
20
|
-
class FetchClient {
|
|
21
|
-
constructor(appName) {
|
|
22
|
-
this.appName = void 0;
|
|
23
|
-
|
|
24
|
-
this.getFronteggContext = () => {
|
|
25
|
-
return _ContextHolder.ContextHolder.for(this.appName);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
this.prepareUrl = async (url, params) => {
|
|
29
|
-
const context = this.getFronteggContext().getContext();
|
|
30
|
-
const baseUrl = this.getContextBaseUrl(url);
|
|
31
|
-
const paramsToSend = await this.buildQueryParams(context, params);
|
|
32
|
-
let finalUrl = url.startsWith('http') ? url : `${baseUrl}${url}`;
|
|
33
|
-
const hasKeys = Object.keys(paramsToSend).length > 0;
|
|
34
|
-
|
|
35
|
-
if (paramsToSend && hasKeys) {
|
|
36
|
-
const urlParams = new URLSearchParams(paramsToSend);
|
|
37
|
-
finalUrl += `?${urlParams}`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return finalUrl;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
this.buildQueryParams = async (context, params) => {
|
|
44
|
-
if (!params) {
|
|
45
|
-
params = {};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const additionalQueryParams = await this.getAdditionalQueryParams(context);
|
|
49
|
-
|
|
50
|
-
for (const queryParam of additionalQueryParams) {
|
|
51
|
-
params[queryParam.key] = queryParam.value;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const keys = Object.keys(params);
|
|
55
|
-
|
|
56
|
-
for (const key of keys) {
|
|
57
|
-
const value = params[key];
|
|
58
|
-
params[key] = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return params;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
this.getAdditionalQueryParams = async context => {
|
|
65
|
-
let output = [];
|
|
66
|
-
|
|
67
|
-
if (context.additionalQueryParamsResolver) {
|
|
68
|
-
output = await context.additionalQueryParamsResolver();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return output;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
this.getAdditionalHeaders = async context => {
|
|
75
|
-
let output = [];
|
|
76
|
-
|
|
77
|
-
if (context.additionalHeadersResolver) {
|
|
78
|
-
output = await context.additionalHeadersResolver();
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (context.tenantResolver) {
|
|
82
|
-
const resolvedTenantResult = await context.tenantResolver();
|
|
83
|
-
|
|
84
|
-
if (!!(resolvedTenantResult != null && resolvedTenantResult.tenant)) {
|
|
85
|
-
output.push({
|
|
86
|
-
key: 'frontegg-login-alias',
|
|
87
|
-
value: resolvedTenantResult.tenant
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (context.appId) {
|
|
93
|
-
output.push({
|
|
94
|
-
key: 'frontegg-requested-application-id',
|
|
95
|
-
value: context.appId
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return output;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
this.buildRequestHeaders = async contentType => {
|
|
103
|
-
var _context$tokenResolve;
|
|
104
|
-
|
|
105
|
-
const fronteggContext = this.getFronteggContext();
|
|
106
|
-
const context = fronteggContext.getContext();
|
|
107
|
-
const headers = FetchClient.getMetadataHeaders(context);
|
|
108
|
-
const authToken = await ((_context$tokenResolve = context == null ? void 0 : context.tokenResolver) != null ? _context$tokenResolve : fronteggContext.getAccessToken)();
|
|
109
|
-
const requestSource = fronteggContext.getRequestSource();
|
|
110
|
-
const scopedTenant = FetchClient.getScopedTenant();
|
|
111
|
-
|
|
112
|
-
if (contentType) {
|
|
113
|
-
headers[_interfaces.fronteggHeaders.contentType] = contentType;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (requestSource) {
|
|
117
|
-
headers[_interfaces.fronteggHeaders.source] = requestSource;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (authToken) {
|
|
121
|
-
headers.Authorization = `Bearer ${authToken}`;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (scopedTenant) {
|
|
125
|
-
headers[_interfaces.fronteggHeaders.scopedTenant] = scopedTenant;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
for (const additionalHeader of await this.getAdditionalHeaders(context)) {
|
|
129
|
-
headers[`${additionalHeader.key}`] = `${additionalHeader.value}`;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return headers;
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
this.sendRequest = async opts => {
|
|
136
|
-
var _opts$method, _ref, _opts$credentials;
|
|
137
|
-
|
|
138
|
-
const context = this.getFronteggContext().getContext();
|
|
139
|
-
const headers = await this.buildRequestHeaders(opts.contentType);
|
|
140
|
-
const url = await this.prepareUrl(opts.url, opts.params);
|
|
141
|
-
const response = await fetch(url, {
|
|
142
|
-
body: opts.body ? opts.contentType === 'application/json' ? JSON.stringify(opts.body) : opts.body : null,
|
|
143
|
-
method: (_opts$method = opts.method) != null ? _opts$method : 'GET',
|
|
144
|
-
headers: (0, _extends2.default)({}, headers, opts.headers),
|
|
145
|
-
credentials: (_ref = (_opts$credentials = opts.credentials) != null ? _opts$credentials : context.requestCredentials) != null ? _ref : 'same-origin'
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
if (response.status === 302) {
|
|
149
|
-
window.location.href = await response.text();
|
|
150
|
-
return new Promise(() => {});
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (!response.ok) {
|
|
154
|
-
var _context$logLevel, _context$logLevel2;
|
|
155
|
-
|
|
156
|
-
if (response.status === 413) {
|
|
157
|
-
throw new _error.FronteggApiError('Error request is too large', response.status);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
let errorMessage;
|
|
161
|
-
let isJsonResponse = true;
|
|
162
|
-
|
|
163
|
-
try {
|
|
164
|
-
errorMessage = await response.text();
|
|
165
|
-
errorMessage = JSON.parse(errorMessage);
|
|
166
|
-
} catch (e) {
|
|
167
|
-
isJsonResponse = false;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if (errorMessage.errors) {
|
|
171
|
-
errorMessage = errorMessage.errors.join(', ');
|
|
172
|
-
} else if (typeof errorMessage !== 'string') {
|
|
173
|
-
errorMessage = `Error ${response.status} - ${response.statusText}`;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
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);
|
|
177
|
-
throw new _error.FronteggApiError(isJsonResponse ? errorMessage : _constants.GENERIC_ERROR_MESSAGE, response.status);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (!opts.responseType || opts.responseType === 'json') {
|
|
181
|
-
try {
|
|
182
|
-
return await response.json();
|
|
183
|
-
} catch (e) {
|
|
184
|
-
return {};
|
|
185
|
-
}
|
|
186
|
-
} else if (opts.responseType === 'blob') {
|
|
187
|
-
const {
|
|
188
|
-
outputFileName
|
|
189
|
-
} = opts.params;
|
|
190
|
-
return await response.blob().then(blob => URL.createObjectURL(blob)).then(url => {
|
|
191
|
-
const tempLink = document.createElement('a');
|
|
192
|
-
tempLink.href = url;
|
|
193
|
-
tempLink.setAttribute('download', outputFileName || 'output');
|
|
194
|
-
tempLink.click();
|
|
195
|
-
});
|
|
196
|
-
} else {
|
|
197
|
-
return await response.text();
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
this.get = async (url, params, opts) => this.sendRequest((0, _extends2.default)({
|
|
202
|
-
url,
|
|
203
|
-
method: 'GET',
|
|
204
|
-
contentType: 'application/json',
|
|
205
|
-
params
|
|
206
|
-
}, opts));
|
|
207
|
-
|
|
208
|
-
this.post = async (url, body, opts) => this.sendRequest((0, _extends2.default)({
|
|
209
|
-
url,
|
|
210
|
-
method: 'POST',
|
|
211
|
-
contentType: 'application/json',
|
|
212
|
-
body
|
|
213
|
-
}, opts));
|
|
214
|
-
|
|
215
|
-
this.patch = async (url, body, opts) => this.sendRequest((0, _extends2.default)({
|
|
216
|
-
url,
|
|
217
|
-
method: 'PATCH',
|
|
218
|
-
contentType: 'application/json',
|
|
219
|
-
body
|
|
220
|
-
}, opts));
|
|
221
|
-
|
|
222
|
-
this.put = async (url, body, opts) => this.sendRequest((0, _extends2.default)({
|
|
223
|
-
url,
|
|
224
|
-
method: 'PUT',
|
|
225
|
-
contentType: 'application/json',
|
|
226
|
-
body
|
|
227
|
-
}, opts));
|
|
228
|
-
|
|
229
|
-
this.delete = async (url, body, opts) => this.sendRequest((0, _extends2.default)({
|
|
230
|
-
url,
|
|
231
|
-
method: 'DELETE',
|
|
232
|
-
contentType: 'application/json',
|
|
233
|
-
body
|
|
234
|
-
}, opts));
|
|
235
|
-
|
|
236
|
-
this.postDownload = async (url, body, params, opts) => this.sendRequest((0, _extends2.default)({
|
|
237
|
-
url,
|
|
238
|
-
method: 'POST',
|
|
239
|
-
contentType: 'application/json',
|
|
240
|
-
responseType: 'blob',
|
|
241
|
-
body,
|
|
242
|
-
params
|
|
243
|
-
}, opts));
|
|
244
|
-
|
|
245
|
-
this.extractHeadersFromOptions = (options = {}) => (0, _extends2.default)({}, options.jwt ? {
|
|
246
|
-
Authorization: options.jwt
|
|
247
|
-
} : {});
|
|
248
|
-
|
|
249
|
-
this.getBaseUrl = (context, url, withFronteggPrefix = true) => {
|
|
250
|
-
return FetchClient.getBaseUrl(context, url, withFronteggPrefix);
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
this.getContextBaseUrl = (url, withFronteggPrefix = true) => {
|
|
254
|
-
const context = this.getFronteggContext().getContext();
|
|
255
|
-
return this.getBaseUrl(context, url, withFronteggPrefix);
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
this.getMetadataHeaders = context => {
|
|
259
|
-
return FetchClient.getMetadataHeaders(context);
|
|
260
|
-
};
|
|
261
|
-
|
|
262
|
-
this.getContextMetadataHeaders = () => {
|
|
263
|
-
const context = this.getFronteggContext().getContext();
|
|
264
|
-
return FetchClient.getMetadataHeaders(context);
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
this.appName = appName;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
exports.FetchClient = FetchClient;
|
|
273
|
-
|
|
274
|
-
FetchClient.getBaseUrl = (context, url, withFronteggPrefix = true) => {
|
|
275
|
-
let baseUrl;
|
|
276
|
-
|
|
277
|
-
if (typeof context.baseUrl === 'function') {
|
|
278
|
-
baseUrl = context.baseUrl(url);
|
|
279
|
-
} else {
|
|
280
|
-
baseUrl = context.baseUrl;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
const prefix = context.urlPrefix || 'frontegg';
|
|
284
|
-
const removePrefix = prefix === 'frontegg' && !withFronteggPrefix;
|
|
285
|
-
|
|
286
|
-
if (!baseUrl.endsWith('/')) {
|
|
287
|
-
baseUrl += '/';
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (!baseUrl.endsWith(prefix) && !removePrefix) {
|
|
291
|
-
baseUrl += prefix;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
return baseUrl;
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
FetchClient.getMetadataHeaders = context => {
|
|
298
|
-
var _context$metadataHead, _context$metadataHead2;
|
|
299
|
-
|
|
300
|
-
const headers = {};
|
|
301
|
-
|
|
302
|
-
if (context != null && (_context$metadataHead = context.metadataHeaders) != null && _context$metadataHead.fronteggSdkVersion) {
|
|
303
|
-
headers[_interfaces.fronteggHeaders.fronteggSdkVersion] = context.metadataHeaders.fronteggSdkVersion;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
if (context != null && (_context$metadataHead2 = context.metadataHeaders) != null && _context$metadataHead2.framework) {
|
|
307
|
-
headers[_interfaces.fronteggHeaders.frameWork] = context.metadataHeaders.framework;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
return headers;
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
FetchClient.getScopedTenant = () => {
|
|
314
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
315
|
-
const scopedTenant = urlParams.get('tenantId');
|
|
316
|
-
|
|
317
|
-
if (scopedTenant) {
|
|
318
|
-
return scopedTenant;
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
return null;
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
var _default = new FetchClient('default');
|
|
325
|
-
|
|
326
|
-
exports.default = _default;
|