Compare commits
2 Commits
sane/dev
...
pr/otpSett
Author | SHA1 | Date | |
---|---|---|---|
a5f5e27b5f | |||
e342264adf |
@@ -450,7 +450,7 @@ async function fillFields(settings, login, fields) {
|
|||||||
// build focus or submit request
|
// build focus or submit request
|
||||||
let focusOrSubmitRequest = {
|
let focusOrSubmitRequest = {
|
||||||
origin: new BrowserpassURL(settings.tab.url).origin,
|
origin: new BrowserpassURL(settings.tab.url).origin,
|
||||||
autoSubmit: getSetting("autoSubmit", login, settings),
|
autoSubmit: helpers.getSetting("autoSubmit", login, settings),
|
||||||
filledFields: filledFields,
|
filledFields: filledFields,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -561,25 +561,6 @@ async function getFullSettings() {
|
|||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get most relevant setting value
|
|
||||||
*
|
|
||||||
* @param string key Setting key
|
|
||||||
* @param object login Login object
|
|
||||||
* @param object settings Settings object
|
|
||||||
* @return object Setting value
|
|
||||||
*/
|
|
||||||
function getSetting(key, login, settings) {
|
|
||||||
if (typeof login.settings[key] !== "undefined") {
|
|
||||||
return login.settings[key];
|
|
||||||
}
|
|
||||||
if (typeof settings.stores[login.store.id].settings[key] !== "undefined") {
|
|
||||||
return settings.stores[login.store.id].settings[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
return settings[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deep copy an object
|
* Deep copy an object
|
||||||
*
|
*
|
||||||
@@ -743,7 +724,7 @@ async function handleMessage(settings, message, sendResponse) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "copyOTP":
|
case "copyOTP":
|
||||||
if (settings.enableOTP) {
|
if (helpers.getSetting("enableOTP", message.login, settings)) {
|
||||||
try {
|
try {
|
||||||
if (!message.login.fields.otp) {
|
if (!message.login.fields.otp) {
|
||||||
throw new Exception("No OTP seed available");
|
throw new Exception("No OTP seed available");
|
||||||
@@ -815,8 +796,8 @@ async function handleMessage(settings, message, sendResponse) {
|
|||||||
|
|
||||||
// copy OTP token after fill
|
// copy OTP token after fill
|
||||||
if (
|
if (
|
||||||
settings.enableOTP &&
|
|
||||||
typeof message.login !== "undefined" &&
|
typeof message.login !== "undefined" &&
|
||||||
|
helpers.getSetting("enableOTP", message.login, settings) &&
|
||||||
message.login.fields.hasOwnProperty("otp")
|
message.login.fields.hasOwnProperty("otp")
|
||||||
) {
|
) {
|
||||||
copyToClipboard(helpers.makeTOTP(message.login.fields.otp.params));
|
copyToClipboard(helpers.makeTOTP(message.login.fields.otp.params));
|
||||||
@@ -968,7 +949,7 @@ async function parseFields(settings, login) {
|
|||||||
if (key === "secret" && lines.length) {
|
if (key === "secret" && lines.length) {
|
||||||
login.fields.secret = lines[0];
|
login.fields.secret = lines[0];
|
||||||
} else if (key === "login") {
|
} else if (key === "login") {
|
||||||
const defaultUsername = getSetting("username", login, settings);
|
const defaultUsername = helpers.getSetting("username", login, settings);
|
||||||
login.fields[key] = defaultUsername || login.login.match(/([^\/]+)$/)[1];
|
login.fields[key] = defaultUsername || login.login.match(/([^\/]+)$/)[1];
|
||||||
} else {
|
} else {
|
||||||
delete login.fields[key];
|
delete login.fields[key];
|
||||||
@@ -982,7 +963,7 @@ async function parseFields(settings, login) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// preprocess otp
|
// preprocess otp
|
||||||
if (settings.enableOTP && login.fields.hasOwnProperty("otp")) {
|
if (helpers.getSetting("enableOTP", login, settings) && login.fields.hasOwnProperty("otp")) {
|
||||||
if (login.fields.otp.match(/^otpauth:\/\/.+/i)) {
|
if (login.fields.otp.match(/^otpauth:\/\/.+/i)) {
|
||||||
// attempt to parse otp data as URI
|
// attempt to parse otp data as URI
|
||||||
try {
|
try {
|
||||||
|
@@ -11,12 +11,32 @@ const BrowserpassURL = require("@browserpass/url");
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
prepareLogins,
|
prepareLogins,
|
||||||
filterSortLogins,
|
filterSortLogins,
|
||||||
|
getSetting,
|
||||||
ignoreFiles,
|
ignoreFiles,
|
||||||
makeTOTP,
|
makeTOTP,
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------- Function definitions ----------------------------------//
|
//----------------------------------- Function definitions ----------------------------------//
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get most relevant setting value
|
||||||
|
*
|
||||||
|
* @param string key Setting key
|
||||||
|
* @param object login Login object
|
||||||
|
* @param object settings Settings object
|
||||||
|
* @return object Setting value
|
||||||
|
*/
|
||||||
|
function getSetting(key, login, settings) {
|
||||||
|
if (typeof login.settings[key] !== "undefined") {
|
||||||
|
return login.settings[key];
|
||||||
|
}
|
||||||
|
if (typeof settings.stores[login.store.id].settings[key] !== "undefined") {
|
||||||
|
return settings.stores[login.store.id].settings[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return settings[key];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the deepest available domain component of a path
|
* Get the deepest available domain component of a path
|
||||||
*
|
*
|
||||||
|
@@ -103,7 +103,7 @@ function view(ctl, params) {
|
|||||||
]),
|
]),
|
||||||
(() => {
|
(() => {
|
||||||
if (
|
if (
|
||||||
this.settings.enableOTP &&
|
helpers.getSetting("enableOTP", login, this.settings) &&
|
||||||
login.fields.otp &&
|
login.fields.otp &&
|
||||||
login.fields.otp.params.type === "totp"
|
login.fields.otp.params.type === "totp"
|
||||||
) {
|
) {
|
||||||
|
Reference in New Issue
Block a user