diff options
author | Saúl Ibarra Corretgé <s@saghul.net> | 2020-06-17 13:51:49 +0200 |
---|---|---|
committer | Hubert Chathi <hubert@uhoreg.ca> | 2020-07-04 16:59:26 -0400 |
commit | a0284c2ba36ac8433ea752e93b4a0a331a3f0c0b (patch) | |
tree | 0dc6d871b1d851dee5a46aa47066ca3519c7c9f3 /javascript/demo/group_demo.js | |
parent | 8a958beb483b41eda34622c778983421baa7b06d (diff) |
Fix group demo to work with > 2 users
Add 4 by default, and make sure OT keys are not reused.
Diffstat (limited to 'javascript/demo/group_demo.js')
-rw-r--r-- | javascript/demo/group_demo.js | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/javascript/demo/group_demo.js b/javascript/demo/group_demo.js index 7cd9e3e..44b8166 100644 --- a/javascript/demo/group_demo.js +++ b/javascript/demo/group_demo.js @@ -167,20 +167,13 @@ DemoUser.prototype.getIdKeys = function() { return JSON.parse(this.olmAccount.identity_keys()); }; -DemoUser.prototype.generateKeys = function(callback) { - var self = this; - this.addTask("generate one time key", function(done) { - self.olmAccount.generate_one_time_keys(1); - done(); - }, callback); -}; - DemoUser.prototype.getOneTimeKey = function() { var self = this; - var keys = JSON.parse(self.olmAccount.one_time_keys()) - .curve25519; + self.olmAccount.generate_one_time_keys(1); + var keys = JSON.parse(self.olmAccount.one_time_keys()).curve25519; for (key_id in keys) { if (keys.hasOwnProperty(key_id)) { + self.olmAccount.mark_keys_as_published(); return keys[key_id]; } } @@ -478,14 +471,31 @@ function initUserDiv(demoUser, div) { function startDemo() { var user1 = new DemoUser(); initUserDiv(user1, document.getElementById("user1")); - user1.generateKeys(); var user2 = new DemoUser(); initUserDiv(user2, document.getElementById("user2")); - user2.generateKeys(); + + var user3 = new DemoUser(); + initUserDiv(user3, document.getElementById("user3")); + + var user4 = new DemoUser(); + initUserDiv(user4, document.getElementById("user4")); user1.addPeer(user2.remoteOps); + user1.addPeer(user3.remoteOps); + user1.addPeer(user4.remoteOps); + user2.addPeer(user1.remoteOps); + user2.addPeer(user3.remoteOps); + user2.addPeer(user4.remoteOps); + + user3.addPeer(user1.remoteOps); + user3.addPeer(user2.remoteOps); + user3.addPeer(user4.remoteOps); + + user4.addPeer(user1.remoteOps); + user4.addPeer(user2.remoteOps); + user4.addPeer(user3.remoteOps); } |