@aspecto/core
Advanced tools
Comparing version 1.1.13 to 1.1.14
@@ -1,2 +0,1 @@ | ||
export declare const shouldIgnore: (data: any) => boolean; | ||
export default class WebSocketConnection { | ||
@@ -3,0 +2,0 @@ private host; |
@@ -11,10 +11,2 @@ "use strict"; | ||
const socketIo = __importStar(require("socket.io-client")); | ||
exports.shouldIgnore = (data) => { | ||
if (data.requestHeaders) { | ||
const xOriginHeader = Object.entries(data.requestHeaders).find(([key, _value]) => key.toLowerCase() === 'x-origin'); | ||
if (xOriginHeader && typeof xOriginHeader[1] === 'string' && xOriginHeader[1].toLowerCase() === 'aspecto-cli') | ||
return true; | ||
} | ||
return false; | ||
}; | ||
class WebSocketConnection { | ||
@@ -46,4 +38,2 @@ constructor(host) { | ||
send(data) { | ||
if (exports.shouldIgnore(data)) | ||
return; | ||
data.token = this.token; | ||
@@ -50,0 +40,0 @@ let stringData = JSON.stringify(data); |
@@ -1,5 +0,6 @@ | ||
import AspectoClientOptions from '../interfaces/AspectoClientOptions'; | ||
import AspectoClientOptions, { Blacklist } from '../interfaces/AspectoClientOptions'; | ||
export default class AspectoConfig { | ||
static samplingRatio: number; | ||
static POST_INSTALL_ID: string; | ||
static blacklist: Blacklist; | ||
static getToken(options?: AspectoClientOptions): any; | ||
@@ -6,0 +7,0 @@ static isDevelopMode(): boolean; |
@@ -29,5 +29,6 @@ "use strict"; | ||
exports.init = (options) => __awaiter(void 0, void 0, void 0, function* () { | ||
var _a, _b, _c, _d, _e, _f; | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
try { | ||
if ((_a = options) === null || _a === void 0 ? void 0 : _a.samplingRatio) { | ||
aspectoConfig_1.default.blacklist = (_a = options) === null || _a === void 0 ? void 0 : _a.blacklist; | ||
if ((_b = options) === null || _b === void 0 ? void 0 : _b.samplingRatio) { | ||
aspectoConfig_1.default.setSamplingRatio(options.samplingRatio); | ||
@@ -38,3 +39,3 @@ } | ||
} | ||
let ws = new ws_1.default(config_1.getCollectorEndpoint((_b = options) === null || _b === void 0 ? void 0 : _b.sendTrafficTo)); | ||
let ws = new ws_1.default(config_1.getCollectorEndpoint((_c = options) === null || _c === void 0 ? void 0 : _c.sendTrafficTo)); | ||
const auth = aspectoConfig_1.default.getToken(options); | ||
@@ -47,3 +48,3 @@ ConfigService_1.default.init({ token: auth }); | ||
errorReporter.set(ws, auth); | ||
if (((_c = options) === null || _c === void 0 ? void 0 : _c.outgoing) !== false) { | ||
if (((_d = options) === null || _d === void 0 ? void 0 : _d.outgoing) !== false) { | ||
const nodeHttpReporter = new NodeHttpReporter_1.default(); | ||
@@ -54,3 +55,3 @@ nodeHttpReporter.set(ws, auth); | ||
else { | ||
if (((_d = options) === null || _d === void 0 ? void 0 : _d.outgoing) !== false) { | ||
if (((_e = options) === null || _e === void 0 ? void 0 : _e.outgoing) !== false) { | ||
const xmlHttpReporter = new XMLHttpReporter_1.default(); | ||
@@ -65,3 +66,3 @@ xmlHttpReporter.set(ws, auth); | ||
} | ||
const collector = new collector_1.default(ws, (_e = options) === null || _e === void 0 ? void 0 : _e.packageName, (_f = options) === null || _f === void 0 ? void 0 : _f.packageVersion); | ||
const collector = new collector_1.default(ws, (_f = options) === null || _f === void 0 ? void 0 : _f.packageName, (_g = options) === null || _g === void 0 ? void 0 : _g.packageVersion); | ||
collector.addCollection(new OsCollector_1.default()); | ||
@@ -68,0 +69,0 @@ if (config_1.isNode) { |
@@ -0,1 +1,5 @@ | ||
export interface Blacklist { | ||
hostname?: string[]; | ||
route?: string[]; | ||
} | ||
export default interface AspectoClientOptions { | ||
@@ -9,2 +13,3 @@ env?: string; | ||
sendTrafficTo?: string; | ||
blacklist?: Blacklist; | ||
} |
@@ -19,2 +19,3 @@ "use strict"; | ||
const ConfigService_1 = __importDefault(require("../config/ConfigService")); | ||
const BlacklistMatcher_1 = __importDefault(require("../config/BlacklistMatcher")); | ||
class BaseReporter { | ||
@@ -35,2 +36,3 @@ constructor() { | ||
sendData(nodeErrorData) { | ||
var _a, _b; | ||
// do not send anything until we initialize privacy rules | ||
@@ -43,2 +45,4 @@ if (!this.privacyEngine) | ||
data[this.getKey()] = nodeErrorData; | ||
if (BlacklistMatcher_1.default.match(data)) | ||
return; | ||
const result = this.privacyEngine.executeRules(data); | ||
@@ -48,5 +52,3 @@ if (result === ActionResult_1.ActionResult.BlockRequest) | ||
// console.log(JSON.stringify(data)); | ||
if (BaseReporter.ws) { | ||
BaseReporter.ws.send(data); | ||
} | ||
(_b = (_a = BaseReporter) === null || _a === void 0 ? void 0 : _a.ws) === null || _b === void 0 ? void 0 : _b.send(data); | ||
} | ||
@@ -53,0 +55,0 @@ set(ws, token) { |
{ | ||
"name": "@aspecto/core", | ||
"version": "1.1.13", | ||
"version": "1.1.14", | ||
"description": "Aspecto metric collector", | ||
@@ -28,3 +28,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@aspecto/privacy-rules": "0.0.8", | ||
"@aspecto/privacy-rules": "0.0.9", | ||
"mimic-response": "^2.0.0", | ||
@@ -31,0 +31,0 @@ "socket.io-client": "^2.3.0", |
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
93589
82
1442
+ Added@aspecto/privacy-rules@0.0.9(transitive)
- Removed@aspecto/privacy-rules@0.0.8(transitive)
Updated@aspecto/privacy-rules@0.0.9