[WIP] Authentication context (resolves #94)
- Built on top of #96
- Added a generic context type to the
Gitclass which allows theauthenticatefunction to respond with a context value (inspired by thecontextcallback inApolloServer). - Context value included in all request-related events
- Refactored the request flow to ensure all HTTP requests are authenticated (even if that means a push results in multiple
authenticatecalls).
Aside from the changes to authenticate every request the re-factoring was mostly to help me reduce the number of code paths that need to be supported.
The more optionally-async optionally-promise callbacks we support the messier the code becomes and it was hard for me to be confident all code branches were correct.
That being said I'm happy to go backwards on some of this refactoring now that it all seems to work.
Left as a WIP as I want to expand the test suite to cover more error cases.
I left a few comments, it will take time to go through this change more thoroughly.
Sure, will address those a bit later today. Once using the library after this refactor... requiring throwing from authenticate feels a bit off. Do you think returning false would be better?