Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using workbox to allow us access to setting up a route to handle the token resposne for any call to an /oauth/token endpoint that we have a valid config for & to improve general stability of the worker.
Also uses IndexedDB to store the token data (I can also refactor the main index to use IndexedDB for consistency) rather than relying on a global variable in a service worker. Service workers in general have no guarantees about lifetimes, they can be killed for any reason and we were seeing this behaviour across multiple devices and environments where the authentication setup would just drop out and the user would have to re-auth.
IndexedDB scope is limited to the origin only, so with a sensible CSP on the frontend server there is no compromise in security as far as I'm aware here.
Tested all day yesterday periodically refreshing the petshop demo app & randomly removing the access token & expiry and I was always able to regenerate the token.
These changes also make some possibly aggressive assumptions about the behaviour of token refreshing, so happy to have a discussion about rolling some of them back 😄 There are docs changes I should add in here too, but I'm anticipating the aforementioned discussion, if this is going to be accepted then I'll also add in needed changes