From 909e00bbc3f25803a2a9332ff8947ae1ff98f299 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 6 Jul 2017 10:25:43 +0200 Subject: [PATCH] create a listmap object using public key crypto --- www/common/curve-put.js | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 www/common/curve-put.js diff --git a/www/common/curve-put.js b/www/common/curve-put.js new file mode 100644 index 000000000..1916e31f9 --- /dev/null +++ b/www/common/curve-put.js @@ -0,0 +1,47 @@ +define([ + '/common/curve.js', + '/bower_components/chainpad-listmap/chainpad-listmap.js', +], function (Curve, Listmap) { + var Edit = {}; + + Edit.create = function (network, channel, theirs, mine, cb) { + try { + var encryptor = Curve.createEncryptor(theirs, mine); + var lm = Listmap.create({ + network: network, + data: {}, + channel: channel, + readOnly: false, + validateKey: undefined, + crypto: encryptor, + userName: 'lol', + logLevel: 1, + }); + + var done = function () { + // TODO make this abort and disconnect the session after the + // user has finished making changes to the object, and they + // have propagated. + }; + + lm.proxy + .on('create', function () { + console.log('created'); + }) + .on('ready', function () { + console.log('ready'); + cb(lm); + }) + .on('disconnect', function () { + console.log('disconnected'); + }) + .on('change', [], function (o, n, p) { + console.log(o, n, p); + }); + } catch (e) { + console.error(e); + } + }; + + return Edit; +});