mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
lint
This commit is contained in:
parent
f46c885fdf
commit
eb894a9b66
|
@ -1761,7 +1761,7 @@
|
|||
const id = details.number;
|
||||
|
||||
libloki.api.debug.logContactSync(
|
||||
'Got sync contact message with',
|
||||
'Got sync contact message with',
|
||||
id,
|
||||
' details:',
|
||||
details
|
||||
|
|
|
@ -1046,7 +1046,8 @@
|
|||
window.libloki.api.sendBackgroundMessage(
|
||||
this.id,
|
||||
window.textsecure.OutgoingMessage.DebugMessageType
|
||||
.INCOMING_FR_ACCEPTED);
|
||||
.INCOMING_FR_ACCEPTED
|
||||
);
|
||||
}
|
||||
},
|
||||
// Our outgoing friend request has been accepted
|
||||
|
|
|
@ -1,78 +1,78 @@
|
|||
/* global assert */
|
||||
|
||||
describe('Loki Messages', () => {
|
||||
describe('#backgroundMessage', () => {
|
||||
it('structure is valid', () => {
|
||||
const pubkey =
|
||||
'05050505050505050505050505050505050505050505050505050505050505050';
|
||||
const backgroundMessage = window.textsecure.OutgoingMessage.buildBackgroundMessage(
|
||||
pubkey
|
||||
);
|
||||
describe('#backgroundMessage', () => {
|
||||
it('structure is valid', () => {
|
||||
const pubkey =
|
||||
'05050505050505050505050505050505050505050505050505050505050505050';
|
||||
const backgroundMessage = window.textsecure.OutgoingMessage.buildBackgroundMessage(
|
||||
pubkey
|
||||
);
|
||||
|
||||
const validBackgroundObject = {
|
||||
server: null,
|
||||
numbers: [pubkey],
|
||||
// For now, a background message contains only a loki address message as
|
||||
// it must not be an empty message for android
|
||||
};
|
||||
const validBackgroundObject = {
|
||||
server: null,
|
||||
numbers: [pubkey],
|
||||
// For now, a background message contains only a loki address message as
|
||||
// it must not be an empty message for android
|
||||
};
|
||||
|
||||
const validBgMessage = {
|
||||
dataMessage: null,
|
||||
syncMessage: null,
|
||||
callMessage: null,
|
||||
nullMessage: null,
|
||||
receiptMessage: null,
|
||||
typingMessage: null,
|
||||
preKeyBundleMessage: null,
|
||||
pairingAuthorisation: null,
|
||||
};
|
||||
const validBgMessage = {
|
||||
dataMessage: null,
|
||||
syncMessage: null,
|
||||
callMessage: null,
|
||||
nullMessage: null,
|
||||
receiptMessage: null,
|
||||
typingMessage: null,
|
||||
preKeyBundleMessage: null,
|
||||
pairingAuthorisation: null,
|
||||
};
|
||||
|
||||
const lokiAddressMessage = {
|
||||
p2pAddress: null,
|
||||
p2pPort: null,
|
||||
type: 1,
|
||||
};
|
||||
const lokiAddressMessage = {
|
||||
p2pAddress: null,
|
||||
p2pPort: null,
|
||||
type: 1,
|
||||
};
|
||||
|
||||
assert.isNumber(backgroundMessage.timestamp);
|
||||
assert.isFunction(backgroundMessage.callback);
|
||||
assert.deepInclude(backgroundMessage, validBackgroundObject);
|
||||
assert.deepInclude(backgroundMessage.message, validBgMessage);
|
||||
assert.deepInclude(
|
||||
backgroundMessage.message.lokiAddressMessage,
|
||||
lokiAddressMessage
|
||||
);
|
||||
});
|
||||
assert.isNumber(backgroundMessage.timestamp);
|
||||
assert.isFunction(backgroundMessage.callback);
|
||||
assert.deepInclude(backgroundMessage, validBackgroundObject);
|
||||
assert.deepInclude(backgroundMessage.message, validBgMessage);
|
||||
assert.deepInclude(
|
||||
backgroundMessage.message.lokiAddressMessage,
|
||||
lokiAddressMessage
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#autoFriendRequestMessage', () => {
|
||||
it('structure is valid', () => {
|
||||
const pubkey =
|
||||
'05050505050505050505050505050505050505050505050505050505050505050';
|
||||
const autoFrMessage = window.textsecure.OutgoingMessage.buildAutoFriendRequestMessage(
|
||||
pubkey
|
||||
);
|
||||
describe('#autoFriendRequestMessage', () => {
|
||||
it('structure is valid', () => {
|
||||
const pubkey =
|
||||
'05050505050505050505050505050505050505050505050505050505050505050';
|
||||
const autoFrMessage = window.textsecure.OutgoingMessage.buildAutoFriendRequestMessage(
|
||||
pubkey
|
||||
);
|
||||
|
||||
const validAutoFrObject = {
|
||||
server: null,
|
||||
numbers: [pubkey],
|
||||
};
|
||||
const validAutoFrObject = {
|
||||
server: null,
|
||||
numbers: [pubkey],
|
||||
};
|
||||
|
||||
const validAutoFrMessage = {
|
||||
syncMessage: null,
|
||||
callMessage: null,
|
||||
nullMessage: null,
|
||||
receiptMessage: null,
|
||||
typingMessage: null,
|
||||
preKeyBundleMessage: null,
|
||||
lokiAddressMessage: null,
|
||||
pairingAuthorisation: null,
|
||||
};
|
||||
const validAutoFrMessage = {
|
||||
syncMessage: null,
|
||||
callMessage: null,
|
||||
nullMessage: null,
|
||||
receiptMessage: null,
|
||||
typingMessage: null,
|
||||
preKeyBundleMessage: null,
|
||||
lokiAddressMessage: null,
|
||||
pairingAuthorisation: null,
|
||||
};
|
||||
|
||||
assert.isNumber(autoFrMessage.timestamp);
|
||||
assert.isFunction(autoFrMessage.callback);
|
||||
assert.deepInclude(autoFrMessage.message, validAutoFrMessage);
|
||||
assert.isObject(autoFrMessage.message.dataMessage);
|
||||
assert.deepInclude(autoFrMessage, validAutoFrObject);
|
||||
});
|
||||
assert.isNumber(autoFrMessage.timestamp);
|
||||
assert.isFunction(autoFrMessage.callback);
|
||||
assert.deepInclude(autoFrMessage.message, validAutoFrMessage);
|
||||
assert.isObject(autoFrMessage.message.dataMessage);
|
||||
assert.deepInclude(autoFrMessage, validAutoFrObject);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -138,7 +138,7 @@ MessageReceiver.prototype.extend({
|
|||
} else {
|
||||
ev = new Event('message');
|
||||
}
|
||||
ev.confirm = function confirmTerm() { };
|
||||
ev.confirm = function confirmTerm() {};
|
||||
ev.data = message;
|
||||
this.dispatchAndWait(ev);
|
||||
},
|
||||
|
@ -1291,49 +1291,49 @@ MessageReceiver.prototype.extend({
|
|||
await this.handleEndSession(envelope.source);
|
||||
}
|
||||
const message = await this.processDecrypted(envelope, msg);
|
||||
const ourPubKey = textsecure.storage.user.getNumber();
|
||||
const senderPubKey = envelope.source;
|
||||
const isMe = senderPubKey === ourPubKey;
|
||||
const conversation = window.ConversationController.get(senderPubKey);
|
||||
const ourPubKey = textsecure.storage.user.getNumber();
|
||||
const senderPubKey = envelope.source;
|
||||
const isMe = senderPubKey === ourPubKey;
|
||||
const conversation = window.ConversationController.get(senderPubKey);
|
||||
|
||||
const { UNPAIRING_REQUEST } = textsecure.protobuf.DataMessage.Flags;
|
||||
const { UNPAIRING_REQUEST } = textsecure.protobuf.DataMessage.Flags;
|
||||
|
||||
const friendRequest =
|
||||
envelope.type === textsecure.protobuf.Envelope.Type.FRIEND_REQUEST;
|
||||
// eslint-disable-next-line no-bitwise
|
||||
const isUnpairingRequest = Boolean(message.flags & UNPAIRING_REQUEST);
|
||||
const friendRequest =
|
||||
envelope.type === textsecure.protobuf.Envelope.Type.FRIEND_REQUEST;
|
||||
// eslint-disable-next-line no-bitwise
|
||||
const isUnpairingRequest = Boolean(message.flags & UNPAIRING_REQUEST);
|
||||
|
||||
if (isUnpairingRequest) {
|
||||
return this.handleUnpairRequest(envelope, ourPubKey);
|
||||
}
|
||||
if (isUnpairingRequest) {
|
||||
return this.handleUnpairRequest(envelope, ourPubKey);
|
||||
}
|
||||
|
||||
// Check if we need to update any profile names
|
||||
if (!isMe && conversation && message.profile) {
|
||||
await this.updateProfile(
|
||||
conversation,
|
||||
message.profile,
|
||||
message.profileKey
|
||||
);
|
||||
}
|
||||
// Check if we need to update any profile names
|
||||
if (!isMe && conversation && message.profile) {
|
||||
await this.updateProfile(
|
||||
conversation,
|
||||
message.profile,
|
||||
message.profileKey
|
||||
);
|
||||
}
|
||||
if (!friendRequest && this.isMessageEmpty(message)) {
|
||||
window.log.warn(
|
||||
`Message ${this.getEnvelopeId(envelope)} ignored; it was empty`
|
||||
);
|
||||
return this.removeFromCache(envelope);
|
||||
}
|
||||
// Build a 'message' event i.e. a received message event
|
||||
const ev = new Event('message');
|
||||
ev.confirm = this.removeFromCache.bind(this, envelope);
|
||||
ev.data = {
|
||||
friendRequest,
|
||||
source: senderPubKey,
|
||||
sourceDevice: envelope.sourceDevice,
|
||||
timestamp: envelope.timestamp.toNumber(),
|
||||
receivedAt: envelope.receivedAt,
|
||||
unidentifiedDeliveryReceived: envelope.unidentifiedDeliveryReceived,
|
||||
message,
|
||||
};
|
||||
return this.dispatchAndWait(ev);
|
||||
// Build a 'message' event i.e. a received message event
|
||||
const ev = new Event('message');
|
||||
ev.confirm = this.removeFromCache.bind(this, envelope);
|
||||
ev.data = {
|
||||
friendRequest,
|
||||
source: senderPubKey,
|
||||
sourceDevice: envelope.sourceDevice,
|
||||
timestamp: envelope.timestamp.toNumber(),
|
||||
receivedAt: envelope.receivedAt,
|
||||
unidentifiedDeliveryReceived: envelope.unidentifiedDeliveryReceived,
|
||||
message,
|
||||
};
|
||||
return this.dispatchAndWait(ev);
|
||||
},
|
||||
isMessageEmpty({
|
||||
body,
|
||||
|
@ -1372,13 +1372,13 @@ MessageReceiver.prototype.extend({
|
|||
async handleContentMessage(envelope) {
|
||||
const plaintext = await this.decrypt(envelope, envelope.content);
|
||||
|
||||
if (!plaintext) {
|
||||
window.log.warn('handleContentMessage: plaintext was falsey');
|
||||
return null;
|
||||
if (!plaintext) {
|
||||
window.log.warn('handleContentMessage: plaintext was falsey');
|
||||
return null;
|
||||
} else if (plaintext instanceof ArrayBuffer && plaintext.byteLength === 0) {
|
||||
return null;
|
||||
}
|
||||
return this.innerHandleContentMessage(envelope, plaintext);
|
||||
return null;
|
||||
}
|
||||
return this.innerHandleContentMessage(envelope, plaintext);
|
||||
},
|
||||
async innerHandleContentMessage(envelope, plaintext) {
|
||||
const content = textsecure.protobuf.Content.decode(plaintext);
|
||||
|
|
|
@ -578,7 +578,7 @@ OutgoingMessage.prototype = {
|
|||
ciphertext,
|
||||
source,
|
||||
keyIdx,
|
||||
});
|
||||
});
|
||||
|
||||
// Encrypt for the group's identity key to hide source and key idx:
|
||||
const {
|
||||
|
@ -637,8 +637,10 @@ OutgoingMessage.prototype = {
|
|||
} = outgoingObject;
|
||||
|
||||
try {
|
||||
const socketMessage = wrapInWebsocketMessage(outgoingObject,
|
||||
this.timestamp);
|
||||
const socketMessage = wrapInWebsocketMessage(
|
||||
outgoingObject,
|
||||
this.timestamp
|
||||
);
|
||||
await this.transmitMessage(
|
||||
destination,
|
||||
socketMessage,
|
||||
|
|
|
@ -399,7 +399,6 @@ MessageSender.prototype = {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
const ourNumber = textsecure.storage.user.getNumber();
|
||||
|
||||
// Check wether we have the keys to start a session with the user
|
||||
|
@ -440,7 +439,7 @@ MessageSender.prototype = {
|
|||
haveSession ||
|
||||
keysFound ||
|
||||
options.isPublic ||
|
||||
options.isMediumGroup ||
|
||||
options.isMediumGroup ||
|
||||
options.messageType === 'friend-request'
|
||||
) {
|
||||
const outgoing = new OutgoingMessage(
|
||||
|
@ -455,11 +454,11 @@ MessageSender.prototype = {
|
|||
this.queueJobForNumber(number, () => outgoing.sendToNumber(number));
|
||||
} else {
|
||||
window.log.error(`No session for number: ${number}`);
|
||||
const isGroupMessage = !!(
|
||||
message &&
|
||||
message.dataMessage &&
|
||||
message.dataMessage.group
|
||||
);
|
||||
const isGroupMessage = !!(
|
||||
message &&
|
||||
message.dataMessage &&
|
||||
message.dataMessage.group
|
||||
);
|
||||
// If it was a message to a group then we need to send a session request
|
||||
if (isGroupMessage) {
|
||||
const sessionRequestMessage = textsecure.OutgoingMessage.buildSessionRequestMessage(
|
||||
|
@ -1223,9 +1222,9 @@ MessageSender.prototype = {
|
|||
|
||||
const attachment = await this.makeAttachmentPointer(avatar);
|
||||
|
||||
proto.group.avatar = attachment;
|
||||
// TODO: re-enable this once we have attachments
|
||||
proto.group.avatar = null;
|
||||
proto.group.avatar = attachment;
|
||||
// TODO: re-enable this once we have attachments
|
||||
proto.group.avatar = null;
|
||||
await this.sendGroupProto(recipients, proto, Date.now(), options);
|
||||
|
||||
return proto.group.id;
|
||||
|
|
|
@ -834,6 +834,7 @@ export class RegistrationTabs extends React.Component<{}, State> {
|
|||
type: 'error',
|
||||
id: 'pairingOngoing',
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
this.setState({
|
||||
|
|
Loading…
Reference in a new issue