1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Mark all the rust crypto stuff internal (#3574)

... for the avoidance of doubt.
This commit is contained in:
Richard van der Hoff
2023-07-11 15:11:35 +01:00
committed by GitHub
parent f2471b6dbd
commit a5e606a1e7
10 changed files with 36 additions and 1 deletions

View File

@@ -24,6 +24,8 @@ import { IEventDecryptionResult } from "../@types/crypto";
/** /**
* Common interface for the crypto implementations * Common interface for the crypto implementations
*
* @internal
*/ */
export interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi { export interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {
/** /**
@@ -90,7 +92,10 @@ export interface CryptoBackend extends SyncCryptoCallbacks, CryptoApi {
getStoredCrossSigningForUser(userId: string): CrossSigningInfo | null; getStoredCrossSigningForUser(userId: string): CrossSigningInfo | null;
} }
/** The methods which crypto implementations should expose to the Sync api */ /** The methods which crypto implementations should expose to the Sync api
*
* @internal
*/
export interface SyncCryptoCallbacks { export interface SyncCryptoCallbacks {
/** /**
* Called by the /sync loop whenever there are incoming to-device messages. * Called by the /sync loop whenever there are incoming to-device messages.
@@ -146,6 +151,9 @@ export interface SyncCryptoCallbacks {
onSyncCompleted(syncState: OnSyncCompletedData): void; onSyncCompleted(syncState: OnSyncCompletedData): void;
} }
/**
* @internal
*/
export interface OnSyncCompletedData { export interface OnSyncCompletedData {
/** /**
* The 'next_batch' result from /sync, which will become the 'since' token for the next call to /sync. * The 'next_batch' result from /sync, which will become the 'since' token for the next call to /sync.

View File

@@ -22,6 +22,8 @@ import { OutgoingRequest, OutgoingRequestProcessor } from "./OutgoingRequestProc
import { UIAuthCallback } from "../interactive-auth"; import { UIAuthCallback } from "../interactive-auth";
/** Manages the cross-signing keys for our own user. /** Manages the cross-signing keys for our own user.
*
* @internal
*/ */
export class CrossSigningIdentity { export class CrossSigningIdentity {
public constructor( public constructor(

View File

@@ -22,6 +22,8 @@ import { OutgoingRequestProcessor } from "./OutgoingRequestProcessor";
* KeyClaimManager: linearises calls to OlmMachine.getMissingSessions to avoid races * KeyClaimManager: linearises calls to OlmMachine.getMissingSessions to avoid races
* *
* We have one of these per `RustCrypto` (and hence per `MatrixClient`). * We have one of these per `RustCrypto` (and hence per `MatrixClient`).
*
* @internal
*/ */
export class KeyClaimManager { export class KeyClaimManager {
private currentClaimPromise: Promise<void>; private currentClaimPromise: Promise<void>;

View File

@@ -34,6 +34,8 @@ import { UIAResponse } from "../@types/uia";
/** /**
* Common interface for all the request types returned by `OlmMachine.outgoingRequests`. * Common interface for all the request types returned by `OlmMachine.outgoingRequests`.
*
* @internal
*/ */
export interface OutgoingRequest { export interface OutgoingRequest {
readonly id: string | undefined; readonly id: string | undefined;
@@ -49,6 +51,8 @@ export interface OutgoingRequest {
* * holding the reference to the `MatrixHttpApi` * * holding the reference to the `MatrixHttpApi`
* * turning `OutgoingRequest`s from the rust backend into HTTP requests, and sending them * * turning `OutgoingRequest`s from the rust backend into HTTP requests, and sending them
* * sending the results of such requests back to the rust backend. * * sending the results of such requests back to the rust backend.
*
* @internal
*/ */
export class OutgoingRequestProcessor { export class OutgoingRequestProcessor {
public constructor( public constructor(

View File

@@ -26,6 +26,8 @@ import { OutgoingRequestProcessor } from "./OutgoingRequestProcessor";
/** /**
* RoomEncryptor: responsible for encrypting messages to a given room * RoomEncryptor: responsible for encrypting messages to a given room
*
* @internal
*/ */
export class RoomEncryptor { export class RoomEncryptor {
private readonly prefixedLogger: PrefixedLogger; private readonly prefixedLogger: PrefixedLogger;

View File

@@ -23,6 +23,8 @@ import { DeviceKeys } from "../client";
* Convert a {@link RustSdkCryptoJs.Device} to a {@link Device} * Convert a {@link RustSdkCryptoJs.Device} to a {@link Device}
* @param device - Rust Sdk device * @param device - Rust Sdk device
* @param userId - owner of the device * @param userId - owner of the device
*
* @internal
*/ */
export function rustDeviceToJsDevice(device: RustSdkCryptoJs.Device, userId: RustSdkCryptoJs.UserId): Device { export function rustDeviceToJsDevice(device: RustSdkCryptoJs.Device, userId: RustSdkCryptoJs.UserId): Device {
// Copy rust device keys to Device.keys // Copy rust device keys to Device.keys
@@ -84,6 +86,8 @@ export function rustDeviceToJsDevice(device: RustSdkCryptoJs.Device, userId: Rus
/** /**
* Convert {@link DeviceKeys} from `/keys/query` request to a `Map<string, Device>` * Convert {@link DeviceKeys} from `/keys/query` request to a `Map<string, Device>`
* @param deviceKeys - Device keys object to convert * @param deviceKeys - Device keys object to convert
*
* @internal
*/ */
export function deviceKeysToDeviceMap(deviceKeys: DeviceKeys): Map<string, Device> { export function deviceKeysToDeviceMap(deviceKeys: DeviceKeys): Map<string, Device> {
return new Map( return new Map(
@@ -97,6 +101,8 @@ type QueryDevice = DeviceKeys[keyof DeviceKeys];
/** /**
* Convert `/keys/query` {@link QueryDevice} device to {@link Device} * Convert `/keys/query` {@link QueryDevice} device to {@link Device}
* @param device - Device from `/keys/query` request * @param device - Device from `/keys/query` request
*
* @internal
*/ */
export function downloadDeviceToJsDevice(device: QueryDevice): Device { export function downloadDeviceToJsDevice(device: QueryDevice): Device {
const keys = new Map(Object.entries(device.keys)); const keys = new Map(Object.entries(device.keys));

View File

@@ -33,6 +33,8 @@ import { ICryptoCallbacks } from "../crypto";
* @param cryptoCallbacks - Crypto callbacks provided by the application * @param cryptoCallbacks - Crypto callbacks provided by the application
* @param storePrefix - the prefix to use on the indexeddbs created by rust-crypto. * @param storePrefix - the prefix to use on the indexeddbs created by rust-crypto.
* If unset, a memory store will be used. * If unset, a memory store will be used.
*
* @internal
*/ */
export async function initRustCrypto( export async function initRustCrypto(
http: MatrixHttpApi<IHttpOpts & { onlyData: true }>, http: MatrixHttpApi<IHttpOpts & { onlyData: true }>,

View File

@@ -58,6 +58,8 @@ import { TypedEventEmitter } from "../models/typed-event-emitter";
/** /**
* An implementation of {@link CryptoBackend} using the Rust matrix-sdk-crypto. * An implementation of {@link CryptoBackend} using the Rust matrix-sdk-crypto.
*
* @internal
*/ */
export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEventMap> implements CryptoBackend { export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEventMap> implements CryptoBackend {
public globalErrorOnUnknownDevices = false; public globalErrorOnUnknownDevices = false;

View File

@@ -21,6 +21,8 @@ import { ServerSideSecretStorage } from "../secret-storage";
* *
* @param secretStorage - The secret store using account data * @param secretStorage - The secret store using account data
* @returns True if the cross-signing keys are all stored and encrypted with the same secret storage key. * @returns True if the cross-signing keys are all stored and encrypted with the same secret storage key.
*
* @internal
*/ */
export async function secretStorageContainsCrossSigningKeys(secretStorage: ServerSideSecretStorage): Promise<boolean> { export async function secretStorageContainsCrossSigningKeys(secretStorage: ServerSideSecretStorage): Promise<boolean> {
// Check if the master cross-signing key is stored in secret storage // Check if the master cross-signing key is stored in secret storage

View File

@@ -33,6 +33,8 @@ import { OutgoingRequest, OutgoingRequestProcessor } from "./OutgoingRequestProc
/** /**
* An incoming, or outgoing, request to verify a user or a device via cross-signing. * An incoming, or outgoing, request to verify a user or a device via cross-signing.
*
* @internal
*/ */
export class RustVerificationRequest export class RustVerificationRequest
extends TypedEventEmitter<VerificationRequestEvent, VerificationRequestEventHandlerMap> extends TypedEventEmitter<VerificationRequestEvent, VerificationRequestEventHandlerMap>
@@ -357,6 +359,7 @@ export class RustVerificationRequest
} }
} }
/** @internal */
export class RustSASVerifier extends TypedEventEmitter<VerifierEvent, VerifierEventHandlerMap> implements Verifier { export class RustSASVerifier extends TypedEventEmitter<VerifierEvent, VerifierEventHandlerMap> implements Verifier {
/** A promise which completes when the verification completes (or rejects when it is cancelled/fails) */ /** A promise which completes when the verification completes (or rejects when it is cancelled/fails) */
private readonly completionPromise: Promise<void>; private readonly completionPromise: Promise<void>;
@@ -507,6 +510,8 @@ const verificationMethodsByIdentifier: Record<string, RustSdkCryptoJs.Verificati
* @param method - specced method identifier, for example `m.sas.v1`. * @param method - specced method identifier, for example `m.sas.v1`.
* @returns Rust-side `VerificationMethod` corresponding to `method`. * @returns Rust-side `VerificationMethod` corresponding to `method`.
* @throws An error if the method is unknown. * @throws An error if the method is unknown.
*
* @internal
*/ */
export function verificationMethodIdentifierToMethod(method: string): RustSdkCryptoJs.VerificationMethod { export function verificationMethodIdentifierToMethod(method: string): RustSdkCryptoJs.VerificationMethod {
const meth = verificationMethodsByIdentifier[method]; const meth = verificationMethodsByIdentifier[method];