Clean up more imports

This commit is contained in:
Maxim Shishmarev 2020-07-01 12:13:01 +10:00
parent 6295e4206d
commit e2b5b6654b
7 changed files with 33 additions and 28 deletions

View file

@ -9,7 +9,8 @@ import * as libsession from '../session';
import { handleSessionRequestMessage } from './sessionHandling';
import { handlePairingAuthorisationMessage } from './multidevice';
import { MediumGroupRequestKeysMessage } from '../session/messages/outgoing';
import { MultiDeviceProtocol } from '../session/protocols';
import { MultiDeviceProtocol, SessionProtocol } from '../session/protocols';
import { PubKey } from '../session/types';
import { handleSyncMessage } from './syncMessages';
import { onError } from './errors';
@ -178,9 +179,9 @@ async function decryptUnidentifiedSender(
}
// We might have substituted the type based on decrypted content
if (type === textsecure.protobuf.Envelope.Type.SESSION_REQUEST) {
if (type === SignalService.Envelope.Type.SESSION_REQUEST) {
// eslint-disable-next-line no-param-reassign
envelope.type = textsecure.protobuf.Envelope.Type.SESSION_REQUEST;
envelope.type = SignalService.Envelope.Type.SESSION_REQUEST;
}
if (isBlocked(sender.getName())) {
@ -216,12 +217,12 @@ async function doDecrypt(
);
switch (envelope.type) {
case textsecure.protobuf.Envelope.Type.CIPHERTEXT:
case SignalService.Envelope.Type.CIPHERTEXT:
window.log.info('message from', getEnvelopeId(envelope));
return lokiSessionCipher.decryptWhisperMessage(ciphertext).then(unpad);
case textsecure.protobuf.Envelope.Type.MEDIUM_GROUP_CIPHERTEXT:
case SignalService.Envelope.Type.MEDIUM_GROUP_CIPHERTEXT:
return decryptForMediumGroup(envelope, ciphertext);
case textsecure.protobuf.Envelope.Type.SESSION_REQUEST: {
case SignalService.Envelope.Type.SESSION_REQUEST: {
window.log.info('session-request message from ', envelope.source);
const fallBackSessionCipher = new libloki.crypto.FallBackSessionCipher(
@ -232,14 +233,14 @@ async function doDecrypt(
.decrypt(ciphertext.toArrayBuffer())
.then(unpad);
}
case textsecure.protobuf.Envelope.Type.PREKEY_BUNDLE:
case SignalService.Envelope.Type.PREKEY_BUNDLE:
window.log.info('prekey message from', getEnvelopeId(envelope));
return decryptPreKeyWhisperMessage(
ciphertext,
lokiSessionCipher,
address
);
case textsecure.protobuf.Envelope.Type.UNIDENTIFIED_SENDER: {
case SignalService.Envelope.Type.UNIDENTIFIED_SENDER: {
return decryptUnidentifiedSender(envelope, ciphertext.toArrayBuffer());
}
default:
@ -291,7 +292,7 @@ async function decrypt(envelope: EnvelopePlus, ciphertext: any): Promise<any> {
};
const requestKeysMessage = new MediumGroupRequestKeysMessage(params);
const senderPubKey = new libsession.Types.PubKey(senderIdentity);
const senderPubKey = new PubKey(senderIdentity);
// tslint:disable-next-line no-floating-promises
libsession.getMessageQueue().send(senderPubKey, requestKeysMessage);
@ -337,16 +338,16 @@ export async function innerHandleContentMessage(
const content = textsecure.protobuf.Content.decode(plaintext);
const { SESSION_REQUEST } = textsecure.protobuf.Envelope.Type;
const { SESSION_REQUEST } = SignalService.Envelope.Type;
await ConversationController.getOrCreateAndWait(envelope.source, 'private');
if (envelope.type === SESSION_REQUEST) {
await handleSessionRequestMessage(envelope, content);
} else {
const device = new libsession.Types.PubKey(envelope.source);
const device = new PubKey(envelope.source);
await libsession.Protocols.SessionProtocol.onSessionEstablished(device);
await SessionProtocol.onSessionEstablished(device);
await libsession.getMessageQueue().processPending(device);
}
@ -492,7 +493,7 @@ async function handleTypingMessage(
// A sender here could be referring to a group.
// Groups don't have primary devices so we need to take that into consideration.
const user = libsession.Types.PubKey.from(source);
const user = PubKey.from(source);
const primaryDevice = user
? await MultiDeviceProtocol.getPrimaryDevice(user)
: null;

View file

@ -19,7 +19,7 @@ export async function updateProfile(
profile: SignalService.DataMessage.ILokiProfile,
profileKey: any
) {
const { dcodeIO, textsecure, Signal, Lodash: _ } = window;
const { dcodeIO, textsecure, Signal } = window;
// Retain old values unless changed:
const newProfile = conversation.get('profile') || {};

View file

@ -3,13 +3,13 @@ import { EnvelopePlus } from './types';
import * as Data from '../../js/modules/data';
import * as libsession from '../session';
import { SignalService } from '../protobuf';
import { updateProfile } from './receiver';
import { onVerified } from './syncMessages';
import { StringUtils } from '../session/utils';
import { MultiDeviceProtocol, SessionProtocol } from '../session/protocols';
import { PubKey } from '../session/types';
async function unpairingRequestIsLegit(source: string, ourPubKey: string) {
const { textsecure, storage, lokiFileServerAPI } = window;
@ -358,7 +358,7 @@ async function onContactReceived(details: any) {
deviceConversations.forEach(device => {
// tslint:disable-next-line: no-floating-promises
SessionProtocol.sendSessionRequestIfNeeded(
new libsession.Types.PubKey(device.id)
new PubKey(device.id)
);
});

View file

@ -6,6 +6,7 @@ import { MessageModel } from '../../js/models/messages';
import { PrimaryPubKey, PubKey } from '../session/types';
import _ from 'lodash';
import { MultiDeviceProtocol } from '../session/protocols';
import { SignalService } from '../protobuf';
async function handleGroups(
conversation: ConversationModel,
@ -13,7 +14,7 @@ async function handleGroups(
source: any
): Promise<any> {
const textsecure = window.textsecure;
const GROUP_TYPES = textsecure.protobuf.GroupContext.Type;
const GROUP_TYPES = SignalService.GroupContext.Type;
// TODO: this should be primary device id!
const ourNumber = textsecure.storage.user.getNumber();

View file

@ -55,7 +55,7 @@ async function handleEnvelope(envelope: EnvelopePlus) {
// return Promise.resolve();
// }
if (envelope.type === textsecure.protobuf.Envelope.Type.RECEIPT) {
if (envelope.type === SignalService.Envelope.Type.RECEIPT) {
return onDeliveryReceipt(envelope.source, envelope.timestamp);
}
@ -128,7 +128,7 @@ async function handleRequestDetail(
): Promise<void> {
const { textsecure } = window;
const envelope = textsecure.protobuf.Envelope.decode(plaintext);
const envelope : any = SignalService.Envelope.decode(plaintext);
// After this point, decoding errors are not the server's
// fault, and we should handle them gracefully and tell the

View file

@ -2,6 +2,9 @@ import { EnvelopePlus } from './types';
import { SignalService } from '../protobuf';
import * as libsession from './../session';
import { toNumber } from 'lodash';
import { PubKey } from '../session/types';
import { SessionEstablishedMessage } from '../session/messages/outgoing';
import { SessionProtocol } from '../session/protocols'
export async function handleEndSession(number: string): Promise<void> {
window.log.info('got end session');
@ -36,8 +39,8 @@ export async function handleSessionRequestMessage(
return;
}
const shouldProcessSessionRequest = await libsession.Protocols.SessionProtocol.shouldProcessSessionRequest(
new libsession.Types.PubKey(envelope.source),
const shouldProcessSessionRequest = await SessionProtocol.shouldProcessSessionRequest(
new PubKey(envelope.source),
toNumber(envelope.timestamp)
);
@ -99,15 +102,15 @@ export async function handleSessionRequestMessage(
);
await builder.processPreKey(device);
await libsession.Protocols.SessionProtocol.onSessionRequestProcessed(
new libsession.Types.PubKey(envelope.source)
await SessionProtocol.onSessionRequestProcessed(
new PubKey(envelope.source)
);
log.debug('sending session established to', envelope.source);
// We don't need to await the call below because we just want to send it off
const user = new libsession.Types.PubKey(envelope.source);
const user = new PubKey(envelope.source);
const sessionEstablished = new libsession.Messages.Outgoing.SessionEstablishedMessage(
const sessionEstablished = new SessionEstablishedMessage(
{ timestamp: Date.now() }
);
await libsession.getMessageQueue().send(user, sessionEstablished);

View file

@ -237,13 +237,13 @@ export async function onVerified(ev: any) {
}
switch (ev.verified.state) {
case textsecure.protobuf.Verified.State.DEFAULT:
case SignalService.Verified.State.DEFAULT:
state = 'DEFAULT';
break;
case textsecure.protobuf.Verified.State.VERIFIED:
case SignalService.Verified.State.VERIFIED:
state = 'VERIFIED';
break;
case textsecure.protobuf.Verified.State.UNVERIFIED:
case SignalService.Verified.State.UNVERIFIED:
state = 'UNVERIFIED';
break;
default: