@kinotic-ai/core 1.3.0 → 1.3.1
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 +15 -2
- package/dist/index.d.cts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +15 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -210,6 +210,8 @@ class StompConnectionManager {
|
|
|
210
210
|
this.serverHeadersSubscription = null;
|
|
211
211
|
const url = "ws" + (connectionInfo.useSSL ? "s" : "") + "://" + connectionInfo.host + (connectionInfo.port ? ":" + connectionInfo.port : "") + "/v1";
|
|
212
212
|
this.rxStomp = new import_rx_stomp.RxStomp;
|
|
213
|
+
let preparedSocket = null;
|
|
214
|
+
const userWebSocketFactory = connectionInfo.webSocketFactory;
|
|
213
215
|
const stompConfig = {
|
|
214
216
|
brokerURL: url,
|
|
215
217
|
connectHeaders: {
|
|
@@ -218,7 +220,7 @@ class StompConnectionManager {
|
|
|
218
220
|
heartbeatIncoming: 120000,
|
|
219
221
|
heartbeatOutgoing: 30000,
|
|
220
222
|
reconnectDelay: this.INITIAL_RECONNECT_DELAY,
|
|
221
|
-
webSocketFactory:
|
|
223
|
+
webSocketFactory: userWebSocketFactory ? () => preparedSocket : undefined,
|
|
222
224
|
beforeConnect: async () => {
|
|
223
225
|
if (connectionInfo?.maxConnectionAttempts) {
|
|
224
226
|
this.connectionAttempts++;
|
|
@@ -229,12 +231,23 @@ class StompConnectionManager {
|
|
|
229
231
|
let message = this.lastWebsocketError?.message ? this.lastWebsocketError?.message : "UNKNOWN";
|
|
230
232
|
reject(`Max number of reconnection attempts reached. Last WS Error ${message}`);
|
|
231
233
|
}
|
|
234
|
+
return;
|
|
232
235
|
} else {
|
|
233
236
|
await this.connectionJitterDelay();
|
|
234
237
|
}
|
|
235
238
|
} else {
|
|
236
239
|
await this.connectionJitterDelay();
|
|
237
240
|
}
|
|
241
|
+
if (userWebSocketFactory) {
|
|
242
|
+
try {
|
|
243
|
+
preparedSocket = await userWebSocketFactory();
|
|
244
|
+
} catch (e) {
|
|
245
|
+
await this.deactivate();
|
|
246
|
+
if (!this.initialConnectionSuccessful) {
|
|
247
|
+
reject(e);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
238
251
|
}
|
|
239
252
|
};
|
|
240
253
|
if (this.debugLogger.enabled) {
|
|
@@ -989,7 +1002,7 @@ var import_operators2 = require("rxjs/operators");
|
|
|
989
1002
|
// packages/core/package.json
|
|
990
1003
|
var package_default = {
|
|
991
1004
|
name: "@kinotic-ai/core",
|
|
992
|
-
version: "1.3.
|
|
1005
|
+
version: "1.3.1",
|
|
993
1006
|
type: "module",
|
|
994
1007
|
files: [
|
|
995
1008
|
"dist"
|
package/dist/index.d.cts
CHANGED
|
@@ -17,11 +17,12 @@ interface IWebSocket {
|
|
|
17
17
|
/**
|
|
18
18
|
* Factory invoked on every (re)connect to produce the WebSocket the STOMP
|
|
19
19
|
* client will use. Supply this in Node when you need to set headers on the
|
|
20
|
-
* upgrade request (for example, an Authorization header).
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* upgrade request (for example, an Authorization header). It may be async —
|
|
21
|
+
* for example, to refresh a short-lived access token before each connect.
|
|
22
|
+
* Browser callers normally leave this unset and rely on the session cookie
|
|
23
|
+
* established by a prior REST login.
|
|
23
24
|
*/
|
|
24
|
-
type WebSocketFactory = () => IWebSocket
|
|
25
|
+
type WebSocketFactory = () => IWebSocket | Promise<IWebSocket>;
|
|
25
26
|
declare class ServerInfo {
|
|
26
27
|
host: string;
|
|
27
28
|
port?: number | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -17,11 +17,12 @@ interface IWebSocket {
|
|
|
17
17
|
/**
|
|
18
18
|
* Factory invoked on every (re)connect to produce the WebSocket the STOMP
|
|
19
19
|
* client will use. Supply this in Node when you need to set headers on the
|
|
20
|
-
* upgrade request (for example, an Authorization header).
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* upgrade request (for example, an Authorization header). It may be async —
|
|
21
|
+
* for example, to refresh a short-lived access token before each connect.
|
|
22
|
+
* Browser callers normally leave this unset and rely on the session cookie
|
|
23
|
+
* established by a prior REST login.
|
|
23
24
|
*/
|
|
24
|
-
type WebSocketFactory = () => IWebSocket
|
|
25
|
+
type WebSocketFactory = () => IWebSocket | Promise<IWebSocket>;
|
|
25
26
|
declare class ServerInfo {
|
|
26
27
|
host: string;
|
|
27
28
|
port?: number | null;
|
package/dist/index.js
CHANGED
|
@@ -108,6 +108,8 @@ class StompConnectionManager {
|
|
|
108
108
|
this.serverHeadersSubscription = null;
|
|
109
109
|
const url = "ws" + (connectionInfo.useSSL ? "s" : "") + "://" + connectionInfo.host + (connectionInfo.port ? ":" + connectionInfo.port : "") + "/v1";
|
|
110
110
|
this.rxStomp = new RxStomp;
|
|
111
|
+
let preparedSocket = null;
|
|
112
|
+
const userWebSocketFactory = connectionInfo.webSocketFactory;
|
|
111
113
|
const stompConfig = {
|
|
112
114
|
brokerURL: url,
|
|
113
115
|
connectHeaders: {
|
|
@@ -116,7 +118,7 @@ class StompConnectionManager {
|
|
|
116
118
|
heartbeatIncoming: 120000,
|
|
117
119
|
heartbeatOutgoing: 30000,
|
|
118
120
|
reconnectDelay: this.INITIAL_RECONNECT_DELAY,
|
|
119
|
-
webSocketFactory:
|
|
121
|
+
webSocketFactory: userWebSocketFactory ? () => preparedSocket : undefined,
|
|
120
122
|
beforeConnect: async () => {
|
|
121
123
|
if (connectionInfo?.maxConnectionAttempts) {
|
|
122
124
|
this.connectionAttempts++;
|
|
@@ -127,12 +129,23 @@ class StompConnectionManager {
|
|
|
127
129
|
let message = this.lastWebsocketError?.message ? this.lastWebsocketError?.message : "UNKNOWN";
|
|
128
130
|
reject(`Max number of reconnection attempts reached. Last WS Error ${message}`);
|
|
129
131
|
}
|
|
132
|
+
return;
|
|
130
133
|
} else {
|
|
131
134
|
await this.connectionJitterDelay();
|
|
132
135
|
}
|
|
133
136
|
} else {
|
|
134
137
|
await this.connectionJitterDelay();
|
|
135
138
|
}
|
|
139
|
+
if (userWebSocketFactory) {
|
|
140
|
+
try {
|
|
141
|
+
preparedSocket = await userWebSocketFactory();
|
|
142
|
+
} catch (e) {
|
|
143
|
+
await this.deactivate();
|
|
144
|
+
if (!this.initialConnectionSuccessful) {
|
|
145
|
+
reject(e);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
136
149
|
}
|
|
137
150
|
};
|
|
138
151
|
if (this.debugLogger.enabled) {
|
|
@@ -890,7 +903,7 @@ import { first, map as map2 } from "rxjs/operators";
|
|
|
890
903
|
// packages/core/package.json
|
|
891
904
|
var package_default = {
|
|
892
905
|
name: "@kinotic-ai/core",
|
|
893
|
-
version: "1.3.
|
|
906
|
+
version: "1.3.1",
|
|
894
907
|
type: "module",
|
|
895
908
|
files: [
|
|
896
909
|
"dist"
|