@@ -70,6 +70,7 @@ public class Client {
7070 let clientKeys = client. generateKeys ( )
7171 let a = clientKeys. public
7272
73+ // Get the Service Key needed from olympus session needed in headers
7374 return firstly { ( ) -> Promise < ( data: Data , response: URLResponse ) > in
7475 Current . network. dataTask ( with: URLRequest . itcServiceKey)
7576 }
@@ -81,9 +82,11 @@ public class Client {
8182 let response = try JSONDecoder ( ) . decode ( ServiceKeyResponse . self, from: data)
8283 serviceKey = response. authServiceKey
8384
85+ /// Load a hashcash of the account name
8486 return self . loadHashcash ( accountName: accountName, serviceKey: serviceKey) . map { ( serviceKey, $0) }
8587 }
8688 . then { ( serviceKey, hashcash) -> Promise < ( serviceKey: String , hashcash: String , data: Data ) > in
89+ /// Call the SRP /init endpoint to start the login
8790 return Current . network. dataTask ( with: URLRequest . SRPInit ( serviceKey: serviceKey, a: Data ( a. bytes) . base64EncodedString ( ) , accountName: accountName) ) . map { ( serviceKey, hashcash, $0. data) }
8891 }
8992 . then { ( serviceKey, hashcash, data) -> Promise < ( data: Data , response: URLResponse ) > in
@@ -108,6 +111,7 @@ public class Client {
108111 let m1 = client. calculateClientProof ( username: accountName, salt: [ UInt8] ( decodedSalt) , clientPublicKey: a, serverPublicKey: . init( [ UInt8] ( decodedB) ) , sharedSecret: . init( sharedSecret. bytes) )
109112 let m2 = client. calculateServerProof ( clientPublicKey: a, clientProof: m1, sharedSecret: . init( [ UInt8] ( sharedSecret. bytes) ) )
110113
114+ /// call the /complete endpoint passing in the hashcash, servicekey, and the calculated proof.
111115 return Current . network. dataTask ( with: URLRequest . SRPComplete ( serviceKey: serviceKey, hashcash: hashcash, accountName: accountName, c: srpInit. c, m1: Data ( m1) . base64EncodedString ( ) , m2: Data ( m2) . base64EncodedString ( ) ) )
112116 } catch {
113117 throw Error . srpError ( error. localizedDescription)
0 commit comments