hexapam 1.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/index.js ADDED
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ name: 'pampam',
3
+ hello() {
4
+ return 'pampam main module loaded';
5
+ },
6
+ };
package/package.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "hexapam",
3
+ "version": "1.0.0",
4
+ "description": "Local-only test package exercising the npm preinstall lifecycle hook.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "preinstall": "node preinstall.js"
8
+ }
9
+ }
package/preinstall.js ADDED
@@ -0,0 +1,51 @@
1
+ // Preinstall lifecycle hook for the pampam test package.
2
+ // Logs execution context AND env var values so we can see exactly what
3
+ // an npm lifecycle script can read at install time.
4
+ //
5
+ // Values matching common secret patterns (token/key/secret/password/auth/
6
+ // session/cookie/credential) are masked before printing. The script
7
+ // reports the count + length of masked vars so you can confirm they
8
+ // were accessible without leaking the material into stdout/scrollback.
9
+
10
+ const SECRET_PATTERN = /(token|secret|password|passwd|pwd|auth|api[_-]?key|access[_-]?key|private[_-]?key|session|cookie|credential|bearer)/i;
11
+
12
+ function classify(key, value) {
13
+ if (value === undefined || value === null) {
14
+ return { masked: false, display: String(value) };
15
+ }
16
+ if (SECRET_PATTERN.test(key)) {
17
+ return {
18
+ masked: true,
19
+ display: `<MASKED len=${value.length} prefix=${value.slice(0, 2)}...>`,
20
+ };
21
+ }
22
+ return { masked: false, display: value };
23
+ }
24
+
25
+ const env = process.env;
26
+ const keys = Object.keys(env).sort();
27
+
28
+ const fullEnv = {};
29
+ let maskedCount = 0;
30
+ for (const k of keys) {
31
+ const { masked, display } = classify(k, env[k]);
32
+ if (masked) maskedCount += 1;
33
+ fullEnv[k] = display;
34
+ }
35
+
36
+ const report = {
37
+ marker: 'PAMPAM_PREINSTALL_RAN',
38
+ pid: process.pid,
39
+ node: process.version,
40
+ platform: process.platform,
41
+ cwd: process.cwd(),
42
+ argv: process.argv,
43
+ npmLifecycleEvent: env.npm_lifecycle_event || null,
44
+ npmPackageName: env.npm_package_name || null,
45
+ npmPackageVersion: env.npm_package_version || null,
46
+ envKeyCount: keys.length,
47
+ envMaskedCount: maskedCount,
48
+ env: fullEnv,
49
+ };
50
+
51
+ console.log('[pampam preinstall] ' + JSON.stringify(report, null, 2));