pull/8/head
Niels Andriesse 7 years ago
parent 78adfabf0c
commit 5541e2c2c3

@ -2569,3 +2569,4 @@
"Invalid public key" = "Invalid public key"; "Invalid public key" = "Invalid public key";
"No search results" = "No search results"; "No search results" = "No search results";
"Calculating proof of work" = "Calculating proof of work"; "Calculating proof of work" = "Calculating proof of work";
"Failed to calculate proof of work." = "Failed to calculate proof of work.";

@ -16,7 +16,7 @@ extern void curve25519_donna(unsigned char *output, const unsigned char *a, cons
} }
static const uint8_t basepoint[ECCKeyLength] = { 9 }; static const uint8_t basepoint[ECCKeyLength] = { 9 };
NSMutableData *publicKey = [NSMutableData dataWithLength:ECCKeyLength]; NSMutableData *publicKey = [NSMutableData dataWithLength:ECCKeyLength];
if (!publicKey) { OWSFail(@"Could not allocate buffer"); } if (!publicKey) { OWSFail(@"Couldn't allocate buffer."); }
curve25519_donna(publicKey.mutableBytes, privateKey.mutableBytes, basepoint); curve25519_donna(publicKey.mutableBytes, privateKey.mutableBytes, basepoint);
// Use KVC to access privateKey and publicKey even though they're private // Use KVC to access privateKey and publicKey even though they're private
ECKeyPair *result = [ECKeyPair new]; ECKeyPair *result = [ECKeyPair new];

@ -1,6 +1,6 @@
import PromiseKit import PromiseKit
@objc public final class LokiMessage : NSObject { public struct LokiMessage {
/// The hex encoded public key of the receiver. /// The hex encoded public key of the receiver.
let destination: String let destination: String
/// The content of the message. /// The content of the message.
@ -12,7 +12,7 @@ import PromiseKit
/// The base 64 encoded proof of work. /// The base 64 encoded proof of work.
let nonce: String let nonce: String
init(destination: String, data: LosslessStringConvertible, ttl: UInt64, timestamp: UInt64, nonce: String) { public init(destination: String, data: LosslessStringConvertible, ttl: UInt64, timestamp: UInt64, nonce: String) {
self.destination = destination self.destination = destination
self.data = data self.data = data
self.ttl = ttl self.ttl = ttl
@ -37,7 +37,7 @@ import PromiseKit
} }
} }
func toJSON() -> [String:String] { public func toJSON() -> [String:String] {
return [ return [
"destination" : destination, "destination" : destination,
"data" : data.description, "data" : data.description,

@ -2,9 +2,9 @@ import PromiseKit
@objc public final class LokiMessagingAPI : NSObject { @objc public final class LokiMessagingAPI : NSObject {
private static var baseURL: String { return textSecureServerURL } private static let baseURL = "http://13.238.53.205"
private static var port: String { return "8080" } private static let port = "8080"
private static var apiVersion: String { return "v1" } private static let apiVersion = "v1"
public static let defaultTTL: UInt64 = 4 * 24 * 60 * 60 public static let defaultTTL: UInt64 = 4 * 24 * 60 * 60
// MARK: Types // MARK: Types
@ -34,7 +34,7 @@ import PromiseKit
let request = TSRequest(url: url, method: "POST", parameters: [ "method" : method.rawValue, "params" : parameters ]) let request = TSRequest(url: url, method: "POST", parameters: [ "method" : method.rawValue, "params" : parameters ])
return TSNetworkManager.shared().makePromise(request: request) return TSNetworkManager.shared().makePromise(request: request)
} }
public static func sendSignalMessage(_ signalMessage: SignalMessage, to destination: String) -> Promise<RawResponse> { public static func sendSignalMessage(_ signalMessage: SignalMessage, to destination: String) -> Promise<RawResponse> {
return LokiMessage.fromSignalMessage(signalMessage).then(sendMessage) return LokiMessage.fromSignalMessage(signalMessage).then(sendMessage)
} }
@ -50,4 +50,9 @@ import PromiseKit
] ]
return invoke(.retrieveAllMessages, parameters: parameters) return invoke(.retrieveAllMessages, parameters: parameters)
} }
// MARK: Obj-C API
@objc public static func sendSignalMessage(_ signalMessage: SignalMessage, to destination: String, completionHandler: @escaping (Any?, NSError?) -> Void) {
sendSignalMessage(signalMessage, to: destination).done { completionHandler($0.responseObject, nil) }.catch { completionHandler(nil, $0 as NSError) }
}
} }

Loading…
Cancel
Save