fix pairing devices bugs since move to new pipeline

pull/1183/head
Audric Ackermann 5 years ago
parent 029851400d
commit 6380f7426f
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -601,17 +601,13 @@ async function removeAllContactSignedPreKeys() {
}
function signatureToBase64(signature) {
if (signature.constructor === dcodeIO.ByteBuffer) {
return dcodeIO.ByteBuffer.wrap(signature).toString('base64');
} else if (isArrayBuffer(signature)) {
return arrayBufferToBase64(signature);
} else if (typeof signature === 'string') {
// assume it's already base64
if (typeof signature === 'string') {
return signature;
}
throw new Error(
'Invalid signature provided in createOrUpdatePairingAuthorisation. Needs to be either ArrayBuffer or ByteBuffer.'
);
}
// Ensure signature is ByteBuffer, ArrayBuffer or Uint8Array otherwise throw error
return dcodeIO.ByteBuffer.wrap(signature).toString('base64');
}
async function createOrUpdatePairingAuthorisation(data) {

@ -590,8 +590,8 @@
const authorisations = await libsession.Protocols.MultiDeviceProtocol.getPairingAuthorisations(
secondaryDeviceStr
);
const existingAuthorisation = authorisations.some(
pairing => pairing.secondaryDevicePubKey === secondaryDevicePubKey
const existingAuthorisation = authorisations.find(
pairing => pairing.secondaryDevicePubKey === secondaryDeviceStr
);
if (!existingAuthorisation) {
throw new Error(
@ -628,7 +628,7 @@
// Try to upload to the file server and then send a message
try {
await lokiFileServerAPI.updateOurDeviceMapping();
const requestPairingMessage = new libsession.Messages.Outgoing.DeviceLinkGrantMessageParams(
const requestPairingMessage = new libsession.Messages.Outgoing.DeviceLinkGrantMessage(
{
timestamp: Date.now(),
...authorisation,

@ -1175,7 +1175,7 @@ MessageReceiver.prototype.extend({
const device = new libsession.Types.PubKey(envelope.source);
await libsession.Protocols.SessionProtocol.onSessionEstablished(device);
// TODO process sending queue for this device now that we have a session
await libsession.getMessageQueue().processPending(device);
}
if (content.pairingAuthorisation) {

@ -35,8 +35,8 @@ export class DeviceLinkGrantMessage extends DeviceLinkRequestMessage {
return new SignalService.PairingAuthorisationMessage({
primaryDevicePubKey: this.primaryDevicePubKey,
secondaryDevicePubKey: this.secondaryDevicePubKey,
requestSignature: this.requestSignature,
grantSignature: this.grantSignature,
requestSignature: new Uint8Array(this.requestSignature),
grantSignature: new Uint8Array(this.grantSignature),
});
}

@ -31,7 +31,7 @@ export class DeviceLinkRequestMessage extends ContentMessage {
return new SignalService.PairingAuthorisationMessage({
primaryDevicePubKey: this.primaryDevicePubKey,
secondaryDevicePubKey: this.secondaryDevicePubKey,
requestSignature: this.requestSignature,
requestSignature: new Uint8Array(this.requestSignature),
grantSignature: null,
});
}

Loading…
Cancel
Save