@@ -139,14 +139,14 @@ export async function checkDeviceIsCrossSigned(app: ElementAppPage): Promise<voi
139
139
* Check that the current device is connected to the expected key backup.
140
140
* Also checks that the decryption key is known and cached locally.
141
141
*
142
- * @param app - app page
142
+ * @param app -` ElementAppPage` wrapper for the playwright `Page`.
143
143
* @param expectedBackupVersion - the version of the backup we expect to be connected to.
144
- * @param checkBackupKeyInCache - whether to check that the backup key is cached locally.
144
+ * @param checkBackupPrivateKeyInCache - whether to check that the backup decryption key is cached locally
145
145
*/
146
146
export async function checkDeviceIsConnectedKeyBackup (
147
147
app : ElementAppPage ,
148
148
expectedBackupVersion : string ,
149
- checkBackupKeyInCache : boolean ,
149
+ checkBackupPrivateKeyInCache : boolean ,
150
150
) : Promise < void > {
151
151
// Sanity check the given backup version: if it's null, something went wrong earlier in the test.
152
152
if ( ! expectedBackupVersion ) {
@@ -160,20 +160,18 @@ export async function checkDeviceIsConnectedKeyBackup(
160
160
if ( ! crypto ) return ;
161
161
162
162
const backupInfo = await crypto . getKeyBackupInfo ( ) ;
163
- const backupKeyStored = Boolean ( await client . isKeyBackupKeyStored ( ) ) ;
164
- const backupKeyFromCache = await crypto . getSessionBackupPrivateKey ( ) ;
165
- const backupKeyCached = Boolean ( backupKeyFromCache ) ;
166
- const backupKeyWellFormed = backupKeyFromCache instanceof Uint8Array ;
163
+ const backupKeyIn4S = Boolean ( await client . isKeyBackupKeyStored ( ) ) ;
164
+ const backupPrivateKeyFromCache = await crypto . getSessionBackupPrivateKey ( ) ;
167
165
const activeBackupVersion = await crypto . getActiveSessionBackupVersion ( ) ;
168
166
169
- return { backupInfo, backupKeyStored , backupKeyCached , backupKeyWellFormed , activeBackupVersion } ;
167
+ return { backupInfo, backupPrivateKeyFromCache , backupKeyIn4S , activeBackupVersion } ;
170
168
} ) ;
171
169
172
170
if ( ! backupData ) {
173
- throw new Error ( "Crypo module is not available" ) ;
171
+ throw new Error ( "Crypto module is not available" ) ;
174
172
}
175
173
176
- const { backupInfo, backupKeyStored , backupKeyCached , backupKeyWellFormed , activeBackupVersion } = backupData ;
174
+ const { backupInfo, backupKeyIn4S , backupPrivateKeyFromCache , activeBackupVersion } = backupData ;
177
175
178
176
// We have a key backup
179
177
expect ( backupInfo ) . toBeDefined ( ) ;
@@ -182,13 +180,13 @@ export async function checkDeviceIsConnectedKeyBackup(
182
180
// The active backup version is as expected
183
181
expect ( activeBackupVersion ) . toBe ( expectedBackupVersion ) ;
184
182
// The backup key is stored in 4S
185
- expect ( backupKeyStored ) . toBe ( true ) ;
183
+ expect ( backupKeyIn4S ) . toBe ( true ) ;
186
184
187
- if ( checkBackupKeyInCache ) {
185
+ if ( checkBackupPrivateKeyInCache ) {
188
186
// The backup key is available locally
189
- expect ( backupKeyCached ) . toBe ( true ) ;
187
+ expect ( Boolean ( backupPrivateKeyFromCache ) ) . toBe ( true ) ;
190
188
// The backup key is well-formed
191
- expect ( backupKeyWellFormed ) . toBe ( true ) ;
189
+ expect ( backupPrivateKeyFromCache instanceof Uint8Array ) . toBe ( true ) ;
192
190
}
193
191
}
194
192
0 commit comments