mirror of
https://github.com/bitwarden/browser.git
synced 2024-09-18 02:41:15 +02:00
updated truekey importer to their new csv format
This commit is contained in:
parent
7bdda34f14
commit
7666d6136d
@ -65,8 +65,8 @@
|
|||||||
case 'msecurecsv':
|
case 'msecurecsv':
|
||||||
importmSecureCsv(file, success, error);
|
importmSecureCsv(file, success, error);
|
||||||
break;
|
break;
|
||||||
case 'truekeyjson':
|
case 'truekeycsv':
|
||||||
importTrueKeyJson(file, success, error);
|
importTrueKeyCsv(file, success, error);
|
||||||
break;
|
break;
|
||||||
case 'clipperzhtml':
|
case 'clipperzhtml':
|
||||||
importClipperzHtml(file, success, error);
|
importClipperzHtml(file, success, error);
|
||||||
@ -1692,84 +1692,71 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function importTrueKeyJson(file, success, error) {
|
function importTrueKeyCsv(file, success, error) {
|
||||||
var folders = [],
|
var folders = [],
|
||||||
logins = [],
|
logins = [],
|
||||||
loginRelationships = [],
|
loginRelationships = [],
|
||||||
i = 0;
|
propsToIgnore = [
|
||||||
|
'kind',
|
||||||
|
'autologin',
|
||||||
|
'favorite',
|
||||||
|
'hexcolor',
|
||||||
|
'protectedwithpassword',
|
||||||
|
'subdomainonly',
|
||||||
|
'type',
|
||||||
|
'tk_export_version',
|
||||||
|
'note',
|
||||||
|
'title',
|
||||||
|
'document_content'
|
||||||
|
];
|
||||||
|
|
||||||
var reader = new FileReader();
|
Papa.parse(file, {
|
||||||
reader.readAsText(file, 'utf-8');
|
header: true,
|
||||||
reader.onload = function (evt) {
|
encoding: 'UTF-8',
|
||||||
var fileContent = evt.target.result;
|
complete: function (results) {
|
||||||
var fileJson = JSON.parse(fileContent);
|
parseCsvErrors(results);
|
||||||
if (fileJson) {
|
|
||||||
if (fileJson.logins) {
|
|
||||||
for (i = 0; i < fileJson.logins.length; i++) {
|
|
||||||
var login = fileJson.logins[i];
|
|
||||||
logins.push({
|
|
||||||
favorite: login.favorite && login.favorite === true,
|
|
||||||
uri: login.url && login.url !== '' ? trimUri(login.url) : null,
|
|
||||||
username: login.login && login.login !== '' ? login.login : null,
|
|
||||||
password: login.password && login.password !== '' ? login.password : null,
|
|
||||||
notes: null,
|
|
||||||
name: login.name && login.name !== '' ? login.name : '--',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fileJson.documents) {
|
angular.forEach(results.data, function (value, key) {
|
||||||
for (i = 0; i < fileJson.documents.length; i++) {
|
var login = {
|
||||||
var doc = fileJson.documents[i];
|
favorite: value.favorite && value.favorite.toLowerCase() === 'true' ? true : false,
|
||||||
var note = {
|
uri: value.url && value.url !== '' ? trimUri(value.url) : null,
|
||||||
favorite: false,
|
username: value.login && value.login !== '' ? value.login : null,
|
||||||
uri: null,
|
password: value.password && value.password !== '' ? value.password : null,
|
||||||
username: null,
|
notes: value.memo && value.memo !== '' ? value.memo : null,
|
||||||
password: null,
|
name: value.name && value.name !== '' ? value.name : '--'
|
||||||
notes: '',
|
};
|
||||||
name: doc.title && doc.title !== '' ? doc.title : '--',
|
|
||||||
};
|
|
||||||
|
|
||||||
if (doc.kind === 'note') {
|
if (value.kind !== 'login') {
|
||||||
if (!doc.document_content || doc.document_content === '') {
|
login.name = value.title && value.title !== '' ? value.title : '--';
|
||||||
continue;
|
login.notes = value.note && value.note !== '' ? value.note : null;
|
||||||
}
|
|
||||||
note.notes = doc.document_content;
|
if (!login.notes) {
|
||||||
|
login.notes = value.document_content && value.document_content !== '' ?
|
||||||
|
value.document_content : null;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
for (var property in doc) {
|
|
||||||
if (doc.hasOwnProperty(property)) {
|
|
||||||
if (property === 'title' || property === 'hexColor' || property === 'kind' ||
|
|
||||||
doc[property] === '' || doc[property] === null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (note.notes !== '') {
|
for (var property in value) {
|
||||||
note.notes = note.notes + '\n';
|
if (value.hasOwnProperty(property) && propsToIgnore.indexOf(property.toLowerCase()) < 0 &&
|
||||||
}
|
value[property] && value[property] !== '') {
|
||||||
note.notes = note.notes + property + ': ' + doc[property];
|
if (!login.notes) {
|
||||||
|
login.notes = '';
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
login.notes += '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
// other custom fields
|
||||||
|
login.notes += (property + ': ' + value[property]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!note.notes || note.notes === '') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
note.notes = note.notes.split('\\n').join('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
logins.push(note);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
logins.push(login);
|
||||||
|
});
|
||||||
|
|
||||||
|
success(folders, logins, loginRelationships);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
success(folders, logins, loginRelationships);
|
|
||||||
};
|
|
||||||
|
|
||||||
reader.onerror = function (evt) {
|
|
||||||
error();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function importClipperzHtml(file, success, error) {
|
function importClipperzHtml(file, success, error) {
|
||||||
|
@ -114,10 +114,10 @@
|
|||||||
'"Export" > "CSV File..." and save the CSV file.')
|
'"Export" > "CSV File..." and save the CSV file.')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'truekeyjson',
|
id: 'truekeycsv',
|
||||||
name: 'True Key (json)',
|
name: 'True Key (csv)',
|
||||||
instructions: $sce.trustAsHtml('Using the True Key desktop application, click the gear icon (top right) and ' +
|
instructions: $sce.trustAsHtml('Using the True Key desktop application, click the gear icon (top right) and ' +
|
||||||
'then navigate to "App Settings". Click the "Export" button and save the JSON file.')
|
'then navigate to "App Settings". Click the "Export" button, enter your password and save the CSV file.')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'passwordbossjson',
|
id: 'passwordbossjson',
|
||||||
|
Loading…
Reference in New Issue
Block a user