From d132b1c4f15fe47409d338a53da9b493c5bef65d Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Thu, 19 Sep 2019 10:03:08 +1000 Subject: [PATCH] Stub LokiDeviceLinkingAPI --- .../src/Loki/API/LokiDeviceLinkingAPI.swift | 50 +++++++++++++++++++ .../src/Loki/API/LokiGroupChatAPI.swift | 3 ++ 2 files changed, 53 insertions(+) create mode 100644 SignalServiceKit/src/Loki/API/LokiDeviceLinkingAPI.swift diff --git a/SignalServiceKit/src/Loki/API/LokiDeviceLinkingAPI.swift b/SignalServiceKit/src/Loki/API/LokiDeviceLinkingAPI.swift new file mode 100644 index 000000000..601e0776b --- /dev/null +++ b/SignalServiceKit/src/Loki/API/LokiDeviceLinkingAPI.swift @@ -0,0 +1,50 @@ +import PromiseKit + +@objc(LKDeviceLinkingAPI) +final class LokiDeviceLinkingAPI : NSObject { + + // MARK: Settings + private static let listeningTimeout = 60 + + // MARK: Types + public struct Account { + public let hexEncodedPublicKey: String + public let isMaster: Bool + } + + // MARK: Lifecycle + override private init() { } + + // MARK: Public API + @objc public static func startListeningForLinkingRequests(onLinkingRequestReceived: (String) -> Void, onTimeout: () -> Void) { + // Listens for linking requests until either one is received or listeningTimeout is reached + } + + @objc public static func authorizeLinkingRequest(with signature: String) { + // Authorize the linking request with the given signature + } + + public static func addSlaveAccount(with hexEncodedPublicKey: String) -> Promise { + // Adds the given slave account to the user's device mapping on the server + notImplemented() + } + + public static func removeSlaveAccount(with hexEncodedPublicKey: String) -> Promise { + // Removes the given slave account from the user's device mapping on the server + notImplemented() + } + + public static func getAccounts(for hexEncodedPublicKey: String) -> Promise<[Account]> { + // Gets the accounts associated with the given hex encoded public key from the server + notImplemented() + } +} + +//LokiDeviceLinkingAPI.startListeningForLinkingRequests(onLinkingRequestReceived: { signature in +// // 1. Validate the signature +// // 2. Ask the user to accept +// // 2.1. If the user declined, we're done +// // 2.2, If the user accepted: LokiDeviceLinkingAPI.authorizeLinkingRequest(with: signature) +//}, onTimeout: { +// // Notify the user +//}) diff --git a/SignalServiceKit/src/Loki/API/LokiGroupChatAPI.swift b/SignalServiceKit/src/Loki/API/LokiGroupChatAPI.swift index fbc8b189c..f7102de9c 100644 --- a/SignalServiceKit/src/Loki/API/LokiGroupChatAPI.swift +++ b/SignalServiceKit/src/Loki/API/LokiGroupChatAPI.swift @@ -83,6 +83,9 @@ public final class LokiGroupChatAPI : NSObject { transaction.setObject(newValue, forKey: "\(server).\(group)", inCollection: lastDeletionServerIDCollection) } } + + // MARK: Lifecycle + override private init() { } // MARK: Private API private static func requestNewAuthToken(for server: String) -> Promise {