|
|
@ -12,8 +12,6 @@ define([
|
|
|
|
var Scrypt = window.scrypt;
|
|
|
|
var Scrypt = window.scrypt;
|
|
|
|
var Nacl = window.nacl;
|
|
|
|
var Nacl = window.nacl;
|
|
|
|
|
|
|
|
|
|
|
|
Cryptpad.styleAlerts();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var secret = {};
|
|
|
|
var secret = {};
|
|
|
|
|
|
|
|
|
|
|
|
var APP = window.APP = {
|
|
|
|
var APP = window.APP = {
|
|
|
@ -21,6 +19,27 @@ define([
|
|
|
|
Crypto: Crypto,
|
|
|
|
Crypto: Crypto,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $warning = $('#warning');
|
|
|
|
|
|
|
|
var $login = $('#login');
|
|
|
|
|
|
|
|
var $logout = $('#logout');
|
|
|
|
|
|
|
|
var $username = $('#username');
|
|
|
|
|
|
|
|
var $password = $('#password');
|
|
|
|
|
|
|
|
var $confirm = $('#confirm');
|
|
|
|
|
|
|
|
var $remember = $('#remember');
|
|
|
|
|
|
|
|
var $loginBox = $('#login-box');
|
|
|
|
|
|
|
|
var $logoutBox = $('#logout-box');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var revealLogin = function () {
|
|
|
|
|
|
|
|
$loginBox.slideDown();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $logout = $logout.click(function () {
|
|
|
|
|
|
|
|
Cryptpad.logout(function () {
|
|
|
|
|
|
|
|
$logoutBox.slideUp();
|
|
|
|
|
|
|
|
revealLogin();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var hashFromCreds = function (username, password, len, cb) {
|
|
|
|
var hashFromCreds = function (username, password, len, cb) {
|
|
|
|
Scrypt(password,
|
|
|
|
Scrypt(password,
|
|
|
|
username,
|
|
|
|
username,
|
|
|
@ -82,6 +101,7 @@ define([
|
|
|
|
// 32 more for a signing key
|
|
|
|
// 32 more for a signing key
|
|
|
|
var edSeed = consume(32);
|
|
|
|
var edSeed = consume(32);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var seed = {};
|
|
|
|
var seed = {};
|
|
|
|
var keys = seed.keys = Crypto.createEditCryptor(null, encryptionSeed);
|
|
|
|
var keys = seed.keys = Crypto.createEditCryptor(null, encryptionSeed);
|
|
|
|
|
|
|
|
|
|
|
@ -124,9 +144,26 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
/* if the user is registering, we expect that the userDoc will be empty
|
|
|
|
/* if the user is registering, we expect that the userDoc will be empty
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var proxyKeys = Object.keys(proxy);
|
|
|
|
|
|
|
|
|
|
|
|
if (opt.register) {
|
|
|
|
if (opt.register) {
|
|
|
|
if (Object.keys(proxy).length) {
|
|
|
|
if (proxyKeys.length) {
|
|
|
|
|
|
|
|
// user is trying to register, but the userDoc is not empty
|
|
|
|
|
|
|
|
// tell them they are already registered.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
alreadyExists();
|
|
|
|
alreadyExists();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// trying to register, and the object is empty, as expected
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (proxyKeys.length) {
|
|
|
|
|
|
|
|
// user has already initialized the object, as expected
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// user has logged in, but there is no object here
|
|
|
|
|
|
|
|
// they should confirm their password
|
|
|
|
|
|
|
|
// basically this means registering
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -146,7 +183,9 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
console.log("remembering your userhash");
|
|
|
|
console.log("remembering your userhash");
|
|
|
|
Cryptpad.login(userHash, opt.remember);
|
|
|
|
Cryptpad.login(userHash, opt.remember);
|
|
|
|
//console.log(userHash);
|
|
|
|
console.log(userHash);
|
|
|
|
|
|
|
|
$('div#login-box').slideUp();
|
|
|
|
|
|
|
|
$('div#logout-box').slideDown();
|
|
|
|
//console.log(proxy);
|
|
|
|
//console.log(proxy);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.on('disconnect', function (info) {
|
|
|
|
.on('disconnect', function (info) {
|
|
|
@ -154,27 +193,6 @@ define([
|
|
|
|
console.log(info);
|
|
|
|
console.log(info);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var $warning = $('#warning');
|
|
|
|
|
|
|
|
var $login = $('#login');
|
|
|
|
|
|
|
|
var $username = $('#username');
|
|
|
|
|
|
|
|
var $password = $('#password');
|
|
|
|
|
|
|
|
var $confirm = $('#confirm');
|
|
|
|
|
|
|
|
var $remember = $('#remember');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var revealLogin = function () {
|
|
|
|
|
|
|
|
$('.box').slideDown();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $logoutBox = $('div.logout');
|
|
|
|
|
|
|
|
var $logout = $('#logout').click(function () {
|
|
|
|
|
|
|
|
Cryptpad.logout(function () {
|
|
|
|
|
|
|
|
// noop?
|
|
|
|
|
|
|
|
$logout.slideUp();
|
|
|
|
|
|
|
|
revealLogin();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var $register = $('#register').click(function () {
|
|
|
|
var $register = $('#register').click(function () {
|
|
|
|
if (!$register.length) { return; }
|
|
|
|
if (!$register.length) { return; }
|
|
|
|
var e = $register[0];
|
|
|
|
var e = $register[0];
|
|
|
@ -196,11 +214,13 @@ define([
|
|
|
|
$register[0].checked = false;
|
|
|
|
$register[0].checked = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cryptpad.ready(function () {
|
|
|
|
if (Cryptpad.getUserHash()) {
|
|
|
|
if (Cryptpad.getUserHash()) {
|
|
|
|
//Cryptpad.alert("You are already logged in!");
|
|
|
|
//Cryptpad.alert("You are already logged in!");
|
|
|
|
$logoutBox.slideDown();
|
|
|
|
$logoutBox.slideDown();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
revealLogin();
|
|
|
|
revealLogin();
|
|
|
|
|
|
|
|
//$logoutBox.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$login.click(function () {
|
|
|
|
$login.click(function () {
|
|
|
@ -232,4 +252,5 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|