WIP invitation API
This commit is contained in:
parent
7a5bfe8245
commit
4a83103f52
@ -1650,7 +1650,7 @@ define([
|
|||||||
placeholder: 'password...' // XXX
|
placeholder: 'password...' // XXX
|
||||||
}),
|
}),
|
||||||
h('br'),
|
h('br'),
|
||||||
linkMessage = h('textarea', {
|
linkMessage = h('textarea', { // XXX ansuz hitting enter submits...
|
||||||
placeholder: 'note...' // XXX
|
placeholder: 'note...' // XXX
|
||||||
})
|
})
|
||||||
]),
|
]),
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var factory = function (/* Util, Cred, nThen */) {
|
var factory = function (Hash, Nacl/*, Util, Cred, nThen */) {
|
||||||
var Invite = {};
|
var Invite = {};
|
||||||
|
|
||||||
/* XXX ansuz
|
/* XXX ansuz
|
||||||
@ -20,12 +20,13 @@ var factory = function (/* Util, Cred, nThen */) {
|
|||||||
Invite.deriveSeeds = function (key) {
|
Invite.deriveSeeds = function (key) {
|
||||||
var seeds = {};
|
var seeds = {};
|
||||||
|
|
||||||
var scrypt_seed;
|
/*
|
||||||
var preview_secrets;
|
|
||||||
var preview_channel;
|
var preview_channel;
|
||||||
var preview_cryptKey;
|
var preview_cryptKey;
|
||||||
|
*/
|
||||||
|
var preview_secrets;
|
||||||
(function () {
|
(function () {
|
||||||
var b64_seed = hashData.key;
|
var b64_seed = key;
|
||||||
if (typeof(b64_seed) !== 'string') {
|
if (typeof(b64_seed) !== 'string') {
|
||||||
return console.error('invite seed is not a string');
|
return console.error('invite seed is not a string');
|
||||||
}
|
}
|
||||||
@ -46,28 +47,32 @@ var factory = function (/* Util, Cred, nThen */) {
|
|||||||
// seed => bytes64
|
// seed => bytes64
|
||||||
Invite.deriveBytes = function (scrypt_seed, cb) {
|
Invite.deriveBytes = function (scrypt_seed, cb) {
|
||||||
// XXX do scrypt stuff...
|
// XXX do scrypt stuff...
|
||||||
|
cb = cb;
|
||||||
};
|
};
|
||||||
|
|
||||||
Invite.derivePreviewHash = function (preview_seed) {
|
Invite.derivePreviewHash = function (preview_seed) {
|
||||||
|
preview_seed = preview_seed;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Invite;
|
return Invite;
|
||||||
};
|
};
|
||||||
if (typeof(module) !== 'undefined' && module.exports) {
|
if (typeof(module) !== 'undefined' && module.exports) {
|
||||||
module.exports = factory(
|
module.exports = factory(
|
||||||
|
require("../common-hash"),
|
||||||
|
require("tweetnacl/nacl-fast"),
|
||||||
require("../common-util"),
|
require("../common-util"),
|
||||||
require("../common-credential.js"),
|
require("../common-credential.js"),
|
||||||
require("nthen")
|
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-util.js',
|
'/common/common-util.js',
|
||||||
'/common/common-credential.js',
|
'/common/common-credential.js',
|
||||||
'/bower_components/nthen/index.js',
|
'/bower_components/nthen/index.js',
|
||||||
], function (Util, Cred, nThen) {
|
'/bower_components/tweetnacl/nacl-fast.min.js',
|
||||||
return factory(Util, nThen);
|
], function (Hash, Util, Cred, nThen) {
|
||||||
|
return factory(Hash, window.nacl, Util, Cred, nThen);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
|
|||||||
@ -3,23 +3,50 @@ var factory = function (Util, Cred, nThen) {
|
|||||||
nThen = nThen; // XXX
|
nThen = nThen; // XXX
|
||||||
var Invite = {};
|
var Invite = {};
|
||||||
|
|
||||||
/*
|
/* INPUTS
|
||||||
TODO key derivation
|
|
||||||
|
* password (for scrypt)
|
||||||
|
* message (personal note)
|
||||||
|
* link hash
|
||||||
|
* bytes64 (scrypt output)
|
||||||
|
* preview_hash
|
||||||
|
|
||||||
scrypt(seed, passwd) => {
|
|
||||||
curve: {
|
|
||||||
private,
|
|
||||||
public,
|
|
||||||
},
|
|
||||||
ed: {
|
|
||||||
private,
|
|
||||||
public,
|
|
||||||
}
|
|
||||||
cryptKey,
|
|
||||||
channel
|
|
||||||
}
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* DERIVATIONS
|
||||||
|
|
||||||
|
* components corresponding to www/common/invitation.js
|
||||||
|
* preview_hash => components
|
||||||
|
* channel
|
||||||
|
* cryptKey
|
||||||
|
* b64_bytes
|
||||||
|
* curvePrivate => curvePublic
|
||||||
|
* edSeed => edPrivate => edPublic
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* IO / FUNCTIONALITY
|
||||||
|
|
||||||
|
* creator
|
||||||
|
* generate a random signKey (prevent writes to preview channel)
|
||||||
|
* encrypt and upload the preview content
|
||||||
|
* via CryptGet
|
||||||
|
* owned by:
|
||||||
|
* the ephemeral edPublic
|
||||||
|
* the invite creator
|
||||||
|
* create a roster entry for the invitation
|
||||||
|
* with encrypted notes for the creator
|
||||||
|
* redeemer
|
||||||
|
* get the preview content
|
||||||
|
* redeem the invite
|
||||||
|
* add yourself to the roster
|
||||||
|
* add the team to your proxy-manager
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
var BYTES_REQUIRED = 256;
|
var BYTES_REQUIRED = 256;
|
||||||
|
|
||||||
Invite.deriveKeys = function (seed, passwd, cb) {
|
Invite.deriveKeys = function (seed, passwd, cb) {
|
||||||
|
|||||||
@ -10,6 +10,7 @@ define([
|
|||||||
'/common/outer/roster.js',
|
'/common/outer/roster.js',
|
||||||
'/common/common-messaging.js',
|
'/common/common-messaging.js',
|
||||||
'/common/common-feedback.js',
|
'/common/common-feedback.js',
|
||||||
|
'/common/outer/invitation.js',
|
||||||
|
|
||||||
'/bower_components/chainpad-listmap/chainpad-listmap.js',
|
'/bower_components/chainpad-listmap/chainpad-listmap.js',
|
||||||
'/bower_components/chainpad-crypto/crypto.js',
|
'/bower_components/chainpad-crypto/crypto.js',
|
||||||
@ -19,7 +20,7 @@ define([
|
|||||||
'/bower_components/saferphore/index.js',
|
'/bower_components/saferphore/index.js',
|
||||||
'/bower_components/tweetnacl/nacl-fast.min.js',
|
'/bower_components/tweetnacl/nacl-fast.min.js',
|
||||||
], function (Util, Hash, Constants, Realtime,
|
], function (Util, Hash, Constants, Realtime,
|
||||||
ProxyManager, UserObject, SF, Roster, Messaging, Feedback,
|
ProxyManager, UserObject, SF, Roster, Messaging, Feedback, Invite,
|
||||||
Listmap, Crypto, CpNetflux, ChainPad, nThen, Saferphore) {
|
Listmap, Crypto, CpNetflux, ChainPad, nThen, Saferphore) {
|
||||||
var Team = {};
|
var Team = {};
|
||||||
|
|
||||||
@ -1259,7 +1260,9 @@ define([
|
|||||||
ctx.store.messenger.openTeamChat(team.getChatData(), onUpdate, cId, cb);
|
ctx.store.messenger.openTeamChat(team.getChatData(), onUpdate, cId, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// XXX ansuz
|
||||||
var createInviteLink = function (ctx, data, cId, cb) {
|
var createInviteLink = function (ctx, data, cId, cb) {
|
||||||
|
Invite = Invite;
|
||||||
var team = ctx.teams[data.teamId];
|
var team = ctx.teams[data.teamId];
|
||||||
team = team;
|
team = team;
|
||||||
/*
|
/*
|
||||||
@ -1277,6 +1280,7 @@ define([
|
|||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
// XXX ansuz
|
||||||
var getLinkData = function (ctx, data, cId, cb) {
|
var getLinkData = function (ctx, data, cId, cb) {
|
||||||
/*
|
/*
|
||||||
var password = data.password;
|
var password = data.password;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user