common-header-lib 0.0.19 → 0.0.20

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.
@@ -1026,6 +1026,23 @@ class HttpCommonService {
1026
1026
  }
1027
1027
  }), catchError$1((e) => throwError(this.errorHandler(e))));
1028
1028
  }
1029
+ //Method: Open the OAuth connection window for the given application
1030
+ openAppConnection(appCode) {
1031
+ const url = GlobalConstants.baseURL + '/xauth/api/Token/AppOAuth?appcode=' + appCode;
1032
+ window.open(url, '_blank');
1033
+ }
1034
+ //Method: Validate MFA / SAML configuration before establishing the APP032 connection
1035
+ checkMFAConfiguration() {
1036
+ return this.http
1037
+ .get(`${GlobalConstants.baseURL}/xaccess/api/Token/getMfaSamlConfig`)
1038
+ .pipe(catchError$1((e) => throwError(this.errorHandler(e))));
1039
+ }
1040
+ //Method: Validate internal SAML app configuration before establishing the connection (e.g. APP033)
1041
+ getInternalAppConfig(appCode) {
1042
+ return this.http
1043
+ .get(`${GlobalConstants.baseURL}/xaccess/api/Token/getInternalAppConfig?appCode=${appCode}`)
1044
+ .pipe(catchError$1((e) => throwError(this.errorHandler(e))));
1045
+ }
1029
1046
  }
1030
1047
  HttpCommonService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HttpCommonService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
1031
1048
  HttpCommonService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: HttpCommonService, providedIn: 'root' });
@@ -3446,6 +3463,17 @@ class CommonHeaderLibComponent {
3446
3463
  this.isErrorOccured = false;
3447
3464
  // @Output() public refreshNotification = new EventEmitter<boolean>();
3448
3465
  this.repeatLoader1 = new Array(9).fill(0);
3466
+ // Mapping of app codes to their pre-connection validation checks.
3467
+ // Apps not listed here open the connection directly without a config check.
3468
+ this.APP_CONNECTION_CHECKS = {
3469
+ APP032: {
3470
+ check: () => this.httpCommonService.checkMFAConfiguration(),
3471
+ },
3472
+ APP033: {
3473
+ // Backend expects the lowercase app code (mirrors Workflow_UI MR !287)
3474
+ check: () => this.httpCommonService.getInternalAppConfig('app033'),
3475
+ },
3476
+ };
3449
3477
  this.setWebAPIURL();
3450
3478
  }
3451
3479
  ngOnChanges(changes) {
@@ -3503,8 +3531,31 @@ class CommonHeaderLibComponent {
3503
3531
  }
3504
3532
  //Method: Take Connection of Application
3505
3533
  getConnectionofApplication(appCode) {
3506
- const url = GlobalConstants.baseURL + '/xauth/api/Token/AppOAuth?appcode=' + appCode;
3507
- window.open(url, '_blank');
3534
+ // Close the apps (9-dots) overlay panel immediately on selection.
3535
+ this.appPanel?.hide();
3536
+ const appCheck = this.APP_CONNECTION_CHECKS[appCode];
3537
+ const commonError = 'Unable to verify the application configuration.';
3538
+ // Apps without a configured check connect directly.
3539
+ if (!appCheck) {
3540
+ this.httpCommonService.openAppConnection(appCode);
3541
+ return;
3542
+ }
3543
+ appCheck
3544
+ .check()
3545
+ .pipe(takeUntil(this.unsubscribeAPIEventListenerData))
3546
+ .subscribe({
3547
+ next: (response) => {
3548
+ if (response?.isValid) {
3549
+ this.httpCommonService.openAppConnection(appCode);
3550
+ }
3551
+ else {
3552
+ this.msgService.error(response?.errorMessage || commonError);
3553
+ }
3554
+ },
3555
+ error: () => {
3556
+ this.msgService.error(commonError);
3557
+ },
3558
+ });
3508
3559
  }
3509
3560
  async getConnectToSingalRhub() {
3510
3561
  try {