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