diff --git a/js/models/conversations.js b/js/models/conversations.js index 60e70460e..b67d943e7 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -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(); diff --git a/libtextsecure/account_manager.js b/libtextsecure/account_manager.js index e39ca1984..573e31caa 100644 --- a/libtextsecure/account_manager.js +++ b/libtextsecure/account_manager.js @@ -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, } ); diff --git a/ts/session/messages/outgoing/content/link/DeviceLinkGrantMessage.ts b/ts/session/messages/outgoing/content/link/DeviceLinkGrantMessage.ts index a07217104..af4750782 100644 --- a/ts/session/messages/outgoing/content/link/DeviceLinkGrantMessage.ts +++ b/ts/session/messages/outgoing/content/link/DeviceLinkGrantMessage.ts @@ -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; diff --git a/ts/session/messages/outgoing/content/link/DeviceLinkRequestMessage.ts b/ts/session/messages/outgoing/content/link/DeviceLinkRequestMessage.ts index 945f9f00e..58c071ca9 100644 --- a/ts/session/messages/outgoing/content/link/DeviceLinkRequestMessage.ts +++ b/ts/session/messages/outgoing/content/link/DeviceLinkRequestMessage.ts @@ -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;