Skip to content

Commit

Permalink
fix(compartment-mapper): Different tack to evade SES import censor (#513
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kriskowal committed Nov 6, 2020
1 parent 56cc403 commit 5df2c0e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
7 changes: 7 additions & 0 deletions packages/compartment-mapper/NEWS.md
@@ -1,5 +1,12 @@
User-visible changes to the compartment mapper:

## Next release

* Embellishes all calls to methods named `import` to work around SES-shim
`Compartment` censoring for dynamic import, using properties instead
of parentheses, since the syntax transformation tools at hand do not
currently simplify these.

## 0.2.2 (2020-11-05)

* Embellishes all calls to methods named `import` to work around SES-shim
Expand Down
12 changes: 6 additions & 6 deletions packages/compartment-mapper/src/import-archive.js
Expand Up @@ -75,9 +75,9 @@ export const parseArchive = async (archiveBytes, archiveLocation) => {
__shimTransforms__,
Compartment
});
// Wrap import calls to bypass SES censoring for dynamic import.
// eslint-disable-next-line prettier/prettier
return (compartment.import)(moduleSpecifier);
// Call import by property to bypass SES censoring for dynamic import.
// eslint-disable-next-line dot-notation
return compartment["import"](moduleSpecifier);
};

return { import: execute };
Expand All @@ -90,7 +90,7 @@ export const loadArchive = async (read, archiveLocation) => {

export const importArchive = async (read, archiveLocation, options) => {
const archive = await loadArchive(read, archiveLocation);
// Wrap import calls to bypass SES censoring for dynamic import.
// eslint-disable-next-line prettier/prettier
return (archive.import)(options);
// Call import by property to bypass SES censoring for dynamic import.
// eslint-disable-next-line dot-notation
return archive["import"](options);
};
12 changes: 6 additions & 6 deletions packages/compartment-mapper/src/import.js
Expand Up @@ -44,17 +44,17 @@ export const loadLocation = async (read, moduleLocation) => {
__shimTransforms__,
Compartment
});
// Wrap import calls to bypass SES censoring for dynamic import.
// eslint-disable-next-line prettier/prettier
return (compartment.import)(moduleSpecifier);
// Call import by property to bypass SES censoring for dynamic import.
// eslint-disable-next-line dot-notation
return compartment["import"](moduleSpecifier);
};

return { import: execute };
};

export const importLocation = async (read, moduleLocation, options = {}) => {
const application = await loadLocation(read, moduleLocation);
// Wrap import calls to bypass SES censoring for dynamic import.
// eslint-disable-next-line prettier/prettier
return (application.import)(options);
// Call import by property to bypass SES censoring for dynamic import.
// eslint-disable-next-line dot-notation
return application["import"](options);
};

0 comments on commit 5df2c0e

Please sign in to comment.