mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-30 13:03:53 +01:00
splashid importer
This commit is contained in:
parent
1fe673951b
commit
8d50e96dab
@ -89,6 +89,9 @@
|
||||
case 'zohovaultcsv':
|
||||
importZohoVaultCsv(file, success, error);
|
||||
break;
|
||||
case 'splashidcsv':
|
||||
importSplashIdCsv(file, success, error);
|
||||
break;
|
||||
default:
|
||||
error();
|
||||
break;
|
||||
@ -2256,5 +2259,110 @@
|
||||
});
|
||||
}
|
||||
|
||||
function importSplashIdCsv(file, success, error) {
|
||||
Papa.parse(file, {
|
||||
encoding: 'UTF-8',
|
||||
complete: function (results) {
|
||||
parseCsvErrors(results);
|
||||
|
||||
var folders = [],
|
||||
logins = [],
|
||||
folderRelationships = [];
|
||||
|
||||
function parseFieldsToNotes(startIndex, row, login) {
|
||||
// last 3 rows do not get parsed
|
||||
for (var k = startIndex; k < row.length - 3; k++) {
|
||||
if (!row[k] || row[k] === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!login.notes) {
|
||||
login.notes = '';
|
||||
}
|
||||
else if (login.notes !== '') {
|
||||
login.notes += '\n';
|
||||
}
|
||||
|
||||
login.notes += row[k];
|
||||
}
|
||||
}
|
||||
|
||||
// skip 1st row since its not data
|
||||
for (var i = 1; i < results.data.length; i++) {
|
||||
if (results.data[i].length < 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var value = results.data[i],
|
||||
category = value[results.data.length - 1],
|
||||
notes = value[results.data.length - 2],
|
||||
type = value[0];
|
||||
|
||||
var folderIndex = folders.length,
|
||||
loginIndex = logins.length,
|
||||
hasFolder = category && category !== '' && category !== 'Unfiled',
|
||||
addFolder = hasFolder,
|
||||
j = 0;
|
||||
|
||||
if (hasFolder) {
|
||||
for (j = 0; j < folders.length; j++) {
|
||||
if (folders[j].name === category) {
|
||||
addFolder = false;
|
||||
folderIndex = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var login = {
|
||||
favorite: false,
|
||||
uri: null,
|
||||
username: null,
|
||||
password: null,
|
||||
notes: notes,
|
||||
name: value[1] && value[1] !== '' ? value[1] : '--'
|
||||
};
|
||||
|
||||
if (type === 'Web Logins' || type === 'Servers' || type === 'Email Accounts') {
|
||||
login.uri = value[4] && value[4] !== '' ? fixUri(value[4]) : null;
|
||||
login.username = value[2] && value[2] !== '' ? value[2] : null;
|
||||
login.password = value[3] && value[3] !== '' ? value[3] : null;
|
||||
parseFieldsToNotes(5, value, login);
|
||||
}
|
||||
else if (value.length > 2) {
|
||||
parseFieldsToNotes(2, value, login);
|
||||
}
|
||||
|
||||
if (login.name && login.name !== '--' && type !== 'Web Logins' && type !== 'Servers'
|
||||
&& type !== 'Email Accounts') {
|
||||
login.name = type + ': ' + login.name;
|
||||
}
|
||||
|
||||
if (login.notes === '') {
|
||||
login.notes = null;
|
||||
}
|
||||
|
||||
logins.push(login);
|
||||
|
||||
if (addFolder) {
|
||||
folders.push({
|
||||
name: category
|
||||
});
|
||||
}
|
||||
|
||||
if (hasFolder) {
|
||||
var relationship = {
|
||||
key: loginIndex,
|
||||
value: folderIndex
|
||||
};
|
||||
folderRelationships.push(relationship);
|
||||
}
|
||||
}
|
||||
|
||||
success(folders, logins, folderRelationships);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return _service;
|
||||
});
|
||||
|
@ -133,6 +133,12 @@
|
||||
'and copy the data from the textarea. Open a text editor like Notepad and paste the data. Save the ' +
|
||||
'data from the text editor as <code>zoho_export.csv</code>.')
|
||||
},
|
||||
{
|
||||
id: 'splashidcsv',
|
||||
name: 'SplashID (csv)',
|
||||
instructions: $sce.trustAsHtml('Using the SplashID Safe desktop application, click on the SplashID ' +
|
||||
'blue lock logo in the top right corner. Navigate to "Export" > "Export as CSV" and save the CSV file.')
|
||||
},
|
||||
{
|
||||
id: 'passworddragonxml',
|
||||
name: 'Password Dragon (xml)',
|
||||
|
Loading…
Reference in New Issue
Block a user