Backwards compatibility updates for libsignal-client
This commit is contained in:
parent
34285054f6
commit
bc0f4387fe
4 changed files with 28 additions and 6 deletions
12
preload.js
12
preload.js
|
@ -534,6 +534,18 @@ try {
|
||||||
},
|
},
|
||||||
createKeyPair: incomingKey => {
|
createKeyPair: incomingKey => {
|
||||||
const incomingKeyBuffer = Buffer.from(incomingKey);
|
const incomingKeyBuffer = Buffer.from(incomingKey);
|
||||||
|
|
||||||
|
if (incomingKeyBuffer.length !== 32) {
|
||||||
|
throw new Error('key must be 32 bytes long');
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-bitwise
|
||||||
|
incomingKeyBuffer[0] &= 248;
|
||||||
|
// eslint-disable-next-line no-bitwise
|
||||||
|
incomingKeyBuffer[31] &= 127;
|
||||||
|
// eslint-disable-next-line no-bitwise
|
||||||
|
incomingKeyBuffer[31] |= 64;
|
||||||
|
|
||||||
const privKey = client.PrivateKey.deserialize(incomingKeyBuffer);
|
const privKey = client.PrivateKey.deserialize(incomingKeyBuffer);
|
||||||
const pubKey = privKey.getPublicKey();
|
const pubKey = privKey.getPublicKey();
|
||||||
|
|
||||||
|
|
|
@ -4023,6 +4023,12 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
async leaveGroup(): Promise<void> {
|
async leaveGroup(): Promise<void> {
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
if (this.get('type') === 'group') {
|
if (this.get('type') === 'group') {
|
||||||
|
const groupId = this.get('groupId');
|
||||||
|
|
||||||
|
if (!groupId) {
|
||||||
|
throw new Error(`leaveGroup/${this.idForLogging()}: No groupId!`);
|
||||||
|
}
|
||||||
|
|
||||||
const groupIdentifiers = this.getRecipients();
|
const groupIdentifiers = this.getRecipients();
|
||||||
this.set({ left: true });
|
this.set({ left: true });
|
||||||
window.Signal.Data.updateConversation(this.attributes);
|
window.Signal.Data.updateConversation(this.attributes);
|
||||||
|
@ -4048,7 +4054,7 @@ export class ConversationModel extends window.Backbone.Model<
|
||||||
message.send(
|
message.send(
|
||||||
this.wrapSend(
|
this.wrapSend(
|
||||||
window.textsecure.messaging.leaveGroup(
|
window.textsecure.messaging.leaveGroup(
|
||||||
this.id,
|
groupId,
|
||||||
groupIdentifiers,
|
groupIdentifiers,
|
||||||
options
|
options
|
||||||
)
|
)
|
||||||
|
|
|
@ -1470,11 +1470,11 @@ export class MessageModel extends window.Backbone.Model<MessageAttributesType> {
|
||||||
|
|
||||||
// General
|
// General
|
||||||
idForLogging(): string {
|
idForLogging(): string {
|
||||||
const source = this.getSource();
|
const account = this.getSourceUuid() || this.getSource();
|
||||||
const device = this.getSourceDevice();
|
const device = this.getSourceDevice();
|
||||||
const timestamp = this.get('sent_at');
|
const timestamp = this.get('sent_at');
|
||||||
|
|
||||||
return `${source}.${device} ${timestamp}`;
|
return `${account}.${device} ${timestamp}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line class-methods-use-this
|
// eslint-disable-next-line class-methods-use-this
|
||||||
|
|
|
@ -622,10 +622,14 @@ class MessageReceiverInner extends EventTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
getEnvelopeId(envelope: EnvelopeClass) {
|
getEnvelopeId(envelope: EnvelopeClass) {
|
||||||
|
const timestamp =
|
||||||
|
envelope && envelope.timestamp && envelope.timestamp.toNumber
|
||||||
|
? envelope.timestamp.toNumber()
|
||||||
|
: null;
|
||||||
|
|
||||||
if (envelope.sourceUuid || envelope.source) {
|
if (envelope.sourceUuid || envelope.source) {
|
||||||
return `${envelope.sourceUuid || envelope.source}.${
|
const sender = envelope.sourceUuid || envelope.source;
|
||||||
envelope.sourceDevice
|
return `${sender}.${envelope.sourceDevice} ${timestamp} (${envelope.id})`;
|
||||||
} ${envelope.timestamp.toNumber()} (${envelope.id})`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return envelope.id;
|
return envelope.id;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue