Move web_api.js and js/modules/crypto.js to TypeScript
This commit is contained in:
parent
71436d18e2
commit
9ab54b9b83
29 changed files with 770 additions and 427 deletions
|
@ -1,52 +1,9 @@
|
|||
type LoggerType = (...args: Array<any>) => void;
|
||||
|
||||
type TextSecureType = {
|
||||
storage: {
|
||||
user: {
|
||||
getNumber: () => string;
|
||||
};
|
||||
get: (item: string) => any;
|
||||
};
|
||||
messaging: {
|
||||
sendStickerPackSync: (
|
||||
operations: Array<{
|
||||
packId: string;
|
||||
packKey: string;
|
||||
installed: boolean;
|
||||
}>,
|
||||
options: Object
|
||||
) => Promise<void>;
|
||||
};
|
||||
};
|
||||
|
||||
type ConversationControllerType = {
|
||||
prepareForSend: (
|
||||
id: string,
|
||||
options: Object
|
||||
) => {
|
||||
wrap: (promise: Promise<any>) => Promise<void>;
|
||||
sendOptions: Object;
|
||||
};
|
||||
};
|
||||
|
||||
interface ShimmedWindow extends Window {
|
||||
log: {
|
||||
error: LoggerType;
|
||||
info: LoggerType;
|
||||
};
|
||||
textsecure: TextSecureType;
|
||||
ConversationController: ConversationControllerType;
|
||||
}
|
||||
|
||||
const unknownWindow = window as unknown;
|
||||
const shimmedWindow = unknownWindow as ShimmedWindow;
|
||||
|
||||
export function sendStickerPackSync(
|
||||
packId: string,
|
||||
packKey: string,
|
||||
installed: boolean
|
||||
) {
|
||||
const { ConversationController, textsecure, log } = shimmedWindow;
|
||||
const { ConversationController, textsecure, log } = window;
|
||||
const ourNumber = textsecure.storage.user.getNumber();
|
||||
const { wrap, sendOptions } = ConversationController.prepareForSend(
|
||||
ourNumber,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue