@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/dist/client/api/index.d.ts +1 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/client/api/logout.d.ts +1 -1
- package/dist/client/api/secureLogout.d.ts +15 -0
- package/dist/client/api/secureLogout.d.ts.map +1 -0
- package/dist/index.cjs.js +31 -3
- package/dist/index.esm.js +31 -3
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
- package/src/client/api/index.ts +1 -0
- package/src/client/api/logout.ts +1 -1
- package/src/client/api/secureLogout.ts +33 -0
package/package.json
CHANGED
package/src/client/api/index.ts
CHANGED
package/src/client/api/logout.ts
CHANGED
|
@@ -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
|
|
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 */
|