akeyless-client-commons 1.1.29 → 1.1.31

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.
@@ -1446,9 +1446,14 @@ var snapshot = function(config, snapshotsFirstTime, settings) {
1446
1446
  });
1447
1447
  }
1448
1448
  var unsubscribe = (0, import_firestore.onSnapshot)(collectionRef, function(snapshot2) {
1449
- if (!snapshotsFirstTime.includes(config.collectionName)) {
1449
+ var firstTimeKey = JSON.stringify({
1450
+ collectionName: config.collectionName,
1451
+ conditions: config.conditions || [],
1452
+ orderBy: config.orderBy || []
1453
+ });
1454
+ if (!snapshotsFirstTime.includes(firstTimeKey)) {
1450
1455
  var _config_onFirstTime, _config_extraParsers;
1451
- snapshotsFirstTime.push(config.collectionName);
1456
+ snapshotsFirstTime.push(firstTimeKey);
1452
1457
  var documents = snapshot2.docs.map(function(doc2) {
1453
1458
  return simpleExtractData(doc2);
1454
1459
  });
@@ -2720,7 +2725,7 @@ var SocketService = /*#__PURE__*/ function() {
2720
2725
  key: "disconnectSocket",
2721
2726
  value: function disconnectSocket() {
2722
2727
  if (this.socket) {
2723
- this.socket.io.engine.close();
2728
+ this.socket.disconnect();
2724
2729
  }
2725
2730
  }
2726
2731
  },
@@ -2738,8 +2743,9 @@ var SocketService = /*#__PURE__*/ function() {
2738
2743
  });
2739
2744
  var eventHandlers = [];
2740
2745
  config.forEach(function(configuration) {
2741
- var collectionName = configuration.collectionName, onAdd = configuration.onAdd, onFirstTime = configuration.onFirstTime, onModify = configuration.onModify, onRemove = configuration.onRemove, extraParsers = configuration.extraParsers, conditions = configuration.conditions, orderBy2 = configuration.orderBy;
2746
+ var collectionName = configuration.collectionName, onAdd = configuration.onAdd, onFirstTime = configuration.onFirstTime, onModify = configuration.onModify, onRemove = configuration.onRemove, extraParsers = configuration.extraParsers;
2742
2747
  var attach = function(eventName, handler) {
2748
+ if (!handler) return;
2743
2749
  _this.socket.off(eventName, handler);
2744
2750
  _this.socket.on(eventName, handler);
2745
2751
  eventHandlers.push({
@@ -1068,9 +1068,14 @@ var snapshot = function(config, snapshotsFirstTime, settings) {
1068
1068
  });
1069
1069
  }
1070
1070
  var unsubscribe = onSnapshot(collectionRef, function(snapshot2) {
1071
- if (!snapshotsFirstTime.includes(config.collectionName)) {
1071
+ var firstTimeKey = JSON.stringify({
1072
+ collectionName: config.collectionName,
1073
+ conditions: config.conditions || [],
1074
+ orderBy: config.orderBy || []
1075
+ });
1076
+ if (!snapshotsFirstTime.includes(firstTimeKey)) {
1072
1077
  var _config_onFirstTime, _config_extraParsers;
1073
- snapshotsFirstTime.push(config.collectionName);
1078
+ snapshotsFirstTime.push(firstTimeKey);
1074
1079
  var documents = snapshot2.docs.map(function(doc2) {
1075
1080
  return simpleExtractData(doc2);
1076
1081
  });
@@ -2341,7 +2346,7 @@ var SocketService = /*#__PURE__*/ function() {
2341
2346
  key: "disconnectSocket",
2342
2347
  value: function disconnectSocket() {
2343
2348
  if (this.socket) {
2344
- this.socket.io.engine.close();
2349
+ this.socket.disconnect();
2345
2350
  }
2346
2351
  }
2347
2352
  },
@@ -2359,8 +2364,9 @@ var SocketService = /*#__PURE__*/ function() {
2359
2364
  });
2360
2365
  var eventHandlers = [];
2361
2366
  config.forEach(function(configuration) {
2362
- var collectionName = configuration.collectionName, onAdd = configuration.onAdd, onFirstTime = configuration.onFirstTime, onModify = configuration.onModify, onRemove = configuration.onRemove, extraParsers = configuration.extraParsers, conditions = configuration.conditions, orderBy2 = configuration.orderBy;
2367
+ var collectionName = configuration.collectionName, onAdd = configuration.onAdd, onFirstTime = configuration.onFirstTime, onModify = configuration.onModify, onRemove = configuration.onRemove, extraParsers = configuration.extraParsers;
2363
2368
  var attach = function(eventName, handler) {
2369
+ if (!handler) return;
2364
2370
  _this.socket.off(eventName, handler);
2365
2371
  _this.socket.on(eventName, handler);
2366
2372
  eventHandlers.push({
@@ -7,9 +7,6 @@ function _array_like_to_array(arr, len) {
7
7
  function _array_with_holes(arr) {
8
8
  if (Array.isArray(arr)) return arr;
9
9
  }
10
- function _array_without_holes(arr) {
11
- if (Array.isArray(arr)) return _array_like_to_array(arr);
12
- }
13
10
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
11
  try {
15
12
  var info = gen[key](arg);
@@ -71,9 +68,6 @@ function _define_property(obj, key, value) {
71
68
  }
72
69
  return obj;
73
70
  }
74
- function _iterable_to_array(iter) {
75
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
76
- }
77
71
  function _iterable_to_array_limit(arr, i) {
78
72
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
79
73
  if (_i == null) return;
@@ -101,9 +95,6 @@ function _iterable_to_array_limit(arr, i) {
101
95
  function _non_iterable_rest() {
102
96
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
103
97
  }
104
- function _non_iterable_spread() {
105
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
106
- }
107
98
  function _object_spread(target) {
108
99
  for(var i = 1; i < arguments.length; i++){
109
100
  var source = arguments[i] != null ? arguments[i] : {};
@@ -146,9 +137,6 @@ function _object_spread_props(target, source) {
146
137
  function _sliced_to_array(arr, i) {
147
138
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
148
139
  }
149
- function _to_consumable_array(arr) {
150
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
151
- }
152
140
  function _type_of(obj) {
153
141
  "@swc/helpers - typeof";
154
142
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
@@ -520,9 +508,14 @@ var snapshot = function(config, snapshotsFirstTime, settings) {
520
508
  });
521
509
  }
522
510
  var unsubscribe = (0, import_firestore.onSnapshot)(collectionRef, function(snapshot3) {
523
- if (!snapshotsFirstTime.includes(config.collectionName)) {
511
+ var firstTimeKey = JSON.stringify({
512
+ collectionName: config.collectionName,
513
+ conditions: config.conditions || [],
514
+ orderBy: config.orderBy || []
515
+ });
516
+ if (!snapshotsFirstTime.includes(firstTimeKey)) {
524
517
  var _config_onFirstTime, _config_extraParsers;
525
- snapshotsFirstTime.push(config.collectionName);
518
+ snapshotsFirstTime.push(firstTimeKey);
526
519
  var documents = snapshot3.docs.map(function(doc2) {
527
520
  return simpleExtractData(doc2);
528
521
  });
@@ -798,7 +791,7 @@ var SocketService = /*#__PURE__*/ function() {
798
791
  key: "disconnectSocket",
799
792
  value: function disconnectSocket() {
800
793
  if (this.socket) {
801
- this.socket.io.engine.close();
794
+ this.socket.disconnect();
802
795
  }
803
796
  }
804
797
  },
@@ -816,8 +809,9 @@ var SocketService = /*#__PURE__*/ function() {
816
809
  });
817
810
  var eventHandlers = [];
818
811
  config.forEach(function(configuration) {
819
- var collectionName = configuration.collectionName, onAdd = configuration.onAdd, onFirstTime = configuration.onFirstTime, onModify = configuration.onModify, onRemove = configuration.onRemove, extraParsers = configuration.extraParsers, conditions = configuration.conditions, orderBy2 = configuration.orderBy;
812
+ var collectionName = configuration.collectionName, onAdd = configuration.onAdd, onFirstTime = configuration.onFirstTime, onModify = configuration.onModify, onRemove = configuration.onRemove, extraParsers = configuration.extraParsers;
820
813
  var attach = function(eventName, handler) {
814
+ if (!handler) return;
821
815
  _this.socket.off(eventName, handler);
822
816
  _this.socket.on(eventName, handler);
823
817
  eventHandlers.push({
@@ -1029,6 +1023,9 @@ var useDbSnapshots = function(configs, label, settings) {
1029
1023
  var snapshotsFirstTime = (0, import_react5.useRef)([]);
1030
1024
  var unsubscribeFunctions = (0, import_react5.useRef)([]);
1031
1025
  useDeepCompareEffect(function() {
1026
+ if (configs.length === 0) {
1027
+ return;
1028
+ }
1032
1029
  var start = performance.now();
1033
1030
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1034
1031
  console.log("==> ".concat(label || "DB snapshots", " started from db... "));
@@ -1121,22 +1118,25 @@ var useSmartSnapshots = function(configs, label, settings) {
1121
1118
  var useSocketSnapshots = function(configs, label, settings) {
1122
1119
  var _auth_currentUser;
1123
1120
  var _ref = _sliced_to_array((0, import_react5.useState)(socketServiceInstance.isConnected()), 2), socketConnected = _ref[0], setSocketConnected = _ref[1];
1124
- var _ref1 = _sliced_to_array((0, import_react5.useState)([]), 2), cleanupSubscriptions = _ref1[0], setCleanupSubscriptions = _ref1[1];
1121
+ var cleanupSubscriptionsRef = (0, import_react5.useRef)([]);
1125
1122
  var socketStarted = (0, import_react5.useRef)(false);
1126
1123
  useDeepCompareEffect(function() {
1124
+ var isActive = true;
1127
1125
  if (!auth.currentUser) {
1128
1126
  return;
1129
1127
  }
1128
+ var clearSubs = function() {
1129
+ cleanupSubscriptionsRef.current.forEach(function(cleanup) {
1130
+ return cleanup();
1131
+ });
1132
+ cleanupSubscriptionsRef.current = [];
1133
+ };
1130
1134
  var subscribe = function() {
1131
1135
  if (configs.length === 0) {
1132
1136
  return;
1133
1137
  }
1134
1138
  var disposer = socketServiceInstance.subscribeToCollections(configs);
1135
- setCleanupSubscriptions(function(prev) {
1136
- return _to_consumable_array(prev).concat([
1137
- disposer
1138
- ]);
1139
- });
1139
+ cleanupSubscriptionsRef.current.push(disposer);
1140
1140
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1141
1141
  console.log("==> ".concat(label || "Cache snapshots", " subscribed to ").concat(configs.map(function(c) {
1142
1142
  return c.collectionName;
@@ -1145,46 +1145,64 @@ var useSocketSnapshots = function(configs, label, settings) {
1145
1145
  };
1146
1146
  if (socketServiceInstance.isConnected()) {
1147
1147
  setSocketConnected(true);
1148
+ clearSubs();
1148
1149
  subscribe();
1149
1150
  } else if (!socketStarted.current) {
1150
1151
  socketStarted.current = true;
1151
1152
  auth.currentUser.getIdToken().then(function(token) {
1153
+ if (!isActive) return;
1152
1154
  socketServiceInstance.startSession(token);
1153
1155
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1154
1156
  console.log("==> ".concat(label || "Cache snapshots", " started... "));
1155
1157
  }
1156
- });
1158
+ }).catch(function() {});
1157
1159
  }
1158
1160
  var offConnect = socketServiceInstance.onConnect(function() {
1161
+ if (!isActive) return;
1159
1162
  setSocketConnected(true);
1160
1163
  socketStarted.current = false;
1164
+ clearSubs();
1161
1165
  subscribe();
1162
1166
  });
1163
1167
  var offDisconnect = socketServiceInstance.onDisconnect(function() {
1168
+ if (!isActive) return;
1164
1169
  setSocketConnected(false);
1165
- cleanupSubscriptions.forEach(function(cleanup) {
1166
- return cleanup();
1167
- });
1170
+ clearSubs();
1168
1171
  });
1169
- return function() {
1170
- cleanupSubscriptions.forEach(function(cleanup) {
1171
- return cleanup();
1172
- });
1173
- offConnect === null || offConnect === void 0 ? void 0 : offConnect();
1174
- offDisconnect === null || offDisconnect === void 0 ? void 0 : offDisconnect();
1175
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1176
- console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
1177
- }
1178
- };
1172
+ if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
1173
+ return function() {
1174
+ isActive = false;
1175
+ clearSubs();
1176
+ offConnect();
1177
+ offDisconnect();
1178
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1179
+ console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
1180
+ }
1181
+ };
1182
+ }
1179
1183
  }, [
1180
1184
  configs,
1181
1185
  (_auth_currentUser = auth.currentUser) === null || _auth_currentUser === void 0 ? void 0 : _auth_currentUser.uid
1182
1186
  ]);
1183
1187
  (0, import_react5.useEffect)(function() {
1188
+ var _auth_onIdTokenChanged;
1189
+ var unsubscribeAuth = (_auth_onIdTokenChanged = auth.onIdTokenChanged) === null || _auth_onIdTokenChanged === void 0 ? void 0 : _auth_onIdTokenChanged.call(auth, function(user) {
1190
+ if (!user) return;
1191
+ user.getIdToken().then(function(token) {
1192
+ return socketServiceInstance.setAuthToken(token);
1193
+ }).catch(function() {});
1194
+ });
1184
1195
  return function() {
1185
- cleanupSubscriptions.forEach(function(cleanup) {
1196
+ cleanupSubscriptionsRef.current.forEach(function(cleanup) {
1186
1197
  return cleanup();
1187
1198
  });
1199
+ cleanupSubscriptionsRef.current = [];
1200
+ if (typeof unsubscribeAuth === "function") {
1201
+ unsubscribeAuth();
1202
+ }
1203
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1204
+ console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
1205
+ }
1188
1206
  };
1189
1207
  }, []);
1190
1208
  return {
@@ -7,9 +7,6 @@ function _array_like_to_array(arr, len) {
7
7
  function _array_with_holes(arr) {
8
8
  if (Array.isArray(arr)) return arr;
9
9
  }
10
- function _array_without_holes(arr) {
11
- if (Array.isArray(arr)) return _array_like_to_array(arr);
12
- }
13
10
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
14
11
  try {
15
12
  var info = gen[key](arg);
@@ -71,9 +68,6 @@ function _define_property(obj, key, value) {
71
68
  }
72
69
  return obj;
73
70
  }
74
- function _iterable_to_array(iter) {
75
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
76
- }
77
71
  function _iterable_to_array_limit(arr, i) {
78
72
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
79
73
  if (_i == null) return;
@@ -101,9 +95,6 @@ function _iterable_to_array_limit(arr, i) {
101
95
  function _non_iterable_rest() {
102
96
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
103
97
  }
104
- function _non_iterable_spread() {
105
- throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
106
- }
107
98
  function _object_spread(target) {
108
99
  for(var i = 1; i < arguments.length; i++){
109
100
  var source = arguments[i] != null ? arguments[i] : {};
@@ -146,9 +137,6 @@ function _object_spread_props(target, source) {
146
137
  function _sliced_to_array(arr, i) {
147
138
  return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
148
139
  }
149
- function _to_consumable_array(arr) {
150
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
151
- }
152
140
  function _unsupported_iterable_to_array(o, minLen) {
153
141
  if (!o) return;
154
142
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -427,9 +415,14 @@ var snapshot = function(config, snapshotsFirstTime, settings) {
427
415
  });
428
416
  }
429
417
  var unsubscribe = onSnapshot(collectionRef, function(snapshot3) {
430
- if (!snapshotsFirstTime.includes(config.collectionName)) {
418
+ var firstTimeKey = JSON.stringify({
419
+ collectionName: config.collectionName,
420
+ conditions: config.conditions || [],
421
+ orderBy: config.orderBy || []
422
+ });
423
+ if (!snapshotsFirstTime.includes(firstTimeKey)) {
431
424
  var _config_onFirstTime, _config_extraParsers;
432
- snapshotsFirstTime.push(config.collectionName);
425
+ snapshotsFirstTime.push(firstTimeKey);
433
426
  var documents = snapshot3.docs.map(function(doc2) {
434
427
  return simpleExtractData(doc2);
435
428
  });
@@ -704,7 +697,7 @@ var SocketService = /*#__PURE__*/ function() {
704
697
  key: "disconnectSocket",
705
698
  value: function disconnectSocket() {
706
699
  if (this.socket) {
707
- this.socket.io.engine.close();
700
+ this.socket.disconnect();
708
701
  }
709
702
  }
710
703
  },
@@ -722,8 +715,9 @@ var SocketService = /*#__PURE__*/ function() {
722
715
  });
723
716
  var eventHandlers = [];
724
717
  config.forEach(function(configuration) {
725
- var collectionName = configuration.collectionName, onAdd = configuration.onAdd, onFirstTime = configuration.onFirstTime, onModify = configuration.onModify, onRemove = configuration.onRemove, extraParsers = configuration.extraParsers, conditions = configuration.conditions, orderBy2 = configuration.orderBy;
718
+ var collectionName = configuration.collectionName, onAdd = configuration.onAdd, onFirstTime = configuration.onFirstTime, onModify = configuration.onModify, onRemove = configuration.onRemove, extraParsers = configuration.extraParsers;
726
719
  var attach = function(eventName, handler) {
720
+ if (!handler) return;
727
721
  _this.socket.off(eventName, handler);
728
722
  _this.socket.on(eventName, handler);
729
723
  eventHandlers.push({
@@ -935,6 +929,9 @@ var useDbSnapshots = function(configs, label, settings) {
935
929
  var snapshotsFirstTime = useRef4([]);
936
930
  var unsubscribeFunctions = useRef4([]);
937
931
  useDeepCompareEffect(function() {
932
+ if (configs.length === 0) {
933
+ return;
934
+ }
938
935
  var start = performance.now();
939
936
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
940
937
  console.log("==> ".concat(label || "DB snapshots", " started from db... "));
@@ -1027,22 +1024,25 @@ var useSmartSnapshots = function(configs, label, settings) {
1027
1024
  var useSocketSnapshots = function(configs, label, settings) {
1028
1025
  var _auth_currentUser;
1029
1026
  var _useState2 = _sliced_to_array(useState2(socketServiceInstance.isConnected()), 2), socketConnected = _useState2[0], setSocketConnected = _useState2[1];
1030
- var _useState21 = _sliced_to_array(useState2([]), 2), cleanupSubscriptions = _useState21[0], setCleanupSubscriptions = _useState21[1];
1027
+ var cleanupSubscriptionsRef = useRef4([]);
1031
1028
  var socketStarted = useRef4(false);
1032
1029
  useDeepCompareEffect(function() {
1030
+ var isActive = true;
1033
1031
  if (!auth.currentUser) {
1034
1032
  return;
1035
1033
  }
1034
+ var clearSubs = function() {
1035
+ cleanupSubscriptionsRef.current.forEach(function(cleanup) {
1036
+ return cleanup();
1037
+ });
1038
+ cleanupSubscriptionsRef.current = [];
1039
+ };
1036
1040
  var subscribe = function() {
1037
1041
  if (configs.length === 0) {
1038
1042
  return;
1039
1043
  }
1040
1044
  var disposer = socketServiceInstance.subscribeToCollections(configs);
1041
- setCleanupSubscriptions(function(prev) {
1042
- return _to_consumable_array(prev).concat([
1043
- disposer
1044
- ]);
1045
- });
1045
+ cleanupSubscriptionsRef.current.push(disposer);
1046
1046
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1047
1047
  console.log("==> ".concat(label || "Cache snapshots", " subscribed to ").concat(configs.map(function(c) {
1048
1048
  return c.collectionName;
@@ -1051,46 +1051,64 @@ var useSocketSnapshots = function(configs, label, settings) {
1051
1051
  };
1052
1052
  if (socketServiceInstance.isConnected()) {
1053
1053
  setSocketConnected(true);
1054
+ clearSubs();
1054
1055
  subscribe();
1055
1056
  } else if (!socketStarted.current) {
1056
1057
  socketStarted.current = true;
1057
1058
  auth.currentUser.getIdToken().then(function(token) {
1059
+ if (!isActive) return;
1058
1060
  socketServiceInstance.startSession(token);
1059
1061
  if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs)) {
1060
1062
  console.log("==> ".concat(label || "Cache snapshots", " started... "));
1061
1063
  }
1062
- });
1064
+ }).catch(function() {});
1063
1065
  }
1064
1066
  var offConnect = socketServiceInstance.onConnect(function() {
1067
+ if (!isActive) return;
1065
1068
  setSocketConnected(true);
1066
1069
  socketStarted.current = false;
1070
+ clearSubs();
1067
1071
  subscribe();
1068
1072
  });
1069
1073
  var offDisconnect = socketServiceInstance.onDisconnect(function() {
1074
+ if (!isActive) return;
1070
1075
  setSocketConnected(false);
1071
- cleanupSubscriptions.forEach(function(cleanup) {
1072
- return cleanup();
1073
- });
1076
+ clearSubs();
1074
1077
  });
1075
- return function() {
1076
- cleanupSubscriptions.forEach(function(cleanup) {
1077
- return cleanup();
1078
- });
1079
- offConnect === null || offConnect === void 0 ? void 0 : offConnect();
1080
- offDisconnect === null || offDisconnect === void 0 ? void 0 : offDisconnect();
1081
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1082
- console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
1083
- }
1084
- };
1078
+ if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
1079
+ return function() {
1080
+ isActive = false;
1081
+ clearSubs();
1082
+ offConnect();
1083
+ offDisconnect();
1084
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1085
+ console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
1086
+ }
1087
+ };
1088
+ }
1085
1089
  }, [
1086
1090
  configs,
1087
1091
  (_auth_currentUser = auth.currentUser) === null || _auth_currentUser === void 0 ? void 0 : _auth_currentUser.uid
1088
1092
  ]);
1089
1093
  useEffect4(function() {
1094
+ var _auth_onIdTokenChanged;
1095
+ var unsubscribeAuth = (_auth_onIdTokenChanged = auth.onIdTokenChanged) === null || _auth_onIdTokenChanged === void 0 ? void 0 : _auth_onIdTokenChanged.call(auth, function(user) {
1096
+ if (!user) return;
1097
+ user.getIdToken().then(function(token) {
1098
+ return socketServiceInstance.setAuthToken(token);
1099
+ }).catch(function() {});
1100
+ });
1090
1101
  return function() {
1091
- cleanupSubscriptions.forEach(function(cleanup) {
1102
+ cleanupSubscriptionsRef.current.forEach(function(cleanup) {
1092
1103
  return cleanup();
1093
1104
  });
1105
+ cleanupSubscriptionsRef.current = [];
1106
+ if (typeof unsubscribeAuth === "function") {
1107
+ unsubscribeAuth();
1108
+ }
1109
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
1110
+ console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
1111
+ }
1094
1112
  };
1095
1113
  }, []);
1096
1114
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akeyless-client-commons",
3
- "version": "1.1.29",
3
+ "version": "1.1.31",
4
4
  "scripts": {
5
5
  "build": "tsup",
6
6
  "deploy": "npm run build && npm version patch --no-git-tag-version && npm publish",