akeyless-client-commons 1.1.17-test.2 → 1.1.17-test.4

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.
@@ -557,8 +557,7 @@ var SocketService = /*#__PURE__*/ function() {
557
557
  this.socket = null;
558
558
  this.connectCallbacks = [];
559
559
  this.disconnectCallbacks = [];
560
- this.transportCloseCount = 0;
561
- this.maxTransportCloseAttempts = 3;
560
+ this.authToken = null;
562
561
  }
563
562
  _create_class(_SocketService, [
564
563
  {
@@ -571,47 +570,21 @@ var SocketService = /*#__PURE__*/ function() {
571
570
  this.socket = io(socketUrl, {
572
571
  path: "/api/data-socket/connect",
573
572
  transports: [
574
- "websocket",
575
- "polling"
573
+ "websocket"
576
574
  ],
577
- // Add polling as fallback
578
- timeout: 2e4,
579
- // Connection timeout
580
- reconnection: true,
581
- reconnectionDelay: 1e3,
582
- reconnectionDelayMax: 5e3,
583
- reconnectionAttempts: 5,
584
- forceNew: false,
585
- // Don't force new connection every time
586
- upgrade: true,
587
- // Allow transport upgrades
588
- rememberUpgrade: true
575
+ auth: this.authToken ? {
576
+ token: this.authToken
577
+ } : void 0
589
578
  });
590
579
  this.socket.on("connect", function() {
591
- var _this_socket, _this_socket1;
580
+ var _this_socket;
592
581
  console.log("Socket connected:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.id);
593
- console.log("Transport:", (_this_socket1 = _this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.io.engine.transport.name);
594
582
  _this.connectCallbacks.forEach(function(cb) {
595
583
  return cb();
596
584
  });
597
585
  });
598
586
  this.socket.on("disconnect", function(reason) {
599
587
  console.log("Socket disconnected:", reason);
600
- if (reason === "transport close" || reason === "transport error") {
601
- console.log("Transport issue detected, will attempt reconnection");
602
- _this.transportCloseCount++;
603
- if (_this.transportCloseCount >= _this.maxTransportCloseAttempts) {
604
- console.warn("Transport closed ".concat(_this.transportCloseCount, " times, switching to polling only"));
605
- if (_this.socket && _this.socket.io) {
606
- _this.socket.io.opts.transports = [
607
- "polling"
608
- ];
609
- }
610
- _this.transportCloseCount = 0;
611
- }
612
- } else {
613
- _this.transportCloseCount = 0;
614
- }
615
588
  _this.disconnectCallbacks.forEach(function(cb) {
616
589
  return cb();
617
590
  });
@@ -619,22 +592,6 @@ var SocketService = /*#__PURE__*/ function() {
619
592
  this.socket.on("connect_error", function(error) {
620
593
  console.error("Socket connection error:", error);
621
594
  });
622
- this.socket.on("reconnect", function(attemptNumber) {
623
- console.log("Socket reconnected after", attemptNumber, "attempts");
624
- });
625
- this.socket.on("reconnect_error", function(error) {
626
- console.error("Socket reconnection error:", error);
627
- });
628
- this.socket.on("reconnect_failed", function() {
629
- console.error("Socket reconnection failed");
630
- });
631
- this.socket.io.engine.on("upgrade", function() {
632
- var _this_socket;
633
- console.log("Transport upgraded to:", (_this_socket = _this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.io.engine.transport.name);
634
- });
635
- this.socket.io.engine.on("upgradeError", function(error) {
636
- console.error("Transport upgrade error:", error);
637
- });
638
595
  }
639
596
  }
640
597
  },
@@ -658,6 +615,9 @@ var SocketService = /*#__PURE__*/ function() {
658
615
  /// subscribe to collections
659
616
  key: "subscribeToCollections",
660
617
  value: function subscribeToCollections(config) {
618
+ if (config.length === 0) {
619
+ return function() {};
620
+ }
661
621
  var s = this.getSocketInstance();
662
622
  var collectionsNames = config.map(function(c) {
663
623
  return c.collectionName;
@@ -852,33 +812,19 @@ var SocketService = /*#__PURE__*/ function() {
852
812
  }
853
813
  },
854
814
  {
855
- key: "getTransportName",
856
- value: function getTransportName() {
857
- var _this_socket;
858
- return ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.io.engine.transport.name) || "unknown";
859
- }
860
- },
861
- {
862
- key: "forceReconnect",
863
- value: function forceReconnect() {
815
+ key: "setAuthToken",
816
+ value: function setAuthToken(token) {
817
+ this.authToken = token;
864
818
  if (this.socket) {
865
- console.log("Forcing socket reconnection...");
866
- this.socket.disconnect();
819
+ this.socket.auth = {
820
+ token: token
821
+ };
822
+ if (this.socket.connected) {
823
+ this.socket.disconnect();
824
+ }
867
825
  this.socket.connect();
868
826
  }
869
827
  }
870
- },
871
- {
872
- key: "getConnectionState",
873
- value: function getConnectionState() {
874
- var _this_socket, _this_socket1, _this_socket2, _this_socket3;
875
- return {
876
- connected: ((_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.connected) || false,
877
- transport: ((_this_socket1 = this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.io.engine.transport.name) || "unknown",
878
- id: (_this_socket2 = this.socket) === null || _this_socket2 === void 0 ? void 0 : _this_socket2.id,
879
- reconnecting: ((_this_socket3 = this.socket) === null || _this_socket3 === void 0 ? void 0 : _this_socket3.io.engine.readyState) === "opening"
880
- };
881
- }
882
828
  }
883
829
  ], [
884
830
  {
@@ -958,9 +904,6 @@ var useSocketSubscription = function(configs, label, settings) {
958
904
  socketServiceInstance.onDisconnect(uiOnDisconnect);
959
905
  setSocketConnected(socketServiceInstance.isConnected());
960
906
  return function() {
961
- if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
962
- console.log("==> ".concat(label || "Cache snapshots", " stopped. "));
963
- }
964
907
  if (settings === null || settings === void 0 ? void 0 : settings.cleanupForConfigChange) {
965
908
  cleanupSubscriptions.forEach(function(cleanup) {
966
909
  return cleanup();
@@ -968,6 +911,9 @@ var useSocketSubscription = function(configs, label, settings) {
968
911
  socketServiceInstance.offConnect(uiOnConnect);
969
912
  socketServiceInstance.offDisconnect(uiOnDisconnect);
970
913
  }
914
+ if (!(settings === null || settings === void 0 ? void 0 : settings.disableLogs) && configs.length > 0) {
915
+ console.log("==> ".concat(label || "Cache snapshots", " unsubscribed. "));
916
+ }
971
917
  };
972
918
  }, [
973
919
  socketConnected,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akeyless-client-commons",
3
- "version": "1.1.17-test.2",
3
+ "version": "1.1.17-test.4",
4
4
  "scripts": {
5
5
  "build": "tsup",
6
6
  "deploy": "npm run build && npm version patch --no-git-tag-version && npm publish",