"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ts/textsecure/OutgoingMessage.ts" between
Signal-Desktop-1.35.2.tar.gz and Signal-Desktop-1.36.1.tar.gz

About: Signal-Desktop is a cross-platform encrypted messaging service (also available for mobile devices).

OutgoingMessage.ts  (Signal-Desktop-1.35.2):OutgoingMessage.ts  (Signal-Desktop-1.36.1)
// tslint:disable no-default-export // tslint:disable no-default-export
import { reject } from 'lodash'; import { reject } from 'lodash';
import { ServerKeysType, WebAPIType } from './WebAPI'; import { ServerKeysType, WebAPIType } from './WebAPI';
import { isEnabled as isRemoteFlagEnabled } from '../RemoteConfig';
import { SignalProtocolAddressClass } from '../libsignal.d'; import { SignalProtocolAddressClass } from '../libsignal.d';
import { ContentClass, DataMessageClass } from '../textsecure.d'; import { ContentClass, DataMessageClass } from '../textsecure.d';
import { import {
CallbackResultType, CallbackResultType,
SendMetadataType, SendMetadataType,
SendOptionsType, SendOptionsType,
} from './SendMessage'; } from './SendMessage';
import { import {
OutgoingIdentityKeyError, OutgoingIdentityKeyError,
OutgoingMessageError, OutgoingMessageError,
SendMessageNetworkError, SendMessageNetworkError,
UnregisteredUserError, UnregisteredUserError,
} from './Errors'; } from './Errors';
import { isValidNumber } from '../types/PhoneNumber';
type OutgoingMessageOptionsType = SendOptionsType & { type OutgoingMessageOptionsType = SendOptionsType & {
online?: boolean; online?: boolean;
}; };
export default class OutgoingMessage { export default class OutgoingMessage {
server: WebAPIType; server: WebAPIType;
timestamp: number; timestamp: number;
identifiers: Array<string>; identifiers: Array<string>;
message: ContentClass; message: ContentClass;
callback: (result: CallbackResultType) => void; callback: (result: CallbackResultType) => void;
silent?: boolean; silent?: boolean;
plaintext?: Uint8Array; plaintext?: Uint8Array;
identifiersCompleted: number; identifiersCompleted: number;
errors: Array<any>; errors: Array<any>;
successfulIdentifiers: Array<any>; successfulIdentifiers: Array<any>;
failoverIdentifiers: Array<any>; failoverIdentifiers: Array<any>;
unidentifiedDeliveries: Array<any>; unidentifiedDeliveries: Array<any>;
discoveredIdentifierPairs: Array<{
e164: string;
uuid: string;
}>;
sendMetadata?: SendMetadataType; sendMetadata?: SendMetadataType;
senderCertificate?: ArrayBuffer; senderCertificate?: ArrayBuffer;
online?: boolean; online?: boolean;
constructor( constructor(
server: WebAPIType, server: WebAPIType,
timestamp: number, timestamp: number,
identifiers: Array<string>, identifiers: Array<string>,
message: ContentClass | DataMessageClass, message: ContentClass | DataMessageClass,
skipping to change at line 71 skipping to change at line 77
this.timestamp = timestamp; this.timestamp = timestamp;
this.identifiers = identifiers; this.identifiers = identifiers;
this.callback = callback; this.callback = callback;
this.silent = silent; this.silent = silent;
this.identifiersCompleted = 0; this.identifiersCompleted = 0;
this.errors = []; this.errors = [];
this.successfulIdentifiers = []; this.successfulIdentifiers = [];
this.failoverIdentifiers = []; this.failoverIdentifiers = [];
this.unidentifiedDeliveries = []; this.unidentifiedDeliveries = [];
this.discoveredIdentifierPairs = [];
const { sendMetadata, senderCertificate, online } = options || ({} as any); const { sendMetadata, senderCertificate, online } = options || ({} as any);
this.sendMetadata = sendMetadata; this.sendMetadata = sendMetadata;
this.senderCertificate = senderCertificate; this.senderCertificate = senderCertificate;
this.online = online; this.online = online;
} }
numberCompleted() { numberCompleted() {
this.identifiersCompleted += 1; this.identifiersCompleted += 1;
if (this.identifiersCompleted >= this.identifiers.length) { if (this.identifiersCompleted >= this.identifiers.length) {
this.callback({ this.callback({
successfulIdentifiers: this.successfulIdentifiers, successfulIdentifiers: this.successfulIdentifiers,
failoverIdentifiers: this.failoverIdentifiers, failoverIdentifiers: this.failoverIdentifiers,
errors: this.errors, errors: this.errors,
unidentifiedDeliveries: this.unidentifiedDeliveries, unidentifiedDeliveries: this.unidentifiedDeliveries,
discoveredIdentifierPairs: this.discoveredIdentifierPairs,
}); });
} }
} }
registerError(identifier: string, reason: string, error?: Error) { registerError(identifier: string, reason: string, error?: Error) {
if (!error || (error.name === 'HTTPError' && error.code !== 404)) { if (!error || (error.name === 'HTTPError' && error.code !== 404)) {
// tslint:disable-next-line no-parameter-reassignment // tslint:disable-next-line no-parameter-reassignment
error = new OutgoingMessageError( error = new OutgoingMessageError(
identifier, identifier,
this.message.toArrayBuffer(), this.message.toArrayBuffer(),
this.timestamp, this.timestamp,
skipping to change at line 567 skipping to change at line 575
// tslint:disable-next-line forin no-for-in no-for-in-array // tslint:disable-next-line forin no-for-in no-for-in-array
for (const j in deviceIdsToRemove) { for (const j in deviceIdsToRemove) {
promise = promise.then(async () => { promise = promise.then(async () => {
const encodedAddress = `${identifier}.${deviceIdsToRemove[j]}`; const encodedAddress = `${identifier}.${deviceIdsToRemove[j]}`;
return window.textsecure.storage.protocol.removeSession(encodedAddress); return window.textsecure.storage.protocol.removeSession(encodedAddress);
}); });
} }
return promise; return promise;
} }
async sendToIdentifier(identifier: string) { async sendToIdentifier(providedIdentifier: string) {
let identifier = providedIdentifier;
try { try {
if (isRemoteFlagEnabled('desktop.cds')) {
if (window.isValidGuid(identifier)) {
// We're good!
} else if (isValidNumber(identifier)) {
if (!window.textsecure.messaging) {
throw new Error(
'sendToIdentifier: window.textsecure.messaging is not available!'
);
}
const lookup = await window.textsecure.messaging.getUuidsForE164s([
identifier,
]);
const uuid = lookup[identifier];
if (uuid) {
this.discoveredIdentifierPairs.push({
uuid,
e164: identifier,
});
identifier = uuid;
} else {
throw new UnregisteredUserError(
identifier,
new Error('User is not registered')
);
}
} else {
throw new Error(
`sendToIdentifier: identifier ${identifier} was neither a UUID or E1
64`
);
}
}
const updateDevices = await this.getStaleDeviceIdsForIdentifier( const updateDevices = await this.getStaleDeviceIdsForIdentifier(
identifier identifier
); );
await this.getKeysForIdentifier(identifier, updateDevices); await this.getKeysForIdentifier(identifier, updateDevices);
await this.reloadDevicesAndSend(identifier, true)(); await this.reloadDevicesAndSend(identifier, true)();
} catch (error) { } catch (error) {
if (error.message === 'Identity key changed') { if (error.message === 'Identity key changed') {
const newError = new OutgoingIdentityKeyError( const newError = new OutgoingIdentityKeyError(
identifier, identifier,
error.originalMessage, error.originalMessage,
error.timestamp, error.timestamp,
error.identityKey error.identityKey
); );
this.registerError(identifier, 'Identity key changed', newError); this.registerError(identifier, 'Identity key changed', newError);
} else { } else {
this.registerError( this.registerError(
identifier, identifier,
`Failed to retrieve new device keys for number ${identifier}`, `Failed to retrieve new device keys for identifier ${identifier}`,
error error
); );
} }
} }
} }
} }
 End of changes. 8 change blocks. 
2 lines changed or deleted 44 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)