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

sti

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sti - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

18

lib/index.js

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

var AuditMerger = (function (Transform) {
function AuditMerger(defaultAudit, isStream) {
function AuditMerger(defaultAudit, isWriteableStream) {
_classCallCheck(this, AuditMerger);

@@ -26,3 +26,3 @@

this.defaultAudit = defaultAudit;
this._isStream = isStream;
this._isWritableStream = isWriteableStream;
}

@@ -36,3 +36,3 @@

var audit = Object.assign(chunck, this.defaultAudit);
if (this._isStream) {
if (this._isWritableStream) {
this.push(JSON.stringify(audit) + "\n");

@@ -71,3 +71,3 @@ } else {

var payload = Object.seal({
timestamp: Date.now(),
timestamp: new Date().toISOString(),
area: this.name,

@@ -87,9 +87,11 @@ actor: actor,

value: function connect(action, defaultAudit) {
var isStream = typeof action !== "function";
var mergedStream = this.stream.pipe(new AuditMerger(defaultAudit, isStream));
var isWriteableStream = typeof action.on === "function" && action.writable;
var mergedStream = this.stream.pipe(new AuditMerger(defaultAudit, isWriteableStream));
if (isStream) {
if (isWriteableStream) {
mergedStream.pipe(action);
} else if (typeof action === "function") {
mergedStream.pipe(through(action));
} else {
mergedStream.pipe(through(action));
throw new TypeError("sti.connect only accepts functions or writeable streams");
}

@@ -96,0 +98,0 @@ },

{
"name": "sti",
"version": "1.0.0",
"version": "1.0.1",
"description": "Audit trail for node",

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

@@ -7,6 +7,6 @@ 'use strict';

class AuditMerger extends Transform {
constructor( defaultAudit, isStream ) {
constructor( defaultAudit, isWriteableStream ) {
super({ objectMode: true });
this.defaultAudit = defaultAudit;
this._isStream = isStream;
this._isWritableStream = isWriteableStream;
}

@@ -16,3 +16,3 @@

let audit = Object.assign(chunck, this.defaultAudit );
if (this._isStream) {
if (this._isWritableStream) {
this.push(JSON.stringify(audit) + '\n');

@@ -39,3 +39,3 @@ }

let payload = Object.seal({
timestamp: Date.now(),
timestamp: new Date().toISOString(),
area: this.name,

@@ -52,13 +52,19 @@ actor,

connect(action, defaultAudit) {
let isStream = typeof action !== 'function';
let mergedStream = this.stream.pipe( new AuditMerger(defaultAudit, isStream) );
const isWriteableStream = typeof action.on === 'function' && action.writable;
const mergedStream = this.stream.pipe(
new AuditMerger(defaultAudit, isWriteableStream)
);
if ( isStream) {
if ( isWriteableStream ) {
mergedStream.pipe( action );
}
else {
else if ( typeof action === 'function' ) {
mergedStream.pipe( through(action) );
}
else {
throw new TypeError('sti.connect only accepts functions or writeable streams');
}
}
}
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