log users out if they do not have curve keys. add curve keys to object on registration and login.

pull/1/head
ansuz 8 years ago
parent 4016a95540
commit e353627204

@ -304,6 +304,12 @@ define([
typeof(proxy.edPublic) === 'string'; typeof(proxy.edPublic) === 'string';
}; };
common.hasCurveKeys = function (proxy) {
return typeof(proxy) === 'object' &&
typeof(proxy.curvePrivate) === 'string' &&
typeof(proxy.curvePublic) === 'string';
};
common.isArray = $.isArray; common.isArray = $.isArray;
/* /*

@ -206,7 +206,8 @@ define([
} }
// if the user is logged in, but does not have signing keys... // if the user is logged in, but does not have signing keys...
if (Cryptpad.isLoggedIn() && !Cryptpad.hasSigningKeys(proxy)) { if (Cryptpad.isLoggedIn() && (!Cryptpad.hasSigningKeys(proxy) ||
!Cryptpad.hasCurveKeys(proxy))) {
return void requestLogin(); return void requestLogin();
} }
@ -219,7 +220,6 @@ define([
Cryptpad.changeDisplayName(proxy[Cryptpad.displayNameKey]); Cryptpad.changeDisplayName(proxy[Cryptpad.displayNameKey]);
}); });
proxy.on('change', [tokenKey], function () { proxy.on('change', [tokenKey], function () {
console.log('wut');
var localToken = tryParsing(localStorage.getItem(tokenKey)); var localToken = tryParsing(localStorage.getItem(tokenKey));
if (localToken !== proxy[tokenKey]) { if (localToken !== proxy[tokenKey]) {
return void requestLogin(); return void requestLogin();

@ -22,7 +22,12 @@ define([
// 16 bytes for a deterministic channel key // 16 bytes for a deterministic channel key
var channelSeed = dispense(16); var channelSeed = dispense(16);
// 32 bytes for a curve key // 32 bytes for a curve key
opt.curveSeed = dispense(32); var curveSeed = dispense(32);
var curvePair = Nacl.box.keyPair.fromSecretKey(new Uint8Array(curveSeed));
opt.curvePrivate = Nacl.util.encodeBase64(curvePair.secretKey);
opt.curvePublic = Nacl.util.encodeBase64(curvePair.publicKey);
// 32 more for a signing key // 32 more for a signing key
var edSeed = opt.edSeed = dispense(32); var edSeed = opt.edSeed = dispense(32);
@ -109,6 +114,9 @@ define([
res.edPrivate = opt.edPrivate; res.edPrivate = opt.edPrivate;
res.edPublic = opt.edPublic; res.edPublic = opt.edPublic;
res.curvePrivate = opt.curvePrivate;
res.curvePublic = opt.curvePublic;
// they tried to just log in but there's no such user // they tried to just log in but there's no such user
if (!isRegister && isProxyEmpty(rt.proxy)) { if (!isRegister && isProxyEmpty(rt.proxy)) {
rt.network.disconnect(); // clean up after yourself rt.network.disconnect(); // clean up after yourself

@ -91,6 +91,9 @@ define([
proxy.edPrivate = result.edPrivate; proxy.edPrivate = result.edPrivate;
proxy.edPublic = result.edPublic; proxy.edPublic = result.edPublic;
proxy.curvePrivate = result.curvePrivate;
proxy.curvePublic = result.curvePublic;
Cryptpad.feedback('LOGIN', true); Cryptpad.feedback('LOGIN', true);
Cryptpad.whenRealtimeSyncs(result.realtime, function() { Cryptpad.whenRealtimeSyncs(result.realtime, function() {
Cryptpad.login(result.userHash, result.userName, function () { Cryptpad.login(result.userHash, result.userName, function () {

@ -75,6 +75,8 @@ define([
var proxy = result.proxy; var proxy = result.proxy;
proxy.edPublic = result.edPublic; proxy.edPublic = result.edPublic;
proxy.edPrivate = result.edPrivate; proxy.edPrivate = result.edPrivate;
proxy.curvePublic = result.curvePublic;
proxy.curvePrivate = result.curvePrivate;
Cryptpad.feedback('REGISTRATION', true); Cryptpad.feedback('REGISTRATION', true);

Loading…
Cancel
Save