From d9416f2d5fe6eb03dc52b3d5945e65623d1a787d Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Fri, 9 Apr 2021 22:28:11 +0530 Subject: [PATCH 1/3] Honor store-specific enableOTP setting --- src/background.js | 7 +++++-- src/popup/detailsInterface.js | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/background.js b/src/background.js index 70031c5a..e6247671 100644 --- a/src/background.js +++ b/src/background.js @@ -743,7 +743,7 @@ async function handleMessage(settings, message, sendResponse) { } break; case "copyOTP": - if (settings.enableOTP) { + if (settings.enableOTP || settings.stores[message.login.store.id].settings.enableOTP) { try { if (!message.login.fields.otp) { throw new Exception("No OTP seed available"); @@ -982,7 +982,10 @@ async function parseFields(settings, login) { } // preprocess otp - if (settings.enableOTP && login.fields.hasOwnProperty("otp")) { + if ( + (settings.enableOTP || settings.stores[login.store.id].settings.enableOTP) && + login.fields.hasOwnProperty("otp") + ) { if (login.fields.otp.match(/^otpauth:\/\/.+/i)) { // attempt to parse otp data as URI try { diff --git a/src/popup/detailsInterface.js b/src/popup/detailsInterface.js index 7c0a4507..f2832026 100644 --- a/src/popup/detailsInterface.js +++ b/src/popup/detailsInterface.js @@ -103,7 +103,8 @@ function view(ctl, params) { ]), (() => { if ( - this.settings.enableOTP && + (this.settings.enableOTP || + this.settings.stores[login.store.id].settings.enableOTP) && login.fields.otp && login.fields.otp.params.type === "totp" ) { From 01fb4109ffb5f9c1098c3052c2d016101f04bdc3 Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Sat, 10 Apr 2021 11:26:45 +0530 Subject: [PATCH 2/3] use getSetting() to fetch enableOTP in background.js also, catch `enableOTP` in `fill` action to copy OTP token after filling login information reference : https://github.com/browserpass/browserpass-extension/pull/261#pullrequestreview-632789845 --- src/background.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/background.js b/src/background.js index e6247671..851ed3d1 100644 --- a/src/background.js +++ b/src/background.js @@ -743,7 +743,7 @@ async function handleMessage(settings, message, sendResponse) { } break; case "copyOTP": - if (settings.enableOTP || settings.stores[message.login.store.id].settings.enableOTP) { + if (getSetting("enableOTP", message.login, settings)) { try { if (!message.login.fields.otp) { throw new Exception("No OTP seed available"); @@ -815,7 +815,7 @@ async function handleMessage(settings, message, sendResponse) { // copy OTP token after fill if ( - settings.enableOTP && + getSetting("enableOTP", message.login, settings) && typeof message.login !== "undefined" && message.login.fields.hasOwnProperty("otp") ) { @@ -982,10 +982,7 @@ async function parseFields(settings, login) { } // preprocess otp - if ( - (settings.enableOTP || settings.stores[login.store.id].settings.enableOTP) && - login.fields.hasOwnProperty("otp") - ) { + if (getSetting("enableOTP", login, settings) && login.fields.hasOwnProperty("otp")) { if (login.fields.otp.match(/^otpauth:\/\/.+/i)) { // attempt to parse otp data as URI try { From edc88b75d0561b724fba32b6bc00fa8b7ce2eb66 Mon Sep 17 00:00:00 2001 From: shine <4771718+shinenelson@users.noreply.github.com> Date: Sat, 10 Apr 2021 11:44:11 +0530 Subject: [PATCH 3/3] use login-scoped settings in popup/detailsInterface.js to fetch the `enableOTP` setting reference : https://github.com/browserpass/browserpass-extension/pull/261#pullrequestreview-632789845 --- src/popup/detailsInterface.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/popup/detailsInterface.js b/src/popup/detailsInterface.js index f2832026..0bed2af7 100644 --- a/src/popup/detailsInterface.js +++ b/src/popup/detailsInterface.js @@ -103,8 +103,7 @@ function view(ctl, params) { ]), (() => { if ( - (this.settings.enableOTP || - this.settings.stores[login.store.id].settings.enableOTP) && + (this.settings.enableOTP || login.store.settings.enableOTP) && login.fields.otp && login.fields.otp.params.type === "totp" ) {