@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
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" ;
18
18
import { deriveKey } from "matrix-js-sdk/src/crypto/key_passphrase" ;
19
19
import { decodeRecoveryKey } from "matrix-js-sdk/src/crypto/recoverykey" ;
20
20
import { logger } from "matrix-js-sdk/src/logger" ;
@@ -40,8 +40,6 @@ let secretStorageKeys: Record<string, Uint8Array> = {};
40
40
let secretStorageKeyInfo : Record < string , SecretStorage . SecretStorageKeyDescription > = { } ;
41
41
let secretStorageBeingAccessed = false ;
42
42
43
- let nonInteractive = false ;
44
-
45
43
let dehydrationCache : {
46
44
key ?: Uint8Array ;
47
45
keyInfo ?: SecretStorage . SecretStorageKeyDescription ;
@@ -138,10 +136,6 @@ async function getSecretStorageKey({
138
136
return [ keyId , keyFromCustomisations ] ;
139
137
}
140
138
141
- if ( nonInteractive ) {
142
- throw new Error ( "Could not unlock non-interactively" ) ;
143
- }
144
-
145
139
const inputToKey = makeInputToKey ( keyInfo ) ;
146
140
const { finished } = Modal . createDialog (
147
141
AccessSecretStorageDialog ,
@@ -430,52 +424,3 @@ async function doAccessSecretStorage(func: () => Promise<void>, forceReset: bool
430
424
throw e ;
431
425
}
432
426
}
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