From 0f02618168da426ffe47161e72b7f8e3541ce892 Mon Sep 17 00:00:00 2001 From: ausiv4 Date: Tue, 4 Aug 2009 03:37:00 +0000 Subject: I've started working on the feature that will allow existing servers to upgrade to SRP. Currently, I've added functionality that will allow the importation of hash.min.js. This is made possible by some code that executes when the script is loaded. This particular code doesn't pack properly, so currently I'm having the pack script append it to the end (unpacked). This requires that clients use the packed version for two reasons. First, the unpacked code lacks the function that gets the source path. Second, it loads hash.min.js. The first problem can be fixed if I can figure out how to get the code to pack properly. The second problem can be solved by checking whether the current script is "srp.js" or "srp.min.js", and loading either (MD5.js & SHA1.js) or hash.min.js respectively. Next we will need to write code where the server detects users who exist in the auth.models.User table, but not the srp.models.User table. --- javascript/srp.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'javascript/srp.js') diff --git a/javascript/srp.js b/javascript/srp.js index 757f985..2a8f6e5 100644 --- a/javascript/srp.js +++ b/javascript/srp.js @@ -23,6 +23,7 @@ function SRP(username, password, ser, base_url) var server = ser; var that = this; var authenticated = false; + var hash_import = false; function paths(str) { @@ -170,6 +171,15 @@ function SRP(username, password, ser, base_url) } } }; + function import_hashes() + { + if(that.isdefined("SHA1") && that.isdefined("MD5")) return; + var scriptElt = document.createElement('script'); + scriptElt.type = 'text/javascript'; + var arr=srpPath.split("/"); + scriptElt.src = arr.slice(0, arr.length-1).join("/")+"/hash.min.js"; + document.getElementsByTagName('head')[0].appendChild(scriptElt); + } this.key = function() { if(K == null) @@ -191,4 +201,8 @@ function SRP(username, password, ser, base_url) { alert(t); }; + this.isdefined = function ( variable) + { + return (typeof(window[variable]) == "undefined")? false: true; + }; }; -- cgit v1.2.3