backtrace-service
Advanced tools
Comparing version 3.3.0 to 3.3.1
@@ -29,3 +29,3 @@ import { NextFunction, Request, Response } from 'express'; | ||
private onCoronerCallback?; | ||
private logger?; | ||
private _logger?; | ||
private httpsAgent; | ||
@@ -99,4 +99,3 @@ constructor(descr: IServiceDescriptor, logger?: Logger); | ||
private sanitizeHeader; | ||
private log; | ||
private readCoronerAuthInfo; | ||
} |
@@ -72,2 +72,3 @@ "use strict"; | ||
var backtraceUniverseHelper_1 = require("../universe/backtraceUniverseHelper"); | ||
var errorHelper_1 = require("../utils/errorHelper"); | ||
/** | ||
@@ -134,3 +135,3 @@ * Identity manager | ||
} | ||
this.logger = logger; | ||
this._logger = logger; | ||
}; | ||
@@ -276,3 +277,3 @@ /* | ||
if (!registeredUniverse) { | ||
this.log('warn', "universe ".concat(requestedUniverse, " not found in registeredUniverses")); | ||
(_b = this._logger) === null || _b === void 0 ? void 0 : _b.warn("universe ".concat(requestedUniverse, " not found in registeredUniverses")); | ||
} | ||
@@ -289,8 +290,3 @@ authRequest.coronerAuth = { | ||
err_1 = _c.sent(); | ||
if (axios_1.default.isAxiosError(err_1) && ((_b = err_1.response) === null || _b === void 0 ? void 0 : _b.status)) { | ||
next(new apiError_1.ApiError(err_1.message, err_1.response.status)); | ||
} | ||
else { | ||
next(err_1); | ||
} | ||
next(new apiError_1.ApiError(errorHelper_1.ErrorHelper.getErrorMessage(err_1), errorHelper_1.ErrorHelper.getErrorStatusCode(err_1))); | ||
return [3 /*break*/, 6]; | ||
@@ -307,3 +303,3 @@ case 6: return [2 /*return*/]; | ||
IdentityManager.prototype.checkProjectAccess = function (request, response, projects) { | ||
var _a, _b, _c, _d, _e; | ||
var _a, _b, _c, _d, _e, _f; | ||
var authRequest = request; | ||
@@ -314,4 +310,5 @@ var universe = (_b = (_a = authRequest === null || authRequest === void 0 ? void 0 : authRequest.coronerAuth) === null || _a === void 0 ? void 0 : _a.cfg) === null || _b === void 0 ? void 0 : _b.universe; | ||
if (!projectsExt) { | ||
this.log('debug', "missing projects_ext"); | ||
return false; // invalidated because flag is never set to true | ||
(_f = this._logger) === null || _f === void 0 ? void 0 : _f.debug("missing projects_ext for universe ".concat(universe.name)); | ||
// invalidated because flag is never set to true | ||
return false; | ||
} | ||
@@ -405,3 +402,3 @@ return ProjectValidation.check(response, projectsExt, projects); | ||
err_2 = _b.sent(); | ||
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.error(err_2, "Cannot login to coronerd. Requested address: ".concat(requestUrl)); | ||
(_a = this._logger) === null || _a === void 0 ? void 0 : _a.warn("Cannot login to coronerd. Requested address: ".concat(requestUrl, ". Reason: ").concat(errorHelper_1.ErrorHelper.getErrorMessage(err_2))); | ||
return [2 /*return*/, undefined]; | ||
@@ -418,8 +415,8 @@ case 4: return [2 /*return*/]; | ||
IdentityManager.prototype.retrieveAndStoreCoronerdInfo = function (coronerdUrl, serviceToCoronerdUrl) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var bpgRequestUrl, prefix, protocol, bpgUniverseRequestUrl, serviceConfiguration, token, headers, bpgUniverseResult, bpgUniverseObjects, err_3; | ||
var bpgRequestUrl, prefix, protocol, bpgUniverseRequestUrl, serviceConfiguration, token, headers, bpgUniverseResult, bpgUniverseObjects, err_3, errorReason, errorMessage; | ||
var _this = this; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
return __generator(this, function (_e) { | ||
switch (_e.label) { | ||
case 0: | ||
@@ -433,10 +430,7 @@ if (!coronerdUrl) { | ||
bpgUniverseRequestUrl = "".concat(protocol).concat(bpgRequestUrl).concat(prefix, "api/bpg"); | ||
_d.label = 1; | ||
return [4 /*yield*/, this.loginCoronerd(bpgRequestUrl)]; | ||
case 1: | ||
_d.trys.push([1, 4, , 5]); | ||
return [4 /*yield*/, this.loginCoronerd(bpgRequestUrl)]; | ||
case 2: | ||
serviceConfiguration = _d.sent(); | ||
serviceConfiguration = _e.sent(); | ||
if (!serviceConfiguration) { | ||
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.warn("Cannot login to coronerd instance from the service. Coroenrd URL :".concat(bpgRequestUrl)); | ||
(_a = this._logger) === null || _a === void 0 ? void 0 : _a.warn("Cannot login to coronerd instance from the service. Coroenrd URL :".concat(bpgRequestUrl)); | ||
return [2 /*return*/, false]; | ||
@@ -453,4 +447,7 @@ } | ||
else { | ||
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.warn('BPG call: Coronerd token is undefined.'); | ||
(_b = this._logger) === null || _b === void 0 ? void 0 : _b.warn('BPG call: Coronerd token is undefined.'); | ||
} | ||
_e.label = 2; | ||
case 2: | ||
_e.trys.push([2, 4, , 5]); | ||
return [4 /*yield*/, axios_1.default.post(bpgUniverseRequestUrl, { | ||
@@ -463,3 +460,3 @@ actions: [{ action: 'get', type: 'configuration/universe' }], | ||
case 3: | ||
bpgUniverseResult = _d.sent(); | ||
bpgUniverseResult = _e.sent(); | ||
bpgUniverseObjects = bpgUniverseResult.data.results[0].result; | ||
@@ -475,4 +472,11 @@ bpgUniverseObjects.forEach(function (universe) { | ||
case 4: | ||
err_3 = _d.sent(); | ||
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.error(err_3, "Cannot get universes from coronerd. Requested address: ".concat(bpgUniverseRequestUrl)); | ||
err_3 = _e.sent(); | ||
errorReason = errorHelper_1.ErrorHelper.getErrorMessage(err_3); | ||
errorMessage = "Cannot get universes from coronerd. Requested address: ".concat(bpgUniverseRequestUrl, ". Reason: ").concat(errorReason); | ||
if (axios_1.default.isAxiosError(err_3)) { | ||
(_c = this._logger) === null || _c === void 0 ? void 0 : _c.warn(errorReason); | ||
} | ||
else { | ||
(_d = this._logger) === null || _d === void 0 ? void 0 : _d.error(err_3, { 'error.message': errorMessage }); | ||
} | ||
return [2 /*return*/, false]; | ||
@@ -559,7 +563,2 @@ case 5: return [2 /*return*/]; | ||
}; | ||
IdentityManager.prototype.log = function (level, msg) { | ||
if (this.logger) { | ||
this.logger.log(level, msg); | ||
} | ||
}; | ||
IdentityManager.prototype.readCoronerAuthInfo = function (request) { | ||
@@ -566,0 +565,0 @@ var authRequest = request; |
@@ -40,2 +40,3 @@ /** | ||
export { asyncWrapper } from './utils/asyncWrapper'; | ||
export { ErrorHelper } from './utils/errorHelper'; | ||
export { PackageUtils } from './utils/packageUtils'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PackageUtils = exports.asyncWrapper = exports.UniverseHelper = exports.ServiceConfiguration = exports.BacktraceService = exports.ErrorScope = exports.ApiError = exports.MetricsStorage = exports.Logger = exports.IdentityManager = exports.listenDescriptor = exports.getDescriptor = void 0; | ||
exports.PackageUtils = exports.ErrorHelper = exports.asyncWrapper = exports.UniverseHelper = exports.ServiceConfiguration = exports.BacktraceService = exports.ErrorScope = exports.ApiError = exports.MetricsStorage = exports.Logger = exports.IdentityManager = exports.listenDescriptor = exports.getDescriptor = void 0; | ||
/** | ||
@@ -43,4 +43,6 @@ * Identity | ||
Object.defineProperty(exports, "asyncWrapper", { enumerable: true, get: function () { return asyncWrapper_1.asyncWrapper; } }); | ||
var errorHelper_1 = require("./utils/errorHelper"); | ||
Object.defineProperty(exports, "ErrorHelper", { enumerable: true, get: function () { return errorHelper_1.ErrorHelper; } }); | ||
var packageUtils_1 = require("./utils/packageUtils"); | ||
Object.defineProperty(exports, "PackageUtils", { enumerable: true, get: function () { return packageUtils_1.PackageUtils; } }); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "backtrace-service", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "Common tools for Backtrace Node services", | ||
@@ -5,0 +5,0 @@ "author": "Backtrace", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
215232
82
3134