├── .circleci ├── config.yml └── scripts │ ├── collect-har-artifact.sh │ └── deps-install.sh ├── .eslintrc.js ├── .github ├── CODEOWNERS └── workflows │ └── security-code-scanner.yml ├── .gitignore ├── .npmignore ├── .nvmrc ├── LICENSE ├── README.md ├── build ├── bundle.js ├── icons.js ├── images │ ├── icon-128.png │ ├── icon-16.png │ └── icon-48.png ├── main.js ├── manifest.js ├── manifests │ ├── _base.json │ ├── brave.json │ ├── chrome.json │ └── firefox.json ├── prep.sh └── zip.js ├── package.json ├── src └── contentscript.js └── yarn.lock /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | workflows: 4 | build-test: 5 | jobs: 6 | - prep-deps 7 | - test-build: 8 | requires: 9 | - prep-deps 10 | - test-lint: 11 | requires: 12 | - prep-deps 13 | - all-tests-pass: 14 | requires: 15 | - test-build 16 | - test-lint 17 | 18 | jobs: 19 | prep-deps: 20 | docker: 21 | - image: circleci/node:10 22 | steps: 23 | - checkout 24 | - run: 25 | name: Install deps 26 | command: | 27 | .circleci/scripts/deps-install.sh 28 | - run: 29 | name: Collect yarn install HAR logs 30 | command: | 31 | .circleci/scripts/collect-har-artifact.sh 32 | - persist_to_workspace: 33 | root: . 34 | paths: 35 | - node_modules 36 | - build-artifacts 37 | 38 | test-build: 39 | docker: 40 | - image: circleci/node:10 41 | steps: 42 | - checkout 43 | - attach_workspace: 44 | at: . 45 | - run: 46 | name: Build project 47 | command: yarn build 48 | 49 | test-lint: 50 | docker: 51 | - image: circleci/node:10 52 | steps: 53 | - checkout 54 | - attach_workspace: 55 | at: . 56 | - run: 57 | name: Lint 58 | command: yarn lint 59 | 60 | all-tests-pass: 61 | docker: 62 | - image: circleci/node:10 63 | steps: 64 | - run: 65 | name: All tests passed 66 | command: echo 'Great success' 67 | -------------------------------------------------------------------------------- /.circleci/scripts/collect-har-artifact.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | set -e 5 | set -u 6 | set -o pipefail 7 | 8 | mkdir -p build-artifacts/yarn-install-har 9 | mv ./*.har build-artifacts/yarn-install-har/ 10 | -------------------------------------------------------------------------------- /.circleci/scripts/deps-install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | set -e 5 | set -u 6 | set -o pipefail 7 | 8 | yarn --frozen-lockfile --ignore-scripts --har 9 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parserOptions: { 3 | ecmaVersion: 2018, 4 | sourceType: 'module', 5 | }, 6 | extends: [ 7 | '@metamask/eslint-config', 8 | '@metamask/eslint-config/config/nodejs', 9 | ], 10 | plugins: [ 11 | 'json', 12 | ], 13 | globals: { 14 | window: true, 15 | document: true, 16 | }, 17 | rules: { 18 | 'import/unambiguous': 'off', 19 | 'import/extensions': 'off', 20 | 'import/no-unassigned-import': 'off', 21 | 'node/no-sync': 'off', 22 | }, 23 | ignorePatterns: [ 24 | '!.eslintrc.js', 25 | 'node_modules/', 26 | 'dist/', 27 | 'build/temp', 28 | ], 29 | } 30 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Lines starting with '#' are comments. 2 | # Each line is a file pattern followed by one or more owners. 3 | 4 | * @MetaMask/extension-devs @rekmarks 5 | -------------------------------------------------------------------------------- /.github/workflows/security-code-scanner.yml: -------------------------------------------------------------------------------- 1 | name: MetaMask Security Code Scanner 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | workflow_dispatch: 11 | 12 | jobs: 13 | run-security-scan: 14 | runs-on: ubuntu-latest 15 | permissions: 16 | actions: read 17 | contents: read 18 | security-events: write 19 | steps: 20 | - name: MetaMask Security Code Scanner 21 | uses: MetaMask/action-security-code-scanner@v1 22 | with: 23 | repo: ${{ github.repository }} 24 | paths_ignored: | 25 | .storybook/ 26 | '**/__snapshots__/' 27 | '**/*.snap' 28 | '**/*.stories.js' 29 | '**/*.stories.tsx' 30 | '**/*.test.browser.ts*' 31 | '**/*.test.js*' 32 | '**/*.test.ts*' 33 | '**/fixtures/' 34 | '**/jest.config.js' 35 | '**/jest.environment.js' 36 | '**/mocks/' 37 | '**/test*/' 38 | docs/ 39 | e2e/ 40 | merged-packages/ 41 | node_modules 42 | storybook/ 43 | test*/ 44 | rules_excluded: example 45 | project_metrics_token: ${{ secrets.SECURITY_SCAN_METRICS_TOKEN }} 46 | slack_webhook: ${{ secrets.APPSEC_BOT_SLACK_WEBHOOK }} 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # build 2 | dist 3 | build/temp 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | yarn-debug.log* 10 | yarn-error.log* 11 | lerna-debug.log* 12 | 13 | # Diagnostic reports (https://nodejs.org/api/report.html) 14 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 15 | 16 | # Runtime data 17 | pids 18 | *.pid 19 | *.seed 20 | *.pid.lock 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | lib-cov 24 | 25 | # Coverage directory used by tools like istanbul 26 | coverage 27 | *.lcov 28 | 29 | # nyc test coverage 30 | .nyc_output 31 | 32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 33 | .grunt 34 | 35 | # Bower dependency directory (https://bower.io/) 36 | bower_components 37 | 38 | # node-waf configuration 39 | .lock-wscript 40 | 41 | # Compiled binary addons (https://nodejs.org/api/addons.html) 42 | build/Release 43 | 44 | # Dependency directories 45 | node_modules/ 46 | jspm_packages/ 47 | 48 | # TypeScript v1 declaration files 49 | typings/ 50 | 51 | # TypeScript cache 52 | *.tsbuildinfo 53 | 54 | # Optional npm cache directory 55 | .npm 56 | 57 | # Optional eslint cache 58 | .eslintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variables file 76 | .env 77 | .env.test 78 | 79 | # parcel-bundler cache (https://parceljs.org/) 80 | .cache 81 | 82 | # Next.js build output 83 | .next 84 | 85 | # Nuxt.js build / generate output 86 | .nuxt 87 | dist 88 | 89 | # Gatsby files 90 | .cache/ 91 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 92 | # https://nextjs.org/blog/next-9-1#public-directory-support 93 | # public 94 | 95 | # vuepress build output 96 | .vuepress/dist 97 | 98 | # Serverless directories 99 | .serverless/ 100 | 101 | # FuseBox cache 102 | .fusebox/ 103 | 104 | # DynamoDB Local files 105 | .dynamodb/ 106 | 107 | # TernJS port file 108 | .tern-port 109 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | * 2 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v10 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 MetaMask 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # legacy-web3-extension 2 | 3 | An extension that adds MetaMask's legacy `window.web3` API to your browser. 4 | 5 | ## Usage 6 | 7 | 1. `yarn install` 8 | 2. `yarn build` 9 | 3. Load the unpacked extension from `dist/unpacked/YOUR_FAVORITE_BROWSER` 10 | 4. Test with any build of the MetaMask Extension, version [9.0.1](https://github.com/MetaMask/metamask-extension/releases/tag/v9.0.1) and later 11 | 12 | ### Dependencies 13 | 14 | This extension has a single production dependency: [`@metamask/legacy-web3`](https://npmjs.com/package/@metamask/legacy-web3) 15 | 16 | The extension's content script contains the [minified source](https://unpkg.com/@metamask/legacy-web3@2.0.0/dist/metamask.web3.min.js) of this dependency as a string literal in order to inject it into web pages as a `