update importer for firefox
This commit is contained in:
parent
c326e03eb2
commit
cd9a43f359
|
@ -40,8 +40,8 @@
|
||||||
case 'operacsv':
|
case 'operacsv':
|
||||||
importChromeCsv(file, success, error);
|
importChromeCsv(file, success, error);
|
||||||
break;
|
break;
|
||||||
case 'firefoxpasswordexportercsvxml':
|
case 'firefoxpasswordexportercsv':
|
||||||
importFirefoxPasswordExporterCsvXml(file, success, error);
|
importFirefoxPasswordExporterCsv(file, success, error);
|
||||||
break;
|
break;
|
||||||
case 'upmcsv':
|
case 'upmcsv':
|
||||||
importUpmCsv(file, success, error);
|
importUpmCsv(file, success, error);
|
||||||
|
@ -173,6 +173,12 @@
|
||||||
'ort', 'adresse'
|
'ort', 'adresse'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
function loginNameFromUrl(url) {
|
||||||
|
var a = document.createElement('a');
|
||||||
|
a.href = url;
|
||||||
|
return a.hostname.startsWith('www.') ? a.hostname.replace('www.', '') : a.hostname;
|
||||||
|
}
|
||||||
|
|
||||||
function isField(fieldText, refFieldValues) {
|
function isField(fieldText, refFieldValues) {
|
||||||
if (!fieldText || fieldText === '') {
|
if (!fieldText || fieldText === '') {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1484,65 +1490,34 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function importFirefoxPasswordExporterCsvXml(file, success, error) {
|
function importFirefoxPasswordExporterCsv(file, success, error) {
|
||||||
|
Papa.parse(file, {
|
||||||
|
header: true,
|
||||||
|
encoding: 'UTF-8',
|
||||||
|
complete: function (results) {
|
||||||
|
parseCsvErrors(results);
|
||||||
|
|
||||||
var folders = [],
|
var folders = [],
|
||||||
ciphers = [];
|
ciphers = [];
|
||||||
|
|
||||||
function getNameFromHost(host) {
|
angular.forEach(results.data, function (value, key) {
|
||||||
var name = '--';
|
|
||||||
try {
|
|
||||||
if (host && host !== '') {
|
|
||||||
var parser = document.createElement('a');
|
|
||||||
parser.href = host;
|
|
||||||
if (parser.hostname) {
|
|
||||||
name = parser.hostname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseXml(xmlDoc) {
|
|
||||||
var xml = $(xmlDoc);
|
|
||||||
|
|
||||||
var entries = xml.find('entry');
|
|
||||||
for (var i = 0; i < entries.length; i++) {
|
|
||||||
var entry = $(entries[i]);
|
|
||||||
if (!entry) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
var host = entry.attr('host'),
|
|
||||||
user = entry.attr('user'),
|
|
||||||
password = entry.attr('password');
|
|
||||||
|
|
||||||
ciphers.push({
|
ciphers.push({
|
||||||
type: constants.cipherType.login,
|
type: constants.cipherType.login,
|
||||||
favorite: false,
|
favorite: false,
|
||||||
notes: null,
|
notes: null,
|
||||||
name: getNameFromHost(host),
|
name: value.hostname && value.hostname !== '' ? loginNameFromUrl(value.hostname) : '--',
|
||||||
login: {
|
login: {
|
||||||
uris: makeUriArray(host),
|
uris: makeUriArray(value.hostname),
|
||||||
username: user && user !== '' ? user : null,
|
username: value.username && value.username !== '' ? value.username : null,
|
||||||
password: password && password !== '' ? password : null,
|
password: value.password && value.password !== '' ? value.password : null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
success(folders, ciphers, []);
|
success(folders, ciphers, []);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
if (file.type && file.type === 'text/xml') {
|
|
||||||
getXmlFileContents(file, parseXml, error);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
error('Only .xml exports are supported.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function importUpmCsv(file, success, error) {
|
function importUpmCsv(file, success, error) {
|
||||||
|
@ -2601,12 +2576,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function importSaferPassCsv(file, success, error) {
|
function importSaferPassCsv(file, success, error) {
|
||||||
function urlDomain(data) {
|
|
||||||
var a = document.createElement('a');
|
|
||||||
a.href = data;
|
|
||||||
return a.hostname.startsWith('www.') ? a.hostname.replace('www.', '') : a.hostname;
|
|
||||||
}
|
|
||||||
|
|
||||||
var folders = [],
|
var folders = [],
|
||||||
ciphers = [];
|
ciphers = [];
|
||||||
|
|
||||||
|
@ -2621,7 +2590,7 @@
|
||||||
type: constants.cipherType.login,
|
type: constants.cipherType.login,
|
||||||
favorite: false,
|
favorite: false,
|
||||||
notes: value.notes && value.notes !== '' ? value.notes : null,
|
notes: value.notes && value.notes !== '' ? value.notes : null,
|
||||||
name: value.url && value.url !== '' ? urlDomain(value.url) : '--',
|
name: value.url && value.url !== '' ? loginNameFromUrl(value.url) : '--',
|
||||||
login: {
|
login: {
|
||||||
uris: makeUriArray(value.url),
|
uris: makeUriArray(value.url),
|
||||||
username: value.username && value.username !== '' ? value.username : null,
|
username: value.username && value.username !== '' ? value.username : null,
|
||||||
|
|
|
@ -36,16 +36,13 @@
|
||||||
'https://help.bitwarden.com/article/import-from-chrome/</a>')
|
'https://help.bitwarden.com/article/import-from-chrome/</a>')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'firefoxpasswordexportercsvxml',
|
id: 'firefoxpasswordexportercsv',
|
||||||
name: 'Firefox Password Exporter (xml)',
|
name: 'Firefox Password Exporter (csv)',
|
||||||
featured: true,
|
featured: true,
|
||||||
sort: 4,
|
sort: 4,
|
||||||
instructions: $sce.trustAsHtml('Use the ' +
|
instructions: $sce.trustAsHtml('Use the ' +
|
||||||
'<a target="_blank" href="https://addons.mozilla.org/en-US/firefox/addon/password-exporter/">' +
|
'<a target="_blank" href="https://github.com/kspearrin/ff-password-exporter#ff-password-exporter">' +
|
||||||
'Password Exporter</a> addon for FireFox to export your passwords to a XML file. After installing ' +
|
'FF Password Exporter</a> application to export your passwords to a CSV file.')
|
||||||
'the addon, type <code>about:addons</code> in your FireFox navigation bar. Locate the Password Exporter ' +
|
|
||||||
'addon and click the "Options" button. In the dialog that pops up, click the "Export Passwords" button ' +
|
|
||||||
'to save the XML file.')
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'keepass2xml',
|
id: 'keepass2xml',
|
||||||
|
|
Loading…
Reference in New Issue