You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Move crypto classes into a separate namespace (#3385)
* Move crypto classes into a separate namespace * Add in re-exports for backwards compatibility * Update src/matrix.ts
This commit is contained in:
committed by
GitHub
parent
b5d544df68
commit
3f48a954d8
@@ -2577,7 +2577,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|||||||
* "master", "self_signing", or "user_signing". Defaults to "master".
|
* "master", "self_signing", or "user_signing". Defaults to "master".
|
||||||
*
|
*
|
||||||
* @returns the key ID
|
* @returns the key ID
|
||||||
* @deprecated prefer {@link CryptoApi#getCrossSigningKeyId}
|
* @deprecated prefer {@link Crypto.CryptoApi#getCrossSigningKeyId}
|
||||||
*/
|
*/
|
||||||
public getCrossSigningId(type: CrossSigningKey | string = CrossSigningKey.Master): string | null {
|
public getCrossSigningId(type: CrossSigningKey | string = CrossSigningKey.Master): string | null {
|
||||||
if (!this.crypto) {
|
if (!this.crypto) {
|
||||||
@@ -2624,7 +2624,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
|||||||
* @param userId - The ID of the user whose devices is to be checked.
|
* @param userId - The ID of the user whose devices is to be checked.
|
||||||
* @param deviceId - The ID of the device to check
|
* @param deviceId - The ID of the device to check
|
||||||
*
|
*
|
||||||
* @deprecated Use {@link CryptoApi.getDeviceVerificationStatus | `CryptoApi.getDeviceVerificationStatus`}
|
* @deprecated Use {@link Crypto.CryptoApi.getDeviceVerificationStatus | `CryptoApi.getDeviceVerificationStatus`}
|
||||||
*/
|
*/
|
||||||
public checkDeviceTrust(userId: string, deviceId: string): DeviceTrustLevel {
|
public checkDeviceTrust(userId: string, deviceId: string): DeviceTrustLevel {
|
||||||
if (!this.crypto) {
|
if (!this.crypto) {
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ export interface CryptoApi {
|
|||||||
/**
|
/**
|
||||||
* Return whether we trust other user's signatures of their devices.
|
* Return whether we trust other user's signatures of their devices.
|
||||||
*
|
*
|
||||||
* @see {@link CryptoApi#setTrustCrossSignedDevices}
|
* @see {@link Crypto.CryptoApi#setTrustCrossSignedDevices}
|
||||||
*
|
*
|
||||||
* @returns `true` if we trust cross-signed devices, otherwise `false`.
|
* @returns `true` if we trust cross-signed devices, otherwise `false`.
|
||||||
*/
|
*/
|
||||||
@@ -252,7 +252,7 @@ export class DeviceVerificationStatus {
|
|||||||
* A device is "verified" if either:
|
* A device is "verified" if either:
|
||||||
* * it has been manually marked as such via {@link MatrixClient#setDeviceVerified}.
|
* * it has been manually marked as such via {@link MatrixClient#setDeviceVerified}.
|
||||||
* * it has been cross-signed with a verified signing key, **and** the client has been configured to trust
|
* * it has been cross-signed with a verified signing key, **and** the client has been configured to trust
|
||||||
* cross-signed devices via {@link CryptoApi#setTrustCrossSignedDevices}.
|
* cross-signed devices via {@link Crypto.CryptoApi#setTrustCrossSignedDevices}.
|
||||||
*
|
*
|
||||||
* @returns true if this device is verified via any means.
|
* @returns true if this device is verified via any means.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -611,7 +611,7 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link CryptoApi#getTrustCrossSignedDevices}.
|
* @deprecated Use {@link Crypto.CryptoApi#getTrustCrossSignedDevices}.
|
||||||
*/
|
*/
|
||||||
public getCryptoTrustCrossSignedDevices(): boolean {
|
public getCryptoTrustCrossSignedDevices(): boolean {
|
||||||
return this.trustCrossSignedDevices;
|
return this.trustCrossSignedDevices;
|
||||||
@@ -641,7 +641,7 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link CryptoApi#setTrustCrossSignedDevices}.
|
* @deprecated Use {@link Crypto.CryptoApi#setTrustCrossSignedDevices}.
|
||||||
*/
|
*/
|
||||||
public setCryptoTrustCrossSignedDevices(val: boolean): void {
|
public setCryptoTrustCrossSignedDevices(val: boolean): void {
|
||||||
this.setTrustCrossSignedDevices(val);
|
this.setTrustCrossSignedDevices(val);
|
||||||
@@ -1473,7 +1473,7 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link CryptoApi.getDeviceVerificationStatus}.
|
* @deprecated Use {@link Crypto.CryptoApi.getDeviceVerificationStatus}.
|
||||||
*/
|
*/
|
||||||
public checkDeviceTrust(userId: string, deviceId: string): DeviceTrustLevel {
|
public checkDeviceTrust(userId: string, deviceId: string): DeviceTrustLevel {
|
||||||
const device = this.deviceList.getStoredDevice(userId, deviceId);
|
const device = this.deviceList.getStoredDevice(userId, deviceId);
|
||||||
@@ -1486,7 +1486,7 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
|
|||||||
* @param userId - The ID of the user whose devices is to be checked.
|
* @param userId - The ID of the user whose devices is to be checked.
|
||||||
* @param device - The device info object to check
|
* @param device - The device info object to check
|
||||||
*
|
*
|
||||||
* @deprecated Use {@link CryptoApi.getDeviceVerificationStatus}.
|
* @deprecated Use {@link Crypto.CryptoApi.getDeviceVerificationStatus}.
|
||||||
*/
|
*/
|
||||||
public checkDeviceInfoTrust(userId: string, device?: DeviceInfo): DeviceTrustLevel {
|
public checkDeviceInfoTrust(userId: string, device?: DeviceInfo): DeviceTrustLevel {
|
||||||
const trustedLocally = !!device?.isVerified();
|
const trustedLocally = !!device?.isVerified();
|
||||||
@@ -1835,7 +1835,7 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
|
|||||||
*
|
*
|
||||||
* @param value - whether to blacklist all unverified devices by default
|
* @param value - whether to blacklist all unverified devices by default
|
||||||
*
|
*
|
||||||
* @deprecated Set {@link CryptoApi#globalBlacklistUnverifiedDevices | CryptoApi.globalBlacklistUnverifiedDevices} directly.
|
* @deprecated Set {@link Crypto.CryptoApi#globalBlacklistUnverifiedDevices | CryptoApi.globalBlacklistUnverifiedDevices} directly.
|
||||||
*/
|
*/
|
||||||
public setGlobalBlacklistUnverifiedDevices(value: boolean): void {
|
public setGlobalBlacklistUnverifiedDevices(value: boolean): void {
|
||||||
this.globalBlacklistUnverifiedDevices = value;
|
this.globalBlacklistUnverifiedDevices = value;
|
||||||
@@ -1844,7 +1844,7 @@ export class Crypto extends TypedEventEmitter<CryptoEvent, CryptoEventHandlerMap
|
|||||||
/**
|
/**
|
||||||
* @returns whether to blacklist all unverified devices by default
|
* @returns whether to blacklist all unverified devices by default
|
||||||
*
|
*
|
||||||
* @deprecated Reference {@link CryptoApi#globalBlacklistUnverifiedDevices | CryptoApi.globalBlacklistUnverifiedDevices} directly.
|
* @deprecated Reference {@link Crypto.CryptoApi#globalBlacklistUnverifiedDevices | CryptoApi.globalBlacklistUnverifiedDevices} directly.
|
||||||
*/
|
*/
|
||||||
public getGlobalBlacklistUnverifiedDevices(): boolean {
|
public getGlobalBlacklistUnverifiedDevices(): boolean {
|
||||||
return this.globalBlacklistUnverifiedDevices;
|
return this.globalBlacklistUnverifiedDevices;
|
||||||
|
|||||||
@@ -64,10 +64,30 @@ export { createNewMatrixCall } from "./webrtc/call";
|
|||||||
export type { MatrixCall } from "./webrtc/call";
|
export type { MatrixCall } from "./webrtc/call";
|
||||||
export { GroupCallEvent, GroupCallIntent, GroupCallState, GroupCallType } from "./webrtc/groupCall";
|
export { GroupCallEvent, GroupCallIntent, GroupCallState, GroupCallType } from "./webrtc/groupCall";
|
||||||
export type { GroupCall } from "./webrtc/groupCall";
|
export type { GroupCall } from "./webrtc/groupCall";
|
||||||
export type { CryptoApi } from "./crypto-api";
|
|
||||||
export { DeviceVerificationStatus } from "./crypto-api";
|
|
||||||
export { CryptoEvent } from "./crypto";
|
export { CryptoEvent } from "./crypto";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Types supporting cryptography.
|
||||||
|
*
|
||||||
|
* The most important is {@link Crypto.CryptoApi}, an instance of which can be retrieved via
|
||||||
|
* {@link MatrixClient.getCrypto}.
|
||||||
|
*/
|
||||||
|
export * as Crypto from "./crypto-api";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Backwards compatibility re-export
|
||||||
|
* @internal
|
||||||
|
* @deprecated use {@link Crypto.CryptoApi}
|
||||||
|
*/
|
||||||
|
export type { CryptoApi } from "./crypto-api";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Backwards compatibility re-export
|
||||||
|
* @internal
|
||||||
|
* @deprecated use {@link Crypto.DeviceVerificationStatus}
|
||||||
|
*/
|
||||||
|
export { DeviceVerificationStatus } from "./crypto-api";
|
||||||
|
|
||||||
let cryptoStoreFactory = (): CryptoStore => new MemoryCryptoStore();
|
let cryptoStoreFactory = (): CryptoStore => new MemoryCryptoStore();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export type DeviceMap = Map<string, Map<string, Device>>;
|
|||||||
type DeviceParameters = Pick<Device, "deviceId" | "userId" | "algorithms" | "keys"> & Partial<Device>;
|
type DeviceParameters = Pick<Device, "deviceId" | "userId" | "algorithms" | "keys"> & Partial<Device>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information on a user's device, as returned by {@link CryptoApi.getUserDeviceInfo}.
|
* Information on a user's device, as returned by {@link Crypto.CryptoApi.getUserDeviceInfo}.
|
||||||
*/
|
*/
|
||||||
export class Device {
|
export class Device {
|
||||||
/** id of the device */
|
/** id of the device */
|
||||||
|
|||||||
Reference in New Issue
Block a user