1
|
|
|
// Importers should always start with this |
2
|
|
|
var PassmanImporter = PassmanImporter || {}; |
|
|
|
|
3
|
|
|
(function(window, $, PassmanImporter) { |
4
|
|
|
'use strict'; |
5
|
|
|
PassmanImporter.clippers = { |
6
|
|
|
info: { |
7
|
|
|
name: 'Clipperz.is', |
8
|
|
|
id: 'clippers', |
9
|
|
|
description: 'Go to menu -> Export -> Download HTML + JSON. Fields will be imported as custom fields.' |
10
|
|
|
} |
11
|
|
|
}; |
12
|
|
|
|
13
|
|
|
PassmanImporter.clippers.readFile = function (file_data) { |
14
|
|
|
return new C_Promise(function() { |
|
|
|
|
15
|
|
|
var credential_list = []; |
16
|
|
|
var re = /<textarea>(.*?)<\/textarea>/gi; |
17
|
|
|
var matches = re.exec(file_data); |
18
|
|
|
if(matches){ |
19
|
|
|
var raw_json = matches[0].substring(10); |
20
|
|
|
raw_json = PassmanImporter.htmlDecode(raw_json.slice(0, -11)); |
21
|
|
|
var json_objects = PassmanImporter.readJson(raw_json); |
22
|
|
|
for(var i = 0; i < json_objects.length; i++){ |
23
|
|
|
var card = json_objects[i]; |
24
|
|
|
re = /(\w+)/gi; |
25
|
|
|
var tags = card.label.match(re); |
26
|
|
|
card.label = card.label.replace(tags.join(' '), '').trim(); |
27
|
|
|
tags = tags.map(function(item){ return {text: item.replace('', '') }}); |
|
|
|
|
28
|
|
|
|
29
|
|
|
|
30
|
|
|
var _credential = PassmanImporter.newCredential(); |
31
|
|
|
_credential.label = card.label; |
32
|
|
|
_credential.description = card.data.notes; |
33
|
|
|
_credential.tags = tags; |
34
|
|
|
for(var field in card.currentVersion.fields){ |
|
|
|
|
35
|
|
|
var field_data = card.currentVersion.fields[field]; |
36
|
|
|
_credential.custom_fields.push( |
37
|
|
|
{ |
38
|
|
|
'label': field_data.label, |
39
|
|
|
'value': field_data.value, |
40
|
|
|
'secret': (field_data.hidden == true) |
|
|
|
|
41
|
|
|
} |
42
|
|
|
) |
|
|
|
|
43
|
|
|
} |
44
|
|
|
if(_credential.label){ |
45
|
|
|
credential_list.push(_credential); |
46
|
|
|
} |
47
|
|
|
var progress = { |
48
|
|
|
percent: i/json_objects.length*100, |
49
|
|
|
loaded: i, |
50
|
|
|
total: json_objects.length |
51
|
|
|
}; |
52
|
|
|
this.call_progress(progress); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
this.call_then(credential_list); |
56
|
|
|
}); |
57
|
|
|
}; |
58
|
|
|
})(window, $, PassmanImporter); |
59
|
|
|
|