@@ -68,7 +68,7 @@ public class DehydrationService: NSObject {
6868 // Convert it back to Data
6969 let pickleKeyData = MXBase64Tools . data ( fromBase64: base64PickleKey)
7070
71- let rehydrationResult = await rehydrateDevice ( pickleKeyData: [ UInt8 ] ( pickleKeyData) )
71+ let rehydrationResult = await rehydrateDevice ( pickleKeyData: pickleKeyData)
7272 switch rehydrationResult {
7373 case . success( ( let deviceId, let rehydratedDevice) ) :
7474 // Fetch and process the to device events available on the dehydrated device
@@ -86,14 +86,14 @@ public class DehydrationService: NSObject {
8686 }
8787
8888 // Finally, create a new dehydrated device with the same pickle key
89- try await dehydrateDevice ( pickleKeyData: [ UInt8 ] ( pickleKeyData) )
89+ try await dehydrateDevice ( pickleKeyData: pickleKeyData)
9090 } else { // Otherwise, generate a new dehydration pickle key, store it and dehydrate a device
9191 // Generate a new dehydration pickle key
92- var pickleKeyData = [ UInt8 ] ( repeating : 0 , count: 32 )
92+ var pickleKeyData = Data ( count: 32 )
9393 _ = SecRandomCopyBytes ( kSecRandomDefault, 32 , & pickleKeyData)
9494
9595 // Convert it to unpadded base 64
96- let base64PickleKey = MXBase64Tools . unpaddedBase64 ( from: Data ( bytes : pickleKeyData, count : 32 ) )
96+ let base64PickleKey = MXBase64Tools . unpaddedBase64 ( from: pickleKeyData)
9797
9898 // Store it on the backend
9999 try await storeSecret ( base64PickleKey, secretId: secretId, secretStorageKeys: [ secretStorageKeyId: privateKeyData] )
@@ -131,10 +131,10 @@ public class DehydrationService: NSObject {
131131
132132 // MARK: - Device dehydration
133133
134- private func dehydrateDevice( pickleKeyData: [ UInt8 ] ) async throws {
135- let dehydratedDevice = dehydratedDevices. create ( )
134+ private func dehydrateDevice( pickleKeyData: Data ) async throws {
135+ let dehydratedDevice = try dehydratedDevices. create ( )
136136
137- let requestDetails = try dehydratedDevice. keysForUpload ( deviceDisplayName: deviceDisplayName, pickleKey: [ UInt8 ] ( pickleKeyData) )
137+ let requestDetails = try dehydratedDevice. keysForUpload ( deviceDisplayName: deviceDisplayName, pickleKey: pickleKeyData)
138138
139139 let parameters = MXDehydratedDeviceCreationParameters ( )
140140 parameters. body = requestDetails. body
@@ -150,7 +150,7 @@ public class DehydrationService: NSObject {
150150 }
151151 }
152152
153- private func rehydrateDevice( pickleKeyData: [ UInt8 ] ) async -> Result < ( deviceId: String , rehydratedDevice: RehydratedDeviceProtocol ) , DehydrationServiceError > {
153+ private func rehydrateDevice( pickleKeyData: Data ) async -> Result < ( deviceId: String , rehydratedDevice: RehydratedDeviceProtocol ) , DehydrationServiceError > {
154154 await withCheckedContinuation { continuation in
155155 self . restClient. retrieveDehydratedDevice { [ weak self] dehydratedDevice in
156156 guard let self else { return }
@@ -163,7 +163,7 @@ public class DehydrationService: NSObject {
163163 }
164164
165165 do {
166- let rehydratedDevice = try self . dehydratedDevices. rehydrate ( pickleKey: [ UInt8 ] ( pickleKeyData) , deviceId: dehydratedDevice. deviceId, deviceData: deviceDataJSON)
166+ let rehydratedDevice = try self . dehydratedDevices. rehydrate ( pickleKey: pickleKeyData, deviceId: dehydratedDevice. deviceId, deviceData: deviceDataJSON)
167167 continuation. resume ( returning: . success( ( dehydratedDevice. deviceId, rehydratedDevice) ) )
168168 } catch {
169169 continuation. resume ( returning: . failure( DehydrationServiceError . failedRehydration ( error) ) )
0 commit comments