From fe0be0134d5e5b6c438ec28e3be7e511287a9316 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Mon, 21 Jun 2021 15:01:56 -0400 Subject: [PATCH] Allow "me" as public key when decrypting in Gun RPC --- services/gunDB/rpc/index.js | 2 +- services/gunDB/sockets/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services/gunDB/rpc/index.js b/services/gunDB/rpc/index.js index 3feecde2..114836d2 100644 --- a/services/gunDB/rpc/index.js +++ b/services/gunDB/rpc/index.js @@ -46,7 +46,7 @@ const deepDecryptIfNeeded = async (value, publicKey) => { } let sec = '' - if (user.is.pub === publicKey) { + if (user.is.pub === publicKey || 'me' === publicKey) { sec = getMySecret() } else { sec = await SEA.secret(await pubToEpub(publicKey), user._.sea) diff --git a/services/gunDB/sockets/index.js b/services/gunDB/sockets/index.js index 18acaf9e..bdab8b56 100644 --- a/services/gunDB/sockets/index.js +++ b/services/gunDB/sockets/index.js @@ -141,7 +141,7 @@ const queryListenerCallback = ({ }) } const eventName = `query:data` - if (publicKeyForDecryption?.length > 15) { + if (publicKeyForDecryption) { const decData = await deepDecryptIfNeeded(data, publicKeyForDecryption) emit(eventName, { subscriptionId, response: { data: decData, key } }) return