From 7c5ab63fd82eee3c597cd54bae76557af497b0d5 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 26 May 2016 17:14:33 +0100 Subject: js group demo: use a remoteOps object To make sure that we don't sneakily use methods which we wouldn't be able to for remote users, expose an interface object which contains the remote interface. --- javascript/demo/group_demo.js | 51 +++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'javascript/demo') diff --git a/javascript/demo/group_demo.js b/javascript/demo/group_demo.js index c8939d3..bd54ea0 100644 --- a/javascript/demo/group_demo.js +++ b/javascript/demo/group_demo.js @@ -24,8 +24,9 @@ function DemoUser(name) { this.olmAccount = new Olm.Account(); this.olmAccount.create(); - /* a list of the people in our chat */ - this.peers = []; + /* the people in our chat, indexed by their Curve25519 identity key. + */ + this.peers = {}; /* for each peer, a one-to-one session - indexed by id key and created on * demand */ @@ -41,6 +42,18 @@ function DemoUser(name) { /* a list of pending tasks */ this.tasks = []; this.taskWorker = undefined; + + /* the operations our peers are allowed to do on us */ + var publicOps = [ + "getIdKey", "getOneTimeKey", + "receiveOneToOne", "receiveGroup", + ]; + + this.remoteOps = {}; + for (var i=0; i