2020-04-24 23:27:55 +02:00
|
|
|
/*
|
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
export as namespace Olm;
|
|
|
|
|
|
|
|
declare class Account {
|
|
|
|
constructor();
|
|
|
|
free();
|
|
|
|
create();
|
|
|
|
identity_keys(): string;
|
2020-08-31 16:50:33 +02:00
|
|
|
sign(message: string | Uint8Array): string;
|
2020-04-24 23:27:55 +02:00
|
|
|
one_time_keys(): string;
|
|
|
|
mark_keys_as_published();
|
|
|
|
max_number_of_one_time_keys(): number;
|
|
|
|
generate_one_time_keys(number_of_keys: number);
|
|
|
|
remove_one_time_keys(session: Session);
|
|
|
|
pickle(key: string): string;
|
|
|
|
unpickle(key: string, pickle: string);
|
|
|
|
}
|
|
|
|
|
|
|
|
declare class Session {
|
|
|
|
constructor();
|
|
|
|
free(): void;
|
2020-08-31 16:50:33 +02:00
|
|
|
pickle(key: string | Uint8Array): string;
|
|
|
|
unpickle(key: string | Uint8Array, pickle: string);
|
2020-04-24 23:27:55 +02:00
|
|
|
create_outbound(
|
|
|
|
account: Account, their_identity_key: string, their_one_time_key: string,
|
|
|
|
): void;
|
|
|
|
create_inbound(account: Account, one_time_key_message: string): void;
|
|
|
|
create_inbound_from(
|
|
|
|
account: Account, identity_key: string, one_time_key_message: string,
|
|
|
|
): void;
|
|
|
|
session_id(): string;
|
|
|
|
has_received_message(): boolean;
|
|
|
|
matches_inbound(one_time_key_message: string): boolean;
|
|
|
|
matches_inbound_from(identity_key: string, one_time_key_message: string): boolean;
|
|
|
|
encrypt(plaintext: string): object;
|
|
|
|
decrypt(message_type: number, message: string): string;
|
|
|
|
describe(): string;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare class Utility {
|
|
|
|
constructor();
|
|
|
|
free(): void;
|
2020-08-31 16:50:33 +02:00
|
|
|
sha256(input: string | Uint8Array): string;
|
|
|
|
ed25519_verify(key: string, message: string | Uint8Array, signature: string): void;
|
2020-04-24 23:27:55 +02:00
|
|
|
}
|
|
|
|
|
2020-04-24 23:44:28 +02:00
|
|
|
declare class InboundGroupSession {
|
|
|
|
constructor();
|
|
|
|
free(): void;
|
|
|
|
pickle(key: string): string;
|
2020-05-07 23:47:07 +02:00
|
|
|
unpickle(key: string, pickle: string);
|
2020-04-24 23:44:28 +02:00
|
|
|
create(session_key: string): string;
|
|
|
|
import_session(session_key: string): string;
|
|
|
|
decrypt(message: string): object;
|
|
|
|
session_id(): string;
|
|
|
|
first_known_index(): number;
|
|
|
|
export_session(message_index: number): string;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare class OutboundGroupSession {
|
|
|
|
constructor();
|
|
|
|
free(): void;
|
|
|
|
pickle(key: string): string;
|
2020-05-07 23:47:07 +02:00
|
|
|
unpickle(key: string, pickle: string);
|
2020-04-24 23:44:28 +02:00
|
|
|
create(): void;
|
|
|
|
encrypt(plaintext: string): string;
|
|
|
|
session_id(): string;
|
|
|
|
session_key(): string;
|
|
|
|
message_index(): number;
|
|
|
|
}
|
|
|
|
|
2020-04-24 23:27:55 +02:00
|
|
|
declare class PkEncryption {
|
|
|
|
constructor();
|
|
|
|
free(): void;
|
|
|
|
set_recipient_key(key: string): void;
|
|
|
|
encrypt(plaintext: string): object;
|
|
|
|
}
|
|
|
|
|
|
|
|
declare class PkDecryption {
|
|
|
|
constructor();
|
|
|
|
free(): void;
|
|
|
|
init_with_private_key(key: Uint8Array): string;
|
|
|
|
generate_key(): string;
|
|
|
|
get_private_key(): Uint8Array;
|
2020-08-31 16:50:33 +02:00
|
|
|
pickle(key: string | Uint8Array): string;
|
|
|
|
unpickle(key: string | Uint8Array, pickle: string): string;
|
2020-04-29 18:39:41 +02:00
|
|
|
decrypt(ephemeral_key: string, mac: string, ciphertext: string): string;
|
2020-04-24 23:27:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
declare class PkSigning {
|
|
|
|
constructor();
|
|
|
|
free(): void;
|
|
|
|
init_with_seed(seed: Uint8Array): string;
|
|
|
|
generate_seed(): Uint8Array;
|
|
|
|
sign(message: string): string;
|
|
|
|
}
|
|
|
|
|
2020-04-29 18:39:41 +02:00
|
|
|
declare class SAS {
|
|
|
|
constructor();
|
|
|
|
free(): void;
|
|
|
|
get_pubkey(): string;
|
|
|
|
set_their_key(their_key: string): void;
|
|
|
|
generate_bytes(info: string, length: number): Uint8Array;
|
|
|
|
calculate_mac(input: string, info: string): string;
|
|
|
|
calculate_mac_long_kdf(input: string, info: string): string;
|
|
|
|
}
|
|
|
|
|
2020-08-31 16:50:33 +02:00
|
|
|
export function init(opts?: object): Promise<void>;
|
2020-04-24 23:27:55 +02:00
|
|
|
|
|
|
|
export function get_library_version(): [number, number, number];
|