Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js b/frontend/beta/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js index 4d3ba08..d5336be 100644 --- a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js +++ b/frontend/beta/js/Clipperz/PM/Proxy/Proxy.Offline.DataStore.js | |||
@@ -1,152 +1,149 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | it and/or modify it under the terms of the GNU Affero General Public |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | try { if (typeof(Clipperz.PM.Proxy.Offline) == 'undefined') { throw ""; }} catch (e) { | 26 | try { if (typeof(Clipperz.PM.Proxy.Offline) == 'undefined') { throw ""; }} catch (e) { |
30 | throw "Clipperz.PM.Proxy.Offline.DataStore depends on Clipperz.PM.Proxy.Offline!"; | 27 | throw "Clipperz.PM.Proxy.Offline.DataStore depends on Clipperz.PM.Proxy.Offline!"; |
31 | } | 28 | } |
32 | 29 | ||
33 | //============================================================================= | 30 | //============================================================================= |
34 | 31 | ||
35 | Clipperz.PM.Proxy.Offline.DataStore = function(args) { | 32 | Clipperz.PM.Proxy.Offline.DataStore = function(args) { |
36 | args = args || {}; | 33 | args = args || {}; |
37 | 34 | ||
38 | this._data = args.data || (typeof(_clipperz_dump_data_) != 'undefined' ? _clipperz_dump_data_ : null); | 35 | this._data = args.data || (typeof(_clipperz_dump_data_) != 'undefined' ? _clipperz_dump_data_ : null); |
39 | this._isReadOnly = (typeof(args.readOnly) == 'undefined' ? true : args.readOnly); | 36 | this._isReadOnly = (typeof(args.readOnly) == 'undefined' ? true : args.readOnly); |
40 | this._shouldPayTolls = args.shouldPayTolls || false; | 37 | this._shouldPayTolls = args.shouldPayTolls || false; |
41 | 38 | ||
42 | this._tolls = {}; | 39 | this._tolls = {}; |
43 | this._connections = {}; | 40 | this._connections = {}; |
44 | 41 | ||
45 | this._b = null; | 42 | this._b = null; |
46 | this._B = null; | 43 | this._B = null; |
47 | this._A = null; | 44 | this._A = null; |
48 | this._userData = null; | 45 | this._userData = null; |
49 | 46 | ||
50 | return this; | 47 | return this; |
51 | } | 48 | } |
52 | 49 | ||
53 | //Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, { | 50 | //Clipperz.Base.extend(Clipperz.PM.Proxy.Offline.DataStore, Object, { |
54 | Clipperz.PM.Proxy.Offline.DataStore.prototype = MochiKit.Base.update(null, { | 51 | Clipperz.PM.Proxy.Offline.DataStore.prototype = MochiKit.Base.update(null, { |
55 | 52 | ||
56 | //------------------------------------------------------------------------- | 53 | //------------------------------------------------------------------------- |
57 | 54 | ||
58 | 'isReadOnly': function () { | 55 | 'isReadOnly': function () { |
59 | return this._isReadOnly; | 56 | return this._isReadOnly; |
60 | }, | 57 | }, |
61 | 58 | ||
62 | //------------------------------------------------------------------------- | 59 | //------------------------------------------------------------------------- |
63 | 60 | ||
64 | 'shouldPayTolls': function() { | 61 | 'shouldPayTolls': function() { |
65 | return this._shouldPayTolls; | 62 | return this._shouldPayTolls; |
66 | }, | 63 | }, |
67 | 64 | ||
68 | //------------------------------------------------------------------------- | 65 | //------------------------------------------------------------------------- |
69 | 66 | ||
70 | 'data': function () { | 67 | 'data': function () { |
71 | return this._data; | 68 | return this._data; |
72 | }, | 69 | }, |
73 | 70 | ||
74 | //------------------------------------------------------------------------- | 71 | //------------------------------------------------------------------------- |
75 | 72 | ||
76 | 'tolls': function () { | 73 | 'tolls': function () { |
77 | return this._tolls; | 74 | return this._tolls; |
78 | }, | 75 | }, |
79 | 76 | ||
80 | //------------------------------------------------------------------------- | 77 | //------------------------------------------------------------------------- |
81 | 78 | ||
82 | 'connections': function () { | 79 | 'connections': function () { |
83 | return this._connections; | 80 | return this._connections; |
84 | }, | 81 | }, |
85 | 82 | ||
86 | //========================================================================= | 83 | //========================================================================= |
87 | 84 | ||
88 | 'resetData': function() { | 85 | 'resetData': function() { |
89 | this._data = { | 86 | this._data = { |
90 | 'users': { | 87 | 'users': { |
91 | 'catchAllUser': { | 88 | 'catchAllUser': { |
92 | __masterkey_test_value__: 'masterkey', | 89 | __masterkey_test_value__: 'masterkey', |
93 | s: '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00', | 90 | s: '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00', |
94 | v: '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00' | 91 | v: '112233445566778899aabbccddeeff00112233445566778899aabbccddeeff00' |
95 | } | 92 | } |
96 | } | 93 | } |
97 | }; | 94 | }; |
98 | }, | 95 | }, |
99 | 96 | ||
100 | //------------------------------------------------------------------------- | 97 | //------------------------------------------------------------------------- |
101 | 98 | ||
102 | 'setupWithEncryptedData': function(someData) { | 99 | 'setupWithEncryptedData': function(someData) { |
103 | this._data = Clipperz.Base.deepClone(someData); | 100 | this._data = Clipperz.Base.deepClone(someData); |
104 | }, | 101 | }, |
105 | 102 | ||
106 | //------------------------------------------------------------------------- | 103 | //------------------------------------------------------------------------- |
107 | 104 | ||
108 | 'setupWithData': function(someData) { | 105 | 'setupWithData': function(someData) { |
109 | var deferredResult; | 106 | var deferredResult; |
110 | var resultData; | 107 | var resultData; |
111 | var i, c; | 108 | var i, c; |
112 | 109 | ||
113 | //Clipperz.log(">>> Proxy.Test.setupWithData"); | 110 | //Clipperz.log(">>> Proxy.Test.setupWithData"); |
114 | resultData = this._data; | 111 | resultData = this._data; |
115 | 112 | ||
116 | deferredResult = new MochiKit.Async.Deferred(); | 113 | deferredResult = new MochiKit.Async.Deferred(); |
117 | c = someData['users'].length; | 114 | c = someData['users'].length; |
118 | 115 | ||
119 | for (i=0; i<c; i++) { | 116 | for (i=0; i<c; i++) { |
120 | varnewConnection; | 117 | varnewConnection; |
121 | varrecordConfiguration; | 118 | varrecordConfiguration; |
122 | 119 | ||
123 | deferredResult.addCallback(MochiKit.Base.method(this, 'userSerializedEncryptedData', someData['users'][i])); | 120 | deferredResult.addCallback(MochiKit.Base.method(this, 'userSerializedEncryptedData', someData['users'][i])); |
124 | deferredResult.addCallback(MochiKit.Base.bind(function(aUserSerializationContext) { | 121 | deferredResult.addCallback(MochiKit.Base.bind(function(aUserSerializationContext) { |
125 | //console.log("SERIALIZED USER", aUserSerializationContext); | 122 | //console.log("SERIALIZED USER", aUserSerializationContext); |
126 | resultData['users'][aUserSerializationContext['credentials']['C']] = { | 123 | resultData['users'][aUserSerializationContext['credentials']['C']] = { |
127 | 's': aUserSerializationContext['credentials']['s'], | 124 | 's': aUserSerializationContext['credentials']['s'], |
128 | 'v': aUserSerializationContext['credentials']['v'], | 125 | 'v': aUserSerializationContext['credentials']['v'], |
129 | 'version': aUserSerializationContext['data']['connectionVersion'], | 126 | 'version': aUserSerializationContext['data']['connectionVersion'], |
130 | 'userDetails': aUserSerializationContext['encryptedData']['user']['header'], | 127 | 'userDetails': aUserSerializationContext['encryptedData']['user']['header'], |
131 | 'userDetailsVersion':aUserSerializationContext['encryptedData']['user']['version'], | 128 | 'userDetailsVersion':aUserSerializationContext['encryptedData']['user']['version'], |
132 | 'statistics': aUserSerializationContext['encryptedData']['user']['statistics'], | 129 | 'statistics': aUserSerializationContext['encryptedData']['user']['statistics'], |
133 | 'lock': aUserSerializationContext['encryptedData']['user']['lock'], | 130 | 'lock': aUserSerializationContext['encryptedData']['user']['lock'], |
134 | 'records': this.rearrangeRecordsData(aUserSerializationContext['encryptedData']['records']) | 131 | 'records': this.rearrangeRecordsData(aUserSerializationContext['encryptedData']['records']) |
135 | } | 132 | } |
136 | }, this)); | 133 | }, this)); |
137 | } | 134 | } |
138 | 135 | ||
139 | deferredResult.addCallback(MochiKit.Base.bind(function() { | 136 | deferredResult.addCallback(MochiKit.Base.bind(function() { |
140 | //console.log("this._data", resultData); | 137 | //console.log("this._data", resultData); |
141 | this._data = resultData; | 138 | this._data = resultData; |
142 | }, this)); | 139 | }, this)); |
143 | 140 | ||
144 | deferredResult.callback(); | 141 | deferredResult.callback(); |
145 | //Clipperz.log("<<< Proxy.Test.setupWithData"); | 142 | //Clipperz.log("<<< Proxy.Test.setupWithData"); |
146 | 143 | ||
147 | return deferredResult; | 144 | return deferredResult; |
148 | }, | 145 | }, |
149 | 146 | ||
150 | //========================================================================= | 147 | //========================================================================= |
151 | 148 | ||
152 | 'b': function() { | 149 | 'b': function() { |