From f7cc3233ed66fc05508898e317dbc8d09efeaeba Mon Sep 17 00:00:00 2001 From: varjolintu Date: Mon, 22 May 2017 11:24:56 +0300 Subject: [PATCH 1/9] Removed underline letters from context menus. --- chromeKeePassXC/background/init.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/chromeKeePassXC/background/init.js b/chromeKeePassXC/background/init.js index 25d95cf..95b4a1b 100644 --- a/chromeKeePassXC/background/init.js +++ b/chromeKeePassXC/background/init.js @@ -105,7 +105,7 @@ browser.runtime.onMessage.addListener(event.onMessage); * Add context menu entry for filling in username + password */ browser.contextMenus.create({ - "title": "Fill &User + Pass", + "title": "Fill User + Pass", "contexts": [ "editable" ], "onclick": function(info, tab) { browser.tabs.sendMessage(tab.id, { @@ -118,7 +118,7 @@ browser.contextMenus.create({ * Add context menu entry for filling in only password which matches for given username */ browser.contextMenus.create({ - "title": "Fill &Pass Only", + "title": "Fill Pass Only", "contexts": [ "editable" ], "onclick": function(info, tab) { browser.tabs.sendMessage(tab.id, { @@ -131,7 +131,7 @@ browser.contextMenus.create({ * Add context menu entry for creating icon for generate-password dialog */ browser.contextMenus.create({ - "title": "Show Password &Generator Icons", + "title": "Show Password Generator Icons", "contexts": [ "editable" ], "onclick": function(info, tab) { browser.tabs.sendMessage(tab.id, { @@ -144,7 +144,7 @@ browser.contextMenus.create({ * Add context menu entry for creating icon for generate-password dialog */ browser.contextMenus.create({ - "title": "&Save credentials", + "title": "Save credentials", "contexts": [ "editable" ], "onclick": function(info, tab) { browser.tabs.sendMessage(tab.id, { From 5512f64e4b8285b26cdf10a039d189e53c3e387a Mon Sep 17 00:00:00 2001 From: varjolintu Date: Tue, 23 May 2017 13:17:45 +0300 Subject: [PATCH 2/9] Updated README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0d5669b..1ca94b9 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ Chrome extension for [KeePassXC](https://keepassxc.org/) with Native Messaging. This is a heavily forked version of [pfn](https://github.com/pfn)'s [chromeIPass](https://github.com/pfn/passifox). +For testing purposes, please use following unofficial KeePassXC [release's](https://github.com/varjolintu/keepassxc/releases). Get the extension for [Firefox](https://addons.mozilla.org/en-US/firefox/addon/chromekeepassxc/) or [Chrome/Chromium](https://chrome.google.com/webstore/detail/chromekeepassxc/iopaggbpplllidnfmcghoonnokmjoicf). From d97115553cb73e977df84e8dcbbbf4bbbde67b00 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Tue, 23 May 2017 14:37:59 +0300 Subject: [PATCH 3/9] Added install script --- install.sh | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100755 install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..b95e937 --- /dev/null +++ b/install.sh @@ -0,0 +1,137 @@ +#!/usr/bin/env bash + +# The MIT License (MIT) +# Copyright (c) 2016 Danny van Kooten +# Modifications (c) 2017 Sami Vänttinen + +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software +# and associated documentation files (the "Software"), to deal in the Software without restriction, +# including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +# LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +# NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +set -e + +DIR="$( cd "$( dirname "$0" )" && pwd )" +APP_NAME="com.varjolintu.chromekeepassxc" +HOST_FILE="$DIR" +KEEPASSXC_PATH="" + +# Find target dirs for various browsers & OS'es +# https://developer.chrome.com/extensions/nativeMessaging#native-messaging-host-location +# https://wiki.mozilla.org/WebExtensions/Native_Messaging +if [ $(uname -s) == 'Darwin' ]; then + if [ "$(whoami)" == "root" ]; then + TARGET_DIR_CHROME="/Library/Google/Chrome/NativeMessagingHosts" + TARGET_DIR_CHROMIUM="/Library/Application Support/Chromium/NativeMessagingHosts" + TARGET_DIR_FIREFOX="/Library/Application Support/Mozilla/NativeMessagingHosts" + TARGET_DIR_VIVALDI="/Library/Application Support/Vivaldi/NativeMessagingHosts" + else + TARGET_DIR_CHROME="$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts" + TARGET_DIR_CHROMIUM="$HOME/Library/Application Support/Chromium/NativeMessagingHosts" + TARGET_DIR_FIREFOX="$HOME/Library/Application Support/Mozilla/NativeMessagingHosts" + TARGET_DIR_VIVALDI="$HOME/Library/Application Support/Vivaldi/NativeMessagingHosts" + fi +else + if [ "$(whoami)" == "root" ]; then + TARGET_DIR_CHROME="/etc/opt/chrome/native-messaging-hosts" + TARGET_DIR_CHROMIUM="/etc/chromium/native-messaging-hosts" + TARGET_DIR_FIREFOX="/usr/lib/mozilla/native-messaging-hosts" + TARGET_DIR_VIVALDI="/etc/chromium/native-messaging-hosts" + else + TARGET_DIR_CHROME="$HOME/.config/google-chrome/NativeMessagingHosts" + TARGET_DIR_CHROMIUM="$HOME/.config/chromium/NativeMessagingHosts" + TARGET_DIR_FIREFOX="$HOME/.mozilla/native-messaging-hosts" + TARGET_DIR_VIVALDI="$HOME/.config/vivaldi/NativeMessagingHosts" + fi +fi + +if [ -e "$DIR/chromeKeePassXC" ]; then + echo "Detected development binary" + HOST_FILE="$DIR/chromeKeePassXC" +fi + +echo "" +echo "Select your browser:" +echo "====================" +echo "1) Chrome" +echo "2) Chromium" +echo "3) Firefox" +echo "4) Vivaldi" +echo -n "1-4: " +read BROWSER +echo "" + +# Set target dir from user input +if [[ "$BROWSER" == "1" ]]; then + BROWSER_NAME="Chrome" + TARGET_DIR="$TARGET_DIR_CHROME" +fi + +if [[ "$BROWSER" == "2" ]]; then + BROWSER_NAME="Chromium" + TARGET_DIR="$TARGET_DIR_CHROMIUM" +fi + +if [[ "$BROWSER" == "3" ]]; then + BROWSER_NAME="Firefox" + TARGET_DIR="$TARGET_DIR_FIREFOX" +fi + +if [[ "$BROWSER" == "4" ]]; then + BROWSER_NAME="Vivaldi" + TARGET_DIR="$TARGET_DIR_VIVALDI" +fi + +# Try to find the KeePassXC binary. +if [ $(uname -s) == 'Darwin' ]; then + KEEPASSXC_PATH="/Applications/KeePassXC.app" +else + KEEPASSXC_PATH="$(command -v keepassxc)" + if [ -z "$KEEPASSXC_PATH" ] ; then + echo "" + echo -n "KeePassXC binary not found. Give the location of KeePassXC binary: " + read KEEPASSXC_PATH + echo "" + fi +fi +echo "KeePassXC binary location set to $KEEPASSXC_PATH" +echo "Installing $BROWSER_NAME host config with path $KEEPASSXC_PATH" +echo "Press (ENTER) or give a new path to binary if it's not correct: " +read NEW_PATH + +if [ "$NEW_PATH" ]; then + KEEPASSXC_PATH="$NEW_PATH" + echo "New path set to: $KEEPASSXC_PATH" +fi + +# Add /Contents/MacOS/KeePassXC to darwin for exact binary path +if [ $(uname -s) == 'Darwin' ]; then + KEEPASSXC_PATH="$KEEPASSXC_PATH/Contents/MacOS/KeePassXC" +fi + +ESCAPED_PATH=${KEEPASSXC_PATH////\\/} + +# Create config dir if not existing +mkdir -p "$TARGET_DIR" + +# Copy manifest host config file +if [ "$BROWSER" == "1" ] || [ "$BROWSER" == "2" ] || [ "$BROWSER" == "4" ]; then + cp "$DIR/com.varjolintu.chromekeepassxc-chrome.json" "$TARGET_DIR/$APP_NAME.json" +else + cp "$DIR/com.varjolintu.chromekeepassxc-firefox.json" "$TARGET_DIR//$APP_NAME.json" +fi + +# Replace path to host +sed -i "" -e "s/%%replace%%/$ESCAPED_PATH/g" "$TARGET_DIR/$APP_NAME.json" + +# Set permissions for the manifest so that all users can read it. +chmod o+r "$TARGET_DIR/$APP_NAME.json" + +echo "Native messaging host for $BROWSER_NAME has been installed to $TARGET_DIR." \ No newline at end of file From 4cb407d83d59c36209e7d42d7a6978dd2dc1e2cd Mon Sep 17 00:00:00 2001 From: varjolintu Date: Tue, 23 May 2017 14:40:05 +0300 Subject: [PATCH 4/9] Added new host json files --- com.varjolintu.chromekeepassxc-chrome.json | 10 ++++++++++ com.varjolintu.chromekeepassxc-firefox.json | 9 +++++++++ 2 files changed, 19 insertions(+) create mode 100644 com.varjolintu.chromekeepassxc-chrome.json create mode 100644 com.varjolintu.chromekeepassxc-firefox.json diff --git a/com.varjolintu.chromekeepassxc-chrome.json b/com.varjolintu.chromekeepassxc-chrome.json new file mode 100644 index 0000000..ce25fa8 --- /dev/null +++ b/com.varjolintu.chromekeepassxc-chrome.json @@ -0,0 +1,10 @@ +{ + "name": "com.varjolintu.chromekeepassxc", + "description": "KeepassXC integration with Chrome with Native Messaging support", + "path" : "%%replace%%", + "type": "stdio", + "allowed_origins": [ + "chrome-extension://iopaggbpplllidnfmcghoonnokmjoicf/", + "chrome-extension://fhakpkpdnjecjfceboihdjpfmgajebii/" + ] +} \ No newline at end of file diff --git a/com.varjolintu.chromekeepassxc-firefox.json b/com.varjolintu.chromekeepassxc-firefox.json new file mode 100644 index 0000000..b5e0176 --- /dev/null +++ b/com.varjolintu.chromekeepassxc-firefox.json @@ -0,0 +1,9 @@ +{ + "name": "com.varjolintu.chromekeepassxc", + "description": "KeepassXC integration with Firefox with Native Messaging support", + "path" : "%%replace%%", + "type": "stdio", + "allowed_extensions": [ + "chromeKeePassXC@sami.vanttinen" + ] +} \ No newline at end of file From e25d70c62308ba6488fff093a88f092631c7ad2f Mon Sep 17 00:00:00 2001 From: varjolintu Date: Tue, 23 May 2017 14:41:43 +0300 Subject: [PATCH 5/9] Modified install script --- install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index b95e937..893fe68 100755 --- a/install.sh +++ b/install.sh @@ -129,7 +129,11 @@ else fi # Replace path to host -sed -i "" -e "s/%%replace%%/$ESCAPED_PATH/g" "$TARGET_DIR/$APP_NAME.json" +if [ $(uname -s) == 'Darwin' ]; then + sed -i "" -e "s/%%replace%%/$ESCAPED_PATH/g" "$TARGET_DIR/$APP_NAME.json" +else + sed -i -e "s/%%replace%%/$ESCAPED_PATH/g" "$TARGET_DIR/$APP_NAME.json" +fi # Set permissions for the manifest so that all users can read it. chmod o+r "$TARGET_DIR/$APP_NAME.json" From a692ee1ef7d03c1311f2ad584c4fa57df0444845 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Tue, 23 May 2017 14:42:35 +0300 Subject: [PATCH 6/9] Removed old json --- com.varjolintu.chromekeepassxc.json | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 com.varjolintu.chromekeepassxc.json diff --git a/com.varjolintu.chromekeepassxc.json b/com.varjolintu.chromekeepassxc.json deleted file mode 100644 index f5aae80..0000000 --- a/com.varjolintu.chromekeepassxc.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "com.varjolintu.chromekeepassxc", - "description": "KeepassXC integration with Chrome with Native Messaging support", - "path": "", - "type": "stdio", - "allowed_origins": [ - "chrome-extension://ffojhfbafadajlgddbgadkbbchliloel/" - ] -} \ No newline at end of file From 1ee1a1ce54970479eaaa76bd06cfc0bd77d839da Mon Sep 17 00:00:00 2001 From: varjolintu Date: Sat, 27 May 2017 12:43:10 +0300 Subject: [PATCH 7/9] Redesigned password generator dialog --- chromeKeePassXC/background/httpauth.js | 6 +- chromeKeePassXC/background/keepass.js | 4 - chromeKeePassXC/background/page.js | 10 +- chromeKeePassXC/chromekeepassxc.css | 106 +++++++++-------- chromeKeePassXC/chromekeepassxc.js | 153 +++++++++++-------------- chromeKeePassXC/manifest.json | 2 +- chromeKeePassXC/options/options.js | 5 - chromeKeePassXC/popups/popup.html | 6 +- 8 files changed, 130 insertions(+), 162 deletions(-) diff --git a/chromeKeePassXC/background/httpauth.js b/chromeKeePassXC/background/httpauth.js index fe995b2..bd7223d 100644 --- a/chromeKeePassXC/background/httpauth.js +++ b/chromeKeePassXC/background/httpauth.js @@ -10,7 +10,7 @@ httpAuth.proxyUrl = null; httpAuth.handleRequest = function (details, callback) { - if(httpAuth.requestId == details.requestId || !page.tabs[details.tabId]) { + if (httpAuth.requestId == details.requestId || !page.tabs[details.tabId]) { callback({}); } else { @@ -26,7 +26,7 @@ httpAuth.processPendingCallbacks = function(details) { httpAuth.url = details.url; httpAuth.isProxy = details.isProxy; - if(details.challenger){ + if (details.challenger){ httpAuth.proxyUrl = details.challenger.host; } @@ -46,7 +46,7 @@ httpAuth.loginOrShowCredentials = function(logins) { event.onHTTPAuthPopup(null, {"id": httpAuth.tabId}, {"logins": logins, "url": url}); //generate popup-list for HTTP Auth usernames + descriptions - if(page.settings.autoFillAndSend) { + if (page.settings.autoFillAndSend) { httpAuth.callback({ authCredentials: { username: logins[0].login, diff --git a/chromeKeePassXC/background/keepass.js b/chromeKeePassXC/background/keepass.js index 9d4ad25..3100f97 100644 --- a/chromeKeePassXC/background/keepass.js +++ b/chromeKeePassXC/background/keepass.js @@ -606,10 +606,6 @@ keepass.deleteKey = function(hash) { localStorage.keyRing = JSON.stringify(keepass.keyRing); } -keepass.getIconColor = function() { - return ((keepass.databaseHash in keepass.keyRing) && keepass.keyRing[keepass.databaseHash].icon) ? keepass.keyRing[keepass.databaseHash].icon : "blue"; -} - keepass.setcurrentKeePassXCVersion = function(version) { if (version) { keepass.currentKeePassXC = { diff --git a/chromeKeePassXC/background/page.js b/chromeKeePassXC/background/page.js index 6c1a05e..0cbe005 100644 --- a/chromeKeePassXC/background/page.js +++ b/chromeKeePassXC/background/page.js @@ -19,19 +19,19 @@ page.initSettings = function() { page.settings.checkUpdateKeePassXC = 3; } if (!("autoCompleteUsernames" in page.settings)) { - page.settings.autoCompleteUsernames = 1; + page.settings.autoCompleteUsernames = true; } if (!("autoFillAndSend" in page.settings)) { - page.settings.autoFillAndSend = 1; + page.settings.autoFillAndSend = true; } if (!("usePasswordGenerator" in page.settings)) { - page.settings.usePasswordGenerator = 1; + page.settings.usePasswordGenerator = true; } if (!("autoFillSingleEntry" in page.settings)) { - page.settings.autoFillSingleEntry = 0; + page.settings.autoFillSingleEntry = false; } if (!("autoRetrieveCredentials" in page.settings)) { - page.settings.autoRetrieveCredentials = 1; + page.settings.autoRetrieveCredentials = true; } localStorage.settings = JSON.stringify(page.settings); } diff --git a/chromeKeePassXC/chromekeepassxc.css b/chromeKeePassXC/chromekeepassxc.css index 2ed1f9b..c1be006 100644 --- a/chromeKeePassXC/chromekeepassxc.css +++ b/chromeKeePassXC/chromekeepassxc.css @@ -6,38 +6,65 @@ font-family: Verdana, Arial, sans-serif !important; color: #222222 !important; } + .ui-dialog-titlebar-close { visibility: hidden !important; } -.cip-ui-widget-overlay { - background: none !important; - z-index: 2147483601 !important; -} -.cip-ui-dialog { - z-index: 2147483602 !important; -} -.cip-ui-dialog .cip-ui-dialog-title { - font-size:.8em !important; -} -.cip-ui-dialog .cip-ui-dialog-titlebar { - padding:.1em .5em !important; -} -.cip-ui-dialog-content { - font-size: .8em !important; + +.ui-dialog { + font-size: 12px !important; } -#cip-genpw-dialog { - text-align: left !important; +.dialog-form .ui-dialog-content .ui-widget-content { + max-height: 80px !important; } -#cip-genpw-dialog button { - height: 26px !important; + +.ui-dialog-titlebar { + background-color: #3a8233; + color: #fff; } -.cip-genpw-clearfix:after { - clear: both; - line-height: 0; - content: ""; + +.ui-dialog .ui-dialog-buttonpane { + text-align: center !important; +} +.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { + float: none !important; +} + +.ui-button .ui-button-text .ui-button { + font-size: .10em !important; +} + +input.genpw-text { + font-size: .9em !important; + padding: .4em; + border-radius: 4px; + border-top-right-radius: 0; + border-bottom-right-radius: 0; + border-collapse: separate; + width: 100%; +} +.genpw-input-group-addon { + font-size: inherit !important; + background-color: #eee; + border: 1px solid #ccc; + padding: .4em; + border-radius: 4px; + border-top-left-radius: 0; + border-bottom-left-radius: 0; + white-space: nowrap; + vertical-align: middle; + display: table-cell; + border-collapse: separate; +} + +.genpw-input-group { + position: relative; display: table; + border-collapse: separate; + width: 100%; } + .cip-genpw-icon { position: absolute; cursor: pointer; @@ -62,38 +89,7 @@ height: 24px; background-image: url(moz-extension://__MSG_@@extension_id__/icons/key_24x24.png); } -.cip-genpw-password-frame { - margin-top: 5px !important; - margin-bottom: 5px !important; -} -.cip-genpw-password-frame > * { - height: 20px !important; - font-size: 11px !important; -} -.cip-genpw-textfield { - background: none !important; - font-size: 11px !important; - display: inline !important; - border: 1px solid rgb(170, 170, 170) !important; - padding: 1px 2px !important; - max-width: none !important; - min-width: 0 !important; - font-size: 1em !important; - width: 240px !important; - padding-left: 5px !important; -} -#cip-genpw-quality { - width: 50px !important; - padding-top: 1px !important; - padding-bottom: 1px !important; -} -.cip-genpw-label { - display: block !important; - margin: 5px 0 !important; -} -.cip-genpw-checkbox { - vertical-align: middle !important; -} + #cip-genpw-btn-fillin { margin-right: 5px; } diff --git a/chromeKeePassXC/chromekeepassxc.js b/chromeKeePassXC/chromekeepassxc.js index da244fa..df17b7d 100644 --- a/chromeKeePassXC/chromekeepassxc.js +++ b/chromeKeePassXC/chromekeepassxc.js @@ -210,59 +210,28 @@ cipPassword.createDialog = function() { _called.passwordCreateDialog = true; var $dialog = jQuery("
") + .addClass("dialog-form") .attr("id", "cip-genpw-dialog"); - - var $divFloat = jQuery("
").addClass("cip-genpw-clearfix"); - var $btnGenerate = jQuery(" - +
You use an old version of KeePassXC. @@ -62,7 +62,7 @@ connected to KeePassXC.

- +
@@ -74,7 +74,7 @@

- +
From 10406eb5c2c50bb6df2e38fa41b783f520823965 Mon Sep 17 00:00:00 2001 From: varjolintu Date: Sat, 27 May 2017 15:08:51 +0300 Subject: [PATCH 8/9] Updated tweetnacl-js to 1.0.0 --- CHANGELOG | 44 ++++++++++++++++++ chromeKeePassXC/background/keepass.js | 15 +++--- chromeKeePassXC/background/nacl-util.js | 51 --------------------- chromeKeePassXC/background/nacl-util.min.js | 1 + chromeKeePassXC/chromekeepassxc.js | 20 +++++--- chromeKeePassXC/manifest.json | 2 +- 6 files changed, 69 insertions(+), 64 deletions(-) create mode 100644 CHANGELOG delete mode 100644 chromeKeePassXC/background/nacl-util.js create mode 100755 chromeKeePassXC/background/nacl-util.min.js diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..5a82e86 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,44 @@ +0.1.6 (2017-05-27) +========================= +- Upgraded tweetnacl-js to 1.0.0 +- Upgraded tweetnacl-utils-js to 0.15.0 +- Some code fixes concerning encryption and decryption +- Redesigned password generator dialog + +0.1.5 (2017-05-22) +========================= +- Fixed a few deprecated functions +- Added some more Firefox compatible code (Firefox now works 90%!) +- Removed an unncecessary .map file + +0.1.4 (2017-05-21) +========================= +- Upgraded manifest options to V2 +- Added some more Firefox compatible code + +0.1.3 (2017-05-19) +========================= +- Fixed a bug showing correct status in the popup +- Added a license for a quick method to determine which browser is used in API calls + +0.1.2 (2017-05-18) +========================= +- Upgraded jquery from 3.2.0 to 3.2.1 +- Removed unnecessary images +- Upgraded deprecated API calls (extension -> runtime, so from synchronous to asynchronous) +- Partial Firefox support (the extension can be loaded but functionality is still limited) + +0.1.1 (2017-04-28) +========================= + +- This version works with the KeePassXC fork +- Upgraded JavaScripts to work asynchronously + +0.1.0 (2017-04-12) +========================= + +- Replaced crypto libraries with tweetnacl-js +- New application and popup icons +- Upgraded bootstrap to version 3.3.7 +- Upgraded jquery from 1.11 to 3.2.0 +- Upgraded jquery-ui from 1.10.2 to 1.12.1 \ No newline at end of file diff --git a/chromeKeePassXC/background/keepass.js b/chromeKeePassXC/background/keepass.js index 3100f97..8ea4d4c 100644 --- a/chromeKeePassXC/background/keepass.js +++ b/chromeKeePassXC/background/keepass.js @@ -76,7 +76,7 @@ keepass.updateCredentials = function(callback, tab, entryId, username, password, keepass.callbackOnId(keepass.nativePort.onMessage, "set-login", function(response) { if (response.message && response.nonce) { var res = keepass.decrypt(response.message, response.nonce); - if (res == false) + if (!res) { console.log("Failed to decrypt message"); } @@ -146,7 +146,7 @@ keepass.retrieveCredentials = function (callback, tab, url, submiturl, forceCall keepass.callbackOnId(keepass.nativePort.onMessage, "get-logins", function(response) { if (response.message && response.nonce) { var res = keepass.decrypt(response.message, response.nonce); - if (res == false) + if (!res) { console.log("Failed to decrypt message"); } @@ -227,7 +227,7 @@ keepass.generatePassword = function (callback, tab, forceCallback) { keepass.callbackOnId(keepass.nativePort.onMessage, "generate-password", function(response) { if (response.message && response.nonce) { var res = keepass.decrypt(response.message, response.nonce); - if (res == false) + if (!res) { console.log("Failed to decrypt message"); } @@ -309,7 +309,7 @@ keepass.associate = function(callback, tab) { keepass.callbackOnId(keepass.nativePort.onMessage, "associate", function(response) { if (response.message && response.nonce) { var res = keepass.decrypt(response.message, response.nonce); - if (res == false) + if (!res) { console.log("Failed to decrypt message"); } @@ -390,7 +390,7 @@ keepass.testAssociation = function (callback, tab, triggerUnlock) { id: id, key: idkey }; - console.log(messageData); + var request = { action: "test-associate", message: keepass.encrypt(messageData, nonce), @@ -400,7 +400,7 @@ keepass.testAssociation = function (callback, tab, triggerUnlock) { keepass.callbackOnId(keepass.nativePort.onMessage, "test-associate", function(response) { if (response.message && response.nonce) { var res = keepass.decrypt(response.message, response.nonce); - if (res == false) { + if (!res) { console.log("Failed to decrypt message"); } else @@ -766,6 +766,9 @@ keepass.setCryptoKey = function(id, key) { keepass.encrypt = function(input, nonce) { var messageData = nacl.util.decodeUTF8(JSON.stringify(input)); var message = nacl.box(messageData, nonce, keepass.serverPublicKey, keepass.keyPair.secretKey); + if (!message) { + return ""; + } return keepass.b64e(message); } diff --git a/chromeKeePassXC/background/nacl-util.js b/chromeKeePassXC/background/nacl-util.js deleted file mode 100644 index 804068b..0000000 --- a/chromeKeePassXC/background/nacl-util.js +++ /dev/null @@ -1,51 +0,0 @@ -// Written in 2014-2016 by Dmitry Chestnykh and Devi Mandiri. -// Public domain. -(function(root, f) { - 'use strict'; - if (typeof module !== 'undefined' && module.exports) module.exports = f(); - else if (root.nacl) root.nacl.util = f(); - else { - root.nacl = {}; - root.nacl.util = f(); - } -}(this, function() { - 'use strict'; - - var util = {}; - - util.decodeUTF8 = function(s) { - if (typeof s !== 'string') throw new TypeError('expected string'); - var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length); - for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i); - return b; - }; - - util.encodeUTF8 = function(arr) { - var i, s = []; - for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i])); - return decodeURIComponent(escape(s.join(''))); - }; - - util.encodeBase64 = function(arr) { - if (typeof btoa === 'undefined') { - return (new Buffer(arr)).toString('base64'); - } else { - var i, s = [], len = arr.length; - for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i])); - return btoa(s.join('')); - } - }; - - util.decodeBase64 = function(s) { - if (typeof atob === 'undefined') { - return new Uint8Array(Array.prototype.slice.call(new Buffer(s, 'base64'), 0)); - } else { - var i, d = atob(s), b = new Uint8Array(d.length); - for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i); - return b; - } - }; - - return util; - -})); diff --git a/chromeKeePassXC/background/nacl-util.min.js b/chromeKeePassXC/background/nacl-util.min.js new file mode 100755 index 0000000..0867ece --- /dev/null +++ b/chromeKeePassXC/background/nacl-util.min.js @@ -0,0 +1 @@ +!function(e,n){"use strict";"undefined"!=typeof module&&module.exports?module.exports=n():e.nacl?e.nacl.util=n():(e.nacl={},e.nacl.util=n())}(this,function(){"use strict";function e(e){if(!/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e))throw new TypeError("invalid encoding")}var n={};return n.decodeUTF8=function(e){if("string"!=typeof e)throw new TypeError("expected string");var n,r=unescape(encodeURIComponent(e)),t=new Uint8Array(r.length);for(n=0;n Date: Sat, 27 May 2017 15:09:39 +0300 Subject: [PATCH 9/9] Changelog --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 5a82e86..47903c4 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,7 +3,7 @@ - Upgraded tweetnacl-js to 1.0.0 - Upgraded tweetnacl-utils-js to 0.15.0 - Some code fixes concerning encryption and decryption -- Redesigned password generator dialog +- Redesigned simpler password generator dialog 0.1.5 (2017-05-22) =========================