2020-03-31 20:03:38 +00:00
|
|
|
// Captures the globals put in place by preload.js, background.js and others
|
|
|
|
|
2020-04-13 17:37:29 +00:00
|
|
|
import {
|
|
|
|
LibSignalType,
|
|
|
|
SignalProtocolAddressClass,
|
|
|
|
StorageType,
|
|
|
|
} from './libsignal.d';
|
|
|
|
import { TextSecureType } from './textsecure.d';
|
|
|
|
import { WebAPIConnectType } from './textsecure/WebAPI';
|
|
|
|
import * as Crypto from './Crypto';
|
|
|
|
|
2020-03-31 20:03:38 +00:00
|
|
|
declare global {
|
|
|
|
interface Window {
|
|
|
|
dcodeIO: DCodeIOType;
|
|
|
|
getExpiration: () => string;
|
|
|
|
getEnvironment: () => string;
|
|
|
|
getSocketStatus: () => number;
|
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-04-01 18:59:11 +00:00
|
|
|
restart: () => void;
|
2020-03-31 20:03:38 +00:00
|
|
|
storage: {
|
|
|
|
put: (key: string, value: any) => void;
|
|
|
|
remove: (key: string) => void;
|
|
|
|
get: (key: string) => any;
|
|
|
|
};
|
|
|
|
textsecure: TextSecureType;
|
|
|
|
|
2020-04-13 17:37:29 +00:00
|
|
|
Signal: {
|
|
|
|
Crypto: typeof Crypto;
|
|
|
|
Metadata: {
|
|
|
|
SecretSessionCipher: typeof SecretSessionCipherClass;
|
|
|
|
createCertificateValidator: (
|
|
|
|
trustRoot: ArrayBuffer
|
|
|
|
) => CertificateValidatorType;
|
|
|
|
};
|
|
|
|
};
|
2020-03-31 20:03:38 +00:00
|
|
|
ConversationController: ConversationControllerType;
|
2020-04-13 17:37:29 +00:00
|
|
|
WebAPI: WebAPIConnectType;
|
2020-03-31 20:03:38 +00:00
|
|
|
Whisper: WhisperType;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-13 17:37:29 +00:00
|
|
|
export type ConversationType = {
|
|
|
|
updateE164: (e164?: string) => void;
|
|
|
|
updateUuid: (uuid?: string) => void;
|
|
|
|
id: string;
|
|
|
|
};
|
|
|
|
|
2020-03-31 20:03:38 +00:00
|
|
|
export type ConversationControllerType = {
|
2020-04-13 17:37:29 +00:00
|
|
|
getOrCreateAndWait: (
|
|
|
|
identifier: string,
|
|
|
|
type: 'private' | 'group'
|
|
|
|
) => Promise<ConversationType>;
|
2020-04-01 18:59:11 +00:00
|
|
|
getConversationId: (identifier: string) => string | null;
|
2020-03-31 20:03:38 +00:00
|
|
|
prepareForSend: (
|
|
|
|
id: string,
|
|
|
|
options: Object
|
|
|
|
) => {
|
|
|
|
wrap: (promise: Promise<any>) => Promise<void>;
|
|
|
|
sendOptions: Object;
|
|
|
|
};
|
2020-04-13 17:37:29 +00:00
|
|
|
get: (
|
|
|
|
identifier: string
|
|
|
|
) => null | {
|
|
|
|
get: (key: string) => any;
|
|
|
|
};
|
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;
|
|
|
|
slice: (start: number, end?: number) => ByteBufferClass;
|
|
|
|
append: (data: ArrayBuffer) => void;
|
|
|
|
limit: number;
|
|
|
|
offset: 0;
|
|
|
|
readVarint32: () => number;
|
|
|
|
skip: (length: number) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export type LoggerType = (...args: Array<any>) => void;
|
2020-03-31 20:03:38 +00:00
|
|
|
|
|
|
|
export type WhisperType = {
|
|
|
|
events: {
|
|
|
|
trigger: (name: string, param1: any, param2: any) => void;
|
|
|
|
};
|
2020-04-01 18:59:11 +00:00
|
|
|
Database: {
|
|
|
|
open: () => Promise<IDBDatabase>;
|
|
|
|
handleDOMException: (
|
|
|
|
context: string,
|
|
|
|
error: DOMException | null,
|
|
|
|
reject: Function
|
|
|
|
) => void;
|
|
|
|
};
|
2020-03-31 20:03:38 +00:00
|
|
|
};
|