Use new getCrossSigningKeyId
instead of old getCrossSigningId
(#10885)
* Use new `getCrossSigningKeyId` instead of old `getCrossSigningId` * Fix type error
This commit is contained in:
parent
77d18f1a43
commit
38c13509fd
5 changed files with 15 additions and 15 deletions
|
@ -289,7 +289,7 @@ export default class DeviceListener {
|
||||||
|
|
||||||
// cross signing isn't enabled - nag to enable it
|
// cross signing isn't enabled - nag to enable it
|
||||||
// There are 3 different toasts for:
|
// There are 3 different toasts for:
|
||||||
if (!cli.getCrossSigningId() && cli.getStoredCrossSigningForUser(cli.getUserId()!)) {
|
if (!(await crypto.getCrossSigningKeyId()) && cli.getStoredCrossSigningForUser(cli.getUserId()!)) {
|
||||||
// Cross-signing on account but this device doesn't trust the master key (verify this session)
|
// Cross-signing on account but this device doesn't trust the master key (verify this session)
|
||||||
showSetupEncryptionToast(SetupKind.VERIFY_THIS_SESSION);
|
showSetupEncryptionToast(SetupKind.VERIFY_THIS_SESSION);
|
||||||
this.checkKeyBackupStatus();
|
this.checkKeyBackupStatus();
|
||||||
|
|
|
@ -87,7 +87,7 @@ async function collectBugReport(opts: IOpts = {}, gzipLogs = true): Promise<Form
|
||||||
keys.push(`curve25519:${client.getDeviceCurve25519Key()}`);
|
keys.push(`curve25519:${client.getDeviceCurve25519Key()}`);
|
||||||
}
|
}
|
||||||
body.append("device_keys", keys.join(", "));
|
body.append("device_keys", keys.join(", "));
|
||||||
body.append("cross_signing_key", client.getCrossSigningId() ?? "n/a");
|
body.append("cross_signing_key", (await client.getCrypto()?.getCrossSigningKeyId()) ?? "n/a");
|
||||||
|
|
||||||
// add cross-signing status information
|
// add cross-signing status information
|
||||||
const crossSigning = client.crypto.crossSigningInfo;
|
const crossSigning = client.crypto.crossSigningInfo;
|
||||||
|
|
|
@ -150,7 +150,7 @@ export class SetupEncryptionStore extends EventEmitter {
|
||||||
}).catch(reject);
|
}).catch(reject);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (cli.getCrossSigningId()) {
|
if (await cli.getCrypto()?.getCrossSigningKeyId()) {
|
||||||
this.phase = Phase.Done;
|
this.phase = Phase.Done;
|
||||||
this.emit("update");
|
this.emit("update");
|
||||||
}
|
}
|
||||||
|
@ -164,9 +164,9 @@ export class SetupEncryptionStore extends EventEmitter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private onUserTrustStatusChanged = (userId: string): void => {
|
private onUserTrustStatusChanged = async (userId: string): Promise<void> => {
|
||||||
if (userId !== MatrixClientPeg.get().getUserId()) return;
|
if (userId !== MatrixClientPeg.get().getUserId()) return;
|
||||||
const publicKeysTrusted = MatrixClientPeg.get().getCrossSigningId();
|
const publicKeysTrusted = await MatrixClientPeg.get().getCrypto()?.getCrossSigningKeyId();
|
||||||
if (publicKeysTrusted) {
|
if (publicKeysTrusted) {
|
||||||
this.phase = Phase.Done;
|
this.phase = Phase.Done;
|
||||||
this.emit("update");
|
this.emit("update");
|
||||||
|
@ -177,7 +177,7 @@ export class SetupEncryptionStore extends EventEmitter {
|
||||||
this.setActiveVerificationRequest(request);
|
this.setActiveVerificationRequest(request);
|
||||||
};
|
};
|
||||||
|
|
||||||
public onVerificationRequestChange = (): void => {
|
public onVerificationRequestChange = async (): Promise<void> => {
|
||||||
if (this.verificationRequest?.cancelled) {
|
if (this.verificationRequest?.cancelled) {
|
||||||
this.verificationRequest.off(VerificationRequestEvent.Change, this.onVerificationRequestChange);
|
this.verificationRequest.off(VerificationRequestEvent.Change, this.onVerificationRequestChange);
|
||||||
this.verificationRequest = null;
|
this.verificationRequest = null;
|
||||||
|
@ -188,7 +188,7 @@ export class SetupEncryptionStore extends EventEmitter {
|
||||||
// At this point, the verification has finished, we just need to wait for
|
// At this point, the verification has finished, we just need to wait for
|
||||||
// cross signing to be ready to use, so wait for the user trust status to
|
// cross signing to be ready to use, so wait for the user trust status to
|
||||||
// change (or change to DONE if it's already ready).
|
// change (or change to DONE if it's already ready).
|
||||||
const publicKeysTrusted = MatrixClientPeg.get().getCrossSigningId();
|
const publicKeysTrusted = await MatrixClientPeg.get().getCrypto()?.getCrossSigningKeyId();
|
||||||
this.phase = publicKeysTrusted ? Phase.Done : Phase.Busy;
|
this.phase = publicKeysTrusted ? Phase.Done : Phase.Busy;
|
||||||
this.emit("update");
|
this.emit("update");
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import { User } from "matrix-js-sdk/src/models/user";
|
||||||
import { verificationMethods as VerificationMethods } from "matrix-js-sdk/src/crypto";
|
import { verificationMethods as VerificationMethods } from "matrix-js-sdk/src/crypto";
|
||||||
import { RoomMember } from "matrix-js-sdk/src/matrix";
|
import { RoomMember } from "matrix-js-sdk/src/matrix";
|
||||||
import { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
import { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
|
||||||
|
import { CrossSigningKey } from "matrix-js-sdk/src/crypto-api";
|
||||||
|
|
||||||
import { MatrixClientPeg } from "./MatrixClientPeg";
|
import { MatrixClientPeg } from "./MatrixClientPeg";
|
||||||
import dis from "./dispatcher/dispatcher";
|
import dis from "./dispatcher/dispatcher";
|
||||||
|
@ -33,10 +34,9 @@ import { findDMForUser } from "./utils/dm/findDMForUser";
|
||||||
|
|
||||||
async function enable4SIfNeeded(): Promise<boolean> {
|
async function enable4SIfNeeded(): Promise<boolean> {
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
if (!cli.isCryptoEnabled()) {
|
const crypto = cli.getCrypto();
|
||||||
return false;
|
if (!crypto) return false;
|
||||||
}
|
const usk = await crypto.getCrossSigningKeyId(CrossSigningKey.UserSigning);
|
||||||
const usk = cli.getCrossSigningId("user_signing");
|
|
||||||
if (!usk) {
|
if (!usk) {
|
||||||
await accessSecretStorage();
|
await accessSecretStorage();
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -80,6 +80,7 @@ describe("DeviceListener", () => {
|
||||||
getDeviceVerificationStatus: jest.fn().mockResolvedValue({
|
getDeviceVerificationStatus: jest.fn().mockResolvedValue({
|
||||||
crossSigningVerified: false,
|
crossSigningVerified: false,
|
||||||
}),
|
}),
|
||||||
|
getCrossSigningKeyId: jest.fn(),
|
||||||
getUserDeviceInfo: jest.fn().mockResolvedValue(new Map()),
|
getUserDeviceInfo: jest.fn().mockResolvedValue(new Map()),
|
||||||
isCrossSigningReady: jest.fn().mockResolvedValue(true),
|
isCrossSigningReady: jest.fn().mockResolvedValue(true),
|
||||||
isSecretStorageReady: jest.fn().mockResolvedValue(true),
|
isSecretStorageReady: jest.fn().mockResolvedValue(true),
|
||||||
|
@ -93,7 +94,6 @@ describe("DeviceListener", () => {
|
||||||
isVersionSupported: jest.fn().mockResolvedValue(true),
|
isVersionSupported: jest.fn().mockResolvedValue(true),
|
||||||
isInitialSyncComplete: jest.fn().mockReturnValue(true),
|
isInitialSyncComplete: jest.fn().mockReturnValue(true),
|
||||||
getKeyBackupEnabled: jest.fn(),
|
getKeyBackupEnabled: jest.fn(),
|
||||||
getCrossSigningId: jest.fn(),
|
|
||||||
getStoredCrossSigningForUser: jest.fn(),
|
getStoredCrossSigningForUser: jest.fn(),
|
||||||
waitForClientWellKnown: jest.fn(),
|
waitForClientWellKnown: jest.fn(),
|
||||||
isRoomEncrypted: jest.fn(),
|
isRoomEncrypted: jest.fn(),
|
||||||
|
@ -298,7 +298,7 @@ describe("DeviceListener", () => {
|
||||||
|
|
||||||
describe("when user does not have a cross signing id on this device", () => {
|
describe("when user does not have a cross signing id on this device", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockClient!.getCrossSigningId.mockReturnValue(null);
|
mockCrypto!.getCrossSigningKeyId.mockResolvedValue(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows verify session toast when account has cross signing", async () => {
|
it("shows verify session toast when account has cross signing", async () => {
|
||||||
|
@ -312,7 +312,7 @@ describe("DeviceListener", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("checks key backup status when when account has cross signing", async () => {
|
it("checks key backup status when when account has cross signing", async () => {
|
||||||
mockClient!.getCrossSigningId.mockReturnValue(null);
|
mockCrypto!.getCrossSigningKeyId.mockResolvedValue(null);
|
||||||
mockClient!.getStoredCrossSigningForUser.mockReturnValue(new CrossSigningInfo(userId));
|
mockClient!.getStoredCrossSigningForUser.mockReturnValue(new CrossSigningInfo(userId));
|
||||||
await createAndStart();
|
await createAndStart();
|
||||||
|
|
||||||
|
@ -322,7 +322,7 @@ describe("DeviceListener", () => {
|
||||||
|
|
||||||
describe("when user does have a cross signing id on this device", () => {
|
describe("when user does have a cross signing id on this device", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
mockClient!.getCrossSigningId.mockReturnValue("abc");
|
mockCrypto!.getCrossSigningKeyId.mockResolvedValue("abc");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows upgrade encryption toast when user has a key backup available", async () => {
|
it("shows upgrade encryption toast when user has a key backup available", async () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue