2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-03-31 20:03:38 +00:00
|
|
|
// Captures the globals put in place by preload.js, background.js and others
|
|
|
|
|
2022-09-06 20:51:34 +00:00
|
|
|
import type { Store } from 'redux';
|
|
|
|
import type * as Backbone from 'backbone';
|
|
|
|
import type PQueue from 'p-queue/dist';
|
|
|
|
import type { assert } from 'chai';
|
|
|
|
import type { PhoneNumber, PhoneNumberFormat } from 'google-libphonenumber';
|
2023-04-10 21:30:33 +00:00
|
|
|
|
2023-10-04 00:12:57 +00:00
|
|
|
import type { ConversationModelCollectionType } from './model-types.d';
|
2022-09-06 20:51:34 +00:00
|
|
|
import type { textsecure } from './textsecure';
|
|
|
|
import type { Storage } from './textsecure/Storage';
|
|
|
|
import type {
|
2021-05-06 00:09:29 +00:00
|
|
|
ChallengeHandler,
|
|
|
|
IPCRequest as IPCChallengeRequest,
|
|
|
|
} from './challenge';
|
2023-01-13 00:24:59 +00:00
|
|
|
import type AccountManager from './textsecure/AccountManager';
|
2022-09-06 20:51:34 +00:00
|
|
|
import type { WebAPIConnectType } from './textsecure/WebAPI';
|
|
|
|
import type { CallingClass } from './services/calling';
|
2022-10-08 00:19:02 +00:00
|
|
|
import type * as StorageService from './services/storage';
|
2022-09-06 20:51:34 +00:00
|
|
|
import type * as Groups from './groups';
|
|
|
|
import type * as Crypto from './Crypto';
|
|
|
|
import type * as Curve from './Curve';
|
|
|
|
import type * as RemoteConfig from './RemoteConfig';
|
2023-04-20 21:23:19 +00:00
|
|
|
import type { OSType } from './util/os/shared';
|
2022-09-06 20:51:34 +00:00
|
|
|
import type { getEnvironment } from './environment';
|
|
|
|
import type { LocalizerType, ThemeType } from './types/Util';
|
2021-12-07 22:41:40 +00:00
|
|
|
import type { Receipt } from './types/Receipt';
|
2022-09-06 20:51:34 +00:00
|
|
|
import type { ConversationController } from './ConversationController';
|
|
|
|
import type { ReduxActions } from './state/types';
|
|
|
|
import type { createApp } from './state/roots/createApp';
|
|
|
|
import type Data from './sql/Client';
|
|
|
|
import type { MessageModel } from './models/messages';
|
|
|
|
import type { ConversationModel } from './models/conversations';
|
2023-04-11 03:54:43 +00:00
|
|
|
import type { BatcherType } from './util/batcher';
|
2022-09-06 20:51:34 +00:00
|
|
|
import type { ConfirmationDialog } from './components/ConfirmationDialog';
|
|
|
|
import type { SignalProtocolStore } from './SignalProtocolStore';
|
|
|
|
import type { SocketStatus } from './types/SocketStatus';
|
|
|
|
import type SyncRequest from './textsecure/SyncRequest';
|
2023-10-04 00:12:57 +00:00
|
|
|
import type { MessageCache } from './services/MessageCache';
|
2022-09-06 20:51:34 +00:00
|
|
|
import type { StateType } from './state/reducer';
|
|
|
|
import type { SystemTraySetting } from './types/SystemTraySetting';
|
|
|
|
import type { Address } from './types/Address';
|
|
|
|
import type { QualifiedAddress } from './types/QualifiedAddress';
|
2023-01-13 00:24:59 +00:00
|
|
|
import type { CIType } from './CI';
|
2022-09-06 20:51:34 +00:00
|
|
|
import type { IPCEventsType } from './util/createIPCEvents';
|
2021-10-07 23:28:47 +00:00
|
|
|
import type { SignalContextType } from './windows/context';
|
2022-06-13 21:39:35 +00:00
|
|
|
import type * as Message2 from './types/Message2';
|
|
|
|
import type { initializeMigrations } from './signal';
|
2023-04-10 21:30:33 +00:00
|
|
|
import type { RetryPlaceholders } from './util/retryPlaceholders';
|
2023-04-20 21:23:19 +00:00
|
|
|
import type { PropsPreloadType as PreferencesPropsType } from './components/Preferences';
|
2023-08-01 16:06:29 +00:00
|
|
|
import type { WindowsNotificationData } from './services/notifications';
|
2020-04-13 17:37:29 +00:00
|
|
|
|
2020-09-04 01:25:19 +00:00
|
|
|
export { Long } from 'long';
|
|
|
|
|
2023-01-13 00:24:59 +00:00
|
|
|
export type IPCType = {
|
|
|
|
addSetupMenuItems: () => void;
|
2023-08-01 16:06:29 +00:00
|
|
|
clearAllWindowsNotifications: () => Promise<void>;
|
2023-01-13 00:24:59 +00:00
|
|
|
closeAbout: () => void;
|
|
|
|
crashReports: {
|
|
|
|
getCount: () => Promise<number>;
|
|
|
|
upload: () => Promise<void>;
|
|
|
|
erase: () => Promise<void>;
|
|
|
|
};
|
|
|
|
drawAttention: () => void;
|
|
|
|
getAutoLaunch: () => Promise<boolean>;
|
2023-11-01 18:03:08 +00:00
|
|
|
getMediaAccessStatus: (
|
|
|
|
mediaType: 'screen' | 'microphone' | 'camera'
|
|
|
|
) => Promise<string | undefined>;
|
2023-01-13 00:24:59 +00:00
|
|
|
getMediaCameraPermissions: () => Promise<boolean>;
|
|
|
|
getMediaPermissions: () => Promise<boolean>;
|
|
|
|
logAppLoadedEvent?: (options: { processedCount?: number }) => void;
|
|
|
|
readyForUpdates: () => void;
|
|
|
|
removeSetupMenuItems: () => unknown;
|
|
|
|
setAutoHideMenuBar: (value: boolean) => void;
|
|
|
|
setAutoLaunch: (value: boolean) => Promise<void>;
|
2023-08-14 23:28:47 +00:00
|
|
|
setBadge: (badge: number | 'marked-unread') => void;
|
2023-01-13 00:24:59 +00:00
|
|
|
setMenuBarVisibility: (value: boolean) => void;
|
|
|
|
showDebugLog: () => void;
|
|
|
|
showPermissionsPopup: (
|
|
|
|
forCalling: boolean,
|
|
|
|
forCamera: boolean
|
|
|
|
) => Promise<void>;
|
|
|
|
showSettings: () => void;
|
|
|
|
showWindow: () => void;
|
2023-08-01 16:06:29 +00:00
|
|
|
showWindowsNotification: (data: WindowsNotificationData) => Promise<void>;
|
2023-01-13 00:24:59 +00:00
|
|
|
shutdown: () => void;
|
|
|
|
titleBarDoubleClick: () => void;
|
|
|
|
updateSystemTraySetting: (value: SystemTraySetting) => void;
|
|
|
|
updateTrayIcon: (count: number) => void;
|
2021-01-04 18:47:14 +00:00
|
|
|
};
|
|
|
|
|
2023-01-19 00:02:03 +00:00
|
|
|
export type FeatureFlagType = {
|
|
|
|
GV2_ENABLE_SINGLE_CHANGE_PROCESSING: boolean;
|
|
|
|
GV2_ENABLE_CHANGE_PROCESSING: boolean;
|
|
|
|
GV2_ENABLE_STATE_PROCESSING: boolean;
|
|
|
|
GV2_ENABLE_PRE_JOIN_FETCH: boolean;
|
|
|
|
GV2_MIGRATION_DISABLE_ADD: boolean;
|
|
|
|
GV2_MIGRATION_DISABLE_INVITE: boolean;
|
|
|
|
};
|
|
|
|
|
2023-04-20 21:23:19 +00:00
|
|
|
type AboutWindowPropsType = {
|
|
|
|
arch: string;
|
2023-03-14 15:55:31 +00:00
|
|
|
environmentText: string;
|
2023-04-20 21:23:19 +00:00
|
|
|
platform: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
type DebugLogWindowPropsType = {
|
|
|
|
downloadLog: (text: string) => unknown;
|
|
|
|
fetchLogs: () => Promise<string>;
|
|
|
|
uploadLogs: (text: string) => Promise<string>;
|
|
|
|
};
|
|
|
|
|
|
|
|
type PermissionsWindowPropsType = {
|
|
|
|
forCamera: boolean;
|
|
|
|
forCalling: boolean;
|
|
|
|
onAccept: () => void;
|
|
|
|
onClose: () => void;
|
|
|
|
};
|
|
|
|
|
|
|
|
type ScreenShareWindowPropsType = {
|
|
|
|
onStopSharing: () => void;
|
|
|
|
presentedSourceName: string;
|
|
|
|
};
|
|
|
|
|
|
|
|
type SettingsOnRenderCallbackType = (props: PreferencesPropsType) => void;
|
|
|
|
|
|
|
|
type SettingsWindowPropsType = {
|
|
|
|
onRender: (callback: SettingsOnRenderCallbackType) => void;
|
2023-03-14 15:55:31 +00:00
|
|
|
};
|
|
|
|
|
2022-06-13 21:39:35 +00:00
|
|
|
export type SignalCoreType = {
|
2023-04-20 21:23:19 +00:00
|
|
|
AboutWindowProps?: AboutWindowPropsType;
|
2022-06-13 21:39:35 +00:00
|
|
|
Crypto: typeof Crypto;
|
|
|
|
Curve: typeof Curve;
|
|
|
|
Data: typeof Data;
|
2023-04-20 21:23:19 +00:00
|
|
|
DebugLogWindowProps?: DebugLogWindowPropsType;
|
2022-06-13 21:39:35 +00:00
|
|
|
Groups: typeof Groups;
|
2023-04-20 21:23:19 +00:00
|
|
|
PermissionsWindowProps?: PermissionsWindowPropsType;
|
2022-06-13 21:39:35 +00:00
|
|
|
RemoteConfig: typeof RemoteConfig;
|
2023-04-20 21:23:19 +00:00
|
|
|
ScreenShareWindowProps?: ScreenShareWindowPropsType;
|
2022-06-13 21:39:35 +00:00
|
|
|
Services: {
|
|
|
|
calling: CallingClass;
|
|
|
|
initializeGroupCredentialFetcher: () => Promise<void>;
|
|
|
|
initializeNetworkObserver: (network: ReduxActions['network']) => void;
|
|
|
|
initializeUpdateListener: (updates: ReduxActions['updates']) => void;
|
2023-04-10 21:30:33 +00:00
|
|
|
retryPlaceholders?: RetryPlaceholders;
|
2022-06-13 21:39:35 +00:00
|
|
|
lightSessionResetQueue?: PQueue;
|
2022-10-08 00:19:02 +00:00
|
|
|
storage: typeof StorageService;
|
2022-06-13 21:39:35 +00:00
|
|
|
};
|
2023-04-20 21:23:19 +00:00
|
|
|
SettingsWindowProps?: SettingsWindowPropsType;
|
2022-06-13 21:39:35 +00:00
|
|
|
Migrations: ReturnType<typeof initializeMigrations>;
|
|
|
|
Types: {
|
|
|
|
Message: typeof Message2;
|
|
|
|
Address: typeof Address;
|
|
|
|
QualifiedAddress: typeof QualifiedAddress;
|
|
|
|
};
|
|
|
|
Components: {
|
|
|
|
ConfirmationDialog: typeof ConfirmationDialog;
|
|
|
|
};
|
2023-04-20 21:23:19 +00:00
|
|
|
OS: OSType;
|
2022-06-13 21:39:35 +00:00
|
|
|
State: {
|
|
|
|
Roots: {
|
|
|
|
createApp: typeof createApp;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
conversationControllerStart: () => void;
|
|
|
|
challengeHandler?: ChallengeHandler;
|
|
|
|
};
|
|
|
|
|
2020-03-31 20:03:38 +00:00
|
|
|
declare global {
|
2022-09-06 20:51:34 +00:00
|
|
|
// We want to extend various globals, so we need to use interfaces.
|
|
|
|
/* eslint-disable no-restricted-syntax */
|
2020-03-31 20:03:38 +00:00
|
|
|
interface Window {
|
2022-06-13 21:39:35 +00:00
|
|
|
// Used in Sticker Creator to create proper paths to emoji images
|
|
|
|
ROOT_PATH?: string;
|
|
|
|
// Used for sticker creator localization
|
|
|
|
localeMessages: { [key: string]: { message: string } };
|
|
|
|
|
2021-01-20 01:19:00 +00:00
|
|
|
isBehindProxy: () => boolean;
|
2023-02-27 22:34:43 +00:00
|
|
|
openArtCreator: (opts: { username: string; password: string }) => void;
|
2020-09-24 20:57:54 +00:00
|
|
|
|
|
|
|
enterKeyboardMode: () => void;
|
|
|
|
enterMouseMode: () => void;
|
2021-07-23 17:23:50 +00:00
|
|
|
getAccountManager: () => AccountManager;
|
2022-06-13 21:39:35 +00:00
|
|
|
getAppInstance: () => string | undefined;
|
2020-07-10 18:28:49 +00:00
|
|
|
getConversations: () => ConversationModelCollectionType;
|
2021-09-13 19:00:32 +00:00
|
|
|
getBuildCreation: () => number;
|
2023-01-18 23:31:10 +00:00
|
|
|
getBuildExpiration: () => number;
|
2021-02-04 19:54:03 +00:00
|
|
|
getEnvironment: typeof getEnvironment;
|
2021-09-17 18:27:53 +00:00
|
|
|
getHostName: () => string;
|
2020-10-30 17:52:21 +00:00
|
|
|
getInteractionMode: () => 'mouse' | 'keyboard';
|
2020-09-09 02:25:05 +00:00
|
|
|
getServerPublicParams: () => string;
|
2020-12-07 19:40:11 +00:00
|
|
|
getSfuUrl: () => string;
|
2021-06-09 22:28:54 +00:00
|
|
|
getSocketStatus: () => SocketStatus;
|
2021-04-08 17:09:54 +00:00
|
|
|
getSyncRequest: (timeoutMillis?: number) => SyncRequest;
|
2020-07-10 18:28:49 +00:00
|
|
|
getTitle: () => string;
|
2020-09-09 02:25:05 +00:00
|
|
|
waitForEmptyEventQueue: () => Promise<void>;
|
2020-09-09 22:50:44 +00:00
|
|
|
getVersion: () => string;
|
2021-05-03 16:38:20 +00:00
|
|
|
isAfterVersion: (version: string, anotherVersion: string) => boolean;
|
|
|
|
isBeforeVersion: (version: string, anotherVersion: string) => boolean;
|
2022-05-11 22:58:14 +00:00
|
|
|
initialTheme?: ThemeType;
|
2022-06-13 21:39:35 +00:00
|
|
|
libphonenumberInstance: {
|
|
|
|
parse: (number: string) => PhoneNumber;
|
|
|
|
getRegionCodeForNumber: (number: PhoneNumber) => string | undefined;
|
|
|
|
format: (number: PhoneNumber, format: PhoneNumberFormat) => string;
|
2020-04-13 17:37:29 +00:00
|
|
|
};
|
2022-06-13 21:39:35 +00:00
|
|
|
libphonenumberFormat: typeof PhoneNumberFormat;
|
2020-09-24 20:57:54 +00:00
|
|
|
nodeSetImmediate: typeof setImmediate;
|
2020-06-04 18:16:19 +00:00
|
|
|
platform: string;
|
2022-07-13 00:37:21 +00:00
|
|
|
preloadedImages: Array<HTMLImageElement>;
|
2020-09-24 20:57:54 +00:00
|
|
|
setImmediate: typeof setImmediate;
|
2021-05-06 00:09:29 +00:00
|
|
|
sendChallengeRequest: (request: IPCChallengeRequest) => void;
|
2020-09-24 20:57:54 +00:00
|
|
|
showKeyboardShortcuts: () => void;
|
2021-06-15 00:09:37 +00:00
|
|
|
storage: Storage;
|
2022-07-13 00:37:21 +00:00
|
|
|
systemTheme: ThemeType;
|
2021-12-16 15:02:22 +00:00
|
|
|
|
2022-06-13 21:39:35 +00:00
|
|
|
Signal: SignalCoreType;
|
2020-09-24 20:57:54 +00:00
|
|
|
|
2023-01-13 00:24:59 +00:00
|
|
|
getServerTrustRoot: () => string;
|
|
|
|
logAuthenticatedConnect?: () => void;
|
|
|
|
|
|
|
|
// ========================================================================
|
|
|
|
// The types below have been somewhat organized. See DESKTOP-4801
|
|
|
|
// ========================================================================
|
|
|
|
|
|
|
|
// Backbone
|
|
|
|
Backbone: typeof Backbone;
|
|
|
|
|
2020-07-10 18:28:49 +00:00
|
|
|
ConversationController: ConversationController;
|
2021-08-18 20:08:14 +00:00
|
|
|
Events: IPCEventsType;
|
2023-01-13 00:24:59 +00:00
|
|
|
FontFace: typeof FontFace;
|
2023-10-04 00:12:57 +00:00
|
|
|
MessageCache: MessageCache;
|
2021-02-26 23:42:45 +00:00
|
|
|
SignalProtocolStore: typeof SignalProtocolStore;
|
2020-04-13 17:37:29 +00:00
|
|
|
WebAPI: WebAPIConnectType;
|
2020-03-31 20:03:38 +00:00
|
|
|
Whisper: WhisperType;
|
2023-01-13 00:24:59 +00:00
|
|
|
getSignalProtocolStore: () => SignalProtocolStore;
|
|
|
|
i18n: LocalizerType;
|
|
|
|
// Note: used in background.html, and not type-checked
|
|
|
|
startApp: () => void;
|
|
|
|
textsecure: typeof textsecure;
|
2020-06-04 18:16:19 +00:00
|
|
|
|
2023-01-13 00:24:59 +00:00
|
|
|
// IPC
|
|
|
|
IPC: IPCType;
|
2020-11-13 19:57:55 +00:00
|
|
|
|
2023-01-13 00:24:59 +00:00
|
|
|
// State
|
|
|
|
reduxActions: ReduxActions;
|
|
|
|
reduxStore: Store<StateType>;
|
2021-01-29 22:16:48 +00:00
|
|
|
|
|
|
|
// Feature Flags
|
2023-01-19 00:02:03 +00:00
|
|
|
Flags: FeatureFlagType;
|
2021-08-20 16:06:15 +00:00
|
|
|
|
2023-01-13 00:24:59 +00:00
|
|
|
// Paths
|
|
|
|
BasePaths: {
|
|
|
|
attachments: string;
|
|
|
|
draft: string;
|
|
|
|
stickers: string;
|
|
|
|
temp: string;
|
|
|
|
};
|
2021-09-02 15:48:53 +00:00
|
|
|
|
2023-01-19 00:02:03 +00:00
|
|
|
// Test only
|
|
|
|
SignalCI?: CIType;
|
|
|
|
|
2023-01-13 00:24:59 +00:00
|
|
|
// TODO DESKTOP-4801
|
2021-10-07 23:28:47 +00:00
|
|
|
SignalContext: SignalContextType;
|
2022-06-13 21:39:35 +00:00
|
|
|
|
2023-01-13 00:24:59 +00:00
|
|
|
// Used only in preload to calculate load time
|
|
|
|
preloadStartTime: number;
|
|
|
|
preloadEndTime: number;
|
|
|
|
|
2022-06-13 21:39:35 +00:00
|
|
|
// Test only
|
2023-01-13 00:24:59 +00:00
|
|
|
RETRY_DELAY: boolean;
|
2022-06-13 21:39:35 +00:00
|
|
|
assert: typeof assert;
|
|
|
|
testUtilities: {
|
2023-10-04 00:12:57 +00:00
|
|
|
debug: (info: unknown) => void;
|
|
|
|
initialize: () => Promise<void>;
|
2022-09-06 20:51:34 +00:00
|
|
|
onComplete: (info: unknown) => void;
|
2022-06-13 21:39:35 +00:00
|
|
|
prepareTests: () => void;
|
|
|
|
};
|
2020-03-31 20:03:38 +00:00
|
|
|
}
|
2020-05-27 21:37:06 +00:00
|
|
|
|
2022-02-25 23:35:53 +00:00
|
|
|
interface Element {
|
|
|
|
// WebKit-specific
|
|
|
|
scrollIntoViewIfNeeded: (bringToCenter?: boolean) => void;
|
|
|
|
}
|
|
|
|
|
2021-06-15 00:09:37 +00:00
|
|
|
// Uint8Array and ArrayBuffer are type-compatible in TypeScript's covariant
|
|
|
|
// type checker, but in reality they are not. Let's assert correct use!
|
|
|
|
interface Uint8Array {
|
|
|
|
__uint8array: never;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ArrayBuffer {
|
2022-09-06 20:51:34 +00:00
|
|
|
__arrayBuffer: never;
|
2021-06-15 00:09:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface SharedArrayBuffer {
|
2022-09-06 20:51:34 +00:00
|
|
|
__arrayBuffer: never;
|
2021-06-15 00:09:37 +00:00
|
|
|
}
|
2020-03-31 20:03:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type WhisperType = {
|
2021-08-30 21:32:56 +00:00
|
|
|
Conversation: typeof ConversationModel;
|
|
|
|
ConversationCollection: typeof ConversationModelCollectionType;
|
|
|
|
Message: typeof MessageModel;
|
|
|
|
|
|
|
|
deliveryReceiptQueue: PQueue;
|
2021-12-07 22:41:40 +00:00
|
|
|
deliveryReceiptBatcher: BatcherType<Receipt>;
|
2021-07-19 20:45:18 +00:00
|
|
|
events: Backbone.Events;
|
2020-03-31 20:03:38 +00:00
|
|
|
};
|