mirror of https://github.com/waku-org/js-waku.git
Do not process Public Key Message if field is missing
This commit is contained in:
parent
370a347ff2
commit
f9174cd3d2
|
@ -121,6 +121,7 @@ function handlePublicKeyMessage(
|
|||
) {
|
||||
if (!msg.payload) return;
|
||||
const publicKeyMsg = PublicKeyMessage.decode(msg.payload);
|
||||
if (!publicKeyMsg) return;
|
||||
const ethDmPublicKey = bytesToHexStr(publicKeyMsg.ethDmPublicKey);
|
||||
if (ethDmPublicKey === myPublicKey) return;
|
||||
|
||||
|
|
|
@ -30,10 +30,16 @@ export class PublicKeyMessage {
|
|||
return PublicKeyMessage.Type.encode(message).finish();
|
||||
}
|
||||
|
||||
public static decode(bytes: Uint8Array | Buffer): PublicKeyMessage {
|
||||
public static decode(
|
||||
bytes: Uint8Array | Buffer
|
||||
): PublicKeyMessage | undefined {
|
||||
const payload = PublicKeyMessage.Type.decode(
|
||||
bytes
|
||||
) as unknown as PublicKeyMessagePayload;
|
||||
if (!payload.signature || !payload.ethDmPublicKey || !payload.ethAddress) {
|
||||
console.log('Field missing on decoded Public Key Message', payload);
|
||||
return;
|
||||
}
|
||||
return new PublicKeyMessage(payload);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue