1
|
|
|
// Importers should always start with this |
2
|
|
|
var PassmanImporter = PassmanImporter || {}; |
|
|
|
|
3
|
|
|
(function(window, $, PassmanImporter) { |
4
|
|
|
'use strict'; |
5
|
|
|
// Define the importer |
6
|
|
|
PassmanImporter.dashLaneCsv = { |
7
|
|
|
info: { |
8
|
|
|
name: 'Dashlane 4 csv', |
9
|
|
|
id: 'dashLaneCsv', |
10
|
|
|
description: 'Create an csv export. Go to File -> export -> Unsecured archive (readable) in CSV format' |
11
|
|
|
} |
12
|
|
|
}; |
13
|
|
|
|
14
|
|
|
PassmanImporter.dashLaneCsv.readFile = function (file_data) { |
15
|
|
|
return new C_Promise(function(){ |
|
|
|
|
16
|
|
|
var rows = file_data.split('\n'); |
17
|
|
|
var credential_list = []; |
18
|
|
|
for (var i = 0; i < rows.length; i++) { |
19
|
|
|
var row = rows[i]; |
20
|
|
|
var row_data = row.split('","'); |
21
|
|
|
if (row_data[0].charAt(0) == '"') { |
22
|
|
|
row_data[0] = row_data[0].substring(1); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
if (row_data[row_data.length-1].toString().charAt(row_data[row_data.length - 1].length - 1) == '"') { |
26
|
|
|
row_data[row_data.length - 1] = row_data[row_data.length -1].substring(0, row_data[row_data.length - 1].length - 1); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
var _credential = PassmanImporter.newCredential(); |
30
|
|
|
_credential.label = row_data[0]; |
31
|
|
|
_credential.username = row_data[2]; |
32
|
|
|
_credential.password = row_data[row_data.length - 2]; |
33
|
|
|
_credential.url = row_data[0]; |
34
|
|
|
_credential.description = row_data[row_data.length - 1]; |
35
|
|
|
if(_credential.label){ |
36
|
|
|
credential_list.push(_credential); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
var progress = { |
40
|
|
|
percent: i/rows.length*100, |
41
|
|
|
loaded: i, |
42
|
|
|
total: rows.length |
43
|
|
|
}; |
44
|
|
|
this.call_progress(progress); |
45
|
|
|
} |
46
|
|
|
this.call_then(credential_list); |
47
|
|
|
}); |
48
|
|
|
}; |
49
|
|
|
})(window, $, PassmanImporter); |
50
|
|
|
|