mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 17:12:45 +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:
@@ -1715,70 +1715,6 @@ static NSArray<NSNumber*> *initialSyncSilentErrorsHTTPStatusCodes;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)attemptDeviceDehydrationWithKeyData:(NSData *)keyData
|
||||
success:(void (^)(void))success
|
||||
failure:(void (^)(NSError *error))failure
|
||||
{
|
||||
[self attemptDeviceDehydrationWithKeyData:keyData retry:YES success:success failure:failure];
|
||||
}
|
||||
|
||||
- (void)attemptDeviceDehydrationWithKeyData:(NSData *)keyData
|
||||
retry:(BOOL)retry
|
||||
success:(void (^)(void))success
|
||||
failure:(void (^)(NSError *error))failure
|
||||
{
|
||||
if (keyData == nil)
|
||||
{
|
||||
MXLogWarning(@"[MXKAccount] attemptDeviceDehydrationWithRetry: no key provided for device dehydration");
|
||||
|
||||
if (failure)
|
||||
{
|
||||
failure(nil);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (![mxSession.crypto.crossSigning isKindOfClass:[MXLegacyCrossSigning class]]) {
|
||||
MXLogFailure(@"Device dehydratation is currently only supported by legacy cross signing, add support to all implementations");
|
||||
if (failure)
|
||||
{
|
||||
failure(nil);
|
||||
}
|
||||
return;
|
||||
}
|
||||
MXLegacyCrossSigning *crossSigning = (MXLegacyCrossSigning *)mxSession.crypto.crossSigning;;
|
||||
|
||||
MXLogDebug(@"[MXKAccount] attemptDeviceDehydrationWithRetry: starting device dehydration");
|
||||
[[MXKAccountManager sharedManager].dehydrationService dehydrateDeviceWithMatrixRestClient:mxRestClient crossSigning:crossSigning dehydrationKey:keyData success:^(NSString *deviceId) {
|
||||
MXLogDebug(@"[MXKAccount] attemptDeviceDehydrationWithRetry: device successfully dehydrated");
|
||||
|
||||
if (success)
|
||||
{
|
||||
success();
|
||||
}
|
||||
} failure:^(NSError *error) {
|
||||
if (retry)
|
||||
{
|
||||
[self attemptDeviceDehydrationWithKeyData:keyData retry:NO success:success failure:failure];
|
||||
MXLogErrorDetails(@"[MXKAccount] attemptDeviceDehydrationWithRetry: device dehydration failed due to error: Retrying.", @{
|
||||
@"error": error ?: @"unknown"
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
MXLogErrorDetails(@"[MXKAccount] attemptDeviceDehydrationWithRetry: device dehydration failed due to error", @{
|
||||
@"error": error ?: @"unknown"
|
||||
});
|
||||
|
||||
if (failure)
|
||||
{
|
||||
failure(error);
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)onMatrixSessionStateChange
|
||||
{
|
||||
// Check if pause has been requested
|
||||
|
||||
Reference in New Issue
Block a user