* Refactor how token refreshing works to be more resilient
1. ensure we do use the new token if it is not explicitly inhibited by the caller
2. eagerly refresh token if we know it is expired
3. allow refreshing a token multiple times if e.g. on bad connection or the environment has been slept and sufficient time has passed since the last refresh attempt
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Iterate
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Iterate
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Add exponential backoff
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Ensure no timing effects on `authedRequest` method call
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Iterate
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---------
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Fix token refresh racing with other requests and not using new token
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Iterate
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---------
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
* Update src with globalThis
* Update spec with globalThis
* Replace in more spec/ places
* More changes to src/
* Add a linter rule for global
* Prettify
* lint
* very messy poc
* iterate
* more types and use tokenRefreshFunction
* working refresh without persistence
* tidy
* add claims to completeauhtorizationcodegrant response
* export tokenrefresher from matrix
* add idtokenclaims
* add claims to completeauhtorizationcodegrant response
* only one token refresh attempt at a time
* tests
* comments
* add tokenRefresher class
* export generateScope
* export oidc from matrix
* test refreshtoken
* mark experimental
* add getRefreshToken to client
* Apply suggestions from code review
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* remove some vars in test
* make TokenRefresher un-abstract, comments and improvements
* remove invalid jsdoc
* Update src/oidc/tokenRefresher.ts
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Code review improvements
* fix verification integ tests
* remove unused type from props
* fix incomplete mock fn in fetch.spec
* document TokenRefreshFunction
* comments
* tidying
* update for injected logger
---------
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
* Support MatrixClient-specific loggers.
Signed-off-by: Patrick Cloke <clokep@patrick.cloke.us>
* Use client-specific logger in client.ts.
Signed-off-by: Patrick Cloke <clokep@patrick.cloke.us>
* Log `fetch` requests to the per-client logger
* Use client-specific logger in rust-crypto
These tests have broken on Node.js 18.17.0.
This is due to Node.js adopting an updated version of the URL parser, in which
the internal `Symbol(query)` property is populated lazily.
We shouldn't be relying on the internal state of the URL object anyway. Let's
just compare the stringified copy.
* Simple request logging with status and duration
* remove url params from logs
* superfluous toString()
* Add tests
* Apply suggestions from code review
* update snapshots
* update log format
* Apply suggestions from code review
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
* update snapshot
---------
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Co-authored-by: Richard van der Hoff <richard@matrix.org>