Merge remote-tracking branch 'origin/inviteUI' into inviteUI
This commit is contained in:
commit
01e7ec7e88
@ -14,14 +14,14 @@ define([
|
|||||||
'/customize/application_config.js',
|
'/customize/application_config.js',
|
||||||
'/customize/pages.js',
|
'/customize/pages.js',
|
||||||
'/bower_components/nthen/index.js',
|
'/bower_components/nthen/index.js',
|
||||||
|
'/common/invitation.js',
|
||||||
|
|
||||||
'/bower_components/scrypt-async/scrypt-async.js',
|
'/bower_components/scrypt-async/scrypt-async.js',
|
||||||
'css!/customize/fonts/cptools/style.css',
|
'css!/customize/fonts/cptools/style.css',
|
||||||
'/bower_components/croppie/croppie.min.js',
|
'/bower_components/croppie/croppie.min.js',
|
||||||
'css!/bower_components/croppie/croppie.css',
|
'css!/bower_components/croppie/croppie.css',
|
||||||
], function ($, Config, Util, Hash, Language, UI, Constants, Feedback, h, MediaTag, Clipboard,
|
], function ($, Config, Util, Hash, Language, UI, Constants, Feedback, h, MediaTag, Clipboard,
|
||||||
Messages, AppConfig, Pages, NThen) {
|
Messages, AppConfig, Pages, NThen, InviteInner) {
|
||||||
var Scrypt = window.scrypt;
|
|
||||||
var UIElements = {};
|
var UIElements = {};
|
||||||
|
|
||||||
// Configure MediaTags to use our local viewer
|
// Configure MediaTags to use our local viewer
|
||||||
@ -1710,6 +1710,10 @@ define([
|
|||||||
$(linkError).text(Messages.team_inviteLinkErrorName).show(); // XXX
|
$(linkError).text(Messages.team_inviteLinkErrorName).show(); // XXX
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var seeds = InviteInner.deriveSeeds(hashData.key);
|
||||||
|
var salt = InviteInner.deriveSalt(pw, AppConfig.loginSalt);
|
||||||
|
|
||||||
var bytes64;
|
var bytes64;
|
||||||
NThen(function (waitFor) {
|
NThen(function (waitFor) {
|
||||||
$(linkForm).hide();
|
$(linkForm).hide();
|
||||||
@ -1717,17 +1721,9 @@ define([
|
|||||||
$nav.find('button.cp-teams-invite-create').prop('disabled', 'disabled');
|
$nav.find('button.cp-teams-invite-create').prop('disabled', 'disabled');
|
||||||
setTimeout(waitFor(), 150);
|
setTimeout(waitFor(), 150);
|
||||||
}).nThen(function (waitFor) {
|
}).nThen(function (waitFor) {
|
||||||
// Scrypt
|
InviteInner.deriveBytes(seeds.scrypt, salt, waitFor(function (_bytes) {
|
||||||
Scrypt(hashData.key,
|
|
||||||
(pw || '') + (AppConfig.loginSalt || ''), // salt
|
|
||||||
8, // memoryCost (n)
|
|
||||||
1024, // block size parameter (r)
|
|
||||||
192, // dkLen
|
|
||||||
200, // interruptStep
|
|
||||||
waitFor(function (_bytes) {
|
|
||||||
bytes64 = _bytes;
|
bytes64 = _bytes;
|
||||||
}),
|
}));
|
||||||
'base64'); // format, could be 'base64'
|
|
||||||
}).nThen(function (waitFor) {
|
}).nThen(function (waitFor) {
|
||||||
$(linkSpinText).text('Add invite link to team'); // XXX
|
$(linkSpinText).text('Add invite link to team'); // XXX
|
||||||
module.execCommand('CREATE_INVITE_LINK', {
|
module.execCommand('CREATE_INVITE_LINK', {
|
||||||
@ -1737,6 +1733,7 @@ define([
|
|||||||
bytes64: bytes64,
|
bytes64: bytes64,
|
||||||
hash: hash,
|
hash: hash,
|
||||||
teamId: config.teamId,
|
teamId: config.teamId,
|
||||||
|
seeds: seeds,
|
||||||
}, waitFor(function (obj) {
|
}, waitFor(function (obj) {
|
||||||
if (obj && obj.error) {
|
if (obj && obj.error) {
|
||||||
waitFor.abort();
|
waitFor.abort();
|
||||||
|
|||||||
@ -1,57 +1,57 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var factory = function (Hash, Nacl/*, Util, Cred, nThen */) {
|
var factory = function (Hash, Nacl, Scrypt/*, Util, Cred, nThen */) {
|
||||||
var Invite = {};
|
var Invite = {};
|
||||||
|
|
||||||
/* XXX ansuz
|
Invite.deriveSeeds = function (seed) {
|
||||||
inner invitation components
|
// take the hash of the provided seed
|
||||||
|
var u8_seed = Nacl.hash(Nacl.util.decodeBase64(seed));
|
||||||
|
|
||||||
* create an invitation link
|
// hash the first half again for scrypt's input
|
||||||
* derive secrets from a v2 link and password
|
var subseed1 = Nacl.hash(u8_seed.subarray(0, 32));
|
||||||
* split hash into two preseeds
|
// hash the remainder for the invite content
|
||||||
* preseed1 => preview hash
|
var subseed2 = Nacl.hash(u8_seed.subarray(32));
|
||||||
* scrypt(scrypt_seed) => b64_bytes
|
|
||||||
* preview an invitation link
|
|
||||||
* get preview hash from invitation link
|
|
||||||
* decrypt an invitation link
|
|
||||||
* (slowly) get b64_bytes from hash
|
|
||||||
|
|
||||||
*/
|
return {
|
||||||
|
scrypt: Nacl.util.encodeBase64(subseed1),
|
||||||
|
preview: Nacl.util.encodeBase64(subseed2),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
Invite.deriveSeeds = function (key) {
|
Invite.derivePreviewHash = function (seeds) {
|
||||||
var seeds = {};
|
return '#/2/invite/view/' +
|
||||||
|
Nacl.util.encodeBase64(seeds.preview.slice(0, 18)).replace('/', '-')
|
||||||
/*
|
|
||||||
var preview_channel;
|
|
||||||
var preview_cryptKey;
|
|
||||||
*/
|
|
||||||
var preview_secrets;
|
|
||||||
(function () {
|
|
||||||
var b64_seed = key;
|
|
||||||
if (typeof(b64_seed) !== 'string') {
|
|
||||||
return console.error('invite seed is not a string');
|
|
||||||
}
|
|
||||||
|
|
||||||
var u8_seed = Nacl.util.decodeBase64(b64_seed);
|
|
||||||
var step1 = Nacl.hash(u8_seed);
|
|
||||||
seeds.scrypt = Nacl.util.encodeBase64(step1.subarray(0, 32));
|
|
||||||
|
|
||||||
var preview_hash = '#/2/invite/view/' +
|
|
||||||
Nacl.util.encodeBase64(step1.subarray(32, 50)).replace('/', '-')
|
|
||||||
+ '/';
|
+ '/';
|
||||||
|
};
|
||||||
|
|
||||||
preview_secrets = Hash.getSecrets('pad', preview_hash);
|
Invite.derivePreviewSecrets = function (seeds) {
|
||||||
}());
|
return Hash.getSecrets('pad', Invite.derivePreviewHash(seeds));
|
||||||
return seeds;
|
};
|
||||||
|
|
||||||
|
Invite.deriveSalt = function (password, instance_salt) {
|
||||||
|
return (password || '') + (instance_salt || '');
|
||||||
};
|
};
|
||||||
|
|
||||||
// seed => bytes64
|
// seed => bytes64
|
||||||
Invite.deriveBytes = function (scrypt_seed, cb) {
|
Invite.deriveBytes = function (scrypt_seed, salt, cb) {
|
||||||
// XXX do scrypt stuff...
|
Scrypt(scrypt_seed,
|
||||||
cb = cb;
|
salt,
|
||||||
|
8, // memoryCost (n)
|
||||||
|
1024, // block size parameter (r)
|
||||||
|
192, // dkLen
|
||||||
|
200, // interruptStep
|
||||||
|
cb,
|
||||||
|
'base64'); // format, could be 'base64'
|
||||||
};
|
};
|
||||||
|
|
||||||
Invite.derivePreviewHash = function (preview_seed) {
|
Invite.getPreviewContent = function (seeds, cb) {
|
||||||
preview_seed = preview_seed;
|
var secrets = Invite.derivePreviewSecrets(seeds);
|
||||||
|
secrets = secrets;
|
||||||
|
cb("NOT_IMPLEMENTED"); // XXX cryptget
|
||||||
|
};
|
||||||
|
|
||||||
|
// XXX remember to pin invites...
|
||||||
|
Invite.setPreviewContent = function (seeds, cb) {
|
||||||
|
cb = cb;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Invite;
|
return Invite;
|
||||||
@ -60,19 +60,15 @@ var factory = function (Hash, Nacl/*, Util, Cred, nThen */) {
|
|||||||
module.exports = factory(
|
module.exports = factory(
|
||||||
require("../common-hash"),
|
require("../common-hash"),
|
||||||
require("tweetnacl/nacl-fast"),
|
require("tweetnacl/nacl-fast"),
|
||||||
require("../common-util"),
|
require("scrypt-async")
|
||||||
require("../common-credential.js"),
|
|
||||||
require("nthen")
|
|
||||||
);
|
);
|
||||||
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
|
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
|
||||||
define([
|
define([
|
||||||
'/common/common-hash.js',
|
'/common/common-hash.js',
|
||||||
'/common/common-util.js',
|
|
||||||
'/common/common-credential.js',
|
|
||||||
'/bower_components/nthen/index.js',
|
|
||||||
'/bower_components/tweetnacl/nacl-fast.min.js',
|
'/bower_components/tweetnacl/nacl-fast.min.js',
|
||||||
], function (Hash, Util, Cred, nThen) {
|
'/bower_components/scrypt_async/scrypt-async.min.js',
|
||||||
return factory(Hash, window.nacl, Util, Cred, nThen);
|
], function (Hash /*, Nacl, Scrypt */) {
|
||||||
|
return factory(Hash, window.nacl, window.Scrypt);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
|||||||
@ -18,7 +18,6 @@ define([
|
|||||||
'/common/invitation.js',
|
'/common/invitation.js',
|
||||||
'/customize/messages.js',
|
'/customize/messages.js',
|
||||||
|
|
||||||
'/bower_components/scrypt-async/scrypt-async.min.js',
|
|
||||||
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
|
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
|
||||||
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
|
||||||
'less!/teams/app-team.less',
|
'less!/teams/app-team.less',
|
||||||
@ -45,7 +44,6 @@ define([
|
|||||||
var APP = {};
|
var APP = {};
|
||||||
var driveAPP = {};
|
var driveAPP = {};
|
||||||
//var SHARED_FOLDER_NAME = Messages.fm_sharedFolderName;
|
//var SHARED_FOLDER_NAME = Messages.fm_sharedFolderName;
|
||||||
var Scrypt = window.scrypt;
|
|
||||||
|
|
||||||
var copyObjectValue = function (objRef, objToCopy) {
|
var copyObjectValue = function (objRef, objToCopy) {
|
||||||
for (var k in objRef) { delete objRef[k]; }
|
for (var k in objRef) { delete objRef[k]; }
|
||||||
@ -1055,6 +1053,20 @@ define([
|
|||||||
var $div = $(div);
|
var $div = $(div);
|
||||||
$div.empty();
|
$div.empty();
|
||||||
var bytes64;
|
var bytes64;
|
||||||
|
|
||||||
|
nThen(function (waitFor) {
|
||||||
|
// XXX show something while we're waiting for the invite preview content
|
||||||
|
waitFor = waitFor;
|
||||||
|
}).nThen(function (waitFor) {
|
||||||
|
InviteInner.getPreviewContent(seeds, waitFor(function (err, json) {
|
||||||
|
json = json; // XXX {message: "", author: "", ???}
|
||||||
|
if (err) {
|
||||||
|
// XXX handle errors
|
||||||
|
}
|
||||||
|
// XXX show invite preview content
|
||||||
|
|
||||||
|
var button = h('button', 'XXX');
|
||||||
|
button.onclick = function () {
|
||||||
nThen(function (waitFor) {
|
nThen(function (waitFor) {
|
||||||
$div.append(h('div', [
|
$div.append(h('div', [
|
||||||
h('i.fa.fa-spin.fa-spinner'),
|
h('i.fa.fa-spin.fa-spinner'),
|
||||||
@ -1062,17 +1074,10 @@ define([
|
|||||||
]));
|
]));
|
||||||
setTimeout(waitFor(), 150);
|
setTimeout(waitFor(), 150);
|
||||||
}).nThen(function (waitFor) {
|
}).nThen(function (waitFor) {
|
||||||
// XXX ansuz InviteInner.deriveBytes
|
var salt = InviteInner.deriveSalt(pw, AppConfig.loginSalt);
|
||||||
Scrypt(seeds.scrypt,
|
InviteInner.deriveBytes(seeds.scrypt, salt, waitFor(function (bytes) {
|
||||||
(pw || '') + (AppConfig.loginSalt || ''), // salt
|
bytes64 = bytes;
|
||||||
8, // memoryCost (n)
|
}));
|
||||||
1024, // block size parameter (r)
|
|
||||||
192, // dkLen
|
|
||||||
200, // interruptStep
|
|
||||||
waitFor(function (_bytes) {
|
|
||||||
bytes64 = _bytes;
|
|
||||||
}),
|
|
||||||
'base64'); // format, could be 'base64'
|
|
||||||
}).nThen(function (waitFor) {
|
}).nThen(function (waitFor) {
|
||||||
APP.module.execCommand('GET_LINK_DATA', {
|
APP.module.execCommand('GET_LINK_DATA', {
|
||||||
bytes64: bytes64,
|
bytes64: bytes64,
|
||||||
@ -1086,6 +1091,11 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$div.append(button);
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
var content = [];
|
var content = [];
|
||||||
if (password) {
|
if (password) {
|
||||||
// XXX XXX
|
// XXX XXX
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user