mirror of
https://github.com/element-hq/element-web
synced 2024-11-23 09:46:09 +03:00
Merge pull request #6220 from matrix-org/t3chguy/ts/5.1
This commit is contained in:
commit
bc786cdf4a
7 changed files with 56 additions and 55 deletions
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
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 Modal from './Modal';
|
||||
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 SettingsStore from "./settings/SettingsStore";
|
||||
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
|
||||
// only meant to act as a cache to avoid prompting the user multiple times
|
||||
|
@ -244,7 +245,7 @@ async function onSecretRequested(
|
|||
deviceId: string,
|
||||
requestId: string,
|
||||
name: string,
|
||||
deviceTrust: IDeviceTrustLevel,
|
||||
deviceTrust: DeviceTrustLevel,
|
||||
): Promise<string> {
|
||||
console.log("onSecretRequested", userId, deviceId, requestId, name, deviceTrust);
|
||||
const client = MatrixClientPeg.get();
|
||||
|
|
|
@ -766,7 +766,7 @@ class VerificationExplorer extends React.PureComponent<IExplorerProps> {
|
|||
render() {
|
||||
const cli = this.context;
|
||||
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();
|
||||
|
||||
return (<div>
|
||||
|
|
|
@ -79,8 +79,8 @@ export default class CrossSigningPanel extends React.PureComponent {
|
|||
async _getUpdatedStatus() {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const pkCache = cli.getCrossSigningCacheCallbacks();
|
||||
const crossSigning = cli.crypto._crossSigningInfo;
|
||||
const secretStorage = cli.crypto._secretStorage;
|
||||
const crossSigning = cli.crypto.crossSigningInfo;
|
||||
const secretStorage = cli.crypto.secretStorage;
|
||||
const crossSigningPublicKeysOnDevice = crossSigning.getId();
|
||||
const crossSigningPrivateKeysInStorage = await crossSigning.isStoredInSecretStorage(secretStorage);
|
||||
const masterPrivateKeyCached = !!(pkCache && await pkCache.getCrossSigningKeyCache("master"));
|
||||
|
|
|
@ -131,7 +131,7 @@ export default class SecureBackupPanel extends React.PureComponent {
|
|||
|
||||
async _getUpdatedDiagnostics() {
|
||||
const cli = MatrixClientPeg.get();
|
||||
const secretStorage = cli.crypto._secretStorage;
|
||||
const secretStorage = cli.crypto.secretStorage;
|
||||
|
||||
const backupKeyStored = !!(await cli.isKeyBackupKeyStored());
|
||||
const backupKeyFromCache = await cli.crypto.getSessionBackupPrivateKey();
|
||||
|
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
|||
// The following interfaces take their names and member names from seshat and the spec
|
||||
/* eslint-disable camelcase */
|
||||
|
||||
export interface MatrixEvent {
|
||||
export interface IMatrixEvent {
|
||||
type: string;
|
||||
sender: string;
|
||||
content: {};
|
||||
|
@ -27,37 +27,37 @@ export interface MatrixEvent {
|
|||
roomId: string;
|
||||
}
|
||||
|
||||
export interface MatrixProfile {
|
||||
export interface IMatrixProfile {
|
||||
avatar_url: string;
|
||||
displayname: string;
|
||||
}
|
||||
|
||||
export interface CrawlerCheckpoint {
|
||||
export interface ICrawlerCheckpoint {
|
||||
roomId: string;
|
||||
token: string;
|
||||
fullCrawl?: boolean;
|
||||
direction: string;
|
||||
}
|
||||
|
||||
export interface ResultContext {
|
||||
events_before: [MatrixEvent];
|
||||
events_after: [MatrixEvent];
|
||||
profile_info: Map<string, MatrixProfile>;
|
||||
export interface IResultContext {
|
||||
events_before: [IMatrixEvent];
|
||||
events_after: [IMatrixEvent];
|
||||
profile_info: Map<string, IMatrixProfile>;
|
||||
}
|
||||
|
||||
export interface ResultsElement {
|
||||
export interface IResultsElement {
|
||||
rank: number;
|
||||
result: MatrixEvent;
|
||||
context: ResultContext;
|
||||
result: IMatrixEvent;
|
||||
context: IResultContext;
|
||||
}
|
||||
|
||||
export interface SearchResult {
|
||||
export interface ISearchResult {
|
||||
count: number;
|
||||
results: [ResultsElement];
|
||||
results: [IResultsElement];
|
||||
highlights: [string];
|
||||
}
|
||||
|
||||
export interface SearchArgs {
|
||||
export interface ISearchArgs {
|
||||
search_term: string;
|
||||
before_limit: number;
|
||||
after_limit: number;
|
||||
|
@ -65,19 +65,19 @@ export interface SearchArgs {
|
|||
room_id?: string;
|
||||
}
|
||||
|
||||
export interface EventAndProfile {
|
||||
event: MatrixEvent;
|
||||
profile: MatrixProfile;
|
||||
export interface IEventAndProfile {
|
||||
event: IMatrixEvent;
|
||||
profile: IMatrixProfile;
|
||||
}
|
||||
|
||||
export interface LoadArgs {
|
||||
export interface ILoadArgs {
|
||||
roomId: string;
|
||||
limit: number;
|
||||
fromEvent?: string;
|
||||
direction?: string;
|
||||
}
|
||||
|
||||
export interface IndexStats {
|
||||
export interface IIndexStats {
|
||||
size: number;
|
||||
eventCount: number;
|
||||
roomCount: number;
|
||||
|
@ -119,13 +119,13 @@ export default abstract class BaseEventIndexManager {
|
|||
* Queue up an event to 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.
|
||||
*
|
||||
* @return {Promise} A promise that will resolve when the was queued up for
|
||||
* addition.
|
||||
*/
|
||||
async addEventToIndex(ev: MatrixEvent, profile: MatrixProfile): Promise<void> {
|
||||
async addEventToIndex(ev: IMatrixEvent, profile: IMatrixProfile): Promise<void> {
|
||||
throw new Error("Unimplemented");
|
||||
}
|
||||
|
||||
|
@ -160,10 +160,10 @@ export default abstract class BaseEventIndexManager {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
async getStats(): Promise<IndexStats> {
|
||||
async getStats(): Promise<IIndexStats> {
|
||||
throw new Error("Unimplemented");
|
||||
}
|
||||
|
||||
|
@ -203,13 +203,13 @@ export default abstract class BaseEventIndexManager {
|
|||
/**
|
||||
* 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.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
async searchEventIndex(searchArgs: SearchArgs): Promise<SearchResult> {
|
||||
async searchEventIndex(searchArgs: ISearchArgs): Promise<ISearchResult> {
|
||||
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.
|
||||
*
|
||||
* @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.
|
||||
* @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
|
||||
* 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
|
||||
* from the index.
|
||||
*
|
||||
|
@ -231,9 +231,9 @@ export default abstract class BaseEventIndexManager {
|
|||
* were already added to the index, false otherwise.
|
||||
*/
|
||||
async addHistoricEvents(
|
||||
events: [EventAndProfile],
|
||||
checkpoint: CrawlerCheckpoint | null,
|
||||
oldCheckpoint: CrawlerCheckpoint | null,
|
||||
events: IEventAndProfile[],
|
||||
checkpoint: ICrawlerCheckpoint | null,
|
||||
oldCheckpoint: ICrawlerCheckpoint | null,
|
||||
): Promise<boolean> {
|
||||
throw new Error("Unimplemented");
|
||||
}
|
||||
|
@ -241,36 +241,36 @@ export default abstract class BaseEventIndexManager {
|
|||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return {Promise} A promise that will resolve once the checkpoint has
|
||||
* been stored.
|
||||
*/
|
||||
async addCrawlerCheckpoint(checkpoint: CrawlerCheckpoint): Promise<void> {
|
||||
async addCrawlerCheckpoint(checkpoint: ICrawlerCheckpoint): Promise<void> {
|
||||
throw new Error("Unimplemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return {Promise} A promise that will resolve once the checkpoint has
|
||||
* been removed.
|
||||
*/
|
||||
async removeCrawlerCheckpoint(checkpoint: CrawlerCheckpoint): Promise<void> {
|
||||
async removeCrawlerCheckpoint(checkpoint: ICrawlerCheckpoint): Promise<void> {
|
||||
throw new Error("Unimplemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
async loadCheckpoints(): Promise<[CrawlerCheckpoint]> {
|
||||
async loadCheckpoints(): Promise<ICrawlerCheckpoint[]> {
|
||||
throw new Error("Unimplemented");
|
||||
}
|
||||
|
||||
|
@ -286,11 +286,11 @@ export default abstract class BaseEventIndexManager {
|
|||
* @param {string} args.direction The direction to which we should continue
|
||||
* 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
|
||||
* historic profile of the sender.
|
||||
*/
|
||||
async loadFileEvents(args: LoadArgs): Promise<[EventAndProfile]> {
|
||||
async loadFileEvents(args: ILoadArgs): Promise<IEventAndProfile[]> {
|
||||
throw new Error("Unimplemented");
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import { MatrixClientPeg } from "../MatrixClientPeg";
|
|||
import { sleep } from "../utils/promise";
|
||||
import SettingsStore from "../settings/SettingsStore";
|
||||
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
|
||||
// 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.
|
||||
*/
|
||||
export default class EventIndex extends EventEmitter {
|
||||
private crawlerCheckpoints: CrawlerCheckpoint[] = [];
|
||||
private crawlerCheckpoints: ICrawlerCheckpoint[] = [];
|
||||
private crawler: ICrawler = null;
|
||||
private currentCheckpoint: CrawlerCheckpoint = null;
|
||||
private currentCheckpoint: ICrawlerCheckpoint = null;
|
||||
|
||||
public async init() {
|
||||
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
||||
|
@ -111,14 +111,14 @@ export default class EventIndex extends EventEmitter {
|
|||
const timeline = room.getLiveTimeline();
|
||||
const token = timeline.getPaginationToken("b");
|
||||
|
||||
const backCheckpoint: CrawlerCheckpoint = {
|
||||
const backCheckpoint: ICrawlerCheckpoint = {
|
||||
roomId: room.roomId,
|
||||
token: token,
|
||||
direction: "b",
|
||||
fullCrawl: true,
|
||||
};
|
||||
|
||||
const forwardCheckpoint: CrawlerCheckpoint = {
|
||||
const forwardCheckpoint: ICrawlerCheckpoint = {
|
||||
roomId: room.roomId,
|
||||
token: token,
|
||||
direction: "f",
|
||||
|
@ -668,13 +668,13 @@ export default class EventIndex extends EventEmitter {
|
|||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return {Promise<[SearchResult]>} A promise that will resolve to an array
|
||||
* of search results once the search is done.
|
||||
*/
|
||||
public async search(searchArgs: SearchArgs) {
|
||||
public async search(searchArgs: ISearchArgs) {
|
||||
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
||||
return indexManager.searchEventIndex(searchArgs);
|
||||
}
|
||||
|
@ -709,7 +709,7 @@ export default class EventIndex extends EventEmitter {
|
|||
const client = MatrixClientPeg.get();
|
||||
const indexManager = PlatformPeg.get().getEventIndexingManager();
|
||||
|
||||
const loadArgs: LoadArgs = {
|
||||
const loadArgs: ILoadArgs = {
|
||||
roomId: room.roomId,
|
||||
limit: limit,
|
||||
};
|
||||
|
|
|
@ -86,8 +86,8 @@ async function collectBugReport(opts: IOpts = {}, gzipLogs = true) {
|
|||
body.append('cross_signing_key', client.getCrossSigningId());
|
||||
|
||||
// add cross-signing status information
|
||||
const crossSigning = client.crypto._crossSigningInfo;
|
||||
const secretStorage = client.crypto._secretStorage;
|
||||
const crossSigning = client.crypto.crossSigningInfo;
|
||||
const secretStorage = client.crypto.secretStorage;
|
||||
|
||||
body.append("cross_signing_ready", String(await client.isCrossSigningReady()));
|
||||
body.append("cross_signing_supported_by_hs",
|
||||
|
|
Loading…
Reference in a new issue