@@ -18,6 +18,7 @@ step(state::State) =
1818struct Success <: State
1919 token:: Dict{String, Any}
2020end
21+ Base. show (io:: IO , :: Success ) = print (io, " Success(<REDACTED>)" )
2122
2223abstract type Failure <: State end
2324
@@ -146,6 +147,8 @@ or NoAuthentication if not.
146147struct NeedAuthentication <: State
147148 server:: String
148149end
150+ Base. show (io:: IO , s:: NeedAuthentication ) = print (io, " NeedAuthentication($(s. server) )" )
151+
149152function step (state:: NeedAuthentication ):: Union{HasToken, NoAuthentication}
150153 path = token_path (state. server)
151154 if isfile (path)
@@ -167,6 +170,8 @@ to RequestLogin, or to Failure otherwise.
167170struct NoAuthentication <: State
168171 server:: String
169172end
173+ Base. show (io:: IO , s:: NoAuthentication ) = print (io, " NoAuthentication($(s. server) )" )
174+
170175function step (state:: NoAuthentication ):: Union{RequestLogin, Failure}
171176 challenge = Random. randstring (32 )
172177 output = IOBuffer ()
@@ -195,6 +200,8 @@ struct HasToken <: State
195200 mtime:: Float64
196201 token:: Dict{String, Any}
197202end
203+ Base. show (io:: IO , s:: HasToken ) = print (io, " HasToken($(s. server) , $(s. mtime) , <REDACTED>)" )
204+
198205function step (state:: HasToken ):: Union{NeedRefresh, Success}
199206 expiry = get (state. token, " expires_at" , get (state. token, " expires" , 0 ))
200207 expires_in = get (state. token, " expires_in" , Inf )
@@ -214,6 +221,8 @@ struct NeedRefresh <: State
214221 server:: String
215222 token:: Dict{String, Any}
216223end
224+ Base. show (io:: IO , s:: NeedRefresh ) = print (io, " NeedRefresh($(s. server) , <REDACTED>)" )
225+
217226function step (state:: NeedRefresh ):: Union{HasNewToken, NoAuthentication}
218227 refresh_token = state. token[" refresh_token" ]
219228 headers = [" Authorization" => " Bearer $refresh_token " ]
@@ -267,6 +276,8 @@ struct HasNewToken <: State
267276 token:: Dict{String, Any}
268277 tries:: Int
269278end
279+ Base. show (io:: IO , s:: HasNewToken ) = print (io, " HasNewToken($(s. server) , <REDACTED>, $(s. tries) )" )
280+
270281HasNewToken (server, token) = HasNewToken (server, token, 0 )
271282function step (state:: HasNewToken ):: Union{HasNewToken, Success, Failure}
272283 if state. tries >= 3
@@ -299,6 +310,8 @@ struct RequestLogin <: State
299310 challenge:: String
300311 response:: String
301312end
313+ Base. show (io:: IO , s:: RequestLogin ) = print (io, " RequestLogin($(s. server) , <REDACTED>, $(s. response) )" )
314+
302315function step (state:: RequestLogin ):: Union{ClaimToken, Failure}
303316 success = open_browser (string (state. server, " /response?" , state. response))
304317 if success
@@ -324,6 +337,8 @@ struct ClaimToken <: State
324337 failures:: Int
325338 max_failures:: Int
326339end
340+ Base. show (io:: IO , s:: ClaimToken ) = print (io, " ClaimToken($(s. server) , <REDACTED>, $(s. response) , $(s. expiry) , $(s. start_time) , $(s. timeout) , $(s. poll_interval) , $(s. failures) , $(s. max_failures) )" )
341+
327342ClaimToken (server, challenge, response, expiry = Inf , failures = 0 ) =
328343 ClaimToken (server, challenge, response, expiry, time (), 180 , 2 , failures, 10 )
329344
0 commit comments