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

@janiscommerce/log

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@janiscommerce/log - npm Package Compare versions

Comparing version 3.6.0 to 3.7.0

4

CHANGELOG.md

@@ -10,2 +10,6 @@ # Changelog

## [3.7.0] - 2023-01-10
### Added
- Now logs sensitive data can be removed using the `JANIS_TRACE_PRIVATE_FIELDS` environment variable
## [3.6.0] - 2022-11-10

@@ -12,0 +16,0 @@ ### Added

@@ -0,1 +1,3 @@

/* eslint-disable no-restricted-syntax */
'use strict';

@@ -28,2 +30,25 @@

const excludeFieldsFromLog = (log, fieldsToExclude = []) => {
if(!Array.isArray(fieldsToExclude) || !fieldsToExclude.length)
return log;
if(Array.isArray(log))
return log.map(item => excludeFieldsFromLog(item, fieldsToExclude));
if(typeof log === 'object' && log !== null) {
const object = {};
Object.keys(log).forEach(key => {
if(!fieldsToExclude.includes(key))
object[key] = excludeFieldsFromLog(log[key], fieldsToExclude);
});
return object;
}
return log;
};
const getEnv = () => process.env.JANIS_ENV;

@@ -35,2 +60,10 @@

const getTracePrivateFields = () => {
if(!process.env.JANIS_TRACE_PRIVATE_FIELDS)
return;
return process.env.JANIS_TRACE_PRIVATE_FIELDS.split(',').map(field => field.trim());
};
module.exports = {

@@ -40,3 +73,5 @@ arrayChunk,

getFormattedEnv,
getServiceName
getServiceName,
getTracePrivateFields,
excludeFieldsFromLog
};

@@ -43,3 +43,3 @@ 'use strict';

const { getEnv, getServiceName } = require('./helpers/utils');
const { getEnv, getServiceName, getTracePrivateFields, excludeFieldsFromLog } = require('./helpers/utils');

@@ -160,2 +160,3 @@ module.exports = class Log {

if(typeof log === 'string')

@@ -167,2 +168,5 @@ log = JSON.parse(log);

if(getTracePrivateFields())
log = excludeFieldsFromLog(log, getTracePrivateFields());
const functionName = process.env.JANIS_FUNCTION_NAME;

@@ -169,0 +173,0 @@ const apiRequestLogId = process.env.JANIS_API_REQUEST_LOG_ID;

14

package.json
{
"name": "@janiscommerce/log",
"version": "3.6.0",
"version": "3.7.0",
"description": "A package for creating logs in Janis Trace Service",

@@ -23,11 +23,11 @@ "main": "lib/index.js",

"devDependencies": {
"@types/node": "^15.0.0",
"eslint": "^7.32.0",
"@types/node": "^18.11.18",
"eslint": "^8.31.0",
"eslint-config-airbnb-base": "^13.2.0",
"eslint-plugin-import": "^2.26.0",
"husky": "^8.0.1",
"mocha": "^10.0.0",
"husky": "^8.0.3",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"sinon": "^9.0.2",
"typescript": "^4.2.4"
"sinon": "^15.0.1",
"typescript": "^4.9.4"
},

@@ -34,0 +34,0 @@ "files": [

@@ -20,2 +20,3 @@ # log

**`JANIS_TRACE_EXTENSION_ENABLED`**: If this variable is set, logs will be attempted to be buffered in the Janis Trace Extension server. If the server fails, direct call to Firehose is the fallback.
**`JANIS_TRACE_PRIVATE_FIELDS`**: In case it is necessary to exclude properties to be logged, they should be defined in this variable. In order to set multiple fields, set them separated by commas. For example: `JANIS_TRACE_PRIVATE_FIELDS=password,token`

@@ -22,0 +23,0 @@ ## API

@@ -5,1 +5,3 @@ export function arrayChunk(array: any, size: any): any[][];

export function getServiceName(): string;
export function getTracePrivateFields(): string[];
export function excludeFieldsFromLog(log: any, fieldsToExclude?: any[]): any;
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