-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(ses): Compartment options migration #2386
Conversation
packages/ses/src/error/assert.js
Outdated
// Internal, to obviate polymorphic dispatch, but may become rigorously | ||
// consistent with @endo/error. | ||
export { makeError, note as annotateError, redactedDetails as X, quote as q }; | ||
// consistent with @endo/error: | ||
|
||
/** @type {AssertionFunctions['typeof']} */ | ||
const assertTypeof = assert.typeof; | ||
|
||
export { | ||
assertTypeof, | ||
makeError, | ||
note as annotateError, | ||
redactedDetails as X, | ||
quote as q, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a drive-by?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this was my preferred solution to avoid a polymorphic dispatch at assertTypeof
elsewhere in this change. You had good feedback elsewhere which will change this to assertEqual
if not a more systematic change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
) { | ||
const { __options__, ...options } = args[0]; | ||
assert( | ||
__options__ === true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since you require it to have value true
, you should be sure to mention that where you explain __option__
, such as the doc-comment above. From the doc-comment alone, I would guest that you only tested whether the property is present.
packages/ses/src/compartment.js
Outdated
assertTypeof( | ||
options.modules, | ||
'undefined', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure you want to check that the value is undefined
rather than whether the property is present?
Why typeof? The above code should be equivalent to
assertTypeof( | |
options.modules, | |
'undefined', | |
assertEqual( | |
options.modules, | |
undefined, |
but the later says what it means better.
a299074
to
59327f0
Compare
Refs: #400
Description
To converge with XS in the patterns accepted by SES for Compartment construction, this change introduces a
__options__
property to the first argument of the Compartment constructor that indicates that the constructor accepts a single options bag argument and does not receive separate endowments and module map arguments.Security Considerations
None.
Scaling Considerations
None.
Documentation Considerations
This change includes updates for NEWS (with migration instructions and a notice of intent to break deprecated usage patterns) and README (to encourage recommended usage). We intend to follow up with an update to hardenedjs.org upon release.
Testing Considerations
All tests have been updated to use the new constructor pattern except those already marked as legacy, which remain to exercise support for the deprecated usage patterns.
Compatibility Considerations
There is a remote possibility that existing code uses
__options__
as the name of an endowment and will now be misinterpreted. We do not imagine any guest programs are in a position to influence their host compartment’s construction.Upgrade Considerations
None.