@kinotic-ai/core 5.0.0-beta.29 → 5.0.0-beta.30
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 +29 -6
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +29 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -124,7 +124,8 @@ class ServerInfo {
|
|
|
124
124
|
useSSL;
|
|
125
125
|
}
|
|
126
126
|
function buildServerUrl(server, scheme) {
|
|
127
|
-
|
|
127
|
+
const host = server.host.includes(":") && !server.host.startsWith("[") ? "[" + server.host + "]" : server.host;
|
|
128
|
+
return scheme + (server.useSSL ? "s" : "") + "://" + host + (server.port ? ":" + server.port : "");
|
|
128
129
|
}
|
|
129
130
|
function buildBrokerUrl(server) {
|
|
130
131
|
return buildServerUrl(server, "ws") + "/api/v1";
|
|
@@ -446,7 +447,9 @@ class StompConnectionManager {
|
|
|
446
447
|
this.failConnection(activation, new Error("Credentials resolver no longer supplies auth headers: " + credentialsResolver.name));
|
|
447
448
|
} else {
|
|
448
449
|
const WS = WebSocket;
|
|
449
|
-
|
|
450
|
+
const socket = new WS(url, { headers: resolved.authHeaders });
|
|
451
|
+
this.endOnRejectedUpgrade(activation, socket);
|
|
452
|
+
activation.preparedSocket = socket;
|
|
450
453
|
}
|
|
451
454
|
} catch (e) {
|
|
452
455
|
this.failConnection(activation, new Error("Credential resolution failed", { cause: e }));
|
|
@@ -457,6 +460,18 @@ class StompConnectionManager {
|
|
|
457
460
|
activation.preparedSocket = null;
|
|
458
461
|
}
|
|
459
462
|
}
|
|
463
|
+
endOnRejectedUpgrade(activation, socket) {
|
|
464
|
+
const emitter = socket;
|
|
465
|
+
if (typeof emitter.on === "function") {
|
|
466
|
+
emitter.on("unexpected-response", (_request, response) => {
|
|
467
|
+
const status = response.statusCode ?? 0;
|
|
468
|
+
if (status >= 400 && status < 500) {
|
|
469
|
+
this.failConnection(activation, new Error("Connection rejected with status " + status));
|
|
470
|
+
}
|
|
471
|
+
socket.close();
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
}
|
|
460
475
|
deactivate(force, reason = null) {
|
|
461
476
|
const activation = this.activation;
|
|
462
477
|
let ret;
|
|
@@ -874,6 +889,7 @@ class SessionCredentialsResolver {
|
|
|
874
889
|
// packages/core/src/internal/api/Util.ts
|
|
875
890
|
var DEFAULT_PORT = 58503;
|
|
876
891
|
var DEFAULT_HOST = "api.kinotic.ai";
|
|
892
|
+
var LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "::1", "[::1]"];
|
|
877
893
|
|
|
878
894
|
class Util {
|
|
879
895
|
static createReplyEvent(incomingHeaders, headers, body) {
|
|
@@ -904,7 +920,6 @@ class Util {
|
|
|
904
920
|
const location = typeof window !== "undefined" ? window.location : undefined;
|
|
905
921
|
let host = server.host ?? env?.KINOTIC_SERVER_HOST;
|
|
906
922
|
const hostFromLocation = host == null && location != null;
|
|
907
|
-
const hostDefaulted = host == null && location == null;
|
|
908
923
|
if (host == null) {
|
|
909
924
|
host = location?.hostname ?? DEFAULT_HOST;
|
|
910
925
|
}
|
|
@@ -915,7 +930,7 @@ class Util {
|
|
|
915
930
|
} else if (hostFromLocation) {
|
|
916
931
|
useSSL = location.protocol === "https:";
|
|
917
932
|
} else {
|
|
918
|
-
useSSL =
|
|
933
|
+
useSSL = !LOOPBACK_HOSTS.includes(host.toLowerCase());
|
|
919
934
|
}
|
|
920
935
|
}
|
|
921
936
|
let port = server.port;
|
|
@@ -1314,7 +1329,7 @@ var import_api2 = __toESM(require("@opentelemetry/api"), 1);
|
|
|
1314
1329
|
// packages/core/package.json
|
|
1315
1330
|
var package_default = {
|
|
1316
1331
|
name: "@kinotic-ai/core",
|
|
1317
|
-
version: "5.0.0-beta.
|
|
1332
|
+
version: "5.0.0-beta.30",
|
|
1318
1333
|
type: "module",
|
|
1319
1334
|
files: [
|
|
1320
1335
|
"dist"
|
|
@@ -1655,10 +1670,18 @@ class ServiceInvocationSupervisor {
|
|
|
1655
1670
|
if (!correlationId) {
|
|
1656
1671
|
throw new Error("Streaming results require a CORRELATION_ID_HEADER to be set");
|
|
1657
1672
|
}
|
|
1673
|
+
if (this.activeStreams.has(correlationId)) {
|
|
1674
|
+
const error = new Error(`stream ${correlationId} already active`);
|
|
1675
|
+
this.handleException(event, error);
|
|
1676
|
+
this.failSpan(span, error);
|
|
1677
|
+
return;
|
|
1678
|
+
}
|
|
1658
1679
|
let subscription = null;
|
|
1659
1680
|
let failed = false;
|
|
1660
1681
|
subscription = stream.pipe(import_operators3.finalize(() => {
|
|
1661
|
-
this.activeStreams.
|
|
1682
|
+
if (this.activeStreams.get(correlationId)?.subscription === subscription) {
|
|
1683
|
+
this.activeStreams.delete(correlationId);
|
|
1684
|
+
}
|
|
1662
1685
|
span.end();
|
|
1663
1686
|
})).subscribe({
|
|
1664
1687
|
next: (value) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -54,6 +54,11 @@ type WebSocketFactory = () => IWebSocket | Promise<IWebSocket>;
|
|
|
54
54
|
declare class ServerInfo {
|
|
55
55
|
host: string;
|
|
56
56
|
port?: number | null;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the server is reached over TLS. Absent, {@code KINOTIC_SERVER_USE_SSL} decides,
|
|
59
|
+
* then the page's own protocol for a host taken from the browser's location, and otherwise
|
|
60
|
+
* TLS for every host but a loopback one ({@code localhost}, {@code 127.0.0.1}, {@code ::1}).
|
|
61
|
+
*/
|
|
57
62
|
useSSL?: boolean | null;
|
|
58
63
|
}
|
|
59
64
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,11 @@ type WebSocketFactory = () => IWebSocket | Promise<IWebSocket>;
|
|
|
54
54
|
declare class ServerInfo {
|
|
55
55
|
host: string;
|
|
56
56
|
port?: number | null;
|
|
57
|
+
/**
|
|
58
|
+
* Whether the server is reached over TLS. Absent, {@code KINOTIC_SERVER_USE_SSL} decides,
|
|
59
|
+
* then the page's own protocol for a host taken from the browser's location, and otherwise
|
|
60
|
+
* TLS for every host but a loopback one ({@code localhost}, {@code 127.0.0.1}, {@code ::1}).
|
|
61
|
+
*/
|
|
57
62
|
useSSL?: boolean | null;
|
|
58
63
|
}
|
|
59
64
|
/**
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,8 @@ class ServerInfo {
|
|
|
5
5
|
useSSL;
|
|
6
6
|
}
|
|
7
7
|
function buildServerUrl(server, scheme) {
|
|
8
|
-
|
|
8
|
+
const host = server.host.includes(":") && !server.host.startsWith("[") ? "[" + server.host + "]" : server.host;
|
|
9
|
+
return scheme + (server.useSSL ? "s" : "") + "://" + host + (server.port ? ":" + server.port : "");
|
|
9
10
|
}
|
|
10
11
|
function buildBrokerUrl(server) {
|
|
11
12
|
return buildServerUrl(server, "ws") + "/api/v1";
|
|
@@ -327,7 +328,9 @@ class StompConnectionManager {
|
|
|
327
328
|
this.failConnection(activation, new Error("Credentials resolver no longer supplies auth headers: " + credentialsResolver.name));
|
|
328
329
|
} else {
|
|
329
330
|
const WS = WebSocket;
|
|
330
|
-
|
|
331
|
+
const socket = new WS(url, { headers: resolved.authHeaders });
|
|
332
|
+
this.endOnRejectedUpgrade(activation, socket);
|
|
333
|
+
activation.preparedSocket = socket;
|
|
331
334
|
}
|
|
332
335
|
} catch (e) {
|
|
333
336
|
this.failConnection(activation, new Error("Credential resolution failed", { cause: e }));
|
|
@@ -338,6 +341,18 @@ class StompConnectionManager {
|
|
|
338
341
|
activation.preparedSocket = null;
|
|
339
342
|
}
|
|
340
343
|
}
|
|
344
|
+
endOnRejectedUpgrade(activation, socket) {
|
|
345
|
+
const emitter = socket;
|
|
346
|
+
if (typeof emitter.on === "function") {
|
|
347
|
+
emitter.on("unexpected-response", (_request, response) => {
|
|
348
|
+
const status = response.statusCode ?? 0;
|
|
349
|
+
if (status >= 400 && status < 500) {
|
|
350
|
+
this.failConnection(activation, new Error("Connection rejected with status " + status));
|
|
351
|
+
}
|
|
352
|
+
socket.close();
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
}
|
|
341
356
|
deactivate(force, reason = null) {
|
|
342
357
|
const activation = this.activation;
|
|
343
358
|
let ret;
|
|
@@ -755,6 +770,7 @@ class SessionCredentialsResolver {
|
|
|
755
770
|
// packages/core/src/internal/api/Util.ts
|
|
756
771
|
var DEFAULT_PORT = 58503;
|
|
757
772
|
var DEFAULT_HOST = "api.kinotic.ai";
|
|
773
|
+
var LOOPBACK_HOSTS = ["localhost", "127.0.0.1", "::1", "[::1]"];
|
|
758
774
|
|
|
759
775
|
class Util {
|
|
760
776
|
static createReplyEvent(incomingHeaders, headers, body) {
|
|
@@ -785,7 +801,6 @@ class Util {
|
|
|
785
801
|
const location = typeof window !== "undefined" ? window.location : undefined;
|
|
786
802
|
let host = server.host ?? env?.KINOTIC_SERVER_HOST;
|
|
787
803
|
const hostFromLocation = host == null && location != null;
|
|
788
|
-
const hostDefaulted = host == null && location == null;
|
|
789
804
|
if (host == null) {
|
|
790
805
|
host = location?.hostname ?? DEFAULT_HOST;
|
|
791
806
|
}
|
|
@@ -796,7 +811,7 @@ class Util {
|
|
|
796
811
|
} else if (hostFromLocation) {
|
|
797
812
|
useSSL = location.protocol === "https:";
|
|
798
813
|
} else {
|
|
799
|
-
useSSL =
|
|
814
|
+
useSSL = !LOOPBACK_HOSTS.includes(host.toLowerCase());
|
|
800
815
|
}
|
|
801
816
|
}
|
|
802
817
|
let port = server.port;
|
|
@@ -1195,7 +1210,7 @@ import opentelemetry, { context as context2, propagation as propagation2, trace,
|
|
|
1195
1210
|
// packages/core/package.json
|
|
1196
1211
|
var package_default = {
|
|
1197
1212
|
name: "@kinotic-ai/core",
|
|
1198
|
-
version: "5.0.0-beta.
|
|
1213
|
+
version: "5.0.0-beta.30",
|
|
1199
1214
|
type: "module",
|
|
1200
1215
|
files: [
|
|
1201
1216
|
"dist"
|
|
@@ -1536,10 +1551,18 @@ class ServiceInvocationSupervisor {
|
|
|
1536
1551
|
if (!correlationId) {
|
|
1537
1552
|
throw new Error("Streaming results require a CORRELATION_ID_HEADER to be set");
|
|
1538
1553
|
}
|
|
1554
|
+
if (this.activeStreams.has(correlationId)) {
|
|
1555
|
+
const error = new Error(`stream ${correlationId} already active`);
|
|
1556
|
+
this.handleException(event, error);
|
|
1557
|
+
this.failSpan(span, error);
|
|
1558
|
+
return;
|
|
1559
|
+
}
|
|
1539
1560
|
let subscription = null;
|
|
1540
1561
|
let failed = false;
|
|
1541
1562
|
subscription = stream.pipe(finalize(() => {
|
|
1542
|
-
this.activeStreams.
|
|
1563
|
+
if (this.activeStreams.get(correlationId)?.subscription === subscription) {
|
|
1564
|
+
this.activeStreams.delete(correlationId);
|
|
1565
|
+
}
|
|
1543
1566
|
span.end();
|
|
1544
1567
|
})).subscribe({
|
|
1545
1568
|
next: (value) => {
|