@todo-3.0/request
v0.1.0
Published
Handle Authenticated HTTP Requests
Readme
@todo-3.0/request
A library for authenticated HTTP calls.
Internals
Notes
- Errors for AuthUser
- Invalid Request
- Unauthenticated
- Network error
- User canceled login prompt
- Errors for Request
- Network error
- Refresh call returned bad or malformed data
- Other errors
- Errors for Refresh
Server returned malformed 401 response
Network error
Init
Initial state. Checks the current status for authentication and refresh tokens.
AuthUser
(Attempts to) authenticate the user through the supplied authenticator.
Request
Does the actual request to the target server. On authentication errors, an attempt is either made to refresh our current token, or to obtain a new token (both by going to the corresponding state).
ResponsePositive
Upon successfully executing a request, this state is passed through to re-pack the data.
ResponseNegative
On irrecoverable failures (which is everything except request to authenticate), this state is passed through to re-pack data.
Refresh
Calls the supplied refresh function in an attempt to obtain a new authentication token.
Final
Returns the (good or bad) response, finishing the state machine.
