feat(ses): shim ArrayBuffer.p.transfer
Staged on #2419
Closes: #XXXX Refs: https://github.com/endojs/endo/pull/2414 #2418 #2419
Description
#2414 by itself does not work on Node 18 and Node 20 because
- those platforms do not have
Array.prototype.transfer, so #2414 must usestructuredCloneinstead structuredClonedoes exist on Node >= 18, so it should be on supported platforms (though see #2418 ). However,structuredCloneitself is dangerous and so must not be added to the shared intrinsics. As a result, in #2414 , when@endo/pass-styleis initialized in a created compartment, it fails to find eitherArray.prototype.transferand `structuredClone
To solve this, @kriskowal suggested that we also shim Array.prototype.transfer if needed during lockdown, along with other repairs. We are avoiding similarly shimming Array.prototype.transferToImmutable because it is not yet standard. But Array.prototype.transfer is standard, and so lockdown can globally shim it before hardening the shared intrinsics.
This PR implements @kriskowal 's suggestion.
Security Considerations
none
Scaling Considerations
by itself, none
Documentation Considerations
nothing signicant.
Testing Considerations
See #2418 . Aside from that, none
Compatibility and Upgrade Considerations
Assumes we only support platforms that provide either Array.prototype.transfer itself, or provides structuredClone.
See #2418
Update: This PR is now staged on #2419 to fix a stale dependence on Node 12, which would no longer work after this PR.
See https://github.com/endojs/endo/issues/2418
The platform-compatability-test tests are not marked as required, so solving #2418 does not actually block this PR. But it would be nice to get that fixed first.
PTAL
Please consider removing the unnecessary
slicecall as brand check, and improve support for when the new length doesn't match.
Done