|
1
|
|
|
/** |
|
2
|
|
|
* Nextcloud - passman |
|
3
|
|
|
* |
|
4
|
|
|
* @copyright Copyright (c) 2016, Sander Brand ([email protected]) |
|
5
|
|
|
* @copyright Copyright (c) 2016, Marcos Zuriaga Miguel ([email protected]) |
|
6
|
|
|
* @license GNU AGPL version 3 or any later version |
|
7
|
|
|
* |
|
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
9
|
|
|
* it under the terms of the GNU Affero General Public License as |
|
10
|
|
|
* published by the Free Software Foundation, either version 3 of the |
|
11
|
|
|
* License, or (at your option) any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* This program is distributed in the hope that it will be useful, |
|
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16
|
|
|
* GNU Affero General Public License for more details. |
|
17
|
|
|
* |
|
18
|
|
|
* You should have received a copy of the GNU Affero General Public License |
|
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
20
|
|
|
* |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
// Importers should always start with this |
|
24
|
|
|
/** global: PassmanImporter */ |
|
25
|
|
|
var PassmanImporter = PassmanImporter || {}; |
|
26
|
|
|
(function (window, $, PassmanImporter) { |
|
27
|
|
|
'use strict'; |
|
28
|
|
|
// Define the importer |
|
29
|
|
|
var steps = [ |
|
30
|
|
|
'Backups for the Passwords app need to be enabled on the Admin panel (they are disabled by default).', |
|
31
|
|
|
'On the Passwords App, in the bottom left corner, press Settings', |
|
32
|
|
|
'Press "Download Backup"', |
|
33
|
|
|
'Confirm the export and save the file' |
|
34
|
|
|
]; |
|
35
|
|
|
PassmanImporter.passwordsApp = { |
|
36
|
|
|
info: { |
|
37
|
|
|
name: 'Passwords App csv', |
|
38
|
|
|
id: 'passwordsApp', |
|
39
|
|
|
exportSteps: steps |
|
40
|
|
|
} |
|
41
|
|
|
}; |
|
42
|
|
|
|
|
43
|
|
|
PassmanImporter.passwordsApp.readFile = function (file_data) { |
|
44
|
|
|
/** global: C_Promise */ |
|
45
|
|
|
var p = new C_Promise(function () { |
|
46
|
|
|
var parsed_csv = PassmanImporter.readCsv(file_data); |
|
47
|
|
|
var credential_list = []; |
|
48
|
|
|
for (var i = 0; i < parsed_csv.length; i++) { |
|
49
|
|
|
var row = parsed_csv[i]; |
|
50
|
|
|
var _credential = PassmanImporter.newCredential(); |
|
51
|
|
|
_credential.label = row.website + ' - '+ row.username; |
|
52
|
|
|
_credential.username = row.username; |
|
53
|
|
|
_credential.password = row.password; |
|
54
|
|
|
_credential.url = row.fulladdress; |
|
55
|
|
|
_credential.description = row.notes; |
|
56
|
|
|
|
|
57
|
|
|
credential_list.push(_credential); |
|
58
|
|
|
|
|
59
|
|
|
var progress = { |
|
60
|
|
|
percent: i / parsed_csv.length * 100, |
|
61
|
|
|
loaded: i, |
|
62
|
|
|
total: parsed_csv.length |
|
63
|
|
|
}; |
|
64
|
|
|
|
|
65
|
|
|
this.call_progress(progress); |
|
66
|
|
|
} |
|
67
|
|
|
this.call_then(credential_list); |
|
68
|
|
|
}); |
|
69
|
|
|
return p; |
|
70
|
|
|
}; |
|
71
|
|
|
})(window, $, PassmanImporter); |
|
72
|
|
|
|