diff --git a/ui/desktop/CHANGELOG.md b/ui/desktop/CHANGELOG.md index 1627a2137..cee2b0afe 100644 --- a/ui/desktop/CHANGELOG.md +++ b/ui/desktop/CHANGELOG.md @@ -3,6 +3,12 @@ Canonical reference for changes, improvements, and bugfixes for Boundary Desktop. +## Next + +### Changes/Deprecations + +- Boundary origin validation now occurs via Electron's built-in net request module, ensuring the validation request is made via chromium's networking library rather than Node's. ([PR](https://github.com/hashicorp/boundary-ui/pull/480)) + ## v1.0.0-alpha (2021.02.16) v1.0.0-alpha is the first release of Boundary Desktop. As a result there are no changes, improvements, or bugfixes from past versions. diff --git a/ui/desktop/electron-app/package.json b/ui/desktop/electron-app/package.json index 69caf84b0..931719eb8 100644 --- a/ui/desktop/electron-app/package.json +++ b/ui/desktop/electron-app/package.json @@ -21,7 +21,6 @@ "forge": "config/forge.config.js" }, "dependencies": { - "axios": "^0.21.1", "electron-devtools-installer": "^3.1.1", "electron-is-dev": "^1.2.0", "electron-squirrel-startup": "^1.0.0", diff --git a/ui/desktop/electron-app/src/origin.js b/ui/desktop/electron-app/src/origin.js index 7d85e4466..cdb640cd2 100644 --- a/ui/desktop/electron-app/src/origin.js +++ b/ui/desktop/electron-app/src/origin.js @@ -1,4 +1,27 @@ -const axios = require('axios'); +const { net } = require('electron') + +const requestTimeoutSeconds = 10; +// Simple promise wrapper around Electron's net.request feature. +// https://www.electronjs.org/docs/api/client-request +const netRequestPromise = url => new Promise((resolve, reject) => { + try { + const request = net.request(url); + // We don't worry about canceling the request timeout timer once a + // request ends because: request.abort() has no effect after a request + // ends and the promise will already have been completed, so a rejection + // has no effect either. + const requestTimeout = + setTimeout(() => { + request.abort(); + reject(new Error('Request timeout')); + }, requestTimeoutSeconds * 1000); + request.on('error', reject); + request.on('response', resolve); + request.end(); + } catch (e) { + reject(e); + } +}); // Provides a singleton class instance to enable a consistent view of // runtime settings across the application. @@ -34,7 +57,7 @@ class RuntimeSettings { // test to see if the origin is API-compatible with the desktop client. const scopesEndpoint = `${origin}/v1/scopes`; try { - await axios.get(scopesEndpoint) + await netRequestPromise(scopesEndpoint); } catch (e) { throw new Error(`Origin ${origin} could not be validated.`); } diff --git a/ui/desktop/electron-app/yarn.lock b/ui/desktop/electron-app/yarn.lock index f885d02d3..b33789d73 100644 --- a/ui/desktop/electron-app/yarn.lock +++ b/ui/desktop/electron-app/yarn.lock @@ -494,13 +494,6 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== -axios@^0.21.1: - version "0.21.1" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" - integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA== - dependencies: - follow-redirects "^1.10.0" - balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" @@ -1335,11 +1328,6 @@ fmix@^0.1.0: dependencies: imul "^1.0.0" -follow-redirects@^1.10.0: - version "1.13.1" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.1.tgz#5f69b813376cee4fd0474a3aba835df04ab763b7" - integrity sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg== - forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"