akeyless-client-commons 1.1.17-test.1 → 1.1.17-test.10

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() {
@@ -1200,6 +1201,7 @@ var SocketService = /*#__PURE__*/ function() {
1200
1201
  this.socket = null;
1201
1202
  this.connectCallbacks = [];
1202
1203
  this.disconnectCallbacks = [];
1204
+ this.authToken = null;
1203
1205
  }
1204
1206
  _create_class(_SocketService, [
1205
1207
  {
@@ -1209,16 +1211,23 @@ var SocketService = /*#__PURE__*/ function() {
1209
1211
  var _this = this;
1210
1212
  if (!this.socket) {
1211
1213
  var socketUrl = isLocal ? "http://localhost:9009" : mode === "qa" ? "https://nx-api.xyz" : "https://nx-api.info";
1212
- console.log("socketUrl", socketUrl);
1213
1214
  this.socket = (0, import_socket.io)(socketUrl, {
1214
1215
  path: "/api/data-socket/connect",
1215
- transports: [
1216
- "websocket"
1217
- ]
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
1218
1227
  });
1219
1228
  this.socket.on("connect", function() {
1220
- var _this_socket;
1221
- console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
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, ")"));
1222
1231
  _this.connectCallbacks.forEach(function(cb) {
1223
1232
  return cb();
1224
1233
  });
@@ -1229,6 +1238,12 @@ var SocketService = /*#__PURE__*/ function() {
1229
1238
  return cb();
1230
1239
  });
1231
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
+ });
1232
1247
  this.socket.on("connect_error", function(error) {
1233
1248
  console.error("Socket connection error:", error);
1234
1249
  });
@@ -1251,10 +1266,93 @@ var SocketService = /*#__PURE__*/ function() {
1251
1266
  return this.socket;
1252
1267
  }
1253
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
+ },
1254
1348
  {
1255
1349
  /// subscribe to collections
1256
1350
  key: "subscribeToCollections",
1257
1351
  value: function subscribeToCollections(config) {
1352
+ var _this = this;
1353
+ if (config.length === 0) {
1354
+ return function() {};
1355
+ }
1258
1356
  var s = this.getSocketInstance();
1259
1357
  var collectionsNames = config.map(function(c) {
1260
1358
  return c.collectionName;
@@ -1262,48 +1360,24 @@ var SocketService = /*#__PURE__*/ function() {
1262
1360
  var eventHandlers = [];
1263
1361
  config.forEach(function(configuration) {
1264
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;
1265
- s.on("initial:".concat(collectionName), onFirstTime);
1266
- eventHandlers.push({
1267
- eventName: "initial:".concat(collectionName),
1268
- handler: onFirstTime
1269
- });
1270
- s.on("add:".concat(collectionName), onAdd);
1271
- eventHandlers.push({
1272
- eventName: "add:".concat(collectionName),
1273
- handler: onAdd
1274
- });
1275
- s.on("update:".concat(collectionName), onModify);
1276
- eventHandlers.push({
1277
- eventName: "update:".concat(collectionName),
1278
- handler: onModify
1279
- });
1280
- s.on("delete:".concat(collectionName), onRemove);
1281
- eventHandlers.push({
1282
- eventName: "delete:".concat(collectionName),
1283
- handler: onRemove
1284
- });
1285
- extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
1286
- var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
1287
- s.on("initial:".concat(collectionName), extraOnFirstTime);
1288
- eventHandlers.push({
1289
- eventName: "initial:".concat(collectionName),
1290
- handler: extraOnFirstTime
1291
- });
1292
- s.on("add:".concat(collectionName), extraOnAdd);
1293
- eventHandlers.push({
1294
- eventName: "add:".concat(collectionName),
1295
- handler: extraOnAdd
1296
- });
1297
- s.on("update:".concat(collectionName), extraOnModify);
1363
+ var attach = function(eventName, handler) {
1364
+ _this.socket.off(eventName, handler);
1365
+ _this.socket.on(eventName, handler);
1298
1366
  eventHandlers.push({
1299
- eventName: "update:".concat(collectionName),
1300
- handler: extraOnModify
1301
- });
1302
- s.on("delete:".concat(collectionName), extraOnRemove);
1303
- eventHandlers.push({
1304
- eventName: "delete:".concat(collectionName),
1305
- handler: extraOnRemove
1367
+ eventName: eventName,
1368
+ handler: handler
1306
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);
1307
1381
  });
1308
1382
  });
1309
1383
  s.emit("subscribe_collections", collectionsNames, function(callback) {
@@ -1404,49 +1478,6 @@ var SocketService = /*#__PURE__*/ function() {
1404
1478
  });
1405
1479
  });
1406
1480
  }
1407
- },
1408
- {
1409
- /// connection management methods
1410
- key: "onConnect",
1411
- value: function onConnect(callback) {
1412
- var _this_socket;
1413
- this.connectCallbacks.push(callback);
1414
- if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
1415
- callback();
1416
- }
1417
- }
1418
- },
1419
- {
1420
- key: "offConnect",
1421
- value: function offConnect(callback) {
1422
- this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
1423
- return cb !== callback;
1424
- });
1425
- }
1426
- },
1427
- {
1428
- key: "onDisconnect",
1429
- value: function onDisconnect(callback) {
1430
- this.disconnectCallbacks.push(callback);
1431
- if (this.socket && !this.socket.connected) {
1432
- callback();
1433
- }
1434
- }
1435
- },
1436
- {
1437
- key: "offDisconnect",
1438
- value: function offDisconnect(callback) {
1439
- this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
1440
- return cb !== callback;
1441
- });
1442
- }
1443
- },
1444
- {
1445
- key: "isConnected",
1446
- value: function isConnected() {
1447
- var _this_socket;
1448
- return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
1449
- }
1450
1481
  }
1451
1482
  ], [
1452
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() {
@@ -978,6 +979,7 @@ var SocketService = /*#__PURE__*/ function() {
978
979
  this.socket = null;
979
980
  this.connectCallbacks = [];
980
981
  this.disconnectCallbacks = [];
982
+ this.authToken = null;
981
983
  }
982
984
  _create_class(_SocketService, [
983
985
  {
@@ -987,16 +989,23 @@ var SocketService = /*#__PURE__*/ function() {
987
989
  var _this = this;
988
990
  if (!this.socket) {
989
991
  var socketUrl = isLocal ? "http://localhost:9009" : mode === "qa" ? "https://nx-api.xyz" : "https://nx-api.info";
990
- console.log("socketUrl", socketUrl);
991
992
  this.socket = io(socketUrl, {
992
993
  path: "/api/data-socket/connect",
993
- transports: [
994
- "websocket"
995
- ]
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
996
1005
  });
997
1006
  this.socket.on("connect", function() {
998
- var _this_socket;
999
- console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
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, ")"));
1000
1009
  _this.connectCallbacks.forEach(function(cb) {
1001
1010
  return cb();
1002
1011
  });
@@ -1007,6 +1016,12 @@ var SocketService = /*#__PURE__*/ function() {
1007
1016
  return cb();
1008
1017
  });
1009
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
+ });
1010
1025
  this.socket.on("connect_error", function(error) {
1011
1026
  console.error("Socket connection error:", error);
1012
1027
  });
@@ -1029,10 +1044,93 @@ var SocketService = /*#__PURE__*/ function() {
1029
1044
  return this.socket;
1030
1045
  }
1031
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
+ },
1032
1126
  {
1033
1127
  /// subscribe to collections
1034
1128
  key: "subscribeToCollections",
1035
1129
  value: function subscribeToCollections(config) {
1130
+ var _this = this;
1131
+ if (config.length === 0) {
1132
+ return function() {};
1133
+ }
1036
1134
  var s = this.getSocketInstance();
1037
1135
  var collectionsNames = config.map(function(c) {
1038
1136
  return c.collectionName;
@@ -1040,48 +1138,24 @@ var SocketService = /*#__PURE__*/ function() {
1040
1138
  var eventHandlers = [];
1041
1139
  config.forEach(function(configuration) {
1042
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;
1043
- s.on("initial:".concat(collectionName), onFirstTime);
1044
- eventHandlers.push({
1045
- eventName: "initial:".concat(collectionName),
1046
- handler: onFirstTime
1047
- });
1048
- s.on("add:".concat(collectionName), onAdd);
1049
- eventHandlers.push({
1050
- eventName: "add:".concat(collectionName),
1051
- handler: onAdd
1052
- });
1053
- s.on("update:".concat(collectionName), onModify);
1054
- eventHandlers.push({
1055
- eventName: "update:".concat(collectionName),
1056
- handler: onModify
1057
- });
1058
- s.on("delete:".concat(collectionName), onRemove);
1059
- eventHandlers.push({
1060
- eventName: "delete:".concat(collectionName),
1061
- handler: onRemove
1062
- });
1063
- extraParsers === null || extraParsers === void 0 ? void 0 : extraParsers.forEach(function(parsers) {
1064
- var extraOnAdd = parsers.onAdd, extraOnFirstTime = parsers.onFirstTime, extraOnModify = parsers.onModify, extraOnRemove = parsers.onRemove;
1065
- s.on("initial:".concat(collectionName), extraOnFirstTime);
1066
- eventHandlers.push({
1067
- eventName: "initial:".concat(collectionName),
1068
- handler: extraOnFirstTime
1069
- });
1070
- s.on("add:".concat(collectionName), extraOnAdd);
1071
- eventHandlers.push({
1072
- eventName: "add:".concat(collectionName),
1073
- handler: extraOnAdd
1074
- });
1075
- s.on("update:".concat(collectionName), extraOnModify);
1141
+ var attach = function(eventName, handler) {
1142
+ _this.socket.off(eventName, handler);
1143
+ _this.socket.on(eventName, handler);
1076
1144
  eventHandlers.push({
1077
- eventName: "update:".concat(collectionName),
1078
- handler: extraOnModify
1079
- });
1080
- s.on("delete:".concat(collectionName), extraOnRemove);
1081
- eventHandlers.push({
1082
- eventName: "delete:".concat(collectionName),
1083
- handler: extraOnRemove
1145
+ eventName: eventName,
1146
+ handler: handler
1084
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);
1085
1159
  });
1086
1160
  });
1087
1161
  s.emit("subscribe_collections", collectionsNames, function(callback) {
@@ -1182,49 +1256,6 @@ var SocketService = /*#__PURE__*/ function() {
1182
1256
  });
1183
1257
  });
1184
1258
  }
1185
- },
1186
- {
1187
- /// connection management methods
1188
- key: "onConnect",
1189
- value: function onConnect(callback) {
1190
- var _this_socket;
1191
- this.connectCallbacks.push(callback);
1192
- if ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) {
1193
- callback();
1194
- }
1195
- }
1196
- },
1197
- {
1198
- key: "offConnect",
1199
- value: function offConnect(callback) {
1200
- this.connectCallbacks = this.connectCallbacks.filter(function(cb) {
1201
- return cb !== callback;
1202
- });
1203
- }
1204
- },
1205
- {
1206
- key: "onDisconnect",
1207
- value: function onDisconnect(callback) {
1208
- this.disconnectCallbacks.push(callback);
1209
- if (this.socket && !this.socket.connected) {
1210
- callback();
1211
- }
1212
- }
1213
- },
1214
- {
1215
- key: "offDisconnect",
1216
- value: function offDisconnect(callback) {
1217
- this.disconnectCallbacks = this.disconnectCallbacks.filter(function(cb) {
1218
- return cb !== callback;
1219
- });
1220
- }
1221
- },
1222
- {
1223
- key: "isConnected",
1224
- value: function isConnected() {
1225
- var _this_socket;
1226
- return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false;
1227
- }
1228
1259
  }
1229
1260
  ], [
1230
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";
@@ -274,10 +273,19 @@ declare class SocketService {
274
273
  private socket;
275
274
  private connectCallbacks;
276
275
  private disconnectCallbacks;
276
+ private authToken;
277
277
  private initSocket;
278
278
  private constructor();
279
279
  static getInstance(): SocketService;
280
- 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;
281
289
  subscribeToCollections(config: OnSnapshotConfig[]): () => void;
282
290
  setData<UpdateType extends RedisUpdateType, DataType = any>(payload: RedisUpdatePayload<UpdateType, DataType>): Promise<SocketCallbackResponse>;
283
291
  getCollectionData<T>(payload: Omit<GetDataPayload<T>, "key">): void;
@@ -287,11 +295,6 @@ declare class SocketService {
287
295
  collection_name: string;
288
296
  }): Promise<SocketCallbackResponse>;
289
297
  clearAllRedisData(): Promise<SocketCallbackResponse>;
290
- onConnect(callback: () => void): void;
291
- offConnect(callback: () => void): void;
292
- onDisconnect(callback: () => void): void;
293
- offDisconnect(callback: () => void): void;
294
- isConnected(): boolean;
295
298
  }
296
299
  declare const socketServiceInstance: SocketService;
297
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";
@@ -274,10 +273,19 @@ declare class SocketService {
274
273
  private socket;
275
274
  private connectCallbacks;
276
275
  private disconnectCallbacks;
276
+ private authToken;
277
277
  private initSocket;
278
278
  private constructor();
279
279
  static getInstance(): SocketService;
280
- 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;
281
289
  subscribeToCollections(config: OnSnapshotConfig[]): () => void;
282
290
  setData<UpdateType extends RedisUpdateType, DataType = any>(payload: RedisUpdatePayload<UpdateType, DataType>): Promise<SocketCallbackResponse>;
283
291
  getCollectionData<T>(payload: Omit<GetDataPayload<T>, "key">): void;
@@ -287,11 +295,6 @@ declare class SocketService {
287
295
  collection_name: string;
288
296
  }): Promise<SocketCallbackResponse>;
289
297
  clearAllRedisData(): Promise<SocketCallbackResponse>;
290
- onConnect(callback: () => void): void;
291
- offConnect(callback: () => void): void;
292
- onDisconnect(callback: () => void): void;
293
- offDisconnect(callback: () => void): void;
294
- isConnected(): boolean;
295
298
  }
296
299
  declare const socketServiceInstance: SocketService;
297
300