@c8y/ngx-components
Version:
Angular modules for Cumulocity IoT applications
161 lines • 5.93 kB
TypeScript
import { IApplication, ICurrentTenant, ITenantLoginOption, TenantLoginOptionsService, TenantLoginOptionType, UserService } from '@c8y/client';
import { AppStateService } from './ui-state.service';
import * as i0 from "@angular/core";
export type PasswordStrengthSettings = Required<Pick<ITenantLoginOption, 'enforceStrength' | 'greenMinLength' | 'strengthValidity'>>;
/** The helper UI service for tenant related methods built upon client services. */
export declare class TenantUiService {
private userService;
private appStateService;
private tenantLoginOption;
readonly MANAGEMENT = "management";
readonly ROLE_TENANT_MANAGEMENT_READ: string;
constructor(userService: UserService, appStateService: AppStateService, tenantLoginOption: TenantLoginOptionsService);
/**
* Returns current tenant
*/
get currentTenant(): ICurrentTenant;
/**
* Checks whether current tenant is the management tenant.
* @returns True if current tenant is the management tenant.
*/
isManagementTenant(): Promise<boolean>;
/**
* Checks whether current tenant is an enterprise tenant.
* An enterprise tenant is a tenant which has subscribed:
* - `branding` microservice or `feature-branding` feature app,
* - `sslmanagement` microservice,
* - `feature-user-hierarchy` feature app,
* - `feature-broker` feature app.
*
* See https://cumulocity.com/guides/users-guide/enterprise-edition/ for details about such tenants.
*
* @returns True, if current tenant is an enterprise tenant.
*/
isEnterpriseTenant(): Promise<boolean>;
/**
* Checks whether the current user has read access to tenants, i.e.:
* - the current tenant can create subtenants or it's the management tenant,
* - the current user has ROLE_TENANT_MANAGEMENT_READ role.
* @returns True, if the current user has read access to tenants.
*/
canReadTenants(): boolean;
/**
* Returns current tenant preferred login mode.
*/
getCurrentTenantPreferredLoginOption(): ITenantLoginOption;
/**
* Returns current user login mode.
*/
getCurrentUserLoginMode(): TenantLoginOptionType;
/**
* Returns tenant login option which is preferred.
*
* @param loginOptions The list of all available tenant's login options.
*
* @returns Returns ITenantLoginOption.
*
* **Example**
* ```typescript
*
* (() => {
* const preferredLoginOption = tenantLoginOptionsService.getPreferredLoginOption(loginOptions);
* })();
* ```
*/
getPreferredLoginOption(loginOptions: ITenantLoginOption[]): ITenantLoginOption;
/**
* Returns Oauth2 login option if it can be used by UI.
*
* @param loginOptions The list of all available tenant's login options.
*
* @returns Returns ITenantLoginOption.
*
* **Example**
* ```typescript
*
* (() => {
* const oauth2 = tenantLoginOptionsService.getOauth2Option(loginOptions);
* })();
* ```
*/
getOauth2Option(loginOptions: ITenantLoginOption[]): ITenantLoginOption;
/**
* Callback which checks if login option is visible on login page.
*
* @param loginOption The tenant login option.
*
* **Example**
* ```typescript
*
* (() => {
* const loginOptionsVisibleOnLoginPage = loginOptions.filter(tenantLoginOptionsService.isVisibleOnLoginPage);
* })();
* ```
*/
isVisibleOnLoginPage(loginOption: ITenantLoginOption): boolean;
/**
* Callback which checks if login option type is 'OAUTH2_INTERNAL'.
*
* @param loginOption The tenant login option.
*
* **Example**
* ```typescript
*
* (() => {
* const oauth2InternalLoginOptions = loginOptions.filter(tenantLoginOptionsService.isOauthInternal);
* })();
* ```
*/
isOauthInternal(loginOption: ITenantLoginOption): boolean;
/**
* Callback which checks if login option type is 'BASIC'.
*
* @param loginOption The tenant login option.
*
* **Example**
* ```typescript
*
* (() => {
* const basicLoginOptions = loginOptions.filter(tenantLoginOptionsService.isBasic);
* })();
* ```
*/
isBasic(loginOption: ITenantLoginOption): boolean;
/**
* Callback which checks if login option type is 'OAUTH2' and grantType is 'AUTHORIZATION_CODE'.
*
* @param loginOption The tenant login option.
*
* **Example**
* ```typescript
*
* (() => {
* const oauth2LoginOptions = loginOptions.filter(tenantLoginOptionsService.OAUTH2);
* })();
* ```
*/
isOauth2(loginOption: ITenantLoginOption): boolean;
/**
* Checks if application of type MICROSERVICE is subscribed to the current tenant.
* It checks the application references of the currentTenant from the application state.
* No additional request.
* @param identifier application name or contextPath
*/
isMicroserviceSubscribedInCurrentTenant(identifier: string): boolean;
/**
* Gets all application of type MICROSERVICE subscribed to the current tenant.
* It checks the application references of the currentTenant from the application state.
* No additional request.
*/
getSubscribedMicroservicesInCurrentTenant(): IApplication[];
/**
* Gets password constraints setting from loginOptions.
* @returns Returns Promise<PasswordStrengthSettings> with password properties.
*/
getPasswordStrengthSettings(): Promise<PasswordStrengthSettings>;
private hasApp;
private isManagement;
static ɵfac: i0.ɵɵFactoryDeclaration<TenantUiService, never>;
static ɵprov: i0.ɵɵInjectableDeclaration<TenantUiService>;
}
//# sourceMappingURL=tenant-ui.service.d.ts.map