Fix attachments

pull/1209/head
Mikunj 5 years ago
parent 58e71243a4
commit 8d11660b13

@ -0,0 +1,16 @@
export interface LibTextsecureCryptoInterface {
encryptAttachment(
plaintext: ArrayBuffer,
keys: ArrayBuffer,
iv: ArrayBuffer
): Promise<{
digest: ArrayBuffer;
ciphertext: ArrayBuffer;
}>;
decryptAttachment(
encryptedBin: ArrayBuffer,
keys: ArrayBuffer,
theirDigest: ArrayBuffer
): Promise<ArrayBuffer>;
decryptProfile(data: ArrayBuffer, key: ArrayBuffer): Promise<ArrayBuffer>;
}

@ -0,0 +1,26 @@
import { LibTextsecureCryptoInterface } from './crypto';
export interface LibTextsecure {
crypto: LibTextsecureCryptoInterface;
storage: any;
SendMessageNetworkError: any;
IncomingIdentityKeyError: any;
OutgoingIdentityKeyError: any;
ReplayableError: any;
OutgoingMessageError: any;
MessageError: any;
SignedPreKeyRotationError: any;
PoWError: any;
EmptySwarmError: any;
SeedNodeError: any;
DNSResolutionError: any;
HTTPError: any;
NotFoundError: any;
WrongSwarmError: any;
WrongDifficultyError: any;
TimestampError: any;
PublicChatError: any;
PublicTokenError: any;
SenderKeyMissing: any;
createTaskWithTimeout(task: any, id: any, options?: any): Promise<any>;
}

@ -580,6 +580,7 @@
display: inline-block; display: inline-block;
margin-left: 6px; margin-left: 6px;
margin-bottom: 2px; margin-bottom: 2px;
margin-left: 5px;
} }
.module-message__metadata__status-icon--sending { .module-message__metadata__status-icon--sending {

@ -13,6 +13,7 @@ import { handleMediumGroupUpdate } from './mediumGroups';
import { handleUnpairRequest } from './multidevice'; import { handleUnpairRequest } from './multidevice';
import { downloadAttachment } from './attachments'; import { downloadAttachment } from './attachments';
import _ from 'lodash'; import _ from 'lodash';
import { StringUtils } from '../session/utils';
export async function updateProfile( export async function updateProfile(
conversation: any, conversation: any,
@ -81,8 +82,10 @@ function cleanAttachment(attachment: any) {
return { return {
..._.omit(attachment, 'thumbnail'), ..._.omit(attachment, 'thumbnail'),
id: attachment.id.toString(), id: attachment.id.toString(),
key: attachment.key ? attachment.key.toString('base64') : null, key: attachment.key ? StringUtils.decode(attachment.key, 'base64') : null,
digest: attachment.digest ? attachment.digest.toString('base64') : null, digest: attachment.digest
? StringUtils.decode(attachment.digest, 'base64')
: null,
}; };
} }
@ -508,7 +511,7 @@ function createMessage(
} }
function sendDeliveryReceipt(source: string, timestamp: any) { function sendDeliveryReceipt(source: string, timestamp: any) {
// FIXME audric // FIXME audric
// const receiptMessage = new DeliveryReceiptMessage({ // const receiptMessage = new DeliveryReceiptMessage({
// timestamp: Date.now(), // timestamp: Date.now(),
// timestamps: [timestamp], // timestamps: [timestamp],

@ -90,7 +90,7 @@ export class AttachmentUtils {
pointer.key.buffer, pointer.key.buffer,
iv.buffer iv.buffer
); );
pointer.digest = data.digest; pointer.digest = new Uint8Array(data.digest);
attachmentData = data.ciphertext; attachmentData = data.ciphertext;
} }

3
ts/window.d.ts vendored

@ -7,6 +7,7 @@ import { LokiPublicChatFactoryInterface } from '../js/modules/loki_public_chat_a
import { LokiAppDotNetServerInterface } from '../js/modules/loki_app_dot_net_api'; import { LokiAppDotNetServerInterface } from '../js/modules/loki_app_dot_net_api';
import { LokiMessageInterface } from '../js/modules/loki_message_api'; import { LokiMessageInterface } from '../js/modules/loki_message_api';
import { SwarmPolling } from './session/snode_api/swarmPolling'; import { SwarmPolling } from './session/snode_api/swarmPolling';
import { LibTextsecure } from '../libtextsecure';
/* /*
We declare window stuff here instead of global.d.ts because we are importing other declarations. We declare window stuff here instead of global.d.ts because we are importing other declarations.
@ -70,7 +71,7 @@ declare global {
showQRDialog: any; showQRDialog: any;
showSeedDialog: any; showSeedDialog: any;
storage: any; storage: any;
textsecure: any; textsecure: LibTextsecure;
toggleLinkPreview: any; toggleLinkPreview: any;
toggleMediaPermissions: any; toggleMediaPermissions: any;
toggleMenuBar: any; toggleMenuBar: any;

Loading…
Cancel
Save