diff --git a/src/client.js b/src/client.js index 834cc9615..e22169946 100644 --- a/src/client.js +++ b/src/client.js @@ -53,7 +53,7 @@ import { isCryptoAvailable } from './crypto'; import { decodeRecoveryKey } from './crypto/recoverykey'; import { keyFromAuthData } from './crypto/key_passphrase'; import { randomString } from './randomstring'; -import { encodeBase64 } from '../lib/crypto/olmlib'; +import { encodeBase64, decodeBase64 } from '../lib/crypto/olmlib'; const SCROLLBACK_DELAY_MS = 3000; const CRYPTO_ENABLED = isCryptoAvailable(); @@ -1634,6 +1634,15 @@ MatrixClient.prototype.restoreKeyBackupWithPassword = async function( ); }; +MatrixClient.prototype.restoreKeyBackupWithSecretStorage = async function( + backupInfo, targetRoomId, targetSessionId, +) { + const privKey = decodeBase64(await this.getSecret("m.megolm_backup.v1")); + return this._restoreKeyBackup( + privKey, targetRoomId, targetSessionId, backupInfo, + ); +}; + MatrixClient.prototype.restoreKeyBackupWithRecoveryKey = function( recoveryKey, targetRoomId, targetSessionId, backupInfo, ) {