Skip to content

Commit

Permalink
fix: thread the new option thru
Browse files Browse the repository at this point in the history
  • Loading branch information
erights committed Mar 26, 2021
1 parent 48f1a03 commit 05714aa
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/ses/src/lockdown-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { assert, makeAssert } from './error/assert.js';
* consoleTaming?: 'safe' | 'unsafe',
* overrideTaming?: 'min' | 'moderate' | 'severe',
* stackFiltering?: 'concise' | 'verbose',
* __unsafeKludgeForReact__?: 'safe' | 'unsafe',
* }} LockdownOptions
*/

Expand Down Expand Up @@ -140,6 +141,7 @@ export function repairIntrinsics(
consoleTaming = 'safe',
overrideTaming = 'moderate',
stackFiltering = 'concise',
__unsafeKludgeForReact__ = 'safe',

...extraOptions
} = options;
Expand Down Expand Up @@ -172,6 +174,7 @@ export function repairIntrinsics(
consoleTaming,
overrideTaming,
stackFiltering,
__unsafeKludgeForReact__,
};

/**
Expand Down Expand Up @@ -247,11 +250,11 @@ export function repairIntrinsics(
* 3. HARDEN to share the intrinsics.
*/

function hardenIntrinsics(kludge) {
function hardenIntrinsics() {
// Circumvent the override mistake.
enablePropertyOverrides(intrinsics, overrideTaming);

if (!kludge) {
if (__unsafeKludgeForReact__ !== 'unsafe') {
// Finally register and optionally freeze all the intrinsics. This
// must be the operation that modifies the intrinsics.
lockdownHarden(intrinsics);
Expand Down Expand Up @@ -284,18 +287,13 @@ export const makeLockdown = (
* @param {LockdownOptions} [options]
*/
const lockdown = (options = {}) => {
const { skipHardenIntrinsics, ...restOptions } = options;
const maybeHardenIntrinsics = repairIntrinsics(
makeCompartmentConstructor,
compartmentPrototype,
getAnonymousIntrinsics,
restOptions,
options,
);
if (skipHardenIntrinsics) {
maybeHardenIntrinsics(true);
} else {
maybeHardenIntrinsics();
}
return maybeHardenIntrinsics();
};
return lockdown;
};
Expand Down

0 comments on commit 05714aa

Please sign in to comment.