diff --git a/packages/ses/src/permits.js b/packages/ses/src/permits.js index c5745903ee..283d861c34 100644 --- a/packages/ses/src/permits.js +++ b/packages/ses/src/permits.js @@ -1,7 +1,7 @@ /* eslint-disable no-restricted-globals */ /* eslint max-lines: 0 */ -import { arrayPush } from './commons.js'; +import { arrayPush, arrayForEach } from './commons.js'; /** @import {GenericErrorConstructor} from '../types.js' */ @@ -299,6 +299,24 @@ const accessor = { set: fn, }; +// eslint-disable-next-line func-names +const strict = function () { + 'use strict'; +}; + +// TODO Remove this once we no longer support the Hermes that needed this. +arrayForEach(['caller', 'arguments'], prop => { + try { + strict[prop]; + } catch (e) { + // https://github.com/facebook/hermes/blob/main/test/hermes/function-non-strict.js + if (e.message === 'Restricted in strict mode') { + // Fixed in Static Hermes: https://github.com/facebook/hermes/issues/1582 + FunctionInstance[prop] = accessor; + } + } +}); + export const isAccessorPermit = permit => { return permit === getter || permit === accessor; };