From 10958e617627315abb1e7dfb54e85784b64c279f Mon Sep 17 00:00:00 2001 From: Russell Dempsey <1173416+SgtPooki@users.noreply.github.com> Date: Tue, 8 Mar 2022 14:42:19 -0800 Subject: [PATCH] feat: use typescript (#194) * migrate classes to separate typescript files * fixed all typescript errors * add aegir * compile new app.js: npx tsc * add vscode config * move app.js to dist/ * chore: improve dev setup * chore: fix with aegir lint -f * chore: replace all tab characters * chore: fix majority of lint errors * chore: clean up comments & fix docs * run check-aegir-project * remove docker publish action * use dist folder * publish github pages on push to master branch * deploy to gh-pages on merge to master * remove release job * temporarily disable running test scripts * clock icon no longer blocks flag icon * create npm start script * minor refactor, misc improvements; dep updates * fix a few UI issues * Bump typescript from 4.5.5 to 4.6.2 Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.5.5 to 4.6.2. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/compare/v4.5.5...v4.6.2) --- updated-dependencies: - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * feat: use jsipfs to publish to ipfs * chore: fix package.json 'main' and 'files' * fix: correct aegir settings & type failures * use gh-pages * fix: Cors onerror clears Tag * revert ipfs client and ipfs-geoip versions * CORS results update correctly * All checks are async * Online icon displays globe on success * minor touchup * commit serialized version of site before changes The json was generated by rendering the public-gateway-checker locally, and then running the following snippet in the console: ```javascript console.log(JSON.stringify(Array.from(document.querySelectorAll('.Node')).map((el) => Array.from(el.querySelectorAll('div')).reduce((acc, item) => { let content = item.textContent if (item.className.includes('Flag')) { content = item.style.getPropertyValue('background-image') } if (item.className.includes('Took')) { // Do not serialized the time it took because it may always change return acc } acc[item.className] = content return acc }, {})).sort((a, b) => { if (a.Link > b.Link) return 1 if (a.Link < b.Link) return -1 return 0 }), null, 2)) ``` * serialize changes after update * fix origin checks * #/# tested correctly updates Also fixed online checks. All gateways show online. Verified manually by clicking each link * runaway fixes... * Update package.json Co-authored-by: Marcin Rataj * Update .github/workflows/js-test-and-release.yml Co-authored-by: Marcin Rataj * Update .github/workflows/build-and-publish-github-pages.yml Co-authored-by: Marcin Rataj * use versioned rate-limter pkg * comment out test github actions Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Marcin Rataj --- .eslintrc.json | 10 + .github/dependabot.yml | 8 + .github/workflows/automerge.yml | 50 + .../build-and-publish-github-pages.yml | 26 + .github/workflows/js-test-and-release.yml | 131 + .gitignore | 237 + .vscode/settings.json | 11 + LICENSE | 23 +- LICENSE-APACHE | 5 + LICENSE-MIT | 19 + README.md | 15 +- app.js | 413 - lastpubver | 1 - package-lock.json | 48586 ++++++++++++++++ package.json | 155 + publish-to-ipfs.sh | 3 - serialized.json | 638 + src/CheckBase.ts | 38 + src/Checker.ts | 44 + src/Cors.ts | 56 + src/Flag.ts | 140 + src/GatewayNode.ts | 143 + src/Log.ts | 43 + src/Origin.ts | 44 + src/Results.ts | 19 + src/Stats.ts | 42 + src/Status.ts | 73 + src/Tag.ts | 95 + src/TagStatus.ts | 12 + src/UiComponent.ts | 13 + src/checkViaImgSrc.ts | 44 + src/constants.ts | 12 + src/expectSubdomainRedirect.ts | 29 + src/gatewayHostname.ts | 14 + gateways.json => src/gateways.json | 0 src/global.d.ts | 67 + index.html => src/index.html | 16 +- src/index.ts | 13 + src/ipfsHttpClient.ts | 8 + styles.css => src/styles.css | 13 +- tsconfig.json | 17 + 41 files changed, 50872 insertions(+), 454 deletions(-) create mode 100644 .eslintrc.json create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/automerge.yml create mode 100644 .github/workflows/build-and-publish-github-pages.yml create mode 100644 .github/workflows/js-test-and-release.yml create mode 100644 .gitignore create mode 100644 .vscode/settings.json create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-MIT delete mode 100644 app.js delete mode 100644 lastpubver create mode 100644 package-lock.json create mode 100644 package.json delete mode 100755 publish-to-ipfs.sh create mode 100644 serialized.json create mode 100644 src/CheckBase.ts create mode 100644 src/Checker.ts create mode 100644 src/Cors.ts create mode 100644 src/Flag.ts create mode 100644 src/GatewayNode.ts create mode 100644 src/Log.ts create mode 100644 src/Origin.ts create mode 100644 src/Results.ts create mode 100644 src/Stats.ts create mode 100644 src/Status.ts create mode 100644 src/Tag.ts create mode 100644 src/TagStatus.ts create mode 100644 src/UiComponent.ts create mode 100644 src/checkViaImgSrc.ts create mode 100644 src/constants.ts create mode 100644 src/expectSubdomainRedirect.ts create mode 100644 src/gatewayHostname.ts rename gateways.json => src/gateways.json (100%) create mode 100644 src/global.d.ts rename index.html => src/index.html (83%) create mode 100644 src/index.ts create mode 100644 src/ipfsHttpClient.ts rename styles.css => src/styles.css (91%) create mode 100644 tsconfig.json diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..ac83679d --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,10 @@ +{ + "extends": [ + "ipfs", + "plugin:compat/recommended" + ], + "env": { + "browser": true, + "node": false + } +} diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..290ad028 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,8 @@ +version: 2 +updates: +- package-ecosystem: npm + directory: "/" + schedule: + interval: daily + time: "10:00" + open-pull-requests-limit: 10 diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml new file mode 100644 index 00000000..13da9c15 --- /dev/null +++ b/.github/workflows/automerge.yml @@ -0,0 +1,50 @@ +# Automatically merge pull requests opened by web3-bot, as soon as (and only if) all tests pass. +# This reduces the friction associated with updating with our workflows. + +on: [ pull_request ] +name: Automerge + +jobs: + automerge-check: + if: github.event.pull_request.user.login == 'web3-bot' + runs-on: ubuntu-latest + outputs: + status: ${{ steps.should-automerge.outputs.status }} + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Check if we should automerge + id: should-automerge + run: | + for commit in $(git rev-list --first-parent origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}); do + committer=$(git show --format=$'%ce' -s $commit) + echo "Committer: $committer" + if [[ "$committer" != "web3-bot@users.noreply.github.com" ]]; then + echo "Commit $commit wasn't committed by web3-bot, but by $committer." + echo "::set-output name=status::false" + exit + fi + done + echo "::set-output name=status::true" + automerge: + needs: automerge-check + runs-on: ubuntu-latest + # The check for the user is redundant here, as this job depends on the automerge-check job, + # but it prevents this job from spinning up, just to be skipped shortly after. + if: github.event.pull_request.user.login == 'web3-bot' && needs.automerge-check.outputs.status == 'true' + steps: + - name: Wait on tests + uses: lewagon/wait-on-check-action@bafe56a6863672c681c3cf671f5e10b20abf2eaa # v0.2 + with: + ref: ${{ github.event.pull_request.head.sha }} + repo-token: ${{ secrets.GITHUB_TOKEN }} + wait-interval: 10 + running-workflow-name: 'automerge' # the name of this job + - name: Merge PR + uses: pascalgn/automerge-action@741c311a47881be9625932b0a0de1b0937aab1ae # v0.13.1 + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + MERGE_LABELS: "" + MERGE_METHOD: "squash" + MERGE_DELETE_BRANCH: true diff --git a/.github/workflows/build-and-publish-github-pages.yml b/.github/workflows/build-and-publish-github-pages.yml new file mode 100644 index 00000000..adf068d6 --- /dev/null +++ b/.github/workflows/build-and-publish-github-pages.yml @@ -0,0 +1,26 @@ +name: Build and Publish github pages +on: + push: + branches: + - master +jobs: + build-and-publish: + concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v2 + + - name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built. + run: | + npm install + npm run build + + # Deploy to gh pages branch + - name: Deploy + uses: s0/git-publish-subdir-action@399aab378450f99b7de6767f62b0d1dbfcb58b53 + env: + REPO: self + BRANCH: gh-pages + FOLDER: dist + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/js-test-and-release.yml b/.github/workflows/js-test-and-release.yml new file mode 100644 index 00000000..0611aa20 --- /dev/null +++ b/.github/workflows/js-test-and-release.yml @@ -0,0 +1,131 @@ +name: test & maybe release +on: + push: + branches: + - master # with #262 - ${{{ github.default_branch }}} + pull_request: + branches: + - master # with #262 - ${{{ github.default_branch }}} + +jobs: + + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: lts/* + - uses: ipfs/aegir/actions/cache-node-modules@master + - run: npm run --if-present lint + - run: npm run --if-present dep-check + + # test-node: + # needs: check + # runs-on: ${{ matrix.os }} + # strategy: + # matrix: + # os: [windows-latest, ubuntu-latest, macos-latest] + # node: ['lts/*'] + # fail-fast: true + # steps: + # - uses: actions/checkout@v2 + # - uses: actions/setup-node@v2 + # with: + # node-version: ${{ matrix.node }} + # - uses: ipfs/aegir/actions/cache-node-modules@master + # - run: npm run --if-present test:node + # - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + # with: + # directory: ./.nyc_output + # flags: node + + # test-chrome: + # needs: check + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # - uses: actions/setup-node@v2 + # with: + # node-version: lts/* + # - uses: ipfs/aegir/actions/cache-node-modules@master + # - run: npm run --if-present test:chrome + # - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + # with: + # directory: ./.nyc_output + # flags: chrome + + # test-chrome-webworker: + # needs: check + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # - uses: actions/setup-node@v2 + # with: + # node-version: lts/* + # - uses: ipfs/aegir/actions/cache-node-modules@master + # - run: npm run --if-present test:chrome-webworker + # - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + # with: + # directory: ./.nyc_output + # flags: chrome-webworker + + # test-firefox: + # needs: check + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # - uses: actions/setup-node@v2 + # with: + # node-version: lts/* + # - uses: ipfs/aegir/actions/cache-node-modules@master + # - run: npm run --if-present test:firefox + # - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + # with: + # directory: ./.nyc_output + # flags: firefox + + # test-firefox-webworker: + # needs: check + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # - uses: actions/setup-node@v2 + # with: + # node-version: lts/* + # - uses: ipfs/aegir/actions/cache-node-modules@master + # - run: npm run --if-present test:firefox-webworker + # - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + # with: + # directory: ./.nyc_output + # flags: firefox-webworker + + # test-electron-main: + # needs: check + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # - uses: actions/setup-node@v2 + # with: + # node-version: lts/* + # - uses: ipfs/aegir/actions/cache-node-modules@master + # - run: npx xvfb-maybe npm run --if-present test:electron-main + # - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + # with: + # directory: ./.nyc_output + # flags: electron-main + + # test-electron-renderer: + # needs: check + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # - uses: actions/setup-node@v2 + # with: + # node-version: lts/* + # - uses: ipfs/aegir/actions/cache-node-modules@master + # - run: npx xvfb-maybe npm run --if-present test:electron-renderer + # - uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # v2.1.0 + # with: + # directory: ./.nyc_output + # flags: electron-renderer diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..56cc26d6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,237 @@ + +# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,windows,linux,node +# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,macos,windows,linux,node + +### Linux ### +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Node ### +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* + +### Node Patch ### +# Serverless Webpack directories +.webpack/ + +# Optional stylelint cache + +# SvelteKit build / generate output +.svelte-kit + +### VisualStudioCode ### +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +### VisualStudioCode Patch ### +# Ignore all local history of files +.history +.ionide + +# Support for Project snippet scope + +### Windows ### +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos,windows,linux,node +.envrc diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..f461b68f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "editor.tabSize": 2, + "typescript.format.semicolons": "remove", + "javascript.format.semicolons": "remove", + "typescript.suggest.includeAutomaticOptionalChainCompletions": true, + "editor.formatOnSave": true, + "eslint.codeActionsOnSave.rules": [], + "files.exclude": { + "package-lock.json": true + } +} diff --git a/LICENSE b/LICENSE index 2606d37a..20ce483c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,4 @@ -MIT License +This project is dual licensed under MIT and Apache-2.0. -Copyright (c) 2017 IPFS - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +MIT: https://www.opensource.org/licenses/mit +Apache-2.0: https://www.apache.org/licenses/license-2.0 diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 00000000..14478a3b --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,5 @@ +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 00000000..72dc60d8 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 700eeade..527a3ac1 100644 --- a/README.md +++ b/README.md @@ -6,27 +6,26 @@ View the Public Gateway Checker on GitHub Pages: https://ipfs.github.io/public-g [![Screenshot of Public Gateway Checker](https://user-images.githubusercontent.com/157609/121263486-f7fb2800-c8b5-11eb-9061-0b6f586a6f25.png)](https://ipfs.github.io/public-gateway-checker/) - ## SECURITY NOTES -- The list contains gateways operated by various parties, coordinated by loose mutual consensus, without a central governing authority. Protocol Labs operates and is responsible for only two of the listed gateways: `ipfs.io` and `dweb.link`. -- Gateways without origin isolation will be marked with ⚠️, indicating they are not safe for use cases that require private local storage of data or credentials. [Learn more](https://github.com/ipfs/public-gateway-checker/issues/150). - +- The list contains gateways operated by various parties, coordinated by loose mutual consensus, without a central governing authority. Protocol Labs operates and is responsible for only two of the listed gateways: `ipfs.io` and `dweb.link`. +- Gateways without origin isolation will be marked with ⚠️, indicating they are not safe for use cases that require private local storage of data or credentials. [Learn more](https://github.com/ipfs/public-gateway-checker/issues/150). ## Adding a new public gateway If you'd like to add a new public gateway, please edit `gateways.json`: + 1. Add the gateway's address to the bottom of the list 2. Make sure the final item in the list does **not** have a comma at the end, but all preceding items do -3. If you care about security of websites loaded via your gateway, make sure it is set up as a [subdomain gateway](https://docs.ipfs.io/how-to/address-ipfs-on-web/#subdomain-gateway). See [config docs](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#gatewaypublicgateways) and [recipes](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#gateway-recipes) for go-ipfs, and [learn more here](https://github.com/ipfs/public-gateway-checker/issues/150). +3. If you care about security of websites loaded via your gateway, make sure it is set up as a [subdomain gateway](https://docs.ipfs.io/how-to/address-ipfs-on-web/#subdomain-gateway). See [config docs](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#gatewaypublicgateways) and [recipes](https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#gateway-recipes) for go-ipfs, and [learn more here](https://github.com/ipfs/public-gateway-checker/issues/150). Then, submit a pull request for this change. Be sure to follow all the directions in the pull request template so your PR can be triaged as quickly as possible. - ## Testing locally -```console -$ npx serve -l 3000 +```bash +npm run build +npm start ``` ## Command line diff --git a/app.js b/app.js deleted file mode 100644 index edded7fb..00000000 --- a/app.js +++ /dev/null @@ -1,413 +0,0 @@ -/* - This program will check IPFS gateways status using 3 methods - 1) By asking for a script through a + @@ -50,15 +53,16 @@

Public Gateways

-
-
Online
- - - +
+
Online
+ + +
Country
+
ΔT
- + diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 00000000..eeb1dd05 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,13 @@ +import { Checker } from './Checker' +import gateways from './gateways.json' + +import { Log } from './Log' + +const log = new Log('App index') + +window.checker = new Checker() + +window.checker.checkGateways(gateways).catch((err) => { + log.error('Unexpected error') + log.error(err) +}) diff --git a/src/ipfsHttpClient.ts b/src/ipfsHttpClient.ts new file mode 100644 index 00000000..591cd90c --- /dev/null +++ b/src/ipfsHttpClient.ts @@ -0,0 +1,8 @@ +const ipfsHttpClient = window.IpfsHttpClient({ + host: 'ipfs.io', + port: 443, + protocol: 'https' +}) +window.client = ipfsHttpClient + +export { ipfsHttpClient } diff --git a/styles.css b/src/styles.css similarity index 91% rename from styles.css rename to src/styles.css index 08fe8e81..795d8289 100644 --- a/styles.css +++ b/src/styles.css @@ -55,7 +55,7 @@ div.Node:hover { div.Node div.Link { width: 100%; text-align: left; - padding-left: 1em; + padding-left: 2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; @@ -69,7 +69,8 @@ div.Node a, div#origin-warning a { div.Node div.Status, div.Node div.Cors, -div.Node div.Origin { +div.Node div.Origin, +div.Node div.Flag { width: 5em; text-align: center; margin: 0 0.5em; @@ -77,11 +78,12 @@ div.Node div.Origin { } div.Node div.Flag { - width: 2em; + /* width: 2em; */ height: 1em; background-repeat: no-repeat; background-size: contain; background-position: center; + display: inline-block } div.Node div.Took { @@ -115,3 +117,8 @@ div#origin-warning p { div#origin-warning ol, div#origin-warning p, div#origin-warning ul { line-height: 1.7; } + + +div#checker\.results .Node:nth-child(1) .Link { + padding-left: 1em; +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..2638dabf --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "aegir/src/config/tsconfig.aegir.json", + "compilerOptions": { + "outDir": "dist", + "paths": { + "*": [ + "./types/*" + ] + } + }, + "include": [ + "types", + "test", // remove this line if you don't want to type-check tests + "src", + "src/gateways.json" + ] +}