1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-23 17:02:25 +03:00

Element-R: Emit CryptoEvent.UserTrustStatusChanged when user identity is updated (#3716)

* Emit a `UserTrustStatusChanged` when user identity is updated

* Remove redundant `onCrossSigningKeysImport` callback

This now happens as a side-effect of importing the keys.

* bump to alpha release of matrix-rust-sdk-crypto-wasm

* fixup! Remove redundant `onCrossSigningKeysImport` callback
This commit is contained in:
Richard van der Hoff
2023-09-08 05:40:02 +01:00
committed by GitHub
parent 8c30b0d12c
commit f963ca5562
6 changed files with 24 additions and 22 deletions

View File

@@ -136,17 +136,7 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEv
CryptoEvent.KeyBackupFailed,
]);
// Fire if the cross signing keys are imported from the secret storage
const onCrossSigningKeysImport = async (): Promise<void> => {
const newVerification = await this.getUserVerificationStatus(this.userId);
this.emit(CryptoEvent.UserTrustStatusChanged, this.userId, newVerification);
};
this.crossSigningIdentity = new CrossSigningIdentity(
olmMachine,
this.outgoingRequestProcessor,
secretStorage,
onCrossSigningKeysImport,
);
this.crossSigningIdentity = new CrossSigningIdentity(olmMachine, this.outgoingRequestProcessor, secretStorage);
}
/**
@@ -1249,6 +1239,19 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEv
}
}
/**
* Callback for `OlmMachine.registerUserIdentityUpdatedCallback`
*
* Called by the rust-sdk whenever there is an update to any user's cross-signing status. We re-check their trust
* status and emit a `UserTrustStatusChanged` event.
*
* @param userId - the user with the updated identity
*/
public async onUserIdentityUpdated(userId: RustSdkCryptoJs.UserId): Promise<void> {
const newVerification = await this.getUserVerificationStatus(userId.toString());
this.emit(CryptoEvent.UserTrustStatusChanged, userId.toString(), newVerification);
}
/**
* Handle a live event received via /sync.
* See {@link ClientEventHandlerMap#event}
@@ -1457,7 +1460,7 @@ type RustCryptoEventMap = {
[CryptoEvent.VerificationRequestReceived]: (request: VerificationRequest) => void;
/**
* Fires when the cross signing keys are imported during {@link CryptoApi#bootstrapCrossSigning}
* Fires when the trust status of a user changes.
*/
[CryptoEvent.UserTrustStatusChanged]: (userId: string, userTrustLevel: UserVerificationStatus) => void;
} & RustBackupCryptoEventMap;