1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-23 22:42:10 +03:00

Add an extra consistency check in bootstrapCrossSigning (#4629)

* Add an extra consistency check in `bootstrapCrossSigning`

check that `importCrossSigningKeys` has actually worked

* Update src/rust-crypto/CrossSigningIdentity.ts

* declare type in @types, instead of in source
This commit is contained in:
Richard van der Hoff
2025-01-20 21:21:05 +00:00
committed by GitHub
parent ce60162827
commit b496601712
2 changed files with 12 additions and 1 deletions

View File

@@ -20,6 +20,11 @@ declare module "@matrix-org/matrix-sdk-crypto-wasm" {
interface OlmMachine {
importSecretsBundle(bundle: RustSdkCryptoJs.SecretsBundle): Promise<void>;
exportSecretsBundle(): Promise<RustSdkCryptoJs.SecretsBundle>;
importCrossSigningKeys(
master_key?: string,
self_signing_key?: string,
user_signing_key?: string,
): Promise<RustSdkCryptoJs.CrossSigningStatus>;
}
interface SecretsBundle {

View File

@@ -87,12 +87,18 @@ export class CrossSigningIdentity {
"bootstrapCrossSigning: Cross-signing private keys not found locally, but they are available " +
"in secret storage, reading storage and caching locally",
);
await this.olmMachine.importCrossSigningKeys(
const status = await this.olmMachine.importCrossSigningKeys(
masterKeyFromSecretStorage,
selfSigningKeyFromSecretStorage,
userSigningKeyFromSecretStorage,
);
// Check that `importCrossSigningKeys` worked correctly (for example, it will fail silently if the
// public keys are not available).
if (!status.hasMaster || !status.hasSelfSigning || !status.hasUserSigning) {
throw new Error("importCrossSigningKeys failed to import the keys");
}
// Get the current device
const device: RustSdkCryptoJs.Device = await this.olmMachine.getDevice(
this.olmMachine.userId,