1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

avira json importer

This commit is contained in:
Kyle Spearrin 2016-12-31 01:00:51 -05:00
parent 1f6677d610
commit 6aaa47cccd
2 changed files with 58 additions and 0 deletions

View File

@ -68,6 +68,9 @@
case 'clipperzhtml': case 'clipperzhtml':
importClipperzHtml(file, success, error); importClipperzHtml(file, success, error);
break; break;
case 'avirajson':
importAviraJson(file, success, error);
break;
default: default:
error(); error();
break; break;
@ -1645,5 +1648,59 @@
}; };
} }
function importAviraJson(file, success, error) {
var folders = [],
sites = [],
siteRelationships = [],
i = 0;
var reader = new FileReader();
reader.readAsText(file, 'utf-8');
reader.onload = function (evt) {
var fileContent = evt.target.result;
var fileJson = JSON.parse(fileContent);
if (fileJson) {
if (fileJson.accounts) {
for (i = 0; i < fileJson.accounts.length; i++) {
var account = fileJson.accounts[i];
var site = {
favorite: account.is_favorite && account.is_favorite === true,
uri: account.domain && account.domain !== '' ? trimUri(account.domain) : null,
username: account.username && account.username !== '' ? account.username : null,
password: account.password && account.password !== '' ? account.password : null,
notes: null,
name: account.label && account.label !== '' ? account.label : account.domain,
};
if (account.email && account.email !== '') {
if (!site.username || site.username === '') {
site.username = account.email;
}
else {
site.notes = account.email;
}
}
if (!site.name || site.name === '') {
site.name = '--';
}
if (site.uri && !site.uri.startsWith('http')) {
site.uri = 'http://' + site.uri;
}
sites.push(site);
}
}
}
success(folders, sites, siteRelationships);
};
reader.onerror = function (evt) {
error();
};
}
return _service; return _service;
}); });

View File

@ -26,6 +26,7 @@
<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>
</select> </select>
</div> </div>
<div class="form-group"> <div class="form-group">