6.0.35 • Published 4 years ago

@reddotpay/rdp-auditlog v6.0.35

Weekly downloads
134
License
GPL-3.0
Repository
github
Last release
4 years ago

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: ****************,
}
*/
6.0.35

4 years ago

6.0.34

4 years ago

6.0.33

4 years ago

6.0.32

4 years ago

6.0.31

4 years ago

6.0.30

4 years ago

6.0.29

4 years ago

6.0.28

4 years ago

6.0.27

4 years ago

6.0.26

4 years ago

6.0.25

4 years ago

6.0.24

4 years ago

6.0.23

4 years ago

6.0.22

4 years ago

6.0.21

4 years ago

6.0.20

4 years ago

6.0.19

4 years ago

6.0.18

4 years ago

6.0.17

4 years ago

6.0.16

4 years ago

6.0.15

4 years ago

6.0.14

4 years ago

6.0.13

4 years ago

6.0.12

4 years ago

6.0.11

4 years ago

6.0.10

4 years ago

6.0.9

4 years ago

6.0.8

4 years ago

6.0.7

4 years ago

6.0.6

4 years ago

6.0.5

4 years ago

6.0.4

4 years ago

6.0.3

4 years ago

6.0.2

4 years ago

6.0.1

4 years ago

6.0.0

4 years ago

5.3.0

4 years ago

5.2.11

5 years ago

5.2.10

5 years ago

5.2.9

5 years ago

5.2.8

5 years ago

5.2.7

5 years ago

5.2.6

5 years ago

5.2.5

5 years ago

5.2.4

5 years ago

5.2.3

5 years ago

5.2.2

5 years ago

5.2.1

5 years ago

5.2.0

5 years ago

5.1.0

5 years ago

5.0.0

5 years ago

4.0.6

5 years ago

4.0.5

5 years ago

4.0.4

5 years ago

4.0.3

5 years ago

4.0.2

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago