mirror of https://github.com/oxen-io/session-ios
Further work on Id Blinding
Renamed the setter for the SOGS 'Server' object for consistency Updated the Curve25519Kit repo to use an Oxen fork Updated the MockDataGenerator to accomodate the latest changes Updated the ConversationVC to better support getting replaced when the conversion from blinded to unblinded happens while on that screen Added a cache for the mapping between blinded ids and standard ids (gets cached whenever a valid match is found) Added a migration to remove the old 'authToken, 'lastMessageServerId' and 'lastDeletionServerId' collections (redundant in SOGS V4)pull/592/head
parent
3e97782d18
commit
a26ee12f8d
@ -0,0 +1,40 @@
|
||||
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc(SNBlindedIdMapping)
|
||||
public class BlindedIdMapping: NSObject, NSCoding { // NSObject/NSCoding conformance is needed for YapDatabase compatibility
|
||||
@objc public let blindedId: String
|
||||
@objc public let sessionId: String
|
||||
@objc public let serverPublicKey: String
|
||||
|
||||
// MARK: - Initialization
|
||||
|
||||
@objc public init(blindedId: String, sessionId: String, serverPublicKey: String) {
|
||||
self.blindedId = blindedId
|
||||
self.sessionId = sessionId
|
||||
self.serverPublicKey = serverPublicKey
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
private override init() { preconditionFailure("Use init(blindedId:sessionId:) instead.") }
|
||||
|
||||
// MARK: - Coding
|
||||
|
||||
public required init?(coder: NSCoder) {
|
||||
guard let blindedId: String = coder.decodeObject(forKey: "blindedId") as! String? else { return nil }
|
||||
guard let sessionId: String = coder.decodeObject(forKey: "sessionId") as! String? else { return nil }
|
||||
guard let serverPublicKey: String = coder.decodeObject(forKey: "serverPublicKey") as! String? else { return nil }
|
||||
|
||||
self.blindedId = blindedId
|
||||
self.sessionId = sessionId
|
||||
self.serverPublicKey = serverPublicKey
|
||||
}
|
||||
|
||||
public func encode(with coder: NSCoder) {
|
||||
coder.encode(blindedId, forKey: "blindedId")
|
||||
coder.encode(sessionId, forKey: "sessionId")
|
||||
coder.encode(serverPublicKey, forKey: "serverPublicKey")
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc(SNSOGSV4Migration)
|
||||
public class SOGSV4Migration: OWSDatabaseMigration {
|
||||
|
||||
@objc
|
||||
class func migrationId() -> String {
|
||||
return "003"
|
||||
}
|
||||
|
||||
override public func runUp(completion: @escaping OWSDatabaseMigrationCompletion) {
|
||||
self.doMigrationAsync(completion: completion)
|
||||
}
|
||||
|
||||
private func doMigrationAsync(completion: @escaping OWSDatabaseMigrationCompletion) {
|
||||
// These collections became redundant in SOGS V4
|
||||
let lastMessageServerIDCollection: String = "SNLastMessageServerIDCollection"
|
||||
let lastDeletionServerIDCollection: String = "SNLastDeletionServerIDCollection"
|
||||
let authTokenCollection: String = "SNAuthTokenCollection"
|
||||
|
||||
Storage.write(with: { transaction in
|
||||
transaction.removeAllObjects(inCollection: lastMessageServerIDCollection)
|
||||
transaction.removeAllObjects(inCollection: lastDeletionServerIDCollection)
|
||||
transaction.removeAllObjects(inCollection: authTokenCollection)
|
||||
|
||||
self.save(with: transaction) // Intentionally capture self
|
||||
}, completion: {
|
||||
completion()
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue