diff --git a/services/gunDB/contact-api/utils/index.js b/services/gunDB/contact-api/utils/index.js index c5bb369c..e1fef163 100644 --- a/services/gunDB/contact-api/utils/index.js +++ b/services/gunDB/contact-api/utils/index.js @@ -206,12 +206,18 @@ const recipientToOutgoingID = async recipientPub => { * @returns {Promise} */ const currHandshakeAddress = async userPub => { - const maybeAddr = await tryAndWait(gun => - gun + const maybeAddr = await tryAndWait(async gun => { + const addr = await gun .user(userPub) .get(Key.CURRENT_HANDSHAKE_ADDRESS) .then() - ) + + if (typeof addr !== 'string' && addr !== null) { + throw new TypeError('Expected handshake address to be string or null') + } + + return addr + }) return typeof maybeAddr === 'string' ? maybeAddr : null }