Refine Sealed Sender behaviors
This commit is contained in:
parent
8391f6ec4e
commit
2d48daa7b6
8 changed files with 59 additions and 32 deletions
|
@ -721,7 +721,8 @@
|
||||||
|
|
||||||
if (Whisper.Import.isComplete()) {
|
if (Whisper.Import.isComplete()) {
|
||||||
const { wrap, sendOptions } = ConversationController.prepareForSend(
|
const { wrap, sendOptions } = ConversationController.prepareForSend(
|
||||||
textsecure.storage.user.getNumber()
|
textsecure.storage.user.getNumber(),
|
||||||
|
{ syncMessage: true }
|
||||||
);
|
);
|
||||||
wrap(
|
wrap(
|
||||||
textsecure.messaging.sendRequestConfigurationSyncMessage(sendOptions)
|
textsecure.messaging.sendRequestConfigurationSyncMessage(sendOptions)
|
||||||
|
|
|
@ -181,10 +181,12 @@
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
prepareForSend(id) {
|
prepareForSend(id, options) {
|
||||||
// id is either a group id or an individual user's id
|
// id is either a group id or an individual user's id
|
||||||
const conversation = this.get(id);
|
const conversation = this.get(id);
|
||||||
const sendOptions = conversation && conversation.getSendOptions();
|
const sendOptions = conversation
|
||||||
|
? conversation.getSendOptions(options)
|
||||||
|
: null;
|
||||||
const wrap = conversation
|
const wrap = conversation
|
||||||
? conversation.wrapSend.bind(conversation)
|
? conversation.wrapSend.bind(conversation)
|
||||||
: promise => promise;
|
: promise => promise;
|
||||||
|
|
|
@ -342,10 +342,11 @@
|
||||||
// a sync message to our own devices, we need to send the accessKeys down for both
|
// a sync message to our own devices, we need to send the accessKeys down for both
|
||||||
// contacts. So we merge their sendOptions.
|
// contacts. So we merge their sendOptions.
|
||||||
const { sendOptions } = ConversationController.prepareForSend(
|
const { sendOptions } = ConversationController.prepareForSend(
|
||||||
this.ourNumber
|
this.ourNumber,
|
||||||
|
{ syncMessage: true }
|
||||||
);
|
);
|
||||||
const recipientSendOptions = this.getSendOptions();
|
const contactSendOptions = this.getSendOptions();
|
||||||
const options = Object.assign({}, sendOptions, recipientSendOptions);
|
const options = Object.assign({}, sendOptions, contactSendOptions);
|
||||||
|
|
||||||
const promise = textsecure.storage.protocol.loadIdentityKey(number);
|
const promise = textsecure.storage.protocol.loadIdentityKey(number);
|
||||||
return promise.then(key =>
|
return promise.then(key =>
|
||||||
|
@ -879,9 +880,9 @@
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
getSendOptions() {
|
getSendOptions(options = {}) {
|
||||||
const senderCertificate = storage.get('senderCertificate');
|
const senderCertificate = storage.get('senderCertificate');
|
||||||
const numberInfo = this.getNumberInfo();
|
const numberInfo = this.getNumberInfo(options);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
senderCertificate,
|
senderCertificate,
|
||||||
|
@ -889,7 +890,10 @@
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
getNumberInfo({ disableMeCheck } = {}) {
|
getNumberInfo(options = {}) {
|
||||||
|
const { syncMessage, disableMeCheck } = options;
|
||||||
|
|
||||||
|
// START: this code has an Expiration date of ~2018/11/21
|
||||||
// We don't want to enable unidentified delivery for send unless it is
|
// We don't want to enable unidentified delivery for send unless it is
|
||||||
// also enabled for our own account.
|
// also enabled for our own account.
|
||||||
const me = ConversationController.getOrCreate(this.ourNumber, 'private');
|
const me = ConversationController.getOrCreate(this.ourNumber, 'private');
|
||||||
|
@ -899,10 +903,11 @@
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
// END
|
||||||
|
|
||||||
if (!this.isPrivate()) {
|
if (!this.isPrivate()) {
|
||||||
const infoArray = this.contactCollection.map(conversation =>
|
const infoArray = this.contactCollection.map(conversation =>
|
||||||
conversation.getNumberInfo({ disableMeCheck })
|
conversation.getNumberInfo(options)
|
||||||
);
|
);
|
||||||
return Object.assign({}, ...infoArray);
|
return Object.assign({}, ...infoArray);
|
||||||
}
|
}
|
||||||
|
@ -910,6 +915,11 @@
|
||||||
const accessKey = this.get('accessKey');
|
const accessKey = this.get('accessKey');
|
||||||
const sealedSender = this.get('sealedSender');
|
const sealedSender = this.get('sealedSender');
|
||||||
|
|
||||||
|
// We never send sync messages as sealed sender
|
||||||
|
if (syncMessage && this.id === this.ourNumber) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
// If we've never fetched user's profile, we default to what we have
|
// If we've never fetched user's profile, we default to what we have
|
||||||
if (sealedSender === SEALED_SENDER.UNKNOWN) {
|
if (sealedSender === SEALED_SENDER.UNKNOWN) {
|
||||||
return {
|
return {
|
||||||
|
@ -1243,19 +1253,17 @@
|
||||||
window.log.info(`Sending ${read.length} read receipts`);
|
window.log.info(`Sending ${read.length} read receipts`);
|
||||||
// Because syncReadMessages sends to our other devices, and sendReadReceipts goes
|
// Because syncReadMessages sends to our other devices, and sendReadReceipts goes
|
||||||
// to a contact, we need accessKeys for both.
|
// to a contact, we need accessKeys for both.
|
||||||
const prep = ConversationController.prepareForSend(this.ourNumber);
|
const { sendOptions } = ConversationController.prepareForSend(
|
||||||
const recipientSendOptions = this.getSendOptions();
|
this.ourNumber,
|
||||||
const sendOptions = Object.assign(
|
{ syncMessage: true }
|
||||||
{},
|
|
||||||
prep.sendOptions,
|
|
||||||
recipientSendOptions
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.wrapSend(
|
await this.wrapSend(
|
||||||
textsecure.messaging.syncReadMessages(read, sendOptions)
|
textsecure.messaging.syncReadMessages(read, sendOptions)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (storage.get('read-receipt-setting')) {
|
if (storage.get('read-receipt-setting')) {
|
||||||
|
const convoSendOptions = this.getSendOptions();
|
||||||
|
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
_.map(_.groupBy(read, 'sender'), async (receipts, sender) => {
|
_.map(_.groupBy(read, 'sender'), async (receipts, sender) => {
|
||||||
const timestamps = _.map(receipts, 'timestamp');
|
const timestamps = _.map(receipts, 'timestamp');
|
||||||
|
@ -1263,7 +1271,7 @@
|
||||||
textsecure.messaging.sendReadReceipts(
|
textsecure.messaging.sendReadReceipts(
|
||||||
sender,
|
sender,
|
||||||
timestamps,
|
timestamps,
|
||||||
sendOptions
|
convoSendOptions
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
|
@ -981,7 +981,8 @@
|
||||||
sendSyncMessage() {
|
sendSyncMessage() {
|
||||||
const ourNumber = textsecure.storage.user.getNumber();
|
const ourNumber = textsecure.storage.user.getNumber();
|
||||||
const { wrap, sendOptions } = ConversationController.prepareForSend(
|
const { wrap, sendOptions } = ConversationController.prepareForSend(
|
||||||
ourNumber
|
ourNumber,
|
||||||
|
{ syncMessage: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
this.syncPromise = this.syncPromise || Promise.resolve();
|
this.syncPromise = this.syncPromise || Promise.resolve();
|
||||||
|
|
|
@ -46,7 +46,9 @@ exports.syncReadReceiptConfiguration = async ({
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { wrap, sendOptions } = prepareForSend(ourNumber);
|
const { wrap, sendOptions } = prepareForSend(ourNumber, {
|
||||||
|
syncMessage: true,
|
||||||
|
});
|
||||||
await wrap(sendRequestConfigurationSyncMessage(sendOptions));
|
await wrap(sendRequestConfigurationSyncMessage(sendOptions));
|
||||||
storage.put(settingName, true);
|
storage.put(settingName, true);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const WebSocket = require('websocket').w3cwebsocket;
|
const WebSocket = require('websocket').w3cwebsocket;
|
||||||
const fetch = require('node-fetch');
|
const fetch = require('node-fetch');
|
||||||
const ProxyAgent = require('proxy-agent');
|
const ProxyAgent = require('proxy-agent');
|
||||||
|
const { Agent } = require('https');
|
||||||
|
|
||||||
const is = require('@sindresorhus/is');
|
const is = require('@sindresorhus/is');
|
||||||
|
|
||||||
|
@ -159,6 +160,11 @@ function _createSocket(url, { certificateAuthority, proxyUrl }) {
|
||||||
return new WebSocket(url, null, null, null, requestOptions);
|
return new WebSocket(url, null, null, null, requestOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const agents = {
|
||||||
|
unauth: null,
|
||||||
|
auth: null,
|
||||||
|
};
|
||||||
|
|
||||||
function _promiseAjax(providedUrl, options) {
|
function _promiseAjax(providedUrl, options) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const url = providedUrl || `${options.host}/${options.path}`;
|
const url = providedUrl || `${options.host}/${options.path}`;
|
||||||
|
@ -169,10 +175,16 @@ function _promiseAjax(providedUrl, options) {
|
||||||
typeof options.timeout !== 'undefined' ? options.timeout : 10000;
|
typeof options.timeout !== 'undefined' ? options.timeout : 10000;
|
||||||
|
|
||||||
const { proxyUrl } = options;
|
const { proxyUrl } = options;
|
||||||
let agent;
|
const agentType = options.unathenticated ? 'unauth' : 'auth';
|
||||||
|
|
||||||
|
if (!agents[agentType]) {
|
||||||
if (proxyUrl) {
|
if (proxyUrl) {
|
||||||
agent = new ProxyAgent(proxyUrl);
|
agents[agentType] = new ProxyAgent(proxyUrl);
|
||||||
|
} else {
|
||||||
|
agents[agentType] = new Agent();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
const agent = agents[agentType];
|
||||||
|
|
||||||
const fetchOptions = {
|
const fetchOptions = {
|
||||||
method: options.type,
|
method: options.type,
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
|
|
||||||
const ourNumber = textsecure.storage.user.getNumber();
|
const ourNumber = textsecure.storage.user.getNumber();
|
||||||
const { wrap, sendOptions } = ConversationController.prepareForSend(
|
const { wrap, sendOptions } = ConversationController.prepareForSend(
|
||||||
ourNumber
|
ourNumber,
|
||||||
|
{ syncMessage: true }
|
||||||
);
|
);
|
||||||
window.log.info('SyncRequest created. Sending contact sync message...');
|
window.log.info('SyncRequest created. Sending contact sync message...');
|
||||||
wrap(sender.sendRequestContactSyncMessage(sendOptions))
|
wrap(sender.sendRequestContactSyncMessage(sendOptions))
|
||||||
|
|
|
@ -244,7 +244,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "js/background.js",
|
"path": "js/background.js",
|
||||||
"line": " wrap(",
|
"line": " wrap(",
|
||||||
"lineNumber": 726,
|
"lineNumber": 727,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2018-10-18T22:23:00.485Z"
|
"updated": "2018-10-18T22:23:00.485Z"
|
||||||
},
|
},
|
||||||
|
@ -252,7 +252,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "js/background.js",
|
"path": "js/background.js",
|
||||||
"line": " await wrap(",
|
"line": " await wrap(",
|
||||||
"lineNumber": 1227,
|
"lineNumber": 1228,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2018-10-26T22:43:23.229Z"
|
"updated": "2018-10-26T22:43:23.229Z"
|
||||||
},
|
},
|
||||||
|
@ -260,7 +260,7 @@
|
||||||
"rule": "jQuery-load(",
|
"rule": "jQuery-load(",
|
||||||
"path": "js/conversation_controller.js",
|
"path": "js/conversation_controller.js",
|
||||||
"line": " async load() {",
|
"line": " async load() {",
|
||||||
"lineNumber": 208,
|
"lineNumber": 210,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2018-10-02T21:00:44.007Z"
|
"updated": "2018-10-02T21:00:44.007Z"
|
||||||
},
|
},
|
||||||
|
@ -268,7 +268,7 @@
|
||||||
"rule": "jQuery-load(",
|
"rule": "jQuery-load(",
|
||||||
"path": "js/conversation_controller.js",
|
"path": "js/conversation_controller.js",
|
||||||
"line": " this._initialPromise = load();",
|
"line": " this._initialPromise = load();",
|
||||||
"lineNumber": 237,
|
"lineNumber": 239,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2018-10-02T21:00:44.007Z"
|
"updated": "2018-10-02T21:00:44.007Z"
|
||||||
},
|
},
|
||||||
|
@ -311,7 +311,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "js/models/messages.js",
|
"path": "js/models/messages.js",
|
||||||
"line": " return wrap(",
|
"line": " return wrap(",
|
||||||
"lineNumber": 993,
|
"lineNumber": 994,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2018-10-05T23:12:28.961Z"
|
"updated": "2018-10-05T23:12:28.961Z"
|
||||||
},
|
},
|
||||||
|
@ -383,7 +383,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "js/modules/startup.js",
|
"path": "js/modules/startup.js",
|
||||||
"line": " await wrap(sendRequestConfigurationSyncMessage(sendOptions));",
|
"line": " await wrap(sendRequestConfigurationSyncMessage(sendOptions));",
|
||||||
"lineNumber": 50,
|
"lineNumber": 52,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2018-10-05T23:12:28.961Z"
|
"updated": "2018-10-05T23:12:28.961Z"
|
||||||
},
|
},
|
||||||
|
@ -2331,7 +2331,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "libtextsecure/sync_request.js",
|
"path": "libtextsecure/sync_request.js",
|
||||||
"line": " wrap(sender.sendRequestContactSyncMessage(sendOptions))",
|
"line": " wrap(sender.sendRequestContactSyncMessage(sendOptions))",
|
||||||
"lineNumber": 31,
|
"lineNumber": 32,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2018-10-05T23:12:28.961Z"
|
"updated": "2018-10-05T23:12:28.961Z"
|
||||||
},
|
},
|
||||||
|
@ -2339,7 +2339,7 @@
|
||||||
"rule": "jQuery-wrap(",
|
"rule": "jQuery-wrap(",
|
||||||
"path": "libtextsecure/sync_request.js",
|
"path": "libtextsecure/sync_request.js",
|
||||||
"line": " return wrap(sender.sendRequestGroupSyncMessage(sendOptions));",
|
"line": " return wrap(sender.sendRequestGroupSyncMessage(sendOptions));",
|
||||||
"lineNumber": 34,
|
"lineNumber": 35,
|
||||||
"reasonCategory": "falseMatch",
|
"reasonCategory": "falseMatch",
|
||||||
"updated": "2018-10-05T23:12:28.961Z"
|
"updated": "2018-10-05T23:12:28.961Z"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue