import { HoistService, HoistUser, IdentityInfo } from '@xh/hoist/core'; /** * Provides basic information related to the authenticated user, including application roles. * This service loads its data from Hoist Core's server-side identity service. * * Also provides support for recognizing impersonation and distinguishing between the apparent and * actual underlying user. */ export declare class IdentityService extends HoistService { telemetryPrefix: string; static instance: IdentityService; private identity; /** @returns current acting user (see authUser for notes on impersonation) */ get user(): HoistUser; /** @returns current acting user's username. */ get username(): string; /** @returns current acting user's initials, based on displayName. */ get userInitials(): string; /** * Actual user who authenticated to the web application. * This will be the same as the user except when an administrator is impersonation another * user for troubleshooting or testing. In those cases, this getter will return the actual * administrator, whereas `this.user` will return the user they are impersonating. */ get authUser(): HoistUser; get authUsername(): string; /** Is an impersonation session currently active? */ get isImpersonating(): boolean; /** * Can the user impersonate other users? * * See also canAuthUserImpersonate() which should be consulted before actually * triggering any impersonation attempts. */ get canImpersonate(): boolean; /** * Can the underlying authenticated user impersonate other users? * * Use this getter to determine if Hoist should allow the client to show impersonation * affordances and to trigger impersonation actions. */ get canAuthUserImpersonate(): boolean; /** * Begin an impersonation session to act as another user. The UI server will allow this only * if the actual authenticated user has the rights to do, and is attempting to impersonate * a known user who has permission to and has accessed the app themselves. If successful, * the application will reload and the admin will now be acting as the other user. * * @param username - the end-user to impersonate */ impersonateAsync(username: string): Promise; /** Exit any active impersonation, reloading the app to resume accessing it as yourself. */ endImpersonateAsync(): Promise; /** * @internal -- for framework use onlu. */ initIdentity(identity: IdentityInfo): void; private canUserImpersonate; /** * Flush any buffered user-attributed state to the server before changing identity, so events * are recorded under the correct session. Each call is null-safe in case the relevant service * has not yet been initialized. */ private pushPendingUserStateAsync; }