From 72d0a439d2c30567f4c80425b8cd669702cd53f9 Mon Sep 17 00:00:00 2001 From: Tomer Shvueli Date: Sat, 20 Feb 2021 14:48:54 -0500 Subject: [PATCH 1/5] feat: Add option to auto-copy TOTP code when page auto fills credentials --- src/_locales/en/messages.json | 6 ++++++ src/popup/settings/options.component.html | 13 +++++++++++++ src/popup/settings/options.component.ts | 14 ++++++++++++++ src/services/autofill.service.ts | 4 +++- 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 790c635f4b..3c04cfad93 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -885,6 +885,12 @@ "enableAutoFillOnPageLoadDesc": { "message": "If a login form is detected, automatically perform an auto-fill when the web page loads." }, + "enableAutoTotpCopyOnAutoFill": { + "message": "Enable Copy to Clipboard of TOTP On Page Auto-fill" + }, + "enableAutoTotpCopyOnAutoFillDesc": { + "message": "If login auto-fills on page load and TOTP exists for this login, copy to clipboard without prompt" + }, "experimentalFeature": { "message": "This is currently an experimental feature. Use at your own risk." }, diff --git a/src/popup/settings/options.component.html b/src/popup/settings/options.component.html index 938bcd756e..dc39c2453c 100644 --- a/src/popup/settings/options.component.html +++ b/src/popup/settings/options.component.html @@ -24,6 +24,19 @@ {{'warning' | i18n}}: {{'experimentalFeature' | i18n}} +
+
+
+ + +
+
+ +
diff --git a/src/popup/settings/options.component.ts b/src/popup/settings/options.component.ts index e5cf6322bb..80a145e318 100644 --- a/src/popup/settings/options.component.ts +++ b/src/popup/settings/options.component.ts @@ -23,6 +23,7 @@ import { ConstantsService } from 'jslib/services/constants.service'; export class OptionsComponent implements OnInit { disableFavicon = false; enableAutoFillOnPageLoad = false; + enableAutoTotpCopyOnAutoFill = false; disableAutoTotpCopy = false; disableContextMenuItem = false; disableAddLoginNotification = false; @@ -70,6 +71,8 @@ export class OptionsComponent implements OnInit { this.enableAutoFillOnPageLoad = await this.storageService.get( ConstantsService.enableAutoFillOnPageLoadKey); + this.enableAutoTotpCopyOnAutoFill = await this.totpService.isAutoCopyOnAutoFillEnabled(); + this.disableAddLoginNotification = await this.storageService.get( ConstantsService.disableAddLoginNotificationKey); @@ -120,9 +123,20 @@ export class OptionsComponent implements OnInit { async updateAutoFillOnPageLoad() { await this.storageService.save(ConstantsService.enableAutoFillOnPageLoadKey, this.enableAutoFillOnPageLoad); + if (!this.enableAutoFillOnPageLoad) { + // If we disable Auto Fill on Page Load, also disable Copying of TOTP + await this.storageService.save(ConstantsService.enableAutoTotpCopyOnAutoFill, false); + // TODO the below reloads the entire extension, I just want to reload the current view, or at least the enable auto totp copy checkbox + window.setTimeout(() => window.location.reload(), 200); + } this.callAnalytics('Auto-fill Page Load', this.enableAutoFillOnPageLoad); } + async updateAutoTotpCopyOnAutoFill() { + await this.storageService.save(ConstantsService.enableAutoTotpCopyOnAutoFill, this.enableAutoTotpCopyOnAutoFill); + this.callAnalytics('Auto Copy TOTP on Page Load', this.enableAutoTotpCopyOnAutoFill); + } + async updateDisableFavicon() { await this.storageService.save(ConstantsService.disableFaviconKey, this.disableFavicon); await this.stateService.save(ConstantsService.disableFaviconKey, this.disableFavicon); diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts index 841e27098d..9cb3822219 100644 --- a/src/services/autofill.service.ts +++ b/src/services/autofill.service.ts @@ -254,10 +254,12 @@ export default class AutofillService implements AutofillServiceInterface { } } + const shouldCopyTotpOnAutoFill = await this.totpService.isAutoCopyOnAutoFillEnabled(); + const totpCode = await this.doAutoFill({ cipher: cipher, pageDetails: pageDetails, - skipTotp: !fromCommand, + skipTotp: !fromCommand && !shouldCopyTotpOnAutoFill, skipLastUsed: !fromCommand, skipUsernameOnlyFill: !fromCommand, onlyEmptyFields: !fromCommand, From 6eb7106bc5e068d8db7f1ae36494e71cc325924f Mon Sep 17 00:00:00 2001 From: Tomer Shvueli Date: Thu, 4 Mar 2021 09:58:22 -0500 Subject: [PATCH 2/5] fix: Nest sub option in Options page, tie auto fill & auto copy features together --- src/_locales/en/messages.json | 5 +---- src/popup/scss/box.scss | 5 +++++ src/popup/settings/options.component.html | 18 +++++++----------- src/popup/settings/options.component.ts | 9 +-------- src/services/autofill.service.ts | 6 ++++-- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 3c04cfad93..12a4f96fb6 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -886,10 +886,7 @@ "message": "If a login form is detected, automatically perform an auto-fill when the web page loads." }, "enableAutoTotpCopyOnAutoFill": { - "message": "Enable Copy to Clipboard of TOTP On Page Auto-fill" - }, - "enableAutoTotpCopyOnAutoFillDesc": { - "message": "If login auto-fills on page load and TOTP exists for this login, copy to clipboard without prompt" + "message": "Enable Copy to Clipboard of TOTP" }, "experimentalFeature": { "message": "This is currently an experimental feature. Use at your own risk." diff --git a/src/popup/scss/box.scss b/src/popup/scss/box.scss index 91f8db1d5a..8ef64b6b76 100644 --- a/src/popup/scss/box.scss +++ b/src/popup/scss/box.scss @@ -9,6 +9,11 @@ margin-top: 0; } + .box { + padding-left: 15px; + padding-bottom: 5px; + } + .box-header { margin: 0 10px 5px 10px; text-transform: uppercase; diff --git a/src/popup/settings/options.component.html b/src/popup/settings/options.component.html index dc39c2453c..81a9a35598 100644 --- a/src/popup/settings/options.component.html +++ b/src/popup/settings/options.component.html @@ -23,19 +23,15 @@ {{'enableAutoFillOnPageLoadDesc' | i18n}} {{'warning' | i18n}}: {{'experimentalFeature' | i18n}}
-
-
-
-
- - +
+
+
+ + +
-
diff --git a/src/popup/settings/options.component.ts b/src/popup/settings/options.component.ts index 80a145e318..c2118634f4 100644 --- a/src/popup/settings/options.component.ts +++ b/src/popup/settings/options.component.ts @@ -123,18 +123,11 @@ export class OptionsComponent implements OnInit { async updateAutoFillOnPageLoad() { await this.storageService.save(ConstantsService.enableAutoFillOnPageLoadKey, this.enableAutoFillOnPageLoad); - if (!this.enableAutoFillOnPageLoad) { - // If we disable Auto Fill on Page Load, also disable Copying of TOTP - await this.storageService.save(ConstantsService.enableAutoTotpCopyOnAutoFill, false); - // TODO the below reloads the entire extension, I just want to reload the current view, or at least the enable auto totp copy checkbox - window.setTimeout(() => window.location.reload(), 200); - } this.callAnalytics('Auto-fill Page Load', this.enableAutoFillOnPageLoad); } async updateAutoTotpCopyOnAutoFill() { - await this.storageService.save(ConstantsService.enableAutoTotpCopyOnAutoFill, this.enableAutoTotpCopyOnAutoFill); - this.callAnalytics('Auto Copy TOTP on Page Load', this.enableAutoTotpCopyOnAutoFill); + await this.storageService.save(ConstantsService.enableAutoTotpCopyOnAutoFillKey, this.enableAutoTotpCopyOnAutoFill); } async updateDisableFavicon() { diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts index 9cb3822219..a71c5f6cfb 100644 --- a/src/services/autofill.service.ts +++ b/src/services/autofill.service.ts @@ -254,12 +254,14 @@ export default class AutofillService implements AutofillServiceInterface { } } - const shouldCopyTotpOnAutoFill = await this.totpService.isAutoCopyOnAutoFillEnabled(); + const copyTotpOnAutoFill = await this.totpService.isAutoCopyOnAutoFillEnabled(); + const enableAutoFill = await this.totpService.isAutoCopyEnabled(); + const shouldCopyTotp = copyTotpOnAutoFill && enableAutoFill; const totpCode = await this.doAutoFill({ cipher: cipher, pageDetails: pageDetails, - skipTotp: !fromCommand && !shouldCopyTotpOnAutoFill, + skipTotp: !fromCommand && !shouldCopyTotp, skipLastUsed: !fromCommand, skipUsernameOnlyFill: !fromCommand, onlyEmptyFields: !fromCommand, From da37add779b5b3e8d7f92ddb0a49057f31115b0a Mon Sep 17 00:00:00 2001 From: Tomer Shvueli Date: Thu, 11 Mar 2021 11:00:39 -0500 Subject: [PATCH 3/5] fix: Updated styles and copy, simpler logic --- src/_locales/en/messages.json | 2 +- src/popup/scss/box.scss | 6 ++++-- src/services/autofill.service.ts | 5 ++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 12a4f96fb6..0ac89a2c87 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -886,7 +886,7 @@ "message": "If a login form is detected, automatically perform an auto-fill when the web page loads." }, "enableAutoTotpCopyOnAutoFill": { - "message": "Enable Copy to Clipboard of TOTP" + "message": "Copy TOTP to clipboard after auto-fill" }, "experimentalFeature": { "message": "This is currently an experimental feature. Use at your own risk." diff --git a/src/popup/scss/box.scss b/src/popup/scss/box.scss index 8ef64b6b76..8ae0842d66 100644 --- a/src/popup/scss/box.scss +++ b/src/popup/scss/box.scss @@ -10,8 +10,10 @@ } .box { - padding-left: 15px; - padding-bottom: 5px; + width: calc(100% - 15px); + margin-left: 15px; + margin-bottom: 5px; + border-left: 1px solid #000000; } .box-header { diff --git a/src/services/autofill.service.ts b/src/services/autofill.service.ts index a71c5f6cfb..4ab9f5b4e4 100644 --- a/src/services/autofill.service.ts +++ b/src/services/autofill.service.ts @@ -255,13 +255,12 @@ export default class AutofillService implements AutofillServiceInterface { } const copyTotpOnAutoFill = await this.totpService.isAutoCopyOnAutoFillEnabled(); - const enableAutoFill = await this.totpService.isAutoCopyEnabled(); - const shouldCopyTotp = copyTotpOnAutoFill && enableAutoFill; + const shouldCopyTotp = fromCommand || copyTotpOnAutoFill; const totpCode = await this.doAutoFill({ cipher: cipher, pageDetails: pageDetails, - skipTotp: !fromCommand && !shouldCopyTotp, + skipTotp: !shouldCopyTotp, skipLastUsed: !fromCommand, skipUsernameOnlyFill: !fromCommand, onlyEmptyFields: !fromCommand, From efd224d3807c99c15251a1816d8da35606693059 Mon Sep 17 00:00:00 2001 From: Tomer Shvueli Date: Fri, 30 Apr 2021 10:48:20 -0400 Subject: [PATCH 4/5] fix: Updated UI so option is no longer nested, added proper description --- src/_locales/en/messages.json | 5 ++++- src/popup/scss/box.scss | 7 ------- src/popup/settings/options.component.html | 17 ++++++++++------- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 0ac89a2c87..6615263add 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -886,7 +886,10 @@ "message": "If a login form is detected, automatically perform an auto-fill when the web page loads." }, "enableAutoTotpCopyOnAutoFill": { - "message": "Copy TOTP to clipboard after auto-fill" + "message": "Automatic TOTP Copy after Page Load" + }, + "enableAutoTotpCopyOnAutoFillDesc": { + "message": "If Auto-fill On Page Load is enabled, and your login has an authenticator key attached to it, the TOTP verification code is automatically copied to your clipboard after loading the web page." }, "experimentalFeature": { "message": "This is currently an experimental feature. Use at your own risk." diff --git a/src/popup/scss/box.scss b/src/popup/scss/box.scss index 8ae0842d66..91f8db1d5a 100644 --- a/src/popup/scss/box.scss +++ b/src/popup/scss/box.scss @@ -9,13 +9,6 @@ margin-top: 0; } - .box { - width: calc(100% - 15px); - margin-left: 15px; - margin-bottom: 5px; - border-left: 1px solid #000000; - } - .box-header { margin: 0 10px 5px 10px; text-transform: uppercase; diff --git a/src/popup/settings/options.component.html b/src/popup/settings/options.component.html index 81a9a35598..e868ad66fb 100644 --- a/src/popup/settings/options.component.html +++ b/src/popup/settings/options.component.html @@ -23,15 +23,18 @@ {{'enableAutoFillOnPageLoadDesc' | i18n}} {{'warning' | i18n}}: {{'experimentalFeature' | i18n}}
-
-
-
- - -
+
+
+
+
+ +
+
From d0b0d63e588c524750bb82278aa6c8e1e3d9db02 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Wed, 5 May 2021 12:28:29 +1000 Subject: [PATCH 5/5] bump jslib --- jslib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jslib b/jslib index a72c8a60c1..2841cff90a 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit a72c8a60c1b7a6980bceee456c53a9ea7b9b3451 +Subproject commit 2841cff90a8ff8136b5d580443725be792521bea