Skip to content

way for modules to declare expecting Lockdown or Endo #2586

@turadg

Description

@turadg

What is the Problem Being Solved?

Two problems.

  1. Developers sometimes encounter SES_ALREADY_LOCKED_DOWN and 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.

  2. 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

Security Considerations

Scaling Considerations

Test Plan

Compatibility Considerations

Upgrade Considerations

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions