From 5d3ff351b0a9270f2983143057b11652f13837a0 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sat, 18 Jul 2020 14:39:46 -0400 Subject: [PATCH 01/29] remove excessive log --- services/gunDB/contact-api/events/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/gunDB/contact-api/events/index.js b/services/gunDB/contact-api/events/index.js index 9d2fa01e..3fbaddf8 100644 --- a/services/gunDB/contact-api/events/index.js +++ b/services/gunDB/contact-api/events/index.js @@ -452,7 +452,7 @@ const getChats = () => currentChats const chatsListeners = new Set() chatsListeners.add(c => { - logger.info(`new Chats: ${JSON.stringify(c, null, 4)}`) + logger.info(`Chats: ${c.length}`) }) const notifyChatsListeners = () => { From 8a647dd380acbf765a9cb9008692c0c7a7399062 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sat, 18 Jul 2020 14:44:37 -0400 Subject: [PATCH 02/29] remove excessive log --- src/routes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes.js b/src/routes.js index 22e163e7..2e9d50b9 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1772,7 +1772,7 @@ module.exports = async ( try { const user = require('../services/gunDB/Mediator').getUser() const data = await timeout5(user.get(Key.PROFILE).get(Key.AVATAR).then()) - logger.info(`avatar poll:${data}`) + logger.info(`avatar poll:${data.length} chars`) res.json({ data }) From ab3d5a8ee8fef92b1dee10d22bcce70eec38cef8 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sat, 18 Jul 2020 14:59:54 -0400 Subject: [PATCH 03/29] compress log size --- services/gunDB/contact-api/events/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/gunDB/contact-api/events/index.js b/services/gunDB/contact-api/events/index.js index 3fbaddf8..24f66a0b 100644 --- a/services/gunDB/contact-api/events/index.js +++ b/services/gunDB/contact-api/events/index.js @@ -329,7 +329,11 @@ const getCurrentOutgoings = () => currentOutgoings const outgoingsListeners = new Set() outgoingsListeners.add(o => { - logger.info(`new outgoings: ${JSON.stringify(o, null, 4)}`) + const values = Object.values(o) + const nulls = values.filter(x => x === null).length + const nonNulls = values.length - nulls + + logger.info(`new outgoings, ${nulls} nulls and ${nonNulls} nonNulls`) }) const notifyOutgoingsListeners = () => { From 296269991c8da8f0c33f64d3208111a1916d8755 Mon Sep 17 00:00:00 2001 From: emad-salah Date: Sun, 19 Jul 2020 12:58:09 +0100 Subject: [PATCH 04/29] GitHub Actions setup for dispatching Wizard builds --- .github/workflows/main.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..163b5e8a --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,21 @@ +name: Update Wizard + +on: + push: + branches: [ 'feature/synchronized-wizard-builds' ] + pull_request: + branches: [ 'feature/synchronized-wizard-builds' ] + +jobs: + dispatch: + strategy: + matrix: + repo: ['shocknet/Wizard'] + runs-on: ubuntu-latest + steps: + - name: Repository Dispatch + uses: peter-evans/repository-dispatch@v1 + with: + token: ${{ secrets.REPO_ACCESS_TOKEN }} + repository: ${{ matrix.repo }} + event-type: api-update From 8c5173b154d2b6a3cd1fc45845f658efeac4ec24 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Mon, 20 Jul 2020 13:10:31 -0400 Subject: [PATCH 05/29] remove excessive log --- src/routes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes.js b/src/routes.js index 2e9d50b9..00bf57f5 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1755,7 +1755,7 @@ module.exports = async ( // spinup Events.onChats(() => {})() const data = Events.getChats() - logger.info(`Chats polled: ${JSON.stringify(data, null, 4)}`) + logger.info(`Chats polled: ${data.length}`) res.json({ data }) From c7715a8f3b02ce5f75814d6070932ae877b19223 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Mon, 20 Jul 2020 15:12:56 -0400 Subject: [PATCH 06/29] contact actions and reads through HTTP --- src/routes.js | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) diff --git a/src/routes.js b/src/routes.js index 00bf57f5..bc4554a2 100644 --- a/src/routes.js +++ b/src/routes.js @@ -2054,6 +2054,175 @@ module.exports = async ( ap.get(`/api/gun/me`, apiGunMeGet) ap.put(`/api/gun/me`, apiGunMePut) + /** + * @typedef {object} ChatsRouteParams + * @prop {(string|undefined)=} publicKey + */ + + /** + * @type {RequestHandler} + */ + const apiGunChatsPost = async (req, res) => { + const { publicKey } = req.params + const { body } = req.body + + if (!publicKey) { + return res.status(400).json({ + errorMessage: `Must specify a publicKey route param for POSTing a message` + }) + } + + try { + const user = GunDB.getUser() + const SEA = GunDB.mySEA + + await GunActions.sendMessage(publicKey,body, user, SEA) + + return res.status(200).json({ + ok: true + }) + } catch (err) { + logger.error(err) + return res.status(500).json({ + errorMessage: err.message + }) + } + } + + ap.post(`/api/gun/chats/:publicKey?`, apiGunChatsPost) + + /** + * @typedef {object} RequestsRouteParams + * @prop {(string|undefined)=} requestID + */ + + /** + * @type {RequestHandler<{}>} + */ + const apiGunRequestsReceivedGet = (_, res) => { + try { + // spinup + Events.onSimplerReceivedRequests(() => {})() + const data = Events.getCurrentReceivedReqs() + + return res.status(200).json({ + data + }) + } catch (err) { + logger.error(err) + return res.status(500).json({ + errorMessage: err.message + }) + } + } + + /** + * @type {RequestHandler<{}>} + */ + const apiGunRequestsSentGet = (_, res) => { + try { + // spinup + Events.onSimplerSentRequests(() => {})() + const data = Events.getCurrentSentReqs() + + return res.status(200).json({ + data + }) + } catch (err) { + logger.error(err) + return res.status(500).json({ + errorMessage: err.message + }) + } + } + + /** + * @typedef {object} RequestsRoutePOSTBody + * @prop {string=} initialMsg + * @prop {string} publicKey + */ + + /** + * @type {RequestHandler<{}>} + */ + const apiGunRequestsPost = async (req, res) => { + const { initialMsg, publicKey } = /** @type {RequestsRoutePOSTBody} */(req.body) + + if (!publicKey) { + return res.status(400).json({ + errorMessage: `Must specify a publicKey route param for POSTing a message` + }) + } + + try { + const gun = require('../services/gunDB/Mediator').getGun() + const user = require('../services/gunDB/Mediator').getUser() + const SEA = require('../services/gunDB/Mediator').mySEA + + if (initialMsg) { + await GunActions.sendHRWithInitialMsg(initialMsg, publicKey, gun, user, SEA) + } else { + await GunActions.sendHandshakeRequest(publicKey, gun, user, SEA) + } + + return res.status(200).json({ + ok: true + }) + } catch (err) { + logger.error(err); + return res.status(500).json({ + errorMessage: err.message + }) + } + } + + /** + * @typedef {object} RequestsRoutePUTBody + * @prop {boolean=} accept + */ + + /** + * @type {RequestHandler} + */ + const apiGunRequestsPut = async (req, res) => { + const { requestID } = req.params + const { accept } = /** @type {RequestsRoutePUTBody} */(req.body) + + if (!requestID) { + return res.status(400).json({ + errorMessage: `Must specify a requestID route param for accepting a request` + }) + } + + if (!accept) { + return res.status(200).json({ + ok: true + }) + } + + try { + const gun = require('../services/gunDB/Mediator').getGun() + const user = require('../services/gunDB/Mediator').getUser() + const SEA = require('../services/gunDB/Mediator').mySEA + + await GunActions.acceptRequest(requestID, gun, user, SEA) + + return res.status(200).json({ + ok: true + }) + } catch (err) { + logger.error(err); + return res.status(500).json({ + errorMessage: err.message + }) + } + } + + ap.get(`/api/gun/requests/received`, apiGunRequestsReceivedGet) + ap.get(`/api/gun/requests/sent`, apiGunRequestsSentGet) + ap.post('/api/gun/requests/', apiGunRequestsPost) + ap.put(`/api/gun/requests/:requestID?`, apiGunRequestsPut) + /** * Return app so that it can be used by express. */ From ae5d713a51b8fa4de95c2ecba6bd1c39d0950600 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Mon, 20 Jul 2020 17:11:15 -0400 Subject: [PATCH 07/29] dev endpoints --- src/routes.js | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/src/routes.js b/src/routes.js index bc4554a2..7d7510ea 100644 --- a/src/routes.js +++ b/src/routes.js @@ -23,6 +23,7 @@ const GunDB = require("../services/gunDB/Mediator"); const { unprotectedRoutes, nonEncryptedRoutes } = require("../utils/protectedRoutes"); const GunActions = require("../services/gunDB/contact-api/actions") const GunGetters = require('../services/gunDB/contact-api/getters') +const GunKey = require('../services/gunDB/contact-api/key') const DEFAULT_MAX_NUM_ROUTES_TO_QUERY = 10; const SESSION_ID = uuid(); @@ -2223,6 +2224,129 @@ module.exports = async ( ap.post('/api/gun/requests/', apiGunRequestsPost) ap.put(`/api/gun/requests/:requestID?`, apiGunRequestsPut) + + + ap.get(`/api/gun/dev/userToIncoming`, async (_, res) => { + try { + const {tryAndWait} = require('../services/gunDB/contact-api/utils') + + const data = await tryAndWait((_, u) => new Promise(res => { + u.get(GunKey.USER_TO_INCOMING).load(data => { + res(data) + }) + })) + + return res.status(200).json({ + data + }) + } catch (err) { + return res.status(500).json({ + errorMessage: err.message + }) + } + }) + + ap.get(`/api/gun/dev/recipientToOutgoing`, async (_, res) => { + try { + const {tryAndWait} = require('../services/gunDB/contact-api/utils') + + const data = await tryAndWait((_, u) => new Promise(res => { + u.get(GunKey.RECIPIENT_TO_OUTGOING).load(data => { + res(data) + }) + })) + + return res.status(200).json({ + data + }) + } catch (err) { + return res.status(500).json({ + errorMessage: err.message + }) + } + }) + + ap.get(`/api/gun/dev/outgoings`, async (_, res) => { + try { + const {tryAndWait} = require('../services/gunDB/contact-api/utils') + + const data = await tryAndWait((_, u) => new Promise(res => { + u.get(GunKey.OUTGOINGS).load(data => { + res(data) + }) + })) + + return res.status(200).json({ + data + }) + } catch (err) { + return res.status(500).json({ + errorMessage: err.message + }) + } + }) + + + ap.get(`/api/gun/dev/currentHandshakeAddress`, async (_, res) => { + try { + const {tryAndWait} = require('../services/gunDB/contact-api/utils') + + const data = await tryAndWait((_, u) => u.get(GunKey.CURRENT_HANDSHAKE_ADDRESS).then()) + + return res.status(200).json({ + data + }) + } catch (err) { + return res.status(500).json({ + errorMessage: err.message + }) + } + }) + + ap.get(`/api/gun/dev/handshakeNodes/:handshakeAddress`, async (req, res) => { + try { + const {tryAndWait} = require('../services/gunDB/contact-api/utils') + + const data = await tryAndWait((g) => + new Promise((res) => { + g.get(GunKey.HANDSHAKE_NODES).get(req.params.handshakeAddress).load(data => { + res(data) + }) + }) + ) + + return res.status(200).json({ + data + }) + } catch (err) { + return res.status(500).json({ + errorMessage: err.message + }) + } + }) + + ap.get(`/api/gun/dev/user/:publicKey`, async (req, res) => { + try { + const {tryAndWait} = require('../services/gunDB/contact-api/utils') + + const data = await tryAndWait((g) => + new Promise((res) => { + g.user(req.params.publicKey).load(data => { + res(data) + }) + }) + ) + + return res.status(200).json({ + data + }) + } catch (err) { + return res.status(500).json({ + errorMessage: err.message + }) + } + }) + /** * Return app so that it can be used by express. */ From f84c1d1c9331216c26b349773782cc2ddc517b1b Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Mon, 20 Jul 2020 19:41:01 -0400 Subject: [PATCH 08/29] disconnect route --- src/routes.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/routes.js b/src/routes.js index 7d7510ea..ecd8786a 100644 --- a/src/routes.js +++ b/src/routes.js @@ -2090,7 +2090,34 @@ module.exports = async ( } } + /** + * @type {RequestHandler} + */ + const apiGunChatsDelete = async (req, res) => { + const { publicKey } = req.params + + if (!publicKey) { + return res.status(400).json({ + errorMessage: `Must specify a publicKey route param for DELETING a chat` + }) + } + + try { + await GunActions.disconnect(publicKey) + + return res.status(200).json({ + ok: true + }) + } catch (err) { + logger.error(err) + return res.status(500).json({ + errorMessage: err.message + }) + } + } + ap.post(`/api/gun/chats/:publicKey?`, apiGunChatsPost) + ap.delete(`/api/gun/chats/:publicKey?`, apiGunChatsDelete) /** * @typedef {object} RequestsRouteParams From 5daf69788841ac40d928c67f2a1169b05681690e Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Mon, 20 Jul 2020 20:03:18 -0400 Subject: [PATCH 09/29] filter new received reqs if requestor is in disconnected state --- services/gunDB/contact-api/events/onReceivedReqs.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/gunDB/contact-api/events/onReceivedReqs.js b/services/gunDB/contact-api/events/onReceivedReqs.js index 0398d688..6f7aaab7 100644 --- a/services/gunDB/contact-api/events/onReceivedReqs.js +++ b/services/gunDB/contact-api/events/onReceivedReqs.js @@ -50,6 +50,7 @@ const react = debounce(() => { for (const [id, req] of Object.entries(currAddressData)) { const inContact = Array.isArray(pubToFeed[req.from]) + const isDisconnected = pubToFeed[req.from] === 'disconnected' if (typeof pubToAvatar[req.from] === 'undefined') { // eslint-disable-next-line no-empty-function @@ -60,7 +61,7 @@ const react = debounce(() => { Streams.onDisplayName(() => {}, req.from)() } - if (!inContact) { + if (!inContact && !isDisconnected) { newReceivedReqsMap[req.from] = { id, requestorAvatar: pubToAvatar[req.from] || null, From e1e6b8798138c2fff7a63cf18d0a281ba199083b Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Tue, 21 Jul 2020 13:34:53 -0400 Subject: [PATCH 10/29] wait for listeners to proccess one tick before fetching --- src/routes.js | 52 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/src/routes.js b/src/routes.js index ecd8786a..e562c2b7 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1720,9 +1720,12 @@ module.exports = async ( try { // spinup Events.onSimplerReceivedRequests(() => {})() - const data = Events.getCurrentReceivedReqs() - res.json({ - data, + // ensure event data gets updated before fetching it + process.nextTick(() => { + const data = Events.getCurrentReceivedReqs() + res.json({ + data, + }) }) } catch (err) { logger.info('Error in Received Requests poll:') @@ -1737,10 +1740,14 @@ module.exports = async ( try { // spinup Events.onSimplerSentRequests(() => {})() - const data = Events.getCurrentSentReqs() - logger.info(`Sent requests poll: ${JSON.stringify(data, null, 4)}`) - res.json({ - data, + + // ensure event data gets updated before fetching it + process.nextTick(() => { + const data = Events.getCurrentSentReqs() + logger.info(`Sent requests poll: ${JSON.stringify(data, null, 4)}`) + res.json({ + data, + }) }) } catch (err) { logger.info('Error in sentRequests poll:') @@ -1755,10 +1762,14 @@ module.exports = async ( try { // spinup Events.onChats(() => {})() - const data = Events.getChats() - logger.info(`Chats polled: ${data.length}`) - res.json({ - data + + // ensure event data gets updated before fetching it + process.nextTick(() => { + const data = Events.getChats() + logger.info(`Chats polled: ${data.length}`) + res.json({ + data, + }) }) } catch (err) { logger.info('Error in Chats poll:') @@ -2131,10 +2142,13 @@ module.exports = async ( try { // spinup Events.onSimplerReceivedRequests(() => {})() - const data = Events.getCurrentReceivedReqs() - return res.status(200).json({ - data + // ensure event data gets updated before fetching it + process.nextTick(() => { + const data = Events.getCurrentReceivedReqs() + res.json({ + data, + }) }) } catch (err) { logger.error(err) @@ -2151,10 +2165,14 @@ module.exports = async ( try { // spinup Events.onSimplerSentRequests(() => {})() - const data = Events.getCurrentSentReqs() + - return res.status(200).json({ - data + // ensure event data gets updated before fetching it + process.nextTick(() => { + const data = Events.getCurrentSentReqs() + res.json({ + data, + }) }) } catch (err) { logger.error(err) From ef31b0c3756198edd43153d8b9a479c02f6d90f1 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Wed, 22 Jul 2020 17:34:01 -0400 Subject: [PATCH 11/29] spin up events at login --- services/gunDB/Mediator/index.js | 23 ++++++++++++ src/routes.js | 64 +++++++++----------------------- 2 files changed, 40 insertions(+), 47 deletions(-) diff --git a/services/gunDB/Mediator/index.js b/services/gunDB/Mediator/index.js index bfd8764b..83a34643 100644 --- a/services/gunDB/Mediator/index.js +++ b/services/gunDB/Mediator/index.js @@ -324,6 +324,18 @@ const authenticate = async (alias, pass, __user) => { API.Jobs.onAcceptedRequests(_user, mySEA) API.Jobs.onOrders(_user, gun, mySEA) API.Jobs.lastSeenNode(_user) + + API.Events.onAvatar(() => {}, user)() + API.Events.onBio(() => {}, user) + API.Events.onBlacklist(() => {}, user) + API.Events.onChats(() => {})() + API.Events.onCurrentHandshakeAddress(() => {}, user)() + API.Events.onDisplayName(() => {}, user)() + API.Events.onOutgoing(() => {})() + API.Events.onSeedBackup(() => {}, user, mySEA) + API.Events.onSimplerReceivedRequests(() => {})() + API.Events.onSimplerSentRequests(() => {})() + return _user._.sea.pub } @@ -372,6 +384,17 @@ const authenticate = async (alias, pass, __user) => { API.Jobs.onOrders(_user, gun, mySEA) API.Jobs.lastSeenNode(_user) + API.Events.onAvatar(() => {}, user)() + API.Events.onBio(() => {}, user) + API.Events.onBlacklist(() => {}, user) + API.Events.onChats(() => {})() + API.Events.onCurrentHandshakeAddress(() => {}, user)() + API.Events.onDisplayName(() => {}, user)() + API.Events.onOutgoing(() => {})() + API.Events.onSeedBackup(() => {}, user, mySEA) + API.Events.onSimplerReceivedRequests(() => {})() + API.Events.onSimplerSentRequests(() => {})() + return ack.sea.pub } else { logger.error( diff --git a/src/routes.js b/src/routes.js index e562c2b7..15a785b7 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1718,14 +1718,9 @@ module.exports = async ( app.get(`/api/gun/${GunEvent.ON_RECEIVED_REQUESTS}`, (_, res) => { try { - // spinup - Events.onSimplerReceivedRequests(() => {})() - // ensure event data gets updated before fetching it - process.nextTick(() => { - const data = Events.getCurrentReceivedReqs() - res.json({ - data, - }) + const data = Events.getCurrentReceivedReqs() + res.json({ + data, }) } catch (err) { logger.info('Error in Received Requests poll:') @@ -1738,16 +1733,10 @@ module.exports = async ( app.get(`/api/gun/${GunEvent.ON_SENT_REQUESTS}`, (_, res) => { try { - // spinup - Events.onSimplerSentRequests(() => {})() - - // ensure event data gets updated before fetching it - process.nextTick(() => { - const data = Events.getCurrentSentReqs() - logger.info(`Sent requests poll: ${JSON.stringify(data, null, 4)}`) - res.json({ - data, - }) + const data = Events.getCurrentSentReqs() + logger.info(`Sent requests poll: ${JSON.stringify(data, null, 4)}`) + res.json({ + data, }) } catch (err) { logger.info('Error in sentRequests poll:') @@ -1760,16 +1749,10 @@ module.exports = async ( app.get(`/api/gun/${GunEvent.ON_CHATS}`, (_, res) => { try { - // spinup - Events.onChats(() => {})() - - // ensure event data gets updated before fetching it - process.nextTick(() => { - const data = Events.getChats() - logger.info(`Chats polled: ${data.length}`) - res.json({ - data, - }) + const data = Events.getChats() + logger.info(`Chats polled: ${data.length}`) + res.json({ + data, }) } catch (err) { logger.info('Error in Chats poll:') @@ -2140,15 +2123,9 @@ module.exports = async ( */ const apiGunRequestsReceivedGet = (_, res) => { try { - // spinup - Events.onSimplerReceivedRequests(() => {})() - - // ensure event data gets updated before fetching it - process.nextTick(() => { - const data = Events.getCurrentReceivedReqs() - res.json({ - data, - }) + const data = Events.getCurrentReceivedReqs() + res.json({ + data, }) } catch (err) { logger.error(err) @@ -2163,16 +2140,9 @@ module.exports = async ( */ const apiGunRequestsSentGet = (_, res) => { try { - // spinup - Events.onSimplerSentRequests(() => {})() - - - // ensure event data gets updated before fetching it - process.nextTick(() => { - const data = Events.getCurrentSentReqs() - res.json({ - data, - }) + const data = Events.getCurrentSentReqs() + res.json({ + data, }) } catch (err) { logger.error(err) From 59f44e825a242ea639efe5d230113c6bcf656ddf Mon Sep 17 00:00:00 2001 From: emad-salah Date: Thu, 23 Jul 2020 16:43:54 +0100 Subject: [PATCH 12/29] Added a .env toggle for enabling/disabling detailed route logging --- src/routes.js | 2 -- src/server.js | 47 +++++++++++++++++++++++++---------------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/routes.js b/src/routes.js index 22e163e7..8b4dbb2a 100644 --- a/src/routes.js +++ b/src/routes.js @@ -272,8 +272,6 @@ module.exports = async ( app.use(async (req, res, next) => { try { - logger.info("Route:", req.path) - if (unprotectedRoutes[req.method][req.path]) { next(); return; diff --git a/src/server.js b/src/server.js index 20b4b3c7..978aa2e6 100644 --- a/src/server.js +++ b/src/server.js @@ -195,31 +195,34 @@ const server = program => { }) app.use((req, res, next) => { - if (sensitiveRoutes[req.method][req.path]) { - logger.info( - JSON.stringify({ - time: new Date(), - ip: req.ip, - method: req.method, - path: req.path, - sessionId: req.sessionId - }) - ) - } else { - logger.info( - JSON.stringify({ - time: new Date(), - ip: req.ip, - method: req.method, - path: req.path, - body: req.body, - query: req.query, - sessionId: req.sessionId - }) - ) + if (process.env.ROUTE_LOGGING === 'true') { + if (sensitiveRoutes[req.method][req.path]) { + logger.info( + JSON.stringify({ + time: new Date(), + ip: req.ip, + method: req.method, + path: req.path, + sessionId: req.sessionId + }) + ) + } else { + logger.info( + JSON.stringify({ + time: new Date(), + ip: req.ip, + method: req.method, + path: req.path, + body: req.body, + query: req.query, + sessionId: req.sessionId + }) + ) + } } next() }) + app.use( session({ secret: defaults.sessionSecret, From bb1138579d007d426f2823f91b50a3c17541a8c7 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 23 Jul 2020 13:01:43 -0400 Subject: [PATCH 13/29] work around load() bug --- services/gunDB/contact-api/getters/index.js | 14 ++++- services/gunDB/contact-api/getters/user.js | 14 ++++- src/routes.js | 66 +++++++++++++++++++-- 3 files changed, 87 insertions(+), 7 deletions(-) diff --git a/services/gunDB/contact-api/getters/index.js b/services/gunDB/contact-api/getters/index.js index 3a82e410..4472ed41 100644 --- a/services/gunDB/contact-api/getters/index.js +++ b/services/gunDB/contact-api/getters/index.js @@ -9,6 +9,7 @@ const Utils = require('../utils') const Wall = require('./wall') const Feed = require('./feed') const User = require('./user') +const { size } = require('lodash') /** * @param {string} pub @@ -51,7 +52,18 @@ exports.userToIncomingID = async pub => { const getMyUser = async () => { const oldProfile = await Utils.tryAndWait( (_, user) => new Promise(res => user.get(Key.PROFILE).load(res)), - v => typeof v !== 'object' + v => { + if (typeof v !== 'object') { + return true + } + + if (v === null) { + return true + } + + // load sometimes returns an empty set on the first try + return size(v) === 0 + } ) const bio = await Utils.tryAndWait( diff --git a/services/gunDB/contact-api/getters/user.js b/services/gunDB/contact-api/getters/user.js index fb8054e1..52d04e72 100644 --- a/services/gunDB/contact-api/getters/user.js +++ b/services/gunDB/contact-api/getters/user.js @@ -2,6 +2,7 @@ * @format */ const Common = require('shock-common') +const size = require('lodash/size') const Key = require('../key') const Utils = require('../utils') @@ -72,7 +73,18 @@ module.exports.getAnUser = getAnUser const getMyUser = async () => { const oldProfile = await Utils.tryAndWait( (_, user) => new Promise(res => user.get(Key.PROFILE).load(res)), - v => typeof v !== 'object' + v => { + if (typeof v !== 'object') { + return true + } + + if (v === null) { + return true + } + + // load sometimes returns an empty set on the first try + return size(v) === 0 + } ) const bio = await Utils.tryAndWait( diff --git a/src/routes.js b/src/routes.js index 15a785b7..dcffb4cc 100644 --- a/src/routes.js +++ b/src/routes.js @@ -13,6 +13,7 @@ const responseTime = require("response-time"); const uuid = require("uuid/v4"); const Common = require('shock-common') const isARealUsableNumber = require('lodash/isFinite') +const size = require('lodash/size') const getListPage = require("../utils/paginate"); const auth = require("../services/auth/auth"); @@ -2249,7 +2250,18 @@ module.exports = async ( u.get(GunKey.USER_TO_INCOMING).load(data => { res(data) }) - })) + }), v => { + if (typeof v !== 'object') { + return true + } + + if (v === null) { + return true + } + + // load sometimes returns an empty set on the first try + return size(v) === 0 + }) return res.status(200).json({ data @@ -2269,7 +2281,18 @@ module.exports = async ( u.get(GunKey.RECIPIENT_TO_OUTGOING).load(data => { res(data) }) - })) + }), v => { + if (typeof v !== 'object') { + return true + } + + if (v === null) { + return true + } + + // load sometimes returns an empty set on the first try + return size(v) === 0 + }) return res.status(200).json({ data @@ -2289,7 +2312,18 @@ module.exports = async ( u.get(GunKey.OUTGOINGS).load(data => { res(data) }) - })) + }), v => { + if (typeof v !== 'object') { + return true + } + + if (v === null) { + return true + } + + // load sometimes returns an empty set on the first try + return size(v) === 0 + }) return res.status(200).json({ data @@ -2328,7 +2362,18 @@ module.exports = async ( res(data) }) }) - ) + , v => { + if (typeof v !== 'object') { + return true + } + + if (v === null) { + return true + } + + // load sometimes returns an empty set on the first try + return size(v) === 0 + }) return res.status(200).json({ data @@ -2350,7 +2395,18 @@ module.exports = async ( res(data) }) }) - ) + , v => { + if (typeof v !== 'object') { + return true + } + + if (v === null) { + return true + } + + // load sometimes returns an empty set on the first try + return size(v) === 0 + }) return res.status(200).json({ data From 1eb4c59ab60ecfa45b9575ef5ee09a5bcc2c73a2 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 23 Jul 2020 13:12:37 -0400 Subject: [PATCH 14/29] commenting --- services/gunDB/contact-api/getters/follows.js | 1 + 1 file changed, 1 insertion(+) diff --git a/services/gunDB/contact-api/getters/follows.js b/services/gunDB/contact-api/getters/follows.js index 22a49333..55ed47f8 100644 --- a/services/gunDB/contact-api/getters/follows.js +++ b/services/gunDB/contact-api/getters/follows.js @@ -28,6 +28,7 @@ exports.currentFollows = async () => { return true } + // load sometimes returns an empty set on the first try if (size(v) === 0) { return true } From 2a68ff87434fade5c81a34459690b6245aca5d86 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 23 Jul 2020 17:43:40 -0400 Subject: [PATCH 15/29] less extraneous data logs --- services/gunDB/contact-api/events/onReceivedReqs.js | 3 ++- services/gunDB/contact-api/events/onSentReqs.js | 7 +++---- services/gunDB/contact-api/streams/pubToFeed.js | 3 ++- services/gunDB/contact-api/streams/pubToIncoming.js | 5 ++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/services/gunDB/contact-api/events/onReceivedReqs.js b/services/gunDB/contact-api/events/onReceivedReqs.js index 6f7aaab7..9a18a29b 100644 --- a/services/gunDB/contact-api/events/onReceivedReqs.js +++ b/services/gunDB/contact-api/events/onReceivedReqs.js @@ -2,6 +2,7 @@ const debounce = require('lodash/debounce') const logger = require('winston') const { Schema } = require('shock-common') +const size = require('lodash/size') const Key = require('../key') const Streams = require('../streams') @@ -96,7 +97,7 @@ const listenerForAddr = addr => data => { } } - logger.info('data for address: ' + addr) + logger.info('data for address length: ' + size(addr)) logger.info(JSON.stringify(data, null, 4)) react() diff --git a/services/gunDB/contact-api/events/onSentReqs.js b/services/gunDB/contact-api/events/onSentReqs.js index 03686a2d..87c40dc1 100644 --- a/services/gunDB/contact-api/events/onSentReqs.js +++ b/services/gunDB/contact-api/events/onSentReqs.js @@ -1,6 +1,7 @@ /** @format */ const debounce = require('lodash/debounce') const logger = require('winston') +const size = require('lodash/size') const Streams = require('../streams') /** @@ -29,7 +30,7 @@ const listeners = new Set() let currentReqs = [] listeners.add(() => { - logger.info(`new sent reqs: ${JSON.stringify(currentReqs)}`) + logger.info(`new sent reqs length: ${currentReqs}`) }) const getCurrentSentReqs = () => currentReqs @@ -55,9 +56,7 @@ const react = debounce(() => { // pk to display name const pubToDN = Streams.getPubToDn() - logger.info( - `pubToLastSentREqID: ${JSON.stringify(pubToLastSentReqID, null, 4)}` - ) + logger.info(`pubToLastSentREqID length: ${size(pubToLastSentReqID)}`) for (const storedReq of storedReqs) { const { handshakeAddress, recipientPub, sentReqID, timestamp } = storedReq diff --git a/services/gunDB/contact-api/streams/pubToFeed.js b/services/gunDB/contact-api/streams/pubToFeed.js index 30e49394..f6f96cc4 100644 --- a/services/gunDB/contact-api/streams/pubToFeed.js +++ b/services/gunDB/contact-api/streams/pubToFeed.js @@ -3,6 +3,7 @@ const uuidv1 = require('uuid/v1') const logger = require('winston') const debounce = require('lodash/debounce') const { Schema, Utils: CommonUtils } = require('shock-common') +const size = require('lodash/size') const Key = require('../key') const Utils = require('../utils') @@ -29,7 +30,7 @@ let pubToFeed = {} const getPubToFeed = () => pubToFeed feedsListeners.add(() => { - logger.info(`new pubToFeed: ${JSON.stringify(getPubToFeed())}`) + logger.info(`new pubToFeed length: ${size(getPubToFeed())}`) }) /** @param {Feeds} ptf */ diff --git a/services/gunDB/contact-api/streams/pubToIncoming.js b/services/gunDB/contact-api/streams/pubToIncoming.js index 72b18b9d..2834ca79 100644 --- a/services/gunDB/contact-api/streams/pubToIncoming.js +++ b/services/gunDB/contact-api/streams/pubToIncoming.js @@ -3,6 +3,7 @@ const uuidv1 = require('uuid/v1') const debounce = require('lodash/debounce') const logger = require('winston') const { Utils: CommonUtils } = require('shock-common') +const size = require('lodash/size') const { USER_TO_INCOMING } = require('../key') /** @typedef {import('../SimpleGUN').OpenListenerData} OpenListenerData */ @@ -30,9 +31,7 @@ const setPubToIncoming = pti => { let latestUpdate = uuidv1() listeners.add(() => { - logger.info( - `new pubToIncoming: ${JSON.stringify(getPubToIncoming(), null, 4)}` - ) + logger.info(`new pubToIncoming length: ${size(getPubToIncoming())}`) }) const onOpen = debounce(async uti => { From 0088b7d8cf6b4affcd4711caae3adbda995a3570 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 23 Jul 2020 20:16:10 -0400 Subject: [PATCH 16/29] sendMessageNew(), returns the created RES --- services/gunDB/contact-api/actions.js | 25 ++++++++++++++++--- .../contact-api/events/onReceivedReqs.js | 1 - 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/services/gunDB/contact-api/actions.js b/services/gunDB/contact-api/actions.js index a0ae6171..699d3c62 100644 --- a/services/gunDB/contact-api/actions.js +++ b/services/gunDB/contact-api/actions.js @@ -631,9 +631,9 @@ const sendHandshakeRequest = async (recipientPublicKey, gun, user, SEA) => { * @param {string} body * @param {UserGUNNode} user * @param {ISEA} SEA - * @returns {Promise} The message id. + * @returns {Promise} The message id. */ -const sendMessage = async (recipientPublicKey, body, user, SEA) => { +const sendMessageNew = async (recipientPublicKey, body, user, SEA) => { if (!user.is) { throw new Error(ErrorCode.NOT_AUTH) } @@ -691,12 +691,28 @@ const sendMessage = async (recipientPublicKey, body, user, SEA) => { if (ack.err) { rej(new Error(ack.err)) } else { - res(msgNode._.get) + res({ + body, + id: msgNode._.get, + outgoing: true, + timestamp: newMessage.timestamp + }) } }) }) } +/** + * Returns the message id. + * @param {string} recipientPublicKey + * @param {string} body + * @param {UserGUNNode} user + * @param {ISEA} SEA + * @returns {Promise} The message id. + */ +const sendMessage = async (recipientPublicKey, body, user, SEA) => + (await sendMessageNew(recipientPublicKey, body, user, SEA)).id + /** * @param {string} recipientPub * @param {string} msgID @@ -1589,5 +1605,6 @@ module.exports = { deletePost, follow, unfollow, - initWall + initWall, + sendMessageNew } diff --git a/services/gunDB/contact-api/events/onReceivedReqs.js b/services/gunDB/contact-api/events/onReceivedReqs.js index 9a18a29b..a0b74e30 100644 --- a/services/gunDB/contact-api/events/onReceivedReqs.js +++ b/services/gunDB/contact-api/events/onReceivedReqs.js @@ -98,7 +98,6 @@ const listenerForAddr = addr => data => { } logger.info('data for address length: ' + size(addr)) - logger.info(JSON.stringify(data, null, 4)) react() } From 41649c7bceb9c21f0dda4946ac3ef0bc9d09a9fc Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 23 Jul 2020 23:04:11 -0400 Subject: [PATCH 17/29] use same handler --- src/routes.js | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/src/routes.js b/src/routes.js index dcffb4cc..39c035d9 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1717,37 +1717,6 @@ module.exports = async ( const Events = require('../services/gunDB/contact-api/events') - app.get(`/api/gun/${GunEvent.ON_RECEIVED_REQUESTS}`, (_, res) => { - try { - const data = Events.getCurrentReceivedReqs() - res.json({ - data, - }) - } catch (err) { - logger.info('Error in Received Requests poll:') - logger.error(err) - res.status(err.message === 'NON_AUTH' ? 401 : 500).json({ - errorMessage: typeof err === 'string' ? err : err.message - }) - } - }) - - app.get(`/api/gun/${GunEvent.ON_SENT_REQUESTS}`, (_, res) => { - try { - const data = Events.getCurrentSentReqs() - logger.info(`Sent requests poll: ${JSON.stringify(data, null, 4)}`) - res.json({ - data, - }) - } catch (err) { - logger.info('Error in sentRequests poll:') - logger.error(err) - res.status(err.message === 'NON_AUTH' ? 401 : 500).json({ - errorMessage: typeof err === 'string' ? err : err.message - }) - } - }) - app.get(`/api/gun/${GunEvent.ON_CHATS}`, (_, res) => { try { const data = Events.getChats() @@ -2235,6 +2204,8 @@ module.exports = async ( } } + ap.get(`/api/gun/${GunEvent.ON_RECEIVED_REQUESTS}`, apiGunRequestsReceivedGet) + ap.get(`/api/gun/${GunEvent.ON_SENT_REQUESTS}`, apiGunRequestsSentGet) ap.get(`/api/gun/requests/received`, apiGunRequestsReceivedGet) ap.get(`/api/gun/requests/sent`, apiGunRequestsSentGet) ap.post('/api/gun/requests/', apiGunRequestsPost) From fc32cf39965786fd7ca145202cb4f3cb8d9d3113 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 23 Jul 2020 23:04:22 -0400 Subject: [PATCH 18/29] null check --- src/routes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes.js b/src/routes.js index 39c035d9..ef3d0bba 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1737,7 +1737,7 @@ module.exports = async ( try { const user = require('../services/gunDB/Mediator').getUser() const data = await timeout5(user.get(Key.PROFILE).get(Key.AVATAR).then()) - logger.info(`avatar poll:${data.length} chars`) + logger.info(`avatar poll:${(data || '').length} chars`) res.json({ data }) From 55fb361c5c7f9890fc25ff5497523493cac80412 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Thu, 23 Jul 2020 23:04:37 -0400 Subject: [PATCH 19/29] send back created resource --- src/routes.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/routes.js b/src/routes.js index ef3d0bba..4e0dce0e 100644 --- a/src/routes.js +++ b/src/routes.js @@ -2041,11 +2041,9 @@ module.exports = async ( const user = GunDB.getUser() const SEA = GunDB.mySEA - await GunActions.sendMessage(publicKey,body, user, SEA) - - return res.status(200).json({ - ok: true - }) + return res.status(200).json( + await GunActions.sendMessageNew(publicKey,body, user, SEA) + ) } catch (err) { logger.error(err) return res.status(500).json({ From 18844d2c55c9ed1974393c2805fc6c9912d31b3f Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Fri, 24 Jul 2020 10:52:22 -0400 Subject: [PATCH 20/29] remove debug code --- src/routes.js | 70 --------------------------------------------------- 1 file changed, 70 deletions(-) diff --git a/src/routes.js b/src/routes.js index 4e0dce0e..c0b613c1 100644 --- a/src/routes.js +++ b/src/routes.js @@ -439,76 +439,6 @@ module.exports = async ( }); - /* - const feedObj = { - feed: [ - { - id:'bd7acbea-c1b1-46c2-aed5-3ad53abb28ba', - paragraphs:[ - "SOme text and stuff 12" - "SOme text and stuff" - ], - profilePic:"", - username:"bobni", - media:[ - { - type:'VIDEO', - ratio_x: 1024, - ratio_y: 436, - magnetUri:'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent', - }, - ] - }, - { - id:'3ac68afc-c605-48d3-a4f8-fbd91aa97f63', - paragraphs:[ - "SOme text and stuff" - ], - profilePic:"", - username:"bobni", - media:[ - { - type:'VIDEO', - ratio_x: 1920, - ratio_y: 804, - magnetUri:'magnet:?xt=urn:btih:c9e15763f722f23e98a29decdfae341b98d53056&dn=Cosmos+Laundromat&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fcosmos-laundromat.torrent', - }, - ] - }, - { - id:'58694a0f-3da1-471f-bd96-145571e29d72', - paragraphs:[ - "SOme text and stuff" - ], - profilePic:"", - username:"bobni", - media:[ - { - type:'VIDEO', - ratio_x: 1920, - ratio_y: 1080, - magnetUri:'magnet:?xt=urn:btih:dd8255ecdc7ca55fb0bbf81323d87062db1f6d1c&dn=Big+Buck+Bunny&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fbig-buck-bunny.torrent', - }, - ] - } - ] - } - user.get("FEED_POC").put(JSON.stringify(feedObj), ack => { - if (ack.err) { - //rej(new Error(ack.err)) - }*/ - const feedObj = { - feed :{} - } - user.get("FEED_POC").put(feedObj, ack => { - if (ack.err) { - //rej(ack.err) - logger.log(ack.err) - } else { - logger.log(ack.err) - } - }) - //register to listen for channel backups const onNewChannelBackup = () => { logger.warn("Subscribing to channel backup ...") From cd9c7983c884e75992c7e9c2842316b0cf0aef92 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Fri, 24 Jul 2020 12:15:07 -0400 Subject: [PATCH 21/29] run disconnect-related writes in parallel --- services/gunDB/contact-api/actions.js | 100 ++++++++++++++------------ 1 file changed, 55 insertions(+), 45 deletions(-) diff --git a/services/gunDB/contact-api/actions.js b/services/gunDB/contact-api/actions.js index 699d3c62..8bd27958 100644 --- a/services/gunDB/contact-api/actions.js +++ b/services/gunDB/contact-api/actions.js @@ -372,50 +372,13 @@ const cleanup = async pub => { const outGoingID = await Utils.recipientToOutgoingID(pub) - await new Promise((res, rej) => { - user - .get(Key.USER_TO_INCOMING) - .get(pub) - .put(null, ack => { - if (ack.err) { - rej(new Error(ack.err)) - } else { - res() - } - }) - }) + const promises = [] - await new Promise((res, rej) => { - user - .get(Key.RECIPIENT_TO_OUTGOING) - .get(pub) - .put(null, ack => { - if (ack.err) { - rej(new Error(ack.err)) - } else { - res() - } - }) - }) - - await new Promise((res, rej) => { - user - .get(Key.USER_TO_LAST_REQUEST_SENT) - .get(pub) - .put(null, ack => { - if (ack.err) { - rej(new Error(ack.err)) - } else { - res() - } - }) - }) - - if (outGoingID) { - await new Promise((res, rej) => { + promises.push( + new Promise((res, rej) => { user - .get(Key.OUTGOINGS) - .get(outGoingID) + .get(Key.USER_TO_INCOMING) + .get(pub) .put(null, ack => { if (ack.err) { rej(new Error(ack.err)) @@ -424,7 +387,56 @@ const cleanup = async pub => { } }) }) + ) + + promises.push( + new Promise((res, rej) => { + user + .get(Key.RECIPIENT_TO_OUTGOING) + .get(pub) + .put(null, ack => { + if (ack.err) { + rej(new Error(ack.err)) + } else { + res() + } + }) + }) + ) + + promises.push( + new Promise((res, rej) => { + user + .get(Key.USER_TO_LAST_REQUEST_SENT) + .get(pub) + .put(null, ack => { + if (ack.err) { + rej(new Error(ack.err)) + } else { + res() + } + }) + }) + ) + + if (outGoingID) { + promises.push( + new Promise((res, rej) => { + user + .get(Key.OUTGOINGS) + .get(outGoingID) + .put(null, ack => { + if (ack.err) { + rej(new Error(ack.err)) + } else { + res() + } + }) + }) + ) } + + await Promise.all(promises) } /** @@ -1227,9 +1239,7 @@ const disconnect = async pub => { throw new Error('No handshake exists for this pub') } - await cleanup(pub) - - await generateHandshakeAddress() + await Promise.all([cleanup(pub), generateHandshakeAddress()]) } /** From b7ad45f1d5a15b0c2da4033fcf401d9893f26dfc Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Fri, 24 Jul 2020 12:16:17 -0400 Subject: [PATCH 22/29] storedReqs dev endpoint --- src/routes.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/routes.js b/src/routes.js index c0b613c1..fde63091 100644 --- a/src/routes.js +++ b/src/routes.js @@ -2317,6 +2317,35 @@ module.exports = async ( } }) + + ap.get(`/api/gun/dev/storedReqs`, async (req, res) => { + try { + const {tryAndWait} = require('../services/gunDB/contact-api/utils') + + const data = await tryAndWait((_, u) => + new Promise((res) => u.get(Key.STORED_REQS).load(res)) + , v => { + if (typeof v !== 'object') { + return true + } + + if (v === null) { + return true + } + + // load sometimes returns an empty set on the first try + return size(v) === 0 + }) + + return res.status(200).json({ + data + }) + } catch (err) { + return res.status(500).json({ + errorMessage: err.message + }) + } + }) /** * Return app so that it can be used by express. */ From 89b1263e8087c35c8fb482adde1b455482167aec Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Fri, 24 Jul 2020 12:43:16 -0400 Subject: [PATCH 23/29] handshake address regen through HTTP --- src/routes.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/routes.js b/src/routes.js index fde63091..5b783321 100644 --- a/src/routes.js +++ b/src/routes.js @@ -1920,8 +1920,13 @@ module.exports = async ( * @type {RequestHandler<{}>} */ const apiGunMePut = async (req, res) => { + /** + * @typedef {Omit} UserWithoutPK + * @typedef {{ handshakeAddress: boolean }} HasHandshakeAddress + * @typedef {UserWithoutPK & HasHandshakeAddress} MePutBody + */ try { - const { avatar, bio , displayName} = /** @type {Partial>} */ (req.body) + const { avatar, bio , displayName, handshakeAddress } = /** @type {Partial} */ (req.body) if (avatar) { await GunActions.setAvatar(avatar, require('../services/gunDB/Mediator').getUser()) @@ -1935,6 +1940,10 @@ module.exports = async ( await GunActions.setDisplayName(displayName, require('../services/gunDB/Mediator').getUser()) } + if (handshakeAddress) { + await GunActions.generateHandshakeAddress(); + } + return res.status(200).json({ ok: true }) From 3c52eb26e32119f97a7b640d54e30ec19af9b248 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Fri, 24 Jul 2020 12:44:21 -0400 Subject: [PATCH 24/29] user to last request sent dev endpoint --- src/routes.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/routes.js b/src/routes.js index 5b783321..cb9d9438 100644 --- a/src/routes.js +++ b/src/routes.js @@ -2355,6 +2355,35 @@ module.exports = async ( }) } }) + + ap.get(`/api/gun/dev/userToLastReqSent`, async (req, res) => { + try { + const {tryAndWait} = require('../services/gunDB/contact-api/utils') + + const data = await tryAndWait((_, u) => + new Promise((res) => u.get(Key.USER_TO_LAST_REQUEST_SENT).load(res)) + , v => { + if (typeof v !== 'object') { + return true + } + + if (v === null) { + return true + } + + // load sometimes returns an empty set on the first try + return size(v) === 0 + }) + + return res.status(200).json({ + data + }) + } catch (err) { + return res.status(500).json({ + errorMessage: err.message + }) + } + }) /** * Return app so that it can be used by express. */ From 7b0d3892d5db9e7b07c6d8310c898567648ed395 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sat, 25 Jul 2020 08:51:42 -0400 Subject: [PATCH 25/29] better logs --- services/gunDB/contact-api/events/onSentReqs.js | 2 +- services/gunDB/contact-api/streams/addresses.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/services/gunDB/contact-api/events/onSentReqs.js b/services/gunDB/contact-api/events/onSentReqs.js index 87c40dc1..93e0740d 100644 --- a/services/gunDB/contact-api/events/onSentReqs.js +++ b/services/gunDB/contact-api/events/onSentReqs.js @@ -30,7 +30,7 @@ const listeners = new Set() let currentReqs = [] listeners.add(() => { - logger.info(`new sent reqs length: ${currentReqs}`) + logger.info(`new sent reqs length: ${size(currentReqs)}`) }) const getCurrentSentReqs = () => currentReqs diff --git a/services/gunDB/contact-api/streams/addresses.js b/services/gunDB/contact-api/streams/addresses.js index d35513dd..705e8b4c 100644 --- a/services/gunDB/contact-api/streams/addresses.js +++ b/services/gunDB/contact-api/streams/addresses.js @@ -1,5 +1,6 @@ /** @format */ const logger = require('winston') +const size = require('lodash/size') const Key = require('../key') /** @@ -13,7 +14,7 @@ const pubToAddress = {} const listeners = new Set() listeners.add(() => { - logger.info(`pubToAddress: ${JSON.stringify(pubToAddress, null, 4)}`) + logger.info(`pubToAddress length: ${size(pubToAddress)}`) }) const notify = () => listeners.forEach(l => l()) From 788e871392e62e8070b12b754f5dc013ed63328a Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sat, 25 Jul 2020 10:14:41 -0400 Subject: [PATCH 26/29] size() as catch-all --- services/gunDB/contact-api/jobs/onAcceptedRequests.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/gunDB/contact-api/jobs/onAcceptedRequests.js b/services/gunDB/contact-api/jobs/onAcceptedRequests.js index 55568679..51f82bff 100644 --- a/services/gunDB/contact-api/jobs/onAcceptedRequests.js +++ b/services/gunDB/contact-api/jobs/onAcceptedRequests.js @@ -6,6 +6,7 @@ const { Constants: { ErrorCode }, Schema } = require('shock-common') +const size = require('lodash/size') const Key = require('../key') const Utils = require('../utils') @@ -126,8 +127,8 @@ const onAcceptedRequests = (user, SEA) => { res(feed) }) }), - // retry on undefined, might be a false negative - v => typeof v === 'undefined' + // @ts-expect-error + v => size(v) === 0 ) const feedIDExistsOnRecipientsOutgoings = From d12656d1545ca95b56cbd5a7b69ccdad2b853800 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sat, 25 Jul 2020 10:15:53 -0400 Subject: [PATCH 27/29] throw instead of log --- services/gunDB/contact-api/jobs/onAcceptedRequests.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/gunDB/contact-api/jobs/onAcceptedRequests.js b/services/gunDB/contact-api/jobs/onAcceptedRequests.js index 51f82bff..dbbd6215 100644 --- a/services/gunDB/contact-api/jobs/onAcceptedRequests.js +++ b/services/gunDB/contact-api/jobs/onAcceptedRequests.js @@ -40,15 +40,16 @@ const onAcceptedRequests = (user, SEA) => { logger.info( `------------------------------------\nPROCID:${procid} (used for debugging memory leaks in jobs)\n---------------------------------------` ) + const mySecret = require('../../Mediator').getMySecret() + try { if (!Schema.isStoredRequest(storedReq)) { - logger.warn( + throw new Error( 'Stored request not an StoredRequest, instead got: ' + JSON.stringify(storedReq) + ' this can be due to nulling out an old request (if null) or something else happened (please look at the output)' ) - return } const recipientPub = await SEA.decrypt(storedReq.recipientPub, mySecret) From 7ca39103b2c53a387baca78fca0253c73ce3d516 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Sat, 25 Jul 2020 10:16:18 -0400 Subject: [PATCH 28/29] comments/messages --- .../gunDB/contact-api/jobs/onAcceptedRequests.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/services/gunDB/contact-api/jobs/onAcceptedRequests.js b/services/gunDB/contact-api/jobs/onAcceptedRequests.js index dbbd6215..5408b469 100644 --- a/services/gunDB/contact-api/jobs/onAcceptedRequests.js +++ b/services/gunDB/contact-api/jobs/onAcceptedRequests.js @@ -51,14 +51,20 @@ const onAcceptedRequests = (user, SEA) => { ' this can be due to nulling out an old request (if null) or something else happened (please look at the output)' ) } + // get the recipient pub from the stored request to avoid an attacker + // overwriting the handshake request in the root graph const recipientPub = await SEA.decrypt(storedReq.recipientPub, mySecret) if (typeof recipientPub !== 'string') { - throw new TypeError() + throw new TypeError( + `Expected storedReq.recipientPub to be an string, instead got: ${recipientPub}` + ) } + if (await Utils.successfulHandshakeAlreadyExists(recipientPub)) { return } + const requestAddress = await SEA.decrypt( storedReq.handshakeAddress, mySecret @@ -101,9 +107,9 @@ const onAcceptedRequests = (user, SEA) => { return } - // The response can be decrypted with the same secret regardless of who - // wrote to it last (see HandshakeRequest definition). - // This could be our feed ID for the recipient, or the recipient's feed + // The response can be decrypted with the same secret regardless + // of who wrote to it last (see HandshakeRequest definition). This + // could be our feed ID for the recipient, or the recipient's feed // id if he accepted the request. const feedID = await SEA.decrypt(sentReq.response, ourSecret) From 8bcfb3236fa0244628734cca87edba9c2d750abc Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Mon, 27 Jul 2020 09:53:24 -0400 Subject: [PATCH 29/29] yarn lock regen --- yarn.lock | 227 ++++++++++++++++++------------------------------------ 1 file changed, 76 insertions(+), 151 deletions(-) diff --git a/yarn.lock b/yarn.lock index 7c6ed939..0b7113e5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -377,32 +377,33 @@ "@types/istanbul-reports" "^1.1.1" "@types/yargs" "^13.0.0" -"@peculiar/asn1-schema@^1.0.3": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@peculiar/asn1-schema/-/asn1-schema-1.0.3.tgz#e55ff9e98a1cf31832629aabacf85be3edf13a48" - integrity sha512-Tfgj9eNJ6cTKEtEuidKenLHMx/Q5M8KEE9hnohHqvdpqHJXWYr5RlT3GjAHPjGXy5+mr7sSfuXfzE6aAkEGN7A== +"@peculiar/asn1-schema@^2.0.1", "@peculiar/asn1-schema@^2.0.8": + version "2.0.8" + resolved "https://registry.yarnpkg.com/@peculiar/asn1-schema/-/asn1-schema-2.0.8.tgz#bafb74388590f6ec3d53d1b2a4fdbe66d44224a4" + integrity sha512-D8ZqT61DdzuXfrILNvtdf7MUcTY2o9WHwmF0WgTKPEGNY5SDxNAjBY3enuwV9SXcSuCAwWac9c9v0vsswB1NIw== dependencies: - asn1js "^2.0.22" - tslib "^1.9.3" - -"@peculiar/json-schema@^1.1.6": - version "1.1.9" - resolved "https://registry.yarnpkg.com/@peculiar/json-schema/-/json-schema-1.1.9.tgz#b746e046b787607a1b2804f64437fda2527b3e62" - integrity sha512-F2ST2y/IQPgY+1QMw1Q33sqJbGDCeO3lGqI69SL3Hgo0++7iHqprUB1QyxB/A7bN3tuM65MBxoM2JLbwh42lsQ== - dependencies: - tslib "^1.10.0" - -"@peculiar/webcrypto@^1.0.22": - version "1.0.22" - resolved "https://registry.yarnpkg.com/@peculiar/webcrypto/-/webcrypto-1.0.22.tgz#9dae652fce6bacd9df15bc91965797cee33adf67" - integrity sha512-NP6H6ZGXUvJnQJCWzUgnRcQv+9nMCNwLUDhTwOxRUwPFvtHauMOl0oPTKUjbhInCMaE55gJqB4yc0YKbde6Exw== - dependencies: - "@peculiar/asn1-schema" "^1.0.3" - "@peculiar/json-schema" "^1.1.6" + "@types/asn1js" "^0.0.1" asn1js "^2.0.26" - pvtsutils "^1.0.9" - tslib "^1.10.0" - webcrypto-core "^1.0.17" + pvtsutils "^1.0.10" + tslib "^1.11.1" + +"@peculiar/json-schema@^1.1.10": + version "1.1.12" + resolved "https://registry.yarnpkg.com/@peculiar/json-schema/-/json-schema-1.1.12.tgz#fe61e85259e3b5ba5ad566cb62ca75b3d3cd5339" + integrity sha512-coUfuoMeIB7B8/NMekxaDzLhaYmp0HZNPEjYRm9goRou8UZIC3z21s0sL9AWoCw4EG876QyO3kYrc61WNF9B/w== + dependencies: + tslib "^2.0.0" + +"@peculiar/webcrypto@^1.1.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@peculiar/webcrypto/-/webcrypto-1.1.2.tgz#3114da877ddd9d2d0be10188371e15855aa71368" + integrity sha512-BkgD5iH2n3+Fdd/+xfhac8VbISo4MPvECPhK1kRpuYC7PnhxaJe2rpU7B4udvMeEL8lhJlvCWybo8Y7A29u/xQ== + dependencies: + "@peculiar/asn1-schema" "^2.0.8" + "@peculiar/json-schema" "^1.1.10" + pvtsutils "^1.0.10" + tslib "^2.0.0" + webcrypto-core "^1.1.2" "@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": version "1.1.2" @@ -464,6 +465,13 @@ dependencies: any-observable "^0.3.0" +"@types/asn1js@^0.0.1": + version "0.0.1" + resolved "https://registry.yarnpkg.com/@types/asn1js/-/asn1js-0.0.1.tgz#ef8b9f9708cb1632a1c3a9cd27717caabe793bc2" + integrity sha1-74uflwjLFjKhw6nNJ3F8qr55O8I= + dependencies: + "@types/pvutils" "*" + "@types/babel__core@^7.1.0": version "7.1.3" resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.3.tgz#e441ea7df63cd080dfcd02ab199e6d16a735fc30" @@ -633,6 +641,11 @@ resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== +"@types/pvutils@*": + version "0.0.2" + resolved "https://registry.yarnpkg.com/@types/pvutils/-/pvutils-0.0.2.tgz#e21684962cfa58ac920fd576d90556032dc86009" + integrity sha512-CgQAm7pjyeF3Gnv78ty4RBVIfluB+Td+2DR8iPaU0prF18pkzptHHP+DoKPfpsJYknKsVZyVsJEu5AuGgAqQ5w== + "@types/ramda@types/npm-ramda#dist": version "0.25.0" resolved "https://codeload.github.com/types/npm-ramda/tar.gz/9529aa3c8ff70ff84afcbc0be83443c00f30ea90" @@ -698,22 +711,6 @@ lodash.unescape "4.0.1" semver "5.5.0" -"@unimodules/core@*": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@unimodules/core/-/core-5.0.0.tgz#e1e3ca3f91f3d27dbc93c6eebc03a40c711da755" - integrity sha512-PswccfzFIviX61Lm8h6/QyC94bWe+6cARwhzgzTCKa6aR6azmi4732ExhX4VxfQjJNHB0szYVXGXVEDsFkj+tQ== - dependencies: - compare-versions "^3.4.0" - -"@unimodules/react-native-adapter@*": - version "5.0.0" - resolved "https://registry.yarnpkg.com/@unimodules/react-native-adapter/-/react-native-adapter-5.0.0.tgz#af9835821a2bf38390b9f09f3231c0b7546ee510" - integrity sha512-qb5p5wUQoi3TRa/33aLLHSnS7sewV99oBxIo9gnzNI3VFzbOm3rsbTjOJNcR2hx0raUolTtnQT75VbgagVQx4w== - dependencies: - invariant "^2.2.4" - lodash "^4.5.0" - prop-types "^15.6.1" - abab@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.2.tgz#a2fba1b122c69a85caa02d10f9270c7219709a9d" @@ -945,11 +942,6 @@ ascli@~1: colour "~0.7.1" optjs "~3.2.2" -asmcrypto.js@^0.22.0: - version "0.22.0" - resolved "https://registry.yarnpkg.com/asmcrypto.js/-/asmcrypto.js-0.22.0.tgz#38fc1440884d802c7bd37d1d23c2b26a5cd5d2d2" - integrity sha512-usgMoyXjMbx/ZPdzTSXExhMPur2FTdz/Vo5PVx2gIaBcdAAJNOFlsdgqveM8Cff7W0v+xrf9BwjOV26JSAF9qA== - asn1@~0.2.3: version "0.2.4" resolved "https://registry.yarnpkg.com/asn1/-/asn1-0.2.4.tgz#8d2475dfab553bb33e77b54e59e880bb8ce23136" @@ -957,7 +949,7 @@ asn1@~0.2.3: dependencies: safer-buffer "~2.1.0" -asn1js@^2.0.22, asn1js@^2.0.26: +asn1js@^2.0.26: version "2.0.26" resolved "https://registry.yarnpkg.com/asn1js/-/asn1js-2.0.26.tgz#0a6d435000f556a96c6012969d9704d981b71251" integrity sha512-yG89F0j9B4B0MKIcFyWWxnpZPLaNTjCj4tkE3fjbAoo0qmpGw0PYYqSbX/4ebnd9Icn8ZgK4K1fvDyEtW1JYtQ== @@ -1027,20 +1019,6 @@ axios@0.19.0, axios@^0.19.0: follow-redirects "1.5.10" is-buffer "^2.0.2" -b64-lite@^1.3.1, b64-lite@^1.4.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/b64-lite/-/b64-lite-1.4.0.tgz#e62442de11f1f21c60e38b74f111ac0242283d3d" - integrity sha512-aHe97M7DXt+dkpa8fHlCcm1CnskAHrJqEfMI0KN7dwqlzml/aUe1AGt6lk51HzrSfVD67xOso84sOpr+0wIe2w== - dependencies: - base-64 "^0.1.0" - -b64u-lite@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/b64u-lite/-/b64u-lite-1.1.0.tgz#a581b7df94cbd4bed7cbb19feae816654f0b1bf0" - integrity sha512-929qWGDVCRph7gQVTC6koHqQIpF4vtVaSbwLltFQo44B1bYUquALswZdBKFfrJCPEnsCOvWkJsPdQYZ/Ukhw8A== - dependencies: - b64-lite "^1.4.0" - babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" @@ -1184,11 +1162,6 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= -base-64@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/base-64/-/base-64-0.1.0.tgz#780a99c84e7d600260361511c4877613bf24f6bb" - integrity sha1-eAqZyE59YAJgNhURxId2E78k9rs= - base-x@^3.0.2: version "3.0.7" resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.7.tgz#1c5a7fafe8f66b4114063e8da102799d4e7c408f" @@ -1201,7 +1174,7 @@ base64-arraybuffer@0.1.5: resolved "https://registry.yarnpkg.com/base64-arraybuffer/-/base64-arraybuffer-0.1.5.tgz#73926771923b5a19747ad666aa5cd4bf9c6e9ce8" integrity sha1-c5JncZI7Whl0etZmqlzUv5xunOg= -base64-js@*, base64-js@^1.0.2, base64-js@^1.3.0: +base64-js@^1.0.2: version "1.3.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.1.tgz#58ece8cb75dd07e71ed08c736abc5fac4dbf8df1" integrity sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g== @@ -1697,7 +1670,7 @@ commander@~2.20.0: resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.1.tgz#3863ce3ca92d0831dcf2a102f5fb4b5926afd0f9" integrity sha512-cCuLsMhJeWQ/ZpsFTbE765kvVfoeSddc4nU3up4fV+fDBcfUXnbITJ+JzhkdjzOqhURjZgujxaioam4RM9yGUg== -compare-versions@^3.4.0, compare-versions@^3.6.0: +compare-versions@^3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-3.6.0.tgz#1a5689913685e5a87637b8d3ffca75514ec41d62" integrity sha512-W6Af2Iw1z4CB7q4uU4hv646dW9GQuBM+YpC0UvUCWSD8w90SJjp+ujJuXaEMtAXBtSqGfMPuFOVn4/+FlaqfBA== @@ -2477,13 +2450,6 @@ expect@^24.9.0: jest-message-util "^24.9.0" jest-regex-util "^24.9.0" -expo-random@*: - version "8.0.0" - resolved "https://registry.yarnpkg.com/expo-random/-/expo-random-8.0.0.tgz#bbcc7a189d29ae9b709b36a6cf84256c22cc16f6" - integrity sha512-ukDC3eGSEliBsnobX1bQRAwti9GE8ZEW53AHFf1fVy+JuAhhZm+M5HW7T0ptdbLjm46VpTDGIO4vq+qxeXAl7g== - dependencies: - base64-js "^1.3.0" - express-session@^1.15.1: version "1.16.2" resolved "https://registry.yarnpkg.com/express-session/-/express-session-1.16.2.tgz#59f36d7770e94872d19b163b6708a2d16aa6848c" @@ -2950,15 +2916,15 @@ grpc@^1.21.1: node-pre-gyp "^0.13.0" protobufjs "^5.0.3" -"gun@git://github.com/amark/gun#c59e0e95f92779ce6bb3aab823d318bc16b20c33": - version "0.2020.116" - resolved "git://github.com/amark/gun#c59e0e95f92779ce6bb3aab823d318bc16b20c33" +"gun@git://github.com/amark/gun#97aa976c97e6219a9f93095d32c220dcd371ca62": + version "0.2020.520" + resolved "git://github.com/amark/gun#97aa976c97e6219a9f93095d32c220dcd371ca62" dependencies: - buffer "^5.4.3" - ws "^7.1.2" + ws "^7.2.1" optionalDependencies: + "@peculiar/webcrypto" "^1.1.1" + buffer "^5.4.3" emailjs "^2.2.0" - isomorphic-webcrypto "^2.3.2" text-encoding "^0.7.0" handlebars@^4.1.2: @@ -3570,24 +3536,6 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= -isomorphic-webcrypto@^2.3.2: - version "2.3.4" - resolved "https://registry.yarnpkg.com/isomorphic-webcrypto/-/isomorphic-webcrypto-2.3.4.tgz#6d18ee7f795ab2f5e9fd7a5b489abaf9ee2e6af5" - integrity sha512-SnOCsm0Vls8jeWP4c26ItHFajzfDlRPcKK4YRUv6jukYGzJwl2tKNwSIAiCh1INdoRttaKhJrLc3HBer1om4HA== - dependencies: - "@peculiar/webcrypto" "^1.0.22" - asmcrypto.js "^0.22.0" - b64-lite "^1.3.1" - b64u-lite "^1.0.1" - msrcrypto "^1.5.6" - str2buf "^1.3.0" - webcrypto-shim "^0.1.4" - optionalDependencies: - "@unimodules/core" "*" - "@unimodules/react-native-adapter" "*" - expo-random "*" - react-native-securerandom "^0.1.1" - isstream@0.1.x, isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" @@ -4345,7 +4293,7 @@ lodash@=4.17.4: resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" integrity sha1-eCA6TRwyiuHYbcpkYONptX9AVa4= -lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.5.0: +lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4, lodash@^4.17.5: version "4.17.19" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.19.tgz#e48ddedbe30b3321783c5b4301fbd353bc1e4a4b" integrity sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ== @@ -4592,11 +4540,6 @@ ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -msrcrypto@^1.5.6: - version "1.5.8" - resolved "https://registry.yarnpkg.com/msrcrypto/-/msrcrypto-1.5.8.tgz#be419be4945bf134d8af52e9d43be7fa261f4a1c" - integrity sha512-ujZ0TRuozHKKm6eGbKHfXef7f+esIhEckmThVnz7RNyiOJd7a6MXj2JGBoL9cnPDW+JMG16MoTUh5X+XXjI66Q== - mute-stream@0.0.8: version "0.0.8" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" @@ -4816,7 +4759,7 @@ oauth-sign@~0.9.0: resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== -object-assign@^4, object-assign@^4.1.0, object-assign@^4.1.1: +object-assign@^4, object-assign@^4.1.0: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= @@ -5286,15 +5229,6 @@ prompts@^2.0.1: kleur "^3.0.3" sisteransi "^1.0.3" -prop-types@^15.6.1: - version "15.7.2" - resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5" - integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ== - dependencies: - loose-envify "^1.4.0" - object-assign "^4.1.1" - react-is "^16.8.1" - protobufjs@^5.0.3: version "5.0.3" resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-5.0.3.tgz#e4dfe9fb67c90b2630d15868249bcc4961467a17" @@ -5365,10 +5299,10 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== -pvtsutils@^1.0.9: - version "1.0.9" - resolved "https://registry.yarnpkg.com/pvtsutils/-/pvtsutils-1.0.9.tgz#0eb6106f27878ccaa55e7dfbf6bd2c75af461dee" - integrity sha512-/kDsuCKPqJuIzn37w6+iN+TiSrN+zrwPEd7FjT61oNbRvceGdsS94fMEWZ4/h6QZU5EZhBMiV+79IYedroP/Yw== +pvtsutils@^1.0.10: + version "1.0.10" + resolved "https://registry.yarnpkg.com/pvtsutils/-/pvtsutils-1.0.10.tgz#157d0fcb853f570d32e0f8788179f3057eacdf38" + integrity sha512-8ZKQcxnZKTn+fpDh7wL4yKax5fdl3UJzT8Jv49djZpB/dzPxacyN1Sez90b6YLdOmvIr9vaySJ5gw4aUA1EdSw== dependencies: tslib "^1.10.0" @@ -5427,23 +5361,11 @@ rc@^1.0.1, rc@^1.1.6, rc@^1.2.7: minimist "^1.2.0" strip-json-comments "~2.0.1" -react-is@^16.8.1: - version "16.12.0" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.12.0.tgz#2cc0fe0fba742d97fd527c42a13bec4eeb06241c" - integrity sha512-rPCkf/mWBtKc97aLL9/txD8DZdemK0vkA3JMLShjlJB3Pj3s+lpf1KaBzMfQrAmhMQB0n1cU/SUGgKKBCe837Q== - react-is@^16.8.4: version "16.10.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.10.1.tgz#0612786bf19df406502d935494f0450b40b8294f" integrity sha512-BXUMf9sIOPXXZWqr7+c5SeOKJykyVr2u0UDzEf4LNGc6taGkQe1A9DFD07umCIXz45RLr9oAAwZbAJ0Pkknfaw== -react-native-securerandom@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/react-native-securerandom/-/react-native-securerandom-0.1.1.tgz#f130623a412c338b0afadedbc204c5cbb8bf2070" - integrity sha1-8TBiOkEsM4sK+t7bwgTFy7i/IHA= - dependencies: - base64-js "*" - read-pkg-up@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-1.0.1.tgz#9d63c13276c065918d57f002a57f40a1b643fb02" @@ -6153,11 +6075,6 @@ stealthy-require@^1.1.1: resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" integrity sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks= -str2buf@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/str2buf/-/str2buf-1.3.0.tgz#a4172afff4310e67235178e738a2dbb573abead0" - integrity sha512-xIBmHIUHYZDP4HyoXGHYNVmxlXLXDrtFHYT0eV6IOdEj3VO9ccaF1Ejl9Oq8iFjITllpT8FhaXb4KsNmw+3EuA== - string-argv@0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.1.tgz#95e2fbec0427ae19184935f816d74aaa4c5c19da" @@ -6531,11 +6448,21 @@ ts-type@^1.2.16: ts-toolbelt "^6.6.2" typedarray-dts "^1.0.0" -tslib@^1.10.0, tslib@^1.9.0, tslib@^1.9.3: +tslib@^1.10.0, tslib@^1.9.0: version "1.10.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a" integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ== +tslib@^1.11.1, tslib@^1.11.2: + version "1.13.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.13.0.tgz#c881e13cc7015894ed914862d276436fa9a47043" + integrity sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q== + +tslib@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.0.0.tgz#18d13fc2dce04051e20f074cc8387fd8089ce4f3" + integrity sha512-lTqkx847PI7xEDYJntxZH89L2/aXInsyF2luSafe/+0fHOMjlBNXdH6th7f70qxLDhul7KZK0zC8V5ZIyHl0/g== + tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" @@ -6776,18 +6703,16 @@ wcwidth@^1.0.1: dependencies: defaults "^1.0.3" -webcrypto-core@^1.0.17: - version "1.0.17" - resolved "https://registry.yarnpkg.com/webcrypto-core/-/webcrypto-core-1.0.17.tgz#a9354bc0b1ba6735e882f4137ede2c4366e6ad9b" - integrity sha512-7jxTLgtM+TahBPErx/Dd2XvxFDfWJrHxjVeTSvIa4LSgiYrmCPlC2INiAMAfb8MbtHiwJKKqF5sPS0AWNjBbXw== +webcrypto-core@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/webcrypto-core/-/webcrypto-core-1.1.2.tgz#c522a9e5596688f2b6bb19e2d336f68efa8bdd57" + integrity sha512-LxM/dTcXr/ZnwwKLox0tGEOIqvP7KIJ4Hk/fFPX20tr1EgqTmpEFZinmu4FzoGVbs6e4jI1priQKCDrOBD3L6w== dependencies: - pvtsutils "^1.0.9" - tslib "^1.10.0" - -webcrypto-shim@^0.1.4: - version "0.1.5" - resolved "https://registry.yarnpkg.com/webcrypto-shim/-/webcrypto-shim-0.1.5.tgz#13e34a010ccc544edecfe8a2642204502841bcf0" - integrity sha512-mE+E00gulvbLjHaAwl0kph60oOLQRsKyivEFgV9DMM/3Y05F1vZvGq12hAcNzHRnYxyEOABBT/XMtwGSg5xA7A== + "@peculiar/asn1-schema" "^2.0.1" + "@peculiar/json-schema" "^1.1.10" + asn1js "^2.0.26" + pvtsutils "^1.0.10" + tslib "^1.11.2" webidl-conversions@^4.0.2: version "4.0.2" @@ -6964,10 +6889,10 @@ ws@^5.2.0: dependencies: async-limiter "~1.0.0" -ws@^7.1.2: - version "7.2.1" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.1.tgz#03ed52423cd744084b2cf42ed197c8b65a936b8e" - integrity sha512-sucePNSafamSKoOqoNfBd8V0StlkzJKL2ZAhGQinCfNQ+oacw+Pk7lcdAElecBF2VkLNZRiIb5Oi1Q5lVUVt2A== +ws@^7.2.1: + version "7.3.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.3.1.tgz#d0547bf67f7ce4f12a72dfe31262c68d7dc551c8" + integrity sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA== ws@~3.3.1: version "3.3.3"