diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index d03371914..6a5a66047 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -416,7 +416,7 @@ define([ }); }; - common.writeLoginBlock = function (data, cb) { // XXX restricted-registration + common.writeLoginBlock = function (data, cb) { postMessage('WRITE_LOGIN_BLOCK', data, function (obj) { cb(obj); }); @@ -1746,7 +1746,7 @@ define([ }); }); }; - common.changeUserPassword = function (Crypt, edPublic, data, cb) { // XXX restricted-registration + common.changeUserPassword = function (Crypt, edPublic, data, cb) { if (!edPublic) { return void cb({ error: 'E_NOT_LOGGED_IN' @@ -1855,6 +1855,9 @@ define([ }; var content = Block.serialize(JSON.stringify(temp), blockKeys); + console.error("OLD AND NEW BLOCK KEYS", oldBlockKeys, blockKeys); + // XXX ignored unless restricted registration is active? + // content.registrationProof = Block.proveAncestor(); console.log("writing new login block"); common.writeLoginBlock(content, waitFor(function (obj) { diff --git a/www/common/outer/login-block.js b/www/common/outer/login-block.js index ef3a38676..46f5158af 100644 --- a/www/common/outer/login-block.js +++ b/www/common/outer/login-block.js @@ -86,6 +86,30 @@ define([ }; }; + Block.proveAncestor = function (O /* oldBlockKeys */, N /* newBlockKeys */) { + N = N; +/* + var registrationProof; + var registrationSig; + if (keys.previous) { + // XXX restricted-registration + // sign the publicKey of the new key with the old key + + // your existing block's publicKey + // the new block's publicKey + // some proof of recency to prevent replays? + // a signature of the whole thing + + // registrationProof = [oldPublicKey, newPublicKey]; + // registrationSig = sign(registrationProof, oldPrivateKey); + } +*/ + +// needed for password change with restricted registration +//registrationProof: registrationProof? Nacl.util.encodeBase64(registrationProof): undefined, +//registrationSig: registrationSig? Nacl.util.encode + }; + Block.remove = function (keys) { // sign the hash of the text 'DELETE_BLOCK' var sig = Nacl.sign.detached(Nacl.hash(