New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@guardian/elk-kinesis-logger

Package Overview
Dependencies
Maintainers
16
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@guardian/elk-kinesis-logger - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

58

dist/elk-kinesis-logger.js

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

app = _ref.app,
roleArn = _ref.roleArn,
streamName = _ref.streamName,

@@ -25,3 +24,2 @@ _ref$verbose = _ref.verbose,

this.app = app;
this.roleArn = roleArn;
this.streamName = streamName;

@@ -32,2 +30,31 @@ this.verbose = verbose;

_createClass(ELKKinesisLogger, [{
key: 'withRole',
value: function withRole(roleArn) {
this.roleArn = roleArn;
return this;
}
}, {
key: '_openWithoutRole',
value: function _openWithoutRole() {
return Promise.resolve(new AWS.Kinesis());
}
}, {
key: '_openWithRole',
value: function _openWithRole() {
var sts = new AWS.STS();
var options = {
RoleArn: this.roleArn,
RoleSessionName: this.app
};
return sts.assumeRole(options).promise().then(function (data) {
return new AWS.Kinesis({
accessKeyId: data.Credentials.AccessKeyId,
secretAccessKey: data.Credentials.SecretAccessKey,
sessionToken: data.Credentials.SessionToken
});
});
}
}, {
key: 'open',

@@ -37,25 +64,8 @@ value: function open() {

return new Promise(function (resolve, reject) {
var sts = new AWS.STS();
var openPromise = this.roleArn ? this._openWithRole() : this._openWithoutRole();
var options = {
RoleArn: _this.roleArn,
RoleSessionName: _this.app
};
sts.assumeRole(options, function (err, data) {
if (err) {
reject(err);
} else {
_this.kinesis = new AWS.Kinesis({
accessKeyId: data.Credentials.AccessKeyId,
secretAccessKey: data.Credentials.SecretAccessKey,
sessionToken: data.Credentials.SessionToken
});
_this._logLines = [];
resolve(_this);
}
});
return openPromise.then(function (kinesis) {
_this.kinesis = kinesis;
_this._logLines = [];
return _this;
});

@@ -62,0 +72,0 @@ }

{
"name": "@guardian/elk-kinesis-logger",
"version": "0.1.0",
"version": "0.2.0",
"description": "Logging to a Kinesis stream for consumption into an ELK cluster",

@@ -5,0 +5,0 @@ "main": "dist/elk-kinesis-logger.js",

@@ -19,3 +19,3 @@ [![CircleCI](https://circleci.com/gh/guardian/elk-kinesis-logger.svg?style=svg)](https://circleci.com/gh/guardian/elk-kinesis-logger)

```bash
npm install elk-kinesis-logger
npm install @guardian/elk-kinesis-logger
```

@@ -35,3 +35,2 @@

app: 'my-app',
roleArn: 'arn:aws:iam::000000000000:role/my-role',
streamName: 'my-stream'

@@ -41,2 +40,12 @@ });

If the stream's access is restricted, you can specify a role arn to assume:
```js
const logger = new ELKKinesisLogger({
stage: 'PROD',
stack: 'my-stack',
app: 'my-app',
streamName: 'my-stream'
}).withRole('arn:aws:iam::000000000000:role/my-role');
```
Open the logger:

@@ -69,3 +78,2 @@ ```js

app: 'my-app',
roleArn: 'arn:aws:iam::000000000000:role/my-role',
streamName: 'my-stream'

@@ -72,0 +80,0 @@ });

const AWS = require('aws-sdk');
class ELKKinesisLogger {
constructor({ stage, stack, app, roleArn, streamName, verbose = true }) {
constructor({ stage, stack, app, streamName, verbose = true }) {
this.stage = stage;
this.stack = stack;
this.app = app;
this.roleArn = roleArn;
this.streamName = streamName;

@@ -13,2 +12,7 @@ this.verbose = verbose;

withRole(roleArn) {
this.roleArn = roleArn;
return this;
}
get _name() {

@@ -18,25 +22,19 @@ return this.constructor.name;

open() {
return new Promise((resolve, reject) => {
const sts = new AWS.STS();
_openWithoutRole() {
return Promise.resolve(new AWS.Kinesis());
}
const options = {
RoleArn: this.roleArn,
RoleSessionName: this.app
};
_openWithRole() {
const sts = new AWS.STS();
sts.assumeRole(options, (err, data) => {
if (err) {
reject(err);
} else {
this.kinesis = new AWS.Kinesis({
accessKeyId: data.Credentials.AccessKeyId,
secretAccessKey: data.Credentials.SecretAccessKey,
sessionToken: data.Credentials.SessionToken
});
const options = {
RoleArn: this.roleArn,
RoleSessionName: this.app
};
this._logLines = [];
resolve(this);
}
return sts.assumeRole(options).promise().then(data => {
return new AWS.Kinesis({
accessKeyId: data.Credentials.AccessKeyId,
secretAccessKey: data.Credentials.SecretAccessKey,
sessionToken: data.Credentials.SessionToken
});

@@ -46,2 +44,14 @@ });

open() {
const openPromise = this.roleArn
? this._openWithRole()
: this._openWithoutRole();
return openPromise.then(kinesis => {
this.kinesis = kinesis;
this._logLines = [];
return this;
});
}
close() {

@@ -48,0 +58,0 @@ this._consoleLog(`ensuring ${this._logLines.length} log lines are written`);

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