@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.
@@ -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
3
  * import { disconnectClient } from '@amityco/ts-sdk-react-native'
4
- * const success = await disconnectClient()
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
@@ -118,8 +118,8 @@ const PostContentType = Object.freeze({
118
118
 
119
119
  function getVersion() {
120
120
  try {
121
- // the string ''v6.21.1-cjs'' should be replaced by actual value by @rollup/plugin-replace
122
- return 'v6.21.1-cjs';
121
+ // the string ''v6.22.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
122
+ return 'v6.22.0-cjs';
123
123
  }
124
124
  catch (error) {
125
125
  return '__dev__';
@@ -7786,7 +7786,7 @@ var objectResolverEngineOnLoginHandler = () => {
7786
7786
  /**
7787
7787
  * ```js
7788
7788
  * import { disconnectClient } from '@amityco/ts-sdk-react-native'
7789
- * const success = await disconnectClient()
7789
+ * const success = await Client.logout()
7790
7790
  * ```
7791
7791
  *
7792
7792
  * Disconnects an {@link Amity.Client} instance from ASC servers
@@ -9053,6 +9053,33 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
9053
9053
  return client;
9054
9054
  };
9055
9055
 
9056
+ /* begin_public_function
9057
+ id: client.secureLogout
9058
+ */
9059
+ /**
9060
+ * ```js
9061
+ * import { Client } from '@amityco/ts-sdk'
9062
+ * const success = await Client.secureLogout()
9063
+ * ```
9064
+ *
9065
+ * Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers
9066
+ *
9067
+ * @returns a success boolean if disconnected
9068
+ *
9069
+ * @category Client API
9070
+ * @async
9071
+ */
9072
+ const secureLogout = async () => {
9073
+ const client = getActiveClient();
9074
+ const { data: { success }, } = await client.http.delete('/api/v4/sessions');
9075
+ if (!success) {
9076
+ throw new Error('Failed to logout');
9077
+ }
9078
+ const result = await logout();
9079
+ return result;
9080
+ };
9081
+ /* end_public_function */
9082
+
9056
9083
  /**
9057
9084
  * ```js
9058
9085
  * import { isConnected } from '@amityco/ts-sdk-react-native'
@@ -9583,6 +9610,7 @@ var index$k = /*#__PURE__*/Object.freeze({
9583
9610
  createClient: createClient,
9584
9611
  login: login,
9585
9612
  logout: logout,
9613
+ secureLogout: secureLogout,
9586
9614
  isConnected: isConnected,
9587
9615
  getFeedSettings: getFeedSettings,
9588
9616
  renewal: renewal,
package/dist/index.esm.js CHANGED
@@ -84,8 +84,8 @@ const PostContentType = Object.freeze({
84
84
 
85
85
  function getVersion() {
86
86
  try {
87
- // the string ''v6.21.1-esm'' should be replaced by actual value by @rollup/plugin-replace
88
- return 'v6.21.1-esm';
87
+ // the string ''v6.22.0-esm'' should be replaced by actual value by @rollup/plugin-replace
88
+ return 'v6.22.0-esm';
89
89
  }
90
90
  catch (error) {
91
91
  return '__dev__';
@@ -23857,7 +23857,7 @@ var objectResolverEngineOnLoginHandler = () => {
23857
23857
  /**
23858
23858
  * ```js
23859
23859
  * import { disconnectClient } from '@amityco/ts-sdk-react-native'
23860
- * const success = await disconnectClient()
23860
+ * const success = await Client.logout()
23861
23861
  * ```
23862
23862
  *
23863
23863
  * Disconnects an {@link Amity.Client} instance from ASC servers
@@ -25124,6 +25124,33 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
25124
25124
  return client;
25125
25125
  };
25126
25126
 
25127
+ /* begin_public_function
25128
+ id: client.secureLogout
25129
+ */
25130
+ /**
25131
+ * ```js
25132
+ * import { Client } from '@amityco/ts-sdk'
25133
+ * const success = await Client.secureLogout()
25134
+ * ```
25135
+ *
25136
+ * Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers
25137
+ *
25138
+ * @returns a success boolean if disconnected
25139
+ *
25140
+ * @category Client API
25141
+ * @async
25142
+ */
25143
+ const secureLogout = async () => {
25144
+ const client = getActiveClient();
25145
+ const { data: { success }, } = await client.http.delete('/api/v4/sessions');
25146
+ if (!success) {
25147
+ throw new Error('Failed to logout');
25148
+ }
25149
+ const result = await logout();
25150
+ return result;
25151
+ };
25152
+ /* end_public_function */
25153
+
25127
25154
  /**
25128
25155
  * ```js
25129
25156
  * import { isConnected } from '@amityco/ts-sdk-react-native'
@@ -25654,6 +25681,7 @@ var index$k = /*#__PURE__*/Object.freeze({
25654
25681
  createClient: createClient,
25655
25682
  login: login,
25656
25683
  logout: logout,
25684
+ secureLogout: secureLogout,
25657
25685
  isConnected: isConnected,
25658
25686
  getFeedSettings: getFeedSettings,
25659
25687
  renewal: renewal,