@burtson-labs/bandit-engine 2.0.99 → 2.0.100
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/{aiProviderStore-337QNQB3.mjs → aiProviderStore-FTD277QP.mjs} +2 -2
- package/dist/chat-PMO3WTM4.mjs +16 -0
- package/dist/chat-provider.js +152 -111
- package/dist/chat-provider.js.map +1 -1
- package/dist/chat-provider.mjs +5 -5
- package/dist/{chunk-J2PMXOV2.mjs → chunk-37JLV5PU.mjs} +18 -143
- package/dist/chunk-37JLV5PU.mjs.map +1 -0
- package/dist/{chunk-H3BYFEIE.mjs → chunk-43MLINPL.mjs} +157 -7
- package/dist/chunk-43MLINPL.mjs.map +1 -0
- package/dist/{chunk-L2EKYO4F.mjs → chunk-BN3D45E2.mjs} +4 -4
- package/dist/{chunk-I7WBZVTR.mjs → chunk-GGSK5RVZ.mjs} +12 -12
- package/dist/{chunk-ZLXWNTFK.mjs → chunk-HAUDGBUS.mjs} +3 -5
- package/dist/{chunk-ZLXWNTFK.mjs.map → chunk-HAUDGBUS.mjs.map} +1 -1
- package/dist/{chunk-RUMVTVNM.mjs → chunk-KYC7CC6C.mjs} +2 -2
- package/dist/{chunk-C2SY64XM.mjs → chunk-R3HBSHLE.mjs} +92 -46
- package/dist/chunk-R3HBSHLE.mjs.map +1 -0
- package/dist/{chunk-AGT77Z3A.mjs → chunk-RN3AKXKI.mjs} +4 -4
- package/dist/{chunk-IVLVUNIB.mjs → chunk-VIKZPBVO.mjs} +5 -5
- package/dist/{chunk-OSSZ7Z2O.mjs → chunk-VTKRZNLI.mjs} +8 -6
- package/dist/{chunk-OSSZ7Z2O.mjs.map → chunk-VTKRZNLI.mjs.map} +1 -1
- package/dist/index.js +105 -35
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -12
- package/dist/index.mjs.map +1 -1
- package/dist/management/management.js +251 -181
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +8 -8
- package/dist/modals/chat-modal/chat-modal.js +161 -121
- package/dist/modals/chat-modal/chat-modal.js.map +1 -1
- package/dist/modals/chat-modal/chat-modal.mjs +4 -4
- package/package.json +1 -1
- package/dist/chat-IOBCRT5Y.mjs +0 -16
- package/dist/chunk-C2SY64XM.mjs.map +0 -1
- package/dist/chunk-H3BYFEIE.mjs.map +0 -1
- package/dist/chunk-J2PMXOV2.mjs.map +0 -1
- /package/dist/{aiProviderStore-337QNQB3.mjs.map → aiProviderStore-FTD277QP.mjs.map} +0 -0
- /package/dist/{chat-IOBCRT5Y.mjs.map → chat-PMO3WTM4.mjs.map} +0 -0
- /package/dist/{chunk-L2EKYO4F.mjs.map → chunk-BN3D45E2.mjs.map} +0 -0
- /package/dist/{chunk-I7WBZVTR.mjs.map → chunk-GGSK5RVZ.mjs.map} +0 -0
- /package/dist/{chunk-RUMVTVNM.mjs.map → chunk-KYC7CC6C.mjs.map} +0 -0
- /package/dist/{chunk-AGT77Z3A.mjs.map → chunk-RN3AKXKI.mjs.map} +0 -0
- /package/dist/{chunk-IVLVUNIB.mjs.map → chunk-VIKZPBVO.mjs.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useAIProviderStore
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-43MLINPL.mjs";
|
|
4
4
|
import "./chunk-KCI46M23.mjs";
|
|
5
5
|
import "./chunk-BJTO5JO5.mjs";
|
|
6
6
|
export {
|
|
7
7
|
useAIProviderStore
|
|
8
8
|
};
|
|
9
|
-
//# sourceMappingURL=aiProviderStore-
|
|
9
|
+
//# sourceMappingURL=aiProviderStore-FTD277QP.mjs.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
chat_default
|
|
3
|
+
} from "./chunk-R3HBSHLE.mjs";
|
|
4
|
+
import "./chunk-ONQMRE2G.mjs";
|
|
5
|
+
import "./chunk-KYC7CC6C.mjs";
|
|
6
|
+
import "./chunk-BN3D45E2.mjs";
|
|
7
|
+
import "./chunk-VIKZPBVO.mjs";
|
|
8
|
+
import "./chunk-37JLV5PU.mjs";
|
|
9
|
+
import "./chunk-LWHSOEPR.mjs";
|
|
10
|
+
import "./chunk-43MLINPL.mjs";
|
|
11
|
+
import "./chunk-KCI46M23.mjs";
|
|
12
|
+
import "./chunk-BJTO5JO5.mjs";
|
|
13
|
+
export {
|
|
14
|
+
chat_default as default
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=chat-PMO3WTM4.mjs.map
|
package/dist/chat-provider.js
CHANGED
|
@@ -45,6 +45,63 @@ var init_packageSettingsStore = __esm({
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
// src/store/authenticationStore.ts
|
|
49
|
+
var import_zustand2, TOKEN_KEY, validToken, user, rawToken, useAuthenticationStore;
|
|
50
|
+
var init_authenticationStore = __esm({
|
|
51
|
+
"src/store/authenticationStore.ts"() {
|
|
52
|
+
"use strict";
|
|
53
|
+
import_zustand2 = require("zustand");
|
|
54
|
+
TOKEN_KEY = "authToken";
|
|
55
|
+
validToken = null;
|
|
56
|
+
user = null;
|
|
57
|
+
rawToken = localStorage.getItem(TOKEN_KEY);
|
|
58
|
+
if (rawToken) {
|
|
59
|
+
try {
|
|
60
|
+
const base64Url = rawToken.split(".")[1];
|
|
61
|
+
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
62
|
+
const jsonPayload = decodeURIComponent(
|
|
63
|
+
atob(base64).split("").map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
64
|
+
);
|
|
65
|
+
const decoded = JSON.parse(jsonPayload);
|
|
66
|
+
if (decoded.exp * 1e3 > Date.now()) {
|
|
67
|
+
validToken = rawToken;
|
|
68
|
+
user = decoded;
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
validToken = null;
|
|
72
|
+
user = null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
useAuthenticationStore = (0, import_zustand2.create)((set) => ({
|
|
76
|
+
token: validToken,
|
|
77
|
+
user,
|
|
78
|
+
authError: null,
|
|
79
|
+
setToken: (token) => {
|
|
80
|
+
if (token) {
|
|
81
|
+
try {
|
|
82
|
+
const base64Url = token.split(".")[1];
|
|
83
|
+
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
84
|
+
const jsonPayload = decodeURIComponent(
|
|
85
|
+
atob(base64).split("").map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
86
|
+
);
|
|
87
|
+
const user2 = JSON.parse(jsonPayload);
|
|
88
|
+
localStorage.setItem(TOKEN_KEY, token);
|
|
89
|
+
set({ token, authError: null, user: user2 });
|
|
90
|
+
} catch {
|
|
91
|
+
set({ token: null, authError: "Invalid token", user: null });
|
|
92
|
+
}
|
|
93
|
+
} else {
|
|
94
|
+
set({ token: null, authError: null, user: null });
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
clearToken: () => {
|
|
98
|
+
localStorage.removeItem(TOKEN_KEY);
|
|
99
|
+
set({ token: null, authError: null, user: null });
|
|
100
|
+
}
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
48
105
|
// src/services/logging/debugLogger.ts
|
|
49
106
|
var DebugLogger, debugLogger;
|
|
50
107
|
var init_debugLogger = __esm({
|
|
@@ -152,6 +209,72 @@ var init_debugLogger = __esm({
|
|
|
152
209
|
}
|
|
153
210
|
});
|
|
154
211
|
|
|
212
|
+
// src/services/auth/authenticationService.ts
|
|
213
|
+
function emitAuthTokenChanged(token) {
|
|
214
|
+
if (typeof window === "undefined") {
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
window.dispatchEvent(new CustomEvent(AUTH_TOKEN_CHANGED_EVENT, {
|
|
218
|
+
detail: { token }
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
var TOKEN_KEY2, AUTH_TOKEN_CHANGED_EVENT, AuthenticationService, authenticationService;
|
|
222
|
+
var init_authenticationService = __esm({
|
|
223
|
+
"src/services/auth/authenticationService.ts"() {
|
|
224
|
+
"use strict";
|
|
225
|
+
init_authenticationStore();
|
|
226
|
+
init_debugLogger();
|
|
227
|
+
TOKEN_KEY2 = "authToken";
|
|
228
|
+
AUTH_TOKEN_CHANGED_EVENT = "bandit:auth-token-changed";
|
|
229
|
+
AuthenticationService = class {
|
|
230
|
+
getToken() {
|
|
231
|
+
const token = localStorage.getItem(TOKEN_KEY2);
|
|
232
|
+
return token;
|
|
233
|
+
}
|
|
234
|
+
setToken(token) {
|
|
235
|
+
localStorage.setItem(TOKEN_KEY2, token);
|
|
236
|
+
useAuthenticationStore.getState().setToken(token);
|
|
237
|
+
emitAuthTokenChanged(token);
|
|
238
|
+
}
|
|
239
|
+
clearToken() {
|
|
240
|
+
localStorage.removeItem(TOKEN_KEY2);
|
|
241
|
+
useAuthenticationStore.getState().clearToken();
|
|
242
|
+
emitAuthTokenChanged(null);
|
|
243
|
+
}
|
|
244
|
+
isAuthenticated() {
|
|
245
|
+
const token = useAuthenticationStore.getState().token;
|
|
246
|
+
return !!token && !this.isTokenExpired(token);
|
|
247
|
+
}
|
|
248
|
+
isTokenExpired(token) {
|
|
249
|
+
try {
|
|
250
|
+
if (!token) return true;
|
|
251
|
+
const decoded = this.parseJwtClaims(token);
|
|
252
|
+
if (!decoded) return true;
|
|
253
|
+
return decoded.exp * 1e3 < Date.now();
|
|
254
|
+
} catch {
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
parseJwtClaims(token) {
|
|
259
|
+
try {
|
|
260
|
+
const base64Url = token.split(".")[1];
|
|
261
|
+
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
262
|
+
const jsonPayload = decodeURIComponent(
|
|
263
|
+
atob(base64).split("").map((c) => {
|
|
264
|
+
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
|
|
265
|
+
}).join("")
|
|
266
|
+
);
|
|
267
|
+
return JSON.parse(jsonPayload);
|
|
268
|
+
} catch (error) {
|
|
269
|
+
debugLogger.error("Failed to parse JWT claims:", { error });
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
authenticationService = new AuthenticationService();
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
155
278
|
// src/services/indexedDB/indexedDBService.ts
|
|
156
279
|
var import_idb, isNotFoundError, IndexedDBService, indexedDBService, indexedDBService_default;
|
|
157
280
|
var init_indexedDBService = __esm({
|
|
@@ -2111,6 +2234,7 @@ var init_gateway_service = __esm({
|
|
|
2111
2234
|
import_axios = __toESM(require("axios"));
|
|
2112
2235
|
import_rxjs6 = require("rxjs");
|
|
2113
2236
|
init_debugLogger();
|
|
2237
|
+
init_authenticationService();
|
|
2114
2238
|
GatewayService = class {
|
|
2115
2239
|
constructor(_baseUrl, _tokenFactory, _feedbackEmail) {
|
|
2116
2240
|
this._baseUrl = _baseUrl;
|
|
@@ -2151,7 +2275,10 @@ var init_gateway_service = __esm({
|
|
|
2151
2275
|
});
|
|
2152
2276
|
instance.interceptors.response.use(
|
|
2153
2277
|
(response) => response,
|
|
2154
|
-
(error) =>
|
|
2278
|
+
(error) => {
|
|
2279
|
+
this._handleAuthFailure(error);
|
|
2280
|
+
return Promise.reject(this._normalizeAxiosError(error));
|
|
2281
|
+
}
|
|
2155
2282
|
);
|
|
2156
2283
|
return instance;
|
|
2157
2284
|
}
|
|
@@ -2172,6 +2299,24 @@ var init_gateway_service = __esm({
|
|
|
2172
2299
|
}
|
|
2173
2300
|
return new Error(error.message);
|
|
2174
2301
|
}
|
|
2302
|
+
_handleAuthFailure(error) {
|
|
2303
|
+
const status = error.response?.status;
|
|
2304
|
+
if (status !== 401 && status !== 403) {
|
|
2305
|
+
return;
|
|
2306
|
+
}
|
|
2307
|
+
const data = error.response?.data;
|
|
2308
|
+
const code = data?.code;
|
|
2309
|
+
if (code !== "FORCE_RELOGIN" && code !== "ACCOUNT_LOCKED") {
|
|
2310
|
+
return;
|
|
2311
|
+
}
|
|
2312
|
+
try {
|
|
2313
|
+
authenticationService.clearToken();
|
|
2314
|
+
} catch {
|
|
2315
|
+
}
|
|
2316
|
+
if (typeof window !== "undefined" && typeof window.dispatchEvent === "function") {
|
|
2317
|
+
window.dispatchEvent(new CustomEvent("auth:force-relogin", { detail: { code } }));
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2175
2320
|
_createHttpError(message, response) {
|
|
2176
2321
|
return Object.assign(new Error(message), { response });
|
|
2177
2322
|
}
|
|
@@ -4389,116 +4534,7 @@ __export(chat_provider_exports, {
|
|
|
4389
4534
|
module.exports = __toCommonJS(chat_provider_exports);
|
|
4390
4535
|
var import_react6 = require("react");
|
|
4391
4536
|
init_packageSettingsStore();
|
|
4392
|
-
|
|
4393
|
-
// src/store/authenticationStore.ts
|
|
4394
|
-
var import_zustand2 = require("zustand");
|
|
4395
|
-
var TOKEN_KEY = "authToken";
|
|
4396
|
-
var validToken = null;
|
|
4397
|
-
var user = null;
|
|
4398
|
-
var rawToken = localStorage.getItem(TOKEN_KEY);
|
|
4399
|
-
if (rawToken) {
|
|
4400
|
-
try {
|
|
4401
|
-
const base64Url = rawToken.split(".")[1];
|
|
4402
|
-
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
4403
|
-
const jsonPayload = decodeURIComponent(
|
|
4404
|
-
atob(base64).split("").map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
4405
|
-
);
|
|
4406
|
-
const decoded = JSON.parse(jsonPayload);
|
|
4407
|
-
if (decoded.exp * 1e3 > Date.now()) {
|
|
4408
|
-
validToken = rawToken;
|
|
4409
|
-
user = decoded;
|
|
4410
|
-
}
|
|
4411
|
-
} catch {
|
|
4412
|
-
validToken = null;
|
|
4413
|
-
user = null;
|
|
4414
|
-
}
|
|
4415
|
-
}
|
|
4416
|
-
var useAuthenticationStore = (0, import_zustand2.create)((set) => ({
|
|
4417
|
-
token: validToken,
|
|
4418
|
-
user,
|
|
4419
|
-
authError: null,
|
|
4420
|
-
setToken: (token) => {
|
|
4421
|
-
if (token) {
|
|
4422
|
-
try {
|
|
4423
|
-
const base64Url = token.split(".")[1];
|
|
4424
|
-
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
4425
|
-
const jsonPayload = decodeURIComponent(
|
|
4426
|
-
atob(base64).split("").map((c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
4427
|
-
);
|
|
4428
|
-
const user2 = JSON.parse(jsonPayload);
|
|
4429
|
-
localStorage.setItem(TOKEN_KEY, token);
|
|
4430
|
-
set({ token, authError: null, user: user2 });
|
|
4431
|
-
} catch {
|
|
4432
|
-
set({ token: null, authError: "Invalid token", user: null });
|
|
4433
|
-
}
|
|
4434
|
-
} else {
|
|
4435
|
-
set({ token: null, authError: null, user: null });
|
|
4436
|
-
}
|
|
4437
|
-
},
|
|
4438
|
-
clearToken: () => {
|
|
4439
|
-
localStorage.removeItem(TOKEN_KEY);
|
|
4440
|
-
set({ token: null, authError: null, user: null });
|
|
4441
|
-
}
|
|
4442
|
-
}));
|
|
4443
|
-
|
|
4444
|
-
// src/services/auth/authenticationService.ts
|
|
4445
|
-
init_debugLogger();
|
|
4446
|
-
var TOKEN_KEY2 = "authToken";
|
|
4447
|
-
var AUTH_TOKEN_CHANGED_EVENT = "bandit:auth-token-changed";
|
|
4448
|
-
function emitAuthTokenChanged(token) {
|
|
4449
|
-
if (typeof window === "undefined") {
|
|
4450
|
-
return;
|
|
4451
|
-
}
|
|
4452
|
-
window.dispatchEvent(new CustomEvent(AUTH_TOKEN_CHANGED_EVENT, {
|
|
4453
|
-
detail: { token }
|
|
4454
|
-
}));
|
|
4455
|
-
}
|
|
4456
|
-
var AuthenticationService = class {
|
|
4457
|
-
getToken() {
|
|
4458
|
-
const token = localStorage.getItem(TOKEN_KEY2);
|
|
4459
|
-
return token;
|
|
4460
|
-
}
|
|
4461
|
-
setToken(token) {
|
|
4462
|
-
localStorage.setItem(TOKEN_KEY2, token);
|
|
4463
|
-
useAuthenticationStore.getState().setToken(token);
|
|
4464
|
-
emitAuthTokenChanged(token);
|
|
4465
|
-
}
|
|
4466
|
-
clearToken() {
|
|
4467
|
-
localStorage.removeItem(TOKEN_KEY2);
|
|
4468
|
-
useAuthenticationStore.getState().clearToken();
|
|
4469
|
-
emitAuthTokenChanged(null);
|
|
4470
|
-
}
|
|
4471
|
-
isAuthenticated() {
|
|
4472
|
-
const token = useAuthenticationStore.getState().token;
|
|
4473
|
-
return !!token && !this.isTokenExpired(token);
|
|
4474
|
-
}
|
|
4475
|
-
isTokenExpired(token) {
|
|
4476
|
-
try {
|
|
4477
|
-
if (!token) return true;
|
|
4478
|
-
const decoded = this.parseJwtClaims(token);
|
|
4479
|
-
if (!decoded) return true;
|
|
4480
|
-
return decoded.exp * 1e3 < Date.now();
|
|
4481
|
-
} catch {
|
|
4482
|
-
return true;
|
|
4483
|
-
}
|
|
4484
|
-
}
|
|
4485
|
-
parseJwtClaims(token) {
|
|
4486
|
-
try {
|
|
4487
|
-
const base64Url = token.split(".")[1];
|
|
4488
|
-
const base64 = base64Url.replace(/-/g, "+").replace(/_/g, "/");
|
|
4489
|
-
const jsonPayload = decodeURIComponent(
|
|
4490
|
-
atob(base64).split("").map((c) => {
|
|
4491
|
-
return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
|
|
4492
|
-
}).join("")
|
|
4493
|
-
);
|
|
4494
|
-
return JSON.parse(jsonPayload);
|
|
4495
|
-
} catch (error) {
|
|
4496
|
-
debugLogger.error("Failed to parse JWT claims:", { error });
|
|
4497
|
-
return null;
|
|
4498
|
-
}
|
|
4499
|
-
}
|
|
4500
|
-
};
|
|
4501
|
-
var authenticationService = new AuthenticationService();
|
|
4537
|
+
init_authenticationService();
|
|
4502
4538
|
|
|
4503
4539
|
// src/store/conversationStore.ts
|
|
4504
4540
|
var import_zustand6 = require("zustand");
|
|
@@ -5407,9 +5443,11 @@ function emitProjectDelete(id) {
|
|
|
5407
5443
|
var import_zustand9 = require("zustand");
|
|
5408
5444
|
var import_uuid3 = require("uuid");
|
|
5409
5445
|
init_packageSettingsStore();
|
|
5446
|
+
init_authenticationService();
|
|
5410
5447
|
init_indexedDBService();
|
|
5411
5448
|
|
|
5412
5449
|
// src/services/conversationSync/conversationSyncService.ts
|
|
5450
|
+
init_authenticationService();
|
|
5413
5451
|
init_packageSettingsStore();
|
|
5414
5452
|
init_debugLogger();
|
|
5415
5453
|
var isRecord = (value) => typeof value === "object" && value !== null;
|
|
@@ -6574,6 +6612,7 @@ init_debugLogger();
|
|
|
6574
6612
|
|
|
6575
6613
|
// src/services/mcp/mcpServersService.ts
|
|
6576
6614
|
init_packageSettingsStore();
|
|
6615
|
+
init_authenticationService();
|
|
6577
6616
|
var gatewayBase = () => {
|
|
6578
6617
|
const settings = usePackageSettingsStore.getState().settings;
|
|
6579
6618
|
const url = settings?.gatewayApiUrl?.replace(/\/$/, "");
|
|
@@ -8727,6 +8766,7 @@ var VectorMigrationService = class _VectorMigrationService {
|
|
|
8727
8766
|
var vectorMigrationService = new VectorMigrationService();
|
|
8728
8767
|
|
|
8729
8768
|
// src/hooks/useVectorStore.tsx
|
|
8769
|
+
init_authenticationStore();
|
|
8730
8770
|
init_packageSettingsStore();
|
|
8731
8771
|
|
|
8732
8772
|
// src/hooks/useFeatures.ts
|
|
@@ -10080,6 +10120,7 @@ var useKnowledgeStore2 = () => {
|
|
|
10080
10120
|
init_aiProviderStore();
|
|
10081
10121
|
init_packageSettingsStore();
|
|
10082
10122
|
init_common_types();
|
|
10123
|
+
init_authenticationService();
|
|
10083
10124
|
init_debugLogger();
|
|
10084
10125
|
init_indexedDBService();
|
|
10085
10126
|
var AIProviderInitService = class _AIProviderInitService {
|