@xuda.io/runtime-bundle 1.0.490 → 1.0.492
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/js/xuda-runtime-bundle.js +143 -65
- package/js/xuda-runtime-bundle.min.js +1 -1
- package/js/xuda-runtime-slim.js +143 -65
- package/js/xuda-runtime-slim.min.es.js +143 -65
- package/js/xuda-runtime-slim.min.js +1 -1
- package/js/xuda-server-bundle.min.mjs +1 -1
- package/js/xuda-server-bundle.mjs +143 -65
- package/js/xuda-worker-bundle.js +143 -65
- package/js/xuda-worker-bundle.min.js +1 -1
- package/package.json +1 -1
|
@@ -34922,7 +34922,7 @@ func.UI.component.init_xu_nav = function ($container, $nav) {
|
|
|
34922
34922
|
};
|
|
34923
34923
|
func.expression = {};
|
|
34924
34924
|
|
|
34925
|
-
func.expression.
|
|
34925
|
+
func.expression.get = async function (SESSION_ID, valP, dsSessionP, sourceP, rowIdP, sourceActionP, secondPassP, calling_fieldIdP, fieldsP, debug_infoP, iterate_info, js_script_callback, jobNo, api_output_type) {
|
|
34926
34926
|
class xu_class {
|
|
34927
34927
|
async get() {
|
|
34928
34928
|
var ret;
|
|
@@ -35276,7 +35276,7 @@ func.expression.get_org = async function (SESSION_ID, valP, dsSessionP, sourceP,
|
|
|
35276
35276
|
return new_class.get();
|
|
35277
35277
|
};
|
|
35278
35278
|
|
|
35279
|
-
func.expression.
|
|
35279
|
+
func.expression.get_bad = async function (SESSION_ID, valP, dsSessionP, sourceP, rowIdP, sourceActionP, secondPassP, calling_fieldIdP, fieldsP = {}, debug_infoP, iterate_info, js_script_callback, jobNo, api_output_type) {
|
|
35280
35280
|
const evalJson = (text) => eval(`(${text})`);
|
|
35281
35281
|
const replaceQuotes = (str) => {
|
|
35282
35282
|
for (const [key, val] of Object.entries(fields)) {
|
|
@@ -35542,64 +35542,6 @@ func.expression.parse_org = function (strP) {
|
|
|
35542
35542
|
return res;
|
|
35543
35543
|
};
|
|
35544
35544
|
|
|
35545
|
-
func.expression.parse_bad = function (strP) {
|
|
35546
|
-
const nonLettersPatt = /\W/;
|
|
35547
|
-
const validSymbolsNoArray = /[^.@\[]/;
|
|
35548
|
-
const validSymbolsWithArray = /[^.@"'\[\]]/;
|
|
35549
|
-
|
|
35550
|
-
function extractStr(str, startPos = 0) {
|
|
35551
|
-
const cleanSplit = (arr) => (arr?.length > 1 && arr[0] === '' && arr[1].includes('@') ? arr.slice(1) : arr);
|
|
35552
|
-
|
|
35553
|
-
const segments = cleanSplit(str.replace(/@/g, '^^@').split('^^'));
|
|
35554
|
-
const result = [];
|
|
35555
|
-
|
|
35556
|
-
for (const val of segments || []) {
|
|
35557
|
-
if (!val) continue;
|
|
35558
|
-
const pos = str.indexOf(val) + startPos;
|
|
35559
|
-
|
|
35560
|
-
if (val.startsWith('@')) {
|
|
35561
|
-
let tmpStr = '';
|
|
35562
|
-
let wordStart = null;
|
|
35563
|
-
let wordEnd = null;
|
|
35564
|
-
let validSymbols = validSymbolsNoArray;
|
|
35565
|
-
|
|
35566
|
-
for (let i = 0; i < val.length; i++) {
|
|
35567
|
-
const char = val[i];
|
|
35568
|
-
|
|
35569
|
-
if (char === '[') validSymbols = validSymbolsWithArray;
|
|
35570
|
-
if (char === '.' && wordStart === null) wordStart = i;
|
|
35571
|
-
else if (wordStart !== null && nonLettersPatt.test(char)) wordEnd = i;
|
|
35572
|
-
|
|
35573
|
-
if (wordStart !== null && wordEnd !== null) {
|
|
35574
|
-
const word = val.slice(wordStart + 1, wordEnd);
|
|
35575
|
-
tmpStr = tmpStr.slice(0, wordStart) + '^^' + tmpStr.slice(wordStart, wordEnd);
|
|
35576
|
-
wordStart = char === '.' ? wordEnd : null;
|
|
35577
|
-
wordEnd = null;
|
|
35578
|
-
}
|
|
35579
|
-
|
|
35580
|
-
tmpStr += nonLettersPatt.test(char) && validSymbols.test(char) && !tmpStr.includes('^^') ? '^^' + char : char;
|
|
35581
|
-
}
|
|
35582
|
-
|
|
35583
|
-
if (tmpStr.includes('^^')) {
|
|
35584
|
-
result.push(...extractStr(tmpStr, pos));
|
|
35585
|
-
} else {
|
|
35586
|
-
const fieldIdMatch = val.match(/^@([^.\[]+)/);
|
|
35587
|
-
result.push({
|
|
35588
|
-
value: val,
|
|
35589
|
-
fieldId: fieldIdMatch ? fieldIdMatch[1] : undefined,
|
|
35590
|
-
pos,
|
|
35591
|
-
});
|
|
35592
|
-
}
|
|
35593
|
-
} else {
|
|
35594
|
-
result.push({ value: val, pos });
|
|
35595
|
-
}
|
|
35596
|
-
}
|
|
35597
|
-
return result;
|
|
35598
|
-
}
|
|
35599
|
-
|
|
35600
|
-
return extractStr(strP);
|
|
35601
|
-
};
|
|
35602
|
-
|
|
35603
35545
|
func.expression.parse = function (input) {
|
|
35604
35546
|
if (typeof input !== 'string') return [];
|
|
35605
35547
|
|
|
@@ -35628,7 +35570,7 @@ func.expression.parse = function (input) {
|
|
|
35628
35570
|
return segments;
|
|
35629
35571
|
};
|
|
35630
35572
|
|
|
35631
|
-
func.expression.
|
|
35573
|
+
func.expression.get_property_org = async function (valP) {
|
|
35632
35574
|
async function secure_eval(val) {
|
|
35633
35575
|
if (typeof IS_PROCESS_SERVER === 'undefined') {
|
|
35634
35576
|
try {
|
|
@@ -35666,21 +35608,73 @@ func.expression.get_property = async function (valP) {
|
|
|
35666
35608
|
property2: property2,
|
|
35667
35609
|
};
|
|
35668
35610
|
};
|
|
35669
|
-
|
|
35611
|
+
|
|
35612
|
+
func.expression.get_property = async function (valP) {
|
|
35613
|
+
if (typeof valP !== 'string') return { property1: undefined, property2: undefined };
|
|
35614
|
+
|
|
35615
|
+
const secureEval = async (expr) => {
|
|
35616
|
+
if (typeof IS_PROCESS_SERVER === 'undefined') {
|
|
35617
|
+
try {
|
|
35618
|
+
return eval(expr);
|
|
35619
|
+
} catch (err) {
|
|
35620
|
+
console.error(err);
|
|
35621
|
+
return undefined;
|
|
35622
|
+
}
|
|
35623
|
+
}
|
|
35624
|
+
try {
|
|
35625
|
+
const vm = new VM.VM({
|
|
35626
|
+
sandbox: {
|
|
35627
|
+
func,
|
|
35628
|
+
SESSION_ID,
|
|
35629
|
+
SESSION_OBJ: { [SESSION_ID]: SESSION_OBJ[SESSION_ID] },
|
|
35630
|
+
},
|
|
35631
|
+
timeout: 1000,
|
|
35632
|
+
allowAsync: false,
|
|
35633
|
+
});
|
|
35634
|
+
return await vm.run(expr);
|
|
35635
|
+
} catch {
|
|
35636
|
+
return undefined; // Simplified error handling
|
|
35637
|
+
}
|
|
35638
|
+
};
|
|
35639
|
+
|
|
35640
|
+
let property1, property2;
|
|
35641
|
+
const bracketStart = valP.indexOf('[');
|
|
35642
|
+
const bracketEnd = valP.indexOf(']');
|
|
35643
|
+
|
|
35644
|
+
if (bracketStart > -1 && bracketEnd > bracketStart) {
|
|
35645
|
+
const expr = valP.slice(bracketStart + 1, bracketEnd);
|
|
35646
|
+
property1 = await secureEval(expr);
|
|
35647
|
+
}
|
|
35648
|
+
|
|
35649
|
+
const dotIndex = valP.indexOf('.');
|
|
35650
|
+
if (dotIndex > -1) {
|
|
35651
|
+
property2 = valP.slice(dotIndex + 1);
|
|
35652
|
+
}
|
|
35653
|
+
|
|
35654
|
+
return { property1, property2 };
|
|
35655
|
+
};
|
|
35656
|
+
|
|
35657
|
+
func.expression.validate_constant_org = function (valP) {
|
|
35670
35658
|
var patt = /["']/;
|
|
35671
35659
|
if (typeof valP === 'string' && patt.test(valP.substr(0, 1)) && patt.test(valP.substr(0, valP.length - 1))) return true;
|
|
35672
35660
|
else return false;
|
|
35673
35661
|
};
|
|
35674
|
-
func.expression.
|
|
35662
|
+
func.expression.validate_variables_org = function (valP) {
|
|
35675
35663
|
if (typeof valP === 'string' && valP.indexOf('@') > -1) return true;
|
|
35676
35664
|
else return false;
|
|
35677
35665
|
};
|
|
35678
|
-
func.expression.
|
|
35666
|
+
func.expression.remove_quotes_org = function (valP) {
|
|
35679
35667
|
if (func.expression.validate_constant(valP)) return valP.substr(1, valP.length - 2);
|
|
35680
35668
|
else return valP;
|
|
35681
35669
|
};
|
|
35682
35670
|
|
|
35683
|
-
func.expression.
|
|
35671
|
+
func.expression.validate_constant = (valP) => typeof valP === 'string' && /^["'].*["']$/.test(valP);
|
|
35672
|
+
|
|
35673
|
+
func.expression.validate_variables = (valP) => typeof valP === 'string' && valP.includes('@');
|
|
35674
|
+
|
|
35675
|
+
func.expression.remove_quotes = (valP) => (func.expression.validate_constant(valP) && typeof valP === 'string' ? valP.slice(1, -1) : valP);
|
|
35676
|
+
|
|
35677
|
+
func.expression.secure_eval_org = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
35684
35678
|
const api_utils = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
35685
35679
|
func,
|
|
35686
35680
|
glb,
|
|
@@ -35781,6 +35775,90 @@ func.expression.secure_eval = async function (SESSION_ID, sourceP, val, job_id,
|
|
|
35781
35775
|
}
|
|
35782
35776
|
}
|
|
35783
35777
|
};
|
|
35778
|
+
|
|
35779
|
+
func.expression.secure_eval = async function (SESSION_ID, sourceP, val, job_id, dsSessionP, js_script_callback, evt) {
|
|
35780
|
+
if (typeof val !== 'string') return val;
|
|
35781
|
+
|
|
35782
|
+
const xu = await func.common.get_module(SESSION_ID, 'xuda-api-library.mjs', {
|
|
35783
|
+
func,
|
|
35784
|
+
glb,
|
|
35785
|
+
SESSION_OBJ,
|
|
35786
|
+
SESSION_ID,
|
|
35787
|
+
APP_OBJ,
|
|
35788
|
+
dsSession: dsSessionP,
|
|
35789
|
+
job_id,
|
|
35790
|
+
});
|
|
35791
|
+
|
|
35792
|
+
const isServer = typeof IS_PROCESS_SERVER !== 'undefined' || typeof IS_DOCKER !== 'undefined';
|
|
35793
|
+
|
|
35794
|
+
// Client-side execution
|
|
35795
|
+
if (!isServer) {
|
|
35796
|
+
try {
|
|
35797
|
+
return eval(val);
|
|
35798
|
+
} catch {
|
|
35799
|
+
try {
|
|
35800
|
+
return JSON5.parse(val);
|
|
35801
|
+
} catch {
|
|
35802
|
+
return val;
|
|
35803
|
+
}
|
|
35804
|
+
}
|
|
35805
|
+
}
|
|
35806
|
+
|
|
35807
|
+
// Server-side execution
|
|
35808
|
+
const sandbox = {
|
|
35809
|
+
func,
|
|
35810
|
+
xu,
|
|
35811
|
+
SESSION_ID,
|
|
35812
|
+
SESSION_OBJ: { [SESSION_ID]: SESSION_OBJ[SESSION_ID] },
|
|
35813
|
+
callback: js_script_callback,
|
|
35814
|
+
job_id,
|
|
35815
|
+
...(sourceP === 'javascript' ? { axios, got, FormData } : {}),
|
|
35816
|
+
};
|
|
35817
|
+
|
|
35818
|
+
const handleError = (err) => {
|
|
35819
|
+
console.error('Execution error:', err);
|
|
35820
|
+
func.events.delete_job(SESSION_ID, job_id);
|
|
35821
|
+
if (isServer && !SESSION_OBJ[SESSION_ID].crawler) {
|
|
35822
|
+
if (sourceP === 'javascript') {
|
|
35823
|
+
__.rpi.write_log(SESSION_OBJ[SESSION_ID].app_id, 'error', 'worker', 'vm error', err, null, val, 'func.expression.get.secure_eval');
|
|
35824
|
+
} else {
|
|
35825
|
+
__.db.add_error_log(SESSION_OBJ[SESSION_ID].app_id, 'api', err);
|
|
35826
|
+
}
|
|
35827
|
+
}
|
|
35828
|
+
return val; // Fallback to original value
|
|
35829
|
+
};
|
|
35830
|
+
|
|
35831
|
+
if (sourceP === 'javascript') {
|
|
35832
|
+
process.on('uncaughtException', handleError);
|
|
35833
|
+
try {
|
|
35834
|
+
const dir = path.join(_conf.studio_drive_path, SESSION_OBJ[SESSION_ID].app_id, 'node_modules');
|
|
35835
|
+
const script = new VM.VMScript(`try { ${val} } catch (e) { func.api.error(SESSION_ID, "nodejs error", e); console.error(e); func.events.delete_job(SESSION_ID, "${job_id}"); }`, { filename: dir, dirname: dir });
|
|
35836
|
+
const vm = new VM.NodeVM({
|
|
35837
|
+
require: { external: true },
|
|
35838
|
+
sandbox,
|
|
35839
|
+
timeout: 60000,
|
|
35840
|
+
});
|
|
35841
|
+
return await vm.run(script, { filename: dir, dirname: dir });
|
|
35842
|
+
} catch (err) {
|
|
35843
|
+
return handleError(err);
|
|
35844
|
+
}
|
|
35845
|
+
}
|
|
35846
|
+
|
|
35847
|
+
try {
|
|
35848
|
+
const vm = new VM.VM({
|
|
35849
|
+
sandbox,
|
|
35850
|
+
timeout: 1000,
|
|
35851
|
+
allowAsync: false,
|
|
35852
|
+
});
|
|
35853
|
+
return await vm.run(val);
|
|
35854
|
+
} catch {
|
|
35855
|
+
try {
|
|
35856
|
+
return JSON5.parse(val);
|
|
35857
|
+
} catch {
|
|
35858
|
+
return val;
|
|
35859
|
+
}
|
|
35860
|
+
}
|
|
35861
|
+
};
|
|
35784
35862
|
func.events = {};
|
|
35785
35863
|
func.events.validate = async function (SESSION_ID, triggerP, dsSessionP, eventIdP, sourceP, argumentsP, return_validation_onlyP) {
|
|
35786
35864
|
var _session = SESSION_OBJ[SESSION_ID];
|