@bnsights/bbsf-utilities 1.0.65 → 1.0.66

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,19 +1,21 @@
1
- import { CommonModule, DOCUMENT } from '@angular/common';
2
- import * as i1$1 from '@angular/common/http';
3
- import { HttpClientModule, HttpHeaders, HttpParams, HttpErrorResponse } from '@angular/common/http';
1
+ import { DOCUMENT, CommonModule } from '@angular/common';
4
2
  import * as i0 from '@angular/core';
5
- import { NgModule, Injectable, inject, Inject } from '@angular/core';
6
- import * as i3 from '@angular/router';
7
- import { RouterModule, Router } from '@angular/router';
8
- import * as i1 from 'ng-block-ui';
9
- import { BlockUIModule, BlockUI } from 'ng-block-ui';
10
- import { provideToastr, ToastrService } from 'ngx-toastr';
11
- import { __decorate } from 'tslib';
12
- import { BehaviorSubject, Subject, throwError, Observable, lastValueFrom } from 'rxjs';
13
- import { JwtHelperService } from '@auth0/angular-jwt';
14
- import * as i4 from 'ngx-cookie-service';
15
- import * as i4$1 from '@ngx-translate/core';
3
+ import { Injectable, Inject, inject, NgModule } from '@angular/core';
4
+ import * as i1$1 from '@angular/router';
5
+ import { RouterModule } from '@angular/router';
6
+ import * as i4 from '@ngx-translate/core';
16
7
  import { TranslateService } from '@ngx-translate/core';
8
+ import * as i1$2 from 'ng-block-ui';
9
+ import { BlockUI, BlockUIModule } from 'ng-block-ui';
10
+ import * as i2 from 'ngx-toastr';
11
+ import { ToastrService, ToastrModule } from 'ngx-toastr';
12
+ import * as i4$1 from 'ngx-cookie-service';
13
+ import { CookieService } from 'ngx-cookie-service';
14
+ import * as i1 from '@angular/common/http';
15
+ import { HttpParams, HttpErrorResponse, HttpHeaders } from '@angular/common/http';
16
+ import { Subject, throwError, Observable, lastValueFrom, BehaviorSubject } from 'rxjs';
17
+ import { JwtHelperService } from '@auth0/angular-jwt';
18
+ import { __decorate } from 'tslib';
17
19
  import { plainToClass } from 'class-transformer';
18
20
  import { takeUntil, tap, map } from 'rxjs/operators';
19
21
  import JSZip from 'jszip';
@@ -31,33 +33,16 @@ import imageToBase64 from 'image-to-base64';
31
33
  import mimeTypes from 'mime-types';
32
34
  import sizeOf from 'image-size';
33
35
 
34
- class BBSFUtilitiesModule {
35
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: BBSFUtilitiesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
36
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.6", ngImport: i0, type: BBSFUtilitiesModule, imports: [CommonModule,
37
- RouterModule, i1.BlockUIModule, HttpClientModule] }); }
38
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: BBSFUtilitiesModule, providers: [
39
- provideToastr(),
40
- ], imports: [CommonModule,
41
- RouterModule,
42
- BlockUIModule.forRoot(),
43
- HttpClientModule] }); }
36
+ class User {
44
37
  }
45
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: BBSFUtilitiesModule, decorators: [{
46
- type: NgModule,
47
- args: [{
48
- declarations: [],
49
- imports: [
50
- CommonModule,
51
- RouterModule,
52
- BlockUIModule.forRoot(),
53
- HttpClientModule
54
- ],
55
- exports: [],
56
- providers: [
57
- provideToastr(),
58
- ]
59
- }]
60
- }] });
38
+
39
+ var AuthenticationModes;
40
+ (function (AuthenticationModes) {
41
+ AuthenticationModes["Forms"] = "Forms";
42
+ AuthenticationModes["UAEPass"] = "UAEPass";
43
+ AuthenticationModes["WindowsAD"] = "WindowsAD";
44
+ AuthenticationModes["AzureAD"] = "AzureAD";
45
+ })(AuthenticationModes || (AuthenticationModes = {}));
61
46
 
62
47
  class AppearanceConfigurationService {
63
48
  constructor(configService) {
@@ -81,251 +66,16 @@ class AppearanceConfigurationService {
81
66
  getLogo() {
82
67
  return this.configService.getConfigurationValue('AnonymousLayout_Logo');
83
68
  }
84
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: AppearanceConfigurationService, deps: [{ token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable }); }
85
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: AppearanceConfigurationService, providedIn: 'root' }); }
69
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AppearanceConfigurationService, deps: [{ token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable }); }
70
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AppearanceConfigurationService, providedIn: 'root' }); }
86
71
  }
87
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: AppearanceConfigurationService, decorators: [{
72
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AppearanceConfigurationService, decorators: [{
88
73
  type: Injectable,
89
74
  args: [{
90
75
  providedIn: 'root'
91
76
  }]
92
77
  }], ctorParameters: () => [{ type: ConfigurationService }] });
93
78
 
94
- class User {
95
- }
96
-
97
- var AuthenticationModes;
98
- (function (AuthenticationModes) {
99
- AuthenticationModes["Forms"] = "Forms";
100
- AuthenticationModes["UAEPass"] = "UAEPass";
101
- AuthenticationModes["WindowsAD"] = "WindowsAD";
102
- AuthenticationModes["AzureAD"] = "AzureAD";
103
- })(AuthenticationModes || (AuthenticationModes = {}));
104
-
105
- const TOKEN_KEY = 'access_token';
106
- class AuthService {
107
- static { this.user = null; }
108
- static { this.UserClaims = null; }
109
- //refresh
110
- static { this.timers = []; }
111
- static { this.seconds = 0; }
112
- constructor(injector, http, environmentService, translateService, router, cookieService, utilityService) {
113
- this.injector = injector;
114
- this.http = http;
115
- this.environmentService = environmentService;
116
- this.translateService = translateService;
117
- this.router = router;
118
- this.cookieService = cookieService;
119
- this.utilityService = utilityService;
120
- this.redirectUrl = '';
121
- this.jwtHelper = new JwtHelperService();
122
- this.isAuthenticatedSubject = new BehaviorSubject(this.hasToken());
123
- this.isAuthenticate$ = this.isAuthenticatedSubject.asObservable();
124
- this.user = this.getUserManager();
125
- }
126
- hasToken() {
127
- const token = this.cookieService.get(TOKEN_KEY);
128
- return token && !this.jwtHelper.isTokenExpired(token);
129
- }
130
- getUserManager() {
131
- const token = this.cookieService.get(TOKEN_KEY);
132
- if (token) {
133
- if (!this.jwtHelper.isTokenExpired(token))
134
- this.handleAccessTokenWithoutLanguage(token);
135
- else
136
- this.cookieService.delete(TOKEN_KEY, '/');
137
- }
138
- else {
139
- AuthService.timers.map(t => clearInterval(t));
140
- AuthService.timers = [];
141
- AuthService.user = null;
142
- this.user = null;
143
- }
144
- return AuthService.user;
145
- }
146
- getUser() {
147
- this.user = AuthService.user;
148
- }
149
- storUser(User) {
150
- AuthService.user = this.user = this.user;
151
- }
152
- getCurrentUser() {
153
- return AuthService.user;
154
- }
155
- isAuthenticated() {
156
- return AuthService.user != null && !this.jwtHelper.isTokenExpired(AuthService.user.access_token);
157
- }
158
- isUserInRole(allowedPermission) {
159
- let selectedPermissionSetID = Number.parseInt(AuthService.user.profile['selectedpermissionsetid']);
160
- return allowedPermission.includes(selectedPermissionSetID);
161
- }
162
- authorizationHeaderValue() {
163
- return AuthService.user
164
- ? `${AuthService.user.token_type} ${AuthService.user.access_token}`
165
- : '';
166
- }
167
- name() {
168
- return AuthService.user != null ? AuthService.user.profile.given_name : '';
169
- }
170
- setUrl(url) {
171
- localStorage.setItem('redirectUrl', url);
172
- }
173
- getUrl() {
174
- return localStorage.getItem('redirectUrl') ?? "/";
175
- }
176
- signOut() {
177
- let isAuthenticated = this.isAuthenticated();
178
- this.cookieService.delete(TOKEN_KEY, '/');
179
- AuthService.timers.map(t => clearInterval(t));
180
- AuthService.timers = [];
181
- AuthService.user = null;
182
- this.user = null;
183
- localStorage.removeItem("redirectUrl");
184
- if (isAuthenticated) {
185
- this.logout().subscribe(res => {
186
- if (this.environmentService.getBBSFAuthenticationMode() == AuthenticationModes.UAEPass)
187
- this.logoutFromUAEPass();
188
- else
189
- this.router.navigate(['/Admin/account/login']);
190
- });
191
- }
192
- else {
193
- if (this.environmentService.getBBSFAuthenticationMode() == AuthenticationModes.UAEPass)
194
- this.logoutFromUAEPass();
195
- else
196
- this.router.navigate(['/Admin/account/login']);
197
- }
198
- }
199
- logout() {
200
- const httpOptions = {
201
- headers: new HttpHeaders({
202
- 'Content-Type': 'application/json',
203
- }),
204
- };
205
- let ApiUrl = '/Account/';
206
- return this.http.get(this.environmentService.getApiUrl() + ApiUrl + 'Logout', httpOptions);
207
- }
208
- clearUserSessionClaims() {
209
- const httpOptions = {
210
- headers: new HttpHeaders({
211
- 'Content-Type': 'application/json',
212
- }),
213
- };
214
- let ApiUrl = '/api/Home/';
215
- return this.http.get(this.environmentService.getBaseUrl() + ApiUrl + 'ClearCurrentUserSession', httpOptions);
216
- }
217
- async handleAccessToken(response) {
218
- this.cookieService.delete(TOKEN_KEY, '/');
219
- const token = response;
220
- AuthService.user = null;
221
- AuthService.user = new User();
222
- AuthService.user.token_type = "Bearer";
223
- AuthService.user.access_token = token;
224
- AuthService.user.profile = this.jwtHelper.decodeToken(token);
225
- AuthService.user.expires_at = this.jwtHelper.getTokenExpirationDate(token);
226
- this.user = AuthService.user;
227
- localStorage.setItem("language", AuthService.user.profile.locale);
228
- this.cookieService.set(TOKEN_KEY, token, AuthService.user.expires_at, "/", null, true, 'Lax');
229
- this.isAuthenticatedSubject.next(true);
230
- this.setTokenSeconds();
231
- AuthService.timers.push(this.checkRefreshToken());
232
- await this.updateLanguage();
233
- }
234
- handleAccessTokenWithoutLanguage(response) {
235
- this.cookieService.delete(TOKEN_KEY, '/');
236
- const token = response;
237
- AuthService.user = null;
238
- AuthService.user = new User();
239
- AuthService.user.token_type = "Bearer";
240
- AuthService.user.access_token = token;
241
- AuthService.user.profile = this.jwtHelper.decodeToken(token);
242
- AuthService.user.expires_at = this.jwtHelper.getTokenExpirationDate(token);
243
- this.setTokenSeconds();
244
- this.user = AuthService.user;
245
- localStorage.setItem("language", AuthService.user.profile.locale);
246
- this.cookieService.set(TOKEN_KEY, token, AuthService.user.expires_at, "/", null, true, 'Lax');
247
- this.isAuthenticatedSubject.next(true);
248
- AuthService.timers.push(this.checkRefreshToken());
249
- }
250
- async updateLanguage() {
251
- if (!localStorage.getItem('language') || localStorage.getItem('language') == this.user.profile.locale)
252
- localStorage.setItem('language', this.user.profile.locale);
253
- if (this.translateService.currentLang != localStorage.getItem('language')) {
254
- this.translateService.resetLang(this.translateService.currentLang);
255
- await this.translateService.reloadLang(localStorage.getItem('language')).subscribe();
256
- }
257
- }
258
- checkRefreshToken() {
259
- let date = new Date();
260
- return setInterval(() => {
261
- if (Math.floor(AuthService.seconds) < 120 && this.isAuthenticated()) {
262
- AuthService.timers.map(t => clearInterval(t));
263
- AuthService.timers = [];
264
- const token = this.cookieService.get(TOKEN_KEY);
265
- if (token) {
266
- this.refresh();
267
- }
268
- }
269
- AuthService.seconds--;
270
- }, 1000);
271
- }
272
- setTokenSeconds() {
273
- let date = new Date();
274
- AuthService.seconds = (AuthService.user.expires_at - date) / 1000;
275
- }
276
- refresh() {
277
- this.cookieService.delete(TOKEN_KEY, '/');
278
- const httpOptions = {
279
- headers: new HttpHeaders({
280
- 'Content-Type': 'application/json',
281
- 'Authorization': this.authorizationHeaderValue(),
282
- }),
283
- };
284
- let ApiUrl = '/api/Home/';
285
- this.http.get(this.environmentService.getApiUrl() + ApiUrl + 'RefreshAccessToken', httpOptions).subscribe((res) => {
286
- this.handleAccessTokenWithoutLanguage(res.val);
287
- });
288
- }
289
- loginWithUAEPass() {
290
- const authEndpoint = `${this.environmentService.getUAEPassBaseUrl()}${this.environmentService.getUAEPassAuthorizationEndPoint()}`;
291
- const queryParams = {
292
- response_type: 'code',
293
- client_id: `${this.environmentService.getUAEPassClientID()}`,
294
- redirect_uri: `${this.environmentService.getBaseUrl()}${this.environmentService.getUAEPassRedirectUrl()}`,
295
- scope: 'urn:uae:digitalid:profile:general urn:uae:digitalid:profile:general:profileType urn:uae:digitalid:profile:general:unifiedId',
296
- state: this.translateService.currentLang,
297
- acr_values: 'urn:safelayer:tws:policies:authentication:level:low',
298
- ui_locales: this.translateService.currentLang,
299
- };
300
- const queryParamsString = Object.entries(queryParams)
301
- .map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
302
- .join('&');
303
- const loginUrl = `${authEndpoint}?${queryParamsString}`;
304
- window.location.href = loginUrl;
305
- return;
306
- }
307
- logoutFromUAEPass() {
308
- const logoutEndpoint = `${this.environmentService.getUAEPassBaseUrl()}${this.environmentService.getUAEPassLogoutEndPoint()}`;
309
- const queryParams = {
310
- redirect_uri: `${this.environmentService.getBaseUrl()}`,
311
- };
312
- const queryParamsString = Object.entries(queryParams)
313
- .map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
314
- .join('&');
315
- const logoutUrl = `${logoutEndpoint}?${queryParamsString}`;
316
- window.location.href = logoutUrl;
317
- return;
318
- }
319
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: AuthService, deps: [{ token: i0.Injector }, { token: i1$1.HttpClient }, { token: EnvironmentService }, { token: BBSFTranslateService }, { token: i3.Router }, { token: i4.CookieService }, { token: UtilityService }], target: i0.ɵɵFactoryTarget.Injectable }); }
320
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: AuthService, providedIn: 'root' }); }
321
- }
322
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: AuthService, decorators: [{
323
- type: Injectable,
324
- args: [{
325
- providedIn: 'root',
326
- }]
327
- }], ctorParameters: () => [{ type: i0.Injector }, { type: i1$1.HttpClient }, { type: EnvironmentService }, { type: BBSFTranslateService }, { type: i3.Router }, { type: i4.CookieService }, { type: UtilityService }] });
328
-
329
79
  class ConfigurationService {
330
80
  static { this.JsonData = []; }
331
81
  constructor(httpClient, authService) {
@@ -354,15 +104,15 @@ class ConfigurationService {
354
104
  return selectedKey;
355
105
  }
356
106
  }
357
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: ConfigurationService, deps: [{ token: i1$1.HttpClient }, { token: AuthService }], target: i0.ɵɵFactoryTarget.Injectable }); }
358
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: ConfigurationService, providedIn: 'root' }); }
107
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ConfigurationService, deps: [{ token: i1.HttpClient }, { token: AuthService }], target: i0.ɵɵFactoryTarget.Injectable }); }
108
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ConfigurationService, providedIn: 'root' }); }
359
109
  }
360
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: ConfigurationService, decorators: [{
110
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ConfigurationService, decorators: [{
361
111
  type: Injectable,
362
112
  args: [{
363
113
  providedIn: 'root'
364
114
  }]
365
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: AuthService }] });
115
+ }], ctorParameters: () => [{ type: i1.HttpClient }, { type: AuthService }] });
366
116
 
367
117
  class AreaModel {
368
118
  }
@@ -546,13 +296,13 @@ class ControlValidationService {
546
296
  let control = form.get(controlName);
547
297
  return control;
548
298
  }
549
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: ControlValidationService, deps: [{ token: UtilityService }], target: i0.ɵɵFactoryTarget.Injectable }); }
550
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: ControlValidationService, providedIn: 'root' }); }
299
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ControlValidationService, deps: [{ token: UtilityService }], target: i0.ɵɵFactoryTarget.Injectable }); }
300
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ControlValidationService, providedIn: 'root' }); }
551
301
  }
552
302
  __decorate([
553
303
  BlockUI()
554
304
  ], ControlValidationService.prototype, "blockUI", void 0);
555
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: ControlValidationService, decorators: [{
305
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ControlValidationService, decorators: [{
556
306
  type: Injectable,
557
307
  args: [{
558
308
  providedIn: 'root'
@@ -637,10 +387,17 @@ class EnvironmentService {
637
387
  let mode = environment["BBSF_AllowMultiTenancy"];
638
388
  return mode.toLocaleLowerCase() == 'true';
639
389
  }
640
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: EnvironmentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
641
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: EnvironmentService, providedIn: 'root' }); }
390
+ getCookieName() {
391
+ let cookieName = environment["BBSF_CookieName"];
392
+ if (!cookieName || cookieName == '') {
393
+ cookieName = 'access_token';
394
+ }
395
+ return cookieName;
396
+ }
397
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EnvironmentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
398
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EnvironmentService, providedIn: 'root' }); }
642
399
  }
643
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: EnvironmentService, decorators: [{
400
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: EnvironmentService, decorators: [{
644
401
  type: Injectable,
645
402
  args: [{
646
403
  providedIn: 'root'
@@ -706,27 +463,27 @@ class MasterLayoutService {
706
463
  params = params.append('RoleID', permissionSetID);
707
464
  return this.http.post(this.apiUrl + 'SwitchRole', null, null, params);
708
465
  }
709
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: MasterLayoutService, deps: [{ token: i3.Router }, { token: RequestHandlerService }, { token: AuthService }, { token: StylesBundleService }, { token: i4$1.TranslateService }, { token: EnvironmentService }], target: i0.ɵɵFactoryTarget.Injectable }); }
710
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: MasterLayoutService, providedIn: 'root' }); }
466
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MasterLayoutService, deps: [{ token: i1$1.Router }, { token: RequestHandlerService }, { token: AuthService }, { token: StylesBundleService }, { token: i4.TranslateService }, { token: EnvironmentService }], target: i0.ɵɵFactoryTarget.Injectable }); }
467
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MasterLayoutService, providedIn: 'root' }); }
711
468
  }
712
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: MasterLayoutService, decorators: [{
469
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: MasterLayoutService, decorators: [{
713
470
  type: Injectable,
714
471
  args: [{
715
472
  providedIn: 'root',
716
473
  }]
717
- }], ctorParameters: () => [{ type: i3.Router }, { type: RequestHandlerService }, { type: AuthService }, { type: StylesBundleService }, { type: i4$1.TranslateService }, { type: EnvironmentService }] });
474
+ }], ctorParameters: () => [{ type: i1$1.Router }, { type: RequestHandlerService }, { type: AuthService }, { type: StylesBundleService }, { type: i4.TranslateService }, { type: EnvironmentService }] });
718
475
 
719
476
  class RequestHandlerService {
720
- constructor(http, authService, environmentService, utilityService, bbsfTranslateService) {
477
+ constructor(http, authService, environmentService, utilityService, bbsfTranslateService, router) {
721
478
  this.http = http;
722
479
  this.authService = authService;
723
480
  this.environmentService = environmentService;
724
481
  this.utilityService = utilityService;
725
482
  this.bbsfTranslateService = bbsfTranslateService;
483
+ this.router = router;
726
484
  this.requestOptions = new RequestOptionsModel();
727
485
  this.currentLanguage = "";
728
486
  this.onDestroy$ = new Subject();
729
- this.router = inject(Router);
730
487
  //using localStorage to avoid call getCurrentLanguage() because it is not all to use async in constructor
731
488
  this.bbsfTranslateService.onLangChange.subscribe((event) => {
732
489
  if (this.currentLanguage != event.lang) {
@@ -964,15 +721,12 @@ class RequestHandlerService {
964
721
  'Image-Upload': 'true',
965
722
  });
966
723
  }
967
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: RequestHandlerService, deps: [{ token: i1$1.HttpClient }, { token: AuthService }, { token: EnvironmentService }, { token: UtilityService }, { token: BBSFTranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
968
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: RequestHandlerService, providedIn: 'root' }); }
724
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: RequestHandlerService, deps: [{ token: i1.HttpClient }, { token: AuthService }, { token: EnvironmentService }, { token: UtilityService }, { token: BBSFTranslateService }, { token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable }); }
725
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: RequestHandlerService }); }
969
726
  }
970
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: RequestHandlerService, decorators: [{
971
- type: Injectable,
972
- args: [{
973
- providedIn: 'root',
974
- }]
975
- }], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: AuthService }, { type: EnvironmentService }, { type: UtilityService }, { type: BBSFTranslateService }] });
727
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: RequestHandlerService, decorators: [{
728
+ type: Injectable
729
+ }], ctorParameters: () => [{ type: i1.HttpClient }, { type: AuthService }, { type: EnvironmentService }, { type: UtilityService }, { type: BBSFTranslateService }, { type: i1$1.Router }] });
976
730
 
977
731
  class StylesBundleService {
978
732
  constructor(document, translateService) {
@@ -1012,10 +766,10 @@ class StylesBundleService {
1012
766
  style.href = `${styleName}`;
1013
767
  head.appendChild(style);
1014
768
  }
1015
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: StylesBundleService, deps: [{ token: DOCUMENT }, { token: BBSFTranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1016
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: StylesBundleService, providedIn: 'root' }); }
769
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: StylesBundleService, deps: [{ token: DOCUMENT }, { token: BBSFTranslateService }], target: i0.ɵɵFactoryTarget.Injectable }); }
770
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: StylesBundleService, providedIn: 'root' }); }
1017
771
  }
1018
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: StylesBundleService, decorators: [{
772
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: StylesBundleService, decorators: [{
1019
773
  type: Injectable,
1020
774
  args: [{
1021
775
  providedIn: 'root'
@@ -1026,10 +780,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImpor
1026
780
  }] }, { type: BBSFTranslateService }] });
1027
781
 
1028
782
  class BBSFTranslateService extends TranslateService {
1029
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: BBSFTranslateService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
1030
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: BBSFTranslateService, providedIn: 'root' }); }
783
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BBSFTranslateService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
784
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BBSFTranslateService, providedIn: 'root' }); }
1031
785
  }
1032
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: BBSFTranslateService, decorators: [{
786
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BBSFTranslateService, decorators: [{
1033
787
  type: Injectable,
1034
788
  args: [{
1035
789
  providedIn: 'root'
@@ -1041,6 +795,87 @@ const TranslationResolverService = () => {
1041
795
  return translateService.getTranslation(translateService.currentLang);
1042
796
  };
1043
797
 
798
+ class UtilityService {
799
+ constructor(translator, environmentService, injector) {
800
+ this.translator = translator;
801
+ this.environmentService = environmentService;
802
+ this.injector = injector;
803
+ this.isCreatedBefore = false;
804
+ }
805
+ getResourceValue(Key) {
806
+ let ResourceValue = this.translator.instant(Key);
807
+ return ResourceValue;
808
+ }
809
+ getCurrentLanguage() {
810
+ let currentLanguage = this.environmentService.getDefaultLanguage();
811
+ let lang = localStorage.getItem('language');
812
+ if (lang)
813
+ currentLanguage = lang;
814
+ else
815
+ localStorage.setItem('language', currentLanguage);
816
+ return currentLanguage;
817
+ }
818
+ isCurrentLanguageEnglish() {
819
+ return this.getCurrentLanguage() == "en";
820
+ }
821
+ isCurrentLanguageArabic() {
822
+ return this.getCurrentLanguage() == "ar";
823
+ }
824
+ notifySuccessMessage(Message, title, time, showHeader = true) {
825
+ let MessageTemplate = this.getResourceValue("SuccessMessage");
826
+ let titleTemplate;
827
+ if (Message) {
828
+ MessageTemplate = Message;
829
+ }
830
+ if (title) {
831
+ titleTemplate = title;
832
+ }
833
+ let toaster = this.injector.get(ToastrService);
834
+ showHeader ? toaster.success(MessageTemplate, titleTemplate) : toaster.success(MessageTemplate);
835
+ }
836
+ notifyErrorMessage(Message, title, time, showHeader = true) {
837
+ let MessageTemplate = this.getResourceValue("ErrorMessage");
838
+ let titleTemplate = this.getResourceValue("Error");
839
+ if (Message) {
840
+ MessageTemplate = Message;
841
+ }
842
+ if (title) {
843
+ titleTemplate = title;
844
+ }
845
+ const toaster = this.injector.get(ToastrService);
846
+ showHeader ? toaster.error(MessageTemplate, titleTemplate) : toaster.error(MessageTemplate);
847
+ }
848
+ notifyWarningMessage(Message, title, time, showHeader = true) {
849
+ let MessageTemplate = this.getResourceValue("WarningMessage");
850
+ let titleTemplate = this.getResourceValue("Warning");
851
+ if (Message) {
852
+ MessageTemplate = Message;
853
+ }
854
+ if (title) {
855
+ titleTemplate = title;
856
+ }
857
+ const toaster = this.injector.get(ToastrService);
858
+ showHeader ? toaster.warning(MessageTemplate, titleTemplate) : toaster.warning(MessageTemplate);
859
+ }
860
+ startBlockUI() {
861
+ this.blockUI.start();
862
+ }
863
+ stopBlockUI() {
864
+ this.blockUI.stop();
865
+ }
866
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: UtilityService, deps: [{ token: BBSFTranslateService }, { token: EnvironmentService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
867
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: UtilityService, providedIn: 'root' }); }
868
+ }
869
+ __decorate([
870
+ BlockUI()
871
+ ], UtilityService.prototype, "blockUI", void 0);
872
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: UtilityService, decorators: [{
873
+ type: Injectable,
874
+ args: [{
875
+ providedIn: 'root'
876
+ }]
877
+ }], ctorParameters: () => [{ type: BBSFTranslateService }, { type: EnvironmentService }, { type: i0.Injector }], propDecorators: { blockUI: [] } });
878
+
1044
879
  const contentTypesXML = `
1045
880
  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1046
881
 
@@ -4585,10 +4420,10 @@ class WordDocumentService {
4585
4420
  var fileBuffer = await generateContainer(model.body, model.header, documentOptions, model.footer);
4586
4421
  return fileBuffer;
4587
4422
  }
4588
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: WordDocumentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4589
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: WordDocumentService, providedIn: 'root' }); }
4423
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WordDocumentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
4424
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WordDocumentService, providedIn: 'root' }); }
4590
4425
  }
4591
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: WordDocumentService, decorators: [{
4426
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: WordDocumentService, decorators: [{
4592
4427
  type: Injectable,
4593
4428
  args: [{
4594
4429
  providedIn: 'root',
@@ -4603,10 +4438,10 @@ class LanguageService {
4603
4438
  getLanguages() {
4604
4439
  return this.http.get(this.apiUrl + 'GetAll', null, null);
4605
4440
  }
4606
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: LanguageService, deps: [{ token: RequestHandlerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4607
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: LanguageService, providedIn: 'root' }); }
4441
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LanguageService, deps: [{ token: RequestHandlerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4442
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LanguageService, providedIn: 'root' }); }
4608
4443
  }
4609
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: LanguageService, decorators: [{
4444
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LanguageService, decorators: [{
4610
4445
  type: Injectable,
4611
4446
  args: [{
4612
4447
  providedIn: 'root',
@@ -4675,10 +4510,10 @@ class SpeechRecognitionService {
4675
4510
  this.recognition.stop();
4676
4511
  }
4677
4512
  }
4678
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: SpeechRecognitionService, deps: [{ token: i0.NgZone }, { token: UtilityService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4679
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: SpeechRecognitionService, providedIn: 'root' }); }
4513
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SpeechRecognitionService, deps: [{ token: i0.NgZone }, { token: UtilityService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4514
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SpeechRecognitionService, providedIn: 'root' }); }
4680
4515
  }
4681
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: SpeechRecognitionService, decorators: [{
4516
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SpeechRecognitionService, decorators: [{
4682
4517
  type: Injectable,
4683
4518
  args: [{
4684
4519
  providedIn: 'root'
@@ -4726,96 +4561,305 @@ class FileLoaderService {
4726
4561
  console.error('Error preloading translations:', error);
4727
4562
  }
4728
4563
  }
4729
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: FileLoaderService, deps: [{ token: BBSFTranslateService }, { token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
4730
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: FileLoaderService, providedIn: 'root' }); }
4564
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: FileLoaderService, deps: [{ token: BBSFTranslateService }, { token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
4565
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: FileLoaderService, providedIn: 'root' }); }
4731
4566
  }
4732
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: FileLoaderService, decorators: [{
4567
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: FileLoaderService, decorators: [{
4733
4568
  type: Injectable,
4734
4569
  args: [{
4735
4570
  providedIn: 'root',
4736
4571
  }]
4737
- }], ctorParameters: () => [{ type: BBSFTranslateService }, { type: i1$1.HttpClient }] });
4572
+ }], ctorParameters: () => [{ type: BBSFTranslateService }, { type: i1.HttpClient }] });
4738
4573
 
4739
- class UtilityService {
4740
- constructor(translator, environmentService, injector) {
4741
- this.translator = translator;
4742
- this.environmentService = environmentService;
4574
+ class AuthService {
4575
+ static { this.user = null; }
4576
+ static { this.UserClaims = null; }
4577
+ //refresh
4578
+ static { this.timers = []; }
4579
+ static { this.seconds = 0; }
4580
+ constructor(injector, http, environmentService, translateService, router, cookieService, utilityService) {
4743
4581
  this.injector = injector;
4744
- this.isCreatedBefore = false;
4582
+ this.http = http;
4583
+ this.environmentService = environmentService;
4584
+ this.translateService = translateService;
4585
+ this.router = router;
4586
+ this.cookieService = cookieService;
4587
+ this.utilityService = utilityService;
4588
+ this.redirectUrl = '';
4589
+ this.jwtHelper = new JwtHelperService();
4590
+ this.isAuthenticatedSubject = new BehaviorSubject(this.hasToken());
4591
+ this.isAuthenticate$ = this.isAuthenticatedSubject.asObservable();
4592
+ this.TOKEN_KEY = 'access_token';
4593
+ this.TOKEN_KEY = this.environmentService.getCookieName();
4594
+ this.user = this.getUserManager();
4745
4595
  }
4746
- getResourceValue(Key) {
4747
- let ResourceValue = this.translator.instant(Key);
4748
- return ResourceValue;
4596
+ hasToken() {
4597
+ const token = this.cookieService.get(this.TOKEN_KEY);
4598
+ return token && !this.jwtHelper.isTokenExpired(token);
4749
4599
  }
4750
- getCurrentLanguage() {
4751
- let currentLanguage = this.environmentService.getDefaultLanguage();
4752
- let lang = localStorage.getItem('language');
4753
- if (lang)
4754
- currentLanguage = lang;
4755
- else
4756
- localStorage.setItem('language', currentLanguage);
4757
- return currentLanguage;
4600
+ getUserManager() {
4601
+ const token = this.cookieService.get(this.TOKEN_KEY);
4602
+ if (token) {
4603
+ if (!this.jwtHelper.isTokenExpired(token))
4604
+ this.handleAccessTokenWithoutLanguage(token);
4605
+ else
4606
+ this.cookieService.delete(this.TOKEN_KEY, '/');
4607
+ }
4608
+ else {
4609
+ AuthService.timers.map(t => clearInterval(t));
4610
+ AuthService.timers = [];
4611
+ AuthService.user = null;
4612
+ this.user = null;
4613
+ }
4614
+ return AuthService.user;
4758
4615
  }
4759
- isCurrentLanguageEnglish() {
4760
- return this.getCurrentLanguage() == "en";
4616
+ getUser() {
4617
+ this.user = AuthService.user;
4761
4618
  }
4762
- isCurrentLanguageArabic() {
4763
- return this.getCurrentLanguage() == "ar";
4619
+ storUser(User) {
4620
+ AuthService.user = this.user = this.user;
4764
4621
  }
4765
- notifySuccessMessage(Message, title, time, showHeader = true) {
4766
- let MessageTemplate = this.getResourceValue("SuccessMessage");
4767
- let titleTemplate;
4768
- if (Message) {
4769
- MessageTemplate = Message;
4770
- }
4771
- if (title) {
4772
- titleTemplate = title;
4622
+ getCurrentUser() {
4623
+ return AuthService.user;
4624
+ }
4625
+ isAuthenticated() {
4626
+ return AuthService.user != null && !this.jwtHelper.isTokenExpired(AuthService.user.access_token);
4627
+ }
4628
+ isUserInRole(allowedPermission) {
4629
+ let selectedPermissionSetID = Number.parseInt(AuthService.user.profile['selectedpermissionsetid']);
4630
+ return allowedPermission.includes(selectedPermissionSetID);
4631
+ }
4632
+ isUserPermissionSetsInRoles(allowedPermission) {
4633
+ const permissionSetSIDString = AuthService.user.profile['permissionSetSID'];
4634
+ if (!permissionSetSIDString) {
4635
+ return false;
4773
4636
  }
4774
- let toaster = this.injector.get(ToastrService);
4775
- showHeader ? toaster.success(MessageTemplate, titleTemplate) : toaster.success(MessageTemplate);
4637
+ // Split comma-separated string and convert to numbers
4638
+ const userPermissionSets = permissionSetSIDString
4639
+ .split(',')
4640
+ .map(id => Number.parseInt(id.trim()))
4641
+ .filter(id => !isNaN(id)); // Filter out invalid numbers
4642
+ // Check if any user permission set is in the allowed permissions
4643
+ return userPermissionSets.some(permissionSetID => allowedPermission.includes(permissionSetID));
4776
4644
  }
4777
- notifyErrorMessage(Message, title, time, showHeader = true) {
4778
- let MessageTemplate = this.getResourceValue("ErrorMessage");
4779
- let titleTemplate = this.getResourceValue("Error");
4780
- if (Message) {
4781
- MessageTemplate = Message;
4645
+ authorizationHeaderValue() {
4646
+ return AuthService.user
4647
+ ? `${AuthService.user.token_type} ${AuthService.user.access_token}`
4648
+ : '';
4649
+ }
4650
+ name() {
4651
+ return AuthService.user != null ? AuthService.user.profile.given_name : '';
4652
+ }
4653
+ setUrl(url) {
4654
+ localStorage.setItem('redirectUrl', url);
4655
+ }
4656
+ getUrl() {
4657
+ return localStorage.getItem('redirectUrl') ?? "/";
4658
+ }
4659
+ signOut() {
4660
+ let isAuthenticated = this.isAuthenticated();
4661
+ this.cookieService.delete(this.TOKEN_KEY, '/');
4662
+ AuthService.timers.map(t => clearInterval(t));
4663
+ AuthService.timers = [];
4664
+ AuthService.user = null;
4665
+ this.user = null;
4666
+ localStorage.removeItem("redirectUrl");
4667
+ if (isAuthenticated) {
4668
+ this.logout().subscribe(res => {
4669
+ if (this.environmentService.getBBSFAuthenticationMode() == AuthenticationModes.UAEPass)
4670
+ this.logoutFromUAEPass();
4671
+ else
4672
+ this.router.navigate(['/Admin/account/login']);
4673
+ });
4782
4674
  }
4783
- if (title) {
4784
- titleTemplate = title;
4675
+ else {
4676
+ if (this.environmentService.getBBSFAuthenticationMode() == AuthenticationModes.UAEPass)
4677
+ this.logoutFromUAEPass();
4678
+ else
4679
+ this.router.navigate(['/Admin/account/login']);
4785
4680
  }
4786
- const toaster = this.injector.get(ToastrService);
4787
- showHeader ? toaster.error(MessageTemplate, titleTemplate) : toaster.error(MessageTemplate);
4788
4681
  }
4789
- notifyWarningMessage(Message, title, time, showHeader = true) {
4790
- let MessageTemplate = this.getResourceValue("WarningMessage");
4791
- let titleTemplate = this.getResourceValue("Warning");
4792
- if (Message) {
4793
- MessageTemplate = Message;
4794
- }
4795
- if (title) {
4796
- titleTemplate = title;
4682
+ logout() {
4683
+ const httpOptions = {
4684
+ headers: new HttpHeaders({
4685
+ 'Content-Type': 'application/json',
4686
+ }),
4687
+ };
4688
+ let ApiUrl = '/Account/';
4689
+ return this.http.get(this.environmentService.getApiUrl() + ApiUrl + 'Logout', httpOptions);
4690
+ }
4691
+ clearUserSessionClaims() {
4692
+ const httpOptions = {
4693
+ headers: new HttpHeaders({
4694
+ 'Content-Type': 'application/json',
4695
+ }),
4696
+ };
4697
+ let ApiUrl = '/api/Home/';
4698
+ return this.http.get(this.environmentService.getBaseUrl() + ApiUrl + 'ClearCurrentUserSession', httpOptions);
4699
+ }
4700
+ async handleAccessToken(response) {
4701
+ this.cookieService.delete(this.TOKEN_KEY, '/');
4702
+ const token = response;
4703
+ AuthService.user = null;
4704
+ AuthService.user = new User();
4705
+ AuthService.user.token_type = "Bearer";
4706
+ AuthService.user.access_token = token;
4707
+ AuthService.user.profile = this.jwtHelper.decodeToken(token);
4708
+ AuthService.user.expires_at = this.jwtHelper.getTokenExpirationDate(token);
4709
+ this.user = AuthService.user;
4710
+ localStorage.setItem("language", AuthService.user.profile.locale);
4711
+ this.cookieService.set(this.TOKEN_KEY, token, AuthService.user.expires_at, "/", null, true, 'Lax');
4712
+ this.isAuthenticatedSubject.next(true);
4713
+ this.setTokenSeconds();
4714
+ AuthService.timers.push(this.checkRefreshToken());
4715
+ await this.updateLanguage();
4716
+ }
4717
+ handleAccessTokenWithoutLanguage(response) {
4718
+ this.cookieService.delete(this.TOKEN_KEY, '/');
4719
+ const token = response;
4720
+ AuthService.user = null;
4721
+ AuthService.user = new User();
4722
+ AuthService.user.token_type = "Bearer";
4723
+ AuthService.user.access_token = token;
4724
+ AuthService.user.profile = this.jwtHelper.decodeToken(token);
4725
+ AuthService.user.expires_at = this.jwtHelper.getTokenExpirationDate(token);
4726
+ this.setTokenSeconds();
4727
+ this.user = AuthService.user;
4728
+ localStorage.setItem("language", AuthService.user.profile.locale);
4729
+ this.cookieService.set(this.TOKEN_KEY, token, AuthService.user.expires_at, "/", null, true, 'Lax');
4730
+ this.isAuthenticatedSubject.next(true);
4731
+ AuthService.timers.push(this.checkRefreshToken());
4732
+ }
4733
+ async updateLanguage() {
4734
+ if (!localStorage.getItem('language') || localStorage.getItem('language') == this.user.profile.locale)
4735
+ localStorage.setItem('language', this.user.profile.locale);
4736
+ if (this.translateService.currentLang != localStorage.getItem('language')) {
4737
+ this.translateService.resetLang(this.translateService.currentLang);
4738
+ await this.translateService.reloadLang(localStorage.getItem('language')).subscribe();
4797
4739
  }
4798
- const toaster = this.injector.get(ToastrService);
4799
- showHeader ? toaster.warning(MessageTemplate, titleTemplate) : toaster.warning(MessageTemplate);
4800
4740
  }
4801
- startBlockUI() {
4802
- this.blockUI.start();
4741
+ checkRefreshToken() {
4742
+ let date = new Date();
4743
+ return setInterval(() => {
4744
+ if (Math.floor(AuthService.seconds) < 120 && this.isAuthenticated()) {
4745
+ AuthService.timers.map(t => clearInterval(t));
4746
+ AuthService.timers = [];
4747
+ const token = this.cookieService.get(this.TOKEN_KEY);
4748
+ if (token) {
4749
+ this.refresh();
4750
+ }
4751
+ }
4752
+ AuthService.seconds--;
4753
+ }, 1000);
4803
4754
  }
4804
- stopBlockUI() {
4805
- this.blockUI.stop();
4755
+ setTokenSeconds() {
4756
+ let date = new Date();
4757
+ AuthService.seconds = (AuthService.user.expires_at - date) / 1000;
4758
+ }
4759
+ refresh() {
4760
+ this.cookieService.delete(this.TOKEN_KEY, '/');
4761
+ const httpOptions = {
4762
+ headers: new HttpHeaders({
4763
+ 'Content-Type': 'application/json',
4764
+ 'Authorization': this.authorizationHeaderValue(),
4765
+ }),
4766
+ };
4767
+ let ApiUrl = '/api/Home/';
4768
+ this.http.get(this.environmentService.getApiUrl() + ApiUrl + 'RefreshAccessToken', httpOptions).subscribe((res) => {
4769
+ this.handleAccessTokenWithoutLanguage(res.val);
4770
+ });
4771
+ }
4772
+ loginWithUAEPass() {
4773
+ const authEndpoint = `${this.environmentService.getUAEPassBaseUrl()}${this.environmentService.getUAEPassAuthorizationEndPoint()}`;
4774
+ const queryParams = {
4775
+ response_type: 'code',
4776
+ client_id: `${this.environmentService.getUAEPassClientID()}`,
4777
+ redirect_uri: `${this.environmentService.getBaseUrl()}${this.environmentService.getUAEPassRedirectUrl()}`,
4778
+ scope: 'urn:uae:digitalid:profile:general urn:uae:digitalid:profile:general:profileType urn:uae:digitalid:profile:general:unifiedId',
4779
+ state: this.translateService.currentLang,
4780
+ acr_values: 'urn:safelayer:tws:policies:authentication:level:low',
4781
+ ui_locales: this.translateService.currentLang,
4782
+ };
4783
+ const queryParamsString = Object.entries(queryParams)
4784
+ .map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
4785
+ .join('&');
4786
+ const loginUrl = `${authEndpoint}?${queryParamsString}`;
4787
+ window.location.href = loginUrl;
4788
+ return;
4789
+ }
4790
+ logoutFromUAEPass() {
4791
+ const logoutEndpoint = `${this.environmentService.getUAEPassBaseUrl()}${this.environmentService.getUAEPassLogoutEndPoint()}`;
4792
+ const queryParams = {
4793
+ redirect_uri: `${this.environmentService.getBaseUrl()}`,
4794
+ };
4795
+ const queryParamsString = Object.entries(queryParams)
4796
+ .map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
4797
+ .join('&');
4798
+ const logoutUrl = `${logoutEndpoint}?${queryParamsString}`;
4799
+ window.location.href = logoutUrl;
4800
+ return;
4806
4801
  }
4807
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: UtilityService, deps: [{ token: BBSFTranslateService }, { token: EnvironmentService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
4808
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: UtilityService, providedIn: 'root' }); }
4802
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AuthService, deps: [{ token: i0.Injector }, { token: i1.HttpClient }, { token: EnvironmentService }, { token: BBSFTranslateService }, { token: i1$1.Router }, { token: i4$1.CookieService }, { token: UtilityService }], target: i0.ɵɵFactoryTarget.Injectable }); }
4803
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AuthService, providedIn: 'root' }); }
4809
4804
  }
4810
- __decorate([
4811
- BlockUI()
4812
- ], UtilityService.prototype, "blockUI", void 0);
4813
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.6", ngImport: i0, type: UtilityService, decorators: [{
4805
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: AuthService, decorators: [{
4814
4806
  type: Injectable,
4815
4807
  args: [{
4816
- providedIn: 'root'
4808
+ providedIn: 'root',
4817
4809
  }]
4818
- }], ctorParameters: () => [{ type: BBSFTranslateService }, { type: EnvironmentService }, { type: i0.Injector }], propDecorators: { blockUI: [] } });
4810
+ }], ctorParameters: () => [{ type: i0.Injector }, { type: i1.HttpClient }, { type: EnvironmentService }, { type: BBSFTranslateService }, { type: i1$1.Router }, { type: i4$1.CookieService }, { type: UtilityService }] });
4811
+
4812
+ class BBSFUtilitiesModule {
4813
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BBSFUtilitiesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
4814
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.12", ngImport: i0, type: BBSFUtilitiesModule, imports: [CommonModule,
4815
+ RouterModule, i1$2.BlockUIModule, i2.ToastrModule] }); }
4816
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BBSFUtilitiesModule, providers: [
4817
+ UtilityService,
4818
+ EnvironmentService,
4819
+ AuthService,
4820
+ RequestHandlerService,
4821
+ StylesBundleService,
4822
+ TranslateService,
4823
+ BBSFTranslateService,
4824
+ ControlValidationService,
4825
+ MasterLayoutService,
4826
+ ConfigurationService,
4827
+ CookieService,
4828
+ LanguageService,
4829
+ SpeechRecognitionService
4830
+ ], imports: [CommonModule,
4831
+ RouterModule,
4832
+ BlockUIModule.forRoot(),
4833
+ ToastrModule.forRoot()] }); }
4834
+ }
4835
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: BBSFUtilitiesModule, decorators: [{
4836
+ type: NgModule,
4837
+ args: [{
4838
+ declarations: [],
4839
+ imports: [
4840
+ CommonModule,
4841
+ RouterModule,
4842
+ BlockUIModule.forRoot(),
4843
+ ToastrModule.forRoot(),
4844
+ ],
4845
+ exports: [],
4846
+ providers: [
4847
+ UtilityService,
4848
+ EnvironmentService,
4849
+ AuthService,
4850
+ RequestHandlerService,
4851
+ StylesBundleService,
4852
+ TranslateService,
4853
+ BBSFTranslateService,
4854
+ ControlValidationService,
4855
+ MasterLayoutService,
4856
+ ConfigurationService,
4857
+ CookieService,
4858
+ LanguageService,
4859
+ SpeechRecognitionService
4860
+ ]
4861
+ }]
4862
+ }] });
4819
4863
 
4820
4864
  /*
4821
4865
  * Public API Surface of @bnsights/bbsf-utilities