diff --git a/src/app/services/importService.js b/src/app/services/importService.js
index 3a0a0ea5e1..acf383928f 100644
--- a/src/app/services/importService.js
+++ b/src/app/services/importService.js
@@ -100,6 +100,9 @@
case 'passkeepcsv':
importPassKeepCsv(file, success, error);
break;
+ case 'gnomejson':
+ importGnomeJson(file, success, error);
+ break;
default:
error();
break;
@@ -2453,5 +2456,76 @@
});
}
+ function importGnomeJson(file, success, error) {
+ var folders = [],
+ logins = [],
+ loginRelationships = [],
+ i = 0;
+
+ getFileContents(file, parseJson, error);
+
+ function parseJson(fileContent) {
+ var fileJson = JSON.parse(fileContent);
+ var folderIndex = 0;
+ var loginIndex = 0;
+
+ if (fileJson && Object.keys(fileJson).length) {
+ for (var keyRing in fileJson) {
+ if (fileJson.hasOwnProperty(keyRing) && fileJson[keyRing].length) {
+ folderIndex = folders.length;
+ folders.push({
+ name: keyRing
+ });
+
+ for (i = 0; i < fileJson[keyRing].length; i++) {
+ var item = fileJson[keyRing][i];
+ if (!item.display_name || item.display_name.indexOf('http') !== 0) {
+ continue;
+ }
+
+ loginIndex = logins.length;
+
+ var login = {
+ favorite: false,
+ uri: fixUri(item.display_name),
+ username: item.attributes.username_value && item.attributes.username_value !== '' ?
+ item.attributes.username_value : null,
+ password: item.secret && item.secret !== '' ? item.secret : null,
+ notes: '',
+ name: item.display_name.replace('http://', '').replace('https://', ''),
+ };
+
+ if (login.name > 30) {
+ login.name = login.name.substring(0, 30);
+ }
+
+ for (var attr in item.attributes) {
+ if (item.attributes.hasOwnProperty(attr) && attr !== 'username_value' &&
+ attr !== 'xdg:schema') {
+ if (login.notes !== '') {
+ login.notes += '\n'
+ }
+ login.notes += (attr + ': ' + item.attributes[attr]);
+ }
+ }
+
+ if (login.notes === '') {
+ login.notes = null;
+ }
+
+ logins.push(login);
+ loginRelationships.push({
+ key: loginIndex,
+ value: folderIndex
+ });
+ }
+ }
+ }
+ }
+
+ success(folders, logins, loginRelationships);
+ }
+ }
+
return _service;
});
diff --git a/src/app/tools/toolsImportController.js b/src/app/tools/toolsImportController.js
index 79e8278905..2b943a0b04 100644
--- a/src/app/tools/toolsImportController.js
+++ b/src/app/tools/toolsImportController.js
@@ -232,6 +232,16 @@
'importing from Google Chrome. See detailed instructions on our help site at ' +
'' +
'https://help.bitwarden.com/article/import-from-chrome/')
+ },
+ {
+ id: 'gnomejson',
+ name: 'GNOME Passwords and Keys/Seahorse (json)',
+ instructions: $sce.trustAsHtml('Make sure you have python-keyring and python-gnomekeyring installed. ' +
+ 'Save the GNOME Keyring Import/Export ' +
+ 'python script by Luke Plant to your desktop as pw_helper.py
. Open terminal and run ' +
+ 'chmod +rx Desktop/pw_helper.py
and then ' +
+ 'python Desktop/pw_helper.py export Desktop/my_passwords.json
. Then upload ' +
+ 'the resulting my_passwords.json
file here to bitwarden.')
}
];