@amityco/ts-sdk 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.
@@ -3,6 +3,7 @@ export * from './activeUser';
3
3
  export * from './createClient';
4
4
  export * from './login';
5
5
  export * from './logout';
6
+ export * from './secureLogout';
6
7
  export * from './isConnected';
7
8
  export * from './getFeedSettings';
8
9
  export * from './renewal';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,cAAc,cAAc,CAAC;AAE7B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AAEzB,cAAc,eAAe,CAAC;AAE9B,cAAc,mBAAmB,CAAC;AAElC,cAAc,WAAW,CAAC;AAE1B,cAAc,cAAc,CAAC;AAE7B,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,cAAc,cAAc,CAAC;AAE7B,cAAc,gBAAgB,CAAC;AAE/B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAE/B,cAAc,eAAe,CAAC;AAE9B,cAAc,mBAAmB,CAAC;AAElC,cAAc,WAAW,CAAC;AAE1B,cAAc,cAAc,CAAC;AAE7B,cAAc,qBAAqB,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * ```js
3
- * import { disconnectClient } from '@amityco/ts-sdk'
4
- * const success = await disconnectClient()
3
+ * import { Client } from '@amityco/ts-sdk';
4
+ * const success = await Client.logout()
5
5
  * ```
6
6
  *
7
7
  * Disconnects an {@link Amity.Client} instance from ASC servers
@@ -0,0 +1,15 @@
1
+ /**
2
+ * ```js
3
+ * import { Client } from '@amityco/ts-sdk'
4
+ * const success = await Client.secureLogout()
5
+ * ```
6
+ *
7
+ * Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers
8
+ *
9
+ * @returns a success boolean if disconnected
10
+ *
11
+ * @category Client API
12
+ * @async
13
+ */
14
+ export declare const secureLogout: () => Promise<boolean>;
15
+ //# sourceMappingURL=secureLogout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secureLogout.d.ts","sourceRoot":"","sources":["../../../src/client/api/secureLogout.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,QAAa,QAAQ,OAAO,CAYpD,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -98,8 +98,8 @@ const PostContentType = Object.freeze({
98
98
 
99
99
  function getVersion() {
100
100
  try {
101
- // the string ''v6.21.1-cjs'' should be replaced by actual value by @rollup/plugin-replace
102
- return 'v6.21.1-cjs';
101
+ // the string ''v6.22.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
102
+ return 'v6.22.0-cjs';
103
103
  }
104
104
  catch (error) {
105
105
  return '__dev__';
@@ -7727,8 +7727,8 @@ var objectResolverEngineOnLoginHandler = () => {
7727
7727
  */
7728
7728
  /**
7729
7729
  * ```js
7730
- * import { disconnectClient } from '@amityco/ts-sdk'
7731
- * const success = await disconnectClient()
7730
+ * import { Client } from '@amityco/ts-sdk';
7731
+ * const success = await Client.logout()
7732
7732
  * ```
7733
7733
  *
7734
7734
  * Disconnects an {@link Amity.Client} instance from ASC servers
@@ -8995,6 +8995,33 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
8995
8995
  return client;
8996
8996
  };
8997
8997
 
8998
+ /* begin_public_function
8999
+ id: client.secureLogout
9000
+ */
9001
+ /**
9002
+ * ```js
9003
+ * import { Client } from '@amityco/ts-sdk'
9004
+ * const success = await Client.secureLogout()
9005
+ * ```
9006
+ *
9007
+ * Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers
9008
+ *
9009
+ * @returns a success boolean if disconnected
9010
+ *
9011
+ * @category Client API
9012
+ * @async
9013
+ */
9014
+ const secureLogout = async () => {
9015
+ const client = getActiveClient();
9016
+ const { data: { success }, } = await client.http.delete('/api/v4/sessions');
9017
+ if (!success) {
9018
+ throw new Error('Failed to logout');
9019
+ }
9020
+ const result = await logout();
9021
+ return result;
9022
+ };
9023
+ /* end_public_function */
9024
+
8998
9025
  /**
8999
9026
  * ```js
9000
9027
  * import { isConnected } from '@amityco/ts-sdk'
@@ -9525,6 +9552,7 @@ var index$k = /*#__PURE__*/Object.freeze({
9525
9552
  createClient: createClient,
9526
9553
  login: login,
9527
9554
  logout: logout,
9555
+ secureLogout: secureLogout,
9528
9556
  isConnected: isConnected,
9529
9557
  getFeedSettings: getFeedSettings,
9530
9558
  renewal: renewal,
package/dist/index.esm.js CHANGED
@@ -83,8 +83,8 @@ const PostContentType = Object.freeze({
83
83
 
84
84
  function getVersion() {
85
85
  try {
86
- // the string ''v6.21.1-esm'' should be replaced by actual value by @rollup/plugin-replace
87
- return 'v6.21.1-esm';
86
+ // the string ''v6.22.0-esm'' should be replaced by actual value by @rollup/plugin-replace
87
+ return 'v6.22.0-esm';
88
88
  }
89
89
  catch (error) {
90
90
  return '__dev__';
@@ -23817,8 +23817,8 @@ var objectResolverEngineOnLoginHandler = () => {
23817
23817
  */
23818
23818
  /**
23819
23819
  * ```js
23820
- * import { disconnectClient } from '@amityco/ts-sdk'
23821
- * const success = await disconnectClient()
23820
+ * import { Client } from '@amityco/ts-sdk';
23821
+ * const success = await Client.logout()
23822
23822
  * ```
23823
23823
  *
23824
23824
  * Disconnects an {@link Amity.Client} instance from ASC servers
@@ -25085,6 +25085,33 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
25085
25085
  return client;
25086
25086
  };
25087
25087
 
25088
+ /* begin_public_function
25089
+ id: client.secureLogout
25090
+ */
25091
+ /**
25092
+ * ```js
25093
+ * import { Client } from '@amityco/ts-sdk'
25094
+ * const success = await Client.secureLogout()
25095
+ * ```
25096
+ *
25097
+ * Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers
25098
+ *
25099
+ * @returns a success boolean if disconnected
25100
+ *
25101
+ * @category Client API
25102
+ * @async
25103
+ */
25104
+ const secureLogout = async () => {
25105
+ const client = getActiveClient();
25106
+ const { data: { success }, } = await client.http.delete('/api/v4/sessions');
25107
+ if (!success) {
25108
+ throw new Error('Failed to logout');
25109
+ }
25110
+ const result = await logout();
25111
+ return result;
25112
+ };
25113
+ /* end_public_function */
25114
+
25088
25115
  /**
25089
25116
  * ```js
25090
25117
  * import { isConnected } from '@amityco/ts-sdk'
@@ -25615,6 +25642,7 @@ var index$k = /*#__PURE__*/Object.freeze({
25615
25642
  createClient: createClient,
25616
25643
  login: login,
25617
25644
  logout: logout,
25645
+ secureLogout: secureLogout,
25618
25646
  isConnected: isConnected,
25619
25647
  getFeedSettings: getFeedSettings,
25620
25648
  renewal: renewal,