@xuda.io/xuda-worker-bundle-min 1.3.896 → 1.3.898
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 +45 -20
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -7117,6 +7117,22 @@ func.utils.connect_pouchdb = async function (SESSION_ID) {
|
|
|
7117
7117
|
return new PouchDB("xuda_rt_" + app_id);
|
|
7118
7118
|
};
|
|
7119
7119
|
|
|
7120
|
+
func.utils.validate_pouchdb = async function (SESSION_ID) {
|
|
7121
|
+
const app_id = SESSION_OBJ[SESSION_ID].app_id;
|
|
7122
|
+
const db = new PouchDB("xuda_rt_" + app_id);
|
|
7123
|
+
db.info()
|
|
7124
|
+
.then((info) => {
|
|
7125
|
+
console.log("Database exists", info);
|
|
7126
|
+
})
|
|
7127
|
+
.catch((error) => {
|
|
7128
|
+
if (error.status === 404) {
|
|
7129
|
+
throw new Error("Database does not exist");
|
|
7130
|
+
} else {
|
|
7131
|
+
throw new Error("Error accessing database", error);
|
|
7132
|
+
}
|
|
7133
|
+
});
|
|
7134
|
+
};
|
|
7135
|
+
|
|
7120
7136
|
func.utils.call_plugin_api = function (SESSION_ID, plugin_nameP, dataP) {
|
|
7121
7137
|
var _session = SESSION_OBJ[SESSION_ID];
|
|
7122
7138
|
|
|
@@ -9792,28 +9808,37 @@ func.expression.secure_eval = async function (
|
|
|
9792
9808
|
}
|
|
9793
9809
|
} else {
|
|
9794
9810
|
try {
|
|
9795
|
-
|
|
9796
|
-
|
|
9797
|
-
|
|
9798
|
-
|
|
9799
|
-
|
|
9800
|
-
|
|
9801
|
-
|
|
9802
|
-
|
|
9803
|
-
|
|
9804
|
-
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9808
|
-
|
|
9809
|
-
|
|
9811
|
+
try {
|
|
9812
|
+
let vm = new VM.VM({
|
|
9813
|
+
sandbox: {
|
|
9814
|
+
xu,
|
|
9815
|
+
func,
|
|
9816
|
+
SESSION_ID,
|
|
9817
|
+
SESSION_OBJ: { [`${SESSION_ID}`]: SESSION_OBJ[SESSION_ID] },
|
|
9818
|
+
callback: js_script_callback,
|
|
9819
|
+
job_id,
|
|
9820
|
+
},
|
|
9821
|
+
timeout: 1000,
|
|
9822
|
+
allowAsync: false,
|
|
9823
|
+
});
|
|
9824
|
+
let ret = val;
|
|
9825
|
+
if (typeof val === "string") {
|
|
9826
|
+
ret = await vm.run(val);
|
|
9827
|
+
}
|
|
9828
|
+
return ret;
|
|
9829
|
+
// return vm.run(val);
|
|
9830
|
+
} catch (err) {
|
|
9831
|
+
// console.warn("Failed to execute VM script:", val, err);
|
|
9832
|
+
// return val;
|
|
9833
|
+
throw "";
|
|
9810
9834
|
}
|
|
9811
|
-
return ret;
|
|
9812
|
-
// return vm.run(val);
|
|
9813
9835
|
} catch (err) {
|
|
9814
|
-
|
|
9815
|
-
|
|
9816
|
-
|
|
9836
|
+
try {
|
|
9837
|
+
return JSON5.parse(val);
|
|
9838
|
+
} catch (err) {
|
|
9839
|
+
// console.error(err);
|
|
9840
|
+
return val;
|
|
9841
|
+
}
|
|
9817
9842
|
}
|
|
9818
9843
|
}
|
|
9819
9844
|
};
|