@frontegg/rest-api 3.0.113 → 3.0.115
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/constants.d.ts +7 -0
- package/constants.js +9 -2
- package/fetch.js +25 -29
- package/index.js +1 -1
- package/node/constants.js +11 -3
- package/node/fetch.js +26 -29
- package/node/index.js +1 -1
- package/node/tenants/index.js +7 -0
- package/node/users/index.js +7 -0
- package/package.json +1 -1
- package/tenants/index.d.ts +2 -1
- package/tenants/index.js +5 -0
- package/tenants/interfaces.d.ts +12 -0
- package/users/index.d.ts +2 -1
- package/users/index.js +5 -0
- package/users/interfaces.d.ts +9 -0
package/constants.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ export declare const urls: {
|
|
|
12
12
|
v1: string;
|
|
13
13
|
v2: string;
|
|
14
14
|
v3: string;
|
|
15
|
+
roles: {
|
|
16
|
+
v3: string;
|
|
17
|
+
};
|
|
15
18
|
apiTokens: {
|
|
16
19
|
v1: string;
|
|
17
20
|
};
|
|
@@ -128,6 +131,9 @@ export declare const urls: {
|
|
|
128
131
|
v1: string;
|
|
129
132
|
};
|
|
130
133
|
v2: string;
|
|
134
|
+
metadata: {
|
|
135
|
+
v2: string;
|
|
136
|
+
};
|
|
131
137
|
};
|
|
132
138
|
subTenants: {
|
|
133
139
|
v1: string;
|
|
@@ -225,3 +231,4 @@ export declare const urls: {
|
|
|
225
231
|
v1: string;
|
|
226
232
|
};
|
|
227
233
|
};
|
|
234
|
+
export declare const GENERIC_ERROR_MESSAGE = "We're facing some difficulties, Please try again";
|
package/constants.js
CHANGED
|
@@ -12,6 +12,9 @@ export const urls = {
|
|
|
12
12
|
v1: '/identity/resources/users/v1',
|
|
13
13
|
v2: '/identity/resources/users/v2',
|
|
14
14
|
v3: '/identity/resources/users/v3',
|
|
15
|
+
roles: {
|
|
16
|
+
v3: '/identity/resources/users/v3/roles'
|
|
17
|
+
},
|
|
15
18
|
apiTokens: {
|
|
16
19
|
v1: '/identity/resources/users/api-tokens/v1'
|
|
17
20
|
},
|
|
@@ -127,7 +130,10 @@ export const urls = {
|
|
|
127
130
|
parents: {
|
|
128
131
|
v1: '/tenants/resources/hierarchy/v1/parents'
|
|
129
132
|
},
|
|
130
|
-
v2: '/tenants/resources/hierarchy/v2'
|
|
133
|
+
v2: '/tenants/resources/hierarchy/v2',
|
|
134
|
+
metadata: {
|
|
135
|
+
v2: '/tenants/resources/hierarchy/v2/metadata'
|
|
136
|
+
}
|
|
131
137
|
},
|
|
132
138
|
subTenants: {
|
|
133
139
|
v1: '/tenants/resources/sub-tenants/v1'
|
|
@@ -224,4 +230,5 @@ export const urls = {
|
|
|
224
230
|
entitlements: {
|
|
225
231
|
v1: '/entitlements/check/v1'
|
|
226
232
|
}
|
|
227
|
-
};
|
|
233
|
+
};
|
|
234
|
+
export const GENERIC_ERROR_MESSAGE = `We're facing some difficulties, Please try again`;
|
package/fetch.js
CHANGED
|
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import { ContextHolder } from './ContextHolder';
|
|
3
3
|
import { fronteggHeaders } from './interfaces';
|
|
4
4
|
import { FronteggApiError } from './error';
|
|
5
|
+
import { GENERIC_ERROR_MESSAGE } from './constants';
|
|
5
6
|
export function getBaseUrl(context, url, withFronteggPrefix = true) {
|
|
6
7
|
let baseUrl;
|
|
7
8
|
|
|
@@ -133,34 +134,6 @@ async function getAdditionalHeaders(context) {
|
|
|
133
134
|
return output;
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
const handleError = async (response, context) => {
|
|
137
|
-
var _errorMessage, _context$logLevel, _context$logLevel2;
|
|
138
|
-
|
|
139
|
-
if (response.status === 413) {
|
|
140
|
-
throw new FronteggApiError('Error request is too large', response.status);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
let errorMessage;
|
|
144
|
-
|
|
145
|
-
try {
|
|
146
|
-
errorMessage = await response.text();
|
|
147
|
-
errorMessage = JSON.parse(errorMessage);
|
|
148
|
-
} catch (e) {
|
|
149
|
-
errorMessage = undefined;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const contentType = response.headers.get("content-type");
|
|
153
|
-
|
|
154
|
-
if ((_errorMessage = errorMessage) != null && _errorMessage.errors) {
|
|
155
|
-
errorMessage = errorMessage.errors.join(', ');
|
|
156
|
-
} else if (typeof errorMessage !== 'string' || !(contentType != null && contentType.includes("application/json"))) {
|
|
157
|
-
errorMessage = `Error ${response.status} - ${response.statusText}`;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
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);
|
|
161
|
-
throw new FronteggApiError(errorMessage, response.status);
|
|
162
|
-
};
|
|
163
|
-
|
|
164
137
|
const sendRequest = async opts => {
|
|
165
138
|
var _opts$method, _ref, _opts$credentials;
|
|
166
139
|
|
|
@@ -180,7 +153,30 @@ const sendRequest = async opts => {
|
|
|
180
153
|
}
|
|
181
154
|
|
|
182
155
|
if (!response.ok) {
|
|
183
|
-
|
|
156
|
+
var _context$logLevel, _context$logLevel2;
|
|
157
|
+
|
|
158
|
+
if (response.status === 413) {
|
|
159
|
+
throw new FronteggApiError('Error request is too large', response.status);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let errorMessage;
|
|
163
|
+
let isJsonResponse = true;
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
errorMessage = await response.text();
|
|
167
|
+
errorMessage = JSON.parse(errorMessage);
|
|
168
|
+
} catch (e) {
|
|
169
|
+
isJsonResponse = false;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (errorMessage.errors) {
|
|
173
|
+
errorMessage = errorMessage.errors.join(', ');
|
|
174
|
+
} else if (typeof errorMessage !== 'string') {
|
|
175
|
+
errorMessage = `Error ${response.status} - ${response.statusText}`;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
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);
|
|
179
|
+
throw new FronteggApiError(isJsonResponse ? errorMessage : GENERIC_ERROR_MESSAGE, response.status);
|
|
184
180
|
}
|
|
185
181
|
|
|
186
182
|
if (!opts.responseType || opts.responseType === 'json') {
|
package/index.js
CHANGED
package/node/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.urls = void 0;
|
|
6
|
+
exports.urls = exports.GENERIC_ERROR_MESSAGE = void 0;
|
|
7
7
|
const urls = {
|
|
8
8
|
vendor: '/vendors',
|
|
9
9
|
identity: {
|
|
@@ -18,6 +18,9 @@ const urls = {
|
|
|
18
18
|
v1: '/identity/resources/users/v1',
|
|
19
19
|
v2: '/identity/resources/users/v2',
|
|
20
20
|
v3: '/identity/resources/users/v3',
|
|
21
|
+
roles: {
|
|
22
|
+
v3: '/identity/resources/users/v3/roles'
|
|
23
|
+
},
|
|
21
24
|
apiTokens: {
|
|
22
25
|
v1: '/identity/resources/users/api-tokens/v1'
|
|
23
26
|
},
|
|
@@ -133,7 +136,10 @@ const urls = {
|
|
|
133
136
|
parents: {
|
|
134
137
|
v1: '/tenants/resources/hierarchy/v1/parents'
|
|
135
138
|
},
|
|
136
|
-
v2: '/tenants/resources/hierarchy/v2'
|
|
139
|
+
v2: '/tenants/resources/hierarchy/v2',
|
|
140
|
+
metadata: {
|
|
141
|
+
v2: '/tenants/resources/hierarchy/v2/metadata'
|
|
142
|
+
}
|
|
137
143
|
},
|
|
138
144
|
subTenants: {
|
|
139
145
|
v1: '/tenants/resources/sub-tenants/v1'
|
|
@@ -231,4 +237,6 @@ const urls = {
|
|
|
231
237
|
v1: '/entitlements/check/v1'
|
|
232
238
|
}
|
|
233
239
|
};
|
|
234
|
-
exports.urls = urls;
|
|
240
|
+
exports.urls = urls;
|
|
241
|
+
const GENERIC_ERROR_MESSAGE = `We're facing some difficulties, Please try again`;
|
|
242
|
+
exports.GENERIC_ERROR_MESSAGE = GENERIC_ERROR_MESSAGE;
|
package/node/fetch.js
CHANGED
|
@@ -17,6 +17,8 @@ var _interfaces = require("./interfaces");
|
|
|
17
17
|
|
|
18
18
|
var _error = require("./error");
|
|
19
19
|
|
|
20
|
+
var _constants = require("./constants");
|
|
21
|
+
|
|
20
22
|
function getBaseUrl(context, url, withFronteggPrefix = true) {
|
|
21
23
|
let baseUrl;
|
|
22
24
|
|
|
@@ -149,34 +151,6 @@ async function getAdditionalHeaders(context) {
|
|
|
149
151
|
return output;
|
|
150
152
|
}
|
|
151
153
|
|
|
152
|
-
const handleError = async (response, context) => {
|
|
153
|
-
var _errorMessage, _context$logLevel, _context$logLevel2;
|
|
154
|
-
|
|
155
|
-
if (response.status === 413) {
|
|
156
|
-
throw new _error.FronteggApiError('Error request is too large', response.status);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
let errorMessage;
|
|
160
|
-
|
|
161
|
-
try {
|
|
162
|
-
errorMessage = await response.text();
|
|
163
|
-
errorMessage = JSON.parse(errorMessage);
|
|
164
|
-
} catch (e) {
|
|
165
|
-
errorMessage = undefined;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const contentType = response.headers.get("content-type");
|
|
169
|
-
|
|
170
|
-
if ((_errorMessage = errorMessage) != null && _errorMessage.errors) {
|
|
171
|
-
errorMessage = errorMessage.errors.join(', ');
|
|
172
|
-
} else if (typeof errorMessage !== 'string' || !(contentType != null && contentType.includes("application/json"))) {
|
|
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(errorMessage, response.status);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
154
|
const sendRequest = async opts => {
|
|
181
155
|
var _opts$method, _ref, _opts$credentials;
|
|
182
156
|
|
|
@@ -197,7 +171,30 @@ const sendRequest = async opts => {
|
|
|
197
171
|
}
|
|
198
172
|
|
|
199
173
|
if (!response.ok) {
|
|
200
|
-
|
|
174
|
+
var _context$logLevel, _context$logLevel2;
|
|
175
|
+
|
|
176
|
+
if (response.status === 413) {
|
|
177
|
+
throw new _error.FronteggApiError('Error request is too large', response.status);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
let errorMessage;
|
|
181
|
+
let isJsonResponse = true;
|
|
182
|
+
|
|
183
|
+
try {
|
|
184
|
+
errorMessage = await response.text();
|
|
185
|
+
errorMessage = JSON.parse(errorMessage);
|
|
186
|
+
} catch (e) {
|
|
187
|
+
isJsonResponse = false;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (errorMessage.errors) {
|
|
191
|
+
errorMessage = errorMessage.errors.join(', ');
|
|
192
|
+
} else if (typeof errorMessage !== 'string') {
|
|
193
|
+
errorMessage = `Error ${response.status} - ${response.statusText}`;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
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);
|
|
197
|
+
throw new _error.FronteggApiError(isJsonResponse ? errorMessage : _constants.GENERIC_ERROR_MESSAGE, response.status);
|
|
201
198
|
}
|
|
202
199
|
|
|
203
200
|
if (!opts.responseType || opts.responseType === 'json') {
|
package/node/index.js
CHANGED
package/node/tenants/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getHierarchyMetadata = getHierarchyMetadata;
|
|
6
7
|
exports.getParentTenants = getParentTenants;
|
|
7
8
|
exports.getSubTenants = getSubTenants;
|
|
8
9
|
exports.getSubTenantsAsTree = getSubTenantsAsTree;
|
|
@@ -51,4 +52,10 @@ async function searchSubTenants(params, options) {
|
|
|
51
52
|
return (0, _fetch.Get)(_constants.urls.tenants.hierarchy.v2, params, {
|
|
52
53
|
headers: (0, _fetch.extractHeadersFromOptions)(options)
|
|
53
54
|
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function getHierarchyMetadata(params, options) {
|
|
58
|
+
return (0, _fetch.Get)(_constants.urls.tenants.hierarchy.metadata.v2, params, {
|
|
59
|
+
headers: (0, _fetch.extractHeadersFromOptions)(options)
|
|
60
|
+
});
|
|
54
61
|
}
|
package/node/users/index.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.GetUserJwt = GetUserJwt;
|
|
7
|
+
exports.getUsersRoles = getUsersRoles;
|
|
7
8
|
exports.getUsersV3 = getUsersV3;
|
|
8
9
|
|
|
9
10
|
var _fetch = require("../fetch");
|
|
@@ -18,4 +19,10 @@ async function getUsersV3(queryParams, options) {
|
|
|
18
19
|
return (0, _fetch.Get)(_constants.urls.identity.users.v3, queryParams, {
|
|
19
20
|
headers: (0, _fetch.extractHeadersFromOptions)(options)
|
|
20
21
|
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async function getUsersRoles(queryParams, options) {
|
|
25
|
+
return (0, _fetch.Get)(_constants.urls.identity.users.roles.v3, queryParams, {
|
|
26
|
+
headers: (0, _fetch.extractHeadersFromOptions)(options)
|
|
27
|
+
});
|
|
21
28
|
}
|
package/package.json
CHANGED
package/tenants/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IGetTenantsUserCountRequest, IGetTenantsUserCountResponse, IParentTenant, ISubTenant, ISubTenantTree, ISwitchTenant, ITenantsResponse, SearchSubTenantsParams, SearchSubTenantsResponse } from "./interfaces";
|
|
1
|
+
import { GetHierarchyMetadataParams, GetHierarchyMetadataResponse, IGetTenantsUserCountRequest, IGetTenantsUserCountResponse, IParentTenant, ISubTenant, ISubTenantTree, ISwitchTenant, ITenantsResponse, SearchSubTenantsParams, SearchSubTenantsResponse } from "./interfaces";
|
|
2
2
|
import { FronteggPaginationWrapper, UserJwtOptions } from "../interfaces";
|
|
3
3
|
/**
|
|
4
4
|
* switch logged in user to specific tenant by providing tenantId.
|
|
@@ -33,3 +33,4 @@ export declare function getSubTenantsAsTree(options?: UserJwtOptions): Promise<I
|
|
|
33
33
|
export declare function getParentTenants(options?: UserJwtOptions): Promise<IParentTenant[]>;
|
|
34
34
|
export declare function getTenantsUsersCount(body: IGetTenantsUserCountRequest, options?: UserJwtOptions): Promise<IGetTenantsUserCountResponse[]>;
|
|
35
35
|
export declare function searchSubTenants(params: SearchSubTenantsParams, options?: UserJwtOptions): Promise<FronteggPaginationWrapper<SearchSubTenantsResponse>>;
|
|
36
|
+
export declare function getHierarchyMetadata(params: GetHierarchyMetadataParams, options?: UserJwtOptions): Promise<GetHierarchyMetadataResponse[]>;
|
package/tenants/index.js
CHANGED
|
@@ -30,4 +30,9 @@ export async function searchSubTenants(params, options) {
|
|
|
30
30
|
return Get(urls.tenants.hierarchy.v2, params, {
|
|
31
31
|
headers: extractHeadersFromOptions(options)
|
|
32
32
|
});
|
|
33
|
+
}
|
|
34
|
+
export async function getHierarchyMetadata(params, options) {
|
|
35
|
+
return Get(urls.tenants.hierarchy.metadata.v2, params, {
|
|
36
|
+
headers: extractHeadersFromOptions(options)
|
|
37
|
+
});
|
|
33
38
|
}
|
package/tenants/interfaces.d.ts
CHANGED
|
@@ -93,8 +93,20 @@ export interface SearchSubTenantsParams {
|
|
|
93
93
|
_sortBy?: TenantSortByEnum;
|
|
94
94
|
_order?: PaginationOrderEnum;
|
|
95
95
|
}
|
|
96
|
+
export interface SearchSubTenantMetadata {
|
|
97
|
+
isParent?: boolean;
|
|
98
|
+
}
|
|
96
99
|
export interface SearchSubTenantsResponse {
|
|
97
100
|
tenantId: string;
|
|
98
101
|
name: string;
|
|
99
102
|
createdAt: Date;
|
|
103
|
+
metadata: SearchSubTenantMetadata;
|
|
104
|
+
}
|
|
105
|
+
export interface GetHierarchyMetadataParams {
|
|
106
|
+
_tenantIds: string[];
|
|
107
|
+
}
|
|
108
|
+
export interface GetHierarchyMetadataResponse {
|
|
109
|
+
tenantId: string;
|
|
110
|
+
totalSubTenants: number;
|
|
111
|
+
isParent: boolean;
|
|
100
112
|
}
|
package/users/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { GetUserJwtRequestDto, GetUserJwtResponseDto, ISearchUserQueryParamsV3, IUsersV3Data } from "./interfaces";
|
|
1
|
+
import { GetUserJwtRequestDto, GetUserJwtResponseDto, GetUserRolesResponse, GetUsersRolesParams, ISearchUserQueryParamsV3, IUsersV3Data } from "./interfaces";
|
|
2
2
|
import { FronteggPaginationWrapper, UserJwtOptions } from "../interfaces";
|
|
3
3
|
export declare function GetUserJwt(body: GetUserJwtRequestDto): Promise<GetUserJwtResponseDto>;
|
|
4
4
|
export declare function getUsersV3(queryParams: ISearchUserQueryParamsV3, options?: UserJwtOptions): Promise<FronteggPaginationWrapper<IUsersV3Data>>;
|
|
5
|
+
export declare function getUsersRoles(queryParams: GetUsersRolesParams, options?: UserJwtOptions): Promise<GetUserRolesResponse[]>;
|
package/users/index.js
CHANGED
|
@@ -7,4 +7,9 @@ export async function getUsersV3(queryParams, options) {
|
|
|
7
7
|
return Get(urls.identity.users.v3, queryParams, {
|
|
8
8
|
headers: extractHeadersFromOptions(options)
|
|
9
9
|
});
|
|
10
|
+
}
|
|
11
|
+
export async function getUsersRoles(queryParams, options) {
|
|
12
|
+
return Get(urls.identity.users.roles.v3, queryParams, {
|
|
13
|
+
headers: extractHeadersFromOptions(options)
|
|
14
|
+
});
|
|
10
15
|
}
|
package/users/interfaces.d.ts
CHANGED
|
@@ -45,3 +45,12 @@ export interface IUsersV3Data {
|
|
|
45
45
|
lastLogin?: Date;
|
|
46
46
|
subAccountAccessAllowed?: boolean;
|
|
47
47
|
}
|
|
48
|
+
export interface GetUsersRolesParams {
|
|
49
|
+
ids: string[];
|
|
50
|
+
}
|
|
51
|
+
export interface GetUserRolesResponse {
|
|
52
|
+
vendorId: string;
|
|
53
|
+
tenantId: string;
|
|
54
|
+
userId: string;
|
|
55
|
+
roleIds: string[];
|
|
56
|
+
}
|