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
98
ts/window.d.ts
vendored
Normal file
98
ts/window.d.ts
vendored
Normal file
|
@ -0,0 +1,98 @@
|
|||
// Captures the globals put in place by preload.js, background.js and others
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
dcodeIO: DCodeIOType;
|
||||
getExpiration: () => string;
|
||||
getEnvironment: () => string;
|
||||
getSocketStatus: () => number;
|
||||
libsignal: LibSignalType;
|
||||
log: {
|
||||
info: LoggerType;
|
||||
warn: LoggerType;
|
||||
error: LoggerType;
|
||||
};
|
||||
storage: {
|
||||
put: (key: string, value: any) => void;
|
||||
remove: (key: string) => void;
|
||||
get: (key: string) => any;
|
||||
};
|
||||
textsecure: TextSecureType;
|
||||
|
||||
ConversationController: ConversationControllerType;
|
||||
Whisper: WhisperType;
|
||||
}
|
||||
}
|
||||
|
||||
export type ConversationControllerType = {
|
||||
prepareForSend: (
|
||||
id: string,
|
||||
options: Object
|
||||
) => {
|
||||
wrap: (promise: Promise<any>) => Promise<void>;
|
||||
sendOptions: Object;
|
||||
};
|
||||
};
|
||||
|
||||
export type DCodeIOType = {
|
||||
ByteBuffer: {
|
||||
wrap: (
|
||||
value: any,
|
||||
type?: string
|
||||
) => {
|
||||
toString: (type: string) => string;
|
||||
toArrayBuffer: () => ArrayBuffer;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
export type LibSignalType = {
|
||||
KeyHelper: {
|
||||
generateIdentityKeyPair: () => Promise<{
|
||||
privKey: ArrayBuffer;
|
||||
pubKey: ArrayBuffer;
|
||||
}>;
|
||||
};
|
||||
Curve: {
|
||||
async: {
|
||||
calculateAgreement: (
|
||||
publicKey: ArrayBuffer,
|
||||
privateKey: ArrayBuffer
|
||||
) => Promise<ArrayBuffer>;
|
||||
};
|
||||
};
|
||||
HKDF: {
|
||||
deriveSecrets: (
|
||||
packKey: ArrayBuffer,
|
||||
salt: ArrayBuffer,
|
||||
info: ArrayBuffer
|
||||
) => Promise<Array<ArrayBuffer>>;
|
||||
};
|
||||
};
|
||||
|
||||
export type LoggerType = (...args: Array<any>) => void;
|
||||
|
||||
export type TextSecureType = {
|
||||
storage: {
|
||||
user: {
|
||||
getNumber: () => string;
|
||||
};
|
||||
get: (key: string) => any;
|
||||
};
|
||||
messaging: {
|
||||
sendStickerPackSync: (
|
||||
operations: Array<{
|
||||
packId: string;
|
||||
packKey: string;
|
||||
installed: boolean;
|
||||
}>,
|
||||
options: Object
|
||||
) => Promise<void>;
|
||||
};
|
||||
};
|
||||
|
||||
export type WhisperType = {
|
||||
events: {
|
||||
trigger: (name: string, param1: any, param2: any) => void;
|
||||
};
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue