feat(ses): tolerate omitted species #2108
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes: #XXXX
refs: #XXXX
Description
MetaMask is targeting React Native, that run on the Hermes JS engine. Thus, it would be good for the ses-shim to work on Hermes. Once problem we ran into is that Hermes omits
Symbol.species
. (Good riddance!) With this PR, the ses-shim should tolerate this difference from standard JS.Security Considerations
Assuming that the semantics of the JS they implement is adjusted from the standard semantics in any of the obvious ways to cope with the absence of
Symbol.species
, this should have little effect on security.Those "obvious ways" are
.map
, return an array rather than an instance of this or a related subclass of array.constructor
for whatSymbol.species
would have been used for. IOW, when asking a subclass of Array to.map
, return an instance of this subclass rather than a somehow related subclass of array.(FWIW, I further assume they make the first choice. Otherwise, what's the point of the omission? However, this PR should be compat with either.)
I say "little effect on security" above because this absence can in theory mislead correct JS code into silently doing the wrong thing.
Scaling Considerations
None
Documentation Considerations
None
Testing Considerations
I leave that to those set up to test on Hermes, since that is the point. Attn @naugtur @kumavis
Compatibility Considerations
It only causes an observable difference on platforms that omit
Symbol.species
, on which the ses shim previously refused to run. So none.Upgrade Considerations
None. Nothing Breaking certainly. Nothing newsworthy yet. But when the ses-shim as a whole is know to support Hermes, that will be newsworthy ;)
*BREAKING*:
in the commit message with migration instructions for any breaking change.NEWS.md
for user-facing changes.