diff --git a/lib/handlers/peer-to-peer-message-handler.js b/lib/handlers/peer-to-peer-message-handler.js --- a/lib/handlers/peer-to-peer-message-handler.js +++ b/lib/handlers/peer-to-peer-message-handler.js @@ -161,10 +161,17 @@ message.userID, null, ); - if (result.valid) { + if (!result.valid) { console.log( - `Received valid device list update for user ${message.userID}`, + `Received invalid device list update for user ${message.userID}. Reason: ${result.reason}`, ); + return; + } + console.log( + `Received valid device list update for user ${message.userID}`, + ); + + if (message?.signedDeviceList?.rawDeviceList) { const receivedRawList = JSON.parse( message.signedDeviceList.rawDeviceList, ); @@ -176,10 +183,6 @@ listsAreEqual ? '' : 'not' } equal.`, ); - } else { - console.log( - `Received invalid device list update for user ${message.userID}. Reason: ${result.reason}`, - ); } } catch (e) { console.log( diff --git a/lib/types/tunnelbroker/peer-to-peer-message-types.js b/lib/types/tunnelbroker/peer-to-peer-message-types.js --- a/lib/types/tunnelbroker/peer-to-peer-message-types.js +++ b/lib/types/tunnelbroker/peer-to-peer-message-types.js @@ -79,13 +79,13 @@ export type DeviceListUpdated = { +type: 'DeviceListUpdated', +userID: string, - +signedDeviceList: SignedDeviceList, + +signedDeviceList?: SignedDeviceList, }; export const deviceListUpdatedValidator: TInterface = tShape({ type: tString(peerToPeerMessageTypes.DEVICE_LIST_UPDATED), userID: tUserID, - signedDeviceList: signedDeviceListValidator, + signedDeviceList: t.maybe(signedDeviceListValidator), }); export type MessageProcessed = {