signal-desktop/ts/window.d.ts

228 lines
6.6 KiB
TypeScript
Raw Normal View History

// Captures the globals put in place by preload.js, background.js and others
import * as Backbone from 'backbone';
import * as Underscore from 'underscore';
2020-06-04 18:16:19 +00:00
import { Ref } from 'react';
import {
ConversationModelCollectionType,
ConversationModelType,
MessageModelCollectionType,
MessageModelType,
} from './model-types.d';
import {
LibSignalType,
SignalProtocolAddressClass,
StorageType,
} from './libsignal.d';
import { ContactRecordIdentityState, TextSecureType } from './textsecure.d';
import { WebAPIConnectType } from './textsecure/WebAPI';
2020-09-04 18:27:12 +00:00
import { CallingClass } from './services/calling';
import * as Crypto from './Crypto';
import * as RemoteConfig from './RemoteConfig';
import { LocalizerType } from './types/Util';
2020-09-04 18:27:12 +00:00
import { CallHistoryDetailsType } from './types/Calling';
import { ColorType } from './types/Colors';
import { ConversationController } from './ConversationController';
import { ReduxActions } from './state/types';
2020-06-04 18:16:19 +00:00
import { SendOptionsType } from './textsecure/SendMessage';
2020-09-09 02:25:05 +00:00
import AccountManager from './textsecure/AccountManager';
import Data from './sql/Client';
2020-09-04 01:25:19 +00:00
export { Long } from 'long';
type TaskResultType = any;
declare global {
interface Window {
dcodeIO: DCodeIOType;
2020-09-09 02:25:05 +00:00
getAccountManager: () => AccountManager | undefined;
2020-06-04 18:16:19 +00:00
getAlwaysRelayCalls: () => Promise<boolean>;
getCallRingtoneNotification: () => Promise<boolean>;
getCallSystemNotification: () => Promise<boolean>;
getConversations: () => ConversationModelCollectionType;
getCountMutedConversations: () => Promise<boolean>;
getEnvironment: () => string;
getExpiration: () => string;
getGuid: () => string;
getInboxCollection: () => ConversationModelCollectionType;
getIncomingCallNotification: () => Promise<boolean>;
2020-06-04 18:16:19 +00:00
getMediaCameraPermissions: () => Promise<boolean>;
getMediaPermissions: () => Promise<boolean>;
2020-09-09 02:25:05 +00:00
getServerPublicParams: () => string;
getSocketStatus: () => number;
getTitle: () => string;
2020-09-09 02:25:05 +00:00
waitForEmptyEventQueue: () => Promise<void>;
getVersion: () => string;
2020-06-04 18:16:19 +00:00
showCallingPermissionsPopup: (forCamera: boolean) => Promise<void>;
i18n: LocalizerType;
isValidGuid: (maybeGuid: string) => boolean;
libphonenumber: {
util: {
getRegionCodeForNumber: (number: string) => string;
};
};
libsignal: LibSignalType;
log: {
info: LoggerType;
warn: LoggerType;
error: LoggerType;
};
normalizeUuids: (obj: any, paths: Array<string>, context: string) => any;
2020-06-04 18:16:19 +00:00
platform: string;
reduxActions: ReduxActions;
restart: () => void;
2020-06-04 18:16:19 +00:00
showWindow: () => void;
setBadgeCount: (count: number) => void;
storage: {
put: (key: string, value: any) => void;
remove: (key: string) => Promise<void>;
2020-05-27 21:37:06 +00:00
get: <T = any>(key: string) => T | undefined;
addBlockedNumber: (number: string) => void;
isBlocked: (number: string) => boolean;
removeBlockedNumber: (number: string) => void;
};
textsecure: TextSecureType;
updateTrayIcon: (count: number) => void;
Backbone: typeof Backbone;
Signal: {
Crypto: typeof Crypto;
Data: typeof Data;
Metadata: {
SecretSessionCipher: typeof SecretSessionCipherClass;
createCertificateValidator: (
trustRoot: ArrayBuffer
) => CertificateValidatorType;
};
RemoteConfig: typeof RemoteConfig;
2020-06-04 18:16:19 +00:00
Services: {
calling: CallingClass;
};
2020-09-09 02:25:05 +00:00
Migrations: {
deleteAttachmentData: (path: string) => Promise<void>;
writeNewAttachmentData: (data: ArrayBuffer) => Promise<string>;
};
Types: {
Message: {
CURRENT_SCHEMA_VERSION: number;
};
};
};
ConversationController: ConversationController;
2020-09-09 02:25:05 +00:00
MessageController: MessageControllerType;
WebAPI: WebAPIConnectType;
Whisper: WhisperType;
2020-06-04 18:16:19 +00:00
// Flags
CALLING: boolean;
2020-09-09 02:25:05 +00:00
GV2: boolean;
}
2020-05-27 21:37:06 +00:00
interface Error {
cause?: Event;
}
}
export type DCodeIOType = {
2020-09-04 01:25:19 +00:00
ByteBuffer: typeof ByteBufferClass & {
BIG_ENDIAN: number;
LITTLE_ENDIAN: number;
Long: DCodeIOType['Long'];
};
Long: Long & {
fromBits: (low: number, high: number, unsigned: boolean) => number;
2020-09-04 01:25:19 +00:00
fromString: (str: string) => Long;
};
};
2020-09-09 02:25:05 +00:00
type MessageControllerType = {
register: (id: string, model: MessageModelType) => MessageModelType;
};
export class CertificateValidatorType {
validate: (cerficate: any, certificateTime: number) => Promise<void>;
}
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>;
}
export class ByteBufferClass {
2020-09-04 01:25:19 +00:00
constructor(value?: any, littleEndian?: number);
static wrap: (
value: any,
encoding?: string,
littleEndian?: number
) => ByteBufferClass;
buffer: ArrayBuffer;
toString: (type: string) => string;
toArrayBuffer: () => ArrayBuffer;
toBinary: () => string;
slice: (start: number, end?: number) => ByteBufferClass;
append: (data: ArrayBuffer) => void;
limit: number;
offset: 0;
2020-09-04 01:25:19 +00:00
readInt: (offset: number) => number;
readLong: (offset: number) => Long;
readShort: (offset: number) => number;
readVarint32: () => number;
2020-09-04 01:25:19 +00:00
writeLong: (l: Long) => void;
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>);
}
export type LoggerType = (...args: Array<any>) => void;
export type WhisperType = {
events: {
on: (name: string, callback: (param1: any, param2?: any) => void) => void;
trigger: (name: string, param1: any, param2?: any) => void;
};
Database: {
open: () => Promise<IDBDatabase>;
handleDOMException: (
context: string,
error: DOMException | null,
reject: Function
) => void;
};
ConversationCollection: typeof ConversationModelCollectionType;
Conversation: typeof ConversationModelType;
MessageCollection: typeof MessageModelCollectionType;
Message: typeof MessageModelType;
};