diff options
author | RaindropsSys <contact@minteck.org> | 2023-04-24 14:03:36 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-04-24 14:03:36 +0200 |
commit | 633c92eae865e957121e08de634aeee11a8b3992 (patch) | |
tree | 09d881bee1dae0b6eee49db1dfaf0f500240606c /includes/external/matrix/node_modules/matrix-js-sdk/lib/crypto/olmlib.d.ts | |
parent | c4657e4509733699c0f26a3c900bab47e915d5a0 (diff) | |
download | pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.gz pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.tar.bz2 pluralconnect-633c92eae865e957121e08de634aeee11a8b3992.zip |
Updated 18 files, added 1692 files and deleted includes/system/compare.inc (automated)
Diffstat (limited to 'includes/external/matrix/node_modules/matrix-js-sdk/lib/crypto/olmlib.d.ts')
-rw-r--r-- | includes/external/matrix/node_modules/matrix-js-sdk/lib/crypto/olmlib.d.ts | 146 |
1 files changed, 146 insertions, 0 deletions
diff --git a/includes/external/matrix/node_modules/matrix-js-sdk/lib/crypto/olmlib.d.ts b/includes/external/matrix/node_modules/matrix-js-sdk/lib/crypto/olmlib.d.ts new file mode 100644 index 0000000..18ee3c9 --- /dev/null +++ b/includes/external/matrix/node_modules/matrix-js-sdk/lib/crypto/olmlib.d.ts @@ -0,0 +1,146 @@ +import type { PkSigning } from "@matrix-org/olm"; +import type { IOneTimeKey } from "../@types/crypto"; +import { OlmDevice } from "./OlmDevice"; +import { DeviceInfo } from "./deviceinfo"; +import { MatrixClient } from "../client"; +import { ISignatures } from "../@types/signed"; +import { MatrixEvent } from "../models/event"; +import { IMessage } from "./algorithms/olm"; +declare enum Algorithm { + Olm = "m.olm.v1.curve25519-aes-sha2", + Megolm = "m.megolm.v1.aes-sha2", + MegolmBackup = "m.megolm_backup.v1.curve25519-aes-sha2" +} +/** + * matrix algorithm tag for olm + */ +export declare const OLM_ALGORITHM = Algorithm.Olm; +/** + * matrix algorithm tag for megolm + */ +export declare const MEGOLM_ALGORITHM = Algorithm.Megolm; +/** + * matrix algorithm tag for megolm backups + */ +export declare const MEGOLM_BACKUP_ALGORITHM = Algorithm.MegolmBackup; +export interface IOlmSessionResult { + /** device info */ + device: DeviceInfo; + /** base64 olm session id; null if no session could be established */ + sessionId: string | null; +} +/** + * Encrypt an event payload for an Olm device + * + * @param resultsObject - The `ciphertext` property + * of the m.room.encrypted event to which to add our result + * + * @param olmDevice - olm.js wrapper + * @param payloadFields - fields to include in the encrypted payload + * + * Returns a promise which resolves (to undefined) when the payload + * has been encrypted into `resultsObject` + */ +export declare function encryptMessageForDevice(resultsObject: Record<string, IMessage>, ourUserId: string, ourDeviceId: string | undefined, olmDevice: OlmDevice, recipientUserId: string, recipientDevice: DeviceInfo, payloadFields: Record<string, any>): Promise<void>; +interface IExistingOlmSession { + device: DeviceInfo; + sessionId: string | null; +} +/** + * Get the existing olm sessions for the given devices, and the devices that + * don't have olm sessions. + * + * + * + * @param devicesByUser - map from userid to list of devices to ensure sessions for + * + * @returns resolves to an array. The first element of the array is a + * a map of user IDs to arrays of deviceInfo, representing the devices that + * don't have established olm sessions. The second element of the array is + * a map from userId to deviceId to {@link OlmSessionResult} + */ +export declare function getExistingOlmSessions(olmDevice: OlmDevice, baseApis: MatrixClient, devicesByUser: Record<string, DeviceInfo[]>): Promise<[Map<string, DeviceInfo[]>, Map<string, Map<string, IExistingOlmSession>>]>; +/** + * Try to make sure we have established olm sessions for the given devices. + * + * @param devicesByUser - map from userid to list of devices to ensure sessions for + * + * @param force - If true, establish a new session even if one + * already exists. + * + * @param otkTimeout - The timeout in milliseconds when requesting + * one-time keys for establishing new olm sessions. + * + * @param failedServers - An array to fill with remote servers that + * failed to respond to one-time-key requests. + * + * @param log - A possibly customised log + * + * @returns resolves once the sessions are complete, to + * an Object mapping from userId to deviceId to + * {@link OlmSessionResult} + */ +export declare function ensureOlmSessionsForDevices(olmDevice: OlmDevice, baseApis: MatrixClient, devicesByUser: Map<string, DeviceInfo[]>, force?: boolean, otkTimeout?: number, failedServers?: string[], log?: import("../logger").PrefixedLogger): Promise<Map<string, Map<string, IOlmSessionResult>>>; +export interface IObject { + unsigned?: object; + signatures?: ISignatures; +} +/** + * Verify the signature on an object + * + * @param olmDevice - olm wrapper to use for verify op + * + * @param obj - object to check signature on. + * + * @param signingUserId - ID of the user whose signature should be checked + * + * @param signingDeviceId - ID of the device whose signature should be checked + * + * @param signingKey - base64-ed ed25519 public key + * + * Returns a promise which resolves (to undefined) if the the signature is good, + * or rejects with an Error if it is bad. + */ +export declare function verifySignature(olmDevice: OlmDevice, obj: IOneTimeKey | IObject, signingUserId: string, signingDeviceId: string, signingKey: string): Promise<void>; +/** + * Sign a JSON object using public key cryptography + * @param obj - Object to sign. The object will be modified to include + * the new signature + * @param key - the signing object or the private key + * seed + * @param userId - The user ID who owns the signing key + * @param pubKey - The public key (ignored if key is a seed) + * @returns the signature for the object + */ +export declare function pkSign(obj: object & IObject, key: Uint8Array | PkSigning, userId: string, pubKey: string): string; +/** + * Verify a signed JSON object + * @param obj - Object to verify + * @param pubKey - The public key to use to verify + * @param userId - The user ID who signed the object + */ +export declare function pkVerify(obj: IObject, pubKey: string, userId: string): void; +/** + * Check that an event was encrypted using olm. + */ +export declare function isOlmEncrypted(event: MatrixEvent): boolean; +/** + * Encode a typed array of uint8 as base64. + * @param uint8Array - The data to encode. + * @returns The base64. + */ +export declare function encodeBase64(uint8Array: ArrayBuffer | Uint8Array): string; +/** + * Encode a typed array of uint8 as unpadded base64. + * @param uint8Array - The data to encode. + * @returns The unpadded base64. + */ +export declare function encodeUnpaddedBase64(uint8Array: ArrayBuffer | Uint8Array): string; +/** + * Decode a base64 string to a typed array of uint8. + * @param base64 - The base64 to decode. + * @returns The decoded data. + */ +export declare function decodeBase64(base64: string): Uint8Array; +export {}; +//# sourceMappingURL=olmlib.d.ts.map
\ No newline at end of file |