@aakash58/chatbot 1.1.13 → 1.1.14

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.
@@ -1,8 +1,8 @@
1
1
  import * as i1$2 from '@angular/common';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
- import { isDevMode, Injectable, InjectionToken, inject, signal, effect, EventEmitter, Output, Input, Component, Pipe, ViewChild, Inject, HostListener, Directive, computed, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef, ViewEncapsulation, ContentChildren, makeEnvironmentProviders, APP_INITIALIZER } from '@angular/core';
5
- import { ReplaySubject, delay, retry, map, catchError, of, BehaviorSubject, firstValueFrom, throwError, tap, Observable, Subject, lastValueFrom, switchMap, filter, take } from 'rxjs';
4
+ import { isDevMode, InjectionToken, signal, Injectable, inject, effect, EventEmitter, Output, Input, Component, Pipe, ViewChild, Inject, HostListener, Directive, computed, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef, ViewEncapsulation, ContentChildren, makeEnvironmentProviders } from '@angular/core';
5
+ import { delay, retry, map, catchError, of, BehaviorSubject, firstValueFrom, throwError, tap, Observable, Subject, lastValueFrom, switchMap, filter, take } from 'rxjs';
6
6
  import { JwtHelperService } from '@auth0/angular-jwt';
7
7
  import * as i1 from '@angular/common/http';
8
8
  import { HttpHeaders, HttpEventType, HttpClient, HttpErrorResponse, provideHttpClient, HTTP_INTERCEPTORS, withInterceptorsFromDi } from '@angular/common/http';
@@ -61,21 +61,6 @@ const DoohbotConst = {
61
61
  botAvatar: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMMAAADDCAYAAAA/f6WqAAAACXBIWXMAACxLAAAsSwGlPZapAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAyeSURBVHgB7d09bBzHFQfw95Y6HuOKKlPlBFiF4QChAAFxp1MhSqlEwaKQjnSRQFQKUWUqU2UqkUACUkihUxdINHTqSCaAzlUCxICoIr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s3pNIvQRpUCiF3Gt1cHxT3OuNgyneLZv39J9WFANxWehxEuuyi6KQT4Zh+p/Qcl3N6+sVXhUKyXYdQJSB8zTWZecZgmGIQRoVanxhsWQyqCm8IFvBdKh6CmTqNM1Zh2CYIJimvWuRRhkvmbSsnrsq0rYxDkgOgsFAsDX7a9PBtkmqZL3hsHgrh/sPzU8JBWs4xsqA/0ksFmc3G7SGlNTAncy5CITkIRgMOSQTz2l7y8QDCeM+MBGiQzAYsj2QsHymtT7qtSQOTIToEAw2xOLpwHR91EuqtrBO5ly0T6QDwWBBH0hocXlVT50Oe8Fm/YXNgYkQDYLBwqBybXq9NyQVCgKkQqba8iVBKhAMtqRnPKujngDvbVjg90QZ/13SwEEi6UEwWGp1P6hZXL54OlUKqtpG2OEaQWoQDJaC6m/D9Hq9k8Xga71ugcxTpJNmu4zaQooQDCGIRxZTnbIyqDlY1hbqaLtIF4IhhHavbFNzWNQ1B9vagl6QQ5CqOQJr7jf/aH740cWfqgHAJ0ZvYFrwhH5gYtMWDPdwf+8eQarwZAhJryGwuLzqkMVWNp5grDAFCIaQ+jUHcS3eUjG9kHtUqHMRZgWCIQIRij+vR21hahAMEbS7C7F/gqO2MD0Ihghsaw5G0H4xNQiGqCzaMybjGlKk6UEwRKTbM2zWOYwlvUj7tUI0CIaI+ktCY5kKxdLOKUMwxED9T6xRZFjaOW0IhhgE6xxcioA73n2CqUIwxESf0UChYeA8CxAMMfEPK/EkzMJ9F0+F2YBGvRh9+/VXBx9+dPGscQMf8TF35Fd4KswGBEPMdECc//jid+pG1+ctDN07KTg45A+tbnnjb/U//odgJmB7yQQFGxhXmZ2f+d/wvB/YoeNmZwELdwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACCH/gcLSoOevknsYwAAAABJRU5ErkJggg==',
62
62
  };
63
63
 
64
- // export const environment = {
65
- // staging: false,
66
- // development: false,
67
- // production: true,
68
- // chatApiUrl: 'https://api.production.com',
69
- // apiKey: '',
70
- // };
71
- const environment = {
72
- config: 'const/app-const.json',
73
- production: false,
74
- apiBaseUrl: '',
75
- loginEndpoint: '',
76
- apiSegment: 'api/v1/',
77
- };
78
-
79
64
  class Logger {
80
65
  static prefix = '[Doohbot]';
81
66
  // 🎨 Color styles
@@ -116,61 +101,6 @@ class Logger {
116
101
  }
117
102
  }
118
103
 
119
- class AppConst {
120
- static appBaseUrl = environment.apiBaseUrl;
121
- static data;
122
- config$ = new ReplaySubject(1);
123
- constructor() { }
124
- async load() {
125
- const filePath = `./assets/${environment.production ? environment.config : environment.config}?t=${new Date().getTime()}`;
126
- const response = await fetch(filePath);
127
- if (!response.ok) {
128
- Logger.error('============================ ERROR ============================');
129
- Logger.error(`Could not find file ${filePath}`);
130
- Logger.error('============================ ERROR ============================');
131
- }
132
- Logger.error('============================ AppConst ============================', filePath);
133
- if (response.ok) {
134
- try {
135
- AppConst.data = await response.json();
136
- this.config$.next(AppConst.data);
137
- Logger.error('============================ AppConst ============================', AppConst.data);
138
- // Override apiBaseUrl if present in environment
139
- // if (environment.apiBaseUrl) {
140
- // AppConst.data.apiBaseUrl = environment.apiBaseUrl;
141
- // }
142
- // // Override loginEndpoint if present in environment
143
- // if (environment.loginEndpoint) {
144
- // AppConst.data.loginEndpoint = environment.loginEndpoint;
145
- // }
146
- }
147
- catch (error) {
148
- Logger.error('============================ ERROR ============================');
149
- Logger.error(`Could not find file ${filePath}.\nMESSAGE: ${error.message}`);
150
- Logger.error('============================ ERROR ============================');
151
- }
152
- if (AppConst.data && !Object.keys(AppConst.data).length) {
153
- Logger.error('============================ ERROR ============================');
154
- Logger.error(`No data found in file ${filePath}`);
155
- Logger.error('============================ ERROR ============================');
156
- }
157
- }
158
- else {
159
- Logger.error('============================ ERROR ============================');
160
- Logger.error(`Failed to load file ${filePath}.\nMESSAGE: Request failed with ${response.status} / ${response.statusText}`);
161
- Logger.error('============================ ERROR ============================');
162
- }
163
- }
164
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AppConst, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
165
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AppConst, providedIn: 'root' });
166
- }
167
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AppConst, decorators: [{
168
- type: Injectable,
169
- args: [{
170
- providedIn: 'root',
171
- }]
172
- }], ctorParameters: () => [] });
173
-
174
104
  /**
175
105
  * Utility class for common snackbar operations
176
106
  * Provides reusable snackbar configurations for consistency across the application
@@ -231,13 +161,78 @@ const DOOHBOT_ADVANCED_CONFIG = new InjectionToken('DOOHBOT_ADVANCED_CONFIG', {
231
161
  }),
232
162
  });
233
163
 
164
+ class DoohbotInput {
165
+ username = '';
166
+ password = '';
167
+ authToken;
168
+ license = '';
169
+ licenseCode = '';
170
+ licenseKey = '';
171
+ filePath = '';
172
+ apiBaseUrl = '';
173
+ apiSegment = '';
174
+ tenancyName = '';
175
+ storageKey = '';
176
+ secretKey = '';
177
+ companyCode = '';
178
+ buttonStyle;
179
+ }
180
+
181
+ class CoreConfigService {
182
+ configSignal = signal(new DoohbotInput(), ...(ngDevMode ? [{ debugName: "configSignal" }] : []));
183
+ config$ = this.configSignal.asReadonly();
184
+ /**
185
+ * Updates the global library configuration
186
+ */
187
+ updateConfig(config) {
188
+ this.configSignal.set(config);
189
+ }
190
+ /**
191
+ * Dynamic getters for common config properties
192
+ */
193
+ get apiUrl() {
194
+ const config = this.configSignal();
195
+ return `${config.apiBaseUrl}${config.apiSegment}`;
196
+ }
197
+ get storageKey() {
198
+ return this.configSignal().storageKey || '';
199
+ }
200
+ get secretKey() {
201
+ return this.configSignal().secretKey || '';
202
+ }
203
+ get companyCode() {
204
+ return this.configSignal().companyCode || '';
205
+ }
206
+ get tenancyName() {
207
+ return this.configSignal().tenancyName || '';
208
+ }
209
+ get licenseKey() {
210
+ return this.configSignal().licenseKey || '';
211
+ }
212
+ get filePath() {
213
+ return this.configSignal().filePath || './assets/const/doohclick_license.json';
214
+ }
215
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CoreConfigService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
216
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CoreConfigService, providedIn: 'root' });
217
+ }
218
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CoreConfigService, decorators: [{
219
+ type: Injectable,
220
+ args: [{
221
+ providedIn: 'root',
222
+ }]
223
+ }] });
224
+
234
225
  class StorageService {
235
- storageKey;
236
- secretKey;
226
+ coreConfig;
227
+ get storageKey() {
228
+ return this.coreConfig.storageKey;
229
+ }
230
+ get secretKey() {
231
+ return this.coreConfig.secretKey;
232
+ }
237
233
  storage;
238
- constructor() {
239
- this.storageKey = AppConst?.data?.storageKey || 'doohbot_storage';
240
- this.secretKey = AppConst?.data?.secretKey || 'doohbot_secret';
234
+ constructor(coreConfig) {
235
+ this.coreConfig = coreConfig;
241
236
  // Determine initial storage
242
237
  // If session storage has data, use it (implies remember me was false)
243
238
  // Otherwise default/fallback to local storage
@@ -324,7 +319,7 @@ class StorageService {
324
319
  return null;
325
320
  }
326
321
  }
327
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: StorageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
322
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: StorageService, deps: [{ token: CoreConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
328
323
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: StorageService, providedIn: 'root' });
329
324
  }
330
325
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: StorageService, decorators: [{
@@ -332,18 +327,21 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
332
327
  args: [{
333
328
  providedIn: 'root',
334
329
  }]
335
- }], ctorParameters: () => [] });
330
+ }], ctorParameters: () => [{ type: CoreConfigService }] });
336
331
 
337
332
  class HttpService {
338
333
  http;
339
334
  tokenStorage;
335
+ coreConfig;
340
336
  // @BlockUI() blockUI!: NgBlockUI;
341
- apiUrl;
342
- constructor(http, tokenStorage) {
337
+ get apiUrl() {
338
+ return this.coreConfig.apiUrl;
339
+ }
340
+ constructor(http, tokenStorage, coreConfig) {
343
341
  this.http = http;
344
342
  this.tokenStorage = tokenStorage;
345
- this.apiUrl = `${AppConst?.data?.apiBaseUrl}${AppConst?.data?.apiSegment}`;
346
- Logger.log('HttpService: Initialized', this.apiUrl);
343
+ this.coreConfig = coreConfig;
344
+ Logger.log('HttpService: Initialized');
347
345
  }
348
346
  get(url, param, nestedParam = false, showLoader = false, refresh = true, headers) {
349
347
  // if (showLoader && !this.blockUI.isActive) {
@@ -420,7 +418,7 @@ class HttpService {
420
418
  // }
421
419
  return value;
422
420
  }
423
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: HttpService, deps: [{ token: i1.HttpClient }, { token: StorageService }], target: i0.ɵɵFactoryTarget.Injectable });
421
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: HttpService, deps: [{ token: i1.HttpClient }, { token: StorageService }, { token: CoreConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
424
422
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: HttpService, providedIn: 'root' });
425
423
  }
426
424
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: HttpService, decorators: [{
@@ -428,7 +426,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
428
426
  args: [{
429
427
  providedIn: 'root',
430
428
  }]
431
- }], ctorParameters: () => [{ type: i1.HttpClient }, { type: StorageService }] });
429
+ }], ctorParameters: () => [{ type: i1.HttpClient }, { type: StorageService }, { type: CoreConfigService }] });
432
430
 
433
431
  class AccountService {
434
432
  http;
@@ -520,12 +518,21 @@ class AuthService {
520
518
  cryptoHelper;
521
519
  tokenStorage;
522
520
  router;
523
- apiUrl;
524
- storageKey;
525
- secretKey;
526
- companyCode;
521
+ coreConfig;
522
+ get apiUrl() {
523
+ return this.coreConfig.apiUrl;
524
+ }
525
+ get storageKey() {
526
+ return this.coreConfig.storageKey;
527
+ }
528
+ get secretKey() {
529
+ return this.coreConfig.secretKey;
530
+ }
531
+ get companyCode() {
532
+ return this.coreConfig.companyCode;
533
+ }
527
534
  jwtHelper = new JwtHelperService();
528
- config = inject(DOOHBOT_ADVANCED_CONFIG, { optional: true });
535
+ advancedConfig = inject(DOOHBOT_ADVANCED_CONFIG, { optional: true });
529
536
  // Reactive Authentication State
530
537
  authStatusSubject = new BehaviorSubject('unauthenticated');
531
538
  authStatus$ = this.authStatusSubject.asObservable();
@@ -533,16 +540,22 @@ class AuthService {
533
540
  isLoggingIn = signal(false, ...(ngDevMode ? [{ debugName: "isLoggingIn" }] : []));
534
541
  authError = signal(null, ...(ngDevMode ? [{ debugName: "authError" }] : []));
535
542
  authSuccess = signal(null, ...(ngDevMode ? [{ debugName: "authSuccess" }] : []));
536
- constructor(accountService, cryptoHelper, tokenStorage, router) {
543
+ constructor(accountService, cryptoHelper, tokenStorage, router, coreConfig) {
537
544
  this.accountService = accountService;
538
545
  this.cryptoHelper = cryptoHelper;
539
546
  this.tokenStorage = tokenStorage;
540
547
  this.router = router;
541
- this.apiUrl = `${AppConst?.data?.apiBaseUrl}${AppConst?.data?.apiSegment}`;
542
- this.storageKey = AppConst?.data?.storageKey;
543
- this.secretKey = AppConst?.data?.secretKey;
544
- this.companyCode = AppConst?.data?.companyCode;
545
- this.cryptoHelper.setSecretKey(this.secretKey);
548
+ this.coreConfig = coreConfig;
549
+ // Properties are now derived from coreConfig
550
+ }
551
+ /**
552
+ * Updates the service configuration from the component input
553
+ */
554
+ updateConfig(config) {
555
+ this.coreConfig.updateConfig(config);
556
+ if (config.secretKey) {
557
+ this.cryptoHelper.setSecretKey(config.secretKey);
558
+ }
546
559
  }
547
560
  getLoggedInUserName() {
548
561
  const username = this.tokenStorage.get('username');
@@ -567,32 +580,30 @@ class AuthService {
567
580
  * Resolves a federated token from browser storage
568
581
  */
569
582
  resolveSilentToken() {
570
- const configuredKey = this.config?.autoConfigFromStorage;
571
- // Try ABP official authentication API first
572
- if (window.abp?.auth?.getToken) {
573
- try {
574
- const abpToken = window.abp.auth.getToken();
575
- if (abpToken) {
576
- Logger.info(`[Auth] Resolved token from ABP auth service: ${abpToken}`);
577
- return abpToken;
578
- }
579
- Logger.debug('[Auth] ABP auth service returned no token');
580
- }
581
- catch (e) {
582
- Logger.error('[Auth] Error calling abp.auth.getToken():', e);
583
+ const config = this.coreConfig.config$();
584
+ const commonKeys = ['access_token', 'id_token', 'token', 'authToken'];
585
+ // 1. Try explicit authToken from config (Highest Priority)
586
+ if (config.authToken) {
587
+ Logger.info(`[Auth] Using explicit authToken from input`);
588
+ return config.authToken;
589
+ }
590
+ // 2. Try configured storage key from advanced config
591
+ if (this.advancedConfig?.autoConfigFromStorage) {
592
+ const key = this.advancedConfig.autoConfigFromStorage;
593
+ const token = localStorage.getItem(key) || sessionStorage.getItem(key);
594
+ if (token) {
595
+ Logger.debug(`[Auth] Resolved token from configured key: ${key}`);
596
+ return token;
583
597
  }
584
598
  }
585
- // Optional fallback: configured storage key
586
- if (configuredKey) {
587
- const token = localStorage.getItem(configuredKey) || sessionStorage.getItem(configuredKey);
599
+ // 3. Try common fallback keys
600
+ for (const key of commonKeys) {
601
+ const token = localStorage.getItem(key) || sessionStorage.getItem(key);
588
602
  if (token) {
589
- Logger.info(`[Auth] Resolved token from configured key: ${configuredKey}`);
603
+ Logger.debug(`[Auth] Resolved token from fallback key: ${key}`);
590
604
  return token;
591
605
  }
592
- Logger.debug(`[Auth] No token found at configured key: ${configuredKey}`);
593
606
  }
594
- // No token found
595
- Logger.debug('[Auth] No token could be resolved from ABP or configured storage');
596
607
  return null;
597
608
  }
598
609
  /**
@@ -832,7 +843,7 @@ class AuthService {
832
843
  };
833
844
  }
834
845
  get licenseKey() {
835
- return this.tokenStorage.get('license_key') || AppConst.data?.licenseKey || '';
846
+ return this.tokenStorage.get('license_key') || this.coreConfig.licenseKey || '';
836
847
  }
837
848
  get isFederated() {
838
849
  return this.licenseKey.startsWith('doohbot_lic_');
@@ -871,7 +882,7 @@ class AuthService {
871
882
  clearCache() {
872
883
  // this.cacheService.clear();
873
884
  }
874
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AuthService, deps: [{ token: AccountService }, { token: CryptoHelperService }, { token: StorageService }, { token: i4.Router }], target: i0.ɵɵFactoryTarget.Injectable });
885
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AuthService, deps: [{ token: AccountService }, { token: CryptoHelperService }, { token: StorageService }, { token: i4.Router }, { token: CoreConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
875
886
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AuthService, providedIn: 'root' });
876
887
  }
877
888
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AuthService, decorators: [{
@@ -879,7 +890,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
879
890
  args: [{
880
891
  providedIn: 'root',
881
892
  }]
882
- }], ctorParameters: () => [{ type: AccountService }, { type: CryptoHelperService }, { type: StorageService }, { type: i4.Router }] });
893
+ }], ctorParameters: () => [{ type: AccountService }, { type: CryptoHelperService }, { type: StorageService }, { type: i4.Router }, { type: CoreConfigService }] });
883
894
 
884
895
  const BASE_STORAGE_KEY = 'app.personalization.v1';
885
896
  const DEFAULT_SETTINGS = {
@@ -1251,16 +1262,6 @@ const SuggestedMessages = [
1251
1262
  'Quick tips to start.',
1252
1263
  ];
1253
1264
 
1254
- class DoohbotInput {
1255
- username = '';
1256
- password = '';
1257
- authToken;
1258
- license = '';
1259
- licenseCode = '';
1260
- licenseKey = '';
1261
- buttonStyle;
1262
- }
1263
-
1264
1265
  class ChatButtonComponent {
1265
1266
  buttonStyle = 'fab';
1266
1267
  isChatOpen = false;
@@ -2188,12 +2189,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
2188
2189
  class ChatApiService {
2189
2190
  http;
2190
2191
  httpStreamService;
2191
- apiUrl;
2192
+ get apiUrl() {
2193
+ return this.http.apiUrl;
2194
+ }
2192
2195
  constructor(http, httpStreamService) {
2193
2196
  this.http = http;
2194
2197
  this.httpStreamService = httpStreamService;
2195
- this.apiUrl = `${AppConst?.data?.apiBaseUrl}${AppConst?.data?.apiSegment}`;
2196
- Logger.log('ChatApiService: Initialized:', this.apiUrl);
2198
+ Logger.log('ChatApiService: Initialized');
2197
2199
  }
2198
2200
  /**
2199
2201
  * Send chat message and get full response
@@ -4197,17 +4199,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
4197
4199
 
4198
4200
  class LicenseService {
4199
4201
  http = inject(HttpClient);
4202
+ coreConfig = inject(CoreConfigService);
4200
4203
  registry = signal(null, ...(ngDevMode ? [{ debugName: "registry" }] : []));
4201
4204
  /**
4202
4205
  * Load the license configuration from a JSON file.
4203
4206
  * Supports both Hierarchical (entitlements) and Flat-map (package:key) formats.
4204
4207
  * @param filePath Path to the license JSON file
4205
4208
  */
4206
- async loadLicenseFile(filePath = './assets/const/doohclick_license.json') {
4209
+ async loadLicenseFile(filePath) {
4207
4210
  try {
4208
- // First try to check if there is a configured path in AppConst
4209
- const configuredPath = AppConst.data?.licenseFile;
4210
- const finalPath = configuredPath || filePath;
4211
+ const finalPath = filePath || this.coreConfig.filePath;
4211
4212
  const data = await firstValueFrom(this.http.get(finalPath));
4212
4213
  if (!data) {
4213
4214
  throw new Error('Empty license file');
@@ -4292,31 +4293,31 @@ class LicenseService {
4292
4293
  }
4293
4294
  /**
4294
4295
  * Resolves the license key for the current tenant.
4295
- * Auto-discovers tenant from URL or optional appBaseUrl pattern.
4296
- * Returns the key for 'doohbot' or null if not found.
4297
4296
  */
4298
- resolveTenantLicenseKey(appBaseUrl) {
4299
- // Attempt to resolve tenancy name using ABP utility
4300
- let tenancyName = null;
4301
- try {
4302
- tenancyName =
4303
- window.AppPreBootstrap?.resolveTenancyName(window.AppConsts?.appBaseUrl || appBaseUrl) ||
4304
- null;
4297
+ resolveTenantLicenseKey(tenancyName) {
4298
+ // Explicit tenancy name (param or coreConfig)
4299
+ const finalTenancyName = tenancyName || this.coreConfig.tenancyName;
4300
+ if (finalTenancyName) {
4301
+ Logger.info(`[LicenseService] Using tenancy name: ${finalTenancyName}`);
4302
+ tenancyName = finalTenancyName;
4305
4303
  }
4306
- catch (e) {
4307
- Logger.error('[LicenseService] Error resolving tenancy name:', e);
4304
+ else {
4305
+ Logger.error('[LicenseService] Error resolving tenancy name from globals:');
4308
4306
  }
4309
- Logger.info('[LicenseService] Detected tenancy name:', tenancyName);
4310
4307
  if (!tenancyName) {
4311
- Logger.log('[LicenseService] Could not resolve tenancy name.');
4308
+ Logger.warn('[LicenseService] Could not resolve tenancy name.');
4312
4309
  return null;
4313
4310
  }
4314
- Logger.info(`[LicenseService] Detected tenant: ${tenancyName}`);
4311
+ Logger.debug(`[LicenseService] Resolving license for tenant: ${tenancyName}`);
4315
4312
  // Lookup license key in registry
4316
- const tenantLicenses = this.registry()?.subjectLicenses.get(`tenant:${tenancyName}`);
4313
+ const reg = this.registry();
4314
+ if (!reg)
4315
+ return null;
4316
+ const tenantLicenses = reg.subjectLicenses.get(`tenant:${tenancyName}`);
4317
4317
  const licenseKey = tenantLicenses?.['doohbot'] || null;
4318
- if (licenseKey)
4319
- Logger.log(`[LicenseService] Found Doohbot license for tenant: ${tenancyName}`);
4318
+ if (licenseKey) {
4319
+ Logger.info(`[LicenseService] Found Doohbot license for tenant: ${tenancyName}`);
4320
+ }
4320
4321
  return licenseKey;
4321
4322
  }
4322
4323
  /**
@@ -4335,93 +4336,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
4335
4336
  }]
4336
4337
  }] });
4337
4338
 
4338
- class EnvironmentDiagnosticService {
4339
- /**
4340
- * Collects all diagnostic information from the environment.
4341
- */
4342
- getDiagnosticReport() {
4343
- const report = {
4344
- timestamp: new Date().toISOString(),
4345
- url: window.location.href,
4346
- storage: {
4347
- localStorage: this.getLocalStorage(),
4348
- sessionStorage: this.getSessionStorage(),
4349
- },
4350
- cookies: this.getCookies(),
4351
- abpContext: this.getAbpContext(),
4352
- };
4353
- Logger.info('[EnvironmentDiagnostic] Full Diagnostic Report:', report);
4354
- return report;
4355
- }
4356
- /**
4357
- * Retrieves all items from localStorage.
4358
- */
4359
- getLocalStorage() {
4360
- const result = {};
4361
- for (let i = 0; i < localStorage.length; i++) {
4362
- const key = localStorage.key(i);
4363
- if (key) {
4364
- result[key] = localStorage.getItem(key) || '';
4365
- }
4366
- }
4367
- Logger.info('[EnvironmentDiagnostic] LocalStorage:', result);
4368
- return result;
4369
- }
4370
- /**
4371
- * Retrieves all items from sessionStorage.
4372
- */
4373
- getSessionStorage() {
4374
- const result = {};
4375
- for (let i = 0; i < sessionStorage.length; i++) {
4376
- const key = sessionStorage.key(i);
4377
- if (key) {
4378
- result[key] = sessionStorage.getItem(key) || '';
4379
- }
4380
- }
4381
- Logger.info('[EnvironmentDiagnostic] SessionStorage:', result);
4382
- return result;
4383
- }
4384
- /**
4385
- * Parses and retrieves all cookies.
4386
- */
4387
- getCookies() {
4388
- const result = {};
4389
- const cookies = document.cookie.split(';');
4390
- for (let cookie of cookies) {
4391
- const [key, value] = cookie.trim().split('=');
4392
- if (key) {
4393
- result[key] = decodeURIComponent(value || '');
4394
- }
4395
- }
4396
- Logger.info('[EnvironmentDiagnostic] Cookies:', result);
4397
- return result;
4398
- }
4399
- /**
4400
- * Checks for ABP-specific global variables.
4401
- */
4402
- getAbpContext() {
4403
- const win = window;
4404
- const context = {
4405
- hasAbp: !!win.abp,
4406
- hasAppPreBootstrap: !!win.AppPreBootstrap,
4407
- hasAppConsts: !!win.AppConsts,
4408
- abpAuthToken: win.abp?.auth?.getToken ? 'FUNCTION_EXISTS' : 'NOT_FOUND',
4409
- appConstsAppBaseUrl: win.AppConsts?.appBaseUrl || 'NOT_FOUND',
4410
- tenancyName: win.AppPreBootstrap?.resolveTenancyName ? 'RESOLVER_EXISTS' : 'NOT_FOUND',
4411
- };
4412
- Logger.info('[EnvironmentDiagnostic] ABP Context:', context);
4413
- return context;
4414
- }
4415
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: EnvironmentDiagnosticService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4416
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: EnvironmentDiagnosticService, providedIn: 'root' });
4417
- }
4418
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: EnvironmentDiagnosticService, decorators: [{
4419
- type: Injectable,
4420
- args: [{
4421
- providedIn: 'root',
4422
- }]
4423
- }] });
4424
-
4425
4339
  class Doohbot extends DoohbotInput {
4426
4340
  elementRef;
4427
4341
  renderer;
@@ -4442,7 +4356,6 @@ class Doohbot extends DoohbotInput {
4442
4356
  snackbarService = inject(SnackbarService);
4443
4357
  personalization = inject(PersonalizationService);
4444
4358
  licenseService = inject(LicenseService);
4445
- diagnosticService = inject(EnvironmentDiagnosticService);
4446
4359
  //! ========================= EXPOSED STATE FROM SERVICES ============================
4447
4360
  // UI State signals
4448
4361
  isChatOpen = this.uiState.isChatOpen;
@@ -4502,8 +4415,6 @@ class Doohbot extends DoohbotInput {
4502
4415
  // Corrected structural integrity.
4503
4416
  ngOnInit() {
4504
4417
  Logger.log('Initializing Doohbot component...');
4505
- // Run diagnostics
4506
- this.diagnosticService.getDiagnosticReport();
4507
4418
  // Run validation once on startup
4508
4419
  this.authService.validateStoredToken().subscribe();
4509
4420
  // React to auth status changes
@@ -4548,6 +4459,7 @@ class Doohbot extends DoohbotInput {
4548
4459
  }
4549
4460
  // Handle config changes
4550
4461
  if (changes['config']) {
4462
+ this.authService.updateConfig(this.config);
4551
4463
  this.userAvatarUrl();
4552
4464
  this.updateUserName();
4553
4465
  if (this.config.licenseKey) {
@@ -4560,7 +4472,10 @@ class Doohbot extends DoohbotInput {
4560
4472
  }
4561
4473
  // Handle dynamic config updates for authentication
4562
4474
  if (!this.isAuthenticated()) {
4563
- this.onFederatedLogin(this.config.authToken);
4475
+ const token = this.config.authToken;
4476
+ if (token) {
4477
+ this.onFederatedLogin(token);
4478
+ }
4564
4479
  }
4565
4480
  }
4566
4481
  if (changes['buttonStyle'] && this.buttonStyle) {
@@ -4576,12 +4491,14 @@ class Doohbot extends DoohbotInput {
4576
4491
  //! ====================== AUTHENTICATION ==================
4577
4492
  // Logic moved to ChatFacadeService.initialize()
4578
4493
  onNormalLogin(credentials) {
4579
- // Try to resolve Key from Subdomain (Multi-tenant Auto-detect)
4580
- let autoKey = this.licenseService.resolveTenantLicenseKey();
4581
- // Fallback to Config Input (Manual/Single-tenant Override)
4582
- if (!autoKey) {
4583
- autoKey = this.config.licenseKey || '';
4584
- }
4494
+ // Try Tenancy Name from Config Input
4495
+ let tenancy = this.config.tenancyName;
4496
+ // fallback: Try to resolve from global utility (Auto-detect)
4497
+ if (!tenancy) {
4498
+ tenancy = window.AppPreBootstrap?.resolveTenancyName(window.AppConsts?.appBaseUrl);
4499
+ }
4500
+ // Resolve key from whatever tenancy we found
4501
+ let autoKey = this.licenseService.resolveTenantLicenseKey(tenancy || undefined);
4585
4502
  // Inject for strict validation
4586
4503
  if (autoKey) {
4587
4504
  credentials.license = autoKey;
@@ -4781,11 +4698,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
4781
4698
  type: ViewChild,
4782
4699
  args: [FullscreenDirective]
4783
4700
  }] } });
4784
- //! ================== INITIALIZATION =======================
4785
- function initializeApp() {
4786
- const appConst = inject(AppConst);
4787
- return () => appConst.load(); // Returns a function that returns a Promise
4788
- }
4789
4701
 
4790
4702
  /**
4791
4703
  * Injection token for providing Doohbot API configuration
@@ -4959,10 +4871,8 @@ class LicenseInterceptor {
4959
4871
  return next.handle(req);
4960
4872
  }
4961
4873
  // Determine if this is an internal API request
4962
- const apiBaseUrl = AppConst.data?.apiBaseUrl || '';
4963
- const apiSegment = AppConst.data?.apiSegment || '/api/';
4964
- const isInternalApi = req.url.includes(apiSegment) ||
4965
- (apiBaseUrl && req.url.startsWith(apiBaseUrl)) ||
4874
+ const apiUrl = authService.apiUrl;
4875
+ const isInternalApi = (apiUrl && req.url.startsWith(apiUrl)) ||
4966
4876
  (!req.url.startsWith('http') && !req.url.startsWith('assets/'));
4967
4877
  if (!isInternalApi) {
4968
4878
  return next.handle(req);
@@ -4986,20 +4896,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
4986
4896
  type: Injectable
4987
4897
  }], ctorParameters: () => [{ type: i0.Injector }] });
4988
4898
 
4989
- function initializeDoohbotApp() {
4990
- return () => {
4991
- const appConst = inject(AppConst);
4992
- return appConst.load();
4993
- };
4994
- }
4995
4899
  function provideDoohbot() {
4996
4900
  return makeEnvironmentProviders([
4997
- AppConst,
4998
- {
4999
- provide: APP_INITIALIZER,
5000
- useFactory: initializeDoohbotApp,
5001
- multi: true,
5002
- },
5003
4901
  provideHttpClient(withInterceptorsFromDi()),
5004
4902
  {
5005
4903
  provide: HTTP_INTERCEPTORS,
@@ -5044,5 +4942,5 @@ function provideDoohbot() {
5044
4942
  * Generated bundle index. Do not edit.
5045
4943
  */
5046
4944
 
5047
- export { Chips, DOOHBOT_API_CONFIG, DialogComponent, DialogService, Doohbot, DoohbotConst, DoohbotInput, DropdownMenu, EnvironmentDiagnosticService, MenuItem, SnackBar, initializeApp, initializeDoohbotApp, provideDoohbot };
4945
+ export { Chips, DOOHBOT_API_CONFIG, DialogComponent, DialogService, Doohbot, DoohbotConst, DoohbotInput, DropdownMenu, MenuItem, SnackBar, provideDoohbot };
5048
4946
  //# sourceMappingURL=aakash58-chatbot.mjs.map