enforce type of profileKey and signature on linking messages

pull/1241/head
Audric Ackermann 5 years ago
parent 948e32fbf7
commit 3fd260b793
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -2713,7 +2713,7 @@
const ourConversation = window.ConversationController.get(ourNumber);
let profileKey = null;
if (this.get('profileSharing')) {
profileKey = storage.get('profileKey');
profileKey = new Uint8Array(storage.get('profileKey'));
}
const avatarPointer = ourConversation.get('avatarPointer');
const { displayName } = ourConversation.getLokiProfile();

@ -553,7 +553,7 @@
timestamp: Date.now(),
primaryDevicePubKey,
secondaryDevicePubKey: ourPubKey,
requestSignature,
requestSignature: new Uint8Array(requestSignature),
}
);
await window.libsession
@ -616,14 +616,7 @@
);
// We need to send the our profile to the secondary device
const { displayName } = ourConversation.getLokiProfile();
const avatarPointer = ourConversation.get('avatarPointer');
const profileKey = window.storage.get('profileKey');
const lokiProfile = {
displayName,
profileKey,
avatarPointer,
};
const lokiProfile = ourConversation.getOurProfile();
// Try to upload to the file server and then send a message
try {
@ -631,7 +624,10 @@
const requestPairingMessage = new libsession.Messages.Outgoing.DeviceLinkGrantMessage(
{
timestamp: Date.now(),
...authorisation,
primaryDevicePubKey: ourPubKey,
secondaryDevicePubKey: secondaryDeviceStr,
requestSignature: new Uint8Array(requestSignature),
grantSignature: new Uint8Array(grantSignature),
lokiProfile,
}
);

@ -25,6 +25,13 @@ export class DeviceLinkGrantMessage extends DeviceLinkRequestMessage {
requestSignature: params.requestSignature,
});
if (!(params.lokiProfile.profileKey instanceof Uint8Array)) {
throw new TypeError('profileKey must be of type Uint8Array');
}
if (!(params.grantSignature instanceof Uint8Array)) {
throw new TypeError('grantSignature must be of type Uint8Array');
}
this.displayName = params.lokiProfile.displayName;
this.avatarPointer = params.lokiProfile.avatarPointer;
this.profileKey = params.lokiProfile.profileKey;

@ -14,6 +14,16 @@ export class DeviceLinkRequestMessage extends ContentMessage {
constructor(params: DeviceLinkMessageParams) {
super({ timestamp: params.timestamp, identifier: params.identifier });
if (!(params.requestSignature instanceof Uint8Array)) {
throw new TypeError('requestSignature must be of type Uint8Array');
}
if (typeof params.primaryDevicePubKey !== 'string') {
throw new TypeError('primaryDevicePubKey must be of type string');
}
if (typeof params.secondaryDevicePubKey !== 'string') {
throw new TypeError('secondaryDevicePubKey must be of type string');
}
this.primaryDevicePubKey = params.primaryDevicePubKey;
this.secondaryDevicePubKey = params.secondaryDevicePubKey;
this.requestSignature = params.requestSignature;

Loading…
Cancel
Save