clean up extraneous variables and log statements

pull/1/head
ansuz 7 years ago
parent 8a18698c03
commit e6d4bced18

@ -48,9 +48,7 @@ define([
var edSeed = opt.edSeed = dispense(32);
// 64 more bytes to seed an additional signing key
opt.blockSeed = new Uint8Array(dispense(64));
var blockKeys = opt.blockKeys = Block.genkeys(opt.blockSeed);
var blockKeys = opt.blockKeys = Block.genkeys(new Uint8Array(dispense(64)));
opt.blockHash = Block.getBlockHash(blockKeys);
// derive a private key from the ed seed
@ -87,13 +85,11 @@ define([
opt.channelHex = parsed.channel;
opt.keys = parsed.keys;
opt.edPublic = blockInfo.edPublic;
opt.edPrivate = blockInfo.edPrivate;
opt.User_name = blockInfo.User_name;
return opt;
};
var loadUserObject = function (opt, cb) {
console.log(opt);
var config = {
websocketURL: NetConfig.getWebsocketURL(),
channel: opt.channelHex,
@ -106,8 +102,6 @@ define([
owners: [opt.edPublic]
};
console.log(config);
var rt = opt.rt = Listmap.create(config);
rt.proxy
.on('ready', function () {
@ -281,7 +275,8 @@ define([
console.log("allocating random bytes for a new user object");
opt = allocateBytes(Nacl.randomBytes(Exports.requiredBytes));
// create a random v2 hash, since we don't need backwards compatibility
userHash = '/drive/#' + Hash.createRandomHash('drive');
//userHash = opt.userHash = Hash.createRandomHash('drive'); // TODO
userHash = opt.userHash;
}
// according to the location derived from the credentials which you entered
@ -394,7 +389,6 @@ define([
toPublish[Constants.userNameKey] = uname;
toPublish[Constants.userHashKey] = userHash;
toPublish.edPublic = RT.proxy.edPublic;
toPublish.edPrivate = RT.proxy.edPrivate;
var blockRequest = Block.serialize(JSON.stringify(toPublish), res.opt.blockKeys);

@ -716,7 +716,7 @@ define([
var password = data.password; // To remove your old block
var newPassword = data.newPassword; // To create your new block
var secret = Hash.getSecrets('drive', hash);
var newHash, newHref, newSecret, newBlockSeed;
var newHash, newHref, newSecret, blockKeys;
var oldIsOwned = false;
var blockHash = LocalStore.getBlockHash();
@ -724,7 +724,6 @@ define([
var Cred, Block, Login;
Nthen(function (waitFor) {
console.log("loading necessary modules");
require([
'/customize/credential.js',
'/common/outer/login-block.js',
@ -736,13 +735,12 @@ define([
}));
}).nThen(function (waitFor) {
// confirm that the provided password is correct
console.log("checking whether the password you entered was correct");
Cred.deriveFromPassphrase(accountName, password, Login.requiredBytes, waitFor(function (bytes) {
var allocated = Login.allocateBytes(bytes);
oldBlockKeys = allocated.blockKeys;
if (blockHash) {
if (blockHash !== allocated.blockHash) {
console.log("password did not yield the correct blockHash ?");
console.log("provided password did not yield the correct blockHash");
// incorrect password probably
waitFor.abort();
return void cb({
@ -753,7 +751,7 @@ define([
} else {
// otherwise they're a legacy user, and we should check against the User_hash
if (hash !== allocated.userHash) {
console.log("password did not yield the correct userHash");
console.log("provided password did not yield the correct userHash");
waitFor.abort();
return void cb({
error: 'INVALID_PASSWORD',
@ -791,26 +789,12 @@ define([
return void cb({ error: err });
}
console.log(val);
console.log("%s => %s", hash, newHash);
Crypt.put(newHash, val, waitFor(function (err) {
if (err) {
waitFor.abort();
console.error(err);
return void cb({ error: err });
}
console.error('checking content at newHash: %s', newHash);
Crypt.get(newHash, function (err, val) {
if (err) {
waitFor.abort();
console.log(err);
return void cb({ error: err });
}
console.error(val);
});
}), optsPut);
}));
}).nThen(function (waitFor) {
@ -818,30 +802,27 @@ define([
console.log("deriving new credentials from passphrase");
Cred.deriveFromPassphrase(accountName, newPassword, Login.requiredBytes, waitFor(function (bytes) {
var allocated = Login.allocateBytes(bytes);
newBlockSeed = allocated.blockSeed;
blockKeys = allocated.blockKeys;
}));
}).nThen(function (waitFor) {
// Write the new login block
var keys = Block.genkeys(newBlockSeed);
var temp = {
User_name: accountName,
User_hash: newHash,
edPublic: edPublic,
// edPrivate XXX
};
var content = Block.serialize(JSON.stringify(temp), keys);
var content = Block.serialize(JSON.stringify(temp), blockKeys);
console.log("writing new login block");
common.writeLoginBlock(content, waitFor(function (obj) {
console.log("new login block written");
var newBlockHash = Block.getBlockHash(keys);
LocalStore.setBlockHash(newBlockHash);
if (obj && obj.error) {
waitFor.abort();
return void cb(obj);
}
console.log("new login block written");
var newBlockHash = Block.getBlockHash(blockKeys);
LocalStore.setBlockHash(newBlockHash);
}));
}).nThen(function (waitFor) {
// New drive hash is in login block, unpin the old one and pin the new one

Loading…
Cancel
Save