Mirror: A maybe slightly safer-ish wrapper around eval Function constructors

Add missing properties

Changed files
+10 -4
src
+10 -4
src/index.ts
···
: undefined;
}
+
function freeze(target: Object): Object {
+
return typeof Object.freeze === 'function'
+
? Object.freeze(target)
+
: target;
+
}
+
// Wrap any given target with a masking object preventing access to prototype properties
function mask(target: any) {
if (
···
: Object.create(null);
// Copy all known keys over to the stand-in and recursively apply `withProxy`
// Prevent unsafe keys from being accessed
-
const keys = Object.getOwnPropertyNames(target)
+
const keys = ['__proto__', 'constructor'].concat(Object.getOwnPropertyNames(target));
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
if (
···
});
}
}
-
return typeof Object.freeze === 'function'
-
? Object.freeze(standin)
-
: standin;
+
if (standin.prototype != null)
+
standin.prototype = freeze(Object.create(null));
+
return freeze(standin);
}
let safeGlobal: Record<string | symbol, unknown> | void;