2020-03-31 20:03:38 +00:00
|
|
|
// Captures the globals put in place by preload.js, background.js and others
|
|
|
|
|
2020-07-10 18:28:49 +00:00
|
|
|
import * as Backbone from 'backbone';
|
|
|
|
import * as Underscore from 'underscore';
|
2020-06-04 18:16:19 +00:00
|
|
|
import { Ref } from 'react';
|
2020-07-10 18:28:49 +00:00
|
|
|
import {
|
|
|
|
ConversationModelCollectionType,
|
|
|
|
ConversationModelType,
|
|
|
|
MessageModelCollectionType,
|
|
|
|
MessageModelType,
|
|
|
|
} from './model-types.d';
|
2020-04-13 17:37:29 +00:00
|
|
|
import {
|
|
|
|
LibSignalType,
|
|
|
|
SignalProtocolAddressClass,
|
|
|
|
StorageType,
|
|
|
|
} from './libsignal.d';
|
2020-07-07 00:56:56 +00:00
|
|
|
import { ContactRecordIdentityState, TextSecureType } from './textsecure.d';
|
2020-04-13 17:37:29 +00:00
|
|
|
import { WebAPIConnectType } from './textsecure/WebAPI';
|
2020-09-04 18:27:12 +00:00
|
|
|
import { CallingClass } from './services/calling';
|
2020-04-13 17:37:29 +00:00
|
|
|
import * as Crypto from './Crypto';
|
2020-08-13 20:53:45 +00:00
|
|
|
import { LocalizerType } from './types/Util';
|
2020-09-04 18:27:12 +00:00
|
|
|
import { CallHistoryDetailsType } from './types/Calling';
|
2020-08-13 20:53:45 +00:00
|
|
|
import { ColorType } from './types/Colors';
|
2020-07-10 18:28:49 +00:00
|
|
|
import { ConversationController } from './ConversationController';
|
2020-06-04 18:16:19 +00:00
|
|
|
import { SendOptionsType } from './textsecure/SendMessage';
|
2020-07-07 00:56:56 +00:00
|
|
|
import Data from './sql/Client';
|
2020-04-13 17:37:29 +00:00
|
|
|
|
2020-06-26 00:08:58 +00:00
|
|
|
type TaskResultType = any;
|
|
|
|
|
2020-03-31 20:03:38 +00:00
|
|
|
declare global {
|
|
|
|
interface Window {
|
|
|
|
dcodeIO: DCodeIOType;
|
2020-06-04 18:16:19 +00:00
|
|
|
getAlwaysRelayCalls: () => Promise<boolean>;
|
|
|
|
getCallRingtoneNotification: () => Promise<boolean>;
|
|
|
|
getCallSystemNotification: () => Promise<boolean>;
|
2020-07-10 18:28:49 +00:00
|
|
|
getConversations: () => ConversationModelCollectionType;
|
|
|
|
getEnvironment: () => string;
|
|
|
|
getExpiration: () => string;
|
|
|
|
getGuid: () => string;
|
|
|
|
getInboxCollection: () => ConversationModelCollectionType;
|
|
|
|
getIncomingCallNotification: () => Promise<boolean>;
|
2020-06-04 18:16:19 +00:00
|
|
|
getMediaCameraPermissions: () => Promise<boolean>;
|
2020-07-10 18:28:49 +00:00
|
|
|
getMediaPermissions: () => Promise<boolean>;
|
|
|
|
getSocketStatus: () => number;
|
|
|
|
getTitle: () => string;
|
2020-06-04 18:16:19 +00:00
|
|
|
showCallingPermissionsPopup: (forCamera: boolean) => Promise<void>;
|
|
|
|
i18n: LocalizerType;
|
2020-07-10 18:28:49 +00:00
|
|
|
isValidGuid: (maybeGuid: string) => boolean;
|
2020-04-13 17:37:29 +00:00
|
|
|
libphonenumber: {
|
|
|
|
util: {
|
|
|
|
getRegionCodeForNumber: (number: string) => string;
|
|
|
|
};
|
|
|
|
};
|
2020-03-31 20:03:38 +00:00
|
|
|
libsignal: LibSignalType;
|
|
|
|
log: {
|
|
|
|
info: LoggerType;
|
|
|
|
warn: LoggerType;
|
|
|
|
error: LoggerType;
|
|
|
|
};
|
2020-04-13 17:37:29 +00:00
|
|
|
normalizeUuids: (obj: any, paths: Array<string>, context: string) => any;
|
2020-06-04 18:16:19 +00:00
|
|
|
platform: string;
|
2020-04-01 18:59:11 +00:00
|
|
|
restart: () => void;
|
2020-06-04 18:16:19 +00:00
|
|
|
showWindow: () => void;
|
2020-07-10 18:28:49 +00:00
|
|
|
setBadgeCount: (count: number) => void;
|
2020-03-31 20:03:38 +00:00
|
|
|
storage: {
|
|
|
|
put: (key: string, value: any) => void;
|
2020-07-24 23:32:08 +00:00
|
|
|
remove: (key: string) => Promise<void>;
|
2020-05-27 21:37:06 +00:00
|
|
|
get: <T = any>(key: string) => T | undefined;
|
2020-07-07 00:56:56 +00:00
|
|
|
addBlockedNumber: (number: string) => void;
|
|
|
|
isBlocked: (number: string) => boolean;
|
|
|
|
removeBlockedNumber: (number: string) => void;
|
2020-03-31 20:03:38 +00:00
|
|
|
};
|
|
|
|
textsecure: TextSecureType;
|
2020-07-10 18:28:49 +00:00
|
|
|
updateTrayIcon: (count: number) => void;
|
2020-03-31 20:03:38 +00:00
|
|
|
|
2020-07-10 18:28:49 +00:00
|
|
|
Backbone: typeof Backbone;
|
2020-04-13 17:37:29 +00:00
|
|
|
Signal: {
|
|
|
|
Crypto: typeof Crypto;
|
2020-07-07 00:56:56 +00:00
|
|
|
Data: typeof Data;
|
2020-04-13 17:37:29 +00:00
|
|
|
Metadata: {
|
|
|
|
SecretSessionCipher: typeof SecretSessionCipherClass;
|
|
|
|
createCertificateValidator: (
|
|
|
|
trustRoot: ArrayBuffer
|
|
|
|
) => CertificateValidatorType;
|
|
|
|
};
|
2020-06-04 18:16:19 +00:00
|
|
|
Services: {
|
|
|
|
calling: CallingClass;
|
|
|
|
};
|
2020-04-13 17:37:29 +00:00
|
|
|
};
|
2020-07-10 18:28:49 +00:00
|
|
|
ConversationController: ConversationController;
|
2020-04-13 17:37:29 +00:00
|
|
|
WebAPI: WebAPIConnectType;
|
2020-03-31 20:03:38 +00:00
|
|
|
Whisper: WhisperType;
|
2020-06-04 18:16:19 +00:00
|
|
|
|
|
|
|
// Flags
|
|
|
|
CALLING: boolean;
|
2020-03-31 20:03:38 +00:00
|
|
|
}
|
2020-05-27 21:37:06 +00:00
|
|
|
|
|
|
|
interface Error {
|
|
|
|
cause?: Event;
|
|
|
|
}
|
2020-03-31 20:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type DCodeIOType = {
|
2020-04-13 17:37:29 +00:00
|
|
|
ByteBuffer: typeof ByteBufferClass;
|
|
|
|
Long: {
|
|
|
|
fromBits: (low: number, high: number, unsigned: boolean) => number;
|
2020-03-31 20:03:38 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-04-13 17:37:29 +00:00
|
|
|
export class CertificateValidatorType {
|
|
|
|
validate: (cerficate: any, certificateTime: number) => Promise<void>;
|
|
|
|
}
|
2020-03-31 20:03:38 +00:00
|
|
|
|
2020-04-13 17:37:29 +00:00
|
|
|
export class SecretSessionCipherClass {
|
|
|
|
constructor(storage: StorageType);
|
|
|
|
decrypt: (
|
|
|
|
validator: CertificateValidatorType,
|
|
|
|
ciphertext: ArrayBuffer,
|
|
|
|
serverTimestamp: number,
|
|
|
|
me: any
|
|
|
|
) => Promise<{
|
|
|
|
isMe: boolean;
|
|
|
|
sender: SignalProtocolAddressClass;
|
|
|
|
senderUuid: SignalProtocolAddressClass;
|
|
|
|
content: ArrayBuffer;
|
|
|
|
}>;
|
|
|
|
getRemoteRegistrationId: (
|
|
|
|
address: SignalProtocolAddressClass
|
|
|
|
) => Promise<number>;
|
|
|
|
closeOpenSessionForDevice: (
|
|
|
|
address: SignalProtocolAddressClass
|
|
|
|
) => Promise<void>;
|
|
|
|
encrypt: (
|
|
|
|
address: SignalProtocolAddressClass,
|
|
|
|
senderCertificate: any,
|
|
|
|
plaintext: ArrayBuffer | Uint8Array
|
|
|
|
) => Promise<ArrayBuffer>;
|
|
|
|
}
|
2020-03-31 20:03:38 +00:00
|
|
|
|
2020-04-13 17:37:29 +00:00
|
|
|
export class ByteBufferClass {
|
|
|
|
constructor(value?: any, encoding?: string);
|
|
|
|
static wrap: (value: any, type?: string) => ByteBufferClass;
|
|
|
|
toString: (type: string) => string;
|
|
|
|
toArrayBuffer: () => ArrayBuffer;
|
2020-07-07 00:56:56 +00:00
|
|
|
toBinary: () => string;
|
2020-04-13 17:37:29 +00:00
|
|
|
slice: (start: number, end?: number) => ByteBufferClass;
|
|
|
|
append: (data: ArrayBuffer) => void;
|
|
|
|
limit: number;
|
|
|
|
offset: 0;
|
|
|
|
readVarint32: () => number;
|
|
|
|
skip: (length: number) => void;
|
|
|
|
}
|
|
|
|
|
2020-06-04 18:16:19 +00:00
|
|
|
export class GumVideoCapturer {
|
|
|
|
constructor(
|
|
|
|
maxWidth: number,
|
|
|
|
maxHeight: number,
|
|
|
|
maxFramerate: number,
|
|
|
|
localPreview: Ref<HTMLVideoElement>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export class CanvasVideoRenderer {
|
|
|
|
constructor(canvas: Ref<HTMLCanvasElement>);
|
|
|
|
}
|
|
|
|
|
2020-04-13 17:37:29 +00:00
|
|
|
export type LoggerType = (...args: Array<any>) => void;
|
2020-03-31 20:03:38 +00:00
|
|
|
|
|
|
|
export type WhisperType = {
|
|
|
|
events: {
|
2020-07-10 18:28:49 +00:00
|
|
|
trigger: (name: string, param1: any, param2?: any) => void;
|
2020-03-31 20:03:38 +00:00
|
|
|
};
|
2020-04-01 18:59:11 +00:00
|
|
|
Database: {
|
|
|
|
open: () => Promise<IDBDatabase>;
|
|
|
|
handleDOMException: (
|
|
|
|
context: string,
|
|
|
|
error: DOMException | null,
|
|
|
|
reject: Function
|
|
|
|
) => void;
|
|
|
|
};
|
2020-07-10 18:28:49 +00:00
|
|
|
ConversationCollection: typeof ConversationModelCollectionType;
|
|
|
|
Conversation: typeof ConversationModelType;
|
|
|
|
MessageCollection: typeof MessageModelCollectionType;
|
|
|
|
Message: typeof MessageModelType;
|
2020-03-31 20:03:38 +00:00
|
|
|
};
|