From 53500467c129d22a27a6cec07d7975c6a9911af6 Mon Sep 17 00:00:00 2001 From: yedidya rashi Date: Thu, 3 Feb 2022 18:19:35 +0200 Subject: [PATCH 01/29] feat(showPassword): add password show/hide functionality --- .../setup/components/UnlockAllArchivesPage.js | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/source/setup/components/UnlockAllArchivesPage.js b/source/setup/components/UnlockAllArchivesPage.js index 1af612e6..a26f0a20 100644 --- a/source/setup/components/UnlockAllArchivesPage.js +++ b/source/setup/components/UnlockAllArchivesPage.js @@ -69,7 +69,8 @@ class UnlockAllArchivesPage extends Component { state = { masterPasswords: {}, - unlocking: [] + unlocking: [], + showPassword: false }; componentDidMount() { @@ -132,6 +133,21 @@ class UnlockAllArchivesPage extends Component { render() { const firstLockedIndex = this.props.archives.findIndex(archive => archive.state === "locked"); + const lockButton = ( + - - - - - - - - - - - - ); return ( - + + + {this.props.archiveTitle} + + + + + + + + + + + + + + this.handlePasswordChangeSubmit(event)} disabled={disableForm || !this.passwordChangeValid} > Change Password @@ -199,7 +221,7 @@ class VaultPage extends PureComponent { } zIndex={2} > -
+ this.handlePasswordChangeSubmit(event)}> Date: Thu, 26 May 2022 12:33:49 +0300 Subject: [PATCH 09/29] Upgrade dropbox client --- package-lock.json | 160 ++++++++++++++++++++------------ package.json | 5 +- source/setup/library/dropbox.js | 16 +--- source/setup/library/remote.js | 28 +++--- 4 files changed, 116 insertions(+), 93 deletions(-) diff --git a/package-lock.json b/package-lock.json index 499a8fc0..803dbd11 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@blueprintjs/icons": "^4.2.5", "@buttercup/channel-queue": "^0.4.0", "@buttercup/config": "^0.1.0", - "@buttercup/dropbox-client": "^0.8.1", + "@buttercup/dropbox-client": "^1.0.0", "@buttercup/google-oauth2-client": "^1.0.0", "@buttercup/googledrive-client": "^1.3.3", "@buttercup/locust": "^0.10.0", @@ -27,7 +27,7 @@ "babel-loader": "^8.2.5", "babel-plugin-jsx-control-statements": "^4.1.2", "browser-info": "^1.2.0", - "buttercup": "^6.13.1", + "buttercup": "^6.14.0", "classnames": "^2.2.6", "color": "^3.1.2", "concurrently": "^4.1.0", @@ -58,7 +58,6 @@ "object-hash": "^1.3.0", "path-posix": "^1.0.0", "path.join": "^1.0.0", - "pify": "^5.0.0", "post-robot": "^8.0.28", "prettier": "^1.19.1", "prettier-check": "^2.0.0", @@ -1792,9 +1791,9 @@ "dev": true }, "node_modules/@buttercup/dropbox-client": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@buttercup/dropbox-client/-/dropbox-client-0.8.1.tgz", - "integrity": "sha512-PQ7aG9i9fSXY5IM8a9Hfa3tZKTfLaGRW9xoVw4AkJbQlXa+ssCH4BW60Opu8eWIdZpw8pMgVNz1ixDTRR1+tww==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@buttercup/dropbox-client/-/dropbox-client-1.0.0.tgz", + "integrity": "sha512-5Ap2kBP0AWbHdmSEA4T6/f/jkVWWeQ9AFt/FoXgHzjDBlFT7GTBVFMQXcG5Iz9Kvg4cjT/AAMeoBZ3uYe9QfiA==", "dev": true, "dependencies": { "cowl": "^1.1.0", @@ -3515,12 +3514,27 @@ "dev": true }, "node_modules/axios": { - "version": "0.26.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", - "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", "dev": true, "dependencies": { - "follow-redirects": "^1.14.8" + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" } }, "node_modules/babel-loader": { @@ -4155,13 +4169,13 @@ } }, "node_modules/buttercup": { - "version": "6.13.1", - "resolved": "https://registry.npmjs.org/buttercup/-/buttercup-6.13.1.tgz", - "integrity": "sha512-YM5v2BF969xt3JQb+0NMdYl7i7Zh4/h2NQvaEoFASe+J92RJlQeEZJL2UVnMkt8ipfLXq4uMpR//5DKSNb5CzQ==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/buttercup/-/buttercup-6.14.0.tgz", + "integrity": "sha512-YYJ9Z+Yu5c3O7STV1/ksjn35aUTFDVSmrZm8W7uUPOz7up+LjsNLF4PAEYF0b73nWExgT2m/jxaag9XqHEWZ9Q==", "dev": true, "dependencies": { - "@buttercup/channel-queue": "^1.0.1", - "@buttercup/dropbox-client": "^0.8.1", + "@buttercup/channel-queue": "^1.2.0", + "@buttercup/dropbox-client": "^1.0.0", "@buttercup/googledrive-client": "^1.3.3", "cowl": "^1.1.0", "crypto-random-string": "^3.3.1", @@ -4169,7 +4183,7 @@ "fast-levenshtein": "^3.0.0", "foreachasync": "^5.1.3", "form-data": "^4.0.0", - "fuse.js": "^6.4.6", + "fuse.js": "^6.6.2", "global": "^4.4.0", "hash.js": "^1.1.7", "iocane": "^5.1.1", @@ -4180,7 +4194,7 @@ "pify": "^5.0.0", "url-join": "^4.0.1", "uuid": "^8.3.2", - "webdav": "^4.7.0" + "webdav": "^4.10.0" }, "engines": { "node": ">=12" @@ -4232,9 +4246,9 @@ } }, "node_modules/buttercup/node_modules/fuse.js": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-6.5.3.tgz", - "integrity": "sha512-sA5etGE7yD/pOqivZRBvUBd/NaL2sjAu6QuSaFoe1H2BrJSkH/T/UXAJ8CdXdw7DvY3Hs8CXKYkDWX7RiP5KOg==", + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-6.6.2.tgz", + "integrity": "sha512-cJaJkxCCxC8qIIcPBF9yGxY0W/tVZS3uEISDxhYIdtk8OL93pe+6Zj7LjCqVV4dzbqcriOZ+kQ/NE4RXZHsIGA==", "dev": true, "engines": { "node": ">=10" @@ -4255,6 +4269,12 @@ "uuid": "dist/bin/uuid" } }, + "node_modules/byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/byte-length/-/byte-length-1.0.2.tgz", + "integrity": "sha512-ovBpjmsgd/teRmgcPh23d4gJvxDoXtAzEL9xTfMU8Yc2kqCDb7L9jAG0XHl1nzuGl+h3ebCIF1i62UFyA9V/2Q==", + "dev": true + }, "node_modules/bytes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", @@ -4525,7 +4545,7 @@ "node_modules/charenc": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", - "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", "dev": true, "engines": { "node": "*" @@ -8949,9 +8969,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.14.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", - "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz", + "integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==", "dev": true, "funding": [ { @@ -19339,13 +19359,14 @@ } }, "node_modules/webdav": { - "version": "4.9.0", - "resolved": "https://registry.npmjs.org/webdav/-/webdav-4.9.0.tgz", - "integrity": "sha512-pMuRtZcjBk3i6q1iY5wBHdablKftoBfhrQEWWEejSh2LXgd0J6VE5V0c1tUlMrFHaVDx8iCoB9kupNzy8SMC4A==", + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/webdav/-/webdav-4.10.0.tgz", + "integrity": "sha512-8PevPYhFsgbDhVGQQyrfBDYHiCYtN01qVX9zjFDA/OjIFqu28SsZuZdvGxBIQu2/e3Wp8M5oUpYvLM3uLP8g6A==", "dev": true, "dependencies": { - "axios": "^0.26.1", + "axios": "^0.27.2", "base-64": "^1.0.0", + "byte-length": "^1.0.2", "fast-xml-parser": "^3.19.0", "he": "^1.2.0", "hot-patcher": "^0.5.0", @@ -19371,9 +19392,9 @@ } }, "node_modules/webdav/node_modules/minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", "dev": true, "dependencies": { "brace-expansion": "^2.0.1" @@ -21458,9 +21479,9 @@ } }, "@buttercup/dropbox-client": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@buttercup/dropbox-client/-/dropbox-client-0.8.1.tgz", - "integrity": "sha512-PQ7aG9i9fSXY5IM8a9Hfa3tZKTfLaGRW9xoVw4AkJbQlXa+ssCH4BW60Opu8eWIdZpw8pMgVNz1ixDTRR1+tww==", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@buttercup/dropbox-client/-/dropbox-client-1.0.0.tgz", + "integrity": "sha512-5Ap2kBP0AWbHdmSEA4T6/f/jkVWWeQ9AFt/FoXgHzjDBlFT7GTBVFMQXcG5Iz9Kvg4cjT/AAMeoBZ3uYe9QfiA==", "dev": true, "requires": { "cowl": "^1.1.0", @@ -22873,12 +22894,26 @@ "dev": true }, "axios": { - "version": "0.26.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", - "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", "dev": true, "requires": { - "follow-redirects": "^1.14.8" + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + }, + "dependencies": { + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } } }, "babel-loader": { @@ -23380,13 +23415,13 @@ } }, "buttercup": { - "version": "6.13.1", - "resolved": "https://registry.npmjs.org/buttercup/-/buttercup-6.13.1.tgz", - "integrity": "sha512-YM5v2BF969xt3JQb+0NMdYl7i7Zh4/h2NQvaEoFASe+J92RJlQeEZJL2UVnMkt8ipfLXq4uMpR//5DKSNb5CzQ==", + "version": "6.14.0", + "resolved": "https://registry.npmjs.org/buttercup/-/buttercup-6.14.0.tgz", + "integrity": "sha512-YYJ9Z+Yu5c3O7STV1/ksjn35aUTFDVSmrZm8W7uUPOz7up+LjsNLF4PAEYF0b73nWExgT2m/jxaag9XqHEWZ9Q==", "dev": true, "requires": { - "@buttercup/channel-queue": "^1.0.1", - "@buttercup/dropbox-client": "^0.8.1", + "@buttercup/channel-queue": "^1.2.0", + "@buttercup/dropbox-client": "^1.0.0", "@buttercup/googledrive-client": "^1.3.3", "cowl": "^1.1.0", "crypto-random-string": "^3.3.1", @@ -23394,7 +23429,7 @@ "fast-levenshtein": "^3.0.0", "foreachasync": "^5.1.3", "form-data": "^4.0.0", - "fuse.js": "^6.4.6", + "fuse.js": "^6.6.2", "global": "^4.4.0", "hash.js": "^1.1.7", "iocane": "^5.1.1", @@ -23405,7 +23440,7 @@ "pify": "^5.0.0", "url-join": "^4.0.1", "uuid": "^8.3.2", - "webdav": "^4.7.0" + "webdav": "^4.10.0" }, "dependencies": { "@buttercup/channel-queue": { @@ -23448,9 +23483,9 @@ } }, "fuse.js": { - "version": "6.5.3", - "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-6.5.3.tgz", - "integrity": "sha512-sA5etGE7yD/pOqivZRBvUBd/NaL2sjAu6QuSaFoe1H2BrJSkH/T/UXAJ8CdXdw7DvY3Hs8CXKYkDWX7RiP5KOg==", + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-6.6.2.tgz", + "integrity": "sha512-cJaJkxCCxC8qIIcPBF9yGxY0W/tVZS3uEISDxhYIdtk8OL93pe+6Zj7LjCqVV4dzbqcriOZ+kQ/NE4RXZHsIGA==", "dev": true }, "is-promise": { @@ -23467,6 +23502,12 @@ } } }, + "byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/byte-length/-/byte-length-1.0.2.tgz", + "integrity": "sha512-ovBpjmsgd/teRmgcPh23d4gJvxDoXtAzEL9xTfMU8Yc2kqCDb7L9jAG0XHl1nzuGl+h3ebCIF1i62UFyA9V/2Q==", + "dev": true + }, "bytes": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", @@ -23695,7 +23736,7 @@ "charenc": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", - "integrity": "sha1-wKHS86cJLgN3S/qD8UwPxXkKhmc=", + "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", "dev": true }, "cheerio": { @@ -27298,9 +27339,9 @@ "dev": true }, "follow-redirects": { - "version": "1.14.9", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", - "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.0.tgz", + "integrity": "sha512-aExlJShTV4qOUOL7yF1U5tvLCB0xQuudbf6toyYA0E/acBNw71mvjFTnLaRp50aQaYocMR0a/RMMBIHeZnGyjQ==", "dev": true }, "for-in": { @@ -35545,13 +35586,14 @@ } }, "webdav": { - "version": "4.9.0", - "resolved": "https://registry.npmjs.org/webdav/-/webdav-4.9.0.tgz", - "integrity": "sha512-pMuRtZcjBk3i6q1iY5wBHdablKftoBfhrQEWWEejSh2LXgd0J6VE5V0c1tUlMrFHaVDx8iCoB9kupNzy8SMC4A==", + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/webdav/-/webdav-4.10.0.tgz", + "integrity": "sha512-8PevPYhFsgbDhVGQQyrfBDYHiCYtN01qVX9zjFDA/OjIFqu28SsZuZdvGxBIQu2/e3Wp8M5oUpYvLM3uLP8g6A==", "dev": true, "requires": { - "axios": "^0.26.1", + "axios": "^0.27.2", "base-64": "^1.0.0", + "byte-length": "^1.0.2", "fast-xml-parser": "^3.19.0", "he": "^1.2.0", "hot-patcher": "^0.5.0", @@ -35574,9 +35616,9 @@ } }, "minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.0.tgz", + "integrity": "sha512-9TPBGGak4nHfGZsPBohm9AWg6NoT7QTCehS3BIJABslyZbzxfV78QM2Y6+i741OPZIafFAaiiEMh5OyIrJPgtg==", "dev": true, "requires": { "brace-expansion": "^2.0.1" diff --git a/package.json b/package.json index b6c61387..8d2f12f8 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "@blueprintjs/icons": "^4.2.5", "@buttercup/channel-queue": "^0.4.0", "@buttercup/config": "^0.1.0", - "@buttercup/dropbox-client": "^0.8.1", + "@buttercup/dropbox-client": "^1.0.0", "@buttercup/google-oauth2-client": "^1.0.0", "@buttercup/googledrive-client": "^1.3.3", "@buttercup/locust": "^0.10.0", @@ -67,7 +67,7 @@ "babel-loader": "^8.2.5", "babel-plugin-jsx-control-statements": "^4.1.2", "browser-info": "^1.2.0", - "buttercup": "^6.13.1", + "buttercup": "^6.14.0", "classnames": "^2.2.6", "color": "^3.1.2", "concurrently": "^4.1.0", @@ -98,7 +98,6 @@ "object-hash": "^1.3.0", "path-posix": "^1.0.0", "path.join": "^1.0.0", - "pify": "^5.0.0", "post-robot": "^8.0.28", "prettier": "^1.19.1", "prettier-check": "^2.0.0", diff --git a/source/setup/library/dropbox.js b/source/setup/library/dropbox.js index f3917b19..79accc8c 100644 --- a/source/setup/library/dropbox.js +++ b/source/setup/library/dropbox.js @@ -1,11 +1,9 @@ import { basename } from "path-posix"; -import Dropbox from "dropbox"; +import { generateAuthorisationURL } from "@buttercup/dropbox-client"; const DROPBOX_CALLBACK_URL = "https://buttercup.pw/"; const DROPBOX_CLIENT_ID = "5fstmwjaisrt06t"; -let __client; - export function dropboxContentsToTree(allItems) { const itemToFile = item => ({ path: item.filename, @@ -33,17 +31,7 @@ export function dropboxContentsToTree(allItems) { return buildItem("/", allItems["/"]); } -export function getClient() { - if (!__client) { - __client = new Dropbox({ - clientId: DROPBOX_CLIENT_ID - }); - } - return __client; -} - export function performAuthentication() { - const client = getClient(); - const url = client.getAuthenticationUrl(DROPBOX_CALLBACK_URL); + const url = generateAuthorisationURL(DROPBOX_CLIENT_ID, DROPBOX_CALLBACK_URL); chrome.tabs.create({ url }); } diff --git a/source/setup/library/remote.js b/source/setup/library/remote.js index 0435c9d6..dd69b42c 100644 --- a/source/setup/library/remote.js +++ b/source/setup/library/remote.js @@ -1,9 +1,5 @@ -import { - createClient as createDropboxClient, - createFsInterface as createDropboxFSClient -} from "@buttercup/dropbox-client"; +import { DropboxClient } from "@buttercup/dropbox-client"; import { createClient as createGoogleDriveClient } from "@buttercup/googledrive-client"; -import pify from "pify"; import { getSharedAppEnv } from "../../shared/library/buttercup.js"; import log from "../../shared/library/log.js"; import { getState } from "../redux/index.js"; @@ -33,7 +29,7 @@ export function disposeWebDAVConnection() { __webdavClient = null; } -function getDropboxFSClient() { +function getDropboxClient() { if (!__dropboxClient) { const state = getState(); const authToken = getDropboxAuthToken(state); @@ -41,21 +37,19 @@ function getDropboxFSClient() { log.error("Unable to create Dropbox client: No token found"); return; } - __dropboxClient = createDropboxFSClient(createDropboxClient(authToken)); + __dropboxClient = new DropboxClient(authToken); } return __dropboxClient; } -export function getDropboxDirectoryContents(directory, dropboxClient = getDropboxFSClient()) { - const readDir = pify(::dropboxClient.readdir); - return readDir(directory, { mode: "stat" }).then(contents => - contents.map(item => ({ - filename: item.path, - basename: item.name, - type: item.type, - size: item.isDirectory() ? 0 : item.size - })) - ); +export async function getDropboxDirectoryContents(directory, dropboxClient = getDropboxClient()) { + const contents = await dropboxClient.getDirectoryContents(directory); + return contents.map(item => ({ + filename: item.path, + basename: item.name, + type: item.type, + size: item.size + })); } function getGoogleDriveClient() { From 4edc9fbed7eed58ce64f412493e8d6cdc3348cb1 Mon Sep 17 00:00:00 2001 From: Perry Mitchell Date: Thu, 26 May 2022 12:56:33 +0300 Subject: [PATCH 10/29] Remove my buttercup addition --- source/setup/components/AddArchivePage.js | 22 +++++++++++----------- source/shared/library/icons.js | 19 ++++++++----------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/source/setup/components/AddArchivePage.js b/source/setup/components/AddArchivePage.js index 0f142f51..bea889de 100644 --- a/source/setup/components/AddArchivePage.js +++ b/source/setup/components/AddArchivePage.js @@ -232,11 +232,11 @@ class AddArchivePage extends PureComponent { const { selectedFilename } = this.props; const disabled = !selectedFilename; const onClickTypeSwitch = switchValue([ - [/webdav|owncloud|nextcloud/, ::this.handleChooseWebDAVBasedFile], - ["dropbox", ::this.handleChooseDropboxBasedFile], - ["googledrive", ::this.handleChooseGoogleDriveBasedFile], - ["mybuttercup", ::this.handleChooseMyButtercupBasedFile], - ["localfile", ::this.handleChooseLocalBasedFile] + [/webdav|owncloud|nextcloud/, evt => this.handleChooseWebDAVBasedFile(evt)], + ["dropbox", evt => this.handleChooseDropboxBasedFile(evt)], + ["googledrive", evt => this.handleChooseGoogleDriveBasedFile(evt)], + ["mybuttercup", evt => this.handleChooseMyButtercupBasedFile(evt)], + ["localfile", evt => this.handleChooseLocalBasedFile(evt)] ]); const handleSubmit = onClickTypeSwitch(this.props.selectedArchiveType); return ( @@ -324,7 +324,7 @@ class AddArchivePage extends PureComponent { - - - - - - + + + + + + + + +
From b030f7768fbf100e000f95c929297261acb2614f Mon Sep 17 00:00:00 2001 From: Perry Mitchell Date: Sun, 29 May 2022 22:04:45 +0300 Subject: [PATCH 12/29] Fix tab script --- package.json | 1 + resources/manifest.json | 3 +-- webpack.config.js | 41 +++++++++++++++++++++-------------------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 8d2f12f8..083c143a 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "build:production": "env-cmd -e production webpack --mode production --progress", "clean": "rimraf dist/* release/*", "dev": "npm run clean && env-cmd -e development webpack --mode development -w", + "dev:chrome": "concurrently -k \"npm run dev\"", "dev:firefox": "concurrently -k \"npm run dev\" \"cd dist && web-ext run\" --restart-tries 20 --restart-after 5000", "dev:prod": "env-cmd -e production webpack --mode production -w --progress", "format": "prettier --write '{{source,test}/**/*.js,webpack.config.js}'", diff --git a/resources/manifest.json b/resources/manifest.json index d13cb64a..b478af61 100644 --- a/resources/manifest.json +++ b/resources/manifest.json @@ -25,8 +25,6 @@ "background": { "scripts": [ - "vendors.js", - "common.js", "background.js" ] }, @@ -62,6 +60,7 @@ "web_accessible_resources": [ "dialog.html", "resources/*", + "assets/*", "setup.html" ] } diff --git a/webpack.config.js b/webpack.config.js index 74db9a15..39d05eee 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -79,29 +79,30 @@ module.exports = { ] }, - optimization: { - splitChunks: { - automaticNameDelimiter: "-", - cacheGroups: { - vendors: { - test: /\/node_modules\//, - name: "vendors", - priority: -10, - chunks: "initial" - }, - default: { - priority: -20, - chunks: "initial", - reuseExistingChunk: true, - name: "common" - } - } - } - }, + // optimization: { + // splitChunks: { + // automaticNameDelimiter: "-", + // cacheGroups: { + // vendors: { + // test: /\/node_modules\//, + // name: "vendors", + // priority: -10, + // chunks: "initial" + // }, + // default: { + // priority: -20, + // chunks: "initial", + // reuseExistingChunk: true, + // name: "common" + // } + // } + // } + // }, output: { filename: "[name].js", - path: DIST + path: DIST, + publicPath: "" }, plugins: [ From 81f9333799ae41c2223612d5917216942b0c38a8 Mon Sep 17 00:00:00 2001 From: Perry Mitchell Date: Mon, 30 May 2022 22:14:07 +0300 Subject: [PATCH 13/29] Update webpack setup --- package-lock.json | 1 + package.json | 1 + resources/manifest.json | 3 +- webpack.config.js | 284 ++++++++++++++++++++++------------------ 4 files changed, 161 insertions(+), 128 deletions(-) diff --git a/package-lock.json b/package-lock.json index 803dbd11..b5871855 100644 --- a/package-lock.json +++ b/package-lock.json @@ -90,6 +90,7 @@ "web-ext": "^4.3.0", "webpack": "^5.72.0", "webpack-cli": "^4.9.2", + "webpack-merge": "^5.8.0", "yoctodelay": "^1.1.0" } }, diff --git a/package.json b/package.json index 083c143a..3303724f 100644 --- a/package.json +++ b/package.json @@ -131,6 +131,7 @@ "web-ext": "^4.3.0", "webpack": "^5.72.0", "webpack-cli": "^4.9.2", + "webpack-merge": "^5.8.0", "yoctodelay": "^1.1.0" } } diff --git a/resources/manifest.json b/resources/manifest.json index b478af61..3f0acf38 100644 --- a/resources/manifest.json +++ b/resources/manifest.json @@ -25,6 +25,7 @@ "background": { "scripts": [ + "background-vendors.js", "background.js" ] }, @@ -33,7 +34,7 @@ { "matches": ["http://*/*", "https://*/*"], "run_at": "document_end", - "js": ["tab.js"] + "js": ["vendors.js", "tab.js"] } ], diff --git a/webpack.config.js b/webpack.config.js index 39d05eee..99519d36 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,18 +1,17 @@ const path = require("path"); const fs = require("fs"); const { DefinePlugin, NormalModuleReplacementPlugin } = require("webpack"); +const { merge } = require("webpack-merge"); const CopyWebpackPlugin = require("copy-webpack-plugin"); const HtmlWebpackPlugin = require("html-webpack-plugin"); const MiniCSSExtractPlugin = require("mini-css-extract-plugin"); -const { devDependencies, version } = require("./package.json"); +const { version } = require("./package.json"); const manifest = require("./resources/manifest.json"); const CHANGELOG = path.resolve(__dirname, "./CHANGELOG.md"); const DIST = path.resolve(__dirname, "./dist"); const ICONS_PATH = path.join(path.dirname(require.resolve("@buttercup/ui")), "icons"); const INDEX_TEMPLATE = path.resolve(__dirname, "./resources/template.pug"); -const REACT_PACKAGES = Object.keys(devDependencies).filter(name => /^react(-|$)/.test(name)); -const REDUX_PACKAGES = Object.keys(devDependencies).filter(name => /^redux(-|$)/.test(name)); const SOURCE = path.resolve(__dirname, "./source"); const __configDefines = Object.keys(process.env).reduce((output, key) => { @@ -40,138 +39,169 @@ function buildManifest(assetNames) { fs.writeFileSync(path.join(DIST, "./manifest.json"), JSON.stringify(newManifest, undefined, 2)); } -module.exports = { - devtool: false, +function getBaseConfig() { + return { + devtool: false, - entry: { - background: path.join(SOURCE, "./background/index.js"), - dialog: path.join(SOURCE, "./dialog/index.js"), - popup: path.join(SOURCE, "./popup/index.js"), - setup: path.join(SOURCE, "./setup/index.js"), - tab: path.join(SOURCE, "./tab/index.js") - }, - - module: { - rules: [ - { - test: /\.js$/, - use: "babel-loader" - }, - { - test: /\.s[ac]ss$/, - use: [MiniCSSExtractPlugin.loader, "css-loader", "sass-loader"] - }, - { - test: /\.css$/, - use: [MiniCSSExtractPlugin.loader, "css-loader"] - }, - { - test: /\.pug$/, - use: "pug-loader" - }, - { - test: /\.(jpg|png|svg|eot|svg|ttf|woff|woff2)$/, - type: "asset/resource", - generator: { - filename: "assets/[name][ext]" - } - } - ] - }, - - // optimization: { - // splitChunks: { - // automaticNameDelimiter: "-", - // cacheGroups: { - // vendors: { - // test: /\/node_modules\//, - // name: "vendors", - // priority: -10, - // chunks: "initial" - // }, - // default: { - // priority: -20, - // chunks: "initial", - // reuseExistingChunk: true, - // name: "common" - // } - // } - // } - // }, - - output: { - filename: "[name].js", - path: DIST, - publicPath: "" - }, - - plugins: [ - new MiniCSSExtractPlugin(), - { - apply: compiler => { - compiler.hooks.afterEmit.tap("AfterEmitPlugin", compilation => { - buildManifest(Object.keys(compilation.getStats().compilation.assets)); - }); - } - }, - new CopyWebpackPlugin({ - patterns: [ + module: { + rules: [ { - from: CHANGELOG + test: /\.js$/, + use: "babel-loader" }, { - from: path.join(__dirname, "./resources", "buttercup-*.png") + test: /\.s[ac]ss$/, + use: [MiniCSSExtractPlugin.loader, "css-loader", "sass-loader"] }, { - from: ICONS_PATH, - to: "icons" + test: /\.css$/, + use: [MiniCSSExtractPlugin.loader, "css-loader"] + }, + { + test: /\.pug$/, + use: "pug-loader" + }, + { + test: /\.(jpg|png|svg|eot|svg|ttf|woff|woff2)$/, + type: "asset/resource", + generator: { + filename: "assets/[name][ext]" + } } ] - }), - new DefinePlugin(__configDefines), - new DefinePlugin({ - __VERSION__: JSON.stringify(version) - }), - new HtmlWebpackPlugin({ - title: "Buttercup", - template: INDEX_TEMPLATE, - filename: "popup.html", - inject: "body", - chunks: ["popup"] - }), - new HtmlWebpackPlugin({ - title: `Buttercup v${version}`, - template: INDEX_TEMPLATE, - filename: "setup.html", - inject: "body", - chunks: ["setup"] - }), - new HtmlWebpackPlugin({ - title: `Buttercup v${version}`, - template: INDEX_TEMPLATE, - filename: "dialog.html", - inject: "body", - chunks: ["dialog"] - }), - new NormalModuleReplacementPlugin(/\/iconv-loader/, "node-noop"), - new NormalModuleReplacementPlugin(/random-number-generator|safe-buffer/, "node-noop") - ], + }, - resolve: { - fallback: { - Buffer: false, - child_process: false, - dns: false, - net: false, - process: false, - stream: false, - tls: false, - util: false + output: { + filename: "[name].js", + path: DIST, + publicPath: "" + }, + + plugins: [ + new MiniCSSExtractPlugin(), + new DefinePlugin(__configDefines), + new DefinePlugin({ + __VERSION__: JSON.stringify(version) + }), + new NormalModuleReplacementPlugin(/\/iconv-loader/, "node-noop"), + new NormalModuleReplacementPlugin(/random-number-generator|safe-buffer/, "node-noop") + ], + + resolve: { + fallback: { + Buffer: false, + child_process: false, + dns: false, + net: false, + process: false, + stream: false, + tls: false, + util: false + } + }, + + watchOptions: { + ignored: /node_modules/, + poll: 1000 } - }, + }; +} - watchOptions: { - ignored: /node_modules/, - poll: 1000 - } -}; +module.exports = [ + merge(getBaseConfig(), { + entry: { + background: path.join(SOURCE, "./background/index.js") + }, + + optimization: { + splitChunks: { + automaticNameDelimiter: "-", + cacheGroups: { + vendors: { + test: /\/node_modules\//, + name: "background-vendors", + priority: -10, + chunks: "initial" + } + } + } + } + }), + merge(getBaseConfig(), { + entry: { + tab: path.join(SOURCE, "./tab/index.js") + } + }), + merge(getBaseConfig(), { + entry: { + dialog: path.join(SOURCE, "./dialog/index.js"), + popup: path.join(SOURCE, "./popup/index.js"), + setup: path.join(SOURCE, "./setup/index.js") + }, + + optimization: { + splitChunks: { + automaticNameDelimiter: "-", + cacheGroups: { + vendors: { + test: /\/node_modules\//, + name: "vendors", + priority: -10, + chunks: "initial" + }, + default: { + priority: -20, + chunks: "initial", + reuseExistingChunk: true, + name: "common" + } + } + } + }, + + plugins: [ + { + apply: compiler => { + compiler.hooks.afterEmit.tap("AfterEmitPlugin", compilation => { + buildManifest(Object.keys(compilation.getStats().compilation.assets)); + }); + } + }, + new CopyWebpackPlugin({ + patterns: [ + { + from: CHANGELOG + }, + { + from: path.join(__dirname, "./resources", "buttercup-*.png") + }, + { + from: ICONS_PATH, + to: "icons" + } + ] + }), + new HtmlWebpackPlugin({ + title: "Buttercup", + template: INDEX_TEMPLATE, + filename: "popup.html", + inject: "body", + chunks: ["popup"] + }), + new HtmlWebpackPlugin({ + title: `Buttercup v${version}`, + template: INDEX_TEMPLATE, + filename: "setup.html", + inject: "body", + chunks: ["setup"] + }), + new HtmlWebpackPlugin({ + title: `Buttercup v${version}`, + template: INDEX_TEMPLATE, + filename: "dialog.html", + inject: "body", + chunks: ["dialog"] + }) + ] + }) +]; From 53f578114922625ea0ce5d9a18d222aa5da9d78a Mon Sep 17 00:00:00 2001 From: Perry Mitchell Date: Tue, 31 May 2022 07:48:01 +0300 Subject: [PATCH 14/29] Cleanup --- resources/manifest.json | 2 +- source/setup/index.js | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/resources/manifest.json b/resources/manifest.json index 3f0acf38..eae65932 100644 --- a/resources/manifest.json +++ b/resources/manifest.json @@ -34,7 +34,7 @@ { "matches": ["http://*/*", "https://*/*"], "run_at": "document_end", - "js": ["vendors.js", "tab.js"] + "js": ["tab.js"] } ], diff --git a/source/setup/index.js b/source/setup/index.js index a5da46a8..7b2a368d 100644 --- a/source/setup/index.js +++ b/source/setup/index.js @@ -46,7 +46,3 @@ trackMouseMovement(); // Track keystrokes for user activity tracking trackKeydownEvent(); - -// setTimeout(() => { -// window.document.body.classList.add("bp3-dark"); -// }); From 9eab96e4482a87c75b93e061a177e634283333eb Mon Sep 17 00:00:00 2001 From: Perry Mitchell Date: Thu, 2 Jun 2022 20:40:43 +0300 Subject: [PATCH 15/29] Remove more fn bind calls --- source/dialog/components/SaveNewCredentialsPage.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/dialog/components/SaveNewCredentialsPage.js b/source/dialog/components/SaveNewCredentialsPage.js index 17e44d55..64888ec2 100644 --- a/source/dialog/components/SaveNewCredentialsPage.js +++ b/source/dialog/components/SaveNewCredentialsPage.js @@ -49,11 +49,11 @@ class SaveNewCredentialsPage extends Component { fill text="Save" icon="floppy-disk" - onClick={::this.handleSaveClick} + onClick={evt => this.handleSaveClick(evt)} intent={Intent.PRIMARY} /> -
- -

Local File

diff --git a/source/setup/components/VaultPage.js b/source/setup/components/VaultPage.js index b527eb6e..5bbbfa61 100644 --- a/source/setup/components/VaultPage.js +++ b/source/setup/components/VaultPage.js @@ -253,22 +253,6 @@ class VaultPage extends PureComponent { onChange={event => this.handleUpdateForm("oldMasterPassword", event)} /> - - - this.handleUpdateForm("passwordToken", event)} - /> - - dispatch => { - dispatch(setMyButtercupAuthID(myButtercupAuthID)); - performMyButtercupAuthentication(); - }, onChooseDropboxBasedArchive: (archiveName, masterPassword) => (dispatch, getState) => { const name = stripTags(archiveName); if (/^[^\s]/.test(name) !== true) { @@ -158,7 +135,7 @@ export default connect( .then(async () => { let fileID; if (shouldCreate) { - const client = createGoogleDriveClient(googleDriveToken); + const client = new GoogleDriveClient(googleDriveToken); const containingDirectory = dirname(remoteFilename); const putOptions = { contents: "\n", @@ -241,32 +218,6 @@ export default connect( dispatch(setAdding(false)); }); }, - onChooseMyButtercupArchive: masterPassword => (dispatch, getState) => { - const state = getState(); - const accessToken = getMyButtercupAccessToken(state); - const refreshToken = getMyButtercupRefreshToken(state); - const vaultID = getMyButtercupVaultID(state); - const name = getMyButtercupName(state); - dispatch(setAdding(true)); - dispatch(setBusy("Adding vault")); - return addMyButtercupArchives(name, vaultID, accessToken, refreshToken, masterPassword) - .then(() => { - dispatch(unsetBusy()); - notifySuccess("Successfully added vault", "My Buttercup vault successfully added."); - setTimeout(() => { - closeCurrentTab(); - }, ADD_ARCHIVE_WINDOW_CLOSE_DELAY); - }) - .catch(err => { - dispatch(unsetBusy()); - console.error(err); - notifyError( - "Failed selecting My Buttercup vault", - `An error occurred when adding the vault: ${err.message}` - ); - dispatch(setAdding(false)); - }); - }, onChooseWebDAVBasedArchive: (type, archiveName, masterPassword, url, username, password) => ( dispatch, getState diff --git a/source/setup/containers/MyBcupVaultPage.js b/source/setup/containers/MyBcupVaultPage.js deleted file mode 100644 index ee2f3496..00000000 --- a/source/setup/containers/MyBcupVaultPage.js +++ /dev/null @@ -1,43 +0,0 @@ -import { connect } from "react-redux"; -import { push } from "react-router-redux"; -import delay from "yoctodelay"; -import MyBcupVaultPage from "../components/MyBcupVaultPage.js"; -import { getArchiveState, getArchiveTitle } from "../../shared/selectors/archives.js"; -import { unlockArchive } from "../library/messaging.js"; -import { notifyError, notifySuccess, notifyWarning } from "../library/notify.js"; -import { setBusy, unsetBusy } from "../../shared/actions/app.js"; -import { isEditing } from "../selectors/manageArchive.js"; -import { setEditing } from "../actions/manageArchive.js"; - -export default connect( - (state, ownProps) => ({ - archiveTitle: getArchiveTitle(state, ownProps.match.params.id), - isEditing: isEditing(state), - state: getArchiveState(state, ownProps.match.params.id), - sourceID: ownProps.match.params.id - }), - { - onUnlockArchive: (sourceID, masterPassword) => dispatch => { - dispatch(setBusy("Unlocking vault...")); - dispatch(setEditing(true)); - unlockArchive(sourceID, masterPassword) - .then(() => { - dispatch(unsetBusy()); - dispatch(setEditing(false)); - notifySuccess("Vault unlocked", "Successfully unlocked vault"); - dispatch(push(`/mybuttercup-vault/${sourceID}`)); - }) - .catch(err => { - dispatch(setEditing(false)); - dispatch(unsetBusy()); - console.error(err); - const { hush } = Layerr.info(err); - if (hush) { - notifyWarning("Authorisation failed", "The credentials were invalid - re-authenticating"); - } else { - notifyError("Failed unlocking vault", `Unable to unlock archive: ${err.message}`); - } - }); - } - } -)(MyBcupVaultPage); diff --git a/source/setup/index.js b/source/setup/index.js index 538f647c..14b60007 100644 --- a/source/setup/index.js +++ b/source/setup/index.js @@ -12,7 +12,6 @@ import LoadingModal from "./containers/LoadingModal.js"; import SaveCredentialsPage from "./containers/SaveCredentialsPage.js"; import AboutPage from "./components/AboutPage.js"; import UnlockAllArchivesPage from "./containers/UnlockAllArchivesPage.js"; -import MyBcupVaultPage from "./containers/MyBcupVaultPage.js"; import DisabledLoginDomainsPage from "./components/DisabledLoginDomainsPage.js"; import App from "../shared/containers/App.js"; import { trackMouseMovement } from "../shared/library/mouseEvents.js"; @@ -30,7 +29,6 @@ ReactDOM.render( - diff --git a/source/setup/library/archives.js b/source/setup/library/archives.js index 0dd3b1dc..3ef78bf5 100644 --- a/source/setup/library/archives.js +++ b/source/setup/library/archives.js @@ -41,17 +41,6 @@ export function addLocalArchive(name, masterPassword, filename, key, shouldCreat }); } -export function addMyButtercupArchives(name, vaultID, accessToken, refreshToken, masterPassword) { - return makeArchiveAdditionRequest({ - type: "mybuttercup", - name, - accessToken, - refreshToken, - masterPassword, - vaultID - }); -} - export function addWebDAVArchive(name, masterPassword, filename, url, username, password, shouldCreate = false) { return makeArchiveAdditionRequest({ type: "webdav", diff --git a/source/setup/library/myButtercup.js b/source/setup/library/myButtercup.js deleted file mode 100644 index f7444b0e..00000000 --- a/source/setup/library/myButtercup.js +++ /dev/null @@ -1,8 +0,0 @@ -import { MyButtercupClient } from "../../shared/library/buttercup.js"; -import { dispatch, getState } from "../redux/index.js"; -import { MYBUTTERCUP_CLIENT_ID } from "../../shared/library/myButtercup.js"; - -export function performAuthentication() { - const url = MyButtercupClient.generateAuthorisationURL(MYBUTTERCUP_CLIENT_ID); - chrome.tabs.create({ url }); -} diff --git a/source/setup/library/remote.js b/source/setup/library/remote.js index 8892518d..7018bd8f 100644 --- a/source/setup/library/remote.js +++ b/source/setup/library/remote.js @@ -1,5 +1,5 @@ import { DropboxClient } from "@buttercup/dropbox-client"; -import { createClient as createGoogleDriveClient } from "@buttercup/googledrive-client"; +import { GoogleDriveClient } from "@buttercup/googledrive-client"; import { getSharedAppEnv } from "../../shared/library/buttercup.js"; import log from "../../shared/library/log.js"; import { getState } from "../redux/index.js"; @@ -38,8 +38,8 @@ function getDropboxClient() { return; } __dropboxClient = new DropboxClient(authToken, { - compat: true, - compatCorsHack: false + // compat: true, + // compatCorsHack: false }); } return __dropboxClient; @@ -63,7 +63,7 @@ function getGoogleDriveClient() { log.error("Unable to create Google Drive client: No token found"); return; } - __googleDriveClient = createGoogleDriveClient(accessToken); + __googleDriveClient = new GoogleDriveClient(accessToken); } return __googleDriveClient; } diff --git a/source/setup/reducers/index.js b/source/setup/reducers/index.js index 96836cc6..7f559848 100644 --- a/source/setup/reducers/index.js +++ b/source/setup/reducers/index.js @@ -11,7 +11,6 @@ import releaseNotes from "./releaseNotes.js"; import remoteFiles from "./remoteFiles.js"; import searching from "../../shared/reducers/searching.js"; import vault from "./vault.js"; -import myButtercup from "../../shared/reducers/mybuttercup.js"; const appReducer = combineReducers({ app, @@ -20,7 +19,6 @@ const appReducer = combineReducers({ dropbox, googleDrive, manageArchive, - myButtercup, releaseNotes, remoteFiles, searching, diff --git a/source/shared/actions/myButtercup.js b/source/shared/actions/myButtercup.js deleted file mode 100644 index 0125c47f..00000000 --- a/source/shared/actions/myButtercup.js +++ /dev/null @@ -1,16 +0,0 @@ -import { createAction } from "redux-actions"; -import { - MYBUTTERCUP_CLEAR_STATE, - MYBUTTERCUP_SET_ACCESS_TOKEN, - MYBUTTERCUP_SET_AUTH_ID, - MYBUTTERCUP_SET_NAME, - MYBUTTERCUP_SET_REFRESH_TOKEN, - MYBUTTERCUP_SET_VAULT_ID -} from "./types.js"; - -export const clearMyButtercupState = createAction(MYBUTTERCUP_CLEAR_STATE); -export const setAccessToken = createAction(MYBUTTERCUP_SET_ACCESS_TOKEN); -export const setAuthID = createAction(MYBUTTERCUP_SET_AUTH_ID); -export const setName = createAction(MYBUTTERCUP_SET_NAME); -export const setRefreshToken = createAction(MYBUTTERCUP_SET_REFRESH_TOKEN); -export const setVaultID = createAction(MYBUTTERCUP_SET_VAULT_ID); diff --git a/source/shared/actions/types.js b/source/shared/actions/types.js index 9ed1b004..153df6eb 100644 --- a/source/shared/actions/types.js +++ b/source/shared/actions/types.js @@ -22,12 +22,5 @@ export const GOOGLE_DRIVE_SET_AUTH_ID = "googleDrive/setAuthenticationID"; export const GOOGLE_DRIVE_SET_AUTH_CODE = "googleDrive/setAuthCode"; export const GOOGLE_DRIVE_SET_REFRESH_TOKEN = "googleDrive/setRefreshToken"; -export const MYBUTTERCUP_CLEAR_STATE = "myButtercup/clear"; -export const MYBUTTERCUP_SET_ACCESS_TOKEN = "myButtercup/accessToken/set"; -export const MYBUTTERCUP_SET_AUTH_ID = "myButtercup/setAuthenticationID"; -export const MYBUTTERCUP_SET_NAME = "myButtercup/name/set"; -export const MYBUTTERCUP_SET_REFRESH_TOKEN = "myButtercup/refreshToken/set"; -export const MYBUTTERCUP_SET_VAULT_ID = "myButtercup/vaultID/set"; - export const SEARCH_SET_ENTRY_RESULTS = "searching/results/set"; export const SEARCH_SET_SOURCES_COUNT = "searching/setSources"; diff --git a/source/shared/library/icons.js b/source/shared/library/icons.js index 34343275..b7561316 100644 --- a/source/shared/library/icons.js +++ b/source/shared/library/icons.js @@ -1,17 +1,10 @@ import VAULT_TYPE_IMAGE_DROPBOX from "../../../resources/providers/dropbox-256.png"; import VAULT_TYPE_IMAGE_GOOGLEDRIVE from "../../../resources/providers/googledrive-256.png"; import VAULT_TYPE_IMAGE_LOCALFILE from "../../../resources/providers/chip.svg"; -import VAULT_TYPE_IMAGE_MYBUTTERCUP from "../../../resources/providers/mybuttercup-256.png"; import VAULT_TYPE_IMAGE_WEBDAV from "../../../resources/providers/webdav-256.png"; export const DATASOURCE_TYPES = ["dropbox", "googledrive", "webdav", "localfile"]; export const VAULT_TYPES = [ - // { - // type: "mybuttercup", - // title: "My Buttercup", - // image: VAULT_TYPE_IMAGE_MYBUTTERCUP, - // invertOnDarkMode: false - // }, { type: "dropbox", title: "Dropbox", diff --git a/source/shared/library/myButtercup.js b/source/shared/library/myButtercup.js deleted file mode 100644 index 09ed3b32..00000000 --- a/source/shared/library/myButtercup.js +++ /dev/null @@ -1,4 +0,0 @@ -export const MYBUTTERCUP_CLIENT_ID = "bcup_browser_ext"; -export const MYBUTTERCUP_CLIENT_SECRET = "71cf1f22921b5ceb84d7ea71d95a854b"; -export const MYBUTTERCUP_REDIRECT_URI = "https://my.buttercup.pw/oauth/authorized/"; -// export const MYBUTTERCUP_REDIRECT_URI = "http://localhost:8000/oauth/authorized/"; diff --git a/source/shared/reducers/mybuttercup.js b/source/shared/reducers/mybuttercup.js deleted file mode 100644 index fafa0dfe..00000000 --- a/source/shared/reducers/mybuttercup.js +++ /dev/null @@ -1,56 +0,0 @@ -import { - MYBUTTERCUP_CLEAR_STATE, - MYBUTTERCUP_SET_ACCESS_TOKEN, - MYBUTTERCUP_SET_AUTH_ID, - MYBUTTERCUP_SET_NAME, - MYBUTTERCUP_SET_REFRESH_TOKEN, - MYBUTTERCUP_SET_VAULT_ID -} from "../actions/types.js"; - -const INITIAL = { - accessToken: null, - authenticationID: null, - name: null, - refreshToken: null, - vaultID: null -}; - -export default function myButtercupReducer(state = INITIAL, action = {}) { - switch (action.type) { - case MYBUTTERCUP_CLEAR_STATE: - return { - ...state, - accessToken: null, - authenticationID: null, - refreshToken: null, - vaultID: null - }; - case MYBUTTERCUP_SET_AUTH_ID: - return { - ...state, - authenticationID: action.payload - }; - case MYBUTTERCUP_SET_ACCESS_TOKEN: - return { - ...state, - accessToken: action.payload - }; - case MYBUTTERCUP_SET_REFRESH_TOKEN: - return { - ...state, - refreshToken: action.payload - }; - case MYBUTTERCUP_SET_VAULT_ID: - return { - ...state, - vaultID: action.payload - }; - case MYBUTTERCUP_SET_NAME: - return { - ...state, - name: action.payload - }; - default: - return state; - } -} diff --git a/source/shared/selectors/myButtercup.js b/source/shared/selectors/myButtercup.js deleted file mode 100644 index 32ec2339..00000000 --- a/source/shared/selectors/myButtercup.js +++ /dev/null @@ -1,21 +0,0 @@ -const KEY = "myButtercup"; - -export function getAccessToken(state) { - return state[KEY].accessToken; -} - -export function getAuthID(state) { - return state[KEY].authenticationID; -} - -export function getName(state) { - return state[KEY].name; -} - -export function getRefreshToken(state) { - return state[KEY].refreshToken; -} - -export function getVaultID(state) { - return state[KEY].vaultID; -} diff --git a/source/tab/index.js b/source/tab/index.js index f476337f..82dae4e6 100644 --- a/source/tab/index.js +++ b/source/tab/index.js @@ -13,7 +13,6 @@ import { showSaveDialog } from "./saveDialog.js"; import { watchInputs } from "./generator.js"; import { trackMouseMovement, trackScrolling } from "../shared/library/mouseEvents.js"; import { trackKeydownEvent } from "../shared/library/keyboardEvents.js"; -import { watchForRegistrationPossibility } from "./myButtercup.js"; import { currentDomainDisabled } from "./page.js"; function checkForLoginSaveAbility() { @@ -92,6 +91,3 @@ trackMouseMovement(); trackScrolling(); // Track keystrokes for user activity tracking trackKeydownEvent(); - -// Setup My Buttercup integrations -setTimeout(watchForRegistrationPossibility, 100); diff --git a/source/tab/messaging.js b/source/tab/messaging.js index 97d13628..ea8ae2f2 100644 --- a/source/tab/messaging.js +++ b/source/tab/messaging.js @@ -1,10 +1,9 @@ import postRobot from "post-robot"; -import { enterLoginDetails, submitLoginForm } from "./login.js"; +import { enterLoginDetails } from "./login.js"; import { hideInputDialog } from "./inputDialog.js"; import { hideSaveDialog } from "./saveDialog.js"; import { openGeneratorForCurrentInput, setPasswordForCurrentInput } from "./generator.js"; import { autoLogin } from "./autoLogin.js"; -import { attemptVaultIDMatch, checkForVaultContainer } from "./myButtercup.js"; export function getConfig() { return new Promise(resolve => { @@ -65,22 +64,6 @@ function handleMessage(request, sender, sendResponse) { autoLogin(username, password); return false; } - case "check-mybcup-vault": { - const { vaultID } = request; - attemptVaultIDMatch(vaultID); - if (!document.hidden) { - setTimeout(checkForVaultContainer, 500); - } else { - const onChange = () => { - if (!document.hidden) { - document.removeEventListener("visibilitychange", onChange, false); - checkForVaultContainer(); - } - }; - document.addEventListener("visibilitychange", onChange, false); - } - break; - } case "enter-details": { const { signIn, entry } = request; enterLoginDetails(entry.properties.username, entry.properties.password, signIn); diff --git a/source/tab/myButtercup.js b/source/tab/myButtercup.js deleted file mode 100644 index 89760610..00000000 --- a/source/tab/myButtercup.js +++ /dev/null @@ -1,101 +0,0 @@ -import { el, mount, setStyle } from "redom"; -import { getExtensionURL } from "../shared/library/extension.js"; -import { getVaults } from "./messaging.js"; - -const BCUP_MESSAGE_PREFIX = /^bcup_ext_resp:/; -const MYBUTTERCUP_DOMAIN_REXP = /^https?:\/\/(my\.buttercup\.pw|localhost:8000)/; - -let __matchedVaultData = null; - -export async function attemptVaultIDMatch(vaultID) { - const vaults = await getVaults(); - const matchingVault = vaults.find(vault => vault.meta && vault.meta.vaultID === vaultID); - if (matchingVault) { - __matchedVaultData = matchingVault; - window.top.postMessage( - `bcup_ext:${JSON.stringify({ - type: "vault-match", - result: "found" - })}`, - "*" - ); - } else { - window.top.postMessage( - `bcup_ext:${JSON.stringify({ - type: "vault-match", - result: "none" - })}`, - "*" - ); - } -} - -export function checkForVaultContainer() { - const vaultContainerEl = document.getElementById("vaultInjection"); - if (vaultContainerEl && vaultContainerEl.dataset.filled === "false" && __matchedVaultData) { - buildMyButtercupFrame(vaultContainerEl); - } -} - -function buildMyButtercupFrame(container) { - const frame = el("iframe", { - style: { - width: "100%", - height: "100%" - }, - src: getExtensionURL(`setup.html#/mybuttercup-vault/${__matchedVaultData.id}`), - frameBorder: "0" - }); - mount(container, frame); - container.dataset.filled = "true"; -} - -function handleWindowMessageResponse(evt) { - const { data } = evt; - if (BCUP_MESSAGE_PREFIX.test(data)) { - const payload = JSON.parse(data.replace(BCUP_MESSAGE_PREFIX, "")); - const { type } = payload; - switch (type) { - case "target-vault-id": { - const { id: myBcupVaultID } = payload; - attemptVaultIDMatch(myBcupVaultID); - break; - } - default: - console.error("Unrecognised message from MyButtercup:", payload); - break; - } - } -} - -export function watchForRegistrationPossibility() { - if (!MYBUTTERCUP_DOMAIN_REXP.test(window.location.href)) { - return; - } - window.addEventListener("message", handleWindowMessageResponse, false); - window.top.postMessage( - `bcup_ext:${JSON.stringify({ - type: "get-vault-id" - })}`, - "*" - ); - window.top.postMessage( - `bcup_ext:${JSON.stringify({ - type: "set-extension-setup-url", - url: chrome.runtime.getURL("/setup.html") - })}`, - "*" - ); - checkForVaultContainer(); - const mutationObserverConfig = { attributes: false, childList: true, subtree: true }; - const onMutation = mutations => { - for (const mutation of mutations) { - if (mutation.addedNodes && mutation.addedNodes.length > 0) { - checkForVaultContainer(); - break; - } - } - }; - const observer = new MutationObserver(onMutation); - observer.observe(document.body, mutationObserverConfig); -} From e189ce6040cb9f7ae2385585d6ca518bd10620e0 Mon Sep 17 00:00:00 2001 From: Perry Mitchell Date: Wed, 8 Nov 2023 22:30:57 +0200 Subject: [PATCH 28/29] Prepare v2.26.0 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d58a22a7..eaec5350 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Buttercup browser extension changelog +## v2.26.0 +_2023-11-08_ + + * **Important version 3 update notice** + * Updates for core libraries and datasources + ## v2.25.3 _2023-01-31_ From 76a33a73295c5f5ce593cfbce723e817cfd49e29 Mon Sep 17 00:00:00 2001 From: Perry Mitchell Date: Wed, 8 Nov 2023 22:32:43 +0200 Subject: [PATCH 29/29] Bump 2.26.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5f219511..afeaad27 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "buttercup-browser-extension", - "version": "2.25.3", + "version": "2.26.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "buttercup-browser-extension", - "version": "2.25.3", + "version": "2.26.0", "license": "MIT", "devDependencies": { "@babel/core": "^7.17.9", diff --git a/package.json b/package.json index 63fa2eed..97e67b27 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "buttercup-browser-extension", - "version": "2.25.3", + "version": "2.26.0", "description": "Buttercup browser extension for Chrome and Firefox.", "main": "source/background/index.js", "scripts": {