Merge pull request #403 from shocknet/pubkey-decrypt-shorthand
Allow "me" as public key when decrypting in Gun RPC
This commit is contained in:
commit
75e738d198
3 changed files with 3 additions and 2 deletions
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
|
|
@ -5,6 +5,7 @@
|
||||||
"editor.formatOnSave": true,
|
"editor.formatOnSave": true,
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
|
"Epub",
|
||||||
"ISEA",
|
"ISEA",
|
||||||
"Reqs"
|
"Reqs"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ const deepDecryptIfNeeded = async (value, publicKey) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
let sec = ''
|
let sec = ''
|
||||||
if (user.is.pub === publicKey) {
|
if (user.is.pub === publicKey || 'me' === publicKey) {
|
||||||
sec = getMySecret()
|
sec = getMySecret()
|
||||||
} else {
|
} else {
|
||||||
sec = await SEA.secret(await pubToEpub(publicKey), user._.sea)
|
sec = await SEA.secret(await pubToEpub(publicKey), user._.sea)
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ const queryListenerCallback = ({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const eventName = `query:data`
|
const eventName = `query:data`
|
||||||
if (publicKeyForDecryption?.length > 15) {
|
if (publicKeyForDecryption) {
|
||||||
const decData = await deepDecryptIfNeeded(data, publicKeyForDecryption)
|
const decData = await deepDecryptIfNeeded(data, publicKeyForDecryption)
|
||||||
emit(eventName, { subscriptionId, response: { data: decData, key } })
|
emit(eventName, { subscriptionId, response: { data: decData, key } })
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue