@aakash58/chatbot 1.1.10 → 1.1.12

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.
@@ -4305,46 +4305,28 @@ class LicenseService {
4305
4305
  * Returns the key for 'doohbot' or null if not found.
4306
4306
  */
4307
4307
  resolveTenantLicenseKey(appBaseUrl) {
4308
- // Extract current URL parts
4309
- const hostname = window.location.hostname;
4310
- const protocol = window.location.protocol;
4311
- const port = window.location.port ? `:${window.location.port}` : '';
4312
- const currentUrl = `${protocol}//${hostname}${port}`;
4313
- // Use provided appBaseUrl or fallback to AppConst
4314
- const finalAppBaseUrl = appBaseUrl || AppConst.data?.appBaseUrl;
4315
- // Resolve tenancy name
4308
+ // Attempt to resolve tenancy name using ABP utility
4316
4309
  let tenancyName = null;
4317
- // Try extracting tenant from URL pattern if {TENANCY_NAME} is present
4318
- if (finalAppBaseUrl?.includes('{TENANCY_NAME}')) {
4319
- const pattern = finalAppBaseUrl.replace('{TENANCY_NAME}', '(.*?)');
4320
- const regex = new RegExp(pattern);
4321
- const match = currentUrl.match(regex);
4322
- tenancyName = match?.[1] ?? null;
4310
+ try {
4311
+ tenancyName =
4312
+ window.AppPreBootstrap?.resolveTenancyName(window.AppConsts?.appBaseUrl || appBaseUrl) ||
4313
+ null;
4323
4314
  }
4324
- if (!tenancyName) {
4325
- // use first subdomain part as tenancy name
4326
- const parts = hostname.split('.');
4327
- if (parts.length > 2)
4328
- tenancyName = parts[0];
4315
+ catch (e) {
4316
+ Logger.error('[LicenseService] Error resolving tenancy name:', e);
4329
4317
  }
4330
- // If still not resolved, log and exit
4318
+ Logger.info('[LicenseService] Detected tenancy name:', tenancyName);
4331
4319
  if (!tenancyName) {
4332
4320
  Logger.log('[LicenseService] Could not resolve tenancy name.');
4333
4321
  return null;
4334
4322
  }
4335
- Logger.log(`[LicenseService] Detected tenant: ${tenancyName}`);
4336
- // Lookup license key in registry ===
4337
- const reg = this.registry();
4338
- if (!reg)
4339
- return null;
4340
- const searchKey = `tenant:${tenancyName}`;
4341
- const tenantLicenses = reg.subjectLicenses.get(searchKey);
4342
- // Return the 'doohbot' license if it exists
4343
- if (tenantLicenses?.['doohbot']) {
4344
- Logger.log(`[LicenseService] Found key for tenant: ${tenancyName}`);
4345
- return tenantLicenses['doohbot'];
4346
- }
4347
- return null;
4323
+ Logger.info(`[LicenseService] Detected tenant: ${tenancyName}`);
4324
+ // Lookup license key in registry
4325
+ const tenantLicenses = this.registry()?.subjectLicenses.get(`tenant:${tenancyName}`);
4326
+ const licenseKey = tenantLicenses?.['doohbot'] || null;
4327
+ if (licenseKey)
4328
+ Logger.log(`[LicenseService] Found Doohbot license for tenant: ${tenancyName}`);
4329
+ return licenseKey;
4348
4330
  }
4349
4331
  /**
4350
4332
  * Check if a registry is currently loaded