start on createSES
MODIFY
src/bundled/createSES.js
src/bundled/createSES.js
+import { deepFreeze } from './deepFreeze.js';
+import { removeProperties } from './removeProperties.js';
+import { tamePrimordials } from './tame.js';
export function createSES(createSESString) {
- const SES = {};
+ function makeSESRealm() {
+ const r = Realm.makeRootRealm();
+ r.global.SES = r.evaluate(createSESString)(createSESString);
+ removeProperties(r.global);
+ tamePrimordials(r.global);
+ const primordialRoots = { global: r.global
+ // todo: add other roots, to reach the
+ // unreachables
+ };
+ deepFreeze(primordialRoots);
+ return r;
+ }
+ const SES = {
+ makeSESRealm,
+ confine(code, endowments) {
+ const r = makeSESRealm();
+ return r.evaluate(code, endowments);
+ }
+ };
return SES;
}

MODIFY
src/bundled/deepFreeze.js
src/bundled/deepFreeze.js
// then copied from proposal-frozen-realms deep-freeze.js
-function deepFreeze(primordialRoots) {
+export function deepFreeze(primordialRoots) {
const { freeze, getOwnPropertyDescriptors, getPrototypeOf } = Object;
const { ownKeys } = Reflect;

MODIFY
src/bundled/removeProperties.js
src/bundled/removeProperties.js
// See the License for the specific language governing permissions and
// limitations under the License.
-const buildWhitelist = require('./whitelist.js').buildWhitelist;
+import { buildWhitelist } from './whitelist.js';
-function removeProperties(global) {
+export function removeProperties(global) {
// walk global object, test against whitelist, delete
const whitelist = buildWhitelist();

MODIFY
src/bundled/tame.js
src/bundled/tame.js
@@ -53,16 +53,9 @@ function tameError(global) {
{ get() { return 'stack suppressed'; } });
}
-function tamePrimordials(global) {
+export function tamePrimordials(global) {
tameDate(global);
tameMath(global);
tameIntl(global);
tameError(global);
}
-
-
-function populateSESObject(global) {
- global.SES = OMGQUINE;
-}
-
-export const tamePrimordialsShim, removePropertiesShim, populateSESObjectShim, deepFreezeShim,

start on createSES