-
Notifications
You must be signed in to change notification settings - Fork 81
Description
What is the Problem Being Solved?
Two problems.
-
Developers sometimes encounter
SES_ALREADY_LOCKED_DOWNand have a hard time finding where it was locked down. Sometimes two modules both attempt lockdown, so the second fails. With transitive dependencies it can be hard to track down. -
Declaring the available global environment for TypeScript is currently done with triple-slash directives which aren't validated at runtime. E.g.,
/// <reference types="ses" />
Description of the Design
Principle: programs should perform lockdown, not modules. That is, only an entry-point module should be doing import '@endo/init' or however lockdown happens.
The change is to let a module declare that it expects to run in a locked-down program. Perhaps by way of an import that:
- checks if the environment is already locked down
- if it isn't, log loudly about the expectation and teach a remedy
- as a side-effect updates the TS global env with what lockdown provides in the global env(e.g.
harden)
Similarly for Endo, with TextEncoder, TextDecoder, URL, HandledPromise, etc