summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2012-11-19 18:11:20 +0100
committerAzul <azul@riseup.net>2012-11-19 18:11:20 +0100
commit082f859bbdaedf4f03eb85aea9b8f88ffda2fe6d (patch)
treefd280571682a640d248c6b714c2831633031052c /src
parenta41d7f306aa1dbcae17643cc9c3b457632ee8909 (diff)
further cleanup
Diffstat (limited to 'src')
-rw-r--r--src/jqueryRest.js62
-rw-r--r--src/srp_session.js16
2 files changed, 41 insertions, 37 deletions
diff --git a/src/jqueryRest.js b/src/jqueryRest.js
index 29f737c..c439f67 100644
--- a/src/jqueryRest.js
+++ b/src/jqueryRest.js
@@ -1,51 +1,39 @@
-jqueryRest = function() {
-
- // we do not fetch the salt from the server
- function register(session)
- {
- return sendVerifier(session);
- }
+srp.remote = (function(){
+ var jqueryRest = (function() {
- function sendVerifier(session) {
- var salt = session.getSalt();
- return $.post("users.json", { user:
- { login: session.getI(),
- password_salt: salt,
- password_verifier: session.getV(salt).toString(16)
- }
- });
- }
+ // we do not fetch the salt from the server
+ function register(session) {
+ return $.post("users.json", { user: session.signup() });
+ }
- function handshake(session) {
- return $.post("sessions.json", { login: session.getI(), A: session.getAstr()});
- }
+ function handshake(session) {
+ return $.post("sessions.json", session.handshake());
+ }
- function authenticate(session) {
- return $.ajax({
- url: "sessions/" + session.getI() + ".json",
- type: 'PUT',
- data: {client_auth: session.getM()},
- });
- }
+ function authenticate(session) {
+ return $.ajax({
+ url: "sessions/" + session.getI() + ".json",
+ type: 'PUT',
+ data: {client_auth: session.getM()}
+ });
+ }
- return {
- register: register,
- register_send_verifier: sendVerifier,
- handshake: handshake,
- authenticate: authenticate
- };
-};
+ return {
+ register: register,
+ handshake: handshake,
+ authenticate: authenticate
+ };
+ }());
-srp.remote = (function(){
function signup(){
- jqueryRest().register(srp.session)
+ jqueryRest.register(srp.session)
.success(srp.signedUp)
.error(srp.error)
};
function login(){
- jqueryRest().handshake(srp.session)
+ jqueryRest.handshake(srp.session)
.success(receiveSalts)
.error(srp.error)
};
@@ -62,7 +50,7 @@ srp.remote = (function(){
else
{
srp.session.calculations(response.salt, response.B);
- jqueryRest().authenticate(srp.session)
+ jqueryRest.authenticate(srp.session)
.success(confirmAuthentication)
.error(srp.error);
}
diff --git a/src/srp_session.js b/src/srp_session.js
index 7f1232f..b278993 100644
--- a/src/srp_session.js
+++ b/src/srp_session.js
@@ -35,6 +35,22 @@ srp.Session = function(login, password) {
return Astr;
};
+ this.signup = function() {
+ var salt = this.getSalt();
+ return {
+ login: this.getI(),
+ password_salt: salt,
+ password_verifier: this.getV(salt).toString(16)
+ };
+ };
+
+ this.handshake = function() {
+ return {
+ login: this.getI(),
+ A: this.getAstr()
+ };
+ };
+
this.getAstr = function() {
return Astr;
}