Compare commits
2 Commits
temp/debug
...
pr/dontAss
Author | SHA1 | Date | |
---|---|---|---|
e3bf558ff6 | |||
![]() |
21f3431d09 |
42
flake.lock
generated
42
flake.lock
generated
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"flake-utils": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1659877975,
|
|
||||||
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1666767323,
|
|
||||||
"narHash": "sha256-drbsgF8iLzQQ6umzOU/idYkI+UoifQdpH+mwohB3J7c=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "e6e675cafe6a1d1b0eeb9ac3fe046091244b714e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"id": "nixpkgs",
|
|
||||||
"ref": "nixos-22.05",
|
|
||||||
"type": "indirect"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": "flake-utils",
|
|
||||||
"nixpkgs": "nixpkgs"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
54
flake.nix
54
flake.nix
@@ -1,54 +0,0 @@
|
|||||||
{
|
|
||||||
description = "TODO";
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.url = "nixpkgs/nixos-22.05";
|
|
||||||
flake-utils.url = github:numtide/flake-utils;
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs = { self, nixpkgs, flake-utils }:
|
|
||||||
with flake-utils.lib; eachSystem allSystems (system:
|
|
||||||
let
|
|
||||||
pkgs = import nixpkgs { inherit system; };
|
|
||||||
lib = pkgs.lib;
|
|
||||||
nativeBuildInputs = with pkgs; [ ];
|
|
||||||
in rec {
|
|
||||||
packages = let
|
|
||||||
pname = "browserpass-extension";
|
|
||||||
version = "3.7.2-next-20221026";
|
|
||||||
in rec {
|
|
||||||
browserpass-extension-yarn-modules = pkgs.mkYarnModules {
|
|
||||||
inherit pname version;
|
|
||||||
packageJSON = ./src/package.json;
|
|
||||||
yarnLock = ./src/yarn.lock;
|
|
||||||
};
|
|
||||||
browserpass-extension = pkgs.stdenv.mkDerivation {
|
|
||||||
inherit pname version;
|
|
||||||
src = ./.;
|
|
||||||
|
|
||||||
patchPhase = ''
|
|
||||||
# dependencies are built externally: skip the yarn install
|
|
||||||
${pkgs.gnused}/bin/sed -i /yarn\ install/d src/Makefile
|
|
||||||
'';
|
|
||||||
|
|
||||||
preBuild = ''
|
|
||||||
ln -s ${browserpass-extension-yarn-modules}/node_modules src/node_modules
|
|
||||||
'';
|
|
||||||
installPhase = ''
|
|
||||||
BASE=$out/share/mozilla/extensions/\{ec8030f7-c20a-464f-9b0e-13a3a9e97384\}
|
|
||||||
mkdir -p $BASE
|
|
||||||
pushd firefox
|
|
||||||
${pkgs.zip}/bin/zip -r $BASE/browserpass@maximbaz.com.xpi ./*
|
|
||||||
popd
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
defaultPackage = packages.browserpass-extension;
|
|
||||||
|
|
||||||
devShells.default = with pkgs; mkShell {
|
|
||||||
buildInputs = nativeBuildInputs ++ [ nodejs yarn ];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@@ -724,7 +724,7 @@ async function handleMessage(settings, message, sendResponse) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "copyOTP":
|
case "copyOTP":
|
||||||
if (helpers.getSetting("enableOTP", message.login, settings, helpers.SettingScope.Store)) {
|
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");
|
||||||
@@ -797,7 +797,7 @@ async function handleMessage(settings, message, sendResponse) {
|
|||||||
// copy OTP token after fill
|
// copy OTP token after fill
|
||||||
if (
|
if (
|
||||||
typeof message.login !== "undefined" &&
|
typeof message.login !== "undefined" &&
|
||||||
helpers.getSetting("enableOTP", message.login, settings, helpers.SettingScope.Store) &&
|
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));
|
||||||
@@ -870,7 +870,7 @@ function hostAction(settings, action, params = {}) {
|
|||||||
async function parseFields(settings, login) {
|
async function parseFields(settings, login) {
|
||||||
var response = await hostAction(settings, "fetch", {
|
var response = await hostAction(settings, "fetch", {
|
||||||
storeId: login.store.id,
|
storeId: login.store.id,
|
||||||
file: login.login + ".gpg",
|
file: login.loginPath,
|
||||||
});
|
});
|
||||||
if (response.status != "ok") {
|
if (response.status != "ok") {
|
||||||
throw new Error(JSON.stringify(response)); // TODO handle host error
|
throw new Error(JSON.stringify(response)); // TODO handle host error
|
||||||
@@ -963,10 +963,7 @@ async function parseFields(settings, login) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// preprocess otp
|
// preprocess otp
|
||||||
if (
|
if (helpers.getSetting("enableOTP", login, settings) && login.fields.hasOwnProperty("otp")) {
|
||||||
helpers.getSetting("enableOTP", login, settings, helpers.SettingScope.Store) &&
|
|
||||||
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 {
|
||||||
|
@@ -8,20 +8,12 @@ const hash = require("hash.js");
|
|||||||
const Authenticator = require("otplib").authenticator.Authenticator;
|
const Authenticator = require("otplib").authenticator.Authenticator;
|
||||||
const BrowserpassURL = require("@browserpass/url");
|
const BrowserpassURL = require("@browserpass/url");
|
||||||
|
|
||||||
const SettingScope = {
|
|
||||||
// query a setting first from the login, then the store, then globally
|
|
||||||
Login: "login",
|
|
||||||
// query a setting first from the store, then globally
|
|
||||||
Store: "store",
|
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
prepareLogins,
|
prepareLogins,
|
||||||
filterSortLogins,
|
filterSortLogins,
|
||||||
getSetting,
|
getSetting,
|
||||||
ignoreFiles,
|
ignoreFiles,
|
||||||
makeTOTP,
|
makeTOTP,
|
||||||
SettingScope,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//----------------------------------- Function definitions ----------------------------------//
|
//----------------------------------- Function definitions ----------------------------------//
|
||||||
@@ -32,11 +24,10 @@ module.exports = {
|
|||||||
* @param string key Setting key
|
* @param string key Setting key
|
||||||
* @param object login Login object
|
* @param object login Login object
|
||||||
* @param object settings Settings object
|
* @param object settings Settings object
|
||||||
* @param string scope SettingScope value to specify where to search for the setting (optional)
|
|
||||||
* @return object Setting value
|
* @return object Setting value
|
||||||
*/
|
*/
|
||||||
function getSetting(key, login, settings, scope = SettingScope.Login) {
|
function getSetting(key, login, settings) {
|
||||||
if (scope === SettingScope.Login && typeof login.settings[key] !== "undefined") {
|
if (typeof login.settings[key] !== "undefined") {
|
||||||
return login.settings[key];
|
return login.settings[key];
|
||||||
}
|
}
|
||||||
if (typeof settings.stores[login.store.id].settings[key] !== "undefined") {
|
if (typeof settings.stores[login.store.id].settings[key] !== "undefined") {
|
||||||
@@ -96,10 +87,14 @@ function prepareLogins(files, settings) {
|
|||||||
for (let storeId in files) {
|
for (let storeId in files) {
|
||||||
for (let key in files[storeId]) {
|
for (let key in files[storeId]) {
|
||||||
// set login fields
|
// set login fields
|
||||||
|
const loginPath = files[storeId][key];
|
||||||
|
// remove the file-type extension
|
||||||
|
const loginName = loginPath.replace(/\.[^.]+$/u, "");
|
||||||
const login = {
|
const login = {
|
||||||
index: index++,
|
index: index++,
|
||||||
store: settings.stores[storeId],
|
store: settings.stores[storeId],
|
||||||
login: files[storeId][key].replace(/\.gpg$/i, ""),
|
login: loginName,
|
||||||
|
loginPath: loginPath,
|
||||||
allowFill: true,
|
allowFill: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -103,7 +103,7 @@ function view(ctl, params) {
|
|||||||
]),
|
]),
|
||||||
(() => {
|
(() => {
|
||||||
if (
|
if (
|
||||||
helpers.getSetting("enableOTP", login, this.settings, helpers.SettingScope.Store) &&
|
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