@caridy/sjs
Advanced tools
Comparing version 0.2.11 to 0.2.12
@@ -25,3 +25,3 @@ import { apply, assign, construct, ReflectSetPrototypeOf, freeze, isFunction, ObjectCreate, isUndefined, ReflectGetOwnPropertyDescriptor, ReflectDefineProperty, ErrorCreate, ReflectGetPrototypeOf, ReflectGet, ReflectSet, ReflectHas, map, isNull, isNullOrUndefined, unconstruct, ownKeys, ReflectIsExtensible, ReflectPreventExtensions, deleteProperty, hasOwnProperty, emptyArray, } from "./shared.js"; | ||
// target is a revoked proxy | ||
shadowTarget = () => { }; | ||
shadowTarget = function () { }; | ||
} | ||
@@ -28,0 +28,0 @@ // This is only really needed for debugging, it helps to identify the proxy by name |
@@ -1,2 +0,2 @@ | ||
import { apply, assign, isUndefined, isNullOrUndefined, ObjectCreate, isFunction, hasOwnProperty, ReflectDefineProperty, emptyArray, ErrorCreate, ESGlobalKeys, ReflectGetOwnPropertyDescriptor, ReflectIsExtensible, SetHas, WeakMapCreate, WeakMapHas, WeakMapSet, ReflectiveIntrinsicObjectNames, WeakMapGet, construct, } from "./shared.js"; | ||
import { apply, assign, isUndefined, isNullOrUndefined, ObjectCreate, isFunction, hasOwnProperty, ReflectDefineProperty, emptyArray, ErrorCreate, ESGlobalKeys, ReflectGetOwnPropertyDescriptor, ReflectIsExtensible, SetHas, WeakMapCreate, WeakMapHas, WeakMapSet, ReflectiveIntrinsicObjectNames, WeakMapGet, construct, ownKeys, } from "./shared.js"; | ||
import { serializedRedEnvSourceText } from "./red.js"; | ||
@@ -89,3 +89,5 @@ import { blueProxyFactory } from "./blue.js"; | ||
if (!isUndefined(blueDescriptors)) { | ||
for (const key in blueDescriptors) { | ||
const keys = ownKeys(blueDescriptors); | ||
for (let i = 0, len = keys.length; i < len; i += 1) { | ||
const key = keys[i]; | ||
// TODO: this whole loop needs cleanup and simplification avoid | ||
@@ -97,2 +99,3 @@ // overriding ECMAScript global keys. | ||
// avoid poisoning by only installing own properties from blueDescriptors | ||
// @ts-ignore PropertyDescriptorMap def defines properties as being only of string type | ||
const blueDescriptor = assign(ObjectCreate(null), blueDescriptors[key]); | ||
@@ -99,0 +102,0 @@ if ('value' in blueDescriptor) { |
export const serializedRedEnvSourceText = (function redEnvFactory(blueEnv, hooks) { | ||
'use strict'; | ||
const LockerLiveValueMarkerSymbol = Symbol.for('@@lockerLiveValue'); | ||
@@ -133,5 +132,8 @@ const { blueMap, distortionMap } = blueEnv; | ||
function copyRedOwnDescriptors(shadowTarget, blueDescriptors) { | ||
for (const key in blueDescriptors) { | ||
const keys = ownKeys(blueDescriptors); | ||
for (let i = 0, len = keys.length; i < len; i += 1) { | ||
const key = keys[i]; | ||
// avoid poisoning by checking own properties from descriptors | ||
if (hasOwnPropertyCall(blueDescriptors, key)) { | ||
// @ts-ignore PropertyDescriptorMap def defines properties as being only of string type | ||
const originalDescriptor = getRedDescriptor(blueDescriptors[key]); | ||
@@ -161,3 +163,3 @@ installDescriptorIntoShadowTarget(shadowTarget, key, originalDescriptor); | ||
setPrototypeOf(shadowTarget, getRedValue(getPrototypeOf(originalTarget))); | ||
// locking down the extensibility of shadowTarget | ||
// locking down the extensibility of shadowTarget | ||
preventExtensions(shadowTarget); | ||
@@ -540,5 +542,6 @@ } | ||
catch (_a) { | ||
// target is either a revoked proxy, or a proxy that throws on the has trap, | ||
// in which case going with the arrow function seems appropriate. | ||
shadowTarget = () => { }; | ||
// target is either a revoked proxy, or a proxy that throws on the | ||
// `has` trap, in which case going with a strict mode function seems | ||
// appropriate. | ||
shadowTarget = function () { }; | ||
} | ||
@@ -592,3 +595,8 @@ renameFunction(blue, shadowTarget); | ||
return getRedValue; | ||
}).toString(); | ||
}) | ||
.toString() | ||
// We cannot have 'use strict' directly in `redEnvFactory()` because bundlers and | ||
// minifiers may strip the directive. So, we inject 'use strict' after the function | ||
// is coerced to a string. | ||
.replace('{', `{'use strict'`); | ||
//# sourceMappingURL=red.js.map |
@@ -69,3 +69,5 @@ export const { isArray: ArrayIsArray } = Array; | ||
'Object', | ||
'Promise', | ||
// Allow Blue `Promise` constructor to overwrite the Red one so that promises | ||
// created by the `Promise` constructor or APIs like `fetch` will work. | ||
//'Promise', | ||
'Proxy', | ||
@@ -72,0 +74,0 @@ 'RangeError', |
{ | ||
"name": "@caridy/sjs", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"description": "Experimental JS Library to create a sandboxed JavaScript environment in browsers and node", | ||
@@ -5,0 +5,0 @@ "module": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
282419
3867