@@ -26,7 +26,7 @@ import Spinner from "../elements/Spinner";
26
26
import InteractiveAuthDialog from "../dialogs/InteractiveAuthDialog" ;
27
27
import ConfirmDestroyCrossSigningDialog from "../dialogs/security/ConfirmDestroyCrossSigningDialog" ;
28
28
import SetupEncryptionDialog from "../dialogs/security/SetupEncryptionDialog" ;
29
- import { accessSecretStorage } from "../../../SecurityManager" ;
29
+ import { accessSecretStorage , withSecretStorageKeyCache } from "../../../SecurityManager" ;
30
30
import AccessibleButton from "../elements/AccessibleButton" ;
31
31
import { SettingsSubsectionText } from "./shared/SettingsSubsection" ;
32
32
@@ -118,45 +118,46 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
118
118
}
119
119
120
120
/**
121
- * Bootstrapping cross-signing take one of these paths:
122
- * 1. Create cross-signing keys locally and store in secret storage (if it
123
- * already exists on the account).
124
- * 2. Access existing secret storage by requesting passphrase and accessing
125
- * cross-signing keys as needed.
126
- * 3. All keys are loaded and there's nothing to do.
127
- * @param {bool } [forceReset] Bootstrap again even if keys already present
121
+ * Reset the user's cross-signing keys.
128
122
*/
129
- private bootstrapCrossSigning = async ( { forceReset = false } ) : Promise < void > = > {
123
+ private async resetCrossSigning ( ) : Promise < void > {
130
124
this . setState ( { error : false } ) ;
131
125
try {
132
126
const cli = MatrixClientPeg . safeGet ( ) ;
133
- await cli . bootstrapCrossSigning ( {
134
- authUploadDeviceSigningKeys : async ( makeRequest ) : Promise < void > => {
135
- const { finished } = Modal . createDialog ( InteractiveAuthDialog , {
136
- title : _t ( "encryption|bootstrap_title" ) ,
137
- matrixClient : cli ,
138
- makeRequest,
139
- } ) ;
140
- const [ confirmed ] = await finished ;
141
- if ( ! confirmed ) {
142
- throw new Error ( "Cross-signing key upload auth canceled" ) ;
143
- }
144
- } ,
145
- setupNewCrossSigning : forceReset ,
127
+ await withSecretStorageKeyCache ( async ( ) => {
128
+ await cli . getCrypto ( ) ! . bootstrapCrossSigning ( {
129
+ authUploadDeviceSigningKeys : async ( makeRequest ) : Promise < void > => {
130
+ const { finished } = Modal . createDialog ( InteractiveAuthDialog , {
131
+ title : _t ( "encryption|bootstrap_title" ) ,
132
+ matrixClient : cli ,
133
+ makeRequest,
134
+ } ) ;
135
+ const [ confirmed ] = await finished ;
136
+ if ( ! confirmed ) {
137
+ throw new Error ( "Cross-signing key upload auth canceled" ) ;
138
+ }
139
+ } ,
140
+ setupNewCrossSigning : true ,
141
+ } ) ;
146
142
} ) ;
147
143
} catch ( e ) {
148
144
this . setState ( { error : true } ) ;
149
145
logger . error ( "Error bootstrapping cross-signing" , e ) ;
150
146
}
151
147
if ( this . unmounted ) return ;
152
148
this . getUpdatedStatus ( ) ;
153
- } ;
149
+ }
154
150
155
- private resetCrossSigning = ( ) : void => {
151
+ /**
152
+ * Callback for when the user clicks the "reset cross signing" button.
153
+ *
154
+ * Shows a confirmation dialog, and then does the reset if confirmed.
155
+ */
156
+ private onResetCrossSigningClick = ( ) : void => {
156
157
Modal . createDialog ( ConfirmDestroyCrossSigningDialog , {
157
- onFinished : ( act ) => {
158
+ onFinished : async ( act ) => {
158
159
if ( ! act ) return ;
159
- this . bootstrapCrossSigning ( { forceReset : true } ) ;
160
+ this . resetCrossSigning ( ) ;
160
161
} ,
161
162
} ) ;
162
163
} ;
@@ -243,7 +244,7 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
243
244
244
245
if ( keysExistAnywhere ) {
245
246
actions . push (
246
- < AccessibleButton key = "reset" kind = "danger" onClick = { this . resetCrossSigning } >
247
+ < AccessibleButton key = "reset" kind = "danger" onClick = { this . onResetCrossSigningClick } >
247
248
{ _t ( "action|reset" ) }
248
249
</ AccessibleButton > ,
249
250
) ;
@@ -260,54 +261,56 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
260
261
< details >
261
262
< summary className = "mx_CrossSigningPanel_advanced" > { _t ( "common|advanced" ) } </ summary >
262
263
< table className = "mx_CrossSigningPanel_statusList" >
263
- < tr >
264
- < th scope = "row" > { _t ( "settings|security|cross_signing_public_keys" ) } </ th >
265
- < td >
266
- { crossSigningPublicKeysOnDevice
267
- ? _t ( "settings|security|cross_signing_in_memory" )
268
- : _t ( "settings|security|cross_signing_not_found" ) }
269
- </ td >
270
- </ tr >
271
- < tr >
272
- < th scope = "row" > { _t ( "settings|security|cross_signing_private_keys" ) } </ th >
273
- < td >
274
- { crossSigningPrivateKeysInStorage
275
- ? _t ( "settings|security|cross_signing_in_4s" )
276
- : _t ( "settings|security|cross_signing_not_in_4s" ) }
277
- </ td >
278
- </ tr >
279
- < tr >
280
- < th scope = "row" > { _t ( "settings|security|cross_signing_master_private_Key" ) } </ th >
281
- < td >
282
- { masterPrivateKeyCached
283
- ? _t ( "settings|security|cross_signing_cached" )
284
- : _t ( "settings|security|cross_signing_not_cached" ) }
285
- </ td >
286
- </ tr >
287
- < tr >
288
- < th scope = "row" > { _t ( "settings|security|cross_signing_self_signing_private_key" ) } </ th >
289
- < td >
290
- { selfSigningPrivateKeyCached
291
- ? _t ( "settings|security|cross_signing_cached" )
292
- : _t ( "settings|security|cross_signing_not_cached" ) }
293
- </ td >
294
- </ tr >
295
- < tr >
296
- < th scope = "row" > { _t ( "settings|security|cross_signing_user_signing_private_key" ) } </ th >
297
- < td >
298
- { userSigningPrivateKeyCached
299
- ? _t ( "settings|security|cross_signing_cached" )
300
- : _t ( "settings|security|cross_signing_not_cached" ) }
301
- </ td >
302
- </ tr >
303
- < tr >
304
- < th scope = "row" > { _t ( "settings|security|cross_signing_homeserver_support" ) } </ th >
305
- < td >
306
- { homeserverSupportsCrossSigning
307
- ? _t ( "settings|security|cross_signing_homeserver_support_exists" )
308
- : _t ( "settings|security|cross_signing_not_found" ) }
309
- </ td >
310
- </ tr >
264
+ < tbody >
265
+ < tr >
266
+ < th scope = "row" > { _t ( "settings|security|cross_signing_public_keys" ) } </ th >
267
+ < td >
268
+ { crossSigningPublicKeysOnDevice
269
+ ? _t ( "settings|security|cross_signing_in_memory" )
270
+ : _t ( "settings|security|cross_signing_not_found" ) }
271
+ </ td >
272
+ </ tr >
273
+ < tr >
274
+ < th scope = "row" > { _t ( "settings|security|cross_signing_private_keys" ) } </ th >
275
+ < td >
276
+ { crossSigningPrivateKeysInStorage
277
+ ? _t ( "settings|security|cross_signing_in_4s" )
278
+ : _t ( "settings|security|cross_signing_not_in_4s" ) }
279
+ </ td >
280
+ </ tr >
281
+ < tr >
282
+ < th scope = "row" > { _t ( "settings|security|cross_signing_master_private_Key" ) } </ th >
283
+ < td >
284
+ { masterPrivateKeyCached
285
+ ? _t ( "settings|security|cross_signing_cached" )
286
+ : _t ( "settings|security|cross_signing_not_cached" ) }
287
+ </ td >
288
+ </ tr >
289
+ < tr >
290
+ < th scope = "row" > { _t ( "settings|security|cross_signing_self_signing_private_key" ) } </ th >
291
+ < td >
292
+ { selfSigningPrivateKeyCached
293
+ ? _t ( "settings|security|cross_signing_cached" )
294
+ : _t ( "settings|security|cross_signing_not_cached" ) }
295
+ </ td >
296
+ </ tr >
297
+ < tr >
298
+ < th scope = "row" > { _t ( "settings|security|cross_signing_user_signing_private_key" ) } </ th >
299
+ < td >
300
+ { userSigningPrivateKeyCached
301
+ ? _t ( "settings|security|cross_signing_cached" )
302
+ : _t ( "settings|security|cross_signing_not_cached" ) }
303
+ </ td >
304
+ </ tr >
305
+ < tr >
306
+ < th scope = "row" > { _t ( "settings|security|cross_signing_homeserver_support" ) } </ th >
307
+ < td >
308
+ { homeserverSupportsCrossSigning
309
+ ? _t ( "settings|security|cross_signing_homeserver_support_exists" )
310
+ : _t ( "settings|security|cross_signing_not_found" ) }
311
+ </ td >
312
+ </ tr >
313
+ </ tbody >
311
314
</ table >
312
315
</ details >
313
316
{ errorSection }
0 commit comments