@kinotic-ai/core 1.4.1 → 1.5.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.
package/dist/index.cjs CHANGED
@@ -152,6 +152,7 @@ var import_stompjs = require("@stomp/stompjs");
152
152
  var import_debug = __toESM(require("debug"));
153
153
  var import_rxjs = require("rxjs");
154
154
  var import_uuid = require("uuid");
155
+ var SESSION_CHECK_PATH = "/api/me";
155
156
 
156
157
  class StompConnectionManager {
157
158
  lastWebsocketError = null;
@@ -216,6 +217,16 @@ class StompConnectionManager {
216
217
  reconnectTimeMode: import_stompjs.ReconnectionTimeMode.EXPONENTIAL,
217
218
  webSocketFactory: userWebSocketFactory ? () => preparedSocket : undefined,
218
219
  beforeConnect: async () => {
220
+ if (!userWebSocketFactory) {
221
+ const sessionCheckUrl = "http" + (connectionInfo.useSSL ? "s" : "") + "://" + connectionInfo.host + (connectionInfo.port ? ":" + connectionInfo.port : "") + SESSION_CHECK_PATH;
222
+ try {
223
+ const res = await fetch(sessionCheckUrl, { credentials: "include" });
224
+ if (res.status === 401) {
225
+ await this.signalFatal(new Error("Authentication required"));
226
+ return;
227
+ }
228
+ } catch {}
229
+ }
219
230
  if (connectionInfo?.maxConnectionAttempts) {
220
231
  this.connectionAttempts++;
221
232
  if (this.connectionAttempts > connectionInfo.maxConnectionAttempts) {
@@ -983,7 +994,7 @@ var import_operators2 = require("rxjs/operators");
983
994
  // packages/core/package.json
984
995
  var package_default = {
985
996
  name: "@kinotic-ai/core",
986
- version: "1.4.1",
997
+ version: "1.5.0",
987
998
  type: "module",
988
999
  files: [
989
1000
  "dist"
package/dist/index.js CHANGED
@@ -53,6 +53,7 @@ import { ReconnectionTimeMode } from "@stomp/stompjs";
53
53
  import debug from "debug";
54
54
  import { Subject } from "rxjs";
55
55
  import { v4 as uuidv4 } from "uuid";
56
+ var SESSION_CHECK_PATH = "/api/me";
56
57
 
57
58
  class StompConnectionManager {
58
59
  lastWebsocketError = null;
@@ -117,6 +118,16 @@ class StompConnectionManager {
117
118
  reconnectTimeMode: ReconnectionTimeMode.EXPONENTIAL,
118
119
  webSocketFactory: userWebSocketFactory ? () => preparedSocket : undefined,
119
120
  beforeConnect: async () => {
121
+ if (!userWebSocketFactory) {
122
+ const sessionCheckUrl = "http" + (connectionInfo.useSSL ? "s" : "") + "://" + connectionInfo.host + (connectionInfo.port ? ":" + connectionInfo.port : "") + SESSION_CHECK_PATH;
123
+ try {
124
+ const res = await fetch(sessionCheckUrl, { credentials: "include" });
125
+ if (res.status === 401) {
126
+ await this.signalFatal(new Error("Authentication required"));
127
+ return;
128
+ }
129
+ } catch {}
130
+ }
120
131
  if (connectionInfo?.maxConnectionAttempts) {
121
132
  this.connectionAttempts++;
122
133
  if (this.connectionAttempts > connectionInfo.maxConnectionAttempts) {
@@ -887,7 +898,7 @@ import { first, map as map2 } from "rxjs/operators";
887
898
  // packages/core/package.json
888
899
  var package_default = {
889
900
  name: "@kinotic-ai/core",
890
- version: "1.4.1",
901
+ version: "1.5.0",
891
902
  type: "module",
892
903
  files: [
893
904
  "dist"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kinotic-ai/core",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"