mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-26 17:08:33 +01:00
add support for passkeep csv import
This commit is contained in:
parent
6a292d6905
commit
9918e903b2
@ -95,6 +95,9 @@
|
||||
case 'meldiumcsv':
|
||||
importMeldiumCsv(file, success, error);
|
||||
break;
|
||||
case 'passkeepcsv':
|
||||
importPassKeepCsv(file, success, error);
|
||||
break;
|
||||
default:
|
||||
error();
|
||||
break;
|
||||
@ -2369,5 +2372,84 @@
|
||||
});
|
||||
}
|
||||
|
||||
function importPassKeepCsv(file, success, error) {
|
||||
function getValue(key, obj) {
|
||||
var val = obj[key] || obj[(' ' + key)];
|
||||
if (val && val !== '') {
|
||||
return val;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Papa.parse(file, {
|
||||
header: true,
|
||||
encoding: 'UTF-8',
|
||||
complete: function (results) {
|
||||
parseCsvErrors(results);
|
||||
|
||||
var folders = [],
|
||||
logins = [],
|
||||
folderRelationships = [];
|
||||
|
||||
angular.forEach(results.data, function (value, key) {
|
||||
var folderIndex = folders.length,
|
||||
loginIndex = logins.length,
|
||||
hasFolder = !!getValue('category', value),
|
||||
addFolder = hasFolder,
|
||||
i = 0;
|
||||
|
||||
if (hasFolder) {
|
||||
for (i = 0; i < folders.length; i++) {
|
||||
if (folders[i].name === getValue('category', value)) {
|
||||
addFolder = false;
|
||||
folderIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var login = {
|
||||
favorite: false,
|
||||
uri: !!getValue('site', value) ? fixUri(getValue('site', value)) : null,
|
||||
username: !!getValue('username', value) ? getValue('username', value) : null,
|
||||
password: !!getValue('password', value) ? getValue('password', value) : null,
|
||||
notes: !!getValue('description', value) ? getValue('description', value) : null,
|
||||
name: !!getValue('title', value) ? getValue('title', value) : '--'
|
||||
};
|
||||
|
||||
if (!!getValue('password2', value)) {
|
||||
if (!login.notes) {
|
||||
login.notes = '';
|
||||
}
|
||||
else {
|
||||
login.notes += '\n';
|
||||
}
|
||||
|
||||
login.notes += ('Password 2: ' + getValue('password2', value));
|
||||
}
|
||||
|
||||
logins.push(login);
|
||||
|
||||
if (addFolder) {
|
||||
folders.push({
|
||||
name: getValue('category', value)
|
||||
});
|
||||
}
|
||||
|
||||
if (hasFolder) {
|
||||
var relationship = {
|
||||
key: loginIndex,
|
||||
value: folderIndex
|
||||
};
|
||||
folderRelationships.push(relationship);
|
||||
}
|
||||
});
|
||||
|
||||
success(folders, logins, folderRelationships);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return _service;
|
||||
});
|
||||
|
@ -196,6 +196,12 @@
|
||||
name: 'Meldium (csv)',
|
||||
instructions: $sce.trustAsHtml('Using the Meldium web vault, navigate to "Settings". ' +
|
||||
'Locate the "Export data" function and click "Show me my data" to save the CSV file.')
|
||||
},
|
||||
{
|
||||
id: 'passkeepcsv',
|
||||
name: 'PassKeep (csv)',
|
||||
instructions: $sce.trustAsHtml('Using the PassKeep mobile app, navigate to "Backup/Restore". ' +
|
||||
'Locate the "CSV Backup/Restore" section and click "Backup to CSV" to save the CSV file.')
|
||||
}
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user