@amityco/ts-sdk-react-native 6.21.1 → 6.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk-react-native",
3
- "version": "6.21.1",
3
+ "version": "6.22.0",
4
4
  "license": "CC-BY-ND-4.0",
5
5
  "author": "amity.co <developers@amity.co> (https://amity.co)",
6
6
  "description": "Amity Social Cloud Typescript SDK",
@@ -5,6 +5,7 @@ export * from './createClient';
5
5
 
6
6
  export * from './login';
7
7
  export * from './logout';
8
+ export * from './secureLogout';
8
9
 
9
10
  export * from './isConnected';
10
11
 
@@ -7,7 +7,7 @@ import { setSessionState } from './setSessionState';
7
7
  /**
8
8
  * ```js
9
9
  * import { disconnectClient } from '@amityco/ts-sdk-react-native'
10
- * const success = await disconnectClient()
10
+ * const success = await Client.logout()
11
11
  * ```
12
12
  *
13
13
  * Disconnects an {@link Amity.Client} instance from ASC servers
@@ -0,0 +1,33 @@
1
+ import { getActiveClient } from '~/client/api/activeClient';
2
+ import { logout } from './logout';
3
+
4
+ /* begin_public_function
5
+ id: client.secureLogout
6
+ */
7
+ /**
8
+ * ```js
9
+ * import { Client } from '@amityco/ts-sdk'
10
+ * const success = await Client.secureLogout()
11
+ * ```
12
+ *
13
+ * Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers
14
+ *
15
+ * @returns a success boolean if disconnected
16
+ *
17
+ * @category Client API
18
+ * @async
19
+ */
20
+ export const secureLogout = async (): Promise<boolean> => {
21
+ const client = getActiveClient();
22
+ const {
23
+ data: { success },
24
+ } = await client.http.delete<{ success: boolean }>('/api/v4/sessions');
25
+
26
+ if (!success) {
27
+ throw new Error('Failed to logout');
28
+ }
29
+
30
+ const result = await logout();
31
+ return result;
32
+ };
33
+ /* end_public_function */