Fix: safe serialise TypedArrays to avoid loosing constructor information (#5941)

* fix: enhance cleanJson to support serialization of typed arrays

* fix: correctness of inference based checks

* fix: remove duplicate Uint8Array reference

* fix: correct export syntax for mixinTypedArrays

Updated the export statement to use 'exports' instead of 'export' for proper module export functionality.

* chore: code cleanup

* test: add basics tests for cleanJson
This commit is contained in:
Siddharth Gelera (reaper)
2025-10-31 17:23:48 +05:30
committed by GitHub
parent 08c182a875
commit e47d1ed353
6 changed files with 142 additions and 2 deletions

View File

@@ -35,6 +35,7 @@ const cheerio = require('cheerio');
const tv4 = require('tv4');
const jsonwebtoken = require('jsonwebtoken');
const { executeQuickJsVmAsync } = require('../sandbox/quickjs');
const { mixinTypedArrays } = require('../sandbox/mixins/typed-arrays');
class ScriptRuntime {
constructor(props) {
@@ -94,6 +95,10 @@ class ScriptRuntime {
__brunoTestResults: __brunoTestResults
};
if (this.runtime === 'vm2') {
mixinTypedArrays(context);
}
if (onConsoleLog && typeof onConsoleLog === 'function') {
const customLogger = (type) => {
return (...args) => {
@@ -265,6 +270,10 @@ class ScriptRuntime {
__brunoTestResults: __brunoTestResults
};
if (this.runtime === 'vm2') {
mixinTypedArrays(context);
}
if (onConsoleLog && typeof onConsoleLog === 'function') {
const customLogger = (type) => {
return (...args) => {