Merge branch 'invitations' into staging
This commit is contained in:
@@ -4,7 +4,7 @@ define([
|
|||||||
'/bower_components/chainpad-crypto/crypto.js',
|
'/bower_components/chainpad-crypto/crypto.js',
|
||||||
'/common/common-util.js',
|
'/common/common-util.js',
|
||||||
'/common/outer/network-config.js',
|
'/common/outer/network-config.js',
|
||||||
'/customize/credential.js',
|
'/common/common-credential.js',
|
||||||
'/bower_components/chainpad/chainpad.dist.js',
|
'/bower_components/chainpad/chainpad.dist.js',
|
||||||
'/common/common-realtime.js',
|
'/common/common-realtime.js',
|
||||||
'/common/common-constants.js',
|
'/common/common-constants.js',
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ var deduplicate = require("./deduplicate");
|
|||||||
|
|
||||||
var commands = {};
|
var commands = {};
|
||||||
|
|
||||||
|
var isValidOwner = function (owner) {
|
||||||
|
return typeof(owner) === 'string' && owner.length === 44;
|
||||||
|
};
|
||||||
|
|
||||||
// ["ADD_OWNERS", ["7eEqelGso3EBr5jHlei6av4r9w2B9XZiGGwA1EgZ-5I="], 1561623438989]
|
// ["ADD_OWNERS", ["7eEqelGso3EBr5jHlei6av4r9w2B9XZiGGwA1EgZ-5I="], 1561623438989]
|
||||||
commands.ADD_OWNERS = function (meta, args) {
|
commands.ADD_OWNERS = function (meta, args) {
|
||||||
// bail out if args isn't an array
|
// bail out if args isn't an array
|
||||||
@@ -30,6 +34,7 @@ commands.ADD_OWNERS = function (meta, args) {
|
|||||||
|
|
||||||
var changed = false;
|
var changed = false;
|
||||||
args.forEach(function (owner) {
|
args.forEach(function (owner) {
|
||||||
|
if (!isValidOwner(owner)) { return; }
|
||||||
if (meta.owners.indexOf(owner) >= 0) { return; }
|
if (meta.owners.indexOf(owner) >= 0) { return; }
|
||||||
meta.owners.push(owner);
|
meta.owners.push(owner);
|
||||||
changed = true;
|
changed = true;
|
||||||
@@ -90,6 +95,7 @@ commands.ADD_PENDING_OWNERS = function (meta, args) {
|
|||||||
}
|
}
|
||||||
// or fill it
|
// or fill it
|
||||||
args.forEach(function (owner) {
|
args.forEach(function (owner) {
|
||||||
|
if (!isValidOwner(owner)) { return; }
|
||||||
if (meta.pending_owners.indexOf(owner) >= 0) { return; }
|
if (meta.pending_owners.indexOf(owner) >= 0) { return; }
|
||||||
meta.pending_owners.push(owner);
|
meta.pending_owners.push(owner);
|
||||||
changed = true;
|
changed = true;
|
||||||
@@ -134,7 +140,7 @@ commands.RESET_OWNERS = function (meta, args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// overwrite the existing owners with the new one
|
// overwrite the existing owners with the new one
|
||||||
meta.owners = deduplicate(args);
|
meta.owners = deduplicate(args.filter(isValidOwner));
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
define([
|
(function () {
|
||||||
'/customize/application_config.js',
|
var factory = function (AppConfig, Scrypt) {
|
||||||
'/bower_components/scrypt-async/scrypt-async.min.js',
|
|
||||||
], function (AppConfig) {
|
|
||||||
var Cred = {};
|
var Cred = {};
|
||||||
var Scrypt = window.scrypt;
|
|
||||||
|
|
||||||
Cred.MINIMUM_PASSWORD_LENGTH = typeof(AppConfig.minimumPasswordLength) === 'number'?
|
Cred.MINIMUM_PASSWORD_LENGTH = typeof(AppConfig.minimumPasswordLength) === 'number'?
|
||||||
AppConfig.minimumPasswordLength: 8;
|
AppConfig.minimumPasswordLength: 8;
|
||||||
@@ -86,4 +83,19 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
return Cred;
|
return Cred;
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (typeof(module) !== 'undefined' && module.exports) {
|
||||||
|
module.exports = factory(
|
||||||
|
{}, //require("../../customize.dist/application_config.js"),
|
||||||
|
require("../bower_components/scrypt-async/scrypt-async.min.js")
|
||||||
|
);
|
||||||
|
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
|
||||||
|
define([
|
||||||
|
'/customize/application_config.js',
|
||||||
|
'/bower_components/scrypt-async/scrypt-async.min.js',
|
||||||
|
], function (AppConfig) {
|
||||||
|
return factory(AppConfig, window.scrypt);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}());
|
||||||
@@ -1017,7 +1017,7 @@ define([
|
|||||||
var Cred, Block, Login;
|
var Cred, Block, Login;
|
||||||
Nthen(function (waitFor) {
|
Nthen(function (waitFor) {
|
||||||
require([
|
require([
|
||||||
'/customize/credential.js',
|
'/common/common-credential.js',
|
||||||
'/common/outer/login-block.js',
|
'/common/outer/login-block.js',
|
||||||
'/customize/login.js'
|
'/customize/login.js'
|
||||||
], waitFor(function (_Cred, _Block, _Login) {
|
], waitFor(function (_Cred, _Block, _Login) {
|
||||||
|
|||||||
95
www/common/outer/invitation.js
Normal file
95
www/common/outer/invitation.js
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
(function () {
|
||||||
|
var factory = function (Util, Cred, nThen) {
|
||||||
|
nThen = nThen; // XXX
|
||||||
|
var Invite = {};
|
||||||
|
|
||||||
|
/*
|
||||||
|
TODO key derivation
|
||||||
|
|
||||||
|
scrypt(seed, passwd) => {
|
||||||
|
curve: {
|
||||||
|
private,
|
||||||
|
public,
|
||||||
|
},
|
||||||
|
ed: {
|
||||||
|
private,
|
||||||
|
public,
|
||||||
|
}
|
||||||
|
cryptKey,
|
||||||
|
channel
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
var BYTES_REQUIRED = 256;
|
||||||
|
|
||||||
|
Invite.deriveKeys = function (seed, passwd, cb) {
|
||||||
|
cb = cb; // XXX
|
||||||
|
// TODO validate has cb
|
||||||
|
// TODO onceAsync the cb
|
||||||
|
// TODO cb with err if !(seed && passwd)
|
||||||
|
|
||||||
|
Cred.deriveFromPassphrase(seed, passwd, BYTES_REQUIRED, function (bytes) {
|
||||||
|
var dispense = Cred.dispenser(bytes);
|
||||||
|
dispense = dispense; // XXX
|
||||||
|
|
||||||
|
// edPriv => edPub
|
||||||
|
// curvePriv => curvePub
|
||||||
|
// channel
|
||||||
|
// cryptKey
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Invite.createSeed = function () {
|
||||||
|
// XXX
|
||||||
|
// return a seed
|
||||||
|
};
|
||||||
|
|
||||||
|
Invite.create = function (cb) {
|
||||||
|
cb = cb; // XXX
|
||||||
|
// TODO validate has cb
|
||||||
|
// TODO onceAsync the cb
|
||||||
|
// TODO cb with err if !(seed && passwd)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// required
|
||||||
|
// password
|
||||||
|
// validateKey
|
||||||
|
// creatorEdPublic
|
||||||
|
// for owner
|
||||||
|
// ephemeral
|
||||||
|
// signingKey
|
||||||
|
// for owner to write invitation
|
||||||
|
// derived
|
||||||
|
// edPriv
|
||||||
|
// edPublic
|
||||||
|
// for invitee ownership
|
||||||
|
// curvePriv
|
||||||
|
// curvePub
|
||||||
|
// for acceptance OR
|
||||||
|
// authenticated decline message via mailbox
|
||||||
|
// channel
|
||||||
|
// for owned deletion
|
||||||
|
// for team pinning
|
||||||
|
// cryptKey
|
||||||
|
// for protecting channel content
|
||||||
|
};
|
||||||
|
|
||||||
|
return Invite;
|
||||||
|
};
|
||||||
|
if (typeof(module) !== 'undefined' && module.exports) {
|
||||||
|
module.exports = factory(
|
||||||
|
require("../common-util"),
|
||||||
|
require("../common-credential.js"),
|
||||||
|
require("nthen")
|
||||||
|
);
|
||||||
|
} else if ((typeof(define) !== 'undefined' && define !== null) && (define.amd !== null)) {
|
||||||
|
define([
|
||||||
|
'/common/common-util.js',
|
||||||
|
'/common/common-credential.js',
|
||||||
|
'/bower_components/nthen/index.js',
|
||||||
|
], function (Util, Cred, nThen) {
|
||||||
|
return factory(Util, nThen);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}());
|
||||||
@@ -3,7 +3,7 @@ define([
|
|||||||
'/customize/login.js',
|
'/customize/login.js',
|
||||||
'/common/cryptpad-common.js',
|
'/common/cryptpad-common.js',
|
||||||
'/common/test.js',
|
'/common/test.js',
|
||||||
'/customize/credential.js', // preloaded for login.js
|
'/common/common-credential.js',
|
||||||
'/common/common-interface.js',
|
'/common/common-interface.js',
|
||||||
'/common/common-util.js',
|
'/common/common-util.js',
|
||||||
'/common/common-realtime.js',
|
'/common/common-realtime.js',
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ define([
|
|||||||
'/common/common-hash.js',
|
'/common/common-hash.js',
|
||||||
'/customize/messages.js',
|
'/customize/messages.js',
|
||||||
'/common/hyperscript.js',
|
'/common/hyperscript.js',
|
||||||
'/customize/credential.js',
|
'/common/common-credential.js',
|
||||||
'/customize/application_config.js',
|
'/customize/application_config.js',
|
||||||
'/api/config',
|
'/api/config',
|
||||||
'/common/make-backup.js',
|
'/common/make-backup.js',
|
||||||
|
|||||||
Reference in New Issue
Block a user