Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

backtrace-service

Package Overview
Dependencies
Maintainers
5
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backtrace-service - npm Package Compare versions

Comparing version 3.0.0-alpha.4 to 3.0.0-alpha.5

5

lib/identity/identity.d.ts

@@ -0,1 +1,2 @@

/// <reference types="qs" />
import { NextFunction, Request, Response } from 'express';

@@ -19,3 +20,3 @@ import { IServiceDescriptor } from '../model/serviceDescriptor';

}): void;
serviceRequest(opts?: ICoronerRequestOption): ((request: Request<import("express-serve-static-core").ParamsDictionary>, response: Response, next: NextFunction) => void)[];
serviceRequest(opts?: ICoronerRequestOption): ((request: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs>, response: Response<any>, next: NextFunction) => void)[];
/**

@@ -27,3 +28,3 @@ * Generate a middleware for Express.js, which authenticates a request given

*/
authenticateRequest(): (request: Request<import("express-serve-static-core").ParamsDictionary>, response: Response, next: NextFunction) => Promise<void>;
authenticateRequest(): (request: Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs>, response: Response<any>, next: NextFunction) => Promise<void>;
/**

@@ -30,0 +31,0 @@ * This assumes route has already passed authentication through authenticateRequest

4

lib/identity/identity.js

@@ -336,5 +336,3 @@ "use strict";

}
return crypto_1.createHmac('sha256', secret)
.update(nonce)
.digest('hex');
return crypto_1.createHmac('sha256', secret).update(nonce).digest('hex');
};

@@ -341,0 +339,0 @@ IdentityManager.prototype.checkHmac = function (secret, nonce, proposedHMac) {

@@ -43,3 +43,3 @@ import express from 'express';

*/
static setupMiddlewares(app: express.Express, prefix?: string): void;
static setupMiddlewares(app: express.Express, prefix?: string, identityManager?: IdentityManager): void;
/**

@@ -49,3 +49,3 @@ * Setup express error middleware

*/
static setupErrorMiddleware(app: express.Express): void;
static setupErrorMiddleware(app: express.Express, identityManager?: IdentityManager): void;
/**

@@ -52,0 +52,0 @@ * Setup security middlewares

@@ -50,3 +50,3 @@ "use strict";

hostUrl: (_h = (_g = this.configuration) === null || _g === void 0 ? void 0 : _g.metrics) === null || _h === void 0 ? void 0 : _h.hostUrl,
disableExpressMetrics: (_k = (_j = this.configuration) === null || _j === void 0 ? void 0 : _j.metrics) === null || _k === void 0 ? void 0 : _k.disableExpressMetrics
disableExpressMetrics: (_k = (_j = this.configuration) === null || _j === void 0 ? void 0 : _j.metrics) === null || _k === void 0 ? void 0 : _k.disableExpressMetrics,
}, this.app, this._logger);

@@ -93,3 +93,3 @@ this.prepareServiceLayer();

this.setupAuth(expressApp);
this.setupMiddlewares(expressApp, service.apiPrefix);
this.setupMiddlewares(expressApp, service.apiPrefix, service.identityManager);
this.setupServiceLayer(expressApp, name, port, function (ip) {

@@ -130,3 +130,3 @@ service.coronerdAddress.add(ip);

*/
BacktraceService.setupMiddlewares = function (app, prefix) {
BacktraceService.setupMiddlewares = function (app, prefix, identityManager) {
app.use(body_parser_1.json());

@@ -137,2 +137,4 @@ app.use(body_parser_1.urlencoded({ extended: true }));

app.get(prefix ? prefix : '/', function (_req, res) {
var _a;
(_a = identityManager) === null || _a === void 0 ? void 0 : _a.bypassProjectAccessCheck(res);
res.type('xml');

@@ -146,3 +148,3 @@ res.status(200).send("<html></html>");

*/
BacktraceService.setupErrorMiddleware = function (app) {
BacktraceService.setupErrorMiddleware = function (app, identityManager) {
app.use(function (err, req, res, next) {

@@ -179,2 +181,3 @@ // handle a situation when we already sent a response from onError method

app.use(function (req, res, next) {
var _a;
// prevent overriding headers.

@@ -184,2 +187,3 @@ if (res.headersSent) {

}
(_a = identityManager) === null || _a === void 0 ? void 0 : _a.bypassProjectAccessCheck(res);
// response json might be required by front-end

@@ -242,3 +246,3 @@ res.status(404).send({

}
BacktraceService.setupErrorMiddleware(this.app);
BacktraceService.setupErrorMiddleware(this.app, this.identityManager);
__1.listenDescriptor(this._descriptor, this.app, this.configuration.ssl, function () {

@@ -245,0 +249,0 @@ _this._logger.info("Application is Running. " + (_this._descriptor ? "Port: " + _this._descriptor.port : ''));

@@ -9,3 +9,3 @@ import { NextFunction, Request, Response } from 'express';

*/
export declare function check(res: Express.Response, allKnownProjects: IProjectsExt[], scopedProjects: string[] | number[]): boolean;
export declare function check(res: Express.Response, allKnownProjects: IProjectsExt[], scopedProjects: (string | number)[]): boolean;
/**

@@ -12,0 +12,0 @@ * Middleware for Backtrace Teams

@@ -11,8 +11,2 @@ "use strict";

exports.setInvalid = setInvalid;
function includes(arr, element) {
return arr.includes(element);
}
function push(arr, element) {
return arr.push(element);
}
/**

@@ -25,3 +19,3 @@ * Checks if scopedProjects are in allKnownProjects and

// Service owners can use original send method.
if (scopedProjects.length === 0) {
if (!scopedProjects || scopedProjects.length === 0) {
setInvalid(res);

@@ -32,5 +26,5 @@ return false;

var projects = Array.from(new Set(scopedProjects));
var projectIdKey = "pid";
if ((typeof projects[0]) === "string") {
projectIdKey = "name";
var projectIdKey = 'pid';
if (typeof projects[0] === 'string') {
projectIdKey = 'name';
}

@@ -40,4 +34,4 @@ // Loop over known projects and record ones that matched scoped list.

allKnownProjects.forEach(function (projectExt) {
if (includes(projects, projectExt[projectIdKey])) {
push(seen, projectExt[projectIdKey]);
if (projects.includes(projectExt[projectIdKey])) {
seen.push(projectExt[projectIdKey]);
}

@@ -68,3 +62,3 @@ });

res.statusCode = 403;
return originalSend.call(res, "project validation failed");
return originalSend.call(res, 'project validation failed');
};

@@ -71,0 +65,0 @@ next();

{
"name": "backtrace-service",
"version": "3.0.0-alpha.4",
"version": "3.0.0-alpha.5",
"description": "Common tools for Backtrace Node services",

@@ -51,2 +51,3 @@ "author": "Backtrace",

"mkdirp": "^0.5.1",
"tslint": "^6.1.2",
"winston": "^3.2.1"

@@ -64,8 +65,10 @@ },

"@types/node": "^11.13.5",
"@types/supertest": "^2.0.10",
"jest": "^24.7.1",
"minimist": "^1.2.5",
"nock": "^10.0.6",
"supertest": "^4.0.2",
"ts-jest": "^24.0.2",
"typescript": "^3.7.3"
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc