@frontegg/rest-api 3.1.76-alpha.9502349697 → 3.1.76-alpha.9794353373
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 +30 -108
- package/ContextHolder/index.js +57 -153
- 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 +27 -126
- 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 +57 -153
- 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 -69
- 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 -58
- 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/directory/index.js
CHANGED
|
@@ -3,41 +3,32 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.countConfigurationUsers = countConfigurationUsers;
|
|
7
|
+
exports.createConfiguration = createConfiguration;
|
|
8
|
+
exports.deleteConfiguration = deleteConfiguration;
|
|
9
|
+
exports.getConfigs = getConfigs;
|
|
10
|
+
exports.updateConfiguration = updateConfiguration;
|
|
7
11
|
|
|
8
12
|
var _constants = require("../constants");
|
|
9
13
|
|
|
10
|
-
var
|
|
14
|
+
var _fetch = require("../fetch");
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.getConfigs = async () => {
|
|
17
|
-
return this.get(`${_constants.urls.directory.v1}`);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
this.updateConfiguration = async (id, body) => {
|
|
21
|
-
return this.patch(`${_constants.urls.directory.v1}/${id}`, body);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
this.createConfiguration = async body => {
|
|
25
|
-
return this.post(`${_constants.urls.directory.v1}`, body);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
this.deleteConfiguration = async id => {
|
|
29
|
-
return this.delete(`${_constants.urls.directory.v1}/${id}`);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
this.countConfigurationUsers = async id => {
|
|
33
|
-
return this.get(`${_constants.urls.directory.temp}/${id}/Users/count`);
|
|
34
|
-
};
|
|
35
|
-
}
|
|
16
|
+
async function getConfigs() {
|
|
17
|
+
return (0, _fetch.Get)(`${_constants.urls.directory.v1}`);
|
|
18
|
+
}
|
|
36
19
|
|
|
20
|
+
async function updateConfiguration(id, body) {
|
|
21
|
+
return (0, _fetch.Patch)(`${_constants.urls.directory.v1}/${id}`, body);
|
|
37
22
|
}
|
|
38
23
|
|
|
39
|
-
|
|
24
|
+
async function createConfiguration(body) {
|
|
25
|
+
return (0, _fetch.Post)(`${_constants.urls.directory.v1}`, body);
|
|
26
|
+
}
|
|
40
27
|
|
|
41
|
-
|
|
28
|
+
async function deleteConfiguration(id) {
|
|
29
|
+
return (0, _fetch.Delete)(`${_constants.urls.directory.v1}/${id}`);
|
|
30
|
+
}
|
|
42
31
|
|
|
43
|
-
|
|
32
|
+
async function countConfigurationUsers(id) {
|
|
33
|
+
return (0, _fetch.Get)(`${_constants.urls.directory.temp}/${id}/Users/count`);
|
|
34
|
+
}
|
|
@@ -3,25 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.loadEntitlementsV2 = loadEntitlementsV2;
|
|
7
7
|
|
|
8
8
|
var _constants = require("../constants");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _fetch = require("../fetch");
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.loadEntitlementsV2 = async () => {
|
|
17
|
-
return this.get(_constants.urls.entitlements.v2);
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
exports.EntitlementsApi = EntitlementsApi;
|
|
24
|
-
|
|
25
|
-
var _default = new EntitlementsApi('default');
|
|
26
|
-
|
|
27
|
-
exports.default = _default;
|
|
12
|
+
async function loadEntitlementsV2() {
|
|
13
|
+
return (0, _fetch.Get)(_constants.urls.entitlements.v2);
|
|
14
|
+
}
|
|
@@ -5,13 +5,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.FeatureFlags = void 0;
|
|
9
|
+
exports.loadFeatureFlags = loadFeatureFlags;
|
|
9
10
|
|
|
10
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
12
|
|
|
12
13
|
var _constants = require("../constants");
|
|
13
14
|
|
|
14
|
-
var
|
|
15
|
+
var _fetch = require("../fetch");
|
|
15
16
|
|
|
16
17
|
const defaultFeatureFlags = {
|
|
17
18
|
flags: {}
|
|
@@ -25,11 +26,11 @@ class FeatureFlags {
|
|
|
25
26
|
this._flags = (_defaultFeatureFlags$ = defaultFeatureFlags.flags) != null ? _defaultFeatureFlags$ : {};
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
static getInstance(name =
|
|
29
|
+
static getInstance(name = "default") {
|
|
29
30
|
return this._instances[name];
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
static set(featureFlags, name =
|
|
33
|
+
static set(featureFlags, name = "default") {
|
|
33
34
|
const featureFlagsInstance = new FeatureFlags();
|
|
34
35
|
featureFlagsInstance.set(featureFlags);
|
|
35
36
|
FeatureFlags._instances[name] = featureFlagsInstance;
|
|
@@ -38,7 +39,7 @@ class FeatureFlags {
|
|
|
38
39
|
|
|
39
40
|
static getFeatureFlags(flags, name) {
|
|
40
41
|
const featureFlagsInstance = this.getInstance(name);
|
|
41
|
-
return flags.map(flag => (featureFlagsInstance == null ? void 0 : featureFlagsInstance._flags[flag]) ===
|
|
42
|
+
return flags.map(flag => (featureFlagsInstance == null ? void 0 : featureFlagsInstance._flags[flag]) === "on");
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
get flags() {
|
|
@@ -58,19 +59,6 @@ class FeatureFlags {
|
|
|
58
59
|
exports.FeatureFlags = FeatureFlags;
|
|
59
60
|
FeatureFlags._instances = {};
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.loadFeatureFlags = async () => {
|
|
66
|
-
return this.get(_constants.urls.featureFlags.v1);
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
exports.FeatureFlagsApi = FeatureFlagsApi;
|
|
73
|
-
|
|
74
|
-
var _default = new FeatureFlagsApi('default');
|
|
75
|
-
|
|
76
|
-
exports.default = _default;
|
|
62
|
+
async function loadFeatureFlags() {
|
|
63
|
+
return (0, _fetch.Get)(_constants.urls.featureFlags.v1);
|
|
64
|
+
}
|
package/node/fetch.js
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.extractHeadersFromOptions = exports.Put = exports.PostDownload = exports.Post = exports.Patch = exports.Get = exports.Delete = void 0;
|
|
9
|
+
exports.getBaseUrl = getBaseUrl;
|
|
10
|
+
exports.getMetadataHeaders = getMetadataHeaders;
|
|
11
|
+
exports.getScopedTenant = getScopedTenant;
|
|
12
|
+
|
|
13
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
14
|
+
|
|
15
|
+
var _ContextHolder = require("./ContextHolder");
|
|
16
|
+
|
|
17
|
+
var _interfaces = require("./interfaces");
|
|
18
|
+
|
|
19
|
+
var _error = require("./error");
|
|
20
|
+
|
|
21
|
+
var _constants = require("./constants");
|
|
22
|
+
|
|
23
|
+
function getBaseUrl(context, url, withFronteggPrefix = true) {
|
|
24
|
+
let baseUrl;
|
|
25
|
+
|
|
26
|
+
if (typeof context.baseUrl === 'function') {
|
|
27
|
+
baseUrl = context.baseUrl(url);
|
|
28
|
+
} else {
|
|
29
|
+
baseUrl = context.baseUrl;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const prefix = context.urlPrefix || 'frontegg';
|
|
33
|
+
const removePrefix = prefix === 'frontegg' && !withFronteggPrefix;
|
|
34
|
+
|
|
35
|
+
if (!baseUrl.endsWith('/')) {
|
|
36
|
+
baseUrl += '/';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!baseUrl.endsWith(prefix) && !removePrefix) {
|
|
40
|
+
baseUrl += prefix;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return baseUrl;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function prepareUrl(context, url, params) {
|
|
47
|
+
const baseUrl = getBaseUrl(context, url);
|
|
48
|
+
const paramsToSend = await buildQueryParams(context, params);
|
|
49
|
+
let finalUrl = url.startsWith('http') ? url : `${baseUrl}${url}`;
|
|
50
|
+
const hasKeys = Object.keys(paramsToSend).length > 0;
|
|
51
|
+
|
|
52
|
+
if (paramsToSend && hasKeys) {
|
|
53
|
+
const urlParams = new URLSearchParams(paramsToSend);
|
|
54
|
+
finalUrl += `?${urlParams}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return finalUrl;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getMetadataHeaders(context) {
|
|
61
|
+
var _context$metadataHead, _context$metadataHead2;
|
|
62
|
+
|
|
63
|
+
const headers = {};
|
|
64
|
+
|
|
65
|
+
if (context != null && (_context$metadataHead = context.metadataHeaders) != null && _context$metadataHead.fronteggSdkVersion) {
|
|
66
|
+
headers[_interfaces.fronteggHeaders.fronteggSdkVersion] = context.metadataHeaders.fronteggSdkVersion;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (context != null && (_context$metadataHead2 = context.metadataHeaders) != null && _context$metadataHead2.framework) {
|
|
70
|
+
headers[_interfaces.fronteggHeaders.frameWork] = context.metadataHeaders.framework;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return headers;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function getScopedTenant() {
|
|
77
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
78
|
+
const scopedTenant = urlParams.get('tenantId');
|
|
79
|
+
|
|
80
|
+
if (scopedTenant) {
|
|
81
|
+
return scopedTenant;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
async function buildRequestHeaders(context, contentType) {
|
|
88
|
+
var _context$tokenResolve;
|
|
89
|
+
|
|
90
|
+
const headers = getMetadataHeaders(context);
|
|
91
|
+
const authToken = await ((_context$tokenResolve = context == null ? void 0 : context.tokenResolver) != null ? _context$tokenResolve : _ContextHolder.ContextHolder.getAccessToken)();
|
|
92
|
+
|
|
93
|
+
const requestSource = _ContextHolder.ContextHolder.getRequestSource();
|
|
94
|
+
|
|
95
|
+
const scopedTenant = getScopedTenant();
|
|
96
|
+
|
|
97
|
+
if (contentType) {
|
|
98
|
+
headers[_interfaces.fronteggHeaders.contentType] = contentType;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (requestSource) {
|
|
102
|
+
headers[_interfaces.fronteggHeaders.source] = requestSource;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (authToken) {
|
|
106
|
+
headers.Authorization = `Bearer ${authToken}`;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (scopedTenant) {
|
|
110
|
+
headers[_interfaces.fronteggHeaders.scopedTenant] = scopedTenant;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
for (const additionalHeader of await getAdditionalHeaders(context)) {
|
|
114
|
+
headers[`${additionalHeader.key}`] = `${additionalHeader.value}`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return headers;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async function buildQueryParams(context, params) {
|
|
121
|
+
if (!params) {
|
|
122
|
+
params = {};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const additionalQueryParams = await getAdditionalQueryParams(context);
|
|
126
|
+
|
|
127
|
+
for (const queryParam of additionalQueryParams) {
|
|
128
|
+
params[queryParam.key] = queryParam.value;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const keys = Object.keys(params);
|
|
132
|
+
|
|
133
|
+
for (const key of keys) {
|
|
134
|
+
const value = params[key];
|
|
135
|
+
params[key] = typeof value === 'object' ? JSON.stringify(value) : value;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return params;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async function getAdditionalQueryParams(context) {
|
|
142
|
+
let output = [];
|
|
143
|
+
|
|
144
|
+
if (context.additionalQueryParamsResolver) {
|
|
145
|
+
output = await context.additionalQueryParamsResolver();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return output;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async function getAdditionalHeaders(context) {
|
|
152
|
+
let output = [];
|
|
153
|
+
|
|
154
|
+
if (context.additionalHeadersResolver) {
|
|
155
|
+
output = await context.additionalHeadersResolver();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (context.tenantResolver) {
|
|
159
|
+
const resolvedTenantResult = await context.tenantResolver();
|
|
160
|
+
|
|
161
|
+
if (!!(resolvedTenantResult != null && resolvedTenantResult.tenant)) {
|
|
162
|
+
output.push({
|
|
163
|
+
key: 'frontegg-login-alias',
|
|
164
|
+
value: resolvedTenantResult.tenant
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (context.appId) {
|
|
170
|
+
output.push({
|
|
171
|
+
key: 'frontegg-requested-application-id',
|
|
172
|
+
value: context.appId
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return output;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const sendRequest = async opts => {
|
|
180
|
+
var _opts$method, _ref, _opts$credentials;
|
|
181
|
+
|
|
182
|
+
const context = _ContextHolder.ContextHolder.getContext();
|
|
183
|
+
|
|
184
|
+
const headers = await buildRequestHeaders(context, opts.contentType);
|
|
185
|
+
const url = await prepareUrl(context, opts.url, opts.params);
|
|
186
|
+
const response = await fetch(url, {
|
|
187
|
+
body: opts.body ? opts.contentType === 'application/json' ? JSON.stringify(opts.body) : opts.body : null,
|
|
188
|
+
method: (_opts$method = opts.method) != null ? _opts$method : 'GET',
|
|
189
|
+
headers: (0, _extends2.default)({}, headers, opts.headers),
|
|
190
|
+
credentials: (_ref = (_opts$credentials = opts.credentials) != null ? _opts$credentials : context.requestCredentials) != null ? _ref : 'same-origin'
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
if (response.status === 302) {
|
|
194
|
+
window.location.href = await response.text();
|
|
195
|
+
return new Promise(() => {});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (!response.ok) {
|
|
199
|
+
var _context$logLevel, _context$logLevel2;
|
|
200
|
+
|
|
201
|
+
if (response.status === 413) {
|
|
202
|
+
throw new _error.FronteggApiError('Error request is too large', response.status);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
let errorMessage;
|
|
206
|
+
let isJsonResponse = true;
|
|
207
|
+
|
|
208
|
+
try {
|
|
209
|
+
errorMessage = await response.text();
|
|
210
|
+
errorMessage = JSON.parse(errorMessage);
|
|
211
|
+
} catch (e) {
|
|
212
|
+
isJsonResponse = false;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (errorMessage.errors) {
|
|
216
|
+
errorMessage = errorMessage.errors.join(', ');
|
|
217
|
+
} else if (typeof errorMessage !== 'string') {
|
|
218
|
+
errorMessage = `Error ${response.status} - ${response.statusText}`;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
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);
|
|
222
|
+
throw new _error.FronteggApiError(isJsonResponse ? errorMessage : _constants.GENERIC_ERROR_MESSAGE, response.status);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (!opts.responseType || opts.responseType === 'json') {
|
|
226
|
+
try {
|
|
227
|
+
return await response.json();
|
|
228
|
+
} catch (e) {
|
|
229
|
+
return {};
|
|
230
|
+
}
|
|
231
|
+
} else if (opts.responseType === 'blob') {
|
|
232
|
+
const {
|
|
233
|
+
outputFileName
|
|
234
|
+
} = opts.params;
|
|
235
|
+
return await response.blob().then(blob => URL.createObjectURL(blob)).then(url => {
|
|
236
|
+
const tempLink = document.createElement('a');
|
|
237
|
+
tempLink.href = url;
|
|
238
|
+
tempLink.setAttribute('download', outputFileName || 'output');
|
|
239
|
+
tempLink.click();
|
|
240
|
+
});
|
|
241
|
+
} else {
|
|
242
|
+
return await response.text();
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const Get = async (url, params, opts) => sendRequest((0, _extends2.default)({
|
|
247
|
+
url,
|
|
248
|
+
method: 'GET',
|
|
249
|
+
contentType: 'application/json',
|
|
250
|
+
params
|
|
251
|
+
}, opts));
|
|
252
|
+
|
|
253
|
+
exports.Get = Get;
|
|
254
|
+
|
|
255
|
+
const Post = async (url, body, opts) => sendRequest((0, _extends2.default)({
|
|
256
|
+
url,
|
|
257
|
+
method: 'POST',
|
|
258
|
+
contentType: 'application/json',
|
|
259
|
+
body
|
|
260
|
+
}, opts));
|
|
261
|
+
|
|
262
|
+
exports.Post = Post;
|
|
263
|
+
|
|
264
|
+
const Patch = async (url, body, opts) => sendRequest((0, _extends2.default)({
|
|
265
|
+
url,
|
|
266
|
+
method: 'PATCH',
|
|
267
|
+
contentType: 'application/json',
|
|
268
|
+
body
|
|
269
|
+
}, opts));
|
|
270
|
+
|
|
271
|
+
exports.Patch = Patch;
|
|
272
|
+
|
|
273
|
+
const Put = async (url, body, opts) => sendRequest((0, _extends2.default)({
|
|
274
|
+
url,
|
|
275
|
+
method: 'PUT',
|
|
276
|
+
contentType: 'application/json',
|
|
277
|
+
body
|
|
278
|
+
}, opts));
|
|
279
|
+
|
|
280
|
+
exports.Put = Put;
|
|
281
|
+
|
|
282
|
+
const Delete = async (url, body, opts) => sendRequest((0, _extends2.default)({
|
|
283
|
+
url,
|
|
284
|
+
method: 'DELETE',
|
|
285
|
+
contentType: 'application/json',
|
|
286
|
+
body
|
|
287
|
+
}, opts));
|
|
288
|
+
|
|
289
|
+
exports.Delete = Delete;
|
|
290
|
+
|
|
291
|
+
const PostDownload = async (url, body, params, opts) => sendRequest((0, _extends2.default)({
|
|
292
|
+
url,
|
|
293
|
+
method: 'POST',
|
|
294
|
+
contentType: 'application/json',
|
|
295
|
+
responseType: 'blob',
|
|
296
|
+
body,
|
|
297
|
+
params
|
|
298
|
+
}, opts));
|
|
299
|
+
|
|
300
|
+
exports.PostDownload = PostDownload;
|
|
301
|
+
|
|
302
|
+
const extractHeadersFromOptions = (options = {}) => (0, _extends2.default)({}, options.jwt ? {
|
|
303
|
+
Authorization: options.jwt
|
|
304
|
+
} : {});
|
|
305
|
+
|
|
306
|
+
exports.extractHeadersFromOptions = extractHeadersFromOptions;
|
package/node/groups/index.js
CHANGED
|
@@ -5,7 +5,18 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.addRolesToGroup = addRolesToGroup;
|
|
9
|
+
exports.addUsersToGroup = addUsersToGroup;
|
|
10
|
+
exports.createGroup = createGroup;
|
|
11
|
+
exports.deleteGroup = deleteGroup;
|
|
12
|
+
exports.deleteRolesFromGroup = deleteRolesFromGroup;
|
|
13
|
+
exports.deleteUsersFromGroup = deleteUsersFromGroup;
|
|
14
|
+
exports.getGroupById = getGroupById;
|
|
15
|
+
exports.getGroupConfiguration = getGroupConfiguration;
|
|
16
|
+
exports.getGroups = getGroups;
|
|
17
|
+
exports.getGroupsByIds = getGroupsByIds;
|
|
18
|
+
exports.updateGroup = updateGroup;
|
|
19
|
+
exports.updateGroupConfiguration = updateGroupConfiguration;
|
|
9
20
|
|
|
10
21
|
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
22
|
|
|
@@ -13,75 +24,62 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
13
24
|
|
|
14
25
|
var _constants = require("../constants");
|
|
15
26
|
|
|
16
|
-
var
|
|
27
|
+
var _fetch = require("../fetch");
|
|
17
28
|
|
|
18
29
|
const _excluded = ["groupId"];
|
|
19
30
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
groupId
|
|
26
|
-
}, query) => {
|
|
27
|
-
return this.get(`${_constants.urls.identity.groups.v1}/${groupId}`, (0, _extends2.default)({}, query));
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
this.getGroups = async query => {
|
|
31
|
-
return this.get(`${_constants.urls.identity.groups.v1}`, (0, _extends2.default)({}, query));
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
this.getGroupsByIds = async (body, params) => {
|
|
35
|
-
return this.post(`${_constants.urls.identity.groups.getByIds.v1}`, body, {
|
|
36
|
-
params
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
this.createGroup = async body => {
|
|
41
|
-
return this.post(`${_constants.urls.identity.groups.v1}`, body);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
this.updateGroup = async _ref => {
|
|
45
|
-
let {
|
|
46
|
-
groupId
|
|
47
|
-
} = _ref,
|
|
48
|
-
body = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
49
|
-
return this.patch(`${_constants.urls.identity.groups.v1}/${groupId}`, body);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
this.deleteGroup = async groupId => {
|
|
53
|
-
return this.delete(`${_constants.urls.identity.groups.v1}/${groupId}`);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
this.addRolesToGroup = async (groupId, body) => {
|
|
57
|
-
return this.post(`${_constants.urls.identity.groups.v1}/${groupId}/roles`, body);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
this.deleteRolesFromGroup = async (groupId, body) => {
|
|
61
|
-
return this.delete(`${_constants.urls.identity.groups.v1}/${groupId}/roles`, body);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
this.addUsersToGroup = async (groupId, body) => {
|
|
65
|
-
return this.post(`${_constants.urls.identity.groups.v1}/${groupId}/users`, body);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
this.deleteUsersFromGroup = async (groupId, body) => {
|
|
69
|
-
return this.delete(`${_constants.urls.identity.groups.v1}/${groupId}/users`, body);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
this.getGroupConfiguration = async () => {
|
|
73
|
-
return this.get(`${_constants.urls.identity.groups.configurations.v1}`);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
this.updateGroupConfiguration = async body => {
|
|
77
|
-
return this.post(`${_constants.urls.identity.groups.configurations.v1}`, body);
|
|
78
|
-
};
|
|
79
|
-
}
|
|
31
|
+
async function getGroupById({
|
|
32
|
+
groupId
|
|
33
|
+
}, query) {
|
|
34
|
+
return (0, _fetch.Get)(`${_constants.urls.identity.groups.v1}/${groupId}`, (0, _extends2.default)({}, query));
|
|
35
|
+
}
|
|
80
36
|
|
|
37
|
+
async function getGroups(query) {
|
|
38
|
+
return (0, _fetch.Get)(`${_constants.urls.identity.groups.v1}`, (0, _extends2.default)({}, query));
|
|
81
39
|
}
|
|
82
40
|
|
|
83
|
-
|
|
41
|
+
async function getGroupsByIds(body, params) {
|
|
42
|
+
return (0, _fetch.Post)(`${_constants.urls.identity.groups.getByIds.v1}`, body, {
|
|
43
|
+
params
|
|
44
|
+
});
|
|
45
|
+
}
|
|
84
46
|
|
|
85
|
-
|
|
47
|
+
async function createGroup(body) {
|
|
48
|
+
return (0, _fetch.Post)(`${_constants.urls.identity.groups.v1}`, body);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function updateGroup(_ref) {
|
|
52
|
+
let {
|
|
53
|
+
groupId
|
|
54
|
+
} = _ref,
|
|
55
|
+
body = (0, _objectWithoutPropertiesLoose2.default)(_ref, _excluded);
|
|
56
|
+
return (0, _fetch.Patch)(`${_constants.urls.identity.groups.v1}/${groupId}`, body);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function deleteGroup(groupId) {
|
|
60
|
+
return (0, _fetch.Delete)(`${_constants.urls.identity.groups.v1}/${groupId}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function addRolesToGroup(groupId, body) {
|
|
64
|
+
return (0, _fetch.Post)(`${_constants.urls.identity.groups.v1}/${groupId}/roles`, body);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function deleteRolesFromGroup(groupId, body) {
|
|
68
|
+
return (0, _fetch.Delete)(`${_constants.urls.identity.groups.v1}/${groupId}/roles`, body);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function addUsersToGroup(groupId, body) {
|
|
72
|
+
return (0, _fetch.Post)(`${_constants.urls.identity.groups.v1}/${groupId}/users`, body);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function deleteUsersFromGroup(groupId, body) {
|
|
76
|
+
return (0, _fetch.Delete)(`${_constants.urls.identity.groups.v1}/${groupId}/users`, body);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function getGroupConfiguration() {
|
|
80
|
+
return (0, _fetch.Get)(`${_constants.urls.identity.groups.configurations.v1}`);
|
|
81
|
+
}
|
|
86
82
|
|
|
87
|
-
|
|
83
|
+
async function updateGroupConfiguration(body) {
|
|
84
|
+
return (0, _fetch.Post)(`${_constants.urls.identity.groups.configurations.v1}`, body);
|
|
85
|
+
}
|
|
@@ -3,25 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.impersonate = impersonate;
|
|
7
7
|
|
|
8
8
|
var _constants = require("../constants");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _fetch = require("../fetch");
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.impersonate = async body => {
|
|
17
|
-
return this.post(`${_constants.urls.identity.impersonate.v1}`, body);
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
exports.ImpersonateApi = ImpersonateApi;
|
|
24
|
-
|
|
25
|
-
var _default = new ImpersonateApi('default');
|
|
26
|
-
|
|
27
|
-
exports.default = _default;
|
|
12
|
+
async function impersonate(body) {
|
|
13
|
+
return (0, _fetch.Post)(`${_constants.urls.identity.impersonate.v1}`, body);
|
|
14
|
+
}
|