import '@iotize/tap/service/impl/group'; import { Tap } from '@iotize/tap'; import { BehaviorSubject, Observable } from 'rxjs'; import { AuthMethod, UsernamePassword } from './definitions'; import { ScramAuth } from './scram-auth'; export declare namespace TapAuth { type SessionData = ScramAuth.SessionData; interface SessionState { /** * User identifier */ groupId: number; /** * Profile identifier * If groupId === profileId, it means that user is logged with a profile */ profileId: number; startTime?: Date; lifeTime: number; /** * User name */ name: string; /** * Profile name (may be same as name if user is logged with a profile) */ profileName: string; } } export declare class TapAuth implements AuthMethod { tap: Tap; protected _sessionState: BehaviorSubject; protected _sessionData: BehaviorSubject; /** * Get current session state snapshot */ get sessionStateSnapshot(): TapAuth.SessionState; /** * Listen to session state changed */ get sessionState(): Observable; /** * Get current session data snapshot */ get sessionDataSnapshot(): ScramAuth.SessionData; /** * Listen to session data changed */ get sessionData(): Observable; private _auth?; private get service(); constructor(tap: Tap); setAuthMethod(method: AuthMethod): void; /** * Clear auth cache. * Usefull for example if Tap configuration has changed */ clearCache(): void; login(params: UsernamePassword, options?: { noRefreshSessionState?: boolean; }): Promise; /** * Tap logout * Reject if logout failed */ logout(): Promise; /** * Read session state from the Tap * This will perform a few tap requests * * TODO we should invalidate encryption key if session state changed */ refreshSessionState(defaults?: { username?: string; }): Promise; /** * Change password for given user. If userIdOrName is not set, it will change password for the currenty * connected user. * @param newPassword * @param userIdOrUndefined user identifier for which password will be change */ changePassword(newPassword: string, userIdOrUndefined?: number): Promise; setupTapAuthEngineIfRequired(): Promise>; private setupTapAuthEngine; }