Skip to content

Commit

Permalink
more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
MattKiazyk committed Oct 30, 2024
1 parent c560d56 commit 72540e9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/AppleAPI/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public class Client {
let clientKeys = client.generateKeys()
let a = clientKeys.public

// Get the Service Key needed from olympus session needed in headers
return firstly { () -> Promise<(data: Data, response: URLResponse)> in
Current.network.dataTask(with: URLRequest.itcServiceKey)
}
Expand All @@ -81,9 +82,11 @@ public class Client {
let response = try JSONDecoder().decode(ServiceKeyResponse.self, from: data)
serviceKey = response.authServiceKey

/// Load a hashcash of the account name
return self.loadHashcash(accountName: accountName, serviceKey: serviceKey).map { (serviceKey, $0) }
}
.then { (serviceKey, hashcash) -> Promise<(serviceKey: String, hashcash: String, data: Data)> in
/// Call the SRP /init endpoint to start the login
return Current.network.dataTask(with: URLRequest.SRPInit(serviceKey: serviceKey, a: Data(a.bytes).base64EncodedString(), accountName: accountName)).map { (serviceKey, hashcash, $0.data)}
}
.then { (serviceKey, hashcash, data) -> Promise<(data: Data, response: URLResponse)> in
Expand All @@ -108,6 +111,7 @@ public class Client {
let m1 = client.calculateClientProof(username: accountName, salt: [UInt8](decodedSalt), clientPublicKey: a, serverPublicKey: .init([UInt8](decodedB)), sharedSecret: .init(sharedSecret.bytes))
let m2 = client.calculateServerProof(clientPublicKey: a, clientProof: m1, sharedSecret: .init([UInt8](sharedSecret.bytes)))

/// call the /complete endpoint passing in the hashcash, servicekey, and the calculated proof.
return Current.network.dataTask(with: URLRequest.SRPComplete(serviceKey: serviceKey, hashcash: hashcash, accountName: accountName, c: srpInit.c, m1: Data(m1).base64EncodedString(), m2: Data(m2).base64EncodedString()))
} catch {
throw Error.srpError(error.localizedDescription)
Expand Down

0 comments on commit 72540e9

Please sign in to comment.