You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Publicise method testing for secret storage key existence
This commit is contained in:
@@ -1073,6 +1073,16 @@ MatrixClient.prototype.checkEventSenderTrust = async function(event) {
|
||||
* @return {string} the name of the key
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check whether we have a key with a given ID.
|
||||
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
||||
*
|
||||
* @function module:client~MatrixClient#hasSecretStorageKey
|
||||
* @param {string} [keyId = default key's ID] The ID of the key to check
|
||||
* for. Defaults to the default key ID if not provided.
|
||||
* @return {boolean} Whether we have the key.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Store an encrypted secret on the server
|
||||
* The Secure Secret Storage API is currently UNSTABLE and may change without notice.
|
||||
@@ -1137,6 +1147,7 @@ MatrixClient.prototype.checkEventSenderTrust = async function(event) {
|
||||
wrapCryptoFuncs(MatrixClient, [
|
||||
"bootstrapSecretStorage",
|
||||
"addSecretStorageKey",
|
||||
"hasSecretStorageKey",
|
||||
"storeSecret",
|
||||
"getSecret",
|
||||
"isSecretStored",
|
||||
@@ -1401,7 +1412,7 @@ MatrixClient.prototype.prepareKeyBackupVersion = async function(
|
||||
logger.log("Preparing key backup version with Secure Secret Storage");
|
||||
|
||||
// Ensure Secure Secret Storage is ready for use
|
||||
if (!this._secretStorage.hasKey()) {
|
||||
if (!this.hasSecretStorageKey()) {
|
||||
throw new Error("Secure Secret Storage has no keys, needs bootstrapping");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ Crypto.prototype.bootstrapSecretStorage = async function({
|
||||
|
||||
// Check if Secure Secret Storage has a default key. If we don't have one, create the
|
||||
// default key (which will also be signed by the cross-signing master key).
|
||||
if (!this._secretStorage.hasKey()) {
|
||||
if (!this.hasSecretStorageKey()) {
|
||||
logger.log("Secret storage default key not found, creating new key");
|
||||
const keyOptions = await createSecretStorageKey();
|
||||
const newKeyId = await this.addSecretStorageKey(
|
||||
@@ -400,6 +400,10 @@ Crypto.prototype.addSecretStorageKey = function(algorithm, opts, keyID) {
|
||||
return this._secretStorage.addKey(algorithm, opts, keyID);
|
||||
};
|
||||
|
||||
Crypto.prototype.hasSecretStorageKey = function(keyID) {
|
||||
return this._secretStorage.hasKey(keyID);
|
||||
};
|
||||
|
||||
Crypto.prototype.storeSecret = function(name, secret, keys) {
|
||||
return this._secretStorage.store(name, secret, keys);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user