add new handling of session request message

pull/1172/head
Audric Ackermann 4 years ago
parent f17ffd295a
commit d1518f8233
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -20,6 +20,7 @@
/* global ConversationController: false */
/* global Signal: false */
/* global log: false */
/* global session: false */
/* eslint-disable more/no-then */
/* eslint-disable no-unreachable */
@ -1545,24 +1546,42 @@ MessageReceiver.prototype.extend({
window.log.info('Error getting conversation: ', envelope.source);
}
},
async handleSessionRequestMessage(envelope, content) {
const shouldProcessSessionRequest = await session.Protocols.SessionProtocol.shouldProcessSessionRequest(
envelope.source,
envelope.timestamp
);
if (shouldProcessSessionRequest) {
if (content.preKeyBundleMessage) {
await this.savePreKeyBundleMessage(
envelope.source,
content.preKeyBundleMessage
);
}
await session.Protocols.SessionProtocol.onSessionRequestProcessed(
envelope.source
);
window.log.info('sending session established to', envelope.source);
// We don't need to await the call below because we just want to send it off
window.libloki.api.sendSessionEstablishedMessage(envelope.source);
}
},
async innerHandleContentMessage(envelope, plaintext) {
const content = textsecure.protobuf.Content.decode(plaintext);
const { SESSION_REQUEST } = textsecure.protobuf.Envelope.Type;
if (content.preKeyBundleMessage) {
await this.savePreKeyBundleMessage(
envelope.source,
content.preKeyBundleMessage
if (envelope.type === SESSION_REQUEST) {
await this.handleSessionRequestMessage(envelope, content);
} else {
await session.Protocols.SessionProtocol.onSessionEstablished(
envelope.source
);
// TODO process sending queue for this device now that we have a session
}
this.handleFriendRequestAcceptIfNeeded(envelope, content);
if (content.lokiAddressMessage) {
return this.handleLokiAddressMessage(
envelope,
content.lokiAddressMessage
);
}
if (content.pairingAuthorisation) {
return this.handlePairingAuthorisationMessage(envelope, content);
}
@ -1660,14 +1679,6 @@ MessageReceiver.prototype.extend({
return this.dispatchEvent(ev);
},
handleNullMessage(envelope) {
// Loki - Temp hack for new protocl backward compatibility
// This should be removed once we add the new protocol
if (envelope.type === textsecure.protobuf.Envelope.Type.FRIEND_REQUEST) {
window.log.info('sent session established to', envelope.source);
// We don't need to await the call below because we just want to send it off
window.libloki.api.sendSessionEstablishedMessage(envelope.source);
}
window.log.info('null message from', this.getEnvelopeId(envelope));
this.removeFromCache(envelope);
},

@ -159,6 +159,7 @@ window.setPassword = (passPhrase, oldPhrase) =>
});
window.passwordUtil = require('./app/password_util');
window.session = require('./ts/session');
// We never do these in our code, so we'll prevent it everywhere
window.open = () => null;

@ -13,7 +13,7 @@ message Envelope {
RECEIPT = 5;
UNIDENTIFIED_SENDER = 6;
MEDIUM_GROUP_CIPHERTEXT = 7;
FRIEND_REQUEST = 101; // contains prekeys + message and is using simple encryption
SESSION_REQUEST = 101; // contains prekeys and is using simple encryption
}
optional Type type = 1;

@ -4,7 +4,7 @@ import { SignalService } from '../../../../protobuf';
export class FallBackSessionCipherStub {
public async encrypt(buffer: ArrayBuffer): Promise<CipherTextObject> {
return {
type: SignalService.Envelope.Type.FRIEND_REQUEST,
type: SignalService.Envelope.Type.SESSION_REQUEST,
body: Buffer.from(buffer).toString('binary'),
};
}

Loading…
Cancel
Save