Skip to main content

Module host_adopt

Module host_adopt 

Source
Expand description

A refresh that moves the stored sign-in to the host AgentMux Cloud’s discovery document names.

A sign-in keeps the Cognito host it was made on and refreshes there for good, so when the cloud moves its sign-in to another name an install would go on calling the old one until its next sign-in. After a refresh works against the discovered host, that host is the one stored. The stored host stays the fallback, so a discovery answer that names a host that does not work signs nobody out: the refresh is made there as it always was, and if it fails the error is the stored host’s.

Only when the discovery document’s client id is the one the sign-in was issued to; a different one is a user pool the cloud has left, which discovery::client_id_superseded already treats as needing a new sign-in.

And only to a host that is AgentMux’s own: the refresh token is never sent to a host discovery does not allow, whatever the document said (checked again here, at the point of use).

Functions§

host_to_adopt
The discovered host to refresh against first, if there is one: the cloud names a host that is not the stored one, for the client the sign-in was issued to, and it is one of AgentMux’s own.
refresh
Refreshes current: against the discovered host when host_to_adopt names one (the result then carries that host), else, or when that fails for any reason (an error answer, no answer, or no answer in time), against the stored host.