Creates a new instance of CachingJwtProvider
.
The function that will be called
whenever the fresh JWT is needed. If the renewJwtFn
returns the JWT
as a string, it will be converted to Jwt instance automatically.
Returns a Promise
resolved with the cached token if it's fresh, or the
token obtained by the call to the renewJwtCallback
otherwise. The token
obtained from the renewJwtCallback
is then cached. If the renewJwtCallback
returns the JWT as a string, it is converted to Jwt instance before returning.
Implementation of IAccessTokenProvider that caches the JWT in memory while it's fresh (i.e. not expired) and uses the user-provided callback function to get the JWT when requested by the clients.