Skip to content

Commit

Permalink
fix(ses): removeUnpermittedIntrinsics on Hermes
Browse files Browse the repository at this point in the history
  • Loading branch information
leotm committed Dec 11, 2024
1 parent 3ef249f commit 49f0f41
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/ses/src/permits.js
Original file line number Diff line number Diff line change
@@ -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' */

Expand Down Expand Up @@ -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;
};
Expand Down

0 comments on commit 49f0f41

Please sign in to comment.