mirror of https://github.com/oxen-io/session-ios
Merge approaches
parent
62141ce952
commit
ad896a1275
@ -1,7 +1,7 @@
|
||||
import PromiseKit
|
||||
|
||||
@objc(LKLongPoller)
|
||||
public final class LokiLongPoller : NSObject {
|
||||
public final class LongPoller : NSObject {
|
||||
private let onMessagesReceived: ([SSKProtoEnvelope]) -> Void
|
||||
private let storage = OWSPrimaryStorage.shared()
|
||||
private var hasStarted = false
|
@ -0,0 +1,24 @@
|
||||
|
||||
public struct LokiDeviceLink {
|
||||
public let master: Device
|
||||
public let slave: Device
|
||||
|
||||
public var isAuthorized: Bool { return master.signature != nil }
|
||||
|
||||
// MARK: Types
|
||||
public struct Device {
|
||||
public let hexEncodedPublicKey: String
|
||||
public let signature: Data?
|
||||
|
||||
public init(hexEncodedPublicKey: String, signature: Data? = nil) {
|
||||
self.hexEncodedPublicKey = hexEncodedPublicKey
|
||||
self.signature = signature
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Lifecycle
|
||||
public init(between master: Device, and slave: Device) {
|
||||
self.master = master
|
||||
self.slave = slave
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
|
||||
public protocol LokiDeviceLinkingSessionDelegate {
|
||||
|
||||
func handleDeviceLinkingRequestReceived(with signature: String)
|
||||
func authorizeDeviceLinkIfValid(_ deviceLink: LokiDeviceLink)
|
||||
func handleDeviceLinkingSessionTimeout()
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
@objc(LKPairingAuthorisation)
|
||||
public final class LokiPairingAuthorisation : NSObject, NSCoding {
|
||||
@objc public let primaryDevicePubKey: String
|
||||
@objc public let secondaryDevicePubKey: String
|
||||
@objc public let requestSignature: Data?
|
||||
@objc public let grantSignature: Data?
|
||||
|
||||
@objc public var isGranted: Bool {
|
||||
return grantSignature != nil
|
||||
}
|
||||
|
||||
@objc public init(primaryDevicePubKey: String, secondaryDevicePubKey: String, requestSignature: Data? = nil, grantSignature: Data? = nil) {
|
||||
self.primaryDevicePubKey = primaryDevicePubKey
|
||||
self.secondaryDevicePubKey = secondaryDevicePubKey
|
||||
self.requestSignature = requestSignature
|
||||
self.grantSignature = grantSignature
|
||||
}
|
||||
|
||||
public convenience init?(coder aDecoder: NSCoder) {
|
||||
guard let primaryDevicePubKey = aDecoder.decodeObject(forKey: "primaryDevicePubKey") as? String,
|
||||
let secondaryDevicePubKey = aDecoder.decodeObject(forKey: "secondaryDevicePubKey") as? String else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let requestSignature = aDecoder.decodeObject(forKey: "requestSignature") as? Data
|
||||
let grantSignature = aDecoder.decodeObject(forKey: "grantSignature") as? Data
|
||||
|
||||
self.init(primaryDevicePubKey: primaryDevicePubKey, secondaryDevicePubKey: secondaryDevicePubKey, requestSignature: requestSignature, grantSignature: grantSignature)
|
||||
}
|
||||
|
||||
public func encode(with aCoder: NSCoder) {
|
||||
aCoder.encode(primaryDevicePubKey, forKey: "primaryDevicePubKey")
|
||||
aCoder.encode(secondaryDevicePubKey, forKey: "secondaryDevicePubKey")
|
||||
aCoder.encode(requestSignature, forKey: "requestSignature")
|
||||
aCoder.encode(grantSignature, forKey: "grantSignature")
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
|
||||
extension OWSPrimaryStorage {
|
||||
|
||||
private func getCollection(for primaryDevice: String) -> String {
|
||||
return "LokiMultiDevice-\(primaryDevice)"
|
||||
}
|
Loading…
Reference in New Issue