@acorex/connectivity 20.0.23 → 20.1.0

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,16 +1,18 @@
1
- import { AXP_ROOT_CONFIG_TOKEN, AXPFilterOperatorMiddlewareService } from '@acorex/platform/common';
1
+ import { AXP_ROOT_CONFIG_TOKEN, AXPFilterOperatorMiddlewareService, AXPRegionalService, AXPFileStorageService, AXPFileStorageStatus } from '@acorex/platform/common';
2
2
  import { AXPEntityResolver, AXPEntityStorageService } from '@acorex/platform/layout/entity';
3
3
  import * as i1 from '@angular/common/http';
4
4
  import { HttpParams, HttpClient, HttpHeaders } from '@angular/common/http';
5
5
  import * as i0 from '@angular/core';
6
6
  import { inject, Injectable, NgModule } from '@angular/core';
7
7
  import { kebabCase } from 'lodash-es';
8
- import { firstValueFrom, map, BehaviorSubject, tap, filter, take, of, switchMap, delay } from 'rxjs';
8
+ import { firstValueFrom, catchError, of, map, BehaviorSubject, tap, filter, take, switchMap, delay } from 'rxjs';
9
9
  import * as i2 from '@acorex/platform/auth';
10
- import { AXPSessionService, AXPAuthModule, AXP_TENANT_LOADER, AXP_APPLICATION_LOADER, AXP_PERMISSION_LOADER, AXP_FEATURE_LOADER } from '@acorex/platform/auth';
10
+ import { AXPAuthStrategy, AXPSessionService, AXPAuthModule, AXP_TENANT_LOADER, AXP_APPLICATION_LOADER, AXP_PERMISSION_LOADER, AXP_FEATURE_LOADER } from '@acorex/platform/auth';
11
11
  import { STRATEGY_CONFIG_TOKEN } from '@acorex/platform/widgets';
12
12
  import * as i1$1 from 'angular-oauth2-oidc';
13
13
  import { OAuthService, OAuthModule } from 'angular-oauth2-oidc';
14
+ import { AXUSLocaleProfile, AXIRLocaleProfile } from '@acorex/core/locale';
15
+ import { AXTranslationService } from '@acorex/core/translation';
14
16
  import { AXM_AUTH_CONFIG_TOKEN } from '@acorex/modules/auth';
15
17
 
16
18
  class AXCApiEntityStorageService {
@@ -129,18 +131,404 @@ class AXCApiEntityStorageService {
129
131
  };
130
132
  });
131
133
  }
132
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXCApiEntityStorageService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
133
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXCApiEntityStorageService }); }
134
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXCApiEntityStorageService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
135
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXCApiEntityStorageService }); }
134
136
  }
135
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXCApiEntityStorageService, decorators: [{
137
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXCApiEntityStorageService, decorators: [{
136
138
  type: Injectable
137
139
  }], ctorParameters: () => [{ type: i1.HttpClient }] });
138
140
 
141
+ class AXCRegionalApiService extends AXPRegionalService {
142
+ constructor() {
143
+ super(...arguments);
144
+ this.http = inject(HttpClient);
145
+ this.languageService = inject(AXTranslationService);
146
+ //#region ---- API Endpoints ----
147
+ this.baseUrl = '/api/regional';
148
+ //#endregion
149
+ //#region ---- Fallback Data ----
150
+ this.fallbackCountries = [
151
+ {
152
+ code: 'US',
153
+ title: 'United States',
154
+ native: 'United States',
155
+ regional: 'en',
156
+ timezone: 'America/New_York'
157
+ },
158
+ {
159
+ code: 'CA',
160
+ title: 'Canada',
161
+ native: 'Canada',
162
+ regional: 'en',
163
+ timezone: 'America/Toronto'
164
+ },
165
+ {
166
+ code: 'GB',
167
+ title: 'United Kingdom',
168
+ native: 'United Kingdom',
169
+ regional: 'en',
170
+ timezone: 'Europe/London'
171
+ }
172
+ ];
173
+ this.fallbackProvinces = [
174
+ {
175
+ code: 'CA',
176
+ title: 'California',
177
+ native: 'California',
178
+ timezone: 'America/Los_Angeles'
179
+ },
180
+ {
181
+ code: 'NY',
182
+ title: 'New York',
183
+ native: 'New York',
184
+ timezone: 'America/New_York'
185
+ },
186
+ {
187
+ code: 'ON',
188
+ title: 'Ontario',
189
+ native: 'Ontario',
190
+ timezone: 'America/Toronto'
191
+ }
192
+ ];
193
+ this.fallbackCities = [
194
+ {
195
+ code: 'NYC',
196
+ title: 'New York City',
197
+ native: 'New York City',
198
+ timezone: 'America/New_York'
199
+ },
200
+ {
201
+ code: 'LA',
202
+ title: 'Los Angeles',
203
+ native: 'Los Angeles',
204
+ timezone: 'America/Los_Angeles'
205
+ },
206
+ {
207
+ code: 'TOR',
208
+ title: 'Toronto',
209
+ native: 'Toronto',
210
+ timezone: 'America/Toronto'
211
+ }
212
+ ];
213
+ this.fallbackCurrencies = [
214
+ {
215
+ code: 'USD',
216
+ title: 'United States Dollar',
217
+ symbol: '$',
218
+ format: '${amount}'
219
+ },
220
+ {
221
+ code: 'CAD',
222
+ title: 'Canadian Dollar',
223
+ symbol: 'CA$',
224
+ format: 'CA${amount}'
225
+ },
226
+ {
227
+ code: 'GBP',
228
+ title: 'British Pound',
229
+ symbol: '£',
230
+ format: '£{amount}'
231
+ }
232
+ ];
233
+ this.fallbackLocaleProfiles = [
234
+ {
235
+ ...AXUSLocaleProfile,
236
+ code: 'en-US',
237
+ title: 'English (United States)',
238
+ nativeTitle: 'English (United States)',
239
+ },
240
+ {
241
+ ...AXIRLocaleProfile,
242
+ code: 'fa-IR',
243
+ title: 'Persian (Iran)',
244
+ nativeTitle: 'فارسی (ایران)',
245
+ }
246
+ ];
247
+ this.fallbackLanguages = [
248
+ {
249
+ code: 'en',
250
+ title: 'English'
251
+ },
252
+ {
253
+ code: 'fa',
254
+ title: 'Persian'
255
+ },
256
+ {
257
+ code: 'es',
258
+ title: 'Spanish'
259
+ }
260
+ ];
261
+ this.fallbackTimeZones = [
262
+ {
263
+ code: 'America/New_York',
264
+ title: 'Eastern Time (US & Canada)',
265
+ offset: '-05:00',
266
+ iana: 'America/New_York',
267
+ abbr: 'EST'
268
+ },
269
+ {
270
+ code: 'America/Los_Angeles',
271
+ title: 'Pacific Time (US & Canada)',
272
+ offset: '-08:00',
273
+ iana: 'America/Los_Angeles',
274
+ abbr: 'PST'
275
+ },
276
+ {
277
+ code: 'Europe/London',
278
+ title: 'Greenwich Mean Time',
279
+ offset: '+00:00',
280
+ iana: 'Europe/London',
281
+ abbr: 'GMT'
282
+ }
283
+ ];
284
+ }
285
+ //#endregion
286
+ async getCountries() {
287
+ const lang = await firstValueFrom(this.languageService.langChanges$);
288
+ try {
289
+ const countries = await firstValueFrom(this.http.get(`${this.baseUrl}/countries`).pipe(catchError(() => of(this.fallbackCountries))));
290
+ return countries.map((country) => {
291
+ if (lang == country.regional) {
292
+ return {
293
+ ...country,
294
+ title: country.native,
295
+ };
296
+ }
297
+ else {
298
+ return country;
299
+ }
300
+ });
301
+ }
302
+ catch {
303
+ return this.fallbackCountries.map((country) => {
304
+ if (lang == country.regional) {
305
+ return {
306
+ ...country,
307
+ title: country.native,
308
+ };
309
+ }
310
+ else {
311
+ return country;
312
+ }
313
+ });
314
+ }
315
+ }
316
+ async getProvinces(countryId) {
317
+ let params = new HttpParams();
318
+ if (countryId) {
319
+ params = params.set('countryId', countryId);
320
+ }
321
+ try {
322
+ return await firstValueFrom(this.http.get(`${this.baseUrl}/provinces`, { params }).pipe(catchError(() => of(this.fallbackProvinces))));
323
+ }
324
+ catch {
325
+ return this.fallbackProvinces;
326
+ }
327
+ }
328
+ async getCities(filter) {
329
+ let params = new HttpParams();
330
+ if (filter?.countryId) {
331
+ params = params.set('countryId', filter.countryId);
332
+ }
333
+ if (filter?.provinceId) {
334
+ params = params.set('provinceId', filter.provinceId);
335
+ }
336
+ try {
337
+ return await firstValueFrom(this.http.get(`${this.baseUrl}/cities`, { params }).pipe(catchError(() => of(this.fallbackCities))));
338
+ }
339
+ catch {
340
+ return this.fallbackCities;
341
+ }
342
+ }
343
+ async getCurrencies() {
344
+ try {
345
+ return await firstValueFrom(this.http.get(`${this.baseUrl}/currencies`).pipe(catchError(() => of(this.fallbackCurrencies))));
346
+ }
347
+ catch {
348
+ return this.fallbackCurrencies;
349
+ }
350
+ }
351
+ async getLocaleProfiles() {
352
+ try {
353
+ return await firstValueFrom(this.http.get(`${this.baseUrl}/locale-profiles`).pipe(catchError(() => of(this.fallbackLocaleProfiles))));
354
+ }
355
+ catch {
356
+ return this.fallbackLocaleProfiles;
357
+ }
358
+ }
359
+ async getLanguages() {
360
+ try {
361
+ return await firstValueFrom(this.http.get(`${this.baseUrl}/languages`).pipe(catchError(() => of(this.fallbackLanguages))));
362
+ }
363
+ catch {
364
+ return this.fallbackLanguages;
365
+ }
366
+ }
367
+ async getAvailableLanguages() {
368
+ try {
369
+ return await firstValueFrom(this.http.get(`${this.baseUrl}/available-languages`).pipe(catchError(() => of(this.fallbackLanguages))));
370
+ }
371
+ catch {
372
+ return this.fallbackLanguages;
373
+ }
374
+ }
375
+ async getBrowserTimeZoneCode() {
376
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
377
+ }
378
+ async getTimeZones() {
379
+ try {
380
+ return await firstValueFrom(this.http.get(`${this.baseUrl}/timezones`).pipe(catchError(() => of(this.fallbackTimeZones))));
381
+ }
382
+ catch {
383
+ return this.fallbackTimeZones;
384
+ }
385
+ }
386
+ }
387
+
388
+ class AXCFileStorageApiService extends AXPFileStorageService {
389
+ constructor() {
390
+ super(...arguments);
391
+ this.http = inject(HttpClient);
392
+ //#region ---- API Endpoints ----
393
+ this.baseUrl = '/api/file-storage';
394
+ //#endregion
395
+ //#region ---- Fallback Data ----
396
+ this.fallbackFileInfo = {
397
+ fileId: 'fallback-file-id',
398
+ refId: 'fallback-ref-id',
399
+ refType: 'fallback-ref-type',
400
+ category: 'fallback-category',
401
+ size: 0,
402
+ mimeType: 'application/octet-stream',
403
+ uploadedAt: new Date(),
404
+ isPublic: true,
405
+ isPrimary: false,
406
+ status: AXPFileStorageStatus.Temporary,
407
+ name: 'fallback-file',
408
+ binary: new File([''], 'fallback-file'),
409
+ };
410
+ }
411
+ //#endregion
412
+ async save(request) {
413
+ try {
414
+ const formData = new FormData();
415
+ formData.append('file', request.file);
416
+ formData.append('refId', request.refId);
417
+ formData.append('refType', request.refType);
418
+ formData.append('category', request.category);
419
+ if (request.name) {
420
+ formData.append('name', request.name);
421
+ }
422
+ if (request.path) {
423
+ formData.append('path', request.path);
424
+ }
425
+ if (request.isPrimary !== undefined) {
426
+ formData.append('isPrimary', request.isPrimary.toString());
427
+ }
428
+ if (request.status) {
429
+ formData.append('status', request.status);
430
+ }
431
+ if (request.metadata) {
432
+ formData.append('metadata', JSON.stringify(request.metadata));
433
+ }
434
+ return await firstValueFrom(this.http.post(`${this.baseUrl}/save`, formData).pipe(catchError(() => of(this.fallbackFileInfo))));
435
+ }
436
+ catch {
437
+ return this.fallbackFileInfo;
438
+ }
439
+ }
440
+ async update(request) {
441
+ try {
442
+ const updateData = {
443
+ metadata: request.metadata,
444
+ };
445
+ if (request.path !== undefined) {
446
+ updateData.path = request.path;
447
+ }
448
+ if (request.isPrimary !== undefined) {
449
+ updateData.isPrimary = request.isPrimary;
450
+ }
451
+ return await firstValueFrom(this.http.put(`${this.baseUrl}/update/${request.fileId}`, updateData).pipe(catchError(() => of(this.fallbackFileInfo))));
452
+ }
453
+ catch {
454
+ return this.fallbackFileInfo;
455
+ }
456
+ }
457
+ async find(request) {
458
+ try {
459
+ let params = new HttpParams();
460
+ if (request.refId) {
461
+ params = params.set('refId', request.refId);
462
+ }
463
+ if (request.refType) {
464
+ params = params.set('refType', request.refType);
465
+ }
466
+ if (request.category) {
467
+ params = params.set('category', request.category);
468
+ }
469
+ if (request.mimeType) {
470
+ params = params.set('mimeType', request.mimeType);
471
+ }
472
+ if (request.isPublic !== undefined) {
473
+ params = params.set('isPublic', request.isPublic.toString());
474
+ }
475
+ if (request.isPrimary !== undefined) {
476
+ params = params.set('isPrimary', request.isPrimary.toString());
477
+ }
478
+ if (request.uploadedAtRange) {
479
+ params = params.set('uploadedAtFrom', request.uploadedAtRange.from.toISOString());
480
+ params = params.set('uploadedAtTo', request.uploadedAtRange.to.toISOString());
481
+ }
482
+ return await firstValueFrom(this.http.get(`${this.baseUrl}/find`, { params }).pipe(catchError(() => of([]))));
483
+ }
484
+ catch {
485
+ return [];
486
+ }
487
+ }
488
+ async getInfo(fileId) {
489
+ try {
490
+ return await firstValueFrom(this.http.get(`${this.baseUrl}/info/${fileId}`).pipe(catchError(() => of(this.fallbackFileInfo))));
491
+ }
492
+ catch {
493
+ return this.fallbackFileInfo;
494
+ }
495
+ }
496
+ async remove(fileId) {
497
+ try {
498
+ await firstValueFrom(this.http.delete(`${this.baseUrl}/remove/${fileId}`).pipe(catchError(() => of(void 0))));
499
+ }
500
+ catch {
501
+ // Silently fail in fallback mode
502
+ }
503
+ }
504
+ async commit(fileId) {
505
+ try {
506
+ await firstValueFrom(this.http.post(`${this.baseUrl}/commit/${fileId}`, {}).pipe(catchError(() => of(void 0))));
507
+ }
508
+ catch {
509
+ // Silently fail in fallback mode
510
+ }
511
+ }
512
+ async markForDeletion(fileId) {
513
+ try {
514
+ await firstValueFrom(this.http.post(`${this.baseUrl}/mark-for-deletion/${fileId}`, {}).pipe(catchError(() => of(void 0))));
515
+ }
516
+ catch {
517
+ // Silently fail in fallback mode
518
+ }
519
+ }
520
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXCFileStorageApiService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
521
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXCFileStorageApiService }); }
522
+ }
523
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXCFileStorageApiService, decorators: [{
524
+ type: Injectable
525
+ }] });
526
+
139
527
  class AXMOidcApplicationLoader {
140
528
  constructor(http) {
141
529
  this.http = http;
142
530
  this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
143
- this.apiGetApps = `${this.configs.baseUrl}/applications/GetListByTenantId`;
531
+ this.apiGetApps = `${this.configs.baseUrl}/applications/applications-for-current-tenant`;
144
532
  this.apiSetApp = `${this.configs.baseUrl}/SetApplication`;
145
533
  }
146
534
  getList() {
@@ -177,10 +565,10 @@ class AXMOidcApplicationLoader {
177
565
  // features: item.features || [],
178
566
  };
179
567
  }
180
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMOidcApplicationLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
181
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMOidcApplicationLoader }); }
568
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMOidcApplicationLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
569
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMOidcApplicationLoader }); }
182
570
  }
183
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMOidcApplicationLoader, decorators: [{
571
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMOidcApplicationLoader, decorators: [{
184
572
  type: Injectable
185
573
  }], ctorParameters: () => [{ type: i1.HttpClient }] });
186
574
 
@@ -220,10 +608,10 @@ class AXMConfigurationService {
220
608
  switchMap(() => of(this.applicationConfig)));
221
609
  }
222
610
  }
223
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMConfigurationService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
224
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMConfigurationService, providedIn: 'root' }); }
611
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMConfigurationService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
612
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMConfigurationService, providedIn: 'root' }); }
225
613
  }
226
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMConfigurationService, decorators: [{
614
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMConfigurationService, decorators: [{
227
615
  type: Injectable,
228
616
  args: [{
229
617
  providedIn: 'root',
@@ -250,11 +638,13 @@ class AXMOidcFeatureLoader {
250
638
  }
251
639
  }
252
640
 
253
- class AXMOidcStrategy {
641
+ class AXCAPIOidcStrategy extends AXPAuthStrategy {
254
642
  constructor() {
643
+ super(...arguments);
255
644
  this.aXMAuthConfigs = inject(AXM_AUTH_CONFIG_TOKEN);
256
645
  this.oauthService = inject(OAuthService);
257
646
  this.http = inject(HttpClient);
647
+ this.sessionService = inject(AXPSessionService);
258
648
  }
259
649
  async configureOAuth() {
260
650
  if (this.openidConfigurationInfo)
@@ -284,148 +674,310 @@ class AXMOidcStrategy {
284
674
  if (oidcJson) {
285
675
  const authData = JSON.parse(oidcJson);
286
676
  if (authData) {
287
- this.setServiceProps(authData);
677
+ this.sessionService.setSession(authData);
288
678
  if (authData.expiresIn && new Date(authData.expiresIn) < new Date()) {
289
679
  if (authData.expiresIn) {
290
- // this.refresh();
680
+ this.sessionService.refreshToken();
291
681
  }
292
682
  else {
293
- this.logout();
683
+ this.signout();
294
684
  }
295
685
  }
296
686
  }
297
687
  }
298
688
  }
299
689
  async signin(credentials) {
300
- await this.configureOAuth();
301
- try {
302
- const body = new HttpParams()
303
- .set('grant_type', 'password')
304
- .set('client_id', this.authConfig.clientId)
305
- .set('client_secret', this.authConfig.dummyClientSecret)
306
- .set('username', credentials.username)
307
- .set('password', credentials.password)
308
- .set('scope', this.authConfig.scope);
309
- const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded');
310
- const response = await firstValueFrom(this.http.post(this.openidConfigurationInfo.info.discoveryDocument.token_endpoint, body.toString(), { headers }));
311
- // const authData = new AuthenticationData(response);
312
- this.setServiceProps({
313
- accessToken: response.access_token,
314
- refreshToken: response.refresh_token,
315
- idToken: response.id_token,
316
- expiresIn: this.calculateExpireInDate(response.expires_in ?? 0),
317
- });
690
+ // If OIDC with username/password
691
+ if (credentials.strategy === 'oidc' && credentials.username && credentials.password) {
692
+ return this.handleOidcPasswordSignin(credentials);
693
+ }
694
+ // If OIDC with idToken/accessToken (OAuth callback)
695
+ if (credentials.strategy === 'oidc' && credentials['idToken'] && credentials['accessToken']) {
696
+ const payload = JwtUtil.parseJwt(credentials['idToken']);
697
+ const user = {
698
+ id: payload['sub'] || payload['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier'] || '',
699
+ title: payload['name'] || payload['email'] || '',
700
+ name: payload['name'] || payload['email'] || '',
701
+ avatar: payload['picture'] || '',
702
+ };
703
+ const tenant = payload['tenantid'] || payload['tenant']
704
+ ? {
705
+ id: payload['tenantid'] || payload['tenant'] || '',
706
+ name: payload['tenantname'] || 'test',
707
+ title: payload['tenanttitle'] || '',
708
+ }
709
+ : undefined;
710
+ const application = payload['applicationid'] || payload['application']
711
+ ? {
712
+ id: payload['applicationid'] || payload['application'] || '',
713
+ name: payload['applicationname'] || '',
714
+ title: payload['applicationtitle'] || '',
715
+ }
716
+ : undefined;
318
717
  return {
319
718
  succeed: true,
320
719
  data: {
321
- accessToken: response.access_token,
322
- expiresIn: this.calculateExpireInDate(response.expires_in ?? 0),
323
- idToken: response.id_token,
324
- refreshToken: response.refresh_token,
325
- user: {
326
- id: response.sub,
327
- title: response.fullname,
328
- name: response.sub,
329
- avatar: response.picture,
330
- },
331
- tenant: {
332
- id: response.tenantid,
333
- name: response.tenantname,
334
- title: response.tenanttitle,
335
- },
336
- application: {
337
- id: response.applicationid,
338
- name: response.applicationname,
339
- title: response.applicationtitle,
340
- },
720
+ accessToken: credentials['accessToken'],
721
+ refreshToken: credentials['refreshToken'],
722
+ idToken: credentials['idToken'],
723
+ user,
724
+ tenant,
725
+ application,
341
726
  },
342
727
  };
343
728
  }
344
- catch (error) {
345
- this.handleError(error);
729
+ throw new Error(`Unsupported authentication strategy or credentials: ${credentials.strategy}`);
730
+ }
731
+ /**
732
+ * Handles OIDC password-based authentication
733
+ */
734
+ async handleOidcPasswordSignin(credentials) {
735
+ await this.configureOAuth();
736
+ const loginRes = await fetch(this.authConfig.issuer + '/api/auth/manual-login', {
737
+ method: 'POST',
738
+ headers: { 'Content-Type': 'application/json' },
739
+ body: JSON.stringify({ username: credentials.username, password: credentials.password }),
740
+ credentials: 'include',
741
+ });
742
+ if (!loginRes.ok) {
743
+ let errorText = 'Login failed';
744
+ try {
745
+ const errorJson = await loginRes.json();
746
+ if (errorJson && errorJson.error && errorJson.error.description) {
747
+ errorText = errorJson.error.description;
748
+ }
749
+ }
750
+ catch {
751
+ try {
752
+ const text = await loginRes.text();
753
+ if (text) {
754
+ errorText = text;
755
+ }
756
+ }
757
+ catch { }
758
+ }
759
+ throw new Error(errorText);
346
760
  }
761
+ // Redirect to authorization endpoint (this will reload the page)
762
+ await this.startAuthorizationFlow('', '');
763
+ // Return a Promise that never resolves, so the sessionService/component does not proceed
764
+ return new Promise(() => { });
347
765
  }
766
+ // private async handleOidcPasswordSignin(credentials: AXPUserPassCredentials): Promise<AXPSignInResult> {
767
+ // await this.configureOAuth();
768
+ // try {
769
+ // const body = new HttpParams()
770
+ // .set('grant_type', 'password')
771
+ // .set('client_id', this.authConfig.clientId!)
772
+ // .set('username', credentials.username)
773
+ // .set('password', credentials.password)
774
+ // .set('scope', this.authConfig.scope!);
775
+ // const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded');
776
+ // const response = await firstValueFrom(
777
+ // this.http.post<IAuthenticationDataModel>(
778
+ // this.openidConfigurationInfo.info.discoveryDocument.token_endpoint,
779
+ // body.toString(),
780
+ // { headers },
781
+ // ),
782
+ // );
783
+ // // Parse id_token to extract user, tenant, and application info
784
+ // const payload = JwtUtil.parseJwt(response.id_token);
785
+ // const user = {
786
+ // id: payload['sub'] || payload['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier'] || '',
787
+ // title: payload['name'] || payload['email'] || '',
788
+ // name: payload['name'] || payload['email'] || '',
789
+ // avatar: payload['picture'] || '',
790
+ // } as AXPUser;
791
+ // const tenant =
792
+ // payload['tenantid'] || payload['tenant']
793
+ // ? {
794
+ // id: payload['tenantid'] || payload['tenant'] || '',
795
+ // name: payload['tenantname'] || '',
796
+ // title: payload['tenanttitle'] || '',
797
+ // }
798
+ // : undefined;
799
+ // const application =
800
+ // payload['applicationid'] || payload['application']
801
+ // ? {
802
+ // id: payload['applicationid'] || payload['application'] || '',
803
+ // name: payload['applicationname'] || '',
804
+ // title: payload['applicationtitle'] || '',
805
+ // }
806
+ // : undefined;
807
+ // return {
808
+ // succeed: true,
809
+ // data: {
810
+ // accessToken: response.access_token,
811
+ // expiresIn: this.calculateExpireInDate(response.expires_in ?? 0),
812
+ // idToken: response.id_token,
813
+ // refreshToken: response.refresh_token!,
814
+ // user,
815
+ // tenant,
816
+ // application,
817
+ // },
818
+ // };
819
+ // } catch (error: any) {
820
+ // this.handleError(error);
821
+ // }
822
+ // }
348
823
  async signout() {
349
- //this.logout();
824
+ localStorage.removeItem('pkce_code_verifier');
825
+ localStorage.removeItem('oauth_provider');
826
+ const logoutUrl = `${this.aXMAuthConfigs?.authConfig?.issuer}/api/auth/logout`;
827
+ await firstValueFrom(this.http.post(logoutUrl, {}, { withCredentials: true }));
350
828
  }
351
829
  async refreshToken(context) {
352
830
  try {
353
831
  await this.configureOAuth();
354
- const refreshResult = await this.refresh(context.tenant?.id, context.application?.id);
355
- if (refreshResult) {
356
- return {
357
- succeed: true,
358
- data: {
359
- accessToken: this.oauthService.getAccessToken(),
360
- refreshToken: this.oauthService.getRefreshToken(),
361
- },
362
- };
832
+ if (!this.authConfig || !this.authConfig.clientId) {
833
+ throw new Error('authConfig or clientId is missing');
363
834
  }
364
- else {
835
+ const authData = this.loadAuthData();
836
+ if (!authData) {
365
837
  return { succeed: false };
366
838
  }
367
- }
368
- catch (error) {
369
- console.error('Error refreshing token', error);
370
- return { succeed: false };
371
- }
372
- }
373
- async refresh(tenantId, applicationId) {
374
- await this.configureOAuth();
375
- const authData = this.loadAuthData();
376
- if (!authData)
377
- return false;
378
- const refreshToken = this.oauthService.getRefreshToken();
379
- if (!refreshToken)
380
- return false;
381
- const body = new HttpParams()
382
- .set('grant_type', 'refresh_token')
383
- .set('client_id', this.authConfig.clientId)
384
- .set('client_secret', this.authConfig.dummyClientSecret)
385
- .set('refresh_token', refreshToken)
386
- .set('tenantId', tenantId ?? '')
387
- .set('applicationId', applicationId ?? '');
388
- const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded');
389
- try {
839
+ const refreshToken = authData.refreshToken;
840
+ if (!refreshToken) {
841
+ return { succeed: false };
842
+ }
843
+ const body = new HttpParams()
844
+ .set('grant_type', 'refresh_token')
845
+ .set('client_id', this.authConfig.clientId)
846
+ .set('refresh_token', refreshToken);
847
+ const headers = new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded');
390
848
  const response = await firstValueFrom(this.http.post(this.openidConfigurationInfo.info.discoveryDocument.token_endpoint, body.toString(), { headers }));
391
- this.setServiceProps({
849
+ // Extract user, tenant, and application from id_token
850
+ const payload = JwtUtil.parseJwt(response.id_token);
851
+ const user = {
852
+ id: payload['sub'] || payload['http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier'] || '',
853
+ title: payload['name'] || payload['email'] || '',
854
+ name: payload['name'] || payload['email'] || '',
855
+ avatar: payload['picture'] || '',
856
+ };
857
+ const tenant = payload['tenantid'] || payload['tenant']
858
+ ? {
859
+ id: payload['tenantid'] || payload['tenant'] || '',
860
+ name: payload['tenantname'] || '',
861
+ title: payload['tenanttitle'] || '',
862
+ }
863
+ : undefined;
864
+ const application = payload['applicationid'] || payload['application']
865
+ ? {
866
+ id: payload['applicationid'] || payload['application'] || '',
867
+ name: payload['applicationname'] || '',
868
+ title: payload['applicationtitle'] || '',
869
+ }
870
+ : undefined;
871
+ const sessionData = {
392
872
  accessToken: response.access_token,
393
873
  refreshToken: response.refresh_token,
394
874
  idToken: response.id_token,
875
+ strategy: 'oidc',
395
876
  expiresIn: this.calculateExpireInDate(response.expires_in ?? 0),
396
- });
397
- return true;
877
+ user,
878
+ tenant,
879
+ application,
880
+ };
881
+ // this.setServiceProps(sessionData);
882
+ return {
883
+ succeed: true,
884
+ data: sessionData,
885
+ };
398
886
  }
399
887
  catch (error) {
400
- console.error('Token refresh error', error);
401
- return false;
888
+ console.error('Error refreshing token', error);
889
+ return { succeed: false };
402
890
  }
403
891
  }
404
- expires_in_milisecound(expires_in_date) {
405
- const now = new Date();
406
- const expire = new Date(expires_in_date);
407
- return expire.getTime() - now.getTime();
408
- }
409
- setServiceProps(authData) {
410
- this.oauthService.getAccessToken = () => authData.accessToken;
411
- this.oauthService.getIdToken = () => authData.idToken ?? '';
412
- this.oauthService.getRefreshToken = () => authData.refreshToken;
413
- if (authData.expiresIn) {
414
- const refreshTime = this.expires_in_milisecound(authData.expiresIn);
415
- this.oauthService.getAccessTokenExpiration = () => refreshTime;
416
- // if (refreshTime < 0) {
417
- // this.refresh();
418
- // }else{
419
- // }
892
+ /**
893
+ * Starts the OIDC authorization code flow, redirecting to the authorize endpoint with tenant_id and application_id as query params.
894
+ */
895
+ async startAuthorizationFlow(tenantId, applicationId) {
896
+ if (!this.openidConfigurationInfo) {
897
+ await this.configureOAuth();
420
898
  }
899
+ // فقط اینجا مقداردهی شود:
900
+ const codeVerifier = this.generateRandomString(128);
901
+ localStorage.setItem('pkce_code_verifier', codeVerifier);
902
+ const codeChallenge = await this.generateCodeChallenge(codeVerifier);
903
+ const authorizeEndpoint = this.openidConfigurationInfo.info.discoveryDocument.authorization_endpoint;
904
+ const clientId = this.authConfig.clientId;
905
+ const redirectUri = this.authConfig.redirectUri;
906
+ const scope = this.authConfig.scope;
907
+ const responseType = 'code';
908
+ const state = Math.random().toString(36).substring(2);
909
+ const url = `${authorizeEndpoint}?response_type=${encodeURIComponent(responseType)}&client_id=${encodeURIComponent(clientId)}&redirect_uri=${encodeURIComponent(redirectUri)}&scope=${encodeURIComponent(scope)}&state=${encodeURIComponent(state)}&tenant_id=${encodeURIComponent(tenantId)}&application_id=${encodeURIComponent(applicationId)}&code_challenge=${encodeURIComponent(codeChallenge)}&code_challenge_method=S256`;
910
+ window.location.href = url;
911
+ }
912
+ /**
913
+ * Unified method to complete the authorization code flow.
914
+ */
915
+ async completeAuthorizationCodeFlow(options) {
916
+ // Ensure OAuth is configured first
917
+ if (!this.openidConfigurationInfo) {
918
+ await this.configureOAuth();
919
+ }
920
+ const codeVerifier = localStorage.getItem('pkce_code_verifier');
921
+ localStorage.removeItem('pkce_code_verifier');
922
+ if (!codeVerifier) {
923
+ throw new Error('Code verifier not found. Please try signing in again.');
924
+ }
925
+ // Removed provider logic
926
+ const tokenEndpoint = options.tokenEndpoint ||
927
+ this.openidConfigurationInfo?.info?.discoveryDocument?.token_endpoint ||
928
+ `${this.aXMAuthConfigs?.authConfig?.issuer}/connect/token`;
929
+ const clientId = options.clientId || this.authConfig?.clientId || this.aXMAuthConfigs?.authConfig?.clientId || 'spa-client';
930
+ // Use the passed redirectUri parameter
931
+ const redirectUri = options.redirectUri;
932
+ const body = new URLSearchParams({
933
+ grant_type: 'authorization_code',
934
+ client_id: clientId,
935
+ code_verifier: codeVerifier,
936
+ code: options.code,
937
+ redirect_uri: redirectUri,
938
+ });
939
+ const response = await fetch(tokenEndpoint, {
940
+ method: 'POST',
941
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
942
+ body: body.toString(),
943
+ });
944
+ if (!response.ok) {
945
+ throw new Error(`Token exchange failed: ${response.status} ${response.statusText}`);
946
+ }
947
+ const tokenData = await response.json();
948
+ const credentials = {
949
+ strategy: 'oidc',
950
+ accessToken: tokenData.access_token,
951
+ refreshToken: tokenData.refresh_token,
952
+ idToken: tokenData.id_token,
953
+ // Optionally, you can add user info if your signin supports it
954
+ };
955
+ await this.sessionService.signin(credentials);
956
+ }
957
+ // Helper methods:
958
+ generateRandomString(length) {
959
+ const array = new Uint8Array(length);
960
+ crypto.getRandomValues(array);
961
+ return this.base64UrlEncode(array);
962
+ }
963
+ async generateCodeChallenge(codeVerifier) {
964
+ const encoder = new TextEncoder();
965
+ const data = encoder.encode(codeVerifier);
966
+ const digest = await crypto.subtle.digest('SHA-256', data);
967
+ return this.base64UrlEncode(new Uint8Array(digest));
968
+ }
969
+ base64UrlEncode(array) {
970
+ return btoa(String.fromCharCode(...array))
971
+ .replace(/\+/g, '-')
972
+ .replace(/\//g, '_')
973
+ .replace(/=/g, '');
974
+ }
975
+ expires_in_milisecound(expires_in_date) {
976
+ return new Date(expires_in_date).getTime() - new Date().getTime();
421
977
  }
422
978
  loadAuthData() {
423
- const authDataJson = localStorage.getItem(AXPSessionService.SESSION_KEY);
424
- if (!authDataJson)
425
- return undefined;
426
- const authData = JSON.parse(authDataJson);
427
- // return authData ? new AuthenticationData(authData) : undefined;
428
- return authData;
979
+ const sessionData = this.sessionService.getSessionData();
980
+ return sessionData || undefined;
429
981
  }
430
982
  async loadUserInfo() {
431
983
  return this.oauthService.loadUserProfile();
@@ -433,32 +985,173 @@ class AXMOidcStrategy {
433
985
  calculateExpireInDate(expireInMilisecound) {
434
986
  return new Date(Date.now() + expireInMilisecound * 1000).toISOString();
435
987
  }
436
- logout() {
437
- this.oauthService.logOut({
438
- noRedirectToLogoutUrl: true
439
- });
440
- }
988
+ // private logout(): void {
989
+ // // this.oauthService.logOut();
990
+ // // Use the public signout method instead of private clearSession
991
+ // this.sessionService.signout();
992
+ // }
441
993
  handleError(error) {
442
- if (error?.reason) {
443
- throw new Error(JSON.stringify(error.reason));
444
- }
445
- else if (error?.message) {
446
- throw new Error(error.message);
447
- }
448
- else {
449
- throw new Error('Network or server error occurred');
450
- }
994
+ console.error('Authentication error:', error);
995
+ throw error;
451
996
  }
452
997
  //#region getter
453
998
  get name() {
454
- return 'user-pass';
999
+ return 'oidc';
455
1000
  }
456
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMOidcStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
457
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMOidcStrategy }); }
1001
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXCAPIOidcStrategy, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
1002
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXCAPIOidcStrategy }); }
458
1003
  }
459
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMOidcStrategy, decorators: [{
1004
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXCAPIOidcStrategy, decorators: [{
460
1005
  type: Injectable
461
1006
  }] });
1007
+ class JwtUtil {
1008
+ /**
1009
+ * Decodes a JWT token and returns its payload as an object.
1010
+ * @param token JWT string
1011
+ */
1012
+ static parseJwt(token) {
1013
+ try {
1014
+ return JSON.parse(atob(token.split('.')[1]));
1015
+ }
1016
+ catch (e) {
1017
+ return null;
1018
+ }
1019
+ }
1020
+ static createJwt(payload) {
1021
+ // Create a proper JWT token with header, payload, and signature
1022
+ const header = {
1023
+ alg: 'HS256',
1024
+ typ: 'JWT'
1025
+ };
1026
+ const headerEncoded = JwtUtil.base64url(header);
1027
+ const payloadEncoded = JwtUtil.base64url(payload);
1028
+ const signature = 'mock-signature-for-testing'; // Mock signature
1029
+ const signatureEncoded = JwtUtil.base64url(signature);
1030
+ const idToken = `${headerEncoded}.${payloadEncoded}.${signatureEncoded}`;
1031
+ return idToken;
1032
+ }
1033
+ // For mock, just JSON stringify as the idToken
1034
+ // Convert idTokenPayload to a JWT-like string (header.payload.signature) so jwtutil can parse it
1035
+ // Use base64url encoding for header and payload, and a dummy signature
1036
+ static base64url(obj) {
1037
+ const json = JSON.stringify(obj);
1038
+ // Encode to UTF-8 bytes
1039
+ let utf8 = [];
1040
+ for (let i = 0; i < json.length; i++) {
1041
+ const charcode = json.charCodeAt(i);
1042
+ if (charcode < 0x80)
1043
+ utf8.push(charcode);
1044
+ else if (charcode < 0x800) {
1045
+ utf8.push(0xc0 | (charcode >> 6));
1046
+ utf8.push(0x80 | (charcode & 0x3f));
1047
+ }
1048
+ else if (charcode < 0xd800 || charcode >= 0xe000) {
1049
+ utf8.push(0xe0 | (charcode >> 12));
1050
+ utf8.push(0x80 | ((charcode >> 6) & 0x3f));
1051
+ utf8.push(0x80 | (charcode & 0x3f));
1052
+ }
1053
+ else {
1054
+ // surrogate pair
1055
+ i++;
1056
+ // UTF-16 encodes 0x10000-0x10FFFF by subtracting 0x10000 and
1057
+ // splitting the 20 bits of 0x0-0xFFFFF into two halves
1058
+ const surrogatePair = 0x10000 + (((charcode & 0x3ff) << 10) | (json.charCodeAt(i) & 0x3ff));
1059
+ utf8.push(0xf0 | (surrogatePair >> 18));
1060
+ utf8.push(0x80 | ((surrogatePair >> 12) & 0x3f));
1061
+ utf8.push(0x80 | ((surrogatePair >> 6) & 0x3f));
1062
+ utf8.push(0x80 | (surrogatePair & 0x3f));
1063
+ }
1064
+ }
1065
+ // Manual base64 encoding (no Buffer, no btoa)
1066
+ const base64abc = [
1067
+ 'A',
1068
+ 'B',
1069
+ 'C',
1070
+ 'D',
1071
+ 'E',
1072
+ 'F',
1073
+ 'G',
1074
+ 'H',
1075
+ 'I',
1076
+ 'J',
1077
+ 'K',
1078
+ 'L',
1079
+ 'M',
1080
+ 'N',
1081
+ 'O',
1082
+ 'P',
1083
+ 'Q',
1084
+ 'R',
1085
+ 'S',
1086
+ 'T',
1087
+ 'U',
1088
+ 'V',
1089
+ 'W',
1090
+ 'X',
1091
+ 'Y',
1092
+ 'Z',
1093
+ 'a',
1094
+ 'b',
1095
+ 'c',
1096
+ 'd',
1097
+ 'e',
1098
+ 'f',
1099
+ 'g',
1100
+ 'h',
1101
+ 'i',
1102
+ 'j',
1103
+ 'k',
1104
+ 'l',
1105
+ 'm',
1106
+ 'n',
1107
+ 'o',
1108
+ 'p',
1109
+ 'q',
1110
+ 'r',
1111
+ 's',
1112
+ 't',
1113
+ 'u',
1114
+ 'v',
1115
+ 'w',
1116
+ 'x',
1117
+ 'y',
1118
+ 'z',
1119
+ '0',
1120
+ '1',
1121
+ '2',
1122
+ '3',
1123
+ '4',
1124
+ '5',
1125
+ '6',
1126
+ '7',
1127
+ '8',
1128
+ '9',
1129
+ '+',
1130
+ '/',
1131
+ ];
1132
+ let result = '', i;
1133
+ for (i = 0; i + 2 < utf8.length; i += 3) {
1134
+ result += base64abc[utf8[i] >> 2];
1135
+ result += base64abc[((utf8[i] & 0x03) << 4) | (utf8[i + 1] >> 4)];
1136
+ result += base64abc[((utf8[i + 1] & 0x0f) << 2) | (utf8[i + 2] >> 6)];
1137
+ result += base64abc[utf8[i + 2] & 0x3f];
1138
+ }
1139
+ if (i < utf8.length) {
1140
+ result += base64abc[utf8[i] >> 2];
1141
+ if (i === utf8.length - 1) {
1142
+ result += base64abc[(utf8[i] & 0x03) << 4];
1143
+ // result += '==';
1144
+ }
1145
+ else {
1146
+ result += base64abc[((utf8[i] & 0x03) << 4) | (utf8[i + 1] >> 4)];
1147
+ result += base64abc[(utf8[i + 1] & 0x0f) << 2];
1148
+ // result += '=';
1149
+ }
1150
+ }
1151
+ // base64url encoding: replace + with -, / with _, remove =
1152
+ return result.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
1153
+ }
1154
+ }
462
1155
 
463
1156
  class AXMOidcPermissionLoader {
464
1157
  constructor(http) {
@@ -481,10 +1174,10 @@ class AXMOidcPermissionLoader {
481
1174
  const truePolicies = Object.keys(policies).filter((key) => policies[key] === true);
482
1175
  return truePolicies;
483
1176
  }
484
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMOidcPermissionLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
485
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMOidcPermissionLoader }); }
1177
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMOidcPermissionLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
1178
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMOidcPermissionLoader }); }
486
1179
  }
487
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMOidcPermissionLoader, decorators: [{
1180
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMOidcPermissionLoader, decorators: [{
488
1181
  type: Injectable
489
1182
  }], ctorParameters: () => [{ type: i1.HttpClient }] });
490
1183
 
@@ -492,11 +1185,12 @@ class AXMOidcTenantLoader {
492
1185
  constructor(http) {
493
1186
  this.http = http;
494
1187
  this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
495
- this.apiGetTenants = `${this.configs.baseUrl}/user-tenants/Tenants`;
496
- this.apiSetTenant = `${this.configs.baseUrl}/SetTenant`;
1188
+ this.apiGetTenants = `${this.configs.baseUrl}/tenants/available-for-user`;
497
1189
  }
498
1190
  getList() {
499
- return this.http.get(this.apiGetTenants).pipe(map((response) => response.items.map((item) => this.mapToAXPTenant(item))));
1191
+ return this.http.get(this.apiGetTenants).pipe(map((response) => response.items.map((item) => {
1192
+ return this.mapToAXPTenant(item);
1193
+ })));
500
1194
  }
501
1195
  async set(tenant) {
502
1196
  return Promise.resolve();
@@ -509,21 +1203,29 @@ class AXMOidcTenantLoader {
509
1203
  // Add other fields and defaults as needed, and handle the logo if applicable
510
1204
  };
511
1205
  }
512
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMOidcTenantLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
513
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMOidcTenantLoader }); }
1206
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMOidcTenantLoader, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
1207
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMOidcTenantLoader }); }
514
1208
  }
515
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXMOidcTenantLoader, decorators: [{
1209
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXMOidcTenantLoader, decorators: [{
516
1210
  type: Injectable
517
1211
  }], ctorParameters: () => [{ type: i1.HttpClient }] });
518
1212
 
519
1213
  class AXCApiModule {
520
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXCApiModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
521
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.7", ngImport: i0, type: AXCApiModule, imports: [i1$1.OAuthModule, i2.AXPAuthModule] }); }
522
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXCApiModule, providers: [
1214
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXCApiModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1215
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.1.3", ngImport: i0, type: AXCApiModule, imports: [i1$1.OAuthModule, i2.AXPAuthModule] }); }
1216
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXCApiModule, providers: [
523
1217
  {
524
1218
  provide: AXPEntityStorageService,
525
1219
  useClass: AXCApiEntityStorageService,
526
1220
  },
1221
+ {
1222
+ provide: AXPRegionalService,
1223
+ useClass: AXCRegionalApiService,
1224
+ },
1225
+ {
1226
+ provide: AXPFileStorageService,
1227
+ useClass: AXCFileStorageApiService,
1228
+ },
527
1229
  {
528
1230
  provide: AXP_TENANT_LOADER,
529
1231
  useClass: AXMOidcTenantLoader,
@@ -549,16 +1251,16 @@ class AXCApiModule {
549
1251
  },
550
1252
  ], imports: [OAuthModule.forRoot(),
551
1253
  AXPAuthModule.forRoot({
552
- strategies: [AXMOidcStrategy],
1254
+ strategies: [AXCAPIOidcStrategy],
553
1255
  })] }); }
554
1256
  }
555
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXCApiModule, decorators: [{
1257
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.3", ngImport: i0, type: AXCApiModule, decorators: [{
556
1258
  type: NgModule,
557
1259
  args: [{
558
1260
  imports: [
559
1261
  OAuthModule.forRoot(),
560
1262
  AXPAuthModule.forRoot({
561
- strategies: [AXMOidcStrategy],
1263
+ strategies: [AXCAPIOidcStrategy],
562
1264
  }),
563
1265
  ],
564
1266
  providers: [
@@ -566,6 +1268,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImpor
566
1268
  provide: AXPEntityStorageService,
567
1269
  useClass: AXCApiEntityStorageService,
568
1270
  },
1271
+ {
1272
+ provide: AXPRegionalService,
1273
+ useClass: AXCRegionalApiService,
1274
+ },
1275
+ {
1276
+ provide: AXPFileStorageService,
1277
+ useClass: AXCFileStorageApiService,
1278
+ },
569
1279
  {
570
1280
  provide: AXP_TENANT_LOADER,
571
1281
  useClass: AXMOidcTenantLoader,
@@ -597,5 +1307,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImpor
597
1307
  * Generated bundle index. Do not edit.
598
1308
  */
599
1309
 
600
- export { AXCApiEntityStorageService, AXCApiModule, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcStrategy, AXMOidcTenantLoader };
1310
+ export { AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader, JwtUtil };
601
1311
  //# sourceMappingURL=acorex-connectivity-api.mjs.map