@hivegpt/hiveai-angular 0.0.567 → 0.0.568

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.
Files changed (29) hide show
  1. package/bundles/hivegpt-hiveai-angular.umd.js +279 -42
  2. package/bundles/hivegpt-hiveai-angular.umd.js.map +1 -1
  3. package/bundles/hivegpt-hiveai-angular.umd.min.js +1 -1
  4. package/bundles/hivegpt-hiveai-angular.umd.min.js.map +1 -1
  5. package/esm2015/lib/components/chat-drawer/chat-drawer.component.js +50 -16
  6. package/esm2015/lib/components/chatbot/chatbot.component.js +5 -3
  7. package/esm2015/lib/components/voice-agent/components/voice-agent-modal/voice-agent-modal.component.js +7 -4
  8. package/esm2015/lib/components/voice-agent/services/voice-agent.service.js +34 -7
  9. package/esm2015/lib/components/voice-agent/voice-modal-tokens.js +1 -1
  10. package/esm2015/lib/services/platform-token-refresh.service.js +173 -0
  11. package/esm2015/public-api.js +2 -1
  12. package/fesm2015/hivegpt-hiveai-angular.js +257 -29
  13. package/fesm2015/hivegpt-hiveai-angular.js.map +1 -1
  14. package/hivegpt-hiveai-angular.metadata.json +1 -1
  15. package/lib/components/chat-drawer/chat-drawer.component.d.ts +7 -1
  16. package/lib/components/chat-drawer/chat-drawer.component.d.ts.map +1 -1
  17. package/lib/components/chatbot/chatbot.component.d.ts +2 -0
  18. package/lib/components/chatbot/chatbot.component.d.ts.map +1 -1
  19. package/lib/components/voice-agent/components/voice-agent-modal/voice-agent-modal.component.d.ts +1 -0
  20. package/lib/components/voice-agent/components/voice-agent-modal/voice-agent-modal.component.d.ts.map +1 -1
  21. package/lib/components/voice-agent/services/voice-agent.service.d.ts +8 -2
  22. package/lib/components/voice-agent/services/voice-agent.service.d.ts.map +1 -1
  23. package/lib/components/voice-agent/voice-modal-tokens.d.ts +2 -0
  24. package/lib/components/voice-agent/voice-modal-tokens.d.ts.map +1 -1
  25. package/lib/services/platform-token-refresh.service.d.ts +59 -0
  26. package/lib/services/platform-token-refresh.service.d.ts.map +1 -0
  27. package/package.json +1 -1
  28. package/public-api.d.ts +1 -0
  29. package/public-api.d.ts.map +1 -1
@@ -1,19 +1,19 @@
1
1
  import { Overlay, OverlayModule } from '@angular/cdk/overlay';
2
2
  import { ComponentPortal } from '@angular/cdk/portal';
3
3
  import * as i1 from '@angular/common/http';
4
- import { HttpHeaders, HttpClient } from '@angular/common/http';
4
+ import { HttpClient, HttpHeaders } from '@angular/common/http';
5
5
  import * as i0 from '@angular/core';
6
- import { Injectable, NgZone, InjectionToken, EventEmitter, Component, Injector, Output, Input, ElementRef, ChangeDetectionStrategy, ChangeDetectorRef, Renderer2, ViewContainerRef, ViewChild, ViewChildren, NgModule, Pipe, Inject } from '@angular/core';
6
+ import { Injectable, InjectionToken, Inject, PLATFORM_ID, Optional, NgZone, EventEmitter, Component, Injector, Output, Input, ElementRef, ChangeDetectionStrategy, ChangeDetectorRef, Renderer2, ViewContainerRef, ViewChild, ViewChildren, NgModule, Pipe } from '@angular/core';
7
7
  import { DomSanitizer } from '@angular/platform-browser';
8
- import { Subject, BehaviorSubject, Subscription, combineLatest, of } from 'rxjs';
9
- import { map, take, takeUntil, filter, switchMap, catchError, tap } from 'rxjs/operators';
8
+ import { BehaviorSubject, of, throwError, Subject, Subscription, combineLatest } from 'rxjs';
9
+ import { switchMap, catchError, filter, take, map, takeUntil, tap } from 'rxjs/operators';
10
+ import { isPlatformBrowser, CommonModule, DOCUMENT } from '@angular/common';
10
11
  import { Socket } from 'ngx-socket-io';
11
12
  import { Validators, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
12
13
  import * as SpeechSDK from 'microsoft-cognitiveservices-speech-sdk';
13
14
  import * as marked from 'marked';
14
15
  import { __awaiter } from 'tslib';
15
16
  import Daily from '@daily-co/daily-js';
16
- import { CommonModule, DOCUMENT } from '@angular/common';
17
17
  import { MatIconModule } from '@angular/material/icon';
18
18
  import { MatSidenavModule } from '@angular/material/sidenav';
19
19
  import { QuillModule } from 'ngx-quill';
@@ -260,6 +260,172 @@ TranslationService.decorators = [
260
260
  },] }
261
261
  ];
262
262
 
263
+ /**
264
+ * Default matches Pro-Events `AppConstants.authTokenKey` — same localStorage shape
265
+ * `{ accessToken, refreshToken, ... }` as JSON.
266
+ * Named factory (no arrow fn) so ngc metadata collection accepts it.
267
+ */
268
+ function hiveGptAuthStorageKeyFactory() {
269
+ return 'authcc-aae1';
270
+ }
271
+ const HIVEGPT_AUTH_STORAGE_KEY = new InjectionToken('HIVEGPT_AUTH_STORAGE_KEY', {
272
+ providedIn: 'root',
273
+ factory: hiveGptAuthStorageKeyFactory,
274
+ });
275
+ /**
276
+ * Proactive access-token refresh (JWT `exp`) + single-flight queue, aligned with
277
+ * Pro-Events `EventInterceptor` + `AuthService.refreshToken`.
278
+ */
279
+ class PlatformTokenRefreshService {
280
+ constructor(http,
281
+ /** Use `Object` (not `object`) so ngc metadata collection accepts the parameter type. */
282
+ platformId,
283
+ /**
284
+ * Avoid `string | null` on the parameter — `|` is treated as unsupported expression in ngc metadata.
285
+ */
286
+ authStorageKey) {
287
+ this.http = http;
288
+ this.platformId = platformId;
289
+ this.refreshTokenInProgress = false;
290
+ this.refreshTokenSubject = new BehaviorSubject(null);
291
+ this.storageKey =
292
+ authStorageKey != null && authStorageKey !== ''
293
+ ? authStorageKey
294
+ : 'authcc-aae1';
295
+ }
296
+ /** Read parsed auth blob from localStorage (same as host app). */
297
+ readStoredAuth() {
298
+ if (!isPlatformBrowser(this.platformId)) {
299
+ return null;
300
+ }
301
+ try {
302
+ const raw = localStorage.getItem(this.storageKey);
303
+ if (!raw) {
304
+ return null;
305
+ }
306
+ return JSON.parse(raw);
307
+ }
308
+ catch (_a) {
309
+ return null;
310
+ }
311
+ }
312
+ persistAuth(res) {
313
+ if (!isPlatformBrowser(this.platformId) || !res) {
314
+ return;
315
+ }
316
+ try {
317
+ localStorage.setItem(this.storageKey, JSON.stringify(res));
318
+ }
319
+ catch (e) {
320
+ console.warn('[HiveGpt] Failed to persist auth tokens', e);
321
+ }
322
+ }
323
+ /**
324
+ * JWT `exp` check without @auth0/angular-jwt (keeps package lean).
325
+ * @param skewSeconds refresh slightly before actual expiry (clock skew).
326
+ */
327
+ isAccessTokenExpired(token, skewSeconds = 60) {
328
+ if (!token || typeof token !== 'string') {
329
+ return true;
330
+ }
331
+ const expMs = this.getJwtExpirationMs(token);
332
+ if (expMs == null) {
333
+ return false;
334
+ }
335
+ return expMs - skewSeconds * 1000 < Date.now();
336
+ }
337
+ getJwtExpirationMs(token) {
338
+ try {
339
+ const parts = token.split('.');
340
+ if (parts.length < 2) {
341
+ return null;
342
+ }
343
+ const payload = parts[1]
344
+ .replace(/-/g, '+')
345
+ .replace(/_/g, '/');
346
+ const padded = payload + '='.repeat((4 - (payload.length % 4)) % 4);
347
+ if (typeof atob === 'undefined') {
348
+ return null;
349
+ }
350
+ const json = JSON.parse(atob(padded));
351
+ if ((json === null || json === void 0 ? void 0 : json.exp) == null || typeof json.exp !== 'number') {
352
+ return null;
353
+ }
354
+ return json.exp * 1000;
355
+ }
356
+ catch (_a) {
357
+ return null;
358
+ }
359
+ }
360
+ /**
361
+ * Returns a valid access token: refreshes via `POST {usersApiBaseUrl}/user/tokenRefresh`
362
+ * when JWT is expired and a refresh token exists in storage.
363
+ */
364
+ ensureValidAccessToken(currentAccessToken, usersApiBaseUrl) {
365
+ if (!isPlatformBrowser(this.platformId)) {
366
+ return of({
367
+ accessToken: currentAccessToken !== null && currentAccessToken !== void 0 ? currentAccessToken : '',
368
+ refreshed: false,
369
+ });
370
+ }
371
+ const stored = this.readStoredAuth();
372
+ const access = (currentAccessToken && String(currentAccessToken).trim()) ||
373
+ (stored === null || stored === void 0 ? void 0 : stored.accessToken) ||
374
+ '';
375
+ const refresh = stored === null || stored === void 0 ? void 0 : stored.refreshToken;
376
+ if (access && !this.isAccessTokenExpired(access)) {
377
+ return of({ accessToken: access, refreshed: false });
378
+ }
379
+ if (!refresh || typeof refresh !== 'string') {
380
+ return of({ accessToken: access, refreshed: false });
381
+ }
382
+ const base = (usersApiBaseUrl || '').replace(/\/+$/, '');
383
+ if (!base) {
384
+ return of({ accessToken: access, refreshed: false });
385
+ }
386
+ const url = `${base}/user/tokenRefresh`;
387
+ if (!this.refreshTokenInProgress) {
388
+ this.refreshTokenInProgress = true;
389
+ this.refreshTokenSubject.next(null);
390
+ return this.http
391
+ .post(url, { refreshToken: refresh })
392
+ .pipe(switchMap((authResponse) => {
393
+ this.refreshTokenInProgress = false;
394
+ if (authResponse === null || authResponse === void 0 ? void 0 : authResponse.accessToken) {
395
+ this.persistAuth(authResponse);
396
+ this.refreshTokenSubject.next(authResponse.accessToken);
397
+ return of({
398
+ accessToken: authResponse.accessToken,
399
+ refreshed: true,
400
+ authResponse,
401
+ });
402
+ }
403
+ this.refreshTokenSubject.next(null);
404
+ return throwError(() => new Error('Token refresh returned no accessToken'));
405
+ }), catchError((err) => {
406
+ this.refreshTokenInProgress = false;
407
+ this.refreshTokenSubject.next(null);
408
+ return throwError(() => err);
409
+ }));
410
+ }
411
+ return this.refreshTokenSubject.pipe(filter((t) => t != null && t !== ''), take(1), switchMap((token) => of({
412
+ accessToken: token,
413
+ refreshed: true,
414
+ })));
415
+ }
416
+ }
417
+ PlatformTokenRefreshService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PlatformTokenRefreshService_Factory() { return new PlatformTokenRefreshService(i0.ɵɵinject(i1.HttpClient), i0.ɵɵinject(i0.PLATFORM_ID), i0.ɵɵinject(HIVEGPT_AUTH_STORAGE_KEY, 8)); }, token: PlatformTokenRefreshService, providedIn: "root" });
418
+ PlatformTokenRefreshService.decorators = [
419
+ { type: Injectable, args: [{
420
+ providedIn: 'root',
421
+ },] }
422
+ ];
423
+ PlatformTokenRefreshService.ctorParameters = () => [
424
+ { type: HttpClient },
425
+ { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] },
426
+ { type: String, decorators: [{ type: Optional }, { type: Inject, args: [HIVEGPT_AUTH_STORAGE_KEY,] }] }
427
+ ];
428
+
263
429
  const formatHoursAndMinutes = (date) => {
264
430
  let hours = date.getHours() % 12;
265
431
  const minutes = date.getMinutes();
@@ -1041,10 +1207,14 @@ DailyVoiceClientService.ctorParameters = () => [
1041
1207
  * - Uses Daily.js for all audio, mic, and real-time speaking detection
1042
1208
  */
1043
1209
  class VoiceAgentService {
1044
- constructor(audioAnalyzer, wsClient, dailyClient) {
1210
+ constructor(audioAnalyzer, wsClient, dailyClient, platformTokenRefresh,
1211
+ /** `Object` not `object` — ngc metadata collection rejects the `object` type in DI params. */
1212
+ platformId) {
1045
1213
  this.audioAnalyzer = audioAnalyzer;
1046
1214
  this.wsClient = wsClient;
1047
1215
  this.dailyClient = dailyClient;
1216
+ this.platformTokenRefresh = platformTokenRefresh;
1217
+ this.platformId = platformId;
1048
1218
  this.callStateSubject = new BehaviorSubject('idle');
1049
1219
  this.statusTextSubject = new BehaviorSubject('');
1050
1220
  this.durationSubject = new BehaviorSubject('00:00');
@@ -1086,7 +1256,7 @@ class VoiceAgentService {
1086
1256
  this.statusTextSubject.next('');
1087
1257
  this.durationSubject.next('0:00');
1088
1258
  }
1089
- connect(apiUrl, token, botId, conversationId, apiKey, eventToken, eventUrl, domainAuthority) {
1259
+ connect(apiUrl, token, botId, conversationId, apiKey, eventToken, eventUrl, domainAuthority, usersApiUrl) {
1090
1260
  return __awaiter(this, void 0, void 0, function* () {
1091
1261
  if (this.callStateSubject.value !== 'idle') {
1092
1262
  console.warn('Call already in progress');
@@ -1095,11 +1265,29 @@ class VoiceAgentService {
1095
1265
  try {
1096
1266
  this.callStateSubject.next('connecting');
1097
1267
  this.statusTextSubject.next('Connecting...');
1268
+ let accessToken = token;
1269
+ // Align with chat drawer token handling: always delegate to
1270
+ // PlatformTokenRefreshService when we have a usersApiUrl, so it can
1271
+ // fall back to stored tokens even if the caller passed an empty token.
1272
+ if (usersApiUrl && isPlatformBrowser(this.platformId)) {
1273
+ try {
1274
+ const ensured = yield this.platformTokenRefresh
1275
+ .ensureValidAccessToken(token, usersApiUrl)
1276
+ .pipe(take(1))
1277
+ .toPromise();
1278
+ if (ensured === null || ensured === void 0 ? void 0 : ensured.accessToken) {
1279
+ accessToken = ensured.accessToken;
1280
+ }
1281
+ }
1282
+ catch (e) {
1283
+ console.warn('[HiveGpt Voice] Token refresh before connect failed', e);
1284
+ }
1285
+ }
1098
1286
  const baseUrl = apiUrl.replace(/\/$/, '');
1099
1287
  const postUrl = `${baseUrl}/ai/ask-voice`;
1100
1288
  const headers = {
1101
1289
  'Content-Type': 'application/json',
1102
- Authorization: `Bearer ${token}`,
1290
+ Authorization: `Bearer ${accessToken}`,
1103
1291
  'domain-authority': domainAuthority,
1104
1292
  'eventtoken': eventToken,
1105
1293
  'eventurl': eventUrl,
@@ -1232,7 +1420,7 @@ class VoiceAgentService {
1232
1420
  }
1233
1421
  }
1234
1422
  }
1235
- VoiceAgentService.ɵprov = i0.ɵɵdefineInjectable({ factory: function VoiceAgentService_Factory() { return new VoiceAgentService(i0.ɵɵinject(AudioAnalyzerService), i0.ɵɵinject(WebSocketVoiceClientService), i0.ɵɵinject(DailyVoiceClientService)); }, token: VoiceAgentService, providedIn: "root" });
1423
+ VoiceAgentService.ɵprov = i0.ɵɵdefineInjectable({ factory: function VoiceAgentService_Factory() { return new VoiceAgentService(i0.ɵɵinject(AudioAnalyzerService), i0.ɵɵinject(WebSocketVoiceClientService), i0.ɵɵinject(DailyVoiceClientService), i0.ɵɵinject(PlatformTokenRefreshService), i0.ɵɵinject(i0.PLATFORM_ID)); }, token: VoiceAgentService, providedIn: "root" });
1236
1424
  VoiceAgentService.decorators = [
1237
1425
  { type: Injectable, args: [{
1238
1426
  providedIn: 'root',
@@ -1241,7 +1429,9 @@ VoiceAgentService.decorators = [
1241
1429
  VoiceAgentService.ctorParameters = () => [
1242
1430
  { type: AudioAnalyzerService },
1243
1431
  { type: WebSocketVoiceClientService },
1244
- { type: DailyVoiceClientService }
1432
+ { type: DailyVoiceClientService },
1433
+ { type: PlatformTokenRefreshService },
1434
+ { type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] }
1245
1435
  ];
1246
1436
 
1247
1437
  const VOICE_MODAL_CONFIG = new InjectionToken('VOICE_MODAL_CONFIG');
@@ -1259,6 +1449,7 @@ class VoiceAgentModalComponent {
1259
1449
  this.domainAuthority = 'prod-lite';
1260
1450
  this.agentName = 'AI Assistant';
1261
1451
  this.agentRole = 'AI Agent Specialist';
1452
+ this.usersApiUrl = '';
1262
1453
  this.injectedConfig = null;
1263
1454
  this.onCloseCallback = null;
1264
1455
  /** Hardcoded voice agent avatar (Nia). */
@@ -1276,7 +1467,7 @@ class VoiceAgentModalComponent {
1276
1467
  this.isConnecting = false;
1277
1468
  }
1278
1469
  ngOnInit() {
1279
- var _a, _b, _c, _d, _e, _f;
1470
+ var _a, _b, _c, _d, _e, _f, _g;
1280
1471
  // When opened via Overlay, config is provided by injection
1281
1472
  this.injectedConfig = this.injector.get(VOICE_MODAL_CONFIG, null);
1282
1473
  this.onCloseCallback = this.injector.get(VOICE_MODAL_CLOSE_CALLBACK, null);
@@ -1292,6 +1483,7 @@ class VoiceAgentModalComponent {
1292
1483
  this.agentName = (_e = this.injectedConfig.agentName) !== null && _e !== void 0 ? _e : this.agentName;
1293
1484
  this.agentRole = (_f = this.injectedConfig.agentRole) !== null && _f !== void 0 ? _f : this.agentRole;
1294
1485
  this.agentAvatar = this.injectedConfig.agentAvatar;
1486
+ this.usersApiUrl = (_g = this.injectedConfig.usersApiUrl) !== null && _g !== void 0 ? _g : this.usersApiUrl;
1295
1487
  }
1296
1488
  // Subscribe to observables
1297
1489
  this.subscriptions.push(this.voiceAgentService.callState$.subscribe(state => {
@@ -1333,7 +1525,7 @@ class VoiceAgentModalComponent {
1333
1525
  return;
1334
1526
  this.isConnecting = true;
1335
1527
  try {
1336
- yield this.voiceAgentService.connect(this.apiUrl, this.token, this.botId, this.conversationId, this.apiKey, this.eventToken, this.eventUrl, this.domainAuthority);
1528
+ yield this.voiceAgentService.connect(this.apiUrl, this.token, this.botId, this.conversationId, this.apiKey, this.eventToken, this.eventUrl, this.domainAuthority, this.usersApiUrl || undefined);
1337
1529
  }
1338
1530
  catch (error) {
1339
1531
  console.error('Failed to connect voice agent:', error);
@@ -1413,7 +1605,8 @@ VoiceAgentModalComponent.propDecorators = {
1413
1605
  domainAuthority: [{ type: Input }],
1414
1606
  agentName: [{ type: Input }],
1415
1607
  agentRole: [{ type: Input }],
1416
- agentAvatar: [{ type: Input }]
1608
+ agentAvatar: [{ type: Input }],
1609
+ usersApiUrl: [{ type: Input }]
1417
1610
  };
1418
1611
 
1419
1612
  // import { Platform } from '@angular/cdk/platform';
@@ -1425,7 +1618,7 @@ var eClassificationType;
1425
1618
  })(eClassificationType || (eClassificationType = {}));
1426
1619
  class ChatDrawerComponent {
1427
1620
  constructor(fb, botService, cdr, http, sanitizer, elementRef, renderer, socketService, conversationService, // private platform: Platform
1428
- translationService, voiceAgentService, overlay, viewContainerRef, injector) {
1621
+ translationService, voiceAgentService, overlay, viewContainerRef, injector, platformTokenRefresh) {
1429
1622
  this.fb = fb;
1430
1623
  this.botService = botService;
1431
1624
  this.cdr = cdr;
@@ -1440,6 +1633,7 @@ class ChatDrawerComponent {
1440
1633
  this.overlay = overlay;
1441
1634
  this.viewContainerRef = viewContainerRef;
1442
1635
  this.injector = injector;
1636
+ this.platformTokenRefresh = platformTokenRefresh;
1443
1637
  this.bodyOverflowClass = 'body-overflow-hidden';
1444
1638
  this.isCollapsedTrue = false;
1445
1639
  this.copilotName = 'HiveXGPT';
@@ -1468,6 +1662,8 @@ class ChatDrawerComponent {
1468
1662
  this.viewBooth = new EventEmitter();
1469
1663
  this.scheduleMeeting = new EventEmitter();
1470
1664
  this.refreshToken = new EventEmitter();
1665
+ /** Emitted after a successful `user/tokenRefresh` so the host can dispatch Login / `saveTokenAndLoginUser`. */
1666
+ this.tokensRefreshed = new EventEmitter();
1471
1667
  this.openSupport = new EventEmitter();
1472
1668
  this.autogenKey = 'Autogen_eDJTtEU-NB0RtIpzq1w';
1473
1669
  this.addToMyAgendaAction = 'add_to_my_agenda';
@@ -4527,8 +4723,8 @@ class ChatDrawerComponent {
4527
4723
  }
4528
4724
  makeAskRequest(inputMsg, agents, conversationId, msg, chat, workflowId, workflow_inputs) {
4529
4725
  var _a;
4530
- var url = `${this.environment.BASE_URL}/ai/ask`;
4531
- var body = {
4726
+ const url = `${this.environment.BASE_URL}/ai/ask`;
4727
+ const body = {
4532
4728
  user_question: inputMsg,
4533
4729
  user_id: this.userId,
4534
4730
  bot_id: this.botId,
@@ -4543,9 +4739,44 @@ class ChatDrawerComponent {
4543
4739
  body['workflow_id'] = workflowId;
4544
4740
  body['workflow_inputs'] = workflow_inputs;
4545
4741
  }
4742
+ const usersApi = this.environment.USERS_API;
4743
+ this.platformTokenRefresh
4744
+ .ensureValidAccessToken(this.s27Token, usersApi)
4745
+ .pipe(take(1))
4746
+ .subscribe({
4747
+ next: (ensured) => {
4748
+ let bearer = ensured.accessToken || this.s27Token || '';
4749
+ if (ensured.refreshed && ensured.accessToken) {
4750
+ this.s27Token = ensured.accessToken;
4751
+ if (ensured.authResponse) {
4752
+ this.tokensRefreshed.emit(ensured.authResponse);
4753
+ }
4754
+ }
4755
+ this.executeAskFetch(url, body, bearer, msg, chat);
4756
+ },
4757
+ error: () => {
4758
+ this.is401 = true;
4759
+ this.refreshToken.emit();
4760
+ if (msg && chat) {
4761
+ this.msg = msg;
4762
+ this.chat = chat;
4763
+ this.isFetchDataFor = true;
4764
+ }
4765
+ this.isChatingWithAi = false;
4766
+ },
4767
+ });
4768
+ this.input = '';
4769
+ this.selectedWorkflow = null;
4770
+ this.openWorkflowInput = false;
4771
+ this.isWorkflowOpen = false;
4772
+ this.scrollToBottom();
4773
+ this.cdr.markForCheck();
4774
+ }
4775
+ /** `/ai/ask` fetch using a Bearer token (after optional proactive refresh). */
4776
+ executeAskFetch(url, body, bearerToken, msg, chat) {
4546
4777
  const headers = {
4547
4778
  'Content-Type': 'application/json',
4548
- Authorization: 'Bearer ' + this.s27Token,
4779
+ Authorization: 'Bearer ' + bearerToken,
4549
4780
  'x-api-key': this.apiKey,
4550
4781
  'hive-bot-id': this.botId,
4551
4782
  'domain-authority': this.domainAuthorityValue,
@@ -4565,7 +4796,6 @@ class ChatDrawerComponent {
4565
4796
  if (response.status === 401 || response.status === 403) {
4566
4797
  this.is401 = true;
4567
4798
  this.refreshToken.emit();
4568
- // If `msg` and `chat` exist, handle them
4569
4799
  if (msg && chat) {
4570
4800
  this.msg = msg;
4571
4801
  this.chat = chat;
@@ -4579,18 +4809,11 @@ class ChatDrawerComponent {
4579
4809
  })
4580
4810
  .then((data) => {
4581
4811
  console.log(data);
4582
- // Additional response handling if needed
4583
4812
  })
4584
4813
  .catch((err) => {
4585
4814
  console.error('Error: ', err);
4586
4815
  this.isChatingWithAi = false;
4587
4816
  });
4588
- this.input = '';
4589
- this.selectedWorkflow = null;
4590
- this.openWorkflowInput = false;
4591
- this.isWorkflowOpen = false;
4592
- this.scrollToBottom();
4593
- this.cdr.markForCheck();
4594
4817
  }
4595
4818
  makeAskRequestold(inputMsg, agents, conversationId, msg, chat, workflowId, workflow_inputs) {
4596
4819
  var _a;
@@ -4740,7 +4963,7 @@ class ChatDrawerComponent {
4740
4963
  }); // returns current time in 'shortTime' format
4741
4964
  }
4742
4965
  openVoiceModal() {
4743
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4966
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
4744
4967
  const conversationId = (_b = (_a = this.conversationKey) !== null && _a !== void 0 ? _a : this.conversationService.getKey(this.botId, false, this.eventId)) !== null && _b !== void 0 ? _b : '';
4745
4968
  this.voiceModalConversationId = conversationId;
4746
4969
  this.setupVoiceTranscripts();
@@ -4762,6 +4985,7 @@ class ChatDrawerComponent {
4762
4985
  agentName: this.botName || 'AI Assistant',
4763
4986
  agentRole: this.botSkills || 'AI Agent Specialist',
4764
4987
  agentAvatar: this.botIcon,
4988
+ usersApiUrl: (_m = (_l = this.environment) === null || _l === void 0 ? void 0 : _l.USERS_API) !== null && _m !== void 0 ? _m : '',
4765
4989
  };
4766
4990
  const closeCallback = () => {
4767
4991
  if (this.voiceModalOverlayRef) {
@@ -5098,7 +5322,8 @@ ChatDrawerComponent.ctorParameters = () => [
5098
5322
  { type: VoiceAgentService },
5099
5323
  { type: Overlay },
5100
5324
  { type: ViewContainerRef },
5101
- { type: Injector }
5325
+ { type: Injector },
5326
+ { type: PlatformTokenRefreshService }
5102
5327
  ];
5103
5328
  ChatDrawerComponent.propDecorators = {
5104
5329
  chatMain: [{ type: ViewChild, args: ['chatMain',] }],
@@ -5168,11 +5393,13 @@ ChatDrawerComponent.propDecorators = {
5168
5393
  viewBooth: [{ type: Output }],
5169
5394
  scheduleMeeting: [{ type: Output }],
5170
5395
  refreshToken: [{ type: Output }],
5396
+ tokensRefreshed: [{ type: Output }],
5171
5397
  openSupport: [{ type: Output }]
5172
5398
  };
5173
5399
 
5174
5400
  class ChatBotComponent {
5175
5401
  constructor() {
5402
+ this.tokensRefreshed = new EventEmitter();
5176
5403
  this.visible = false;
5177
5404
  }
5178
5405
  toggle() {
@@ -5182,7 +5409,7 @@ class ChatBotComponent {
5182
5409
  ChatBotComponent.decorators = [
5183
5410
  { type: Component, args: [{
5184
5411
  selector: 'hivegpt-chatbot',
5185
- template: "<button mat-icon-button class=\"chat-button\" color=\"primary\" (click)=\"toggle()\">\n <mat-icon>chat</mat-icon>\n</button>\n\n<ng-container *ngIf=\"visible\">\n <hivegpt-chat-drawer-package\n [apiKey]=\"apiKey\"\n [bgBubbleAi]=\"bgBubbleAi\"\n [bgBubbleUser]=\"bgBubbleUser\"\n [bgGradient]=\"bgGradient\"\n [botName]=\"botName\"\n [closeButtonbgColor]=\"closeButtonbgColor\"\n [closeButtonColor]=\"closeButtonColor\"\n [credentials]=\"credentials\"\n [dateTextColor]=\"dateTextColor\"\n [dateTimeColor]=\"dateTimeColor\"\n [eventId]=\"eventId\"\n [eventName]=\"eventName\"\n [formFieldBgColor]=\"formFieldBgColor\"\n [formFieldTextColor]=\"formFieldTextColor\"\n [fullView]=\"fullView\"\n [greeting]=\"greeting\"\n [gradientColors]=\"gradientColors\"\n [messageTextColorAi]=\"messageTextColorAi\"\n [messageTextColorUser]=\"messageTextColorUser\"\n [sendButtonColor]=\"sendButtonColor\"\n [sendButtonTextColor]=\"sendButtonTextColor\"\n [showClose]=\"showClose\"\n [thumbsDownMessages]=\"thumbsDownMessages\"\n [thumbsUpMessage]=\"thumbsUpMessage\"\n [unknownResponses]=\"unknownResponses\"\n [useOpenAi]=\"useOpenAi\"\n [userId]=\"userId\"\n [userAvatarUrl]=\"userAvatarUrl\"\n [timezone]=\"timezone\"\n [botId]=\"botId\"\n [s27Token]=\"s27Token\"\n [workspaceToken]=\"workspaceToken\"\n [isDev]=\"isDev\"\n [baseUrl]=\"baseUrl\"\n >\n </hivegpt-chat-drawer-package>\n</ng-container>\n",
5412
+ template: "<button mat-icon-button class=\"chat-button\" color=\"primary\" (click)=\"toggle()\">\n <mat-icon>chat</mat-icon>\n</button>\n\n<ng-container *ngIf=\"visible\">\n <hivegpt-chat-drawer-package\n [apiKey]=\"apiKey\"\n [bgBubbleAi]=\"bgBubbleAi\"\n [bgBubbleUser]=\"bgBubbleUser\"\n [bgGradient]=\"bgGradient\"\n [botName]=\"botName\"\n [closeButtonbgColor]=\"closeButtonbgColor\"\n [closeButtonColor]=\"closeButtonColor\"\n [credentials]=\"credentials\"\n [dateTextColor]=\"dateTextColor\"\n [dateTimeColor]=\"dateTimeColor\"\n [eventId]=\"eventId\"\n [eventName]=\"eventName\"\n [formFieldBgColor]=\"formFieldBgColor\"\n [formFieldTextColor]=\"formFieldTextColor\"\n [fullView]=\"fullView\"\n [greeting]=\"greeting\"\n [gradientColors]=\"gradientColors\"\n [messageTextColorAi]=\"messageTextColorAi\"\n [messageTextColorUser]=\"messageTextColorUser\"\n [sendButtonColor]=\"sendButtonColor\"\n [sendButtonTextColor]=\"sendButtonTextColor\"\n [showClose]=\"showClose\"\n [thumbsDownMessages]=\"thumbsDownMessages\"\n [thumbsUpMessage]=\"thumbsUpMessage\"\n [unknownResponses]=\"unknownResponses\"\n [useOpenAi]=\"useOpenAi\"\n [userId]=\"userId\"\n [userAvatarUrl]=\"userAvatarUrl\"\n [timezone]=\"timezone\"\n [botId]=\"botId\"\n [s27Token]=\"s27Token\"\n (tokensRefreshed)=\"tokensRefreshed.emit($event)\"\n [workspaceToken]=\"workspaceToken\"\n [isDev]=\"isDev\"\n [baseUrl]=\"baseUrl\"\n >\n </hivegpt-chat-drawer-package>\n</ng-container>\n",
5186
5413
  styles: ["::-webkit-scrollbar{width:5px}::-webkit-scrollbar-track{background:#f1f1f1}::-webkit-scrollbar-thumb,::-webkit-scrollbar-thumb:hover{background:#e5ccbc}.spinner{align-items:center;display:flex;gap:2px;justify-content:center}.spinner>div{animation:bouncedelay 1.4s ease-in-out infinite;animation-fill-mode:both;background-color:#173330;border-radius:100%;display:inline-block;height:5px;width:5px}.spinner .bounce1{animation-delay:-.32s}.spinner .bounce2{animation-delay:-.16s}@keyframes bouncedelay{0%,80%,to{-webkit-transform:scale(0);transform:scale(0)}40%{-webkit-transform:scale(1);transform:scale(1)}}.chat-button{align-items:center;background:#17235b;border:#17235b;border-radius:50%;bottom:20px;color:#fff;display:inline-flex;font-size:24px;height:50px;justify-content:center;position:fixed;right:20px;width:50px}"]
5187
5414
  },] }
5188
5415
  ];
@@ -5220,6 +5447,7 @@ ChatBotComponent.propDecorators = {
5220
5447
  rules: [{ type: Input }],
5221
5448
  eventId: [{ type: Input }],
5222
5449
  s27Token: [{ type: Input }],
5450
+ tokensRefreshed: [{ type: Output }],
5223
5451
  workspaceToken: [{ type: Input }],
5224
5452
  isDev: [{ type: Input }],
5225
5453
  baseUrl: [{ type: Input }]
@@ -5514,5 +5742,5 @@ HiveGptModule.decorators = [
5514
5742
  * Generated bundle index. Do not edit.
5515
5743
  */
5516
5744
 
5517
- export { AudioAnalyzerService, ChatBotComponent, ChatDrawerComponent, HiveGptModule, VOICE_MODAL_CLOSE_CALLBACK, VOICE_MODAL_CONFIG, VoiceAgentModalComponent, VoiceAgentModule, VoiceAgentService, eClassificationType, BotsService as ɵa, SocketService as ɵb, ConversationService as ɵc, NotificationSocket as ɵd, TranslationService as ɵe, WebSocketVoiceClientService as ɵf, DailyVoiceClientService as ɵg, VideoPlayerComponent as ɵh, SafeHtmlPipe as ɵi, BotHtmlEditorComponent as ɵj };
5745
+ export { AudioAnalyzerService, ChatBotComponent, ChatDrawerComponent, HIVEGPT_AUTH_STORAGE_KEY, HiveGptModule, PlatformTokenRefreshService, VOICE_MODAL_CLOSE_CALLBACK, VOICE_MODAL_CONFIG, VoiceAgentModalComponent, VoiceAgentModule, VoiceAgentService, eClassificationType, hiveGptAuthStorageKeyFactory, BotsService as ɵa, SocketService as ɵb, ConversationService as ɵc, NotificationSocket as ɵd, TranslationService as ɵe, WebSocketVoiceClientService as ɵf, DailyVoiceClientService as ɵg, VideoPlayerComponent as ɵh, SafeHtmlPipe as ɵi, BotHtmlEditorComponent as ɵj };
5518
5746
  //# sourceMappingURL=hivegpt-hiveai-angular.js.map