diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/rpc.js | 11 | ||||
| -rw-r--r-- | lib/sockets.js | 6 |
2 files changed, 10 insertions, 7 deletions
@@ -5,9 +5,10 @@ export default ({ host, port, wallet, username, password }) => {}, { get: (target, prop) => (...params) => - ((method, ...params) => - wretch() - .url(`http://${host}:${port}/wallet/${wallet}`) + ((method, ...params) => { + let url = `http://${host}:${port}/wallet/${wallet}`; + return wretch() + .url(url) .auth( `Basic ${Buffer.from(`${username}:${password}`).toString( "base64" @@ -17,6 +18,8 @@ export default ({ host, port, wallet, username, password }) => method, params }) - .json(({ result }) => result))(prop.toLowerCase(), ...params) + .json(({ result }) => result) + })(prop.toLowerCase(), ...params) + } ); diff --git a/lib/sockets.js b/lib/sockets.js index ee16b962..33d1d208 100644 --- a/lib/sockets.js +++ b/lib/sockets.js @@ -90,8 +90,7 @@ app.register(async function(app) { case "login": let token = data; - - if (lastSeen[token] > subtractSeconds(5)) ws.close(); + if (lastSeen[token] > subtractSeconds(5)) return; lastSeen[token] = new Date(); try { @@ -136,6 +135,7 @@ app.register(async function(app) { }); let accounts = await user.getAccounts(); + let keys = await user.getKeys(); user = user.get({ plain: true }); user.accounts = accounts; @@ -194,7 +194,7 @@ app.register(async function(app) { }); ws.on("close", function(code, reason) { - // if (reason) console.log("closing socket", reason); + // if (reason) console.log("closing socket", reason.toString(), id); try { const username = names[id]; if (store.sockets[username] && store.sockets[username][id]) { |
