mirror of
https://github.com/Viren070/AIOStreams.git
synced 2025-12-01 23:14:04 +01:00
fix: fixes
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
||||
parseAndDecryptString,
|
||||
Cache,
|
||||
unminifyConfig,
|
||||
minifyConfig,
|
||||
} from '@aiostreams/utils';
|
||||
|
||||
const app = express();
|
||||
@@ -104,14 +105,16 @@ app.get('/configure', (req, res) => {
|
||||
|
||||
app.get('/:config/configure', (req, res) => {
|
||||
const config = req.params.config;
|
||||
if (config.startsWith('eyJ')) {
|
||||
if (config.startsWith('eyJ') || config.startsWith('eyI')) {
|
||||
return res.sendFile(
|
||||
path.join(__dirname, '../../frontend/out/configure.html')
|
||||
);
|
||||
}
|
||||
try {
|
||||
const configJson = encryptInfoInConfig(
|
||||
unminifyConfig(extractJsonConfig(config))
|
||||
// unminify so we can encrypt the sensitive info
|
||||
// and then minify it again before sending it to the frontend
|
||||
const configJson = minifyConfig(
|
||||
encryptInfoInConfig(unminifyConfig(extractJsonConfig(config)))
|
||||
);
|
||||
const base64Config = Buffer.from(JSON.stringify(configJson)).toString(
|
||||
'base64'
|
||||
|
||||
@@ -493,7 +493,10 @@ export default function Configure() {
|
||||
if (config.startsWith('E-')) {
|
||||
throw new Error('Encrypted Config Not Supported');
|
||||
} else {
|
||||
decodedConfig = unminifyConfig(JSON.parse(atob(config)));
|
||||
decodedConfig = JSON.parse(atob(decodeURIComponent(config)));
|
||||
console.log('Decoded config', decodedConfig);
|
||||
decodedConfig = unminifyConfig(decodedConfig);
|
||||
console.log('Unminified config', decodedConfig);
|
||||
}
|
||||
return decodedConfig;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,11 @@ export function minifyConfig(obj: any, depth: number = 0): any {
|
||||
throw new Error('Max depth reached');
|
||||
}
|
||||
if (typeof obj !== 'object' || obj === null) {
|
||||
if (Object.values(compressedConfigMap).includes(obj)) {
|
||||
let valueToCheck = obj;
|
||||
if (typeof obj === 'number') {
|
||||
valueToCheck = obj.toString();
|
||||
}
|
||||
if (Object.values(compressedConfigMap).includes(valueToCheck)) {
|
||||
return `${obj}${MINIFY_SUFFIX}`;
|
||||
}
|
||||
return compressedConfigMap[obj] ?? obj;
|
||||
|
||||
Reference in New Issue
Block a user