Improve typings for LibsignalProtocol

pull/1162/head
Mikunj 5 years ago
parent cbc32b9989
commit 41fa167e79

@ -1,7 +1,10 @@
import { CipherTextObject } from '../../../../window/types/libsignal-protocol';
import {
CipherTextObject,
SessionCipher,
} from '../../../../window/types/libsignal-protocol';
import { SignalService } from '../../../../protobuf';
export class SessionCipherStub {
export class SessionCipherStub implements SessionCipher {
public storage: any;
public address: any;
constructor(storage: any, address: any) {
@ -17,4 +20,36 @@ export class SessionCipherStub {
body: Buffer.from(buffer).toString('binary'),
};
}
public async decryptPreKeyWhisperMessage(
buffer: ArrayBuffer | Uint8Array
): Promise<ArrayBuffer> {
throw new Error('Method not implemented.');
}
public async decryptWhisperMessage(
buffer: ArrayBuffer | Uint8Array
): Promise<ArrayBuffer> {
throw new Error('Method not implemented.');
}
public async getRecord(encodedNumber: string): Promise<any> {
throw new Error('Method not implemented.');
}
public async getRemoteRegistrationId(): Promise<number> {
throw new Error('Method not implemented.');
}
public async hasOpenSession(): Promise<boolean> {
throw new Error('Method not implemented.');
}
public async closeOpenSessionForDevice(): Promise<void> {
throw new Error('Method not implemented.');
}
public async deleteAllSessionsForDevice(): Promise<void> {
throw new Error('Method not implemented.');
}
}

@ -9,6 +9,7 @@
"max-func-body-length": false,
"no-unused-expression": false,
"no-unused-variable": false,
"await-promise": [true, "PromiseLike"],
"no-floating-promises": [true, "PromiseLike"]

@ -7,15 +7,16 @@ export type CipherTextObject = {
body: BinaryString;
registrationId?: number;
};
export interface SignalProtocolAddressConstructor {
new (hexEncodedPublicKey: string, deviceId: number): SignalProtocolAddress;
fromString(encodedAddress: string): SignalProtocolAddress;
}
export declare class SignalProtocolAddress {
constructor(hexEncodedPublicKey: string, deviceId: number);
// tslint:disable-next-line: function-name
public static fromString(encodedAddress: string): SignalProtocolAddress;
public getName(): string;
public getDeviceId(): number;
public toString(): string;
public equals(other: SignalProtocolAddress): boolean;
export interface SignalProtocolAddress {
getName(): string;
getDeviceId(): number;
toString(): string;
equals(other: SignalProtocolAddress): boolean;
}
export type KeyPair = {
@ -99,29 +100,30 @@ export interface KeyHelperInterface {
}>;
}
export declare class SessionCipher {
constructor(storage: any, remoteAddress: SignalProtocolAddress);
export type SessionCipherConstructor = new (
storage: any,
remoteAddress: SignalProtocolAddress
) => SessionCipher;
export interface SessionCipher {
/**
* @returns The envelope type, registration id and binary encoded encrypted body.
*/
public encrypt(buffer: ArrayBuffer | Uint8Array): Promise<CipherTextObject>;
public decryptPreKeyWhisperMessage(
buffer: ArrayBuffer | Uint8Array
): Promise<ArrayBuffer>;
public decryptWhisperMessage(
encrypt(buffer: ArrayBuffer | Uint8Array): Promise<CipherTextObject>;
decryptPreKeyWhisperMessage(
buffer: ArrayBuffer | Uint8Array
): Promise<ArrayBuffer>;
public getRecord(encodedNumber: string): Promise<any | undefined>;
public getRemoteRegistrationId(): Promise<number>;
public hasOpenSession(): Promise<boolean>;
public closeOpenSessionForDevice(): Promise<void>;
public deleteAllSessionsForDevice(): Promise<void>;
decryptWhisperMessage(buffer: ArrayBuffer | Uint8Array): Promise<ArrayBuffer>;
getRecord(encodedNumber: string): Promise<any | undefined>;
getRemoteRegistrationId(): Promise<number>;
hasOpenSession(): Promise<boolean>;
closeOpenSessionForDevice(): Promise<void>;
deleteAllSessionsForDevice(): Promise<void>;
}
export interface LibsignalProtocol {
SignalProtocolAddress: typeof SignalProtocolAddress;
SignalProtocolAddress: SignalProtocolAddressConstructor;
Curve: CurveInterface;
crypto: CryptoInterface;
KeyHelper: KeyHelperInterface;
SessionCipher: typeof SessionCipher;
SessionCipher: SessionCipherConstructor;
}

Loading…
Cancel
Save