@amityco/ts-sdk-react-native 7.21.1-2883a955.0 → 7.21.1-28cb8278.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.
@@ -4,7 +4,8 @@
4
4
  * const success = await Client.secureLogout()
5
5
  * ```
6
6
  *
7
- * Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers
7
+ * Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers.
8
+ * Automatically unregisters push notifications and clears all cache before disconnecting.
8
9
  *
9
10
  * @returns a success boolean if disconnected
10
11
  *
@@ -1 +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"}
1
+ {"version":3,"file":"secureLogout.d.ts","sourceRoot":"","sources":["../../../src/client/api/secureLogout.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,QAAa,QAAQ,OAAO,CAoBpD,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -10481,6 +10481,21 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
10481
10481
  return client;
10482
10482
  };
10483
10483
 
10484
+ const unregisterPushNotification = async () => {
10485
+ const client = getActiveClient();
10486
+ const deviceId = await getDeviceId();
10487
+ const { data: { status, error }, } = await client.http.delete('/v1/notification', {
10488
+ params: {
10489
+ deviceId,
10490
+ },
10491
+ headers: { 'X-API-Key': client.apiKey },
10492
+ });
10493
+ if (error) {
10494
+ throw new ASCApiError(error, 500000 /* Amity.ServerError.BUSINESS_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
10495
+ }
10496
+ return status === 'success';
10497
+ };
10498
+
10484
10499
  /* begin_public_function
10485
10500
  id: client.secureLogout
10486
10501
  */
@@ -10490,7 +10505,8 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
10490
10505
  * const success = await Client.secureLogout()
10491
10506
  * ```
10492
10507
  *
10493
- * Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers
10508
+ * Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers.
10509
+ * Automatically unregisters push notifications and clears all cache before disconnecting.
10494
10510
  *
10495
10511
  * @returns a success boolean if disconnected
10496
10512
  *
@@ -10503,6 +10519,14 @@ const secureLogout = async () => {
10503
10519
  if (!success) {
10504
10520
  throw new Error('Failed to logout');
10505
10521
  }
10522
+ // Unregister push notification before clearing the session.
10523
+ // logout() clears cache, disconnects MQTT and emitter — so this must run first.
10524
+ try {
10525
+ await unregisterPushNotification();
10526
+ }
10527
+ catch (e) {
10528
+ client.log('client/api/secureLogout: failed to unregister push notification', e);
10529
+ }
10506
10530
  const result = await logout();
10507
10531
  return result;
10508
10532
  };
@@ -10709,21 +10733,6 @@ const registerPushNotification = async (deviceToken) => {
10709
10733
  return status === 'success';
10710
10734
  };
10711
10735
 
10712
- const unregisterPushNotification = async () => {
10713
- const client = getActiveClient();
10714
- const deviceId = getDeviceId();
10715
- const { data: { status, error }, } = await client.http.delete('/v1/notification', {
10716
- params: {
10717
- deviceId,
10718
- },
10719
- headers: { 'X-API-Key': client.apiKey },
10720
- });
10721
- if (error) {
10722
- throw new ASCApiError(error, 500000 /* Amity.ServerError.BUSINESS_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
10723
- }
10724
- return status === 'success';
10725
- };
10726
-
10727
10736
  /**
10728
10737
  * @deprecated This function will to be deprecated and use the new getLinkPreviewMetadata
10729
10738
  */
package/dist/index.esm.js CHANGED
@@ -26554,6 +26554,21 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
26554
26554
  return client;
26555
26555
  };
26556
26556
 
26557
+ const unregisterPushNotification = async () => {
26558
+ const client = getActiveClient();
26559
+ const deviceId = await getDeviceId();
26560
+ const { data: { status, error }, } = await client.http.delete('/v1/notification', {
26561
+ params: {
26562
+ deviceId,
26563
+ },
26564
+ headers: { 'X-API-Key': client.apiKey },
26565
+ });
26566
+ if (error) {
26567
+ throw new ASCApiError(error, 500000 /* Amity.ServerError.BUSINESS_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
26568
+ }
26569
+ return status === 'success';
26570
+ };
26571
+
26557
26572
  /* begin_public_function
26558
26573
  id: client.secureLogout
26559
26574
  */
@@ -26563,7 +26578,8 @@ const createClient = (apiKey, apiRegion = API_REGIONS.SG, { debugSession = DEFAU
26563
26578
  * const success = await Client.secureLogout()
26564
26579
  * ```
26565
26580
  *
26566
- * Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers
26581
+ * Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers.
26582
+ * Automatically unregisters push notifications and clears all cache before disconnecting.
26567
26583
  *
26568
26584
  * @returns a success boolean if disconnected
26569
26585
  *
@@ -26576,6 +26592,14 @@ const secureLogout = async () => {
26576
26592
  if (!success) {
26577
26593
  throw new Error('Failed to logout');
26578
26594
  }
26595
+ // Unregister push notification before clearing the session.
26596
+ // logout() clears cache, disconnects MQTT and emitter — so this must run first.
26597
+ try {
26598
+ await unregisterPushNotification();
26599
+ }
26600
+ catch (e) {
26601
+ client.log('client/api/secureLogout: failed to unregister push notification', e);
26602
+ }
26579
26603
  const result = await logout();
26580
26604
  return result;
26581
26605
  };
@@ -26782,21 +26806,6 @@ const registerPushNotification = async (deviceToken) => {
26782
26806
  return status === 'success';
26783
26807
  };
26784
26808
 
26785
- const unregisterPushNotification = async () => {
26786
- const client = getActiveClient();
26787
- const deviceId = getDeviceId();
26788
- const { data: { status, error }, } = await client.http.delete('/v1/notification', {
26789
- params: {
26790
- deviceId,
26791
- },
26792
- headers: { 'X-API-Key': client.apiKey },
26793
- });
26794
- if (error) {
26795
- throw new ASCApiError(error, 500000 /* Amity.ServerError.BUSINESS_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
26796
- }
26797
- return status === 'success';
26798
- };
26799
-
26800
26809
  /**
26801
26810
  * @deprecated This function will to be deprecated and use the new getLinkPreviewMetadata
26802
26811
  */