Merge pull request #6220 from matrix-org/t3chguy/ts/5.1

This commit is contained in:
Michael Telatynski 2021-06-24 15:23:59 +01:00 committed by GitHub
commit bc786cdf4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 56 additions and 55 deletions

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { ICryptoCallbacks, IDeviceTrustLevel, ISecretStorageKeyInfo } from 'matrix-js-sdk/src/matrix'; import { ICryptoCallbacks, ISecretStorageKeyInfo } from 'matrix-js-sdk/src/matrix';
import { MatrixClient } from 'matrix-js-sdk/src/client'; import { MatrixClient } from 'matrix-js-sdk/src/client';
import Modal from './Modal'; import Modal from './Modal';
import * as sdk from './index'; import * as sdk from './index';
@ -28,6 +28,7 @@ import AccessSecretStorageDialog from './components/views/dialogs/security/Acces
import RestoreKeyBackupDialog from './components/views/dialogs/security/RestoreKeyBackupDialog'; import RestoreKeyBackupDialog from './components/views/dialogs/security/RestoreKeyBackupDialog';
import SettingsStore from "./settings/SettingsStore"; import SettingsStore from "./settings/SettingsStore";
import SecurityCustomisations from "./customisations/Security"; import SecurityCustomisations from "./customisations/Security";
import { DeviceTrustLevel } from 'matrix-js-sdk/src/crypto/CrossSigning';
// This stores the secret storage private keys in memory for the JS SDK. This is // This stores the secret storage private keys in memory for the JS SDK. This is
// only meant to act as a cache to avoid prompting the user multiple times // only meant to act as a cache to avoid prompting the user multiple times
@ -244,7 +245,7 @@ async function onSecretRequested(
deviceId: string, deviceId: string,
requestId: string, requestId: string,
name: string, name: string,
deviceTrust: IDeviceTrustLevel, deviceTrust: DeviceTrustLevel,
): Promise<string> { ): Promise<string> {
console.log("onSecretRequested", userId, deviceId, requestId, name, deviceTrust); console.log("onSecretRequested", userId, deviceId, requestId, name, deviceTrust);
const client = MatrixClientPeg.get(); const client = MatrixClientPeg.get();

View file

@ -766,7 +766,7 @@ class VerificationExplorer extends React.PureComponent<IExplorerProps> {
render() { render() {
const cli = this.context; const cli = this.context;
const room = this.props.room; const room = this.props.room;
const inRoomChannel = cli.crypto._inRoomVerificationRequests; const inRoomChannel = cli.crypto.inRoomVerificationRequests;
const inRoomRequests = (inRoomChannel._requestsByRoomId || new Map()).get(room.roomId) || new Map(); const inRoomRequests = (inRoomChannel._requestsByRoomId || new Map()).get(room.roomId) || new Map();
return (<div> return (<div>

View file

@ -79,8 +79,8 @@ export default class CrossSigningPanel extends React.PureComponent {
async _getUpdatedStatus() { async _getUpdatedStatus() {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
const pkCache = cli.getCrossSigningCacheCallbacks(); const pkCache = cli.getCrossSigningCacheCallbacks();
const crossSigning = cli.crypto._crossSigningInfo; const crossSigning = cli.crypto.crossSigningInfo;
const secretStorage = cli.crypto._secretStorage; const secretStorage = cli.crypto.secretStorage;
const crossSigningPublicKeysOnDevice = crossSigning.getId(); const crossSigningPublicKeysOnDevice = crossSigning.getId();
const crossSigningPrivateKeysInStorage = await crossSigning.isStoredInSecretStorage(secretStorage); const crossSigningPrivateKeysInStorage = await crossSigning.isStoredInSecretStorage(secretStorage);
const masterPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("master")); const masterPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("master"));

View file

@ -131,7 +131,7 @@ export default class SecureBackupPanel extends React.PureComponent {
async _getUpdatedDiagnostics() { async _getUpdatedDiagnostics() {
const cli = MatrixClientPeg.get(); const cli = MatrixClientPeg.get();
const secretStorage = cli.crypto._secretStorage; const secretStorage = cli.crypto.secretStorage;
const backupKeyStored = !!(await cli.isKeyBackupKeyStored()); const backupKeyStored = !!(await cli.isKeyBackupKeyStored());
const backupKeyFromCache = await cli.crypto.getSessionBackupPrivateKey(); const backupKeyFromCache = await cli.crypto.getSessionBackupPrivateKey();

View file

@ -17,7 +17,7 @@ limitations under the License.
// The following interfaces take their names and member names from seshat and the spec // The following interfaces take their names and member names from seshat and the spec
/* eslint-disable camelcase */ /* eslint-disable camelcase */
export interface MatrixEvent { export interface IMatrixEvent {
type: string; type: string;
sender: string; sender: string;
content: {}; content: {};
@ -27,37 +27,37 @@ export interface MatrixEvent {
roomId: string; roomId: string;
} }
export interface MatrixProfile { export interface IMatrixProfile {
avatar_url: string; avatar_url: string;
displayname: string; displayname: string;
} }
export interface CrawlerCheckpoint { export interface ICrawlerCheckpoint {
roomId: string; roomId: string;
token: string; token: string;
fullCrawl?: boolean; fullCrawl?: boolean;
direction: string; direction: string;
} }
export interface ResultContext { export interface IResultContext {
events_before: [MatrixEvent]; events_before: [IMatrixEvent];
events_after: [MatrixEvent]; events_after: [IMatrixEvent];
profile_info: Map<string, MatrixProfile>; profile_info: Map<string, IMatrixProfile>;
} }
export interface ResultsElement { export interface IResultsElement {
rank: number; rank: number;
result: MatrixEvent; result: IMatrixEvent;
context: ResultContext; context: IResultContext;
} }
export interface SearchResult { export interface ISearchResult {
count: number; count: number;
results: [ResultsElement]; results: [IResultsElement];
highlights: [string]; highlights: [string];
} }
export interface SearchArgs { export interface ISearchArgs {
search_term: string; search_term: string;
before_limit: number; before_limit: number;
after_limit: number; after_limit: number;
@ -65,19 +65,19 @@ export interface SearchArgs {
room_id?: string; room_id?: string;
} }
export interface EventAndProfile { export interface IEventAndProfile {
event: MatrixEvent; event: IMatrixEvent;
profile: MatrixProfile; profile: IMatrixProfile;
} }
export interface LoadArgs { export interface ILoadArgs {
roomId: string; roomId: string;
limit: number; limit: number;
fromEvent?: string; fromEvent?: string;
direction?: string; direction?: string;
} }
export interface IndexStats { export interface IIndexStats {
size: number; size: number;
eventCount: number; eventCount: number;
roomCount: number; roomCount: number;
@ -119,13 +119,13 @@ export default abstract class BaseEventIndexManager {
* Queue up an event to be added to the index. * Queue up an event to be added to the index.
* *
* @param {MatrixEvent} ev The event that should be added to the index. * @param {MatrixEvent} ev The event that should be added to the index.
* @param {MatrixProfile} profile The profile of the event sender at the * @param {IMatrixProfile} profile The profile of the event sender at the
* time of the event receival. * time of the event receival.
* *
* @return {Promise} A promise that will resolve when the was queued up for * @return {Promise} A promise that will resolve when the was queued up for
* addition. * addition.
*/ */
async addEventToIndex(ev: MatrixEvent, profile: MatrixProfile): Promise<void> { async addEventToIndex(ev: IMatrixEvent, profile: IMatrixProfile): Promise<void> {
throw new Error("Unimplemented"); throw new Error("Unimplemented");
} }
@ -160,10 +160,10 @@ export default abstract class BaseEventIndexManager {
/** /**
* Get statistical information of the index. * Get statistical information of the index.
* *
* @return {Promise<IndexStats>} A promise that will resolve to the index * @return {Promise<IIndexStats>} A promise that will resolve to the index
* statistics. * statistics.
*/ */
async getStats(): Promise<IndexStats> { async getStats(): Promise<IIndexStats> {
throw new Error("Unimplemented"); throw new Error("Unimplemented");
} }
@ -203,13 +203,13 @@ export default abstract class BaseEventIndexManager {
/** /**
* Search the event index using the given term for matching events. * Search the event index using the given term for matching events.
* *
* @param {SearchArgs} searchArgs The search configuration for the search, * @param {ISearchArgs} searchArgs The search configuration for the search,
* sets the search term and determines the search result contents. * sets the search term and determines the search result contents.
* *
* @return {Promise<[SearchResult]>} A promise that will resolve to an array * @return {Promise<[ISearchResult]>} A promise that will resolve to an array
* of search results once the search is done. * of search results once the search is done.
*/ */
async searchEventIndex(searchArgs: SearchArgs): Promise<SearchResult> { async searchEventIndex(searchArgs: ISearchArgs): Promise<ISearchResult> {
throw new Error("Unimplemented"); throw new Error("Unimplemented");
} }
@ -218,12 +218,12 @@ export default abstract class BaseEventIndexManager {
* *
* This is used to add a batch of events to the index. * This is used to add a batch of events to the index.
* *
* @param {[EventAndProfile]} events The list of events and profiles that * @param {[IEventAndProfile]} events The list of events and profiles that
* should be added to the event index. * should be added to the event index.
* @param {[CrawlerCheckpoint]} checkpoint A new crawler checkpoint that * @param {[ICrawlerCheckpoint]} checkpoint A new crawler checkpoint that
* should be stored in the index which should be used to continue crawling * should be stored in the index which should be used to continue crawling
* the room. * the room.
* @param {[CrawlerCheckpoint]} oldCheckpoint The checkpoint that was used * @param {[ICrawlerCheckpoint]} oldCheckpoint The checkpoint that was used
* to fetch the current batch of events. This checkpoint will be removed * to fetch the current batch of events. This checkpoint will be removed
* from the index. * from the index.
* *
@ -231,9 +231,9 @@ export default abstract class BaseEventIndexManager {
* were already added to the index, false otherwise. * were already added to the index, false otherwise.
*/ */
async addHistoricEvents( async addHistoricEvents(
events: [EventAndProfile], events: IEventAndProfile[],
checkpoint: CrawlerCheckpoint | null, checkpoint: ICrawlerCheckpoint | null,
oldCheckpoint: CrawlerCheckpoint | null, oldCheckpoint: ICrawlerCheckpoint | null,
): Promise<boolean> { ): Promise<boolean> {
throw new Error("Unimplemented"); throw new Error("Unimplemented");
} }
@ -241,36 +241,36 @@ export default abstract class BaseEventIndexManager {
/** /**
* Add a new crawler checkpoint to the index. * Add a new crawler checkpoint to the index.
* *
* @param {CrawlerCheckpoint} checkpoint The checkpoint that should be added * @param {ICrawlerCheckpoint} checkpoint The checkpoint that should be added
* to the index. * to the index.
* *
* @return {Promise} A promise that will resolve once the checkpoint has * @return {Promise} A promise that will resolve once the checkpoint has
* been stored. * been stored.
*/ */
async addCrawlerCheckpoint(checkpoint: CrawlerCheckpoint): Promise<void> { async addCrawlerCheckpoint(checkpoint: ICrawlerCheckpoint): Promise<void> {
throw new Error("Unimplemented"); throw new Error("Unimplemented");
} }
/** /**
* Add a new crawler checkpoint to the index. * Add a new crawler checkpoint to the index.
* *
* @param {CrawlerCheckpoint} checkpoint The checkpoint that should be * @param {ICrawlerCheckpoint} checkpoint The checkpoint that should be
* removed from the index. * removed from the index.
* *
* @return {Promise} A promise that will resolve once the checkpoint has * @return {Promise} A promise that will resolve once the checkpoint has
* been removed. * been removed.
*/ */
async removeCrawlerCheckpoint(checkpoint: CrawlerCheckpoint): Promise<void> { async removeCrawlerCheckpoint(checkpoint: ICrawlerCheckpoint): Promise<void> {
throw new Error("Unimplemented"); throw new Error("Unimplemented");
} }
/** /**
* Load the stored checkpoints from the index. * Load the stored checkpoints from the index.
* *
* @return {Promise<[CrawlerCheckpoint]>} A promise that will resolve to an * @return {Promise<[ICrawlerCheckpoint]>} A promise that will resolve to an
* array of crawler checkpoints once they have been loaded from the index. * array of crawler checkpoints once they have been loaded from the index.
*/ */
async loadCheckpoints(): Promise<[CrawlerCheckpoint]> { async loadCheckpoints(): Promise<ICrawlerCheckpoint[]> {
throw new Error("Unimplemented"); throw new Error("Unimplemented");
} }
@ -286,11 +286,11 @@ export default abstract class BaseEventIndexManager {
* @param {string} args.direction The direction to which we should continue * @param {string} args.direction The direction to which we should continue
* loading events from. This is used only if fromEvent is used as well. * loading events from. This is used only if fromEvent is used as well.
* *
* @return {Promise<[EventAndProfile]>} A promise that will resolve to an * @return {Promise<[IEventAndProfile]>} A promise that will resolve to an
* array of Matrix events that contain mxc URLs accompanied with the * array of Matrix events that contain mxc URLs accompanied with the
* historic profile of the sender. * historic profile of the sender.
*/ */
async loadFileEvents(args: LoadArgs): Promise<[EventAndProfile]> { async loadFileEvents(args: ILoadArgs): Promise<IEventAndProfile[]> {
throw new Error("Unimplemented"); throw new Error("Unimplemented");
} }

View file

@ -28,7 +28,7 @@ import { MatrixClientPeg } from "../MatrixClientPeg";
import { sleep } from "../utils/promise"; import { sleep } from "../utils/promise";
import SettingsStore from "../settings/SettingsStore"; import SettingsStore from "../settings/SettingsStore";
import { SettingLevel } from "../settings/SettingLevel"; import { SettingLevel } from "../settings/SettingLevel";
import {CrawlerCheckpoint, LoadArgs, SearchArgs} from "./BaseEventIndexManager"; import { ICrawlerCheckpoint, ILoadArgs, ISearchArgs } from "./BaseEventIndexManager";
// The time in ms that the crawler will wait loop iterations if there // The time in ms that the crawler will wait loop iterations if there
// have not been any checkpoints to consume in the last iteration. // have not been any checkpoints to consume in the last iteration.
@ -45,9 +45,9 @@ interface ICrawler {
* Event indexing class that wraps the platform specific event indexing. * Event indexing class that wraps the platform specific event indexing.
*/ */
export default class EventIndex extends EventEmitter { export default class EventIndex extends EventEmitter {
private crawlerCheckpoints: CrawlerCheckpoint[] = []; private crawlerCheckpoints: ICrawlerCheckpoint[] = [];
private crawler: ICrawler = null; private crawler: ICrawler = null;
private currentCheckpoint: CrawlerCheckpoint = null; private currentCheckpoint: ICrawlerCheckpoint = null;
public async init() { public async init() {
const indexManager = PlatformPeg.get().getEventIndexingManager(); const indexManager = PlatformPeg.get().getEventIndexingManager();
@ -111,14 +111,14 @@ export default class EventIndex extends EventEmitter {
const timeline = room.getLiveTimeline(); const timeline = room.getLiveTimeline();
const token = timeline.getPaginationToken("b"); const token = timeline.getPaginationToken("b");
const backCheckpoint: CrawlerCheckpoint = { const backCheckpoint: ICrawlerCheckpoint = {
roomId: room.roomId, roomId: room.roomId,
token: token, token: token,
direction: "b", direction: "b",
fullCrawl: true, fullCrawl: true,
}; };
const forwardCheckpoint: CrawlerCheckpoint = { const forwardCheckpoint: ICrawlerCheckpoint = {
roomId: room.roomId, roomId: room.roomId,
token: token, token: token,
direction: "f", direction: "f",
@ -668,13 +668,13 @@ export default class EventIndex extends EventEmitter {
/** /**
* Search the event index using the given term for matching events. * Search the event index using the given term for matching events.
* *
* @param {SearchArgs} searchArgs The search configuration for the search, * @param {ISearchArgs} searchArgs The search configuration for the search,
* sets the search term and determines the search result contents. * sets the search term and determines the search result contents.
* *
* @return {Promise<[SearchResult]>} A promise that will resolve to an array * @return {Promise<[SearchResult]>} A promise that will resolve to an array
* of search results once the search is done. * of search results once the search is done.
*/ */
public async search(searchArgs: SearchArgs) { public async search(searchArgs: ISearchArgs) {
const indexManager = PlatformPeg.get().getEventIndexingManager(); const indexManager = PlatformPeg.get().getEventIndexingManager();
return indexManager.searchEventIndex(searchArgs); return indexManager.searchEventIndex(searchArgs);
} }
@ -709,7 +709,7 @@ export default class EventIndex extends EventEmitter {
const client = MatrixClientPeg.get(); const client = MatrixClientPeg.get();
const indexManager = PlatformPeg.get().getEventIndexingManager(); const indexManager = PlatformPeg.get().getEventIndexingManager();
const loadArgs: LoadArgs = { const loadArgs: ILoadArgs = {
roomId: room.roomId, roomId: room.roomId,
limit: limit, limit: limit,
}; };

View file

@ -86,8 +86,8 @@ async function collectBugReport(opts: IOpts = {}, gzipLogs = true) {
body.append('cross_signing_key', client.getCrossSigningId()); body.append('cross_signing_key', client.getCrossSigningId());
// add cross-signing status information // add cross-signing status information
const crossSigning = client.crypto._crossSigningInfo; const crossSigning = client.crypto.crossSigningInfo;
const secretStorage = client.crypto._secretStorage; const secretStorage = client.crypto.secretStorage;
body.append("cross_signing_ready", String(await client.isCrossSigningReady())); body.append("cross_signing_ready", String(await client.isCrossSigningReady()));
body.append("cross_signing_supported_by_hs", body.append("cross_signing_supported_by_hs",