Made changes to how messages are sent.
Instead of blocking the message queue when we don't have a session, we instead just send out a session request and send the queued messages using fallback encryption. This means that users will be able to message right away without having to wait. The only down side is that all messages sent before sessions are established will be using the weaker encryption. This change also means we have to detach session requests from envelope type (which is a good thing) and thus now a message is a session request if it contains a preKeyBundle.pull/1233/head
parent
4381d0135f
commit
646973e330
@ -1,5 +1,5 @@
|
||||
export enum EncryptionType {
|
||||
Signal,
|
||||
SessionRequest,
|
||||
Fallback,
|
||||
MediumGroup,
|
||||
}
|
||||
|
@ -1,59 +0,0 @@
|
||||
import { expect } from 'chai';
|
||||
import { beforeEach } from 'mocha';
|
||||
|
||||
import {
|
||||
DeviceUnlinkMessage,
|
||||
SessionRequestMessage,
|
||||
} from '../../../session/messages/outgoing';
|
||||
import { SignalService } from '../../../protobuf';
|
||||
import { toRawMessage } from '../../../session/utils/Messages';
|
||||
import { EncryptionType, PubKey, RawMessage } from '../../../session/types';
|
||||
import { TestUtils } from '../../test-utils';
|
||||
import { TextEncoder } from 'util';
|
||||
|
||||
describe('toRawMessage', () => {
|
||||
let message: DeviceUnlinkMessage;
|
||||
const pubkey: PubKey = TestUtils.generateFakePubKey();
|
||||
let raw: RawMessage;
|
||||
|
||||
beforeEach(() => {
|
||||
const timestamp = Date.now();
|
||||
message = new DeviceUnlinkMessage({ timestamp });
|
||||
raw = toRawMessage(pubkey, message);
|
||||
});
|
||||
|
||||
it('copied fields are set', () => {
|
||||
expect(raw).to.have.property('ttl', message.ttl());
|
||||
expect(raw)
|
||||
.to.have.property('plainTextBuffer')
|
||||
.to.be.deep.equal(message.plainTextBuffer());
|
||||
expect(raw).to.have.property('timestamp', message.timestamp);
|
||||
expect(raw).to.have.property('identifier', message.identifier);
|
||||
expect(raw).to.have.property('device', pubkey.key);
|
||||
});
|
||||
|
||||
it('encryption is set to SESSION_REQUEST if message is of instance SessionRequestMessage', () => {
|
||||
const preKeyBundle = {
|
||||
deviceId: 123456,
|
||||
preKeyId: 654321,
|
||||
signedKeyId: 111111,
|
||||
preKey: new TextEncoder().encode('preKey'),
|
||||
signature: new TextEncoder().encode('signature'),
|
||||
signedKey: new TextEncoder().encode('signedKey'),
|
||||
identityKey: new TextEncoder().encode('identityKey'),
|
||||
};
|
||||
const sessionRequest = new SessionRequestMessage({
|
||||
timestamp: Date.now(),
|
||||
preKeyBundle,
|
||||
});
|
||||
const sessionRequestRaw = toRawMessage(pubkey, sessionRequest);
|
||||
expect(sessionRequestRaw).to.have.property(
|
||||
'encryption',
|
||||
EncryptionType.SessionRequest
|
||||
);
|
||||
});
|
||||
|
||||
it('encryption is set to Signal if message is not of instance SessionRequestMessage', () => {
|
||||
expect(raw).to.have.property('encryption', EncryptionType.Signal);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue