-rw-r--r-- | frontend/beta/js/Clipperz/PM/DataModel/Record.js | 7 | ||||
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Proxy.js | 3 | ||||
-rwxr-xr-x | frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js | 262 | ||||
-rw-r--r-- | frontend/gamma/html/index_template.html | 5 | ||||
-rw-r--r-- | frontend/gamma/js/Clipperz/Async.js | 19 | ||||
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/Proxy.js | 2 |
6 files changed, 26 insertions, 272 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/Record.js b/frontend/beta/js/Clipperz/PM/DataModel/Record.js index 270f2ae..ffb45de 100644 --- a/frontend/beta/js/Clipperz/PM/DataModel/Record.js +++ b/frontend/beta/js/Clipperz/PM/DataModel/Record.js @@ -266,44 +266,49 @@ Clipperz.PM.DataModel.Record.prototype = MochiKit.Base.update(null, { } else { result = MochiKit.Async.succeed(this.decryptedData()); } //MochiKit.Logging.logDebug("<<< [" + (new Date()).valueOf() + "] Record.decryptData"); return result; }, //------------------------------------------------------------------------- 'processData': function(someValues) { //MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.processData"); //MochiKit.Logging.logDebug("--- Record.processData: " + Clipperz.Base.serializeJSON(someValues)); if (this.shouldProcessData()) { var currentVersionParameters; +console.log("Record.processData", someValues); this.processDataToExtractLegacyValues(someValues['data']); if (typeof(someValues['data']['notes']) != 'undefined') { this.setNotes(someValues['data']['notes']); } + if (someValues['data']['currentVersionKey'] != null) { this.setCurrentVersionKey(someValues['data']['currentVersionKey']); } else { this.setCurrentVersionKey(this.key()); } - currentVersionParameters = someValues['currentVersion']; +// currentVersionParameters = someValues['currentVersion']; + currentVersionParameters = someValues['versions'][someValues['currentVersion']]; +console.log("Record.processData - this.currentVersionKey()", this.currentVersionKey()); +console.log("Record.processData - currentVersionParameters", currentVersionParameters); currentVersionParameters['key'] = this.currentVersionKey(); this.setCurrentVersion(new Clipperz.PM.DataModel.RecordVersion(this, currentVersionParameters)); if (someValues['data']['directLogins'] != null) { var directLoginReference; for (directLoginReference in someValues['data']['directLogins']) { var directLogin; var directLoginParameters; directLoginParameters = someValues['data']['directLogins'][directLoginReference]; directLoginParameters.record = this; directLoginParameters.reference = directLoginReference; directLogin = new Clipperz.PM.DataModel.DirectLogin(directLoginParameters); this.addDirectLogin(directLogin, true); diff --git a/frontend/beta/js/Clipperz/PM/Proxy.js b/frontend/beta/js/Clipperz/PM/Proxy.js index f476196..bec9195 100644 --- a/frontend/beta/js/Clipperz/PM/Proxy.js +++ b/frontend/beta/js/Clipperz/PM/Proxy.js @@ -103,34 +103,33 @@ Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, { 'addToll': function(aToll) { //console.log(">>> Proxy.addToll", aToll); this.tolls()[aToll.requestType()].push(aToll); //console.log("<<< Proxy.addToll"); }, //========================================================================= 'setTollCallback': function(someParameters) { //console.log(">>> Proxy.setTollCallback", someParameters); if (typeof(someParameters['toll']) != 'undefined') { //console.log("added a new toll", someParameters['toll']); this.addToll(new Clipperz.PM.Toll(someParameters['toll'])); } //console.log("<<< Proxy.setTallCallback", someParameters['result']); - //return someParameters['result']; - return someParameters; + return someParameters['result']; }, //========================================================================= 'registration': function (someParameters) { return this.processMessage('registration', someParameters, 'REGISTER'); }, 'handshake': function (someParameters) { return this.processMessage('handshake', someParameters, 'CONNECT'); }, 'message': function (someParameters) { return this.processMessage('message', someParameters, 'MESSAGE'); }, diff --git a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js b/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js deleted file mode 100755 index 34a10c2..0000000 --- a/frontend/beta/js/Clipperz/PM/Proxy/Proxy.PHP.js +++ b/dev/null @@ -1,262 +0,0 @@ -/* - -Copyright 2008-2011 Clipperz Srl - -This file is part of Clipperz Community Edition. -Clipperz Community Edition is an online password manager. -For further information about its features and functionalities please -refer to http://www.clipperz.com. - -* Clipperz Community Edition is free software: you can redistribute - it and/or modify it under the terms of the GNU Affero General Public - License as published by the Free Software Foundation, either version - 3 of the License, or (at your option) any later version. - -* Clipperz Community Edition is distributed in the hope that it will - be useful, but WITHOUT ANY WARRANTY; without even the implied - warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Affero General Public License for more details. - -* You should have received a copy of the GNU Affero General Public - License along with Clipperz Community Edition. If not, see - <http://www.gnu.org/licenses/>. - -*/ - -if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } -if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } - -//============================================================================= - -Clipperz.PM.Proxy.PHP = function(args) { - Clipperz.PM.Proxy.PHP.superclass.constructor.call(this, args); -/* - this._tolls = { - 'CONNECT': [], - 'REGISTER': [], - 'MESSAGE': [] - }; -*/ - return this; -} - -YAHOO.extendX(Clipperz.PM.Proxy.PHP, Clipperz.PM.Proxy, { - - 'toString': function() { - return "Clipperz.PM.Proxy.PHP - " + this.args(); - }, - - //========================================================================= -/* - 'tolls': function() { - return this._tolls; - }, -*/ - //------------------------------------------------------------------------- -/* - 'payToll': function(aRequestType, someParameters) { - var deferredResult; - -//MochiKit.Logging.logDebug(">>> Proxy.DWR.payToll: " + aRequestType); - if (this.tolls()[aRequestType].length > 0) { - deferredResult = MochiKit.Async.succeed(this.tolls()[aRequestType].pop()); - } else { -//MochiKit.Logging.logDebug("### " + aRequestType + " toll NOT immediately available; request queued."); - deferredResult = new MochiKit.Async.Deferred(); - deferredResult.addCallback(function(someParameters) { - return new Clipperz.PM.Toll(someParameters['toll']); - }) - com_clipperz_pm_Proxy.knock(Clipperz.Base.serializeJSON({requestType:aRequestType}), { - callback:MochiKit.Base.method(deferredResult, 'callback'), - errorHandler:MochiKit.Base.method(deferredResult, 'errback') - }); - } - - deferredResult.addCallback(function(aToll) { - return aToll.deferredPay(); - }); - deferredResult.addCallback(function(someParameters, aToll) { - var result; - - result = { - parameters: someParameters, - toll: aToll - } - - return result; - }, someParameters); - - return deferredResult; - }, -*/ - //------------------------------------------------------------------------- -/* - 'addToll': function(aToll) { - this.tolls()[aToll.requestType()].push(aToll); - }, -*/ - //========================================================================= -/* - 'setTollCallback': function(someParameters) { -//MochiKit.Logging.logDebug(">>> Proxy.DWR.setTollCallback"); -//MochiKit.Logging.logDebug("--- Proxy.DWR.setTollCallback - " + Clipperz.Base.serializeJSON(someParameters)); - if (typeof(someParameters['toll']) != 'undefined') { - this.addToll(new Clipperz.PM.Toll(someParameters['toll'])); - } - return someParameters['result']; - }, -*/ - //========================================================================= - - 'registration': function(someParameters) { - return this.sendMessage('registration', someParameters, 'REGISTER'); - }, - - //------------------------------------------------------------------------- - - 'handshake': function(someParameters) { -/* - _s = "e8a2162f29aeaabb729f5625e9740edbf0cd80ac77c6b19ab951ed6c88443b8c"; - _v = new Clipperz.Crypto.BigInt("955e2db0f7844aca372f5799e5f7e51b5866718493096908bd66abcf1d068108", 16); - _b = new Clipperz.Crypto.BigInt("5761e6c84d22ea3c5649de01702d60f674ccfe79238540eb34c61cd020230c53", 16); - - _B = _v.add(Clipperz.Crypto.SRP.g().powerModule(_b, Clipperz.Crypto.SRP.n())); - _u = new Clipperz.Crypto.BigInt(Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_B.asString(10))).toHexString(), 16); - _A = new Clipperz.Crypto.BigInt("3b3567ec33d73673552e960872eb154d091a2488915941038aef759236a27e64", 16); - _S = (_A.multiply(_v.powerModule(_u, Clipperz.Crypto.SRP.n()))).powerModule(_b, Clipperz.Crypto.SRP.n()); - _K = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_S.asString(10))).toHexString().slice(2); - _M1 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_A.asString(10) + _B.asString(10) + _K)).toHexString().slice(2); - _M2 = Clipperz.PM.Crypto.encryptingFunctions.versions[someParameters.version].hash(new Clipperz.ByteArray(_A.asString(10) + _M1 + _K)).toHexString().slice(2); - -// MochiKit.Logging.logDebug("b = " + _b.asString(16)); -// MochiKit.Logging.logDebug("v = " + _v.asString(16)); - MochiKit.Logging.logDebug("B = " + _B.asString(16)); - MochiKit.Logging.logDebug("u = " + _u.asString(16)); - MochiKit.Logging.logDebug("S = " + _S.asString(16)); - MochiKit.Logging.logDebug("K = " + _K); - MochiKit.Logging.logDebug("M1 = " + _M1); - MochiKit.Logging.logDebug("M2 = " + _M2); -// MochiKit.Logging.logDebug("someParameters.version: " + someParameters.version); -*/ - return this.sendMessage('handshake', someParameters, 'CONNECT'); - }, - - //------------------------------------------------------------------------- - - 'message': function(someParameters) { - return this.sendMessage('message', someParameters, 'MESSAGE'); - }, - - //------------------------------------------------------------------------- - - 'logout': function(someParameters) { -//MochiKit.Logging.logDebug("=== Proxy.DWR.logout"); - return this.sendMessage('logout', someParameters, 'MESSAGE'); - }, - - //========================================================================= - - 'sendMessage': function(aFunctionName, someParameters, aRequestType) { -/* - var deferredResult; - var proxy; - -//MochiKit.Logging.logDebug(">>> Proxy.DWR.sendMessage - " + aFunctionName + " - " + aRequestType); - proxy = this; - - deferredResult = new MochiKit.Async.Deferred(); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.1 Proxy.DWR.sendMessage - 1: " + res); return res;}); - deferredResult.addCallback(MochiKit.Base.method(proxy, 'payToll'), aRequestType); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.2 Proxy.DWR.sendMessage - 2: " + Clipperz.Base.serializeJSON(res)); return res;}); - deferredResult.addCallback(MochiKit.Base.method(proxy, 'sendRemoteMessage'), aFunctionName); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.DWR.sendMessage - 3: " + res); return res;}); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.DWR.sendMessage - 3: " + Clipperz.Base.serializeJSON(res)); return res;}); - deferredResult.callback(someParameters); - -//MochiKit.Logging.logDebug("<<< Proxy.DWR.sendMessage"); - return deferredResult; -*/ - -// return this.sendRemoteMessage(aFunctionName, someParameters); - - - var deferredResult; - var proxy; - - proxy = this; - - deferredResult = new MochiKit.Async.Deferred(); - deferredResult.addCallback(MochiKit.Base.method(proxy, 'sendRemoteMessage'), aFunctionName); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.PHP.sendMessage - 3: " + res); return res;}); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("x.3 Proxy.PHP.sendMessage - 3.1: " + Clipperz.Base.serializeJSON(res)); return res;}); - - deferredResult.callback(someParameters); - - return deferredResult; - }, - - //========================================================================= - - 'sendRemoteMessage': function(aFunctionName, someParameters) { -/* - var deferredResult; - -//MochiKit.Logging.logDebug(">>> Proxy.DWR.sendRemoteMessage('" + aFunctionName + "', " + Clipperz.Base.serializeJSON(someParameters) + ") - " + this); - deferredResult = new MochiKit.Async.Deferred(); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Proxy.DWR.sendRemoteMessage - 1: " + res); return res;}); -// deferredResult.addCallback(MochiKit.Base.method(this, 'setTollCallback')); -//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Proxy.DWR.sendRemoteMessage - 2: " + res); return res;}); - - com_clipperz_pm_Proxy[aFunctionName](Clipperz.Base.serializeJSON(someParameters), { - callback:MochiKit.Base.method(deferredResult, 'callback'), - errorHandler:MochiKit.Base.method(deferredResult, 'errback') - }); -//MochiKit.Logging.logDebug("<<< Proxy.PHP.sendRemoteMessage - result: " + deferredResult); - - return deferredResult; -*/ - - var deferredResult; - var parameters; - -//MochiKit.Logging.logDebug(">>> Proxy.PHP.sendRemoteMessage('" + aFunctionName + "', " + Clipperz.Base.serializeJSON(someParameters) + ") - " + this); - parameters = {}; - parameters['method'] = aFunctionName; -// parameters['version'] = someParameters['version']; -// parameters['message'] = someParameters['message']; - parameters['parameters'] = Clipperz.Base.serializeJSON(someParameters); -//MochiKit.Logging.logDebug("--- Proxy.PHP.sendRemoteMessage('" + Clipperz.Base.serializeJSON(parameters) + ") - " + this); - deferredResult = new MochiKit.Async.Deferred(); - deferredResult.addCallback(MochiKit.Async.doXHR, "./php/index.php", { - method:'POST', - sendContent:MochiKit.Base.queryString(parameters), - headers:{"Content-Type":"application/x-www-form-urlencoded"} - }); -//deferredResult.addCallback(function(res) {MochiKit.Logging.logDebug("Proxy.PHP.response - 2: " + res.responseText); return res;}); -//deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("Proxy.PHP.response - ERROR: " + res); return res;}); - deferredResult.addCallback(MochiKit.Async.evalJSONRequest); - deferredResult.addCallback(function (someValues) { - if (someValues['result'] == 'EXCEPTION') { - throw someValues['message']; - } - return someValues; - }) - deferredResult.callback(); - - return deferredResult; - }, - - //========================================================================= - - 'isReadOnly': function() { - return false; - }, - - //========================================================================= - __syntaxFix__: "syntax fix" - -}); - -//============================================================================= - -//Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.PHP("Proxy.PHP - async test"); diff --git a/frontend/gamma/html/index_template.html b/frontend/gamma/html/index_template.html index 8cf838c..bedb243 100644 --- a/frontend/gamma/html/index_template.html +++ b/frontend/gamma/html/index_template.html @@ -26,32 +26,37 @@ Clipperz_normalizedNewLine = '\x0d\x0a'; @js_DEBUG@ </head> <body> <div id="mainDiv"> <div id="loading"> <a href="http://www.clipperz.com" target="_blank"><div id="logo"></div></a> <h5 class="clipperzPayoff">keep it to yourself!</h5> <h2>loading ...</h2> </div> @js_INSTALL@ </div> <div id="applicationVersionType" class="@application.version.type@"></div> +<script> + Clipperz.PM.Proxy.defaultProxy = new Clipperz.PM.Proxy.JSON({'url':'@request.path@', 'shouldPayTolls':@should.pay.toll@}); + /*offline_data_placeholder*/ +</script> + <!-- --> <div id="javaScriptAlert"> <div class="mask"></div> <div class="message"> <div class="header"></div> <div class="body"> <div class="alertLogo"></div> <div class="alert"> <h1>Attention!</h1> <p>If you can read this message, the chances are that your browser does not properly support JavaScript? or you have disabled this functionality yourself.</p> <h3>Javascript is required to access Clipperz.</h3> <h5>Please enable scripting or upgrade your browser.</h5> </div> </div> <div class="footer"></div> </div> diff --git a/frontend/gamma/js/Clipperz/Async.js b/frontend/gamma/js/Clipperz/Async.js index 7c9d783..97d8ecf 100644 --- a/frontend/gamma/js/Clipperz/Async.js +++ b/frontend/gamma/js/Clipperz/Async.js @@ -49,88 +49,94 @@ Clipperz.Async.Deferred = function(aName, args) { //============================================================================= Clipperz.Base.extend(Clipperz.Async.Deferred, MochiKit.Async.Deferred, { 'name': function () { return this._name; }, 'args': function () { return this._args; }, //----------------------------------------------------------------------------- 'callback': function (aValue) { if (this._shouldTrace) { - Clipperz.log("CALLBACK " + this._name, aValue); + // Clipperz.log("CALLBACK " + this._name, aValue); + console.log("CALLBACK " + this._name, aValue); } if (this.chained == false) { var message; message = "ERROR [" + this._name + "]"; this.addErrback(function(aResult) { if (! (aResult instanceof MochiKit.Async.CancelledError)) { Clipperz.log(message, aResult); } return aResult; }); if (this._shouldTrace) { var resultMessage; resultMessage = "RESULT " + this._name + " <=="; // this.addCallback(function(aResult) { Clipperz.Async.Deferred.superclass.addCallback.call(this, function(aResult) { - Clipperz.log(resultMessage, aResult); + // Clipperz.log(resultMessage, aResult); + console.log(resultMessage, aResult); return aResult; }); } } if (CLIPPERZ_DEFERRED_CALL_LOGGING_ENABLED === true) { Clipperz.log("callback " + this._name, this); } return Clipperz.Async.Deferred.superclass.callback.apply(this, arguments); }, //----------------------------------------------------------------------------- 'addCallback': function () { var message; if (this._shouldTrace) { this._count ++; message = "[" + this._count + "] " + this._name + " "; // this.addBoth(function(aResult) {Clipperz.log(message + "-->", aResult); return aResult;}); this.addCallbacks( - function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, - function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;} + // function(aResult) {Clipperz.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, + function(aResult) {console.log("-OK- " + message + "-->"/*, aResult*/); return aResult;}, + // function(aResult) {Clipperz.log("FAIL " + message + "-->"/*, aResult*/); return aResult;} + function(aResult) {console.log("FAIL " + message + "-->"/*, aResult*/); return aResult;} ); } Clipperz.Async.Deferred.superclass.addCallback.apply(this, arguments); if (this._shouldTrace) { // this.addBoth(function(aResult) {Clipperz.log(message + "<--", aResult); return aResult;}); this.addCallbacks( - function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;}, - function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;} + // function(aResult) {Clipperz.log("-OK- " + message + "<--", aResult); return aResult;}, + function(aResult) {console.log("-OK- " + message + "<--", aResult); return aResult;}, + // function(aResult) {Clipperz.log("FAIL " + message + "<--", aResult); return aResult;} + function(aResult) {console.log("FAIL " + message + "<--", aResult); return aResult;} ); } }, //============================================================================= 'addCallbackPass': function() { var passFunction; passFunction = MochiKit.Base.partial.apply(null, arguments); this.addCallback(function() { var result; result = arguments[arguments.length -1]; passFunction(); @@ -393,32 +399,33 @@ MochiKit.Base.update(Clipperz.Async.DeferredSynchronizer.prototype, { } return this.result(); }, //----------------------------------------------------------------------------- 'handleMethodCallDone': function(anIndexValue, aResult) { this.incrementNumberOfMethodsDone(); this.methodResults()[anIndexValue] = aResult; if (this.numberOfMethodsDone() < this.methods().length) { // nothing to do here other than possibly log something } else if (this.numberOfMethodsDone() == this.methods().length) { this.result().callback(); } else if (this.numberOfMethodsDone() > this.methods().length) { + alert("Clipperz.Async.Deferred.handleMethodCallDone -> WTF!"); // WTF!!! :( } }, //----------------------------------------------------------------------------- __syntaxFix__: "syntax fix" }); //############################################################################# MochiKit.Base.update(Clipperz.Async, { 'callbacks': function (aName, someFunctions, someArguments, aCallbackValue) { var deferredResult; diff --git a/frontend/gamma/js/Clipperz/PM/Proxy.js b/frontend/gamma/js/Clipperz/PM/Proxy.js index 190bffd..9817eac 100644 --- a/frontend/gamma/js/Clipperz/PM/Proxy.js +++ b/frontend/gamma/js/Clipperz/PM/Proxy.js @@ -129,33 +129,33 @@ Clipperz.PM.Proxy.prototype = MochiKit.Base.update(null, { return this.processMessage('handshake', someParameters, 'CONNECT'); }, 'message': function (someParameters) { return this.processMessage('message', someParameters, 'MESSAGE'); }, 'logout': function (someParameters) { return this.processMessage('logout', someParameters, 'MESSAGE'); }, //========================================================================= 'processMessage': function (aFunctionName, someParameters, aRequestType) { var deferredResult; - deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:false}); + deferredResult = new Clipperz.Async.Deferred("Proxy.processMessage", {trace:true}); deferredResult.addMethod(this, 'payToll', aRequestType); deferredResult.addMethod(this, 'sendMessage', aFunctionName); deferredResult.addMethod(this, 'setTollCallback'); deferredResult.callback(someParameters); return deferredResult; }, //========================================================================= 'sendMessage': function () { throw Clipperz.Base.exception.AbstractMethod; }, //========================================================================= |