You've already forked matrix-js-sdk
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:
committed by
GitHub
parent
ce60162827
commit
b496601712
5
src/@types/matrix-sdk-crypto-wasm.d.ts
vendored
5
src/@types/matrix-sdk-crypto-wasm.d.ts
vendored
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user