@acorex/connectivity 20.6.0-next.7 → 20.6.0-next.8
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.
package/api/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { AXPApplicationLoader, AXPApplication, AXPFeatureLoader, AXPFeature, AXP
|
|
|
9
9
|
import * as i3 from '@acorex/connectivity/utils';
|
|
10
10
|
import * as i1 from '@acorex/platform/runtime';
|
|
11
11
|
import { Observable } from 'rxjs';
|
|
12
|
+
import { AXPUserAvatarProvider, AXPUserAvatarData } from '@acorex/platform/layout/components';
|
|
12
13
|
import * as _acorex_modules_report_management from '@acorex/modules/report-management';
|
|
13
14
|
import { AXPReportCategoryProvider, AXPReportCategory, AXPReportDefinitionProvider, AXPReportDefinition } from '@acorex/modules/report-management';
|
|
14
15
|
|
|
@@ -209,6 +210,15 @@ declare class AXMOidcTenantLoader implements AXPTenantLoader {
|
|
|
209
210
|
static ɵprov: i0.ɵɵInjectableDeclaration<AXMOidcTenantLoader>;
|
|
210
211
|
}
|
|
211
212
|
|
|
213
|
+
declare class AXCApiUserAvatarProvider implements AXPUserAvatarProvider {
|
|
214
|
+
private userService;
|
|
215
|
+
private sessionService;
|
|
216
|
+
private http;
|
|
217
|
+
private readonly configs;
|
|
218
|
+
private readonly baseUrl;
|
|
219
|
+
provide(userId: string): Promise<AXPUserAvatarData>;
|
|
220
|
+
}
|
|
221
|
+
|
|
212
222
|
declare class APIGoogleStrategy extends AXPAuthStrategy {
|
|
213
223
|
private aXMAuthConfigs;
|
|
214
224
|
private oauthService;
|
|
@@ -423,5 +433,5 @@ declare const AXC_REPORT_DEFINITION_API_PROVIDER: {
|
|
|
423
433
|
multi: boolean;
|
|
424
434
|
};
|
|
425
435
|
|
|
426
|
-
export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXCReportCategoryApiProvider, AXCReportDefinitionApiProvider, AXCReportManagementApiModule, AXCReportManagementDataService, AXC_REPORT_CATEGORY_API_PROVIDER, AXC_REPORT_DEFINITION_API_PROVIDER, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
|
|
436
|
+
export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXCApiUserAvatarProvider, AXCReportCategoryApiProvider, AXCReportDefinitionApiProvider, AXCReportManagementApiModule, AXCReportManagementDataService, AXC_REPORT_CATEGORY_API_PROVIDER, AXC_REPORT_DEFINITION_API_PROVIDER, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
|
|
427
437
|
export type { AXCReportCategoryApiItem, AXCReportCategoryApiResponse, AXCReportDefinitionApiItem, AXCReportDefinitionApiResponse, AXCReportLayoutDefinition, AXCReportParameter, AXCReportParameterGroup, AXPExecuteReportDto, AXPOAuthExternalCredentials, AXPUserPassCredentials, ApplicationConfiguration, Auth, Culture, IAuthenticationDataModel, Language, Localization, NameValue, Resource };
|
|
@@ -8,11 +8,14 @@ import { kebabCase } from 'lodash-es';
|
|
|
8
8
|
import { firstValueFrom, catchError, of, map, BehaviorSubject, tap, filter, take, switchMap, delay } from 'rxjs';
|
|
9
9
|
import * as i2 from '@acorex/platform/auth';
|
|
10
10
|
import { AXPAuthStrategy, AXPSessionService, JwtUtil, TimeUtil, PkceUtil, AXPAuthModule, AXP_TENANT_LOADER, AXP_APPLICATION_LOADER, AXP_PERMISSION_LOADER, AXP_FEATURE_LOADER } from '@acorex/platform/auth';
|
|
11
|
+
import { AXP_USER_AVATAR_PROVIDER } from '@acorex/platform/layout/components';
|
|
11
12
|
import { STRATEGY_CONFIG_TOKEN } from '@acorex/platform/layout/widgets';
|
|
12
13
|
import * as i1$1 from 'angular-oauth2-oidc';
|
|
13
14
|
import { OAuthService, OAuthModule } from 'angular-oauth2-oidc';
|
|
14
15
|
import { AXM_AUTH_CONFIG_TOKEN } from '@acorex/modules/auth';
|
|
15
16
|
import { Router } from '@angular/router';
|
|
17
|
+
import { AXMUsersEntityService } from '@acorex/modules/security-management';
|
|
18
|
+
import { AXPDataGenerator } from '@acorex/platform/core';
|
|
16
19
|
import { AXCUtilsModule, AXCExternalAuthorizationService } from '@acorex/connectivity/utils';
|
|
17
20
|
import { AXPRuntimeModule, provideCommandSetups } from '@acorex/platform/runtime';
|
|
18
21
|
import { AXP_REPORT_CATEGORY_PROVIDER, AXP_REPORT_DEFINITION_PROVIDER } from '@acorex/modules/report-management';
|
|
@@ -789,6 +792,63 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
789
792
|
type: Injectable
|
|
790
793
|
}], ctorParameters: () => [{ type: i1.HttpClient }] });
|
|
791
794
|
|
|
795
|
+
class AXCApiUserAvatarProvider {
|
|
796
|
+
constructor() {
|
|
797
|
+
this.userService = inject(AXMUsersEntityService);
|
|
798
|
+
this.sessionService = inject(AXPSessionService);
|
|
799
|
+
this.http = inject(HttpClient);
|
|
800
|
+
this.configs = inject(AXP_ROOT_CONFIG_TOKEN);
|
|
801
|
+
this.baseUrl = this.configs.baseUrl;
|
|
802
|
+
}
|
|
803
|
+
async provide(userId) {
|
|
804
|
+
// Check if requesting current user info
|
|
805
|
+
const currentUser = this.sessionService.user;
|
|
806
|
+
const isCurrentUser = currentUser?.id === userId;
|
|
807
|
+
if (isCurrentUser) {
|
|
808
|
+
// Use OpenIddict /connect/userinfo endpoint for current user
|
|
809
|
+
try {
|
|
810
|
+
// Extract base URL without /api suffix and add /connect/userinfo
|
|
811
|
+
const authority = this.baseUrl.replace(/\/api$/, '');
|
|
812
|
+
const userInfoUrl = `${authority}/connect/userinfo`;
|
|
813
|
+
const token = this.sessionService.getToken();
|
|
814
|
+
// Add Authorization header if token exists (interceptor will also add it, but explicit is better)
|
|
815
|
+
const headers = new HttpHeaders();
|
|
816
|
+
if (token) {
|
|
817
|
+
headers.set('Authorization', `Bearer ${token}`);
|
|
818
|
+
}
|
|
819
|
+
const userInfo = await firstValueFrom(this.http.get(userInfoUrl, { headers }));
|
|
820
|
+
const [firstName, lastName] = (userInfo.name || userInfo.sub || '').split(' ') || ['', ''];
|
|
821
|
+
return {
|
|
822
|
+
id: userInfo.sub || userId,
|
|
823
|
+
username: userInfo.preferred_username || userInfo.name || '',
|
|
824
|
+
firstName: firstName || userInfo.given_name || '',
|
|
825
|
+
lastName: lastName || userInfo.family_name || '',
|
|
826
|
+
status: 'online',
|
|
827
|
+
avatarUrl: userInfo.picture || 'https://via.placeholder.com/150',
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
catch (error) {
|
|
831
|
+
console.error('Failed to load userinfo from /connect/userinfo, falling back to entity service', error);
|
|
832
|
+
// Fallback to entity service if userinfo endpoint fails
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
// Use entity service for other users or as fallback
|
|
836
|
+
const user = await this.userService.getOne(userId);
|
|
837
|
+
if (!user) {
|
|
838
|
+
throw new Error(`User not found for ${userId}`);
|
|
839
|
+
}
|
|
840
|
+
const [firstName, lastName] = user.displayName.split(' ') || ['', ''];
|
|
841
|
+
return {
|
|
842
|
+
id: user.id,
|
|
843
|
+
username: user.username,
|
|
844
|
+
firstName: firstName || '',
|
|
845
|
+
lastName: lastName || '',
|
|
846
|
+
status: 'online',
|
|
847
|
+
avatarUrl: `https://avatar.iran.liara.run/public/${AXPDataGenerator.pick([35, 22, 16, 6, 31])}`,
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
|
|
792
852
|
//#endregion
|
|
793
853
|
//#region ---- Helper Functions ----
|
|
794
854
|
// /**
|
|
@@ -1215,7 +1275,11 @@ class AXCApiModule {
|
|
|
1215
1275
|
selectValueStrategy: 'valueField',
|
|
1216
1276
|
lookupValueStrategy: 'valueField',
|
|
1217
1277
|
},
|
|
1218
|
-
}
|
|
1278
|
+
},
|
|
1279
|
+
{
|
|
1280
|
+
provide: AXP_USER_AVATAR_PROVIDER,
|
|
1281
|
+
useClass: AXCApiUserAvatarProvider,
|
|
1282
|
+
},
|
|
1219
1283
|
], imports: [OAuthModule.forRoot(),
|
|
1220
1284
|
AXPAuthModule.forRoot({
|
|
1221
1285
|
strategies: [AXCAPIOidcStrategy],
|
|
@@ -1265,7 +1329,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
1265
1329
|
selectValueStrategy: 'valueField',
|
|
1266
1330
|
lookupValueStrategy: 'valueField',
|
|
1267
1331
|
},
|
|
1268
|
-
}
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
provide: AXP_USER_AVATAR_PROVIDER,
|
|
1335
|
+
useClass: AXCApiUserAvatarProvider,
|
|
1336
|
+
},
|
|
1269
1337
|
],
|
|
1270
1338
|
}]
|
|
1271
1339
|
}] });
|
|
@@ -1545,5 +1613,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
|
|
|
1545
1613
|
* Generated bundle index. Do not edit.
|
|
1546
1614
|
*/
|
|
1547
1615
|
|
|
1548
|
-
export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXCReportCategoryApiProvider, AXCReportDefinitionApiProvider, AXCReportManagementApiModule, AXCReportManagementDataService, AXC_REPORT_CATEGORY_API_PROVIDER, AXC_REPORT_DEFINITION_API_PROVIDER, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
|
|
1616
|
+
export { APIGoogleStrategy, AXCAPIOidcStrategy, AXCApiEntityStorageService, AXCApiModule, AXCApiUserAvatarProvider, AXCReportCategoryApiProvider, AXCReportDefinitionApiProvider, AXCReportManagementApiModule, AXCReportManagementDataService, AXC_REPORT_CATEGORY_API_PROVIDER, AXC_REPORT_DEFINITION_API_PROVIDER, AXMConfigurationService, AXMOidcApplicationLoader, AXMOidcFeatureLoader, AXMOidcPermissionLoader, AXMOidcTenantLoader };
|
|
1549
1617
|
//# sourceMappingURL=acorex-connectivity-api.mjs.map
|