Fix SES lockdown on older browsers (#10014)

On older browsers that don't support `globalThis`[1], the SES lockdown
throws an error. The `globalthis` shim has been added to all pages, to
the background process, and to the `contentscript`. This should prevent
the error on older browsers.

[1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#Browser_compatibility
feature/default_network_editable
Mark Stacey 4 years ago committed by GitHub
parent da5e5cd8b6
commit d13aabde23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/home.html
  2. 8
      app/manifest/_base.json
  3. 1
      app/notification.html
  4. 1
      app/phishing.html
  5. 1
      app/popup.html
  6. 4
      development/build/static.js
  7. 1
      package.json

@ -10,6 +10,7 @@
<body>
<div id="app-content"></div>
<div id="popover-content"></div>
<script src="./globalthis.js" type="text/javascript" charset="utf-8"></script>
<script src="./initSentry.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown.cjs" type="text/javascript" charset="utf-8"></script>
<script src="./runLockdown.js" type="text/javascript" charset="utf-8"></script>

@ -2,6 +2,7 @@
"author": "https://metamask.io",
"background": {
"scripts": [
"globalthis.js",
"initSentry.js",
"lockdown.cjs",
"runLockdown.js",
@ -36,7 +37,12 @@
"content_scripts": [
{
"matches": ["file://*/*", "http://*/*", "https://*/*"],
"js": ["lockdown.cjs", "runLockdown.js", "contentscript.js"],
"js": [
"globalthis.js",
"lockdown.cjs",
"runLockdown.js",
"contentscript.js"
],
"run_at": "document_start",
"all_frames": true
},

@ -33,6 +33,7 @@
<img id="loading__spinner" src="./images/spinner.gif" alt="" />
</div>
<div id="popover-content"></div>
<script src="./globalthis.js" type="text/javascript" charset="utf-8"></script>
<script src="./initSentry.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown.cjs" type="text/javascript" charset="utf-8"></script>
<script src="./runLockdown.js" type="text/javascript" charset="utf-8"></script>

@ -2,6 +2,7 @@
<html lang="en">
<head>
<title>Ethereum Phishing Detection - MetaMask</title>
<script src="./globalthis.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown.cjs" type="text/javascript" charset="utf-8"></script>
<script src="./runLockdown.js" type="text/javascript" charset="utf-8"></script>
<script src="./phishing-detect.js"></script>

@ -10,6 +10,7 @@
<body style="width:357px; height:600px;">
<div id="app-content"></div>
<div id="popover-content"></div>
<script src="./globalthis.js" type="text/javascript" charset="utf-8"></script>
<script src="./initSentry.js" type="text/javascript" charset="utf-8"></script>
<script src="./lockdown.cjs" type="text/javascript" charset="utf-8"></script>
<script src="./runLockdown.js" type="text/javascript" charset="utf-8"></script>

@ -44,6 +44,10 @@ const copyTargets = [
pattern: `*.html`,
dest: ``,
},
{
src: `./node_modules/globalthis/dist/browser.js`,
dest: `globalthis.js`,
},
{
src: `./node_modules/ses/dist/`,
pattern: `lockdown.cjs`,

@ -128,6 +128,7 @@
"extensionizer": "^1.0.1",
"fast-json-patch": "^2.0.4",
"fuse.js": "^3.2.0",
"globalthis": "^1.0.1",
"human-standard-token-abi": "^2.0.0",
"json-rpc-engine": "^6.1.0",
"json-rpc-middleware-stream": "^2.1.1",

Loading…
Cancel
Save