b7d56def82
* Starting to work through lint errors * libsignal-protocol: Update changes for primary repo compatibility * Step 1: task_with_timeout rename * Step 2: Apply the changes to TaskWithTimeout.ts * Step 1: All to-be-converted libtextsecure/*.js files moved * Step 2: No Typescript errors! * Get libtextsecure tests passing again * TSLint errors down to 1 * Compilation succeeds, no lint errors or test failures * WebSocketResources - update import for case-sensitive filesystems * Fixes for lint-deps * Remove unnecessary @ts-ignore * Fix inability to message your own contact after link * Add log message for the end of migration 20 * lint fix
215 lines
5.6 KiB
TypeScript
215 lines
5.6 KiB
TypeScript
export type LibSignalType = {
|
|
externalCurve?: CurveType;
|
|
crypto: {
|
|
encrypt: (
|
|
key: ArrayBuffer,
|
|
data: ArrayBuffer,
|
|
iv: ArrayBuffer
|
|
) => Promise<ArrayBuffer>;
|
|
decrypt: (
|
|
key: ArrayBuffer,
|
|
data: ArrayBuffer,
|
|
iv: ArrayBuffer
|
|
) => Promise<ArrayBuffer>;
|
|
calculateMAC: (key: ArrayBuffer, data: ArrayBuffer) => Promise<ArrayBuffer>;
|
|
verifyMAC: (
|
|
data: ArrayBuffer,
|
|
key: ArrayBuffer,
|
|
mac: ArrayBuffer,
|
|
length: number
|
|
) => Promise<void>;
|
|
getRandomBytes: (size: number) => ArrayBuffer;
|
|
};
|
|
KeyHelper: {
|
|
generateIdentityKeyPair: () => Promise<{
|
|
privKey: ArrayBuffer;
|
|
pubKey: ArrayBuffer;
|
|
}>;
|
|
generateRegistrationId: () => number;
|
|
generateSignedPreKey: (
|
|
identityKeyPair: KeyPairType,
|
|
signedKeyId: number
|
|
) => Promise<SignedPreKeyType>;
|
|
generatePreKey: (keyId: number) => Promise<PreKeyType>;
|
|
};
|
|
Curve: {
|
|
generateKeyPair: () => KeyPairType;
|
|
createKeyPair: (privKey: ArrayBuffer) => KeyPairType;
|
|
calculateAgreement: (
|
|
pubKey: ArrayBuffer,
|
|
privKey: ArrayBuffer
|
|
) => ArrayBuffer;
|
|
verifySignature: (
|
|
pubKey: ArrayBuffer,
|
|
msg: ArrayBuffer,
|
|
sig: ArrayBuffer
|
|
) => void;
|
|
calculateSignature: (
|
|
privKey: ArrayBuffer,
|
|
message: ArrayBuffer
|
|
) => ArrayBuffer | Promise<ArrayBuffer>;
|
|
validatePubKeyFormat: (buffer: ArrayBuffer) => ArrayBuffer;
|
|
async: CurveType;
|
|
};
|
|
HKDF: {
|
|
deriveSecrets: (
|
|
packKey: ArrayBuffer,
|
|
salt: ArrayBuffer,
|
|
// The string is a bit crazy, but ProvisioningCipher currently passes in a string
|
|
info: ArrayBuffer | string
|
|
) => Promise<Array<ArrayBuffer>>;
|
|
};
|
|
worker: {
|
|
startWorker: () => void;
|
|
stopWorker: () => void;
|
|
};
|
|
FingerprintGenerator: typeof FingerprintGeneratorClass;
|
|
SessionBuilder: typeof SessionBuilderClass;
|
|
SessionCipher: typeof SessionCipherClass;
|
|
SignalProtocolAddress: typeof SignalProtocolAddressClass;
|
|
};
|
|
|
|
export type KeyPairType = {
|
|
pubKey: ArrayBuffer;
|
|
privKey: ArrayBuffer;
|
|
};
|
|
|
|
export type SignedPreKeyType = {
|
|
keyId: number;
|
|
keyPair: KeyPairType;
|
|
signature: ArrayBuffer;
|
|
};
|
|
|
|
export type PreKeyType = {
|
|
keyId: number;
|
|
keyPair: KeyPairType;
|
|
};
|
|
|
|
type RecordType = {
|
|
archiveCurrentState: () => void;
|
|
deleteAllSessions: () => void;
|
|
getOpenSession: () => void;
|
|
getSessionByBaseKey: () => void;
|
|
getSessions: () => void;
|
|
haveOpenSession: () => void;
|
|
promoteState: () => void;
|
|
serialize: () => void;
|
|
updateSessionState: () => void;
|
|
};
|
|
|
|
type CurveType = {
|
|
generateKeyPair: () => Promise<KeyPairType>;
|
|
createKeyPair: (privKey: ArrayBuffer) => Promise<KeyPairType>;
|
|
calculateAgreement: (
|
|
pubKey: ArrayBuffer,
|
|
privKey: ArrayBuffer
|
|
) => Promise<ArrayBuffer>;
|
|
verifySignature: (
|
|
pubKey: ArrayBuffer,
|
|
msg: ArrayBuffer,
|
|
sig: ArrayBuffer
|
|
) => Promise<void>;
|
|
calculateSignature: (
|
|
privKey: ArrayBuffer,
|
|
message: ArrayBuffer
|
|
) => ArrayBuffer | Promise<ArrayBuffer>;
|
|
validatePubKeyFormat: (buffer: ArrayBuffer) => ArrayBuffer;
|
|
};
|
|
|
|
type SessionRecordType = any;
|
|
|
|
export type StorageType = {
|
|
Direction: {
|
|
SENDING: number;
|
|
RECEIVING: number;
|
|
};
|
|
getIdentityKeyPair: () => Promise<KeyPairType>;
|
|
getLocalRegistrationId: () => Promise<number>;
|
|
isTrustedIdentity: () => Promise<void>;
|
|
loadPreKey: (
|
|
encodedAddress: string,
|
|
publicKey: ArrayBuffer | undefined,
|
|
direction: number
|
|
) => Promise<void>;
|
|
loadSession: (encodedAddress: string) => Promise<SessionRecordType>;
|
|
loadSignedPreKey: (keyId: number) => Promise<SignedPreKeyType>;
|
|
removePreKey: (keyId: number) => Promise<void>;
|
|
saveIdentity: (
|
|
encodedAddress: string,
|
|
publicKey: ArrayBuffer,
|
|
nonblockingApproval?: boolean
|
|
) => Promise<boolean>;
|
|
storeSession: (
|
|
encodedAddress: string,
|
|
record: SessionRecordType
|
|
) => Promise<void>;
|
|
};
|
|
|
|
declare class FingerprintGeneratorClass {
|
|
constructor(iterations: number);
|
|
createFor: (
|
|
localIdentifier: string,
|
|
localIdentityKey: ArrayBuffer,
|
|
remoteIdentifier: string,
|
|
remoteIdentityKey: ArrayBuffer
|
|
) => string;
|
|
}
|
|
|
|
export declare class SignalProtocolAddressClass {
|
|
static fromString(encodedAddress: string): SignalProtocolAddressClass;
|
|
constructor(name: string, deviceId: number);
|
|
getName: () => string;
|
|
getDeviceId: () => number;
|
|
toString: () => string;
|
|
equals: (other: SignalProtocolAddressClass) => boolean;
|
|
}
|
|
|
|
type DeviceType = {
|
|
deviceId: number;
|
|
identityKey: ArrayBuffer;
|
|
registrationId: number;
|
|
signedPreKey: {
|
|
keyId: number;
|
|
publicKey: ArrayBuffer;
|
|
signature: ArrayBuffer;
|
|
};
|
|
preKey?: {
|
|
keyId: number;
|
|
publicKey: ArrayBuffer;
|
|
};
|
|
};
|
|
|
|
declare class SessionBuilderClass {
|
|
constructor(storage: StorageType, remoteAddress: SignalProtocolAddressClass);
|
|
processPreKey: (device: DeviceType) => Promise<void>;
|
|
processV3: (record: RecordType, message: any) => Promise<void>;
|
|
}
|
|
|
|
export declare class SessionCipherClass {
|
|
constructor(
|
|
storage: StorageType,
|
|
remoteAddress: SignalProtocolAddressClass,
|
|
options?: any
|
|
);
|
|
closeOpenSessionForDevice: () => Promise<void>;
|
|
decryptPreKeyWhisperMessage: (
|
|
buffer: ArrayBuffer,
|
|
encoding?: string
|
|
) => Promise<ArrayBuffer>;
|
|
decryptWhisperMessage: (
|
|
buffer: ArrayBuffer,
|
|
encoding?: string
|
|
) => Promise<ArrayBuffer>;
|
|
deleteAllSessionsForDevice: () => Promise<void>;
|
|
encrypt: (
|
|
buffer: ArrayBuffer | Uint8Array,
|
|
encoding?: string
|
|
) => Promise<{
|
|
type: number;
|
|
registrationId: number;
|
|
body: string;
|
|
}>;
|
|
getRecord: () => Promise<RecordType>;
|
|
getRemoteRegistrationId: () => Promise<number>;
|
|
hasOpenSession: () => Promise<boolean>;
|
|
}
|