From 9195c5744549fab0104fa844f5581ff0c7a7f755 Mon Sep 17 00:00:00 2001 From: yflory Date: Mon, 4 Jun 2018 14:59:37 +0200 Subject: [PATCH 1/8] Use socket.io instead of WebSocket --- package.json | 1 + server.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7ad861062..06214aab8 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "pull-stream": "^3.6.1", "replify": "^1.2.0", "saferphore": "0.0.1", + "socket.io": "^2.1.1", "sortify": "^1.0.4", "stream-to-pull-stream": "^1.7.2", "tweetnacl": "~0.12.2", diff --git a/server.js b/server.js index aac8d7513..feddc8bbe 100644 --- a/server.js +++ b/server.js @@ -5,7 +5,7 @@ var Express = require('express'); var Http = require('http'); var Https = require('https'); var Fs = require('fs'); -var WebSocketServer = require('ws').Server; +var SocketIO = require('socket.io'); var NetfluxSrv = require('./node_modules/chainpad-server/NetfluxWebsocketSrv'); var Package = require('./package.json'); var Path = require("path"); @@ -246,7 +246,10 @@ var nt = nThen(function (w) { console.log("setting up a new websocket server"); wsConfig = { port: websocketPort}; } - var wsSrv = new WebSocketServer(wsConfig); + var wsSrv = new SocketIO(httpServer, { + path: config.websocketPath || '/cryptpad_websocket' + }); + Storage.create(config, function (store) { NetfluxSrv.run(store, wsSrv, config, rpc); }); From 184708f859f74a36feb7d14d8153fb533fa9b22a Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 21 Jun 2018 10:40:09 +0200 Subject: [PATCH 2/8] fix login from register page --- customize.dist/login.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/customize.dist/login.js b/customize.dist/login.js index 4d2855b16..13fb6f40c 100644 --- a/customize.dist/login.js +++ b/customize.dist/login.js @@ -268,7 +268,9 @@ define([ proxy[Constants.displayNameKey] = uname; } LocalStore.eraseTempSessionValues(); - proceed(result); + LocalStore.login(result.userHash, result.userName, function () { + setTimeout(function () { proceed(result); }); + }); }); }); break; From 29aca1da02deacba702caa4261e493b18cf04aa9 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 21 Jun 2018 14:36:38 +0200 Subject: [PATCH 3/8] Bump listmap version --- bower.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 8e6d5cb79..b35e8e481 100644 --- a/bower.json +++ b/bower.json @@ -30,9 +30,8 @@ "secure-fabric.js": "secure-v1.7.9", "hyperjson": "~1.4.0", "chainpad-crypto": "^0.2.0", - "chainpad-listmap": "^0.5.0", + "chainpad-listmap": "^0.6.0", "chainpad": "^5.1.0", - "chainpad-netflux": "^0.7.0", "file-saver": "1.3.1", "alertifyjs": "1.0.11", "scrypt-async": "1.2.0", From ad0663c1683873f332ae7c2c27f20d5c6a87b7f7 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 21 Jun 2018 16:48:09 +0200 Subject: [PATCH 4/8] :q --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 27cf19d81..b50288ea7 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "2.3.0", "license": "AGPL-3.0-or-later", "dependencies": { - "chainpad-server": "^2.0.0", + "chainpad-server": "^2.1.0", "express": "~4.16.0", "mkdirp": "^0.5.1", "nthen": "~0.1.0", From 990471460c9517397104d9daf1c0995b6d9ac099 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 21 Jun 2018 16:51:28 +0200 Subject: [PATCH 5/8] lint compliance --- www/common/cryptpad-common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 1193e7303..d76e6d58a 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -741,7 +741,7 @@ define([ } }), optsPut); })); - }).nThen(function (waitFor) { + }).nThen(function (/* waitFor */) { // Migration success // TODO: Replace user hash in login block }).nThen(function (waitFor) { From 89e64a724357f50816e2f076cfc220955f98c461 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 21 Jun 2018 16:52:04 +0200 Subject: [PATCH 6/8] dispense bytes for block location --- customize.dist/login.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/customize.dist/login.js b/customize.dist/login.js index e8c78726a..ab0290909 100644 --- a/customize.dist/login.js +++ b/customize.dist/login.js @@ -13,11 +13,12 @@ define([ '/common/outer/local-store.js', '/customize/messages.js', '/bower_components/nthen/index.js', + '/common/outer/login-block.js', '/bower_components/tweetnacl/nacl-fast.min.js', '/bower_components/scrypt-async/scrypt-async.min.js', // better load speed ], function ($, Listmap, Crypto, Util, NetConfig, Cred, ChainPad, Realtime, Constants, UI, - Feedback, LocalStore, Messages, nThen) { + Feedback, LocalStore, Messages, nThen, Block) { var Exports = { Cred: Cred, }; @@ -42,11 +43,11 @@ define([ // 32 more for a signing key var edSeed = opt.edSeed = dispense(32); - // TODO // 32 more bytes to seed an additional signing key + opt.blockSignSeed = dispense(32); - // TODO // 32 more bytes for a symmetric key for block encryption + opt.blockSymmetric = dispense(32); // derive a private key from the ed seed var signingKeypair = Nacl.sign.keyPair.fromSeed(new Uint8Array(edSeed)); @@ -124,6 +125,14 @@ define([ // run scrypt to derive the user's keys res.opt = allocateBytes(bytes); })); + + + // TODO consider checking the block here + }).nThen(function (/* waitFor */) { + // check for blocks + Block = Block; // jshint + + }).nThen(function (waitFor) { var opt = res.opt; // use the derived key to generate an object From 567a4d2d9828c886bd8db8d5b36fd97fd1035e75 Mon Sep 17 00:00:00 2001 From: ansuz Date: Thu, 21 Jun 2018 16:54:57 +0200 Subject: [PATCH 7/8] use more restrictive semver for chainpad-server --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8de5b61f4..fc1810da8 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "2.3.0", "license": "AGPL-3.0-or-later", "dependencies": { - "chainpad-server": "^2.0.0", + "chainpad-server": "~2.0.0", "express": "~4.16.0", "mkdirp": "^0.5.1", "nthen": "~0.1.0", From ddcbd000dc5722772e5fcffc732fbcb3ce4d9f0e Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 21 Jun 2018 16:55:54 +0200 Subject: [PATCH 8/8] Bump chainpad-server version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b50288ea7..c6b69cf44 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "2.3.0", "license": "AGPL-3.0-or-later", "dependencies": { - "chainpad-server": "^2.1.0", + "chainpad-server": "~2.1.0", "express": "~4.16.0", "mkdirp": "^0.5.1", "nthen": "~0.1.0",