User-visible changes in SES:
# v1.5.0 (2024-05-06)
- Adds `importNowHook` to the `Compartment` options. The compartment will invoke the hook whenever it encounters a missing dependency while running `compartmentInstance.importNow(specifier)`, which cannot use an asynchronous `importHook`.
- To support TypeScript v5.5, a CommonJS-specific type declaration file is now explicitly exported.
# v1.3.0 (2024-02-22)
- Now supports `Promise.any`, `AggegateError`, `error.errors`,
and `error.cause`.
- Assertion functions/methods that were parameterized by an error constructor
(`makeError`, `assert`, `assert.fail`, `assert.equal`) now also accept named
options `cause` and `errors` in their immediately succeeding
`options` argument.
- For all those, the error constructor can now be an `AggregateError`.
If they do make an error instance, they encapsulate the
non-uniformity of the `AggregateError` construction arguments, allowing
all the error constructors to be used polymorphically
(generic / interchangeable).
- Adds a `GenericErrorConstructor` type to be effectively the common supertype
of `ErrorConstructor` and `AggregateErrorConstructor`, for typing these
error constructor parameters that handle the error constructor
polymorphically.
- The SES `console` now includes `error.cause` and `error.errors` in
its diagnostic output for errors.
# v1.2.0 (2024-02-14)
- Exports `ses/lockdown-shim.js`, `ses/compartment-shim.js`, and
`ses/assert-shim.js` for piecemeal usage.
This change is motivated by the need to omit `ses/assert-shim.js` in Test262
environments.
# v1.1.0 (2024-01-17)
- The [iterators-helpers](https://github.com/tc39/proposal-iterator-helpers)
proposal includes two accessor properties whose purpose is to emulate
a data property, but without the override mistake problem. The ses-shim
creates many such properties, but was unprepared for them to already be
present in the JS platform it starts with. Chrome Canary and Node 22
both implement the iterators-helper proposal, triggering this bug, preventing
the ses-shim from initializing. The ses-shim
[now copes safely](https://github.com/endojs/endo/pull/1969) with an
enumerated set of such properties, starting with these two properties from
the iterators-helpers proposal.
- The ses-shim now permits the new methods from the
[set-methods](https://github.com/tc39/proposal-set-methods) proposal,
enabling these methods to be used on platforms where they are implemented,
which are currently a Chrome Canary and a Node 22.
# v0.18.8 (2023-09-11)
- Extracts `repairIntrinsics(options)` and `hardenIntrinsics()` from the
behavior of `lockdown(options)` so vetted shims can run between these
calls.
Any modifications to shared intrinsics survive if applied after
`repairIntrinsics()`.
- In the SES-shim implementation of HardenedJS, all constructed compartments
get the same safe `Date` constructor, that does not provide the ability to
measure duration.
It used to do this by having `Date.now()` return `NaN`, and to have calls on
the constructor that would normally have returned an indication of the
current date, instead return the corresponding invalid date indication.
Now, all of these throw a `TypeError` whose message begins with `'secure
mode'`.
This aligns with the XS implementation of HardenedJS.
- Similarly, In the SES-shim implementation of HardenedJS, all constructed
compartments get the same safe `Math` namespace object that does not provide
a working `random()` function.
It used to do that by omitting the `random` property from the safe `Math`
namespace object.
Now, the safe shared `Math` namespace object has a `Math.random()` function
that throws a `TypeError whose message begins with `'secure mode'`.
This again aligns with the XS implementation of HardenedJS.
# v0.18.6 (2023-08-07)
- Censors the pattern `{...import(specifier)}`.
We previously censored `import(specifier)` and expressly allowed
`object.import(specifier)`.
The relaxation for the latter form in version 0.13.0 inadvertently allowed
import with the spread operator.
# v0.18.5 (2023-07-14)
- Adds `assert.bare` for embedding unquoted strings in details.
- Permits new `dispose` symbols, other recent additions to JavaScript, and for
the anticipated iterator helpers.
- Tames `Symbol` so symbols can be preserved in the start compartment and
denied to shared compartments.
- Improves debugging in Safari.
- Adds missing native function markers.
All native functions should have a `toString` that says `[native code]`, even
if emulated.
# v0.18.4 (2023-04-20)
- Pass through the start compartment's `globalThis.harden` if defined.
# v0.18.3 (2023-04-14)
- New `__hardenTaming__: 'unsafe'` lockdown option to fake harden unsafely,
which can be used to improve performance for applications that are known to be
safe even with a no-op `harden`.
- Finite deep stacks, using LRU budgets for depth of stacks an well as the
maximum number of weakly-held errors to annotate.
- Add `%AsyncGenerator%.length` and `%AsyncFunctionPrototype%.length` `number`
properties to allowlist.
# v0.18.2 (2023-03-07)
- Introduces the `__syncModuleFunctor__` property of static module record
to replace evauluation of `__syncModuleProgram__` for environments without eval.
# v0.18.1 (2022-12-23)
- Fixes a bug for SES initialization in a no-unsafe-eval
Content-Security-Policy.
- Fixes a bug where reexport of multiple named exports of the same name was
causing them to be overridden by the last value. Now named exports are
handled in the same manner as `export *`.
- Allows Compatment `importHook` implementations to return aliases: module
descriptors that refer to a module by its specifier in the same or a
specified compartment, without providing a static module record (module
source).
# v0.18.0 (2022-11-14)
- *BREAKING*: Removes support for `globalLexicals`.
To our knowledge, there are no production uses for `globalLexicals`.
They currently could leak because `moduleLexicals` and `globalLexicals`
used the same scope object, so properties of one would leak to the other
with crafted modules.
We had an opportunity to plug the leak at the cost of a fifth scope
in all evaluators, but elected to remove the unnecessary complexity instead.
# v0.17.0 (2022-10-24)
- Previous versions of SES would leak the proxy used to isolate evaluated
code to functions added to the global object by guest code.
The value of `this` in such functions should be `undefined`, but that is not
possible to emulate in this shim.
This version changes the value of `this` in such functions to be the same as
`globalThis` of the compartment, as would be correct in sloppy mode.
- Removes experimental support for "known scope proxies".
# v0.16.0 (2022-10-19)
- When hardening a typed array, detects and locks down properties named as
number-coercible strings that are not index properties.
# v0.15.23 (2022-09-27)
- Fixes the unhandled promise rejection logic to report unhandled rejections
when the promise is collected. Because of a bug it previously only reported
at process exit.
- Improves the fidelity of emulation for V8 `Error.prepareStackTrace`,
allowing more legacy code to work by default in isolation.
# v0.15.18 (2022-08-23)
- Removes the `__allowUnsafeMonkeyPatching__` option to lockdown. As the name
should indicate, this was always an unsafe temporary kludge. Its only known
use was in agoric-sdk, now gone at
https://github.com/Agoric/agoric-sdk/pull/5922 . Without this option, a
successful `lockdown` will now always harden the primordials.
# v0.15.8 (2022-02-18)
- Harden now gives special treatment to typed arrays.
Instead of freezing a typed array, harden will seal it and make all of its
non-integer properties non-writable.
All of their integer properties will remain writable and non-configurable.
TypedArrays are exceedingly unusual because their integer properties are
writable and neither freeze nor defineProperty can convert them from writable
to non-writable.
# v0.15.3 (2022-01-21)
- Fixes the type definition for assert.error so that the final options bag,
which may include `errorName`, checks correctly in TypeScript.
- Lockdown will now throw an error if code running before SES initialization
replaced `eval`.
# 0.15.2 (2021-12-08)
- The `Removing...` messages that Lockdown emits when encountering unrecognized
properties on shared intrinsics are now logged as "warnings".
This has the material benefit of sending these messages to STDERR on Node.js.
- Updates permits for all current TC39 stage 3 and 4 proposals, notably
suppressing the `Removing...` messages for `Object.hasOwn`; `findLast` and
`findLastIndex` on both `Array.prototype` and `TypedArray.prototype`; and the
properties `transfer`, `resize`, `resizable`, and `maxByteLength` of
`ArrayBuffer.prototype`.
# 0.15.1 (2021-11-15)
- The TypeScript definition of `lockdown` now allows for the option
`"errorTrapping": "none"`.
- Fixes error trapping on the web, showing both the message (and stack) of any
error that throws out of the top of an event.
# 0.15.0 (2021-11-02)
- _BREAKING CHANGE_: The lockdown option `domainTaming` is now `safe` by
default, which will break any application that depends transtively on the
Node.js `domain` module.
Notably, [standard-things/esm](https://github.com/standard-things/esm)
uses domains and so SES will not support `node -r esm` going forward.
This protects against the unhardened `domain` property appearing on shared
objects like callbacks and promises.
This overcomes the last _known_ obstacle toward object capability containment.
- Lockdown will now read options from the environment as defined by the Node.js
`process.env` parameter space.
- _BREAKING CHANGE_: Lockdown may no longer be called more than once.
Lockdown no longer returns a boolean to indicate whether it was effective
(true) or redundant (false). Instead, Lockdown will return undefined for
its first invocation or throw an error otherwise.
# 0.14.4 (2021-10-14)
- Fixes a defect in the per-compartment `Function` and `eval` functions, such
that these environments did not have the compartment's `globalLexicals`.
There is no known environment depending on this invariant for security
reasons, but such a scenario would be a program arranging a translator that
introduces run-time security checks, like metering, that depend on the
existence of a named global lexical.
[#898](https://github.com/endojs/endo/issues/898)
- The above fix incidentally improved the performance of compartment evaluation
for cases that do not require special global lexicals, by sharing a single
per-compartment evaluator.
# 0.14.3 (2021-09-18)
- Due to a peculiar bit of error handling code in Node 14, as explained at
[Hardened JavaScript interferes with Node.js 14 Error
construction](https://github.com/endojs/endo/issues/868),
we have added more overrides to the default `overrideTaming: 'moderate'`
setting. At this setting, assigning to the `name` property of a mutable error
instance should work. It will continue not to work at the `'min'` setting, so
use the default `'moderate'` setting if you need to.
- Adds a lockdown option `domainTaming` to detect whether Node.js domains have
been initialized and prevents them from being initialized afterward.
Domains otherwise presented a hazard to the integrity of SES containment on
Node.js.
The option defaults to `"unsafe"` in this version and will be switched to
`"safe"` by default in the next release that allows for breaking-changes, to
afford a gradual migration.
Thank you to @dominictarr with [Least Authority](https://leastauthority.com/)
for devising this feature.
- Fixes reflexive module imports. Previously, SES would fail to initialize a
module graph where a module imported an alias to itself.
# 0.14.1 (2021-08-12)
- Adds permits for `Array.prototype.at` and `String.prototype.at` which are
Stage 3 proposals for ECMA 262.
# 0.14.0 (2021-07-22)
- _BREAKING_: Any precompiled static module records from prior versions
will not load in this version of SES or beyond. The format of the preamble
has been changed to admit the possibility of a variable named `Map` declared
in the scope of a module.
- Fixes the type assertions for `assert` and `assert.string`.
- Reveals `harden` only after `lockdown`. Harden was never usable before
lockdown because it would render the environment irreparable.
Calling `harden` before `lockdown` previously threw an exception.
Now it is possible to write libraries that are usable both in JS and SES,
which can know whether to harden their API by the presence of harden in
global scope.
- Adds `errorTrapping` lockdown option and by default traps uncaught exceptions
and logs them back with their original stack traces.
These would previously appear as mysterios `{}` lines in Node.js.
# 0.13.4 (2021-06-19)
- Adds more TypeScript definitions, importable with `///