mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-18 01:41:27 +01:00
gnome importer
This commit is contained in:
parent
a1529bc4e9
commit
c3bea80ec7
@ -100,6 +100,9 @@
|
|||||||
case 'passkeepcsv':
|
case 'passkeepcsv':
|
||||||
importPassKeepCsv(file, success, error);
|
importPassKeepCsv(file, success, error);
|
||||||
break;
|
break;
|
||||||
|
case 'gnomejson':
|
||||||
|
importGnomeJson(file, success, error);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
error();
|
error();
|
||||||
break;
|
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;
|
return _service;
|
||||||
});
|
});
|
||||||
|
@ -232,6 +232,16 @@
|
|||||||
'importing from Google Chrome. See detailed instructions on our help site at ' +
|
'importing from Google Chrome. See detailed instructions on our help site at ' +
|
||||||
'<a target="_blank" href="https://help.bitwarden.com/article/import-from-chrome/">' +
|
'<a target="_blank" href="https://help.bitwarden.com/article/import-from-chrome/">' +
|
||||||
'https://help.bitwarden.com/article/import-from-chrome/</a>')
|
'https://help.bitwarden.com/article/import-from-chrome/</a>')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'gnomejson',
|
||||||
|
name: 'GNOME Passwords and Keys/Seahorse (json)',
|
||||||
|
instructions: $sce.trustAsHtml('Make sure you have python-keyring and python-gnomekeyring installed. ' +
|
||||||
|
'Save the <a target="_blank" href="http://bit.ly/2sMldAI">GNOME Keyring Import/Export</a> ' +
|
||||||
|
'python script by Luke Plant to your desktop as <code>pw_helper.py</code>. Open terminal and run ' +
|
||||||
|
'<code>chmod +rx Desktop/pw_helper.py</code> and then ' +
|
||||||
|
'<code>python Desktop/pw_helper.py export Desktop/my_passwords.json</code>. Then upload ' +
|
||||||
|
'the resulting <code>my_passwords.json</code> file here to bitwarden.')
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user