Skip to content

Commit

Permalink
feat: Thread URL and Base64 endowments
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Sep 23, 2021
1 parent 758957c commit b52269d
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/SwingSet/src/controller.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// @ts-check
/* global globalThis */

import fs from 'fs';
import process from 'process';
import re2 from 're2';
Expand Down Expand Up @@ -213,6 +215,8 @@ export async function makeSwingsetController(
console: makeConsole(`${debugPrefix}SwingSet:kernel`),
assert,
require: kernelRequire,
URL: globalThis.Base64, // Unavailable only on XSnap
Base64: globalThis.Base64, // Available only on XSnap
},
});
const buildKernel = kernelNS.default;
Expand Down
6 changes: 6 additions & 0 deletions packages/SwingSet/src/kernel/vatManager/manager-local.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// @ts-check
/* global globalThis */

import { assert, details as X } from '@agoric/assert';
import { importBundle } from '@agoric/import-bundle';
import { makeLiveSlots } from '../liveSlots.js';
Expand Down Expand Up @@ -124,6 +126,10 @@ export function makeLocalVatManagerFactory(tools) {
consensusMode || logger(...args);
}),
assert,
TextEncoder,
TextDecoder,
Base64: globalThis.Base64, // Available only on XSnap
URL: globalThis.URL, // Unavailable only on XSnap
});
const inescapableGlobalProperties = { ...ls.inescapableGlobalProperties };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ function makeWorker(port) {
assert,
// bootstrap provides HandledPromise
HandledPromise: globalThis.HandledPromise,
TextEncoder,
TextDecoder,
Base64: globalThis.Base64, // Present only in XSnap
};

const inescapableGlobalProperties = { ...ls.inescapableGlobalProperties };
Expand Down
4 changes: 4 additions & 0 deletions packages/SwingSet/tools/install-ses-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
// https://github.com/endojs/endo/blob/master/packages/ses/lockdown-options.md
// for more explanation of these lockdown options.

/* global globalThis */

import 'ses';
import '@agoric/eventual-send/shim.js';
// TODO Remove babel-standalone preinitialization
Expand Down Expand Up @@ -73,3 +75,5 @@ Error.stackTraceLimit = Infinity;

harden(TextEncoder);
harden(TextDecoder);
harden(globalThis.URL); // Absent only on XSnap
harden(globalThis.Base64); // Present only on XSnap
4 changes: 4 additions & 0 deletions packages/import-bundle/src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* global globalThis */

import { parseArchive } from '@endo/compartment-mapper/import-archive.js';
import { decodeBase64 } from '@endo/base64';
import { assert, details as X } from '@agoric/assert';
Expand All @@ -21,6 +23,8 @@ export async function importBundle(bundle, options = {}) {
const endowments = {
TextEncoder,
TextDecoder,
URL: globalThis.URL, // Absent only in XSnap
Base64: globalThis.Base64, // Present only in XSnap
...optEndowments,
};

Expand Down
4 changes: 3 additions & 1 deletion packages/install-ses/install-ses.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global LOCKDOWN_OPTIONS process */
/* global globalThis LOCKDOWN_OPTIONS process */
// 'lockdown' appears on the global as a side-effect of importing 'ses'
import 'ses';

Expand Down Expand Up @@ -147,3 +147,5 @@ Error.stackTraceLimit = Infinity;

harden(TextEncoder);
harden(TextDecoder);
harden(globalThis.URL); // Absent only on XSnap
harden(globalThis.Base64); // Present only on XSnap
9 changes: 8 additions & 1 deletion packages/spawner/src/vat-spawned.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
/* global globalThis */

import { importBundle } from '@agoric/import-bundle';
import { Far } from '@agoric/marshal';

const endowments = { console, assert };
const endowments = {
console,
assert,
Base64: globalThis.Base64, // Present only on XSnap
URL: globalThis.URL, // Absent only on XSnap
};

export function buildRootObject() {
return Far('root', {
Expand Down

0 comments on commit b52269d

Please sign in to comment.