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

Issue:
Federated logout
It seems like auth-spa-js 1.1.0 currently does not support telling auth0 to perform a [federated logout](https://auth0.com/docs/logout/guides/logout-idps). There seems to be no way to pass the required _federated_ query parameter since the `LogoutOptions` interface does not allow this:
https://github.com/auth0/auth0-spa-js/blob/5f946338af92183298d93161e9f181b823cd2ec2/src/global.ts#L162-L179

Am i missing something? If not, can you please add an option to support auth0's federated logout?

Pull request:
Add ?federated logout param
fix #126 

### Description

Adds option to send the `federated` query param to /logout


### References

https://auth0.com/docs/logout/guides/logout-idps

### Testing

- [x] This change adds test coverage for new/changed/fixed functionality

Patch:
diff --git a/src/Auth0Client.ts b/src/Auth0Client.ts
index 7a7d74c..c817856 100644
--- a/src/Auth0Client.ts
+++ b/src/Auth0Client.ts
@@ -403,7 +403,9 @@ export default class Auth0Client {
       delete options.client_id;
     }
     ClientStorage.remove('auth0.is.authenticated');
-    const url = this._url(`/v2/logout?${createQueryParams(options)}`);
-    window.location.assign(url);
+    const { federated, ...logoutOptions } = options;
+    const federatedQuery = federated ? `&federated` : '';
+    const url = this._url(`/v2/logout?${createQueryParams(logoutOptions)}`);
+    window.location.assign(`${url}${federatedQuery}`);
   }
 }
diff --git a/src/global.ts b/src/global.ts
index b40cb00..e5ba593 100644
--- a/src/global.ts
+++ b/src/global.ts
@@ -176,6 +176,14 @@ interface LogoutOptions {
    * The `client_id` of your application.
    */
   client_id?: string;
+
+  /**
+   * When supported by the upstream identity provider,
+   * forces the user to logout of their identity provider
+   * and from Auth0.
+   * [Read more about how federated logout works at Auth0](https://auth0.com/docs/logout/guides/logout-idps)
+   */
+  federated?: boolean;
 }
 
 /**


Test patch:
diff --git a/__tests__/index.test.ts b/__tests__/index.test.ts
index dd41699..b797f01 100644
--- a/__tests__/index.test.ts
+++ b/__tests__/index.test.ts
@@ -947,6 +947,12 @@ describe('Auth0', () => {
         returnTo: 'https://return.to'
       });
     });
+    it('creates correct query params when `options.federated` is true', async () => {
+      const { auth0, utils } = await setup();
+
+      auth0.logout({ federated: true, client_id: null });
+      expect(utils.createQueryParams).toHaveBeenCalledWith({});
+    });
     it('calls `window.location.assign` with the correct url', async () => {
       const { auth0 } = await setup();
 
@@ -955,6 +961,14 @@ describe('Auth0', () => {
         `https://test.auth0.com/v2/logout?query=params${TEST_TELEMETRY_QUERY_STRING}`
       );
     });
+    it('calls `window.location.assign` with the correct url when `options.federated` is true', async () => {
+      const { auth0 } = await setup();
+
+      auth0.logout({ federated: true });
+      expect(window.location.assign).toHaveBeenCalledWith(
+        `https://test.auth0.com/v2/logout?query=params${TEST_TELEMETRY_QUERY_STRING}&federated`
+      );
+    });
   });
 });
 describe('default creation function', () => {