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

backtrace-node

Package Overview
Dependencies
Maintainers
4
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

backtrace-node - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

80

lib/backtraceApi.js
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var axios_1 = __importDefault(require("axios"));
var tslib_1 = require("tslib");
var axios_1 = tslib_1.__importDefault(require("axios"));
var events_1 = require("events");
var form_data_1 = __importDefault(require("form-data"));
var fs = __importStar(require("fs"));
var json_stringify_safe_1 = __importDefault(require("json-stringify-safe"));
var path = __importStar(require("path"));
var form_data_1 = tslib_1.__importDefault(require("form-data"));
var fs = tslib_1.__importStar(require("fs"));
var json_stringify_safe_1 = tslib_1.__importDefault(require("json-stringify-safe"));
var path = tslib_1.__importStar(require("path"));
var backtraceResult_1 = require("./model/backtraceResult");
var BacktraceApi = /** @class */ (function (_super) {
__extends(BacktraceApi, _super);
tslib_1.__extends(BacktraceApi, _super);
function BacktraceApi(backtraceUri, timeout) {

@@ -78,5 +20,5 @@ var _this = _super.call(this) || this;

BacktraceApi.prototype.send = function (report) {
return __awaiter(this, void 0, void 0, function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var data, formData, result, err, err_1;
return __generator(this, function (_a) {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {

@@ -115,5 +57,5 @@ case 0: return [4 /*yield*/, report.toJson()];

BacktraceApi.prototype.getFormData = function (report, data) {
return __awaiter(this, void 0, void 0, function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var formData, json, attachments;
return __generator(this, function (_a) {
return tslib_1.__generator(this, function (_a) {
formData = new form_data_1.default();

@@ -120,0 +62,0 @@ json = json_stringify_safe_1.default(data);

14

lib/backtraceClient.d.ts

@@ -14,2 +14,4 @@ /// <reference types="node" />

private _clientRateLimit;
private _symbolication;
private _symbolicationMap?;
constructor(clientOptions: IBacktraceClientOptions | BacktraceClientOptions);

@@ -25,2 +27,14 @@ /**

/**
* Set symbolication info
*/
setSymbolication(): void;
/**
* Add symbolication map to each report.
* @param symbolicationMap
*/
setSymbolicationMap(symbolicationMap: Array<{
file: string;
uuid: string;
}>): void;
/**
* Clear all saved attributes

@@ -27,0 +41,0 @@ */

"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var clientRateLimit_1 = require("./clientRateLimit");

@@ -73,10 +14,11 @@ var events_1 = require("events");

var BacktraceClient = /** @class */ (function (_super) {
__extends(BacktraceClient, _super);
tslib_1.__extends(BacktraceClient, _super);
function BacktraceClient(clientOptions) {
var _this = _super.call(this) || this;
_this._memorizedAttributes = {};
_this._symbolication = false;
if (!clientOptions.endpoint) {
throw new Error("Backtrace: missing 'endpoint' option.");
}
_this.options = __assign(__assign({}, new backtraceClientOptions_1.BacktraceClientOptions()), clientOptions);
_this.options = tslib_1.__assign(tslib_1.__assign({}, new backtraceClientOptions_1.BacktraceClientOptions()), clientOptions);
_this._backtraceApi = new backtraceApi_1.BacktraceApi(_this.getSubmitUrl(), _this.options.timeout);

@@ -98,2 +40,25 @@ _this._clientRateLimit = new clientRateLimit_1.ClientRateLimit(_this.options.rateLimit);

/**
* Set symbolication info
*/
BacktraceClient.prototype.setSymbolication = function () {
this._symbolication = true;
};
/**
* Add symbolication map to each report.
* @param symbolicationMap
*/
BacktraceClient.prototype.setSymbolicationMap = function (symbolicationMap) {
if (!symbolicationMap) {
throw new Error('Symbolication map is undefined');
}
if (!Array.isArray(symbolicationMap)) {
throw new TypeError('Invalid type of symbolication map');
}
var invalidValues = symbolicationMap.some(function (n) { return !n.file || !n.uuid; });
if (invalidValues) {
throw new TypeError('Symbolication map contains invalid values - missing file or uuid value');
}
this._symbolicationMap = symbolicationMap;
};
/**
* Clear all saved attributes

@@ -116,2 +81,6 @@ */

var report = new backtraceReport_1.BacktraceReport(payload, attributes, fileAttachments);
report.symbolication = this._symbolication;
if (this._symbolicationMap) {
report.symbolicationMap = this._symbolicationMap;
}
report.setSourceCodeOptions(this.options.tabWidth, this.options.contextLineCount);

@@ -129,5 +98,5 @@ return report;

if (fileAttachments === void 0) { fileAttachments = []; }
return __awaiter(this, void 0, void 0, function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var report, limitResult, result;
return __generator(this, function (_a) {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {

@@ -185,5 +154,5 @@ case 0:

BacktraceClient.prototype.sendAsync = function (report) {
return __awaiter(this, void 0, void 0, function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var limitResult;
return __generator(this, function (_a) {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {

@@ -233,3 +202,3 @@ case 0:

}
return __assign(__assign(__assign({}, attributes), this.options.attributes), this.getMemorizedAttributes());
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, attributes), this.options.attributes), this.getMemorizedAttributes());
};

@@ -236,0 +205,0 @@ BacktraceClient.prototype.getMemorizedAttributes = function () {

"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var fs = __importStar(require("fs"));
var path = __importStar(require("path"));
var tslib_1 = require("tslib");
var fs = tslib_1.__importStar(require("fs"));
var path = tslib_1.__importStar(require("path"));
/**

@@ -27,3 +21,3 @@ * Read module dependencies

function readModule(root, depth) {
if (depth === void 0) { depth = 5; }
if (depth === void 0) { depth = 10; }
if (depth < 0) {

@@ -61,3 +55,3 @@ return readLibModule();

function readLibModule() {
console.warn('reading Backtrace module - cannot found correct module');
console.warn('reading Backtrace module - cannot find correct module');
return require('../../package.json');

@@ -64,0 +58,0 @@ }

"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var fs = __importStar(require("fs"));
var process = __importStar(require("process"));
var tslib_1 = require("tslib");
var fs = tslib_1.__importStar(require("fs"));
var process = tslib_1.__importStar(require("process"));
var sys = process.platform;

@@ -13,0 +7,0 @@ var memInfoRe = /^(.+):\s+(\d+)\s*(.+)?$/;

@@ -27,2 +27,46 @@ import { BacktraceClient } from './backtraceClient';

/**
* Send report asynchronously to Backtrace
* @param payload report payload
* @param reportAttributes attributes
* @param fileAttachments file attachments paths
*/
export declare function reportAsync(payload: Error | string, reportAttributes?: object | undefined, fileAttachments?: string[]): Promise<BacktraceResult>;
/**
* Send Backtrace report to Backtrace asynchronously.
* @param data Backtrace report
*/
export declare function sendAsync(data: btReport.BacktraceReport): Promise<BacktraceResult>;
/**
* Memorize selected values from application.
* Memorized attributes will be available in your next Backtrace report.
* Memorized attributes will be only available for one report.
* @param key attribute key
* @param value attribute value
*/
export declare function memorize(key: string, value: any): void;
/**
* Clear all saved attributes
*/
export declare function clearMemorizedAttributes(): void;
/**
* Returns all memorized attributes without clearing them.
*/
export declare function checkMemorizedAttributes(): object;
/**
* Set symbolication info
*/
export declare function setSymbolication(): void;
/**
* Add symbolication map to each report.
* @param symbolicationMap
*/
export declare function setSymbolicationMap(symbolicationMap: Array<{
file: string;
uuid: string;
}>): void;
/**
* Send backtrace report to Backtrace
*/
export declare function sendReport(data: btReport.BacktraceReport, callback?: (err?: Error) => void): BacktraceResult;
/**
* Send report synchronosuly to Backtrace

@@ -29,0 +73,0 @@ * @param error report payload

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var backtraceClient_1 = require("./backtraceClient");

@@ -90,5 +44,5 @@ var backtraceClient;

if (arg4 === void 0) { arg4 = []; }
return __awaiter(this, void 0, void 0, function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var data, attachments, callback, result;
return __generator(this, function (_a) {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {

@@ -121,2 +75,107 @@ case 0:

/**
* Send report asynchronously to Backtrace
* @param payload report payload
* @param reportAttributes attributes
* @param fileAttachments file attachments paths
*/
function reportAsync(payload, reportAttributes, fileAttachments) {
if (reportAttributes === void 0) { reportAttributes = {}; }
if (fileAttachments === void 0) { fileAttachments = []; }
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!backtraceClient) {
throw new Error('Must call initialize method first');
}
return [4 /*yield*/, backtraceClient.reportAsync(payload, reportAttributes, fileAttachments)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
}
exports.reportAsync = reportAsync;
/**
* Send Backtrace report to Backtrace asynchronously.
* @param data Backtrace report
*/
function sendAsync(data) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0:
if (!backtraceClient) {
throw new Error('Must call initialize method first');
}
return [4 /*yield*/, backtraceClient.sendAsync(data)];
case 1: return [2 /*return*/, _a.sent()];
}
});
});
}
exports.sendAsync = sendAsync;
/**
* Memorize selected values from application.
* Memorized attributes will be available in your next Backtrace report.
* Memorized attributes will be only available for one report.
* @param key attribute key
* @param value attribute value
*/
function memorize(key, value) {
if (!backtraceClient) {
throw new Error('Must call initialize method first');
}
backtraceClient.memorize(key, value);
}
exports.memorize = memorize;
/**
* Clear all saved attributes
*/
function clearMemorizedAttributes() {
if (!backtraceClient) {
throw new Error('Must call initialize method first');
}
backtraceClient.clearMemorizedAttributes();
}
exports.clearMemorizedAttributes = clearMemorizedAttributes;
/**
* Returns all memorized attributes without clearing them.
*/
function checkMemorizedAttributes() {
var _a;
return (_a = backtraceClient) === null || _a === void 0 ? void 0 : _a.checkMemorizedAttributes();
}
exports.checkMemorizedAttributes = checkMemorizedAttributes;
/**
* Set symbolication info
*/
function setSymbolication() {
if (!backtraceClient) {
throw new Error('Must call initialize method first');
}
backtraceClient.setSymbolication();
}
exports.setSymbolication = setSymbolication;
/**
* Add symbolication map to each report.
* @param symbolicationMap
*/
function setSymbolicationMap(symbolicationMap) {
if (!backtraceClient) {
throw new Error('Must call initialize method first');
}
backtraceClient.setSymbolicationMap(symbolicationMap);
}
exports.setSymbolicationMap = setSymbolicationMap;
/**
* Send backtrace report to Backtrace
*/
function sendReport(data, callback) {
if (!backtraceClient) {
throw new Error('Must call initialize method first');
}
return backtraceClient.sendReport(data, callback);
}
exports.sendReport = sendReport;
/**
* Send report synchronosuly to Backtrace

@@ -164,3 +223,3 @@ * @param error report payload

}
backtraceClient.reportSync(err, __assign(__assign({}, req), resp));
backtraceClient.reportSync(err, tslib_1.__assign(tslib_1.__assign({}, req), resp));
next(err);

@@ -167,0 +226,0 @@ }

@@ -13,2 +13,3 @@ export declare class BacktraceClientOptions implements IBacktraceClientOptions {

rateLimit: number;
debugBacktrace: boolean;
}

@@ -15,0 +16,0 @@ export interface IBacktraceClientOptions {

@@ -14,2 +14,3 @@ "use strict";

this.rateLimit = 0;
this.debugBacktrace = false;
}

@@ -16,0 +17,0 @@ return BacktraceClientOptions;

@@ -22,2 +22,6 @@ import { ISourceCode } from './sourceCode';

};
symbolication_maps?: Array<{
file: string;
uuid: string;
}>;
}

@@ -10,2 +10,7 @@ import { IBacktraceData } from './backtraceData';

private attachments;
set symbolication(symbolication: boolean);
set symbolicationMap(symbolMap: Array<{
file: string;
uuid: string;
}>);
readonly uuid: string;

@@ -37,2 +42,4 @@ readonly timestamp: number;

stackTrace: BacktraceStackTrace;
private _symbolicationMap?;
private _symbolication;
/**

@@ -101,2 +108,6 @@ * Current report attributes

setSourceCodeOptions(tabWidth: number, contextLineCount: number): void;
/**
* Include symbolication information based on stack trace analysis
*/
private includeSymbolication;
private collectReportInformation;

@@ -103,0 +114,0 @@ private readBuiltInAttributes;

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
// tslint:disable-next-line: no-var-requires

@@ -61,3 +8,3 @@ var packageJson = require('./../../package.json');

var node_machine_id_1 = require("node-machine-id");
var os = __importStar(require("os"));
var os = tslib_1.__importStar(require("os"));
var moduleResolver_1 = require("../helpers/moduleResolver");

@@ -104,2 +51,3 @@ var processHelper_1 = require("../helpers/processHelper");

this.classifiers = [];
this._symbolication = false;
/**

@@ -124,2 +72,26 @@ * Current report attributes

}
Object.defineProperty(BacktraceReport.prototype, "symbolication", {
set: function (symbolication) {
this._symbolication = symbolication;
},
enumerable: true,
configurable: true
});
Object.defineProperty(BacktraceReport.prototype, "symbolicationMap", {
set: function (symbolMap) {
if (!symbolMap) {
throw new Error('Symbolication map is undefined');
}
if (!Array.isArray(symbolMap)) {
throw new TypeError('Invalid type of symbolication map');
}
var invalidValues = symbolMap.some(function (n) { return !n.file || !n.uuid; });
if (invalidValues) {
throw new TypeError('Symbolication map contains invalid values - missing file or uuid value');
}
this._symbolicationMap = symbolMap;
},
enumerable: true,
configurable: true
});
/**

@@ -168,3 +140,3 @@ * Check if report contains exception information

BacktraceReport.prototype.addObjectAttributes = function (attributes) {
this.clientAttributes = __assign(__assign(__assign({}, this.clientAttributes), this.attributes), attributes);
this.clientAttributes = tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, this.clientAttributes), this.attributes), attributes);
};

@@ -181,5 +153,5 @@ BacktraceReport.prototype.addAttribute = function (key, value) {

BacktraceReport.prototype.toJson = function () {
return __awaiter(this, void 0, void 0, function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var result;
return __generator(this, function (_a) {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {

@@ -209,4 +181,8 @@ case 0:

sourceCode: this.stackTrace.getSourceCode(),
symbolication_maps: this._symbolicationMap || this.stackTrace.symbolicationMaps,
};
if (this.attributes['symbolication_id']) {
// when symbolication information exists, set symbolication to sourcemap.
// we should check symbolicationMap and _symbolication boolean value and symbolication id from attributes
// if any value exists, we should extend report object with 'sourcemap' property.
if (this._symbolication || this.attributes['symbolication_id'] || this._symbolicationMap) {
result.symbolication = 'sourcemap';

@@ -223,6 +199,12 @@ }

};
/**
* Include symbolication information based on stack trace analysis
*/
BacktraceReport.prototype.includeSymbolication = function () {
return this._symbolication && !this.attributes['symbolication_id'] && !this._symbolicationMap;
};
BacktraceReport.prototype.collectReportInformation = function () {
return __awaiter(this, void 0, void 0, function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {

@@ -233,3 +215,3 @@ case 0:

this.stackTrace.setSourceCodeOptions(this.tabWidth, this.contextLineCount);
return [4 /*yield*/, this.stackTrace.parseStackFrames()];
return [4 /*yield*/, this.stackTrace.parseStackFrames(this.includeSymbolication())];
case 1:

@@ -240,3 +222,3 @@ _b.sent();

// combine attributes
this.attributes = __assign(__assign({}, this.readBuiltInAttributes()), this.clientAttributes);
this.attributes = tslib_1.__assign(tslib_1.__assign({}, this.readBuiltInAttributes()), this.clientAttributes);
// combine annotations

@@ -250,3 +232,3 @@ this.annotations = this.readAnnotation();

BacktraceReport.prototype.readBuiltInAttributes = function () {
return __assign(__assign(__assign(__assign({}, processHelper_1.readMemoryInformation()), processHelper_1.readProcessStatus()), this.readAttributes()), this.readErrorAttributes());
return tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, processHelper_1.readMemoryInformation()), processHelper_1.readProcessStatus()), this.readAttributes()), this.readErrorAttributes());
};

@@ -317,3 +299,3 @@ BacktraceReport.prototype.detectReportType = function (err) {

}
return __assign(__assign({}, result), this.annotations);
return tslib_1.__assign(tslib_1.__assign({}, result), this.annotations);
};

@@ -320,0 +302,0 @@ BacktraceReport.prototype.splitAttributesFromAnnotations = function (clientAttributes) {

@@ -24,2 +24,7 @@ import { ISourceCode } from './sourceCode';

};
symbolicationMaps?: Array<{
file: string;
uuid: string;
}>;
private symbolicationPaths;
private callingModulePath;

@@ -53,3 +58,5 @@ private readonly stackLineRe;

*/
parseStackFrames(): Promise<void>;
parseStackFrames(includeSymbolication: boolean): Promise<void>;
private generateSymbolicationMap;
private convertHexToUuid;
private addSourceRequest;

@@ -56,0 +63,0 @@ private readSourceCode;

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var fs = __importStar(require("fs"));
var tslib_1 = require("tslib");
var crypto_1 = require("crypto");
var fs = tslib_1.__importStar(require("fs"));
var path_1 = require("path");

@@ -60,2 +19,3 @@ var source_scan_1 = require("source-scan");

this.sourceCodeInformation = {};
this.symbolicationPaths = new Set();
this.callingModulePath = '';

@@ -103,7 +63,7 @@ this.stackLineRe = /\s+at (.+) \((.+):(\d+):(\d+)\)/;

*/
BacktraceStackTrace.prototype.parseStackFrames = function () {
return __awaiter(this, void 0, void 0, function () {
BacktraceStackTrace.prototype.parseStackFrames = function (includeSymbolication) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var stackTrace, lines, backtracePath;
var _this = this;
return __generator(this, function (_a) {
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {

@@ -133,3 +93,10 @@ case 0:

};
_this.addSourceRequest(stackFrame);
// ignore not existing stack frames
if (fs.existsSync(stackFrame.sourceCode)) {
_this.addSourceRequest(stackFrame);
// extend root object with symbolication information
if (includeSymbolication) {
_this.symbolicationPaths.add(stackFrame.sourceCode);
}
}
if (_this.isCallingModule(stackFrame)) {

@@ -145,2 +112,5 @@ _this.callingModulePath = stackFrame.sourceCode;

_a.sent();
if (includeSymbolication) {
this.generateSymbolicationMap();
}
return [2 /*return*/];

@@ -151,7 +121,36 @@ }

};
BacktraceStackTrace.prototype.addSourceRequest = function (stackFrame) {
// ignore not existing stack frames
if (!fs.existsSync(stackFrame.sourceCode)) {
BacktraceStackTrace.prototype.generateSymbolicationMap = function () {
var _this = this;
if (this.symbolicationPaths.size === 0) {
return;
}
this.symbolicationMaps = [];
this.symbolicationPaths.forEach(function (symbolicationPath) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var file, hash;
var _a;
return tslib_1.__generator(this, function (_b) {
file = fs.readFileSync(symbolicationPath, 'utf8');
hash = crypto_1.createHash('md5')
.update(file)
.digest('hex');
(_a = this.symbolicationMaps) === null || _a === void 0 ? void 0 : _a.push({
file: symbolicationPath,
uuid: this.convertHexToUuid(hash),
});
return [2 /*return*/];
});
}); });
};
BacktraceStackTrace.prototype.convertHexToUuid = function (hex) {
return (hex.slice(0, 8) +
'-' +
hex.slice(8, 12) +
'-' +
hex.slice(12, 16) +
'-' +
hex.slice(16, 20) +
'-' +
hex.slice(20, 32));
};
BacktraceStackTrace.prototype.addSourceRequest = function (stackFrame) {
// add source code to existing list. Otherwise create empty array

@@ -165,5 +164,5 @@ this.requestedSourceCode[stackFrame.sourceCode] = this.requestedSourceCode[stackFrame.sourceCode] || [];

BacktraceStackTrace.prototype.readSourceCode = function () {
return __awaiter(this, void 0, void 0, function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _a, _b, _i, key, element, minLine, maxLine, i, item, parameter, res;
return __generator(this, function (_c) {
return tslib_1.__generator(this, function (_c) {
switch (_c.label) {

@@ -207,5 +206,5 @@ case 0:

BacktraceStackTrace.prototype.getSourceCodeInformation = function (parameter) {
return __awaiter(this, void 0, void 0, function () {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
return tslib_1.__generator(this, function (_a) {
return [2 /*return*/, new Promise(function (res, rej) {

@@ -212,0 +211,0 @@ source_scan_1.scanFile(parameter, function (err, buff) {

{
"name": "backtrace-node",
"version": "1.0.7",
"version": "1.0.8",
"description": "Backtrace error reporting tool",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

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

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

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