Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b840f35

Browse files
committed
Remove now-unreachable tryToUnlockSecretStorageWithDehydrationKey
1 parent 9107431 commit b840f35

File tree

1 file changed

+1
-56
lines changed

1 file changed

+1
-56
lines changed

src/SecurityManager.ts

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import { Crypto, ICryptoCallbacks, MatrixClient, encodeBase64, SecretStorage } from "matrix-js-sdk/src/matrix";
17+
import { Crypto, ICryptoCallbacks, encodeBase64, SecretStorage } from "matrix-js-sdk/src/matrix";
1818
import { deriveKey } from "matrix-js-sdk/src/crypto/key_passphrase";
1919
import { decodeRecoveryKey } from "matrix-js-sdk/src/crypto/recoverykey";
2020
import { logger } from "matrix-js-sdk/src/logger";
@@ -40,8 +40,6 @@ let secretStorageKeys: Record<string, Uint8Array> = {};
4040
let secretStorageKeyInfo: Record<string, SecretStorage.SecretStorageKeyDescription> = {};
4141
let secretStorageBeingAccessed = false;
4242

43-
let nonInteractive = false;
44-
4543
let dehydrationCache: {
4644
key?: Uint8Array;
4745
keyInfo?: SecretStorage.SecretStorageKeyDescription;
@@ -138,10 +136,6 @@ async function getSecretStorageKey({
138136
return [keyId, keyFromCustomisations];
139137
}
140138

141-
if (nonInteractive) {
142-
throw new Error("Could not unlock non-interactively");
143-
}
144-
145139
const inputToKey = makeInputToKey(keyInfo);
146140
const { finished } = Modal.createDialog(
147141
AccessSecretStorageDialog,
@@ -430,52 +424,3 @@ async function doAccessSecretStorage(func: () => Promise<void>, forceReset: bool
430424
throw e;
431425
}
432426
}
433-
434-
// FIXME: this function name is a bit of a mouthful
435-
export async function tryToUnlockSecretStorageWithDehydrationKey(client: MatrixClient): Promise<void> {
436-
const key = dehydrationCache.key;
437-
let restoringBackup = false;
438-
if (key && (await client.isSecretStorageReady())) {
439-
logger.log("Trying to set up cross-signing using dehydration key");
440-
secretStorageBeingAccessed = true;
441-
nonInteractive = true;
442-
try {
443-
await client.checkOwnCrossSigningTrust();
444-
445-
// we also need to set a new dehydrated device to replace the
446-
// device we rehydrated
447-
let dehydrationKeyInfo = {};
448-
if (dehydrationCache.keyInfo && dehydrationCache.keyInfo.passphrase) {
449-
dehydrationKeyInfo = { passphrase: dehydrationCache.keyInfo.passphrase };
450-
}
451-
await client.setDehydrationKey(key, dehydrationKeyInfo, "Backup device");
452-
453-
// and restore from backup
454-
const backupInfo = await client.getKeyBackupVersion();
455-
if (backupInfo) {
456-
restoringBackup = true;
457-
// don't await, because this can take a long time
458-
client.restoreKeyBackupWithSecretStorage(backupInfo).finally(() => {
459-
secretStorageBeingAccessed = false;
460-
nonInteractive = false;
461-
if (!isCachingAllowed()) {
462-
secretStorageKeys = {};
463-
secretStorageKeyInfo = {};
464-
}
465-
});
466-
}
467-
} finally {
468-
dehydrationCache = {};
469-
// the secret storage cache is needed for restoring from backup, so
470-
// don't clear it yet if we're restoring from backup
471-
if (!restoringBackup) {
472-
secretStorageBeingAccessed = false;
473-
nonInteractive = false;
474-
if (!isCachingAllowed()) {
475-
secretStorageKeys = {};
476-
secretStorageKeyInfo = {};
477-
}
478-
}
479-
}
480-
}
481-
}

0 commit comments

Comments
 (0)