@frontegg/rest-api 7.31.0-alpha.6 → 7.32.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/FetchClient.d.ts +0 -1
- package/FetchClient.js +3 -7
- package/auth/index.js +6 -1
- package/constants.d.ts +0 -1
- package/constants.js +1 -2
- package/entitlements/interfaces.d.ts +4 -0
- package/entitlements/interfaces.js +6 -1
- package/error.d.ts +1 -3
- package/error.js +1 -6
- package/index.js +1 -1
- package/node/FetchClient.js +2 -6
- package/node/auth/index.js +6 -1
- package/node/constants.js +2 -4
- package/node/entitlements/interfaces.js +7 -2
- package/node/error.js +1 -6
- package/node/index.js +1 -1
- package/package.json +1 -1
package/FetchClient.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export declare class FetchClient {
|
|
|
12
12
|
private getAdditionalQueryParams;
|
|
13
13
|
private getAdditionalHeaders;
|
|
14
14
|
private buildRequestHeaders;
|
|
15
|
-
private getResponseTraceId;
|
|
16
15
|
sendRequest: (opts: RequestOptions) => Promise<any>;
|
|
17
16
|
get: (url: string, params?: any, opts?: Omit<RequestOptions, "method" | "url">) => Promise<any>;
|
|
18
17
|
post: (url: string, body?: any, opts?: Omit<RequestOptions, "method" | "url">) => Promise<any>;
|
package/FetchClient.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { ContextHolder } from './ContextHolder';
|
|
3
3
|
import { FronteggApiError } from './error';
|
|
4
|
-
import {
|
|
4
|
+
import { GENERIC_ERROR_MESSAGE } from './constants';
|
|
5
5
|
import { fronteggHeaders } from './interfaces';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -95,10 +95,6 @@ export class FetchClient {
|
|
|
95
95
|
}
|
|
96
96
|
return headers;
|
|
97
97
|
};
|
|
98
|
-
this.getResponseTraceId = response => {
|
|
99
|
-
var _response$headers, _response$headers$get;
|
|
100
|
-
return response == null ? void 0 : (_response$headers = response.headers) == null ? void 0 : (_response$headers$get = _response$headers.get) == null ? void 0 : _response$headers$get.call(_response$headers, FRONTEGG_TRACE_ID);
|
|
101
|
-
};
|
|
102
98
|
this.sendRequest = async opts => {
|
|
103
99
|
var _opts$method, _ref, _opts$credentials;
|
|
104
100
|
const context = this.getFronteggContext().getContext();
|
|
@@ -120,7 +116,7 @@ export class FetchClient {
|
|
|
120
116
|
if (!response.ok) {
|
|
121
117
|
var _context$logLevel, _context$logLevel2;
|
|
122
118
|
if (response.status === 413) {
|
|
123
|
-
throw new FronteggApiError('Error request is too large', response.status
|
|
119
|
+
throw new FronteggApiError('Error request is too large', response.status);
|
|
124
120
|
}
|
|
125
121
|
let errorMessage;
|
|
126
122
|
let isJsonResponse = true;
|
|
@@ -136,7 +132,7 @@ export class FetchClient {
|
|
|
136
132
|
errorMessage = `Error ${response.status} - ${response.statusText}`;
|
|
137
133
|
}
|
|
138
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);
|
|
139
|
-
throw new FronteggApiError(isJsonResponse ? errorMessage : GENERIC_ERROR_MESSAGE, response.status
|
|
135
|
+
throw new FronteggApiError(isJsonResponse ? errorMessage : GENERIC_ERROR_MESSAGE, response.status);
|
|
140
136
|
}
|
|
141
137
|
if (opts.responseType === 'stream') {
|
|
142
138
|
return response.body;
|
package/auth/index.js
CHANGED
|
@@ -10,6 +10,7 @@ export { setTabTenantInSessionStorage, getTabTenantFromSessionStorage, getCurren
|
|
|
10
10
|
import { urls } from '../constants';
|
|
11
11
|
import { jwtDecode } from '../jwt';
|
|
12
12
|
import { LOAD_AUTHORIZATION_FF } from './interfaces';
|
|
13
|
+
import { ADMIN_PORTAL_ENTITLEMENTS_FF } from '../entitlements/interfaces';
|
|
13
14
|
import { FeatureFlags } from '../feature-flags';
|
|
14
15
|
import { executeConditionalPromise, getCurrentUserTenantsFunction, getTabTenantFromSessionStorage, setTabTenantInSessionStorage } from './utils';
|
|
15
16
|
import { TenantsApi } from '../tenants';
|
|
@@ -762,7 +763,11 @@ export class AuthenticationApi extends BaseApiClient {
|
|
|
762
763
|
* @returns true if entitlements load should be done
|
|
763
764
|
*/
|
|
764
765
|
shouldLoadEntitlements() {
|
|
765
|
-
|
|
766
|
+
if (!ContextHolder.for(this.appName).shouldLoadEntitlements()) {
|
|
767
|
+
return false;
|
|
768
|
+
}
|
|
769
|
+
const [isEntitlementsFFOn] = FeatureFlags.getFeatureFlags([ADMIN_PORTAL_ENTITLEMENTS_FF], this.appName || '');
|
|
770
|
+
return isEntitlementsFFOn;
|
|
766
771
|
}
|
|
767
772
|
|
|
768
773
|
/**
|
package/constants.d.ts
CHANGED
package/constants.js
CHANGED
|
@@ -281,5 +281,4 @@ export const urls = {
|
|
|
281
281
|
v1: 'http://localhost:3037/resources/velo/v1'
|
|
282
282
|
}
|
|
283
283
|
};
|
|
284
|
-
export const GENERIC_ERROR_MESSAGE = `We're facing some difficulties, Please try again`;
|
|
285
|
-
export const FRONTEGG_TRACE_ID = 'frontegg-trace-id';
|
|
284
|
+
export const GENERIC_ERROR_MESSAGE = `We're facing some difficulties, Please try again`;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export let NotEntitledJustification;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* entitlements feature flag
|
|
5
|
+
*/
|
|
2
6
|
(function (NotEntitledJustification) {
|
|
3
7
|
NotEntitledJustification["MISSING_PERMISSION"] = "MISSING_PERMISSION";
|
|
4
8
|
NotEntitledJustification["MISSING_FEATURE"] = "MISSING_FEATURE";
|
|
5
9
|
NotEntitledJustification["BUNDLE_EXPIRED"] = "BUNDLE_EXPIRED";
|
|
6
|
-
})(NotEntitledJustification || (NotEntitledJustification = {}));
|
|
10
|
+
})(NotEntitledJustification || (NotEntitledJustification = {}));
|
|
11
|
+
export const ADMIN_PORTAL_ENTITLEMENTS_FF = 'admin_portal_entitlements';
|
package/error.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export declare class FronteggApiError extends Error {
|
|
2
2
|
private readonly _statusCode;
|
|
3
|
-
|
|
4
|
-
constructor(message: string, statusCode: number, traceId: string | null);
|
|
3
|
+
constructor(message: string, statusCode: number);
|
|
5
4
|
get statusCode(): number;
|
|
6
|
-
get traceId(): string | null;
|
|
7
5
|
}
|
package/error.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
export class FronteggApiError extends Error {
|
|
2
|
-
constructor(message, statusCode
|
|
2
|
+
constructor(message, statusCode) {
|
|
3
3
|
super(message);
|
|
4
4
|
this._statusCode = void 0;
|
|
5
|
-
this._traceId = void 0;
|
|
6
5
|
this._statusCode = statusCode;
|
|
7
|
-
this._traceId = traceId;
|
|
8
6
|
}
|
|
9
7
|
get statusCode() {
|
|
10
8
|
return this._statusCode;
|
|
11
9
|
}
|
|
12
|
-
get traceId() {
|
|
13
|
-
return this._traceId;
|
|
14
|
-
}
|
|
15
10
|
}
|
package/index.js
CHANGED
package/node/FetchClient.js
CHANGED
|
@@ -101,10 +101,6 @@ class FetchClient {
|
|
|
101
101
|
}
|
|
102
102
|
return headers;
|
|
103
103
|
};
|
|
104
|
-
this.getResponseTraceId = response => {
|
|
105
|
-
var _response$headers, _response$headers$get;
|
|
106
|
-
return response == null ? void 0 : (_response$headers = response.headers) == null ? void 0 : (_response$headers$get = _response$headers.get) == null ? void 0 : _response$headers$get.call(_response$headers, _constants.FRONTEGG_TRACE_ID);
|
|
107
|
-
};
|
|
108
104
|
this.sendRequest = async opts => {
|
|
109
105
|
var _opts$method, _ref, _opts$credentials;
|
|
110
106
|
const context = this.getFronteggContext().getContext();
|
|
@@ -126,7 +122,7 @@ class FetchClient {
|
|
|
126
122
|
if (!response.ok) {
|
|
127
123
|
var _context$logLevel, _context$logLevel2;
|
|
128
124
|
if (response.status === 413) {
|
|
129
|
-
throw new _error.FronteggApiError('Error request is too large', response.status
|
|
125
|
+
throw new _error.FronteggApiError('Error request is too large', response.status);
|
|
130
126
|
}
|
|
131
127
|
let errorMessage;
|
|
132
128
|
let isJsonResponse = true;
|
|
@@ -142,7 +138,7 @@ class FetchClient {
|
|
|
142
138
|
errorMessage = `Error ${response.status} - ${response.statusText}`;
|
|
143
139
|
}
|
|
144
140
|
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);
|
|
145
|
-
throw new _error.FronteggApiError(isJsonResponse ? errorMessage : _constants.GENERIC_ERROR_MESSAGE, response.status
|
|
141
|
+
throw new _error.FronteggApiError(isJsonResponse ? errorMessage : _constants.GENERIC_ERROR_MESSAGE, response.status);
|
|
146
142
|
}
|
|
147
143
|
if (opts.responseType === 'stream') {
|
|
148
144
|
return response.body;
|
package/node/auth/index.js
CHANGED
|
@@ -75,6 +75,7 @@ var _utils = require("./utils");
|
|
|
75
75
|
var _constants2 = require("../constants");
|
|
76
76
|
var _jwt = require("../jwt");
|
|
77
77
|
var _interfaces = require("./interfaces");
|
|
78
|
+
var _interfaces2 = require("../entitlements/interfaces");
|
|
78
79
|
var _featureFlags = require("../feature-flags");
|
|
79
80
|
var _tenants = require("../tenants");
|
|
80
81
|
var _BaseApiClient = require("../BaseApiClient");
|
|
@@ -828,7 +829,11 @@ class AuthenticationApi extends _BaseApiClient.BaseApiClient {
|
|
|
828
829
|
* @returns true if entitlements load should be done
|
|
829
830
|
*/
|
|
830
831
|
shouldLoadEntitlements() {
|
|
831
|
-
|
|
832
|
+
if (!_ContextHolder.ContextHolder.for(this.appName).shouldLoadEntitlements()) {
|
|
833
|
+
return false;
|
|
834
|
+
}
|
|
835
|
+
const [isEntitlementsFFOn] = _featureFlags.FeatureFlags.getFeatureFlags([_interfaces2.ADMIN_PORTAL_ENTITLEMENTS_FF], this.appName || '');
|
|
836
|
+
return isEntitlementsFFOn;
|
|
832
837
|
}
|
|
833
838
|
|
|
834
839
|
/**
|
package/node/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.urls = exports.GENERIC_ERROR_MESSAGE =
|
|
6
|
+
exports.urls = exports.GENERIC_ERROR_MESSAGE = void 0;
|
|
7
7
|
const urls = {
|
|
8
8
|
vendor: '/vendors',
|
|
9
9
|
identity: {
|
|
@@ -289,6 +289,4 @@ const urls = {
|
|
|
289
289
|
};
|
|
290
290
|
exports.urls = urls;
|
|
291
291
|
const GENERIC_ERROR_MESSAGE = `We're facing some difficulties, Please try again`;
|
|
292
|
-
exports.GENERIC_ERROR_MESSAGE = GENERIC_ERROR_MESSAGE;
|
|
293
|
-
const FRONTEGG_TRACE_ID = 'frontegg-trace-id';
|
|
294
|
-
exports.FRONTEGG_TRACE_ID = FRONTEGG_TRACE_ID;
|
|
292
|
+
exports.GENERIC_ERROR_MESSAGE = GENERIC_ERROR_MESSAGE;
|
|
@@ -3,11 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.NotEntitledJustification = void 0;
|
|
6
|
+
exports.NotEntitledJustification = exports.ADMIN_PORTAL_ENTITLEMENTS_FF = void 0;
|
|
7
7
|
let NotEntitledJustification;
|
|
8
|
+
/**
|
|
9
|
+
* entitlements feature flag
|
|
10
|
+
*/
|
|
8
11
|
exports.NotEntitledJustification = NotEntitledJustification;
|
|
9
12
|
(function (NotEntitledJustification) {
|
|
10
13
|
NotEntitledJustification["MISSING_PERMISSION"] = "MISSING_PERMISSION";
|
|
11
14
|
NotEntitledJustification["MISSING_FEATURE"] = "MISSING_FEATURE";
|
|
12
15
|
NotEntitledJustification["BUNDLE_EXPIRED"] = "BUNDLE_EXPIRED";
|
|
13
|
-
})(NotEntitledJustification || (exports.NotEntitledJustification = NotEntitledJustification = {}));
|
|
16
|
+
})(NotEntitledJustification || (exports.NotEntitledJustification = NotEntitledJustification = {}));
|
|
17
|
+
const ADMIN_PORTAL_ENTITLEMENTS_FF = 'admin_portal_entitlements';
|
|
18
|
+
exports.ADMIN_PORTAL_ENTITLEMENTS_FF = ADMIN_PORTAL_ENTITLEMENTS_FF;
|
package/node/error.js
CHANGED
|
@@ -5,18 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.FronteggApiError = void 0;
|
|
7
7
|
class FronteggApiError extends Error {
|
|
8
|
-
constructor(message, statusCode
|
|
8
|
+
constructor(message, statusCode) {
|
|
9
9
|
super(message);
|
|
10
10
|
this._statusCode = void 0;
|
|
11
|
-
this._traceId = void 0;
|
|
12
11
|
this._statusCode = statusCode;
|
|
13
|
-
this._traceId = traceId;
|
|
14
12
|
}
|
|
15
13
|
get statusCode() {
|
|
16
14
|
return this._statusCode;
|
|
17
15
|
}
|
|
18
|
-
get traceId() {
|
|
19
|
-
return this._traceId;
|
|
20
|
-
}
|
|
21
16
|
}
|
|
22
17
|
exports.FronteggApiError = FronteggApiError;
|
package/node/index.js
CHANGED