From 8d50e96dab9a5aef45c54e04d05f5c3fcb4806dc Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 28 Jan 2017 01:57:36 -0500 Subject: [PATCH] splashid importer --- src/app/services/importService.js | 108 +++++++++++++++++++++++++ src/app/tools/toolsImportController.js | 6 ++ 2 files changed, 114 insertions(+) diff --git a/src/app/services/importService.js b/src/app/services/importService.js index fe51023ffb..2f0ab171ae 100644 --- a/src/app/services/importService.js +++ b/src/app/services/importService.js @@ -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; }); diff --git a/src/app/tools/toolsImportController.js b/src/app/tools/toolsImportController.js index 09073076fa..43ce6f8c27 100644 --- a/src/app/tools/toolsImportController.js +++ b/src/app/tools/toolsImportController.js @@ -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 zoho_export.csv.') }, + { + 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)',