1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-06 09:20:43 +01:00

saferpass csv importer

This commit is contained in:
Kyle Spearrin 2016-12-31 16:24:11 -05:00
parent 53fcfd13ee
commit f186ec160a
2 changed files with 121 additions and 84 deletions

View File

@ -4,6 +4,85 @@
.factory('importService', function () { .factory('importService', function () {
var _service = {}; var _service = {};
_service.import = function (source, file, success, error) {
if (!file) {
error();
return;
}
switch (source) {
case 'local':
importLocal(file, success, error);
break;
case 'lastpass':
importLastPass(file, success, error);
break;
case 'safeincloudcsv':
importSafeInCloudCsv(file, success, error);
break;
case 'safeincloudxml':
importSafeInCloudXml(file, success, error);
break;
case 'keepassxml':
importKeePassXml(file, success, error);
break;
case 'padlockcsv':
importPadlockCsv(file, success, error);
break;
case '1password1pif':
import1Password1Pif(file, success, error);
break;
case 'chromecsv':
importChromeCsv(file, success, error);
break;
case 'firefoxpasswordexportercsvxml':
importFirefoxPasswordExporterCsvXml(file, success, error);
break;
case 'upmcsv':
importUpmCsv(file, success, error);
break;
case 'keepercsv':
importKeeperCsv(file, success, error);
break;
case 'passworddragonxml':
importPasswordDragonXml(file, success, error);
break;
case 'enpasscsv':
importEnpassCsv(file, success, error);
break;
case 'pwsafexml':
importPasswordSafeXml(file, success, error);
break;
case 'dashlanecsv':
importDashlaneCsv(file, success, error);
break;
case 'stickypasswordxml':
importStickyPasswordXml(file, success, error);
break;
case 'msecurecsv':
importmSecureCsv(file, success, error);
break;
case 'truekeyjson':
importTrueKeyJson(file, success, error);
break;
case 'clipperzhtml':
importClipperzHtml(file, success, error);
break;
case 'avirajson':
importAviraJson(file, success, error);
break;
case 'roboformhtml':
importRoboFormHtml(file, success, error);
break;
case 'saferpasscsv':
importSaferPassCsv(file, success, error);
break;
default:
error();
break;
}
};
var _passwordFieldNames = [ var _passwordFieldNames = [
'password', 'pass word', 'passphrase', 'pass phrase', 'password', 'pass word', 'passphrase', 'pass phrase',
'pass', 'code', 'code word', 'codeword', 'pass', 'code', 'code word', 'codeword',
@ -63,82 +142,6 @@
return false; return false;
} }
_service.import = function (source, file, success, error) {
if (!file) {
error();
return;
}
switch (source) {
case 'local':
importLocal(file, success, error);
break;
case 'lastpass':
importLastPass(file, success, error);
break;
case 'safeincloudcsv':
importSafeInCloudCsv(file, success, error);
break;
case 'safeincloudxml':
importSafeInCloudXml(file, success, error);
break;
case 'keypassxml':
importKeyPassXml(file, success, error);
break;
case 'padlockcsv':
importPadlockCsv(file, success, error);
break;
case '1password1pif':
import1Password1Pif(file, success, error);
break;
case 'chromecsv':
importChromeCsv(file, success, error);
break;
case 'firefoxpasswordexportercsvxml':
importFirefoxPasswordExporterCsvXml(file, success, error);
break;
case 'upmcsv':
importUpmCsv(file, success, error);
break;
case 'keepercsv':
importKeeperCsv(file, success, error);
break;
case 'passworddragonxml':
importPasswordDragonXml(file, success, error);
break;
case 'enpasscsv':
importEnpassCsv(file, success, error);
break;
case 'pwsafexml':
importPasswordSafeXml(file, success, error);
break;
case 'dashlanecsv':
importDashlaneCsv(file, success, error);
break;
case 'stickypasswordxml':
importStickyPasswordXml(file, success, error);
break;
case 'msecurecsv':
importmSecureCsv(file, success, error);
break;
case 'truekeyjson':
importTrueKeyJson(file, success, error);
break;
case 'clipperzhtml':
importClipperzHtml(file, success, error);
break;
case 'avirajson':
importAviraJson(file, success, error);
break;
case 'roboformhtml':
importRoboFormHtml(file, success, error);
break;
default:
error();
break;
}
};
function trimUri(uri) { function trimUri(uri) {
if (uri.length > 1000) { if (uri.length > 1000) {
return uri.substring(0, 1000); return uri.substring(0, 1000);
@ -530,7 +533,7 @@
}); });
} }
function importKeyPassXml(file, success, error) { function importKeePassXml(file, success, error) {
var folders = [], var folders = [],
sites = [], sites = [],
siteRelationships = []; siteRelationships = [];
@ -1840,5 +1843,38 @@
}; };
} }
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 = [],
sites = [],
siteRelationships = [];
Papa.parse(file, {
header: true,
encoding: 'UTF-8',
complete: function (results) {
parseCsvErrors(results);
angular.forEach(results.data, function (value, key) {
sites.push({
favorite: false,
uri: value.url && value.url !== '' ? trimUri(value.url) : null,
username: value.username && value.username !== '' ? value.username : null,
password: value.password && value.password !== '' ? value.password : null,
notes: value.notes && value.notes !== '' ? value.notes : null,
name: value.url && value.url !== '' ? urlDomain(value.url) : '--',
});
});
success(folders, sites, siteRelationships);
}
});
}
return _service; return _service;
}); });

View File

@ -11,23 +11,24 @@
<option value="lastpass">LastPass (csv)</option> <option value="lastpass">LastPass (csv)</option>
<option value="chromecsv">Chrome (csv)</option> <option value="chromecsv">Chrome (csv)</option>
<option value="firefoxpasswordexportercsvxml">Firefox Password Exporter (xml)</option> <option value="firefoxpasswordexportercsvxml">Firefox Password Exporter (xml)</option>
<option value="safeincloudxml">SafeInCloud (xml)</option> <option value="keepassxml">KeePass (xml)</option>
<option value="safeincloudcsv">SafeInCloud (csv)</option>
<option value="keypassxml">KeyPass (xml)</option>
<option value="padlockcsv">Padlock (csv)</option>
<option value="dashlanecsv">Dashlane (csv)</option> <option value="dashlanecsv">Dashlane (csv)</option>
<option value="1password1pif">1Password (1pif)</option> <option value="1password1pif">1Password (1pif)</option>
<option value="upmcsv">Universal Password Manager (csv)</option> <option value="roboformhtml">RoboForm (html)</option>
<option value="keepercsv">Keeper (csv)</option> <option value="keepercsv">Keeper (csv)</option>
<option value="passworddragonxml">Password Dragon (xml)</option>
<option value="enpasscsv">Enpass (csv)</option> <option value="enpasscsv">Enpass (csv)</option>
<option value="safeincloudxml">SafeInCloud (xml)</option>
<option value="safeincloudcsv">SafeInCloud (csv)</option>
<option value="padlockcsv">Padlock (csv)</option>
<option value="passworddragonxml">Password Dragon (xml)</option>
<option value="pwsafexml">Password Safe (xml)</option> <option value="pwsafexml">Password Safe (xml)</option>
<option value="stickypasswordxml">Sticky Password (xml)</option> <option value="stickypasswordxml">Sticky Password (xml)</option>
<option value="msecurecsv">mSecure (csv)</option> <option value="msecurecsv">mSecure (csv)</option>
<option value="truekeyjson">True Key (json)</option> <option value="truekeyjson">True Key (json)</option>
<option value="clipperzhtml">Clipperz (html)</option> <option value="clipperzhtml">Clipperz (html)</option>
<option value="avirajson">Avira (json)</option> <option value="avirajson">Avira (json)</option>
<option value="roboformhtml">RoboForm (html)</option> <option value="saferpasscsv">SaferPass (csv)</option>
<option value="upmcsv">Universal Password Manager (csv)</option>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">