@kinotic-ai/core 5.0.0-beta.27 → 5.0.0-beta.28
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 +21 -13
- package/dist/index.js +21 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -194,14 +194,19 @@ class StompActivation {
|
|
|
194
194
|
preparedSocket = null;
|
|
195
195
|
attempt = null;
|
|
196
196
|
failPending = null;
|
|
197
|
+
abortController = new AbortController;
|
|
197
198
|
subscriptions = [];
|
|
198
199
|
get ended() {
|
|
199
200
|
return this._ended;
|
|
200
201
|
}
|
|
202
|
+
get signal() {
|
|
203
|
+
return this.abortController.signal;
|
|
204
|
+
}
|
|
201
205
|
end() {
|
|
202
206
|
this._ended = true;
|
|
203
207
|
this.wake?.();
|
|
204
208
|
this.wake = null;
|
|
209
|
+
this.abortController.abort();
|
|
205
210
|
}
|
|
206
211
|
delay(ms) {
|
|
207
212
|
return new Promise((resolve) => {
|
|
@@ -349,9 +354,9 @@ class StompConnectionManager {
|
|
|
349
354
|
activation.own(this.rxStomp.webSocketErrors$.subscribe((value) => {
|
|
350
355
|
this.lastWebsocketError = value;
|
|
351
356
|
}));
|
|
352
|
-
activation.own(this.rxStomp.stompErrors$.subscribe(
|
|
357
|
+
activation.own(this.rxStomp.stompErrors$.subscribe((frame) => {
|
|
353
358
|
const stompError = new Error(frame.headers["message"], { cause: frame });
|
|
354
|
-
|
|
359
|
+
this.failConnection(activation, new Error("STOMP connection error", { cause: stompError }));
|
|
355
360
|
}));
|
|
356
361
|
activation.own(this.rxStomp.connected$.subscribe(() => {
|
|
357
362
|
activation.established();
|
|
@@ -359,19 +364,19 @@ class StompConnectionManager {
|
|
|
359
364
|
this.connectionAttempts = 0;
|
|
360
365
|
}));
|
|
361
366
|
activation.pending(reject);
|
|
362
|
-
activation.own(this.rxStomp.serverHeaders$.pipe(import_operators.skip(this.rxStompHasConnected ? 1 : 0)).subscribe(
|
|
367
|
+
activation.own(this.rxStomp.serverHeaders$.pipe(import_operators.skip(this.rxStompHasConnected ? 1 : 0)).subscribe((value) => {
|
|
363
368
|
this.rxStompHasConnected = true;
|
|
364
369
|
const connectedInfoJson = value["connected-info" /* CONNECTED_INFO_HEADER */];
|
|
365
370
|
if (connectedInfoJson == null) {
|
|
366
371
|
if (!this.initialConnectionSuccessful) {
|
|
367
|
-
|
|
372
|
+
this.failConnection(activation, new Error("Server did not return proper data for successful login"));
|
|
368
373
|
}
|
|
369
374
|
return;
|
|
370
375
|
}
|
|
371
376
|
const connectedInfo = JSON.parse(connectedInfoJson);
|
|
372
377
|
if (connectedInfo.replyToId == null) {
|
|
373
378
|
if (!this.initialConnectionSuccessful) {
|
|
374
|
-
|
|
379
|
+
this.failConnection(activation, new Error("Server did not return a replyToId for successful login"));
|
|
375
380
|
}
|
|
376
381
|
return;
|
|
377
382
|
}
|
|
@@ -409,9 +414,12 @@ class StompConnectionManager {
|
|
|
409
414
|
if (!usesPreparedSocket) {
|
|
410
415
|
const sessionCheckUrl = buildServerUrl(server, "http") + SESSION_CHECK_PATH;
|
|
411
416
|
try {
|
|
412
|
-
const res = await fetch(sessionCheckUrl, {
|
|
417
|
+
const res = await fetch(sessionCheckUrl, {
|
|
418
|
+
credentials: "include",
|
|
419
|
+
signal: AbortSignal.any([activation.signal, AbortSignal.timeout(this.CONNECTION_TIMEOUT)])
|
|
420
|
+
});
|
|
413
421
|
if (res.status === 401) {
|
|
414
|
-
|
|
422
|
+
this.failConnection(activation, new Error("Authentication required"));
|
|
415
423
|
return;
|
|
416
424
|
}
|
|
417
425
|
} catch (e) {
|
|
@@ -429,19 +437,19 @@ class StompConnectionManager {
|
|
|
429
437
|
try {
|
|
430
438
|
activation.preparedSocket = await userWebSocketFactory();
|
|
431
439
|
} catch (e) {
|
|
432
|
-
|
|
440
|
+
this.failConnection(activation, new Error("WebSocket factory failed", { cause: e }));
|
|
433
441
|
}
|
|
434
442
|
} else if (headerAuth) {
|
|
435
443
|
try {
|
|
436
444
|
const resolved = await credentialsResolver.resolve(server);
|
|
437
445
|
if (resolved?.authHeaders == null) {
|
|
438
|
-
|
|
446
|
+
this.failConnection(activation, new Error("Credentials resolver no longer supplies auth headers: " + credentialsResolver.name));
|
|
439
447
|
} else {
|
|
440
448
|
const WS = WebSocket;
|
|
441
449
|
activation.preparedSocket = new WS(url, { headers: resolved.authHeaders });
|
|
442
450
|
}
|
|
443
451
|
} catch (e) {
|
|
444
|
-
|
|
452
|
+
this.failConnection(activation, new Error("Credential resolution failed", { cause: e }));
|
|
445
453
|
}
|
|
446
454
|
}
|
|
447
455
|
if (activation.ended && activation.preparedSocket) {
|
|
@@ -481,10 +489,10 @@ class StompConnectionManager {
|
|
|
481
489
|
await activation.delay(randomJitter);
|
|
482
490
|
}
|
|
483
491
|
}
|
|
484
|
-
|
|
492
|
+
failConnection(activation, err) {
|
|
485
493
|
if (!activation.ended) {
|
|
486
494
|
this.debugLogger("Connection failed, ending it: %O", err);
|
|
487
|
-
|
|
495
|
+
this.deactivate(undefined, err).catch((e) => this.debugLogger("Closing the failed connection failed: %O", e));
|
|
488
496
|
}
|
|
489
497
|
}
|
|
490
498
|
}
|
|
@@ -1306,7 +1314,7 @@ var import_api2 = __toESM(require("@opentelemetry/api"), 1);
|
|
|
1306
1314
|
// packages/core/package.json
|
|
1307
1315
|
var package_default = {
|
|
1308
1316
|
name: "@kinotic-ai/core",
|
|
1309
|
-
version: "5.0.0-beta.
|
|
1317
|
+
version: "5.0.0-beta.28",
|
|
1310
1318
|
type: "module",
|
|
1311
1319
|
files: [
|
|
1312
1320
|
"dist"
|
package/dist/index.js
CHANGED
|
@@ -75,14 +75,19 @@ class StompActivation {
|
|
|
75
75
|
preparedSocket = null;
|
|
76
76
|
attempt = null;
|
|
77
77
|
failPending = null;
|
|
78
|
+
abortController = new AbortController;
|
|
78
79
|
subscriptions = [];
|
|
79
80
|
get ended() {
|
|
80
81
|
return this._ended;
|
|
81
82
|
}
|
|
83
|
+
get signal() {
|
|
84
|
+
return this.abortController.signal;
|
|
85
|
+
}
|
|
82
86
|
end() {
|
|
83
87
|
this._ended = true;
|
|
84
88
|
this.wake?.();
|
|
85
89
|
this.wake = null;
|
|
90
|
+
this.abortController.abort();
|
|
86
91
|
}
|
|
87
92
|
delay(ms) {
|
|
88
93
|
return new Promise((resolve) => {
|
|
@@ -230,9 +235,9 @@ class StompConnectionManager {
|
|
|
230
235
|
activation.own(this.rxStomp.webSocketErrors$.subscribe((value) => {
|
|
231
236
|
this.lastWebsocketError = value;
|
|
232
237
|
}));
|
|
233
|
-
activation.own(this.rxStomp.stompErrors$.subscribe(
|
|
238
|
+
activation.own(this.rxStomp.stompErrors$.subscribe((frame) => {
|
|
234
239
|
const stompError = new Error(frame.headers["message"], { cause: frame });
|
|
235
|
-
|
|
240
|
+
this.failConnection(activation, new Error("STOMP connection error", { cause: stompError }));
|
|
236
241
|
}));
|
|
237
242
|
activation.own(this.rxStomp.connected$.subscribe(() => {
|
|
238
243
|
activation.established();
|
|
@@ -240,19 +245,19 @@ class StompConnectionManager {
|
|
|
240
245
|
this.connectionAttempts = 0;
|
|
241
246
|
}));
|
|
242
247
|
activation.pending(reject);
|
|
243
|
-
activation.own(this.rxStomp.serverHeaders$.pipe(skip(this.rxStompHasConnected ? 1 : 0)).subscribe(
|
|
248
|
+
activation.own(this.rxStomp.serverHeaders$.pipe(skip(this.rxStompHasConnected ? 1 : 0)).subscribe((value) => {
|
|
244
249
|
this.rxStompHasConnected = true;
|
|
245
250
|
const connectedInfoJson = value["connected-info" /* CONNECTED_INFO_HEADER */];
|
|
246
251
|
if (connectedInfoJson == null) {
|
|
247
252
|
if (!this.initialConnectionSuccessful) {
|
|
248
|
-
|
|
253
|
+
this.failConnection(activation, new Error("Server did not return proper data for successful login"));
|
|
249
254
|
}
|
|
250
255
|
return;
|
|
251
256
|
}
|
|
252
257
|
const connectedInfo = JSON.parse(connectedInfoJson);
|
|
253
258
|
if (connectedInfo.replyToId == null) {
|
|
254
259
|
if (!this.initialConnectionSuccessful) {
|
|
255
|
-
|
|
260
|
+
this.failConnection(activation, new Error("Server did not return a replyToId for successful login"));
|
|
256
261
|
}
|
|
257
262
|
return;
|
|
258
263
|
}
|
|
@@ -290,9 +295,12 @@ class StompConnectionManager {
|
|
|
290
295
|
if (!usesPreparedSocket) {
|
|
291
296
|
const sessionCheckUrl = buildServerUrl(server, "http") + SESSION_CHECK_PATH;
|
|
292
297
|
try {
|
|
293
|
-
const res = await fetch(sessionCheckUrl, {
|
|
298
|
+
const res = await fetch(sessionCheckUrl, {
|
|
299
|
+
credentials: "include",
|
|
300
|
+
signal: AbortSignal.any([activation.signal, AbortSignal.timeout(this.CONNECTION_TIMEOUT)])
|
|
301
|
+
});
|
|
294
302
|
if (res.status === 401) {
|
|
295
|
-
|
|
303
|
+
this.failConnection(activation, new Error("Authentication required"));
|
|
296
304
|
return;
|
|
297
305
|
}
|
|
298
306
|
} catch (e) {
|
|
@@ -310,19 +318,19 @@ class StompConnectionManager {
|
|
|
310
318
|
try {
|
|
311
319
|
activation.preparedSocket = await userWebSocketFactory();
|
|
312
320
|
} catch (e) {
|
|
313
|
-
|
|
321
|
+
this.failConnection(activation, new Error("WebSocket factory failed", { cause: e }));
|
|
314
322
|
}
|
|
315
323
|
} else if (headerAuth) {
|
|
316
324
|
try {
|
|
317
325
|
const resolved = await credentialsResolver.resolve(server);
|
|
318
326
|
if (resolved?.authHeaders == null) {
|
|
319
|
-
|
|
327
|
+
this.failConnection(activation, new Error("Credentials resolver no longer supplies auth headers: " + credentialsResolver.name));
|
|
320
328
|
} else {
|
|
321
329
|
const WS = WebSocket;
|
|
322
330
|
activation.preparedSocket = new WS(url, { headers: resolved.authHeaders });
|
|
323
331
|
}
|
|
324
332
|
} catch (e) {
|
|
325
|
-
|
|
333
|
+
this.failConnection(activation, new Error("Credential resolution failed", { cause: e }));
|
|
326
334
|
}
|
|
327
335
|
}
|
|
328
336
|
if (activation.ended && activation.preparedSocket) {
|
|
@@ -362,10 +370,10 @@ class StompConnectionManager {
|
|
|
362
370
|
await activation.delay(randomJitter);
|
|
363
371
|
}
|
|
364
372
|
}
|
|
365
|
-
|
|
373
|
+
failConnection(activation, err) {
|
|
366
374
|
if (!activation.ended) {
|
|
367
375
|
this.debugLogger("Connection failed, ending it: %O", err);
|
|
368
|
-
|
|
376
|
+
this.deactivate(undefined, err).catch((e) => this.debugLogger("Closing the failed connection failed: %O", e));
|
|
369
377
|
}
|
|
370
378
|
}
|
|
371
379
|
}
|
|
@@ -1187,7 +1195,7 @@ import opentelemetry, { context as context2, propagation as propagation2, trace,
|
|
|
1187
1195
|
// packages/core/package.json
|
|
1188
1196
|
var package_default = {
|
|
1189
1197
|
name: "@kinotic-ai/core",
|
|
1190
|
-
version: "5.0.0-beta.
|
|
1198
|
+
version: "5.0.0-beta.28",
|
|
1191
1199
|
type: "module",
|
|
1192
1200
|
files: [
|
|
1193
1201
|
"dist"
|