diff --git a/packages/ses/src/permits.js b/packages/ses/src/permits.js index c5745903ee..13432ad689 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, getOwnPropertyNames, arrayForEach } from './commons.js'; /** @import {GenericErrorConstructor} from '../types.js' */ @@ -299,6 +299,22 @@ const accessor = { set: fn, }; +// eslint-disable-next-line func-names +const strict = function () { + 'use strict'; +}; + +arrayForEach(getOwnPropertyNames(strict), 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') { + FunctionInstance[prop] = accessor; + } + } +}); + export const isAccessorPermit = permit => { return permit === getter || permit === accessor; };