@vita-mojo/aggregator 1.9.0 → 1.10.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/main.js.enc CHANGED
Binary file
package/main.js.map.enc CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vita-mojo/aggregator",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "type": "commonjs",
5
5
  "scripts": {
6
6
  "postinstall": "node postinstall.js"
package/postinstall.js CHANGED
@@ -5,6 +5,49 @@ const fs = require('fs');
5
5
  const path = require('path');
6
6
  const crypto = require('crypto');
7
7
 
8
+ /**
9
+ * Load environment variables from .env file
10
+ */
11
+ function loadEnvFile() {
12
+ // Navigate up to repo root (from node_modules/@cicd_vitamojo/aggregator)
13
+ const repoRoot = path.resolve(__dirname, '../../../..');
14
+ const envFilePath = path.join(repoRoot, '.env');
15
+
16
+ if (!fs.existsSync(envFilePath)) {
17
+ console.log('ℹ No .env file found in repo root');
18
+ return;
19
+ }
20
+
21
+ try {
22
+ const envContent = fs.readFileSync(envFilePath, 'utf-8');
23
+ const lines = envContent.split('\n');
24
+
25
+ for (const line of lines) {
26
+ const trimmed = line.trim();
27
+
28
+ // Skip empty lines and comments
29
+ if (!trimmed || trimmed.startsWith('#')) {
30
+ continue;
31
+ }
32
+
33
+ const [key, ...valueParts] = trimmed.split('=');
34
+ const value = valueParts.join('=').trim();
35
+
36
+ // Remove quotes if present
37
+ const cleanValue = value.replace(/^['"]|['"]$/g, '');
38
+
39
+ // Only set if not already in environment
40
+ if (!process.env[key]) {
41
+ process.env[key] = cleanValue;
42
+ }
43
+ }
44
+
45
+ console.log('✓ Loaded environment variables from .env file');
46
+ } catch (error) {
47
+ console.error(`⚠ Failed to read .env file: ${error.message}`);
48
+ }
49
+ }
50
+
8
51
  /**
9
52
  * Decrypt a file using a shared secret
10
53
  */
@@ -36,7 +79,7 @@ function decryptFiles() {
36
79
  }
37
80
 
38
81
  // Shared secret must be 32 bytes (256 bits) for AES-256
39
- const sharedSecret = Buffer.from(sharedSecretEnv, 'utf8');
82
+ const sharedSecret = Buffer.from(sharedSecretEnv, 'base64');
40
83
  if (sharedSecret.length !== 32) {
41
84
  throw new Error(`AGGREGATOR_ENCRYPTION_KEY must be 32 bytes (256 bits), got ${sharedSecret.length} bytes`);
42
85
  }
@@ -83,6 +126,7 @@ function decryptFiles() {
83
126
  * Main execution
84
127
  */
85
128
  try {
129
+ loadEnvFile();
86
130
  decryptFiles();
87
131
  } catch (error) {
88
132
  console.error('\n❌ Aggregator decryption failed:', error.message);