# @reddotpay/rdp-auditlog

> Audit logger for RDP products

Latest version **6.0.35** (published 2020-04-27) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install @reddotpay/rdp-auditlog
pnpm add @reddotpay/rdp-auditlog
yarn add @reddotpay/rdp-auditlog
bun add @reddotpay/rdp-auditlog
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.35 |
| Published | 2020-04-27 |
| First published | 2019-07-02 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 58.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jerry Pan |
| Maintainers | gianebao, jerrypan90, leroyleejh |
| Keywords | npm, package, reddotpay, rdp-auditlog, auditlog |

## Links

- npm: https://www.npmjs.com/package/@reddotpay/rdp-auditlog
- Repository: https://github.com/reddotpay/auditlog
- Homepage: https://github.com/reddotpay/auditlog#readme
- Issues: https://github.com/reddotpay/auditlog/issues
- npm.io page: https://npm.io/package/@reddotpay/rdp-auditlog

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 6.0.35 (latest) — 2020-04-27
- 6.0.34 — 2020-03-09
- 6.0.33 — 2020-02-26
- 6.0.32 — 2020-02-14
- 6.0.31 — 2020-02-14
- 6.0.30 — 2020-02-14
- 6.0.29 — 2020-02-11
- 6.0.28 — 2020-02-11
- 6.0.27 — 2020-02-06
- 6.0.26 — 2020-02-06
- 6.0.25 — 2020-02-04
- 6.0.24 — 2020-02-03
- 6.0.23 — 2020-01-31
- 6.0.22 — 2020-01-31
- 6.0.21 — 2020-01-30
- … 50 more at https://npm.io/package/@reddotpay/rdp-auditlog/versions

## README

# rdp-Auditlog
[![npm (scoped)](https://img.shields.io/npm/v/@reddotpay/rdp-auditlog.svg)](https://www.npmjs.com/package/@reddotpay/rdp-auditlog)

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

---
_Source: https://npm.io/package/@reddotpay/rdp-auditlog · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
