@heroku/js-blanket 0.0.0
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/.c8rc.json +11 -0
- package/.editorconfig +11 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +41 -0
- package/.github/copilot-instructions.md +117 -0
- package/.github/workflows/ci.yml +25 -0
- package/.husky/pre-commit +1 -0
- package/.lintstagedrc.json +4 -0
- package/.tool-versions +1 -0
- package/CODEOWNERS +8 -0
- package/CODE_OF_CONDUCT.md +111 -0
- package/CONTRIBUTING.md +123 -0
- package/LICENSE +206 -0
- package/README.md +218 -0
- package/SECURITY.md +8 -0
- package/docs/examples/logging-integration.md +736 -0
- package/eslint.config.mjs +108 -0
- package/package.json +80 -0
- package/prettier.config.mjs +10 -0
- package/scripts/test-setup.mjs +24 -0
- package/src/adapters/logging/generic.test.ts +531 -0
- package/src/adapters/logging/generic.ts +21 -0
- package/src/core/patterns.ts +22 -0
- package/src/core/presets.ts +122 -0
- package/src/core/scrubber.test.ts +465 -0
- package/src/core/scrubber.ts +284 -0
- package/src/core/types.test.ts +516 -0
- package/src/core/types.ts +176 -0
- package/src/index.test.ts +41 -0
- package/src/index.ts +8 -0
- package/tsconfig.cjs.json +12 -0
- package/tsconfig.esm.json +12 -0
- package/tsconfig.json +32 -0
- package/tsconfig.test.json +9 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { defineConfig } from 'eslint/config';
|
|
2
|
+
import js from '@eslint/js';
|
|
3
|
+
import tsParser from '@typescript-eslint/parser';
|
|
4
|
+
import tsPlugin from '@typescript-eslint/eslint-plugin';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
// ESLint flat config for a TypeScript project with dual-build (CJS/ESM) outputs.
|
|
9
|
+
// - Ignores built artifacts in `dist/`
|
|
10
|
+
// - Applies base JS recommended rules to JS files
|
|
11
|
+
// - Applies TypeScript parsing and TS-specific rules to TS files
|
|
12
|
+
// - Enables common Mocha globals in test files
|
|
13
|
+
|
|
14
|
+
export default defineConfig([
|
|
15
|
+
// Global ignores for generated content and dependencies
|
|
16
|
+
{
|
|
17
|
+
ignores: ['dist/**', 'node_modules/**', 'coverage/**'],
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
// JavaScript files
|
|
21
|
+
{
|
|
22
|
+
files: ['**/*.js', '**/*.mjs', '**/*.cjs'],
|
|
23
|
+
...js.configs.recommended,
|
|
24
|
+
languageOptions: {
|
|
25
|
+
ecmaVersion: 2022,
|
|
26
|
+
sourceType: 'module',
|
|
27
|
+
globals: {
|
|
28
|
+
console: 'readonly',
|
|
29
|
+
process: 'readonly',
|
|
30
|
+
Buffer: 'readonly',
|
|
31
|
+
__dirname: 'readonly',
|
|
32
|
+
__filename: 'readonly',
|
|
33
|
+
module: 'readonly',
|
|
34
|
+
require: 'readonly',
|
|
35
|
+
exports: 'readonly',
|
|
36
|
+
global: 'readonly',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
// TypeScript source files
|
|
42
|
+
{
|
|
43
|
+
files: ['src/**/*.ts', 'src/**/*.mts', 'src/**/*.cts'],
|
|
44
|
+
languageOptions: {
|
|
45
|
+
parser: tsParser,
|
|
46
|
+
parserOptions: {
|
|
47
|
+
// Use the project tsconfig for type-aware linting
|
|
48
|
+
project: ['./tsconfig.json'],
|
|
49
|
+
tsconfigRootDir: path.dirname(fileURLToPath(import.meta.url)),
|
|
50
|
+
ecmaVersion: 2022,
|
|
51
|
+
sourceType: 'module',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
plugins: {
|
|
55
|
+
'@typescript-eslint': tsPlugin,
|
|
56
|
+
},
|
|
57
|
+
rules: {
|
|
58
|
+
// Align with config behavior
|
|
59
|
+
'@typescript-eslint/no-unused-vars': [
|
|
60
|
+
'warn',
|
|
61
|
+
{
|
|
62
|
+
argsIgnorePattern: '^_',
|
|
63
|
+
varsIgnorePattern: '^_',
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// Test files (Mocha) - Updated for colocation
|
|
70
|
+
{
|
|
71
|
+
files: [
|
|
72
|
+
'src/**/*.test.ts',
|
|
73
|
+
'src/**/*.spec.ts',
|
|
74
|
+
'src/testUtils/**/*.test.ts',
|
|
75
|
+
],
|
|
76
|
+
languageOptions: {
|
|
77
|
+
parser: tsParser,
|
|
78
|
+
parserOptions: {
|
|
79
|
+
project: ['./tsconfig.test.json'],
|
|
80
|
+
tsconfigRootDir: path.dirname(fileURLToPath(import.meta.url)),
|
|
81
|
+
ecmaVersion: 2022,
|
|
82
|
+
sourceType: 'module',
|
|
83
|
+
},
|
|
84
|
+
globals: {
|
|
85
|
+
describe: 'readonly',
|
|
86
|
+
it: 'readonly',
|
|
87
|
+
before: 'readonly',
|
|
88
|
+
beforeEach: 'readonly',
|
|
89
|
+
after: 'readonly',
|
|
90
|
+
afterEach: 'readonly',
|
|
91
|
+
console: 'readonly',
|
|
92
|
+
global: 'readonly',
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
plugins: {
|
|
96
|
+
'@typescript-eslint': tsPlugin,
|
|
97
|
+
},
|
|
98
|
+
rules: {
|
|
99
|
+
'@typescript-eslint/no-unused-vars': [
|
|
100
|
+
'warn',
|
|
101
|
+
{
|
|
102
|
+
argsIgnorePattern: '^_',
|
|
103
|
+
varsIgnorePattern: '^_',
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
]);
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@heroku/js-blanket",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Framework-agnostic sensitive data scrubbing library for error monitoring and logging",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pii",
|
|
7
|
+
"scrubbing",
|
|
8
|
+
"security",
|
|
9
|
+
"data-sanitization",
|
|
10
|
+
"error-monitoring",
|
|
11
|
+
"logging"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/heroku/js-blanket#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/heroku/js-blanket/issues"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/heroku/js-blanket.git"
|
|
20
|
+
},
|
|
21
|
+
"license": "Apache-2.0",
|
|
22
|
+
"author": "Heroku",
|
|
23
|
+
"type": "module",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": "./dist/esm/index.js",
|
|
27
|
+
"require": "./dist/cjs/index.js",
|
|
28
|
+
"types": "./dist/esm/index.d.ts"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"main": "./dist/cjs/index.js",
|
|
32
|
+
"types": "./dist/esm/index.d.ts",
|
|
33
|
+
"directories": {
|
|
34
|
+
"doc": "docs"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build:cjs": "rm -rf dist/cjs && tsc -p tsconfig.cjs.json && mkdir -p dist/cjs && echo '{\"type\": \"commonjs\"}' > dist/cjs/package.json",
|
|
38
|
+
"build:esm": "rm -rf dist/esm && tsc -p tsconfig.esm.json",
|
|
39
|
+
"build": "pnpm run build:cjs && pnpm run build:esm",
|
|
40
|
+
"test": "c8 mocha --require ./scripts/test-setup.mjs --forbid-only \"dist/esm/**/*.test.js\"",
|
|
41
|
+
"prepare": "husky",
|
|
42
|
+
"lint": "eslint \"src/**/*.{js,ts}\"",
|
|
43
|
+
"lint:fix": "eslint \"src/**/*.{js,ts}\" --fix",
|
|
44
|
+
"prettier": "prettier . --write",
|
|
45
|
+
"format": "pnpm run prettier && pnpm run lint:fix",
|
|
46
|
+
"pretest": "pnpm run build:cjs && pnpm run build:esm && pnpm run type-check",
|
|
47
|
+
"type-check": "tsc --noEmit -p tsconfig.json",
|
|
48
|
+
"lint-staged": "npx lint-staged",
|
|
49
|
+
"check": "pnpm run format && pnpm run type-check && pnpm test",
|
|
50
|
+
"ci": "pnpm run lint && pnpm run type-check && pnpm test"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"tslib": "^2.8.1"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@eslint/js": "^9.39.1",
|
|
57
|
+
"@types/chai": "^5.2.3",
|
|
58
|
+
"@types/mocha": "^10.0.10",
|
|
59
|
+
"@types/node": "^24.10.0",
|
|
60
|
+
"@typescript-eslint/eslint-plugin": "^8.46.3",
|
|
61
|
+
"@typescript-eslint/parser": "^8.46.3",
|
|
62
|
+
"c8": "^10.1.3",
|
|
63
|
+
"chai": "^6.2.0",
|
|
64
|
+
"eslint": "^9.39.1",
|
|
65
|
+
"husky": "^9.1.7",
|
|
66
|
+
"lint-staged": "^16.2.6",
|
|
67
|
+
"mocha": "^11.7.5",
|
|
68
|
+
"prettier": "^3.6.2",
|
|
69
|
+
"typescript": "^5.9.3"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=20.0.0"
|
|
73
|
+
},
|
|
74
|
+
"publishConfig": {
|
|
75
|
+
"access": "public",
|
|
76
|
+
"registry": "https://registry.npmjs.org/"
|
|
77
|
+
},
|
|
78
|
+
"packageManager": "pnpm@10.21.0",
|
|
79
|
+
"module": "./dist/esm/index.js"
|
|
80
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Suppress structured logger output objects while preserving Mocha output
|
|
2
|
+
const originalLog = console.log.bind(console);
|
|
3
|
+
const originalError = console.error.bind(console);
|
|
4
|
+
|
|
5
|
+
function shouldSuppress(args) {
|
|
6
|
+
if (args.length === 1 && typeof args[0] === 'object' && args[0] !== null) {
|
|
7
|
+
const msg = args[0];
|
|
8
|
+
const hasStructuredShape =
|
|
9
|
+
Object.prototype.hasOwnProperty.call(msg, 'message') &&
|
|
10
|
+
Object.prototype.hasOwnProperty.call(msg, 'level');
|
|
11
|
+
return hasStructuredShape;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
console.log = (...args) => {
|
|
17
|
+
if (shouldSuppress(args)) return;
|
|
18
|
+
originalLog(...args);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
console.error = (...args) => {
|
|
22
|
+
if (shouldSuppress(args)) return;
|
|
23
|
+
originalError(...args);
|
|
24
|
+
};
|