@reddotpay/rdp-auditlog

6.0.35 • Public • Published

rdp-Auditlog

npm (scoped)

Audit log npm package for RDP products

Install

  1. npm install @reddotpay/rdp-auditlog dotenv
  2. npm install aws-sdk --save-dev
  3. refer to Sample Environment File for environment variables
Sample Environment File
ENVIRONMENT=development | staging | production
DELIVERY_STREAM_NAME=$RDP_AUDITLOGS_STREAM_DEV | $RDP_AUDITLOGS_STREAM | $RDP_AUDITLOGS_STREAM_PROD
DISPLAY_AUDITLOG=true

Requirements

AWS Role can refer to either Managed Policy ARN or Policy below.

Managed Policy ARN
arn:aws:iam::aws:policy/AmazonKinesisFirehoseFullAccess
Policy
BackendFunctionRole
	Type: AWS::IAM::Role
	Properties:
		AssumeRolePolicyDocument:
		Version: '2012-10-17'
		Statement:
		- 
			Effect: Allow
			Action:
			- 'sts:AssumeRole'
			Principal:
				Service:
				- lambda.amazonaws.com

		Policies:
		-
			PolicyName: {Product}BackendFunctionRole
			PolicyDocument:
				Version: '2012-10-17'
				Statement:
				- 
					Effect: Allow
					Action:
					- 'lambda:*'
					- 'firehose:*'
					- 'logs:*'
					- 'ec2:*'
					Resource: '*'

Usage

Primary Function

/*
    DATA TYPE
    summmary {string} - description of log / error
    variable {any} - the variable to log
    error {object} - error object return in catch block
    event {object} - lambda event
    response {object} - response that is return to frontend
*/

Function 1: rdp.log(summary, variable); - equivalent to console.log
Function 2: rdp.error(summary, error); - equivalent to console.error
Function 3: await rdp.audit(event, response); - only called once before lambda return response
Example
// index.js

const rdp = require('@reddotpay/rdp-auditlog');

exports.handler = async (event) => {
    /*
        All the Lambda Routes
    */

    await rdp.audit(event, response); <==== fn 3

    return response;
}
// models/test.js

const axios = require('axios');
const rdp = require('@reddotpay/rdp-auditlog');

class test {
    async get(input) {
        try {
            rdp.log('test get route>>', input); <==== fn 1
            ...
        } catch (e) {
            rdp.error('test get route error>>', e); <==== fn 2
            ...
        }

        return;
    }

    async post(input) {
        try {
            rdp.log('test get route>>', input); <==== fn 1
            ...
        } catch (e) {
            rdp.error('test get route error>>', e); <==== fn 2
            ...
        }

        return;
    }
}
Response
{
    FailedPutCount: 0,
    Encrypted: false,
    RequestResponses: [{
        RecordId: 'streamId',
    }],
}

Masking Function

rdp.maskReturnDefault();
rdp.maskEmail(email);
rdp.maskCard(cardNumber);
rdp.maskString(string);
rdp.maskObject(object);
Example
const maskReturnDefault = rdp.maskReturnDefault();
// ****************
remarks: default is always 16 asterisk

const maskedEmail = rdp.maskEmail('username@domain.com');
// use*****@domain.com

const maskedCard = rdp.maskCard('1111222233334444');
// ****************

const maskedString = rdp.maskString('teststring');
// **********

const maskedObject = rdp.maskObject({
    key1: "value1",
    key2: [1, 2, 3],
    key3: {
        nestedKey1: "nestedValue1",
        nestedKey2: "nestedValue2",
    },
});
/*
{
    key1: ****************,
    key2: ****************,
    key3: ****************,
}
*/

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
6.0.351latest

Version History

VersionDownloads (Last 7 Days)Published
6.0.351
6.0.340
6.0.330
6.0.320
6.0.310
6.0.301
6.0.290
6.0.281
6.0.271
6.0.260
6.0.250
6.0.240
6.0.231
6.0.220
6.0.211
6.0.200
6.0.190
6.0.180
6.0.171
6.0.160
6.0.150
6.0.140
6.0.131
6.0.120
6.0.110
6.0.100
6.0.90
6.0.80
6.0.70
6.0.61
6.0.50
6.0.40
6.0.31
6.0.20
6.0.10
6.0.00
5.3.00
5.2.110
5.2.101
5.2.91
5.2.80
5.2.70
5.2.61
5.2.51
5.2.41
5.2.30
5.2.20
5.2.10
5.2.00
5.1.00
5.0.00
4.0.61
4.0.50
4.0.40
4.0.30
4.0.21
4.0.10
4.0.00
3.0.11
3.0.00
2.0.00
1.0.31
1.0.20
1.0.11
1.0.01

Package Sidebar

Install

npm i @reddotpay/rdp-auditlog

Weekly Downloads

21

Version

6.0.35

License

GPL-3.0

Unpacked Size

59.5 kB

Total Files

12

Last publish

Collaborators

  • leroyleejh
  • npmjs-rdp