@pixelated-tech/components 3.7.11 → 3.7.13
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.
|
@@ -3,25 +3,35 @@ import fs from 'fs';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
const debug = false;
|
|
5
5
|
/**
|
|
6
|
-
* Read the full master config blob from
|
|
6
|
+
* Read the full master config blob from local file.
|
|
7
7
|
* This function is intended for server-side use only.
|
|
8
8
|
*/
|
|
9
9
|
export function getFullPixelatedConfig() {
|
|
10
10
|
let raw = '';
|
|
11
11
|
let source = 'none';
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
// Focus strictly on the config file.
|
|
13
|
+
// Search multiple locations to handle different production/standalone environments.
|
|
14
|
+
const filename = 'pixelated.config.json';
|
|
15
|
+
const paths = [
|
|
16
|
+
path.join(process.cwd(), 'src/app/config', filename),
|
|
17
|
+
path.join(process.cwd(), 'app/config', filename),
|
|
18
|
+
path.join(process.cwd(), filename),
|
|
19
|
+
path.join(process.cwd(), '.next/server', filename), // Sometimes moved here in build
|
|
20
|
+
];
|
|
21
|
+
for (const configPath of paths) {
|
|
22
|
+
if (fs.existsSync(configPath)) {
|
|
23
|
+
try {
|
|
24
|
+
raw = fs.readFileSync(configPath, 'utf8');
|
|
25
|
+
source = configPath;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
console.error(`Failed to read config file at ${configPath}`, err);
|
|
30
|
+
}
|
|
21
31
|
}
|
|
22
32
|
}
|
|
23
33
|
if (!raw) {
|
|
24
|
-
console.error('PIXELATED_CONFIG not found
|
|
34
|
+
console.error('PIXELATED_CONFIG not found. Ensure src/app/config/pixelated.config.json is available.');
|
|
25
35
|
return {};
|
|
26
36
|
}
|
|
27
37
|
// Handle decryption if the content is encrypted
|
|
@@ -34,7 +44,7 @@ export function getFullPixelatedConfig() {
|
|
|
34
44
|
try {
|
|
35
45
|
raw = decrypt(raw, key);
|
|
36
46
|
if (debug)
|
|
37
|
-
console.log(`PIXELATED_CONFIG decrypted using key
|
|
47
|
+
console.log(`PIXELATED_CONFIG decrypted using key.`);
|
|
38
48
|
}
|
|
39
49
|
catch (err) {
|
|
40
50
|
console.error('Failed to decrypt PIXELATED_CONFIG', err);
|
|
@@ -44,11 +54,11 @@ export function getFullPixelatedConfig() {
|
|
|
44
54
|
try {
|
|
45
55
|
const parsed = JSON.parse(raw);
|
|
46
56
|
if (debug)
|
|
47
|
-
console.log(`PIXELATED_CONFIG loaded from ${source}
|
|
57
|
+
console.log(`PIXELATED_CONFIG loaded from ${source}`);
|
|
48
58
|
return parsed;
|
|
49
59
|
}
|
|
50
60
|
catch (err) {
|
|
51
|
-
console.error('Failed to parse PIXELATED_CONFIG JSON; source=', source,
|
|
61
|
+
console.error('Failed to parse PIXELATED_CONFIG JSON; source=', source, err);
|
|
52
62
|
return {};
|
|
53
63
|
}
|
|
54
64
|
}
|
|
@@ -59,6 +69,9 @@ export function getFullPixelatedConfig() {
|
|
|
59
69
|
export function getClientOnlyPixelatedConfig(full) {
|
|
60
70
|
const src = full ?? getFullPixelatedConfig();
|
|
61
71
|
function isSecretKey(key) {
|
|
72
|
+
// Explicitly allow common public-facing keys
|
|
73
|
+
if (/api_key|apikey|public_key/i.test(key))
|
|
74
|
+
return false;
|
|
62
75
|
return /token|secret|key|password|management|access/i.test(key);
|
|
63
76
|
}
|
|
64
77
|
function strip(obj) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PixelatedConfig } from './config.types';
|
|
2
2
|
/**
|
|
3
|
-
* Read the full master config blob from
|
|
3
|
+
* Read the full master config blob from local file.
|
|
4
4
|
* This function is intended for server-side use only.
|
|
5
5
|
*/
|
|
6
6
|
export declare function getFullPixelatedConfig(): PixelatedConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/components/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMtD;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,eAAe,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../src/components/config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMtD;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,eAAe,CAuDxD;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,eAAe,CA0BpF"}
|