@kinotic-ai/core 1.4.1 → 1.6.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
@@ -74,7 +74,6 @@ __export(exports_src, {
74
74
  Scope: () => Scope,
75
75
  Publish: () => Publish,
76
76
  ParticipantConstants: () => ParticipantConstants,
77
- Participant: () => Participant,
78
77
  Pageable: () => Pageable,
79
78
  Order: () => Order,
80
79
  OffsetPageable: () => OffsetPageable,
@@ -152,6 +151,7 @@ var import_stompjs = require("@stomp/stompjs");
152
151
  var import_debug = __toESM(require("debug"));
153
152
  var import_rxjs = require("rxjs");
154
153
  var import_uuid = require("uuid");
154
+ var SESSION_CHECK_PATH = "/api/me";
155
155
 
156
156
  class StompConnectionManager {
157
157
  lastWebsocketError = null;
@@ -216,6 +216,16 @@ class StompConnectionManager {
216
216
  reconnectTimeMode: import_stompjs.ReconnectionTimeMode.EXPONENTIAL,
217
217
  webSocketFactory: userWebSocketFactory ? () => preparedSocket : undefined,
218
218
  beforeConnect: async () => {
219
+ if (!userWebSocketFactory) {
220
+ const sessionCheckUrl = "http" + (connectionInfo.useSSL ? "s" : "") + "://" + connectionInfo.host + (connectionInfo.port ? ":" + connectionInfo.port : "") + SESSION_CHECK_PATH;
221
+ try {
222
+ const res = await fetch(sessionCheckUrl, { credentials: "include" });
223
+ if (res.status === 401) {
224
+ await this.signalFatal(new Error("Authentication required"));
225
+ return;
226
+ }
227
+ } catch {}
228
+ }
219
229
  if (connectionInfo?.maxConnectionAttempts) {
220
230
  this.connectionAttempts++;
221
231
  if (this.connectionAttempts > connectionInfo.maxConnectionAttempts) {
@@ -983,7 +993,7 @@ var import_operators2 = require("rxjs/operators");
983
993
  // packages/core/package.json
984
994
  var package_default = {
985
995
  name: "@kinotic-ai/core",
986
- version: "1.4.1",
996
+ version: "1.6.0",
987
997
  type: "module",
988
998
  files: [
989
999
  "dist"
@@ -1466,23 +1476,6 @@ class ConnectedInfo {
1466
1476
  replyToId;
1467
1477
  participant;
1468
1478
  }
1469
- // packages/core/src/api/security/Participant.ts
1470
- class Participant {
1471
- id;
1472
- tenantId;
1473
- authScopeType;
1474
- authScopeId;
1475
- metadata;
1476
- roles;
1477
- constructor(id, tenantId, authScopeType, authScopeId, metadata, roles) {
1478
- this.id = id;
1479
- this.tenantId = tenantId;
1480
- this.authScopeType = authScopeType;
1481
- this.authScopeId = authScopeId;
1482
- this.metadata = metadata || new Map;
1483
- this.roles = roles || [];
1484
- }
1485
- }
1486
1479
  // packages/core/src/api/security/ParticipantConstants.ts
1487
1480
  class ParticipantConstants {
1488
1481
  static PARTICIPANT_TYPE_METADATA_KEY = "type";
package/dist/index.d.cts CHANGED
@@ -72,59 +72,37 @@ interface Identifiable<T> {
72
72
  id: T | null;
73
73
  }
74
74
  /**
75
+ * Identifying information about a logged-in participant on the RPC layer.
76
+ *
77
+ * This is the base shape every participant shares, regardless of scope, and is what RPC-only
78
+ * consumers work with directly. The Kinotic OS contract layers scope-typed participants on top
79
+ * of it — see the participant types in {@code @kinotic-ai/os-api}.
80
+ *
81
+ * Mirrors the server {@code org.kinotic.core.api.security.Participant}.
82
+ *
75
83
  * Created by Navíd Mitchell 🤪on 6/16/23.
76
84
  */
77
85
  interface IParticipant extends Identifiable<string> {
78
86
  /**
79
- * The identity of the participant
80
- *
81
- * @return the identity of the participant
87
+ * The identity of the participant.
82
88
  */
83
89
  id: string;
84
90
  /**
85
- * The tenant that the participant belongs to
86
- *
87
- * @return the tenant or null if not using multi-tenancy
91
+ * Key/value pairs carrying additional information about the participant.
88
92
  */
89
- tenantId?: string | null;
93
+ metadata: Record<string, string>;
90
94
  /**
91
- * The scope layer this participant authenticated against.
92
- * Well-known values are "SYSTEM", "ORGANIZATION", and "APPLICATION",
93
- * but custom values are allowed for extensibility.
94
- */
95
- authScopeType?: string | null;
96
- /**
97
- * The identifier of the specific scope this participant belongs to.
98
- * For example, "kinotic" for system scope, an organization ID, or an application ID.
99
- * Together with {@link authScopeType}, uniquely identifies which user pool
100
- * this participant was authenticated from.
101
- */
102
- authScopeId?: string | null;
103
- /**
104
- * Metadata is a map of key value pairs that can be used to store additional information about a participant
105
- *
106
- * @return a map of key value pairs
107
- */
108
- metadata: Map<string, string>;
109
- /**
110
- * Roles are a list of strings that can be used to authorize a participant to perform certain actions
111
- *
112
- * @return a list of roles
95
+ * Roles used to authorize the participant to perform actions.
113
96
  */
114
97
  roles: string[];
115
98
  }
116
99
  /**
100
+ * A logged-in participant on the RPC layer. Alias of {@link IParticipant}; the Kinotic OS contract
101
+ * ({@code @kinotic-ai/os-api}) narrows this to scope-typed participants.
102
+ *
117
103
  * Created by Navid Mitchell on 6/2/20
118
104
  */
119
- declare class Participant implements IParticipant {
120
- id: string;
121
- tenantId?: string | null;
122
- authScopeType?: string | null;
123
- authScopeId?: string | null;
124
- metadata: Map<string, string>;
125
- roles: string[];
126
- constructor(id: string, tenantId?: string, authScopeType?: string, authScopeId?: string, metadata?: Map<string, string>, roles?: string[]);
127
- }
105
+ type Participant = IParticipant;
128
106
  /**
129
107
  * Contains information about the connection that was established
130
108
  */
package/dist/index.d.ts CHANGED
@@ -72,59 +72,37 @@ interface Identifiable<T> {
72
72
  id: T | null;
73
73
  }
74
74
  /**
75
+ * Identifying information about a logged-in participant on the RPC layer.
76
+ *
77
+ * This is the base shape every participant shares, regardless of scope, and is what RPC-only
78
+ * consumers work with directly. The Kinotic OS contract layers scope-typed participants on top
79
+ * of it — see the participant types in {@code @kinotic-ai/os-api}.
80
+ *
81
+ * Mirrors the server {@code org.kinotic.core.api.security.Participant}.
82
+ *
75
83
  * Created by Navíd Mitchell 🤪on 6/16/23.
76
84
  */
77
85
  interface IParticipant extends Identifiable<string> {
78
86
  /**
79
- * The identity of the participant
80
- *
81
- * @return the identity of the participant
87
+ * The identity of the participant.
82
88
  */
83
89
  id: string;
84
90
  /**
85
- * The tenant that the participant belongs to
86
- *
87
- * @return the tenant or null if not using multi-tenancy
91
+ * Key/value pairs carrying additional information about the participant.
88
92
  */
89
- tenantId?: string | null;
93
+ metadata: Record<string, string>;
90
94
  /**
91
- * The scope layer this participant authenticated against.
92
- * Well-known values are "SYSTEM", "ORGANIZATION", and "APPLICATION",
93
- * but custom values are allowed for extensibility.
94
- */
95
- authScopeType?: string | null;
96
- /**
97
- * The identifier of the specific scope this participant belongs to.
98
- * For example, "kinotic" for system scope, an organization ID, or an application ID.
99
- * Together with {@link authScopeType}, uniquely identifies which user pool
100
- * this participant was authenticated from.
101
- */
102
- authScopeId?: string | null;
103
- /**
104
- * Metadata is a map of key value pairs that can be used to store additional information about a participant
105
- *
106
- * @return a map of key value pairs
107
- */
108
- metadata: Map<string, string>;
109
- /**
110
- * Roles are a list of strings that can be used to authorize a participant to perform certain actions
111
- *
112
- * @return a list of roles
95
+ * Roles used to authorize the participant to perform actions.
113
96
  */
114
97
  roles: string[];
115
98
  }
116
99
  /**
100
+ * A logged-in participant on the RPC layer. Alias of {@link IParticipant}; the Kinotic OS contract
101
+ * ({@code @kinotic-ai/os-api}) narrows this to scope-typed participants.
102
+ *
117
103
  * Created by Navid Mitchell on 6/2/20
118
104
  */
119
- declare class Participant implements IParticipant {
120
- id: string;
121
- tenantId?: string | null;
122
- authScopeType?: string | null;
123
- authScopeId?: string | null;
124
- metadata: Map<string, string>;
125
- roles: string[];
126
- constructor(id: string, tenantId?: string, authScopeType?: string, authScopeId?: string, metadata?: Map<string, string>, roles?: string[]);
127
- }
105
+ type Participant = IParticipant;
128
106
  /**
129
107
  * Contains information about the connection that was established
130
108
  */
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.6.0",
891
902
  type: "module",
892
903
  files: [
893
904
  "dist"
@@ -1370,23 +1381,6 @@ class ConnectedInfo {
1370
1381
  replyToId;
1371
1382
  participant;
1372
1383
  }
1373
- // packages/core/src/api/security/Participant.ts
1374
- class Participant {
1375
- id;
1376
- tenantId;
1377
- authScopeType;
1378
- authScopeId;
1379
- metadata;
1380
- roles;
1381
- constructor(id, tenantId, authScopeType, authScopeId, metadata, roles) {
1382
- this.id = id;
1383
- this.tenantId = tenantId;
1384
- this.authScopeType = authScopeType;
1385
- this.authScopeId = authScopeId;
1386
- this.metadata = metadata || new Map;
1387
- this.roles = roles || [];
1388
- }
1389
- }
1390
1384
  // packages/core/src/api/security/ParticipantConstants.ts
1391
1385
  class ParticipantConstants {
1392
1386
  static PARTICIPANT_TYPE_METADATA_KEY = "type";
@@ -1407,7 +1401,6 @@ export {
1407
1401
  Scope,
1408
1402
  Publish,
1409
1403
  ParticipantConstants,
1410
- Participant,
1411
1404
  Pageable,
1412
1405
  Order,
1413
1406
  OffsetPageable,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kinotic-ai/core",
3
- "version": "1.4.1",
3
+ "version": "1.6.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"