mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-18 07:28:28 +02:00
Device dehydration v2
- add support for device dehydration v2 i.e. `org.matrix.msc3814` - run dehydration flows after successfully recovering or creating secrets - enable said flows based on .well-known `org.matrix.msc3814` config key - delete previous implementation and helper methods
This commit is contained in:
@@ -1495,68 +1495,6 @@
|
||||
[self _createAccountWithCredentials:credentials];
|
||||
}
|
||||
|
||||
- (void)attemptDeviceRehydrationWithKeyData:(NSData *)keyData
|
||||
credentials:(MXCredentials *)credentials
|
||||
{
|
||||
[self attemptDeviceRehydrationWithKeyData:keyData
|
||||
credentials:credentials
|
||||
retry:YES];
|
||||
}
|
||||
|
||||
- (void)attemptDeviceRehydrationWithKeyData:(NSData *)keyData
|
||||
credentials:(MXCredentials *)credentials
|
||||
retry:(BOOL)retry
|
||||
{
|
||||
MXLogDebug(@"[MXKAuthenticationViewController] attemptDeviceRehydration: starting device rehydration");
|
||||
|
||||
if (keyData == nil)
|
||||
{
|
||||
MXLogError(@"[MXKAuthenticationViewController] attemptDeviceRehydration: no key provided for device rehydration");
|
||||
[self _createAccountWithCredentials:credentials];
|
||||
return;
|
||||
}
|
||||
|
||||
MXRestClient *mxRestClient = [[MXRestClient alloc] initWithCredentials:credentials andOnUnrecognizedCertificateBlock:^BOOL(NSData *certificate) {
|
||||
return NO;
|
||||
} andPersistentTokenDataHandler:^(void (^handler)(NSArray<MXCredentials *> *credentials, void (^completion)(BOOL didUpdateCredentials))) {
|
||||
[[MXKAccountManager sharedManager] readAndWriteCredentials:handler];
|
||||
} andUnauthenticatedHandler: nil];
|
||||
|
||||
MXWeakify(self);
|
||||
[[MXKAccountManager sharedManager].dehydrationService rehydrateDeviceWithMatrixRestClient:mxRestClient dehydrationKey:keyData success:^(NSString * deviceId) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
||||
if (deviceId)
|
||||
{
|
||||
MXLogDebug(@"[MXKAuthenticationViewController] attemptDeviceRehydration: device %@ rehydrated successfully.", deviceId);
|
||||
credentials.deviceId = deviceId;
|
||||
}
|
||||
else
|
||||
{
|
||||
MXLogDebug(@"[MXKAuthenticationViewController] attemptDeviceRehydration: device rehydration has been canceled.");
|
||||
}
|
||||
|
||||
[self _createAccountWithCredentials:credentials];
|
||||
} failure:^(NSError *error) {
|
||||
MXStrongifyAndReturnIfNil(self);
|
||||
|
||||
if (retry)
|
||||
{
|
||||
MXLogErrorDetails(@"[MXKAuthenticationViewController] attemptDeviceRehydration: device rehydration failed due to error: Retrying", @{
|
||||
@"error": error ?: @"unknown"
|
||||
});
|
||||
[self attemptDeviceRehydrationWithKeyData:keyData credentials:credentials retry:NO];
|
||||
return;
|
||||
}
|
||||
|
||||
MXLogErrorDetails(@"[MXKAuthenticationViewController] attemptDeviceRehydration: device rehydration failed due to error", @{
|
||||
@"error": error ?: @"unknown"
|
||||
});
|
||||
|
||||
[self _createAccountWithCredentials:credentials];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)_createAccountWithCredentials:(MXCredentials *)credentials
|
||||
{
|
||||
MXKAccount *account = [[MXKAccount alloc] initWithCredentials:credentials];
|
||||
|
||||
Reference in New Issue
Block a user