diff --git a/src/client.js b/src/client.js index 13f8a4c5a..d5c56838a 100644 --- a/src/client.js +++ b/src/client.js @@ -965,6 +965,14 @@ function wrapCryptoFuncs(MatrixClient, names) { } /** + * Check whether we already have cross-signing keys for the current user. + * The cross-signing API is currently UNSTABLE and may change without notice. + * + * @function module:client~MatrixClient#doesCrossSigningHaveKeys + * @return {boolean} Whether we have keys. + */ + + /** * Generate new cross-signing keys. * The cross-signing API is currently UNSTABLE and may change without notice. * @@ -1018,6 +1026,7 @@ function wrapCryptoFuncs(MatrixClient, names) { */ wrapCryptoFuncs(MatrixClient, [ + "doesCrossSigningHaveKeys", "resetCrossSigningKeys", "getCrossSigningId", "getStoredCrossSigningForUser", diff --git a/src/crypto/CrossSigning.js b/src/crypto/CrossSigning.js index 90d95014a..e362a1889 100644 --- a/src/crypto/CrossSigning.js +++ b/src/crypto/CrossSigning.js @@ -101,6 +101,10 @@ export class CrossSigningInfo extends EventEmitter { }; } + hasKeys() { + return Object.keys(this.keys).length > 0; + } + /** * Get the ID used to identify the user * diff --git a/src/crypto/index.js b/src/crypto/index.js index 4b670d5a3..32499e26a 100644 --- a/src/crypto/index.js +++ b/src/crypto/index.js @@ -328,6 +328,15 @@ Crypto.prototype.checkPrivateKey = function(privateKey, expectedPublicKey) { } }; +/** + * Check whether we already have cross-signing keys for the current user. + * + * @return {boolean} Whether we have keys. + */ +Crypto.prototype.doesCrossSigningHaveKeys = function() { + return this._crossSigningInfo.hasKeys(); +}; + /** * Generate new cross-signing keys. *