|
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
|
|
|
|
|
24
|
|
|
/** global: PassmanExporter */ |
|
25
|
|
|
PassmanExporter.json = { |
|
26
|
|
|
info: { |
|
27
|
|
|
name: 'JSON', |
|
28
|
|
|
id: 'json', |
|
29
|
|
|
description: 'Export credentials as a JSON file.' |
|
30
|
|
|
} |
|
31
|
|
|
}; |
|
32
|
|
|
|
|
33
|
|
|
PassmanExporter.json.export = function (credentials, FileService, EncryptService) { |
|
34
|
|
|
/** global: C_Promise */ |
|
35
|
|
|
return new C_Promise(function () { |
|
36
|
|
|
PassmanExporter.getCredentialsWithFiles(credentials, FileService, EncryptService).then((function(){ |
|
37
|
|
|
var _output = []; |
|
38
|
|
|
for (var i = 0; i < credentials.length; i++) { |
|
39
|
|
|
var _credential = angular.copy(credentials[i]); |
|
40
|
|
|
|
|
41
|
|
|
delete _credential.vault_key; |
|
42
|
|
|
delete _credential.vault_id; |
|
43
|
|
|
delete _credential.shared_key; |
|
44
|
|
|
|
|
45
|
|
|
_output.push(_credential); |
|
46
|
|
|
|
|
47
|
|
|
var progress = { |
|
48
|
|
|
percent: i / credentials.length * 100, |
|
49
|
|
|
loaded: i, |
|
50
|
|
|
total: credentials.length |
|
51
|
|
|
}; |
|
52
|
|
|
this.call_progress(progress); |
|
53
|
|
|
} |
|
54
|
|
|
var file_data = JSON.stringify(_output); |
|
55
|
|
|
this.call_then(); |
|
56
|
|
|
download(file_data, 'passman-export.json'); |
|
57
|
|
|
}).bind(this)).progress(function() { |
|
58
|
|
|
|
|
59
|
|
|
}); |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
}); |
|
63
|
|
|
}; |
|
64
|
|
|
|