summaryrefslogtreecommitdiff
path: root/lib/plainXHR.js
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2012-08-13 11:45:51 +0200
committerAzul <azul@riseup.net>2012-08-13 11:45:51 +0200
commit79610eaf3c0628c8b84da3a4bbf8a6598e1a03cb (patch)
tree412cf8475bbb1dd19e42f12e1ba6393beefe0e12 /lib/plainXHR.js
parentda8f6025900740684bc81e9a7c22f6a83ed48d79 (diff)
seperated session from the srp flow - login tests pass, signup fail
Diffstat (limited to 'lib/plainXHR.js')
-rw-r--r--lib/plainXHR.js48
1 files changed, 11 insertions, 37 deletions
diff --git a/lib/plainXHR.js b/lib/plainXHR.js
index 67d8137..95ceeac 100644
--- a/lib/plainXHR.js
+++ b/lib/plainXHR.js
@@ -1,20 +1,9 @@
-plainXHR = function() {
-
- function getUrl()
- {
- return "";
- }
-
- function paths(path)
- {
- return path
- }
+SRP.prototype.Remote = function() {
// Perform ajax requests at the specified path, with the specified parameters
// Calling back the specified function.
- function ajaxRequest(relative_path, params, callback)
+ function ajaxRequest(url, params, callback)
{
- var full_url = this.geturl() + this.paths(relative_path);
if( window.XMLHttpRequest)
xhr = new XMLHttpRequest();
else if (window.ActiveXObject){
@@ -33,7 +22,7 @@ plainXHR = function() {
callback(parseResponse());
}
};
- xhr.open("POST", full_url, true);
+ xhr.open("POST", url, true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Content-length", params.length);
xhr.send(params);
@@ -90,35 +79,20 @@ plainXHR = function() {
return response;
};
- function register(session, callback)
+ this.register = function(session, callback)
{
- this.ajaxRequest("register/salt/", "I="+session.getI(), callback);
- }
-
- function sendVerifier(session, callback) {
- this.ajaxRequest("register/user/", "v="+session.getV().toString(16), callback);
- }
-
- function handshake(I, Astr, callback) {
- this.ajaxRequest("handshake/", "I="+I+"&A="+Astr, callback);
+ ajaxRequest("register/salt/", "I="+session.getI(), callback);
}
- function authenticate(M, callback) {
- this.ajaxRequest("authenticate/", "M="+M, callback);
+ this.sendVerifier = function(session, callback) {
+ ajaxRequest("register/user/", "v="+session.getV().toString(16), callback);
}
- function upgrade(M, callback) {
- this.ajaxRequest("upgrade/authenticate/", "M="+M, callback);
+ this.handshake = function(session, callback) {
+ ajaxRequest("handshake/", "I="+session.getI()+"&A="+session.getAstr(), callback);
}
- return {
- geturl: getUrl,
- paths: paths,
- ajaxRequest: ajaxRequest,
- register: register,
- register_send_verifier: sendVerifier,
- handshake: handshake,
- authenticate: authenticate,
- upgrade: upgrade
+ this.authenticate = function(session, callback) {
+ ajaxRequest("authenticate/", "M="+session.getM(), callback);
}
}