@@ -70,6 +70,7 @@ public class Client {
70
70
let clientKeys = client. generateKeys ( )
71
71
let a = clientKeys. public
72
72
73
+ // Get the Service Key needed from olympus session needed in headers
73
74
return firstly { ( ) -> Promise < ( data: Data , response: URLResponse ) > in
74
75
Current . network. dataTask ( with: URLRequest . itcServiceKey)
75
76
}
@@ -81,9 +82,11 @@ public class Client {
81
82
let response = try JSONDecoder ( ) . decode ( ServiceKeyResponse . self, from: data)
82
83
serviceKey = response. authServiceKey
83
84
85
+ /// Load a hashcash of the account name
84
86
return self . loadHashcash ( accountName: accountName, serviceKey: serviceKey) . map { ( serviceKey, $0) }
85
87
}
86
88
. then { ( serviceKey, hashcash) -> Promise < ( serviceKey: String , hashcash: String , data: Data ) > in
89
+ /// Call the SRP /init endpoint to start the login
87
90
return Current . network. dataTask ( with: URLRequest . SRPInit ( serviceKey: serviceKey, a: Data ( a. bytes) . base64EncodedString ( ) , accountName: accountName) ) . map { ( serviceKey, hashcash, $0. data) }
88
91
}
89
92
. then { ( serviceKey, hashcash, data) -> Promise < ( data: Data , response: URLResponse ) > in
@@ -108,6 +111,7 @@ public class Client {
108
111
let m1 = client. calculateClientProof ( username: accountName, salt: [ UInt8] ( decodedSalt) , clientPublicKey: a, serverPublicKey: . init( [ UInt8] ( decodedB) ) , sharedSecret: . init( sharedSecret. bytes) )
109
112
let m2 = client. calculateServerProof ( clientPublicKey: a, clientProof: m1, sharedSecret: . init( [ UInt8] ( sharedSecret. bytes) ) )
110
113
114
+ /// call the /complete endpoint passing in the hashcash, servicekey, and the calculated proof.
111
115
return Current . network. dataTask ( with: URLRequest . SRPComplete ( serviceKey: serviceKey, hashcash: hashcash, accountName: accountName, c: srpInit. c, m1: Data ( m1) . base64EncodedString ( ) , m2: Data ( m2) . base64EncodedString ( ) ) )
112
116
} catch {
113
117
throw Error . srpError ( error. localizedDescription)
0 commit comments