Repository: auth0/auth0-spa-js (ts)

Issue:
getTokenSilently takes `timeout` options instead of `timeoutInSeconds`
Hello! We've bumped into a nasty bug where `timeoutInSeconds` options passed into `getTokenSilently`is ignored and couldn't figure out where the issue is. Upon inspecting library's code we were able to identify that the `timeoutInSeconds` is not used at all in [_getTokenUsingRefreshToken](https://github.com/auth0/auth0-spa-js/blob/5959a2c3f262aec98613964b21975324f440515b/src/Auth0Client.ts#L875) which is called eventually in `getTokenSilently`.

Instead [`customOptions`](https://github.com/auth0/auth0-spa-js/blob/5959a2c3f262aec98613964b21975324f440515b/src/Auth0Client.ts#L883) is passed into [`oauthToken`](https://github.com/auth0/auth0-spa-js/blob/5959a2c3f2/src/utils.ts#L361) as is, which expects `timeout` option.

This is especially confusing since docs doesn't mention `timeout` option at all https://auth0.github.io/auth0-spa-js/interfaces/gettokensilentlyoptions.html

Pull request:
[SDK-2156] Heed timeoutInSeconds when calling getTokenSilently with refresh tokens
### Description

This PR fixes an issue where specifying `timeoutInSeconds` to `getTokenSilently` would have no effect, and instead always defaulting to 10 seconds.

Fixes #636 


### Testing

- [X] This change adds test coverage for new/changed/fixed functionality

### Checklist

- [X] I have added documentation for new/changed functionality in this PR or in auth0.com/docs
- [X] All active GitHub checks for tests, formatting, and security are passing
- [X] The correct base branch is being used, if not `master`


Patch:
diff --git a/src/Auth0Client.ts b/src/Auth0Client.ts
index 5ac7dda..d0c7875 100644
--- a/src/Auth0Client.ts
+++ b/src/Auth0Client.ts
@@ -876,6 +876,11 @@ export default class Auth0Client {
       ...customOptions
     } = options;
 
+    const timeout =
+      typeof options.timeoutInSeconds === 'number'
+        ? options.timeoutInSeconds * 1000
+        : null;
+
     try {
       tokenResult = await oauthToken(
         {
@@ -887,7 +892,8 @@ export default class Auth0Client {
           client_id: this.options.client_id,
           grant_type: 'refresh_token',
           refresh_token: cache && cache.refresh_token,
-          redirect_uri
+          redirect_uri,
+          ...(timeout && { timeout })
         } as RefreshTokenOptions,
         this.worker
       );


Test patch:
diff --git a/__tests__/index.test.ts b/__tests__/index.test.ts
index 15953b7..dad8245 100644
--- a/__tests__/index.test.ts
+++ b/__tests__/index.test.ts
@@ -1120,7 +1120,10 @@ describe('Auth0', () => {
 
           cache.get.mockReturnValue({ refresh_token: TEST_REFRESH_TOKEN });
 
-          await auth0.getTokenSilently({ ignoreCache: true });
+          await auth0.getTokenSilently({
+            ignoreCache: true,
+            timeoutInSeconds: 10
+          });
 
           expect(cache.get).toHaveBeenCalledWith({
             audience: 'default',
@@ -1136,7 +1139,8 @@ describe('Auth0', () => {
               refresh_token: TEST_REFRESH_TOKEN,
               client_id: TEST_CLIENT_ID,
               grant_type: 'refresh_token',
-              redirect_uri: 'http://localhost'
+              redirect_uri: 'http://localhost',
+              timeout: 10000
             },
             webWorkerMatcher
           );