@kinotic-ai/core 5.0.0-beta.1 → 5.0.0-beta.3
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 +216 -106
- package/dist/index.d.cts +117 -58
- package/dist/index.d.ts +117 -58
- package/dist/index.js +216 -106
- package/dist/node/index.cjs +79 -0
- package/dist/node/index.d.cts +9 -0
- package/dist/node/index.d.ts +9 -0
- package/dist/node/index.js +14 -0
- package/package.json +14 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* The outcome of credential resolution: the headers to present on the WebSocket upgrade and
|
|
3
|
+
* the scope the caller belongs to. {@link authHeaders} undefined means the connection
|
|
4
|
+
* authenticates with the browser session cookie instead of headers.
|
|
5
|
+
*/
|
|
6
|
+
interface ResolvedCredentials {
|
|
7
|
+
authHeaders?: Record<string, string>;
|
|
8
|
+
organizationId?: string;
|
|
9
|
+
applicationId?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Finds the credentials a Kinotic connection authenticates with. Consulted on every
|
|
13
|
+
* (re)connect, so an implementation backing short-lived credentials can refresh them each
|
|
14
|
+
* time; one whose resolution is expensive — a network round-trip, a disk read — must cache
|
|
15
|
+
* the result internally and refresh only as expiry nears, since reconnects pay the cost of
|
|
16
|
+
* every resolve. Returning null means this resolver found nothing — in a
|
|
17
|
+
* {@link ChainedCredentialsResolver} the next resolver tries; at the top level the connect
|
|
18
|
+
* fails naming every resolver consulted.
|
|
19
|
+
*/
|
|
20
|
+
interface CredentialsResolver {
|
|
21
|
+
/** Short name shown in the connect failure that lists the resolvers consulted. */
|
|
22
|
+
readonly name: string;
|
|
23
|
+
/**
|
|
24
|
+
* Resolves credentials for a connection to the given server, or null when this resolver
|
|
25
|
+
* has none to offer.
|
|
26
|
+
*/
|
|
27
|
+
resolve(server: ServerInfo): Promise<ResolvedCredentials | null>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
2
30
|
* Structural shape of a WebSocket used by the underlying STOMP client.
|
|
3
31
|
* Copied from the WebSocket interface to avoid pulling in the DOM typelib,
|
|
4
32
|
* so this type stays usable in Node environments where `lib: dom` is not set.
|
|
@@ -28,25 +56,45 @@ declare class ServerInfo {
|
|
|
28
56
|
port?: number | null;
|
|
29
57
|
useSSL?: boolean | null;
|
|
30
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Builds the base URL of a server for the given scheme stem ({@code 'ws'} or {@code 'http'}):
|
|
61
|
+
* TLS appends {@code s}, and the port is omitted when absent so the scheme default applies.
|
|
62
|
+
*/
|
|
63
|
+
declare function buildServerUrl(server: ServerInfo, scheme: "ws" | "http"): string;
|
|
64
|
+
/**
|
|
65
|
+
* Builds the WebSocket broker URL the STOMP client connects to for a given server — the
|
|
66
|
+
* single source of truth for the broker path, so a caller supplying its own
|
|
67
|
+
* {@link WebSocketFactory} never re-types it and drifts from core.
|
|
68
|
+
*/
|
|
69
|
+
declare function buildBrokerUrl(server: ServerInfo): string;
|
|
31
70
|
declare enum SessionKeepAliveMode {
|
|
32
71
|
NONE = "NONE",
|
|
33
72
|
ACTIVITY = "ACTIVITY",
|
|
34
73
|
CONNECTION = "CONNECTION"
|
|
35
74
|
}
|
|
36
75
|
/**
|
|
37
|
-
*
|
|
76
|
+
* Options for {@link IKinotic#connect}. Every field is optional: absent {@link server}
|
|
77
|
+
* fields resolve from the environment (the {@code KINOTIC_SERVER_HOST} /
|
|
78
|
+
* {@code KINOTIC_SERVER_PORT} / {@code KINOTIC_SERVER_USE_SSL} variables, the browser's own
|
|
79
|
+
* location, then {@code https://api.kinotic.com}), and absent {@link credentials} resolve
|
|
80
|
+
* through the default {@link ChainedCredentialsResolver} (environment variables, then the
|
|
81
|
+
* browser session).
|
|
38
82
|
*
|
|
39
|
-
* Authentication is performed during the WebSocket upgrade (handshake), not in
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* {@link WebSocketFactory} that attaches the required upgrade headers.
|
|
83
|
+
* Authentication is performed during the WebSocket upgrade (handshake), not in the STOMP
|
|
84
|
+
* CONNECT frame: the resolved credentials supply the upgrade headers, or none for
|
|
85
|
+
* session-cookie auth.
|
|
43
86
|
*/
|
|
44
|
-
|
|
87
|
+
interface ConnectOptions {
|
|
88
|
+
/** The server to connect to; absent fields resolve from the environment. */
|
|
89
|
+
server?: Partial<ServerInfo>;
|
|
90
|
+
/**
|
|
91
|
+
* Finds the credentials this connection authenticates with, consulted on every
|
|
92
|
+
* (re)connect. Absent, the default resolution chain applies.
|
|
93
|
+
*/
|
|
94
|
+
credentials?: CredentialsResolver;
|
|
45
95
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* request. If omitted, a default WebSocket is created and authentication
|
|
49
|
-
* is expected to come from the session cookie.
|
|
96
|
+
* Escape hatch: fully replaces socket construction and credential resolution. When set,
|
|
97
|
+
* {@link credentials} is ignored and the factory owns the upgrade request.
|
|
50
98
|
*/
|
|
51
99
|
webSocketFactory?: WebSocketFactory;
|
|
52
100
|
/**
|
|
@@ -60,7 +108,7 @@ declare class ConnectionInfo extends ServerInfo {
|
|
|
60
108
|
* Defaults to {@link SessionKeepAliveMode.ACTIVITY}.
|
|
61
109
|
* Use {@link SessionKeepAliveMode.NONE} to remove the session when the websocket connection closes.
|
|
62
110
|
*/
|
|
63
|
-
sessionKeepAlive
|
|
111
|
+
sessionKeepAlive?: SessionKeepAliveMode;
|
|
64
112
|
}
|
|
65
113
|
import { Optional } from "typescript-optional";
|
|
66
114
|
import { Observable } from "rxjs";
|
|
@@ -183,11 +231,12 @@ interface IEventBus {
|
|
|
183
231
|
*/
|
|
184
232
|
serverInfo: ServerInfo | null;
|
|
185
233
|
/**
|
|
186
|
-
*
|
|
187
|
-
*
|
|
234
|
+
* Connects to a Kinotic server using fully resolved options — {@link IKinotic#connect}
|
|
235
|
+
* performs the resolution.
|
|
236
|
+
* @param options the resolved connection options
|
|
188
237
|
* @return Promise containing the result of the initial connection attempt
|
|
189
238
|
*/
|
|
190
|
-
connect(
|
|
239
|
+
connect(options: ConnectOptions): Promise<ConnectedInfo>;
|
|
191
240
|
/**
|
|
192
241
|
* Disconnects the client from the server
|
|
193
242
|
* This will clear any subscriptions and close the connection
|
|
@@ -253,7 +302,7 @@ declare enum EventConstants {
|
|
|
253
302
|
CONTENT_LENGTH_HEADER = "content-length",
|
|
254
303
|
REPLY_TO_HEADER = "reply-to",
|
|
255
304
|
/**
|
|
256
|
-
* Header provided by the server on connection to provide the {@link
|
|
305
|
+
* Header provided by the server on connection to provide the {@link ConnectedInfo} as a JSON string
|
|
257
306
|
*/
|
|
258
307
|
CONNECTED_INFO_HEADER = "connected-info",
|
|
259
308
|
/**
|
|
@@ -613,11 +662,12 @@ interface IKinotic {
|
|
|
613
662
|
*/
|
|
614
663
|
defaultZone: string | null;
|
|
615
664
|
/**
|
|
616
|
-
*
|
|
617
|
-
*
|
|
665
|
+
* Connects to a Kinotic server. Every option is optional: absent server fields and
|
|
666
|
+
* credentials resolve from the environment — see {@link ConnectOptions}.
|
|
667
|
+
* @param options overrides for the resolved connection, or nothing to resolve everything
|
|
618
668
|
* @return Promise containing the result of the initial connection attempt
|
|
619
669
|
*/
|
|
620
|
-
connect(
|
|
670
|
+
connect(options?: ConnectOptions): Promise<ConnectedInfo>;
|
|
621
671
|
/**
|
|
622
672
|
* Disconnects the client from the server
|
|
623
673
|
* This will clear any subscriptions and close the connection
|
|
@@ -655,11 +705,12 @@ declare class KinoticSingleton implements IKinotic {
|
|
|
655
705
|
get eventBus(): IEventBus;
|
|
656
706
|
set eventBus(eventBus: IEventBus);
|
|
657
707
|
/**
|
|
658
|
-
*
|
|
659
|
-
*
|
|
708
|
+
* Connects to a Kinotic server. Every option is optional: absent server fields and
|
|
709
|
+
* credentials resolve from the environment — see {@link ConnectOptions}.
|
|
710
|
+
* @param options overrides for the resolved connection, or nothing to resolve everything
|
|
660
711
|
* @return Promise containing the result of the initial connection attempt
|
|
661
712
|
*/
|
|
662
|
-
connect(
|
|
713
|
+
connect(options?: ConnectOptions): Promise<ConnectedInfo>;
|
|
663
714
|
/**
|
|
664
715
|
* Disconnects the client from the server
|
|
665
716
|
* This will clear any subscriptions and close the connection
|
|
@@ -1174,7 +1225,7 @@ declare class EventBus implements IEventBus {
|
|
|
1174
1225
|
get fatalErrors(): Observable3<Error>;
|
|
1175
1226
|
isConnectionActive(): boolean;
|
|
1176
1227
|
isConnected(): boolean;
|
|
1177
|
-
connect(
|
|
1228
|
+
connect(options: ConnectOptions): Promise<ConnectedInfo>;
|
|
1178
1229
|
disconnect(force?: boolean): Promise<void>;
|
|
1179
1230
|
/** Runs connect and disconnect one at a time so they never overlap on the shared socket. */
|
|
1180
1231
|
private serializeLifecycle;
|
|
@@ -1209,50 +1260,58 @@ declare class EventBus implements IEventBus {
|
|
|
1209
1260
|
private _observe;
|
|
1210
1261
|
}
|
|
1211
1262
|
/**
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1263
|
+
* Kinotic client credentials: a clientId/clientSecret pair presented as upgrade headers —
|
|
1264
|
+
* a user's email and password, or a machine identity's id and provisioned secret. Scope is
|
|
1265
|
+
* structural, determined by which ids are given: neither → SYSTEM, organizationId only →
|
|
1266
|
+
* ORGANIZATION, both → APPLICATION. For machines the ids are optional; when supplied they
|
|
1267
|
+
* must agree with the machine's own scope.
|
|
1215
1268
|
*/
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
getAuthHeaders(): Promise<Record<string, string>> | Record<string, string>;
|
|
1269
|
+
declare class BasicCredentialsResolver implements CredentialsResolver {
|
|
1270
|
+
readonly name: string;
|
|
1271
|
+
private readonly credentials;
|
|
1272
|
+
constructor(clientId: string, clientSecret: string, organizationId?: string, applicationId?: string);
|
|
1273
|
+
resolve(_server: ServerInfo): Promise<ResolvedCredentials>;
|
|
1222
1274
|
}
|
|
1223
1275
|
/**
|
|
1224
|
-
*
|
|
1225
|
-
*
|
|
1226
|
-
* The provider is consulted on every (re)connect, so short-lived credentials are
|
|
1227
|
-
* refreshed each time. Supply the result as {@link ConnectionInfo#webSocketFactory}.
|
|
1228
|
-
*
|
|
1229
|
-
* For Node/Bun callers: the returned factory creates the socket with the runtime
|
|
1230
|
-
* WebSocket's `headers` option, which the DOM `WebSocket` typings omit and the
|
|
1231
|
-
* browser WebSocket does not support. Browser callers continue to omit
|
|
1232
|
-
* `webSocketFactory` and authenticate via the session cookie from a prior REST login.
|
|
1276
|
+
* A bearer token presented as the {@code Authorization} upgrade header. The supplier form is
|
|
1277
|
+
* invoked on every (re)connect, so short-lived tokens can be refreshed each time.
|
|
1233
1278
|
*/
|
|
1234
|
-
declare
|
|
1279
|
+
declare class BearerCredentialsResolver implements CredentialsResolver {
|
|
1280
|
+
readonly name: string;
|
|
1281
|
+
private readonly token;
|
|
1282
|
+
constructor(token: string | (() => Promise<string> | string));
|
|
1283
|
+
resolve(_server: ServerInfo): Promise<ResolvedCredentials>;
|
|
1284
|
+
}
|
|
1235
1285
|
/**
|
|
1236
|
-
*
|
|
1237
|
-
*
|
|
1286
|
+
* Consults each resolver in order and returns the first non-null result. The default
|
|
1287
|
+
* credential resolution every {@code Kinotic.connect()} without explicit credentials uses is
|
|
1288
|
+
* a chain; supply your own to control the sources or their order.
|
|
1238
1289
|
*/
|
|
1239
|
-
declare class
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1290
|
+
declare class ChainedCredentialsResolver implements CredentialsResolver {
|
|
1291
|
+
readonly name: string;
|
|
1292
|
+
private readonly resolvers;
|
|
1293
|
+
constructor(...resolvers: CredentialsResolver[]);
|
|
1294
|
+
resolve(server: ServerInfo): Promise<ResolvedCredentials | null>;
|
|
1243
1295
|
}
|
|
1244
1296
|
/**
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1249
|
-
*
|
|
1250
|
-
* access token). The supplier may be async and is invoked on every (re)connect.
|
|
1297
|
+
* Credentials from environment variables — the zero-code path for machines and services:
|
|
1298
|
+
* {@code KINOTIC_CLIENT_ID} + {@code KINOTIC_CLIENT_SECRET} (with optional
|
|
1299
|
+
* {@code KINOTIC_ORGANIZATION_ID} / {@code KINOTIC_APPLICATION_ID}) resolve as client
|
|
1300
|
+
* credentials, or {@code KINOTIC_TOKEN} as a bearer token. Resolves to null in a browser or
|
|
1301
|
+
* when none of the variables are set.
|
|
1251
1302
|
*/
|
|
1252
|
-
declare class
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1303
|
+
declare class EnvCredentialsResolver implements CredentialsResolver {
|
|
1304
|
+
readonly name: string;
|
|
1305
|
+
resolve(server: ServerInfo): Promise<ResolvedCredentials | null>;
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* The browser's session cookie, established by a prior REST login. Resolves to credentials
|
|
1309
|
+
* with no headers — the cookie rides the upgrade request on its own — and only in an
|
|
1310
|
+
* environment that has one (a browser); elsewhere it passes to the next resolver.
|
|
1311
|
+
*/
|
|
1312
|
+
declare class SessionCredentialsResolver implements CredentialsResolver {
|
|
1313
|
+
readonly name: string;
|
|
1314
|
+
resolve(_server: ServerInfo): Promise<ResolvedCredentials | null>;
|
|
1256
1315
|
}
|
|
1257
1316
|
/**
|
|
1258
1317
|
* Some common constants used for the {@link Participant} and {@link Participant#getMetadata()}
|
|
@@ -1268,4 +1327,4 @@ declare class ParticipantConstants {
|
|
|
1268
1327
|
/** The clientId TestSecurityService (clienttest profile) maps to the ANONYMOUS role in core package tests. */
|
|
1269
1328
|
static readonly CLI_PARTICIPANT_ID: string;
|
|
1270
1329
|
}
|
|
1271
|
-
export { validateZone, validateLabel, receivesContext, isAdvertised, createCRI,
|
|
1330
|
+
export { validateZone, validateLabel, receivesContext, isAdvertised, createCRI, buildServerUrl, buildBrokerUrl, Zone, WebSocketFactory, Version, TextEventFactory, Sort, SessionKeepAliveMode, SessionCredentialsResolver, ServiceRegistry, ServiceContext, ServerInfo, Scope, ResolvedCredentials, Publish, ParticipantConstants, Participant, Pageable, Page, Order, OffsetPageable, NullHandling, KinoticSingleton, KinoticPlugin, Kinotic, JsonEventFactory, IterablePage, Identifiable, IWebSocket, IServiceRegistry, IServiceProxy, IParticipant, IKinotic, IEventFactory, IEventBus, IEvent, IEditableDataSource, IDataSource, ICrudServiceProxyFactory, ICrudServiceProxy, FunctionalIterablePage, EventConstants, EventBus, Event, EnvCredentialsResolver, Direction, DefaultCRI, DataSourceUtils, CursorPageable, CrudServiceProxyFactory, CrudServiceProxy, CredentialsResolver, ContextInterceptor, Context, ConnectedInfo, ConnectOptions, ChainedCredentialsResolver, CRI, BearerCredentialsResolver, BasicCredentialsResolver, AbstractIterablePage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* The outcome of credential resolution: the headers to present on the WebSocket upgrade and
|
|
3
|
+
* the scope the caller belongs to. {@link authHeaders} undefined means the connection
|
|
4
|
+
* authenticates with the browser session cookie instead of headers.
|
|
5
|
+
*/
|
|
6
|
+
interface ResolvedCredentials {
|
|
7
|
+
authHeaders?: Record<string, string>;
|
|
8
|
+
organizationId?: string;
|
|
9
|
+
applicationId?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Finds the credentials a Kinotic connection authenticates with. Consulted on every
|
|
13
|
+
* (re)connect, so an implementation backing short-lived credentials can refresh them each
|
|
14
|
+
* time; one whose resolution is expensive — a network round-trip, a disk read — must cache
|
|
15
|
+
* the result internally and refresh only as expiry nears, since reconnects pay the cost of
|
|
16
|
+
* every resolve. Returning null means this resolver found nothing — in a
|
|
17
|
+
* {@link ChainedCredentialsResolver} the next resolver tries; at the top level the connect
|
|
18
|
+
* fails naming every resolver consulted.
|
|
19
|
+
*/
|
|
20
|
+
interface CredentialsResolver {
|
|
21
|
+
/** Short name shown in the connect failure that lists the resolvers consulted. */
|
|
22
|
+
readonly name: string;
|
|
23
|
+
/**
|
|
24
|
+
* Resolves credentials for a connection to the given server, or null when this resolver
|
|
25
|
+
* has none to offer.
|
|
26
|
+
*/
|
|
27
|
+
resolve(server: ServerInfo): Promise<ResolvedCredentials | null>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
2
30
|
* Structural shape of a WebSocket used by the underlying STOMP client.
|
|
3
31
|
* Copied from the WebSocket interface to avoid pulling in the DOM typelib,
|
|
4
32
|
* so this type stays usable in Node environments where `lib: dom` is not set.
|
|
@@ -28,25 +56,45 @@ declare class ServerInfo {
|
|
|
28
56
|
port?: number | null;
|
|
29
57
|
useSSL?: boolean | null;
|
|
30
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Builds the base URL of a server for the given scheme stem ({@code 'ws'} or {@code 'http'}):
|
|
61
|
+
* TLS appends {@code s}, and the port is omitted when absent so the scheme default applies.
|
|
62
|
+
*/
|
|
63
|
+
declare function buildServerUrl(server: ServerInfo, scheme: "ws" | "http"): string;
|
|
64
|
+
/**
|
|
65
|
+
* Builds the WebSocket broker URL the STOMP client connects to for a given server — the
|
|
66
|
+
* single source of truth for the broker path, so a caller supplying its own
|
|
67
|
+
* {@link WebSocketFactory} never re-types it and drifts from core.
|
|
68
|
+
*/
|
|
69
|
+
declare function buildBrokerUrl(server: ServerInfo): string;
|
|
31
70
|
declare enum SessionKeepAliveMode {
|
|
32
71
|
NONE = "NONE",
|
|
33
72
|
ACTIVITY = "ACTIVITY",
|
|
34
73
|
CONNECTION = "CONNECTION"
|
|
35
74
|
}
|
|
36
75
|
/**
|
|
37
|
-
*
|
|
76
|
+
* Options for {@link IKinotic#connect}. Every field is optional: absent {@link server}
|
|
77
|
+
* fields resolve from the environment (the {@code KINOTIC_SERVER_HOST} /
|
|
78
|
+
* {@code KINOTIC_SERVER_PORT} / {@code KINOTIC_SERVER_USE_SSL} variables, the browser's own
|
|
79
|
+
* location, then {@code https://api.kinotic.com}), and absent {@link credentials} resolve
|
|
80
|
+
* through the default {@link ChainedCredentialsResolver} (environment variables, then the
|
|
81
|
+
* browser session).
|
|
38
82
|
*
|
|
39
|
-
* Authentication is performed during the WebSocket upgrade (handshake), not in
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* {@link WebSocketFactory} that attaches the required upgrade headers.
|
|
83
|
+
* Authentication is performed during the WebSocket upgrade (handshake), not in the STOMP
|
|
84
|
+
* CONNECT frame: the resolved credentials supply the upgrade headers, or none for
|
|
85
|
+
* session-cookie auth.
|
|
43
86
|
*/
|
|
44
|
-
|
|
87
|
+
interface ConnectOptions {
|
|
88
|
+
/** The server to connect to; absent fields resolve from the environment. */
|
|
89
|
+
server?: Partial<ServerInfo>;
|
|
90
|
+
/**
|
|
91
|
+
* Finds the credentials this connection authenticates with, consulted on every
|
|
92
|
+
* (re)connect. Absent, the default resolution chain applies.
|
|
93
|
+
*/
|
|
94
|
+
credentials?: CredentialsResolver;
|
|
45
95
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* request. If omitted, a default WebSocket is created and authentication
|
|
49
|
-
* is expected to come from the session cookie.
|
|
96
|
+
* Escape hatch: fully replaces socket construction and credential resolution. When set,
|
|
97
|
+
* {@link credentials} is ignored and the factory owns the upgrade request.
|
|
50
98
|
*/
|
|
51
99
|
webSocketFactory?: WebSocketFactory;
|
|
52
100
|
/**
|
|
@@ -60,7 +108,7 @@ declare class ConnectionInfo extends ServerInfo {
|
|
|
60
108
|
* Defaults to {@link SessionKeepAliveMode.ACTIVITY}.
|
|
61
109
|
* Use {@link SessionKeepAliveMode.NONE} to remove the session when the websocket connection closes.
|
|
62
110
|
*/
|
|
63
|
-
sessionKeepAlive
|
|
111
|
+
sessionKeepAlive?: SessionKeepAliveMode;
|
|
64
112
|
}
|
|
65
113
|
import { Optional } from "typescript-optional";
|
|
66
114
|
import { Observable } from "rxjs";
|
|
@@ -183,11 +231,12 @@ interface IEventBus {
|
|
|
183
231
|
*/
|
|
184
232
|
serverInfo: ServerInfo | null;
|
|
185
233
|
/**
|
|
186
|
-
*
|
|
187
|
-
*
|
|
234
|
+
* Connects to a Kinotic server using fully resolved options — {@link IKinotic#connect}
|
|
235
|
+
* performs the resolution.
|
|
236
|
+
* @param options the resolved connection options
|
|
188
237
|
* @return Promise containing the result of the initial connection attempt
|
|
189
238
|
*/
|
|
190
|
-
connect(
|
|
239
|
+
connect(options: ConnectOptions): Promise<ConnectedInfo>;
|
|
191
240
|
/**
|
|
192
241
|
* Disconnects the client from the server
|
|
193
242
|
* This will clear any subscriptions and close the connection
|
|
@@ -253,7 +302,7 @@ declare enum EventConstants {
|
|
|
253
302
|
CONTENT_LENGTH_HEADER = "content-length",
|
|
254
303
|
REPLY_TO_HEADER = "reply-to",
|
|
255
304
|
/**
|
|
256
|
-
* Header provided by the server on connection to provide the {@link
|
|
305
|
+
* Header provided by the server on connection to provide the {@link ConnectedInfo} as a JSON string
|
|
257
306
|
*/
|
|
258
307
|
CONNECTED_INFO_HEADER = "connected-info",
|
|
259
308
|
/**
|
|
@@ -613,11 +662,12 @@ interface IKinotic {
|
|
|
613
662
|
*/
|
|
614
663
|
defaultZone: string | null;
|
|
615
664
|
/**
|
|
616
|
-
*
|
|
617
|
-
*
|
|
665
|
+
* Connects to a Kinotic server. Every option is optional: absent server fields and
|
|
666
|
+
* credentials resolve from the environment — see {@link ConnectOptions}.
|
|
667
|
+
* @param options overrides for the resolved connection, or nothing to resolve everything
|
|
618
668
|
* @return Promise containing the result of the initial connection attempt
|
|
619
669
|
*/
|
|
620
|
-
connect(
|
|
670
|
+
connect(options?: ConnectOptions): Promise<ConnectedInfo>;
|
|
621
671
|
/**
|
|
622
672
|
* Disconnects the client from the server
|
|
623
673
|
* This will clear any subscriptions and close the connection
|
|
@@ -655,11 +705,12 @@ declare class KinoticSingleton implements IKinotic {
|
|
|
655
705
|
get eventBus(): IEventBus;
|
|
656
706
|
set eventBus(eventBus: IEventBus);
|
|
657
707
|
/**
|
|
658
|
-
*
|
|
659
|
-
*
|
|
708
|
+
* Connects to a Kinotic server. Every option is optional: absent server fields and
|
|
709
|
+
* credentials resolve from the environment — see {@link ConnectOptions}.
|
|
710
|
+
* @param options overrides for the resolved connection, or nothing to resolve everything
|
|
660
711
|
* @return Promise containing the result of the initial connection attempt
|
|
661
712
|
*/
|
|
662
|
-
connect(
|
|
713
|
+
connect(options?: ConnectOptions): Promise<ConnectedInfo>;
|
|
663
714
|
/**
|
|
664
715
|
* Disconnects the client from the server
|
|
665
716
|
* This will clear any subscriptions and close the connection
|
|
@@ -1174,7 +1225,7 @@ declare class EventBus implements IEventBus {
|
|
|
1174
1225
|
get fatalErrors(): Observable3<Error>;
|
|
1175
1226
|
isConnectionActive(): boolean;
|
|
1176
1227
|
isConnected(): boolean;
|
|
1177
|
-
connect(
|
|
1228
|
+
connect(options: ConnectOptions): Promise<ConnectedInfo>;
|
|
1178
1229
|
disconnect(force?: boolean): Promise<void>;
|
|
1179
1230
|
/** Runs connect and disconnect one at a time so they never overlap on the shared socket. */
|
|
1180
1231
|
private serializeLifecycle;
|
|
@@ -1209,50 +1260,58 @@ declare class EventBus implements IEventBus {
|
|
|
1209
1260
|
private _observe;
|
|
1210
1261
|
}
|
|
1211
1262
|
/**
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1214
|
-
*
|
|
1263
|
+
* Kinotic client credentials: a clientId/clientSecret pair presented as upgrade headers —
|
|
1264
|
+
* a user's email and password, or a machine identity's id and provisioned secret. Scope is
|
|
1265
|
+
* structural, determined by which ids are given: neither → SYSTEM, organizationId only →
|
|
1266
|
+
* ORGANIZATION, both → APPLICATION. For machines the ids are optional; when supplied they
|
|
1267
|
+
* must agree with the machine's own scope.
|
|
1215
1268
|
*/
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
getAuthHeaders(): Promise<Record<string, string>> | Record<string, string>;
|
|
1269
|
+
declare class BasicCredentialsResolver implements CredentialsResolver {
|
|
1270
|
+
readonly name: string;
|
|
1271
|
+
private readonly credentials;
|
|
1272
|
+
constructor(clientId: string, clientSecret: string, organizationId?: string, applicationId?: string);
|
|
1273
|
+
resolve(_server: ServerInfo): Promise<ResolvedCredentials>;
|
|
1222
1274
|
}
|
|
1223
1275
|
/**
|
|
1224
|
-
*
|
|
1225
|
-
*
|
|
1226
|
-
* The provider is consulted on every (re)connect, so short-lived credentials are
|
|
1227
|
-
* refreshed each time. Supply the result as {@link ConnectionInfo#webSocketFactory}.
|
|
1228
|
-
*
|
|
1229
|
-
* For Node/Bun callers: the returned factory creates the socket with the runtime
|
|
1230
|
-
* WebSocket's `headers` option, which the DOM `WebSocket` typings omit and the
|
|
1231
|
-
* browser WebSocket does not support. Browser callers continue to omit
|
|
1232
|
-
* `webSocketFactory` and authenticate via the session cookie from a prior REST login.
|
|
1276
|
+
* A bearer token presented as the {@code Authorization} upgrade header. The supplier form is
|
|
1277
|
+
* invoked on every (re)connect, so short-lived tokens can be refreshed each time.
|
|
1233
1278
|
*/
|
|
1234
|
-
declare
|
|
1279
|
+
declare class BearerCredentialsResolver implements CredentialsResolver {
|
|
1280
|
+
readonly name: string;
|
|
1281
|
+
private readonly token;
|
|
1282
|
+
constructor(token: string | (() => Promise<string> | string));
|
|
1283
|
+
resolve(_server: ServerInfo): Promise<ResolvedCredentials>;
|
|
1284
|
+
}
|
|
1235
1285
|
/**
|
|
1236
|
-
*
|
|
1237
|
-
*
|
|
1286
|
+
* Consults each resolver in order and returns the first non-null result. The default
|
|
1287
|
+
* credential resolution every {@code Kinotic.connect()} without explicit credentials uses is
|
|
1288
|
+
* a chain; supply your own to control the sources or their order.
|
|
1238
1289
|
*/
|
|
1239
|
-
declare class
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1290
|
+
declare class ChainedCredentialsResolver implements CredentialsResolver {
|
|
1291
|
+
readonly name: string;
|
|
1292
|
+
private readonly resolvers;
|
|
1293
|
+
constructor(...resolvers: CredentialsResolver[]);
|
|
1294
|
+
resolve(server: ServerInfo): Promise<ResolvedCredentials | null>;
|
|
1243
1295
|
}
|
|
1244
1296
|
/**
|
|
1245
|
-
*
|
|
1246
|
-
*
|
|
1247
|
-
*
|
|
1248
|
-
*
|
|
1249
|
-
*
|
|
1250
|
-
* access token). The supplier may be async and is invoked on every (re)connect.
|
|
1297
|
+
* Credentials from environment variables — the zero-code path for machines and services:
|
|
1298
|
+
* {@code KINOTIC_CLIENT_ID} + {@code KINOTIC_CLIENT_SECRET} (with optional
|
|
1299
|
+
* {@code KINOTIC_ORGANIZATION_ID} / {@code KINOTIC_APPLICATION_ID}) resolve as client
|
|
1300
|
+
* credentials, or {@code KINOTIC_TOKEN} as a bearer token. Resolves to null in a browser or
|
|
1301
|
+
* when none of the variables are set.
|
|
1251
1302
|
*/
|
|
1252
|
-
declare class
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1303
|
+
declare class EnvCredentialsResolver implements CredentialsResolver {
|
|
1304
|
+
readonly name: string;
|
|
1305
|
+
resolve(server: ServerInfo): Promise<ResolvedCredentials | null>;
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* The browser's session cookie, established by a prior REST login. Resolves to credentials
|
|
1309
|
+
* with no headers — the cookie rides the upgrade request on its own — and only in an
|
|
1310
|
+
* environment that has one (a browser); elsewhere it passes to the next resolver.
|
|
1311
|
+
*/
|
|
1312
|
+
declare class SessionCredentialsResolver implements CredentialsResolver {
|
|
1313
|
+
readonly name: string;
|
|
1314
|
+
resolve(_server: ServerInfo): Promise<ResolvedCredentials | null>;
|
|
1256
1315
|
}
|
|
1257
1316
|
/**
|
|
1258
1317
|
* Some common constants used for the {@link Participant} and {@link Participant#getMetadata()}
|
|
@@ -1268,4 +1327,4 @@ declare class ParticipantConstants {
|
|
|
1268
1327
|
/** The clientId TestSecurityService (clienttest profile) maps to the ANONYMOUS role in core package tests. */
|
|
1269
1328
|
static readonly CLI_PARTICIPANT_ID: string;
|
|
1270
1329
|
}
|
|
1271
|
-
export { validateZone, validateLabel, receivesContext, isAdvertised, createCRI,
|
|
1330
|
+
export { validateZone, validateLabel, receivesContext, isAdvertised, createCRI, buildServerUrl, buildBrokerUrl, Zone, WebSocketFactory, Version, TextEventFactory, Sort, SessionKeepAliveMode, SessionCredentialsResolver, ServiceRegistry, ServiceContext, ServerInfo, Scope, ResolvedCredentials, Publish, ParticipantConstants, Participant, Pageable, Page, Order, OffsetPageable, NullHandling, KinoticSingleton, KinoticPlugin, Kinotic, JsonEventFactory, IterablePage, Identifiable, IWebSocket, IServiceRegistry, IServiceProxy, IParticipant, IKinotic, IEventFactory, IEventBus, IEvent, IEditableDataSource, IDataSource, ICrudServiceProxyFactory, ICrudServiceProxy, FunctionalIterablePage, EventConstants, EventBus, Event, EnvCredentialsResolver, Direction, DefaultCRI, DataSourceUtils, CursorPageable, CrudServiceProxyFactory, CrudServiceProxy, CredentialsResolver, ContextInterceptor, Context, ConnectedInfo, ConnectOptions, ChainedCredentialsResolver, CRI, BearerCredentialsResolver, BasicCredentialsResolver, AbstractIterablePage };
|