@datdm198x/safe-logger 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -1
- package/package.json +12 -4
package/README.md
CHANGED
|
@@ -39,14 +39,61 @@ Output:
|
|
|
39
39
|
*/
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
### Handling AWS Credentials
|
|
43
|
+
|
|
44
|
+
`safe-logger` automatically detects and masks common AWS-related environment variables and keys, supporting both camelCase and snake_case formats.
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { safeLog } from '@datdm198x/safe-logger';
|
|
48
|
+
|
|
49
|
+
// Example with camelCase
|
|
50
|
+
const awsConfig = {
|
|
51
|
+
awsAccessKeyId: 'AKIAIOSFODNN7EXAMPLE',
|
|
52
|
+
awsSecretAccessKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
|
|
53
|
+
awsRegion: 'us-east-1'
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Example with snake_case
|
|
57
|
+
const awsEnvConfig = {
|
|
58
|
+
aws_access_key_id: 'AKIAIOSFODNN7EXAMPLE',
|
|
59
|
+
aws_secret_access_key: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
console.log(safeLog(awsConfig));
|
|
63
|
+
console.log(safeLog(awsEnvConfig));
|
|
64
|
+
/*
|
|
65
|
+
Output:
|
|
66
|
+
{
|
|
67
|
+
awsAccessKeyId: '***************IPLE',
|
|
68
|
+
awsSecretAccessKey: '************************************PLEY',
|
|
69
|
+
awsRegion: '*******-1'
|
|
70
|
+
}
|
|
71
|
+
{
|
|
72
|
+
aws_access_key_id: '***************IPLE',
|
|
73
|
+
aws_secret_access_key: '************************************PLEY'
|
|
74
|
+
}
|
|
75
|
+
*/
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
|
|
42
79
|
## Development
|
|
43
80
|
|
|
44
81
|
### Build
|
|
45
82
|
```bash
|
|
46
83
|
npm run build
|
|
47
84
|
```
|
|
48
|
-
|
|
49
85
|
### Testing
|
|
86
|
+
|
|
50
87
|
```bash
|
|
51
88
|
npm test
|
|
52
89
|
```
|
|
90
|
+
|
|
91
|
+
All tests pass, ensuring reliable masking across various scenarios:
|
|
92
|
+
- **General Masking:** Validates passwords, emails, CVVs, and nested structures.
|
|
93
|
+
- **Edge Cases:** Handles non-string types, `null`, `undefined`, and empty containers safely.
|
|
94
|
+
- **Deep Nesting:** Ensures recursive sanitization works for complex objects.
|
|
95
|
+
- **AWS & SMTP:** Verifies consistent masking for both camelCase and UPPER_SNAKE_CASE formats.
|
|
96
|
+
- **Comprehensive Coverage:** Validates a wide range of PII, API secrets, and sensitive identifiers.
|
|
97
|
+
|
|
98
|
+

|
|
99
|
+
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datdm198x/safe-logger",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "A utility to safely mask and sanitize sensitive data in objects for logging purposes, preventing PII and credentials from being logged.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -16,7 +16,15 @@
|
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "git+https://github.com/dat-dao-c2c/safe-logger.git"
|
|
18
18
|
},
|
|
19
|
-
"keywords": [
|
|
19
|
+
"keywords": [
|
|
20
|
+
"logging",
|
|
21
|
+
"masking",
|
|
22
|
+
"sanitization",
|
|
23
|
+
"security",
|
|
24
|
+
"pii",
|
|
25
|
+
"data-protection",
|
|
26
|
+
"safe-log"
|
|
27
|
+
],
|
|
20
28
|
"author": "",
|
|
21
29
|
"license": "ISC",
|
|
22
30
|
"type": "module",
|
|
@@ -32,4 +40,4 @@
|
|
|
32
40
|
"@types/node": "^26.0.1",
|
|
33
41
|
"vitest": "^4.1.9"
|
|
34
42
|
}
|
|
35
|
-
}
|
|
43
|
+
}
|