monkey-front-core 22.2.2 → 22.2.4
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.
|
@@ -2571,7 +2571,7 @@ class MonkeyEcxRequestStateService {
|
|
|
2571
2571
|
clearData(id) {
|
|
2572
2572
|
requestsMap.delete(id);
|
|
2573
2573
|
}
|
|
2574
|
-
getHeaders(url) {
|
|
2574
|
+
getHeaders(url, skipAuthorization = false) {
|
|
2575
2575
|
const isTokenMandatory = () => {
|
|
2576
2576
|
return !(this._bootstrapService
|
|
2577
2577
|
.getNotMandatoryUrls()
|
|
@@ -2583,7 +2583,7 @@ class MonkeyEcxRequestStateService {
|
|
|
2583
2583
|
if (!isTokenMandatory())
|
|
2584
2584
|
return {};
|
|
2585
2585
|
const token = this._tokenStorageService.getToken();
|
|
2586
|
-
let program = token
|
|
2586
|
+
let program = token?.program;
|
|
2587
2587
|
try {
|
|
2588
2588
|
program = this._bootstrapService.handleProgram?.(program) || program;
|
|
2589
2589
|
}
|
|
@@ -2591,11 +2591,13 @@ class MonkeyEcxRequestStateService {
|
|
|
2591
2591
|
//not to do
|
|
2592
2592
|
}
|
|
2593
2593
|
const headers = {
|
|
2594
|
-
Authorization: '',
|
|
2595
2594
|
Program: ''
|
|
2596
2595
|
};
|
|
2597
|
-
if (
|
|
2598
|
-
headers.Authorization =
|
|
2596
|
+
if (!skipAuthorization) {
|
|
2597
|
+
headers.Authorization = '';
|
|
2598
|
+
if (MonkeyEcxUtils.persistNullEmptyUndefined(token?.accessToken)) {
|
|
2599
|
+
headers.Authorization = `Bearer ${token?.accessToken}`;
|
|
2600
|
+
}
|
|
2599
2601
|
}
|
|
2600
2602
|
if (MonkeyEcxUtils.persistNullEmptyUndefined(program)) {
|
|
2601
2603
|
headers.Program = program;
|
|
@@ -4225,10 +4227,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImpor
|
|
|
4225
4227
|
* MIT Licence
|
|
4226
4228
|
************************* */
|
|
4227
4229
|
|
|
4230
|
+
function isPlainObject(value) {
|
|
4231
|
+
if (typeof value !== 'object' || value === null) {
|
|
4232
|
+
return false;
|
|
4233
|
+
}
|
|
4234
|
+
const proto = Object.getPrototypeOf(value);
|
|
4235
|
+
return proto === Object.prototype || proto === null;
|
|
4236
|
+
}
|
|
4228
4237
|
function MonkeyEcxCoreService(params) {
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
propertyDescriptor.value = function (...args) {
|
|
4238
|
+
const wrap = (method) => {
|
|
4239
|
+
return function wrapped(...args) {
|
|
4232
4240
|
const context = this;
|
|
4233
4241
|
Object.entries(context).forEach(([key, value]) => {
|
|
4234
4242
|
if (value instanceof MonkeyEcxService) {
|
|
@@ -4236,19 +4244,22 @@ function MonkeyEcxCoreService(params) {
|
|
|
4236
4244
|
}
|
|
4237
4245
|
});
|
|
4238
4246
|
const requestArgs = args.map((arg) => {
|
|
4239
|
-
if (
|
|
4240
|
-
arg !== null &&
|
|
4241
|
-
!Array.isArray(arg) &&
|
|
4242
|
-
arg.context === undefined) {
|
|
4247
|
+
if (isPlainObject(arg) && arg.context === undefined) {
|
|
4243
4248
|
return { ...arg };
|
|
4244
4249
|
}
|
|
4245
4250
|
return arg;
|
|
4246
4251
|
});
|
|
4247
|
-
|
|
4248
|
-
return result;
|
|
4252
|
+
return method.apply(context, requestArgs);
|
|
4249
4253
|
};
|
|
4250
|
-
return propertyDescriptor;
|
|
4251
4254
|
};
|
|
4255
|
+
return ((...args) => {
|
|
4256
|
+
if (args.length === 2 && typeof args[1] === 'object' && 'kind' in args[1]) {
|
|
4257
|
+
return wrap(args[0]);
|
|
4258
|
+
}
|
|
4259
|
+
const descriptor = args[2];
|
|
4260
|
+
descriptor.value = wrap(descriptor.value);
|
|
4261
|
+
return descriptor;
|
|
4262
|
+
});
|
|
4252
4263
|
}
|
|
4253
4264
|
|
|
4254
4265
|
/** ************************
|
|
@@ -5119,12 +5130,13 @@ const monkeyEcxHttpConfigInterceptor = (req, next) => {
|
|
|
5119
5130
|
return next(req);
|
|
5120
5131
|
}
|
|
5121
5132
|
const state = requestId ? requestStateService.getData(requestId) : null;
|
|
5122
|
-
const
|
|
5133
|
+
const skipAuthorization = !!state?.skipAuthorization;
|
|
5134
|
+
const headers = requestStateService.getHeaders(req.url, skipAuthorization);
|
|
5123
5135
|
const updatedReq = req.clone({ setHeaders: headers });
|
|
5124
5136
|
return next(updatedReq).pipe(map$1((event) => {
|
|
5125
5137
|
return event;
|
|
5126
5138
|
}), catchError$1((error) => {
|
|
5127
|
-
if (refreshShouldHappen(error)) {
|
|
5139
|
+
if (!skipAuthorization && refreshShouldHappen(error)) {
|
|
5128
5140
|
requestErrorService.handleError(error, state);
|
|
5129
5141
|
return requestStateService.handleRefreshTokenError(req, next);
|
|
5130
5142
|
}
|