@ria-pro/mfe-integration
v1.0.0
Published
Library for Micro-Frontends (MFE) integrating with the **eesti.ee** portal. It provides a standard interface for MFEs to interact with the portal shell, access user information, language settings, and configuration.
Readme
@ria/mfe-integration
Library for Micro-Frontends (MFE) integrating with the eesti.ee portal. It provides a standard interface for MFEs to interact with the portal shell, access user information, language settings, and configuration.
Core Interface: MfeIntegration
The main interface provided by this library is MfeIntegration. It allows the MFE to communicate with the portal shell and retrieve essential data.
Methods
userInfo(): Returns aBehaviorSubject<IntegrationUserInfo | undefined>. Provides information about the currently authenticated user.language(): Returns aBehaviorSubject<Language>. Provides the current language of the portal (e.g., ET, EN, RU).portalType(): Returns aBehaviorSubject<PortalType>. Indicates the current portal type (e.g., CITIZEN, BUSINESS).getShellConfig(): Returns aPromise<AppConfig>. Retrieves the shell configuration (primarily for RIA-handled MFEs).getApiBaseUrl(): Returns the API base URL for the MFE.getOtherData(): Returns aMap<string, string>containing additional configuration or data.loaded(): Should be called by the MFE when it is fully loaded and ready to be displayed.destruct(): Used to clean up resources when the MFE is being destroyed.
Data Models
IntegrationUserInfo
Contains detailed information about the authenticated user:
firstName,lastName,fullNamepersonalCodeloggedInDate,loginExpireDate(Unix timestamps)representedParty: Information about the party the user is representing (Citizen or Business).
Language
Enum representing the portal's supported languages.
PortalType
Enum representing the type of portal environment (e.g., Citizen, Business).
Usage Example
import { MfeIntegration, IntegrationUserInfo } from '@ria/mfe-integration';
// Assuming the 'mfeIntegration' instance is provided by the portal shell
const integration: MfeIntegration = getMfeIntegrationInstance();
// Subscribe to user info updates
integration.userInfo().subscribe((user: IntegrationUserInfo | undefined) => {
if (user) {
console.log(`Hello, ${user.firstName}!`);
} else {
console.log('User is not authenticated.');
}
});
// Subscribe to language changes
integration.language().subscribe(lang => {
console.log(`Current language: ${lang}`);
});
// Notify the shell that MFE is loaded
integration.loaded();