akeyless-client-commons 1.1.17-test.8 → 1.1.17-test.9

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.
@@ -1193,6 +1193,7 @@ var dataSocketDomain = isLocal ? "http://localhost:9009/api/data-socket" : baseD
1193
1193
  var dataSyncDomain = isLocal ? "http://localhost:9010/api/data-sync" : baseDomain + "/data-sync";
1194
1194
  // src/helpers/socket.ts
1195
1195
  var import_socket = require("socket.io-client");
1196
+ var SESSION_STORAGE_KEY = "sessionId";
1196
1197
  var SocketService = /*#__PURE__*/ function() {
1197
1198
  "use strict";
1198
1199
  function _SocketService() {
@@ -1212,19 +1213,24 @@ var SocketService = /*#__PURE__*/ function() {
1212
1213
  var socketUrl = isLocal ? "http://localhost:9009" : mode === "qa" ? "https://nx-api.xyz" : "https://nx-api.info";
1213
1214
  this.socket = (0, import_socket.io)(socketUrl, {
1214
1215
  path: "/api/data-socket/connect",
1215
- transports: [
1216
- "websocket"
1217
- ],
1218
- auth: this.authToken ? {
1219
- token: this.authToken
1220
- } : void 0
1216
+ auth: function(cb) {
1217
+ var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
1218
+ var token = _this.authToken;
1219
+ var authPayload = {};
1220
+ if (token) authPayload.token = token;
1221
+ if (sessionId) authPayload.sessionId = sessionId;
1222
+ cb(authPayload);
1223
+ },
1224
+ reconnection: true,
1225
+ reconnectionAttempts: 30,
1226
+ reconnectionDelay: 2 * 1e3
1221
1227
  });
1222
1228
  this.socket.on("connect", function() {
1223
- var _this_socket;
1224
- console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
1225
- });
1226
- this.connectCallbacks.forEach(function(cb) {
1227
- return cb();
1229
+ var _this_socket, _this_socket1;
1230
+ console.log("\uD83D\uDFE2 Socket connected: ".concat((_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id, " (recovered - ").concat((_this_socket1 = _this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.recovered, ")"));
1231
+ _this.connectCallbacks.forEach(function(cb) {
1232
+ return cb();
1233
+ });
1228
1234
  });
1229
1235
  this.socket.on("disconnect", function(reason) {
1230
1236
  console.log("Socket disconnected:", reason);
@@ -1232,6 +1238,12 @@ var SocketService = /*#__PURE__*/ function() {
1232
1238
  return cb();
1233
1239
  });
1234
1240
  });
1241
+ this.socket.on("session", function(param) {
1242
+ var sessionId = param.sessionId;
1243
+ if (sessionId) {
1244
+ localStorage.setItem(SESSION_STORAGE_KEY, sessionId);
1245
+ }
1246
+ });
1235
1247
  this.socket.on("connect_error", function(error) {
1236
1248
  console.error("Socket connection error:", error);
1237
1249
  });
@@ -1254,10 +1266,90 @@ var SocketService = /*#__PURE__*/ function() {
1254
1266
  return this.socket;
1255
1267
  }
1256
1268
  },
1269
+ {
1270
+ /// connection management methods
1271
+ key: "startSession",
1272
+ value: function startSession(token) {
1273
+ this.setAuthToken(token);
1274
+ this.initSocket();
1275
+ }
1276
+ },
1277
+ {
1278
+ key: "onConnect",
1279
+ value: function onConnect(callback) {
1280
+ var _this = this;
1281
+ var _this_socket;
1282
+ if (!this.connectCallbacks.includes(callback)) {
1283
+ this.connectCallbacks.push(callback);
1284
+ }
1285
+ if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
1286
+ callback();
1287
+ }
1288
+ return function() {
1289
+ return _this.offConnect(callback);
1290
+ };
1291
+ }
1292
+ },
1293
+ {
1294
+ key: "offConnect",
1295
+ value: function offConnect(callback) {
1296
+ this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
1297
+ return cb !== callback;
1298
+ });
1299
+ }
1300
+ },
1301
+ {
1302
+ key: "onDisconnect",
1303
+ value: function onDisconnect(callback) {
1304
+ var _this = this;
1305
+ if (!this.disconnectCallbacks.includes(callback)) {
1306
+ this.disconnectCallbacks.push(callback);
1307
+ }
1308
+ if (this.socket && !this.socket.connected) {
1309
+ callback();
1310
+ }
1311
+ return function() {
1312
+ return _this.offDisconnect(callback);
1313
+ };
1314
+ }
1315
+ },
1316
+ {
1317
+ key: "offDisconnect",
1318
+ value: function offDisconnect(callback) {
1319
+ this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
1320
+ return cb !== callback;
1321
+ });
1322
+ }
1323
+ },
1324
+ {
1325
+ key: "isConnected",
1326
+ value: function isConnected() {
1327
+ var _this_socket;
1328
+ return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
1329
+ }
1330
+ },
1331
+ {
1332
+ key: "setAuthToken",
1333
+ value: function setAuthToken(token) {
1334
+ this.authToken = token;
1335
+ if (this.socket) {
1336
+ this.socket.connect();
1337
+ }
1338
+ }
1339
+ },
1340
+ {
1341
+ key: "disconnectSocket",
1342
+ value: function disconnectSocket() {
1343
+ if (this.socket) {
1344
+ this.socket.io.engine.close();
1345
+ }
1346
+ }
1347
+ },
1257
1348
  {
1258
1349
  /// subscribe to collections
1259
1350
  key: "subscribeToCollections",
1260
1351
  value: function subscribeToCollections(config) {
1352
+ var _this = this;
1261
1353
  if (config.length === 0) {
1262
1354
  return function() {};
1263
1355
  }
@@ -1268,48 +1360,24 @@ var SocketService = /*#__PURE__*/ function() {
1268
1360
  var eventHandlers = [];
1269
1361
  config.forEach(function(configuration) {
1270
1362
  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;
1271
- s.on("initial:".concat(collectionName), onFirstTime);
1272
- eventHandlers.push({
1273
- eventName: "initial:".concat(collectionName),
1274
- handler: onFirstTime
1275
- });
1276
- s.on("add:".concat(collectionName), onAdd);
1277
- eventHandlers.push({
1278
- eventName: "add:".concat(collectionName),
1279
- handler: onAdd
1280
- });
1281
- s.on("update:".concat(collectionName), onModify);
1282
- eventHandlers.push({
1283
- eventName: "update:".concat(collectionName),
1284
- handler: onModify
1285
- });
1286
- s.on("delete:".concat(collectionName), onRemove);
1287
- eventHandlers.push({
1288
- eventName: "delete:".concat(collectionName),
1289
- handler: onRemove
1290
- });
1291
- extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
1292
- var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
1293
- s.on("initial:".concat(collectionName), extraOnFirstTime);
1363
+ var attach = function(eventName, handler) {
1364
+ _this.socket.off(eventName, handler);
1365
+ _this.socket.on(eventName, handler);
1294
1366
  eventHandlers.push({
1295
- eventName: "initial:".concat(collectionName),
1296
- handler: extraOnFirstTime
1297
- });
1298
- s.on("add:".concat(collectionName), extraOnAdd);
1299
- eventHandlers.push({
1300
- eventName: "add:".concat(collectionName),
1301
- handler: extraOnAdd
1302
- });
1303
- s.on("update:".concat(collectionName), extraOnModify);
1304
- eventHandlers.push({
1305
- eventName: "update:".concat(collectionName),
1306
- handler: extraOnModify
1307
- });
1308
- s.on("delete:".concat(collectionName), extraOnRemove);
1309
- eventHandlers.push({
1310
- eventName: "delete:".concat(collectionName),
1311
- handler: extraOnRemove
1367
+ eventName: eventName,
1368
+ handler: handler
1312
1369
  });
1370
+ };
1371
+ attach("initial:".concat(collectionName), onFirstTime);
1372
+ attach("add:".concat(collectionName), onAdd);
1373
+ attach("update:".concat(collectionName), onModify);
1374
+ attach("delete:".concat(collectionName), onRemove);
1375
+ extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
1376
+ var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
1377
+ attach("initial:".concat(collectionName), extraOnFirstTime);
1378
+ attach("add:".concat(collectionName), extraOnAdd);
1379
+ attach("update:".concat(collectionName), extraOnModify);
1380
+ attach("delete:".concat(collectionName), extraOnRemove);
1313
1381
  });
1314
1382
  });
1315
1383
  s.emit("subscribe_collections", collectionsNames, function(callback) {
@@ -1410,64 +1478,6 @@ var SocketService = /*#__PURE__*/ function() {
1410
1478
  });
1411
1479
  });
1412
1480
  }
1413
- },
1414
- {
1415
- /// connection management methods
1416
- key: "onConnect",
1417
- value: function onConnect(callback) {
1418
- var _this_socket;
1419
- this.connectCallbacks.push(callback);
1420
- if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
1421
- callback();
1422
- }
1423
- }
1424
- },
1425
- {
1426
- key: "offConnect",
1427
- value: function offConnect(callback) {
1428
- this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
1429
- return cb !== callback;
1430
- });
1431
- }
1432
- },
1433
- {
1434
- key: "onDisconnect",
1435
- value: function onDisconnect(callback) {
1436
- this.disconnectCallbacks.push(callback);
1437
- if (this.socket && !this.socket.connected) {
1438
- callback();
1439
- }
1440
- }
1441
- },
1442
- {
1443
- key: "offDisconnect",
1444
- value: function offDisconnect(callback) {
1445
- this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
1446
- return cb !== callback;
1447
- });
1448
- }
1449
- },
1450
- {
1451
- key: "isConnected",
1452
- value: function isConnected() {
1453
- var _this_socket;
1454
- return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
1455
- }
1456
- },
1457
- {
1458
- key: "setAuthToken",
1459
- value: function setAuthToken(token) {
1460
- this.authToken = token;
1461
- if (this.socket) {
1462
- this.socket.auth = {
1463
- token: token
1464
- };
1465
- if (this.socket.connected) {
1466
- this.socket.disconnect();
1467
- }
1468
- this.socket.connect();
1469
- }
1470
- }
1471
1481
  }
1472
1482
  ], [
1473
1483
  {
@@ -971,6 +971,7 @@ var dataSocketDomain = isLocal ? "http://localhost:9009/api/data-socket" : baseD
971
971
  var dataSyncDomain = isLocal ? "http://localhost:9010/api/data-sync" : baseDomain + "/data-sync";
972
972
  // src/helpers/socket.ts
973
973
  import { io } from "socket.io-client";
974
+ var SESSION_STORAGE_KEY = "sessionId";
974
975
  var SocketService = /*#__PURE__*/ function() {
975
976
  "use strict";
976
977
  function _SocketService() {
@@ -990,19 +991,24 @@ var SocketService = /*#__PURE__*/ function() {
990
991
  var socketUrl = isLocal ? "http://localhost:9009" : mode === "qa" ? "https://nx-api.xyz" : "https://nx-api.info";
991
992
  this.socket = io(socketUrl, {
992
993
  path: "/api/data-socket/connect",
993
- transports: [
994
- "websocket"
995
- ],
996
- auth: this.authToken ? {
997
- token: this.authToken
998
- } : void 0
994
+ auth: function(cb) {
995
+ var sessionId = localStorage.getItem(SESSION_STORAGE_KEY) || void 0;
996
+ var token = _this.authToken;
997
+ var authPayload = {};
998
+ if (token) authPayload.token = token;
999
+ if (sessionId) authPayload.sessionId = sessionId;
1000
+ cb(authPayload);
1001
+ },
1002
+ reconnection: true,
1003
+ reconnectionAttempts: 30,
1004
+ reconnectionDelay: 2 * 1e3
999
1005
  });
1000
1006
  this.socket.on("connect", function() {
1001
- var _this_socket;
1002
- console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
1003
- });
1004
- this.connectCallbacks.forEach(function(cb) {
1005
- return cb();
1007
+ var _this_socket, _this_socket1;
1008
+ console.log("\uD83D\uDFE2 Socket connected: ".concat((_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id, " (recovered - ").concat((_this_socket1 = _this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.recovered, ")"));
1009
+ _this.connectCallbacks.forEach(function(cb) {
1010
+ return cb();
1011
+ });
1006
1012
  });
1007
1013
  this.socket.on("disconnect", function(reason) {
1008
1014
  console.log("Socket disconnected:", reason);
@@ -1010,6 +1016,12 @@ var SocketService = /*#__PURE__*/ function() {
1010
1016
  return cb();
1011
1017
  });
1012
1018
  });
1019
+ this.socket.on("session", function(param) {
1020
+ var sessionId = param.sessionId;
1021
+ if (sessionId) {
1022
+ localStorage.setItem(SESSION_STORAGE_KEY, sessionId);
1023
+ }
1024
+ });
1013
1025
  this.socket.on("connect_error", function(error) {
1014
1026
  console.error("Socket connection error:", error);
1015
1027
  });
@@ -1032,10 +1044,90 @@ var SocketService = /*#__PURE__*/ function() {
1032
1044
  return this.socket;
1033
1045
  }
1034
1046
  },
1047
+ {
1048
+ /// connection management methods
1049
+ key: "startSession",
1050
+ value: function startSession(token) {
1051
+ this.setAuthToken(token);
1052
+ this.initSocket();
1053
+ }
1054
+ },
1055
+ {
1056
+ key: "onConnect",
1057
+ value: function onConnect(callback) {
1058
+ var _this = this;
1059
+ var _this_socket;
1060
+ if (!this.connectCallbacks.includes(callback)) {
1061
+ this.connectCallbacks.push(callback);
1062
+ }
1063
+ if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
1064
+ callback();
1065
+ }
1066
+ return function() {
1067
+ return _this.offConnect(callback);
1068
+ };
1069
+ }
1070
+ },
1071
+ {
1072
+ key: "offConnect",
1073
+ value: function offConnect(callback) {
1074
+ this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
1075
+ return cb !== callback;
1076
+ });
1077
+ }
1078
+ },
1079
+ {
1080
+ key: "onDisconnect",
1081
+ value: function onDisconnect(callback) {
1082
+ var _this = this;
1083
+ if (!this.disconnectCallbacks.includes(callback)) {
1084
+ this.disconnectCallbacks.push(callback);
1085
+ }
1086
+ if (this.socket && !this.socket.connected) {
1087
+ callback();
1088
+ }
1089
+ return function() {
1090
+ return _this.offDisconnect(callback);
1091
+ };
1092
+ }
1093
+ },
1094
+ {
1095
+ key: "offDisconnect",
1096
+ value: function offDisconnect(callback) {
1097
+ this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
1098
+ return cb !== callback;
1099
+ });
1100
+ }
1101
+ },
1102
+ {
1103
+ key: "isConnected",
1104
+ value: function isConnected() {
1105
+ var _this_socket;
1106
+ return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
1107
+ }
1108
+ },
1109
+ {
1110
+ key: "setAuthToken",
1111
+ value: function setAuthToken(token) {
1112
+ this.authToken = token;
1113
+ if (this.socket) {
1114
+ this.socket.connect();
1115
+ }
1116
+ }
1117
+ },
1118
+ {
1119
+ key: "disconnectSocket",
1120
+ value: function disconnectSocket() {
1121
+ if (this.socket) {
1122
+ this.socket.io.engine.close();
1123
+ }
1124
+ }
1125
+ },
1035
1126
  {
1036
1127
  /// subscribe to collections
1037
1128
  key: "subscribeToCollections",
1038
1129
  value: function subscribeToCollections(config) {
1130
+ var _this = this;
1039
1131
  if (config.length === 0) {
1040
1132
  return function() {};
1041
1133
  }
@@ -1046,48 +1138,24 @@ var SocketService = /*#__PURE__*/ function() {
1046
1138
  var eventHandlers = [];
1047
1139
  config.forEach(function(configuration) {
1048
1140
  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;
1049
- s.on("initial:".concat(collectionName), onFirstTime);
1050
- eventHandlers.push({
1051
- eventName: "initial:".concat(collectionName),
1052
- handler: onFirstTime
1053
- });
1054
- s.on("add:".concat(collectionName), onAdd);
1055
- eventHandlers.push({
1056
- eventName: "add:".concat(collectionName),
1057
- handler: onAdd
1058
- });
1059
- s.on("update:".concat(collectionName), onModify);
1060
- eventHandlers.push({
1061
- eventName: "update:".concat(collectionName),
1062
- handler: onModify
1063
- });
1064
- s.on("delete:".concat(collectionName), onRemove);
1065
- eventHandlers.push({
1066
- eventName: "delete:".concat(collectionName),
1067
- handler: onRemove
1068
- });
1069
- extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
1070
- var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
1071
- s.on("initial:".concat(collectionName), extraOnFirstTime);
1141
+ var attach = function(eventName, handler) {
1142
+ _this.socket.off(eventName, handler);
1143
+ _this.socket.on(eventName, handler);
1072
1144
  eventHandlers.push({
1073
- eventName: "initial:".concat(collectionName),
1074
- handler: extraOnFirstTime
1075
- });
1076
- s.on("add:".concat(collectionName), extraOnAdd);
1077
- eventHandlers.push({
1078
- eventName: "add:".concat(collectionName),
1079
- handler: extraOnAdd
1080
- });
1081
- s.on("update:".concat(collectionName), extraOnModify);
1082
- eventHandlers.push({
1083
- eventName: "update:".concat(collectionName),
1084
- handler: extraOnModify
1085
- });
1086
- s.on("delete:".concat(collectionName), extraOnRemove);
1087
- eventHandlers.push({
1088
- eventName: "delete:".concat(collectionName),
1089
- handler: extraOnRemove
1145
+ eventName: eventName,
1146
+ handler: handler
1090
1147
  });
1148
+ };
1149
+ attach("initial:".concat(collectionName), onFirstTime);
1150
+ attach("add:".concat(collectionName), onAdd);
1151
+ attach("update:".concat(collectionName), onModify);
1152
+ attach("delete:".concat(collectionName), onRemove);
1153
+ extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
1154
+ var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
1155
+ attach("initial:".concat(collectionName), extraOnFirstTime);
1156
+ attach("add:".concat(collectionName), extraOnAdd);
1157
+ attach("update:".concat(collectionName), extraOnModify);
1158
+ attach("delete:".concat(collectionName), extraOnRemove);
1091
1159
  });
1092
1160
  });
1093
1161
  s.emit("subscribe_collections", collectionsNames, function(callback) {
@@ -1188,64 +1256,6 @@ var SocketService = /*#__PURE__*/ function() {
1188
1256
  });
1189
1257
  });
1190
1258
  }
1191
- },
1192
- {
1193
- /// connection management methods
1194
- key: "onConnect",
1195
- value: function onConnect(callback) {
1196
- var _this_socket;
1197
- this.connectCallbacks.push(callback);
1198
- if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
1199
- callback();
1200
- }
1201
- }
1202
- },
1203
- {
1204
- key: "offConnect",
1205
- value: function offConnect(callback) {
1206
- this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
1207
- return cb !== callback;
1208
- });
1209
- }
1210
- },
1211
- {
1212
- key: "onDisconnect",
1213
- value: function onDisconnect(callback) {
1214
- this.disconnectCallbacks.push(callback);
1215
- if (this.socket && !this.socket.connected) {
1216
- callback();
1217
- }
1218
- }
1219
- },
1220
- {
1221
- key: "offDisconnect",
1222
- value: function offDisconnect(callback) {
1223
- this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
1224
- return cb !== callback;
1225
- });
1226
- }
1227
- },
1228
- {
1229
- key: "isConnected",
1230
- value: function isConnected() {
1231
- var _this_socket;
1232
- return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
1233
- }
1234
- },
1235
- {
1236
- key: "setAuthToken",
1237
- value: function setAuthToken(token) {
1238
- this.authToken = token;
1239
- if (this.socket) {
1240
- this.socket.auth = {
1241
- token: token
1242
- };
1243
- if (this.socket.connected) {
1244
- this.socket.disconnect();
1245
- }
1246
- this.socket.connect();
1247
- }
1248
- }
1249
1259
  }
1250
1260
  ], [
1251
1261
  {
@@ -6,7 +6,6 @@ import { WhereFilterOp, Unsubscribe, Firestore, CollectionReference, DocumentDat
6
6
  import { TObject, NxUser, CountryOptions, LanguageOptions, UserPermissionsObject, userPermissionsObjectValue, Client, RedisUpdateType, RedisUpdatePayload, SocketCallbackResponse } from 'akeyless-types-commons';
7
7
  import React, { Dispatch, SetStateAction } from 'react';
8
8
  import { ClassValue } from 'clsx';
9
- import { Socket } from 'socket.io-client';
10
9
 
11
10
  type SetState<T> = (updater: ((prev: T) => T) | T) => void;
12
11
  type AppName = "installer" | "toolbox" | "dashboard";
@@ -278,7 +277,15 @@ declare class SocketService {
278
277
  private initSocket;
279
278
  private constructor();
280
279
  static getInstance(): SocketService;
281
- getSocketInstance(): Socket;
280
+ private getSocketInstance;
281
+ startSession(token: string): void;
282
+ onConnect(callback: () => void): () => void;
283
+ offConnect(callback: () => void): void;
284
+ onDisconnect(callback: () => void): () => void;
285
+ offDisconnect(callback: () => void): void;
286
+ isConnected(): boolean;
287
+ setAuthToken(token: string): void;
288
+ disconnectSocket(): void;
282
289
  subscribeToCollections(config: OnSnapshotConfig[]): () => void;
283
290
  setData<UpdateType extends RedisUpdateType, DataType = any>(payload: RedisUpdatePayload<UpdateType, DataType>): Promise<SocketCallbackResponse>;
284
291
  getCollectionData<T>(payload: Omit<GetDataPayload<T>, "key">): void;
@@ -288,12 +295,6 @@ declare class SocketService {
288
295
  collection_name: string;
289
296
  }): Promise<SocketCallbackResponse>;
290
297
  clearAllRedisData(): Promise<SocketCallbackResponse>;
291
- onConnect(callback: () => void): void;
292
- offConnect(callback: () => void): void;
293
- onDisconnect(callback: () => void): void;
294
- offDisconnect(callback: () => void): void;
295
- isConnected(): boolean;
296
- setAuthToken(token: string): void;
297
298
  }
298
299
  declare const socketServiceInstance: SocketService;
299
300
 
@@ -6,7 +6,6 @@ import { WhereFilterOp, Unsubscribe, Firestore, CollectionReference, DocumentDat
6
6
  import { TObject, NxUser, CountryOptions, LanguageOptions, UserPermissionsObject, userPermissionsObjectValue, Client, RedisUpdateType, RedisUpdatePayload, SocketCallbackResponse } from 'akeyless-types-commons';
7
7
  import React, { Dispatch, SetStateAction } from 'react';
8
8
  import { ClassValue } from 'clsx';
9
- import { Socket } from 'socket.io-client';
10
9
 
11
10
  type SetState<T> = (updater: ((prev: T) => T) | T) => void;
12
11
  type AppName = "installer" | "toolbox" | "dashboard";
@@ -278,7 +277,15 @@ declare class SocketService {
278
277
  private initSocket;
279
278
  private constructor();
280
279
  static getInstance(): SocketService;
281
- getSocketInstance(): Socket;
280
+ private getSocketInstance;
281
+ startSession(token: string): void;
282
+ onConnect(callback: () => void): () => void;
283
+ offConnect(callback: () => void): void;
284
+ onDisconnect(callback: () => void): () => void;
285
+ offDisconnect(callback: () => void): void;
286
+ isConnected(): boolean;
287
+ setAuthToken(token: string): void;
288
+ disconnectSocket(): void;
282
289
  subscribeToCollections(config: OnSnapshotConfig[]): () => void;
283
290
  setData<UpdateType extends RedisUpdateType, DataType = any>(payload: RedisUpdatePayload<UpdateType, DataType>): Promise<SocketCallbackResponse>;
284
291
  getCollectionData<T>(payload: Omit<GetDataPayload<T>, "key">): void;
@@ -288,12 +295,6 @@ declare class SocketService {
288
295
  collection_name: string;
289
296
  }): Promise<SocketCallbackResponse>;
290
297
  clearAllRedisData(): Promise<SocketCallbackResponse>;
291
- onConnect(callback: () => void): void;
292
- offConnect(callback: () => void): void;
293
- onDisconnect(callback: () => void): void;
294
- offDisconnect(callback: () => void): void;
295
- isConnected(): boolean;
296
- setAuthToken(token: string): void;
297
298
  }
298
299
  declare const socketServiceInstance: SocketService;
299
300