/** * Connection service * @module Connection */ import { RBEvent } from '../../models/event.model'; import { Subscription } from 'rxjs'; import { Service } from '../../services/service'; import { ConnectedUser } from '../../models'; /** @internal */ export declare const CONNECTION_SVC = "ConnectionService"; export declare enum ConnectionStateEnum { NONE = "NONE", CONNECTING = "CONNECTING", CONNECTED = "CONNECTED", RECONNECTING = "RECONNECTING", DISCONNECTED = "DISCONNECTED" } export declare enum DisconnectionReasonEnum { UNLOGGED = "UNLOGGED", NO_NETWORK = "NO_NETWORK", CHANGE_PWD_ERROR = "CHANGE_PWD_ERROR", THIRD_PARTY_CHANGE_PWD = "3RD_PARTY_CHANGE_PWD", AUTH_TOKEN_EXPIRE = "TOKEN_EXPIRE" } export declare enum ConnectionTokenState { AUTH_TOKEN_WILL_EXPIRE = "AUTH_TOKEN_WILL_EXPIRE", AUTH_TOKEN_RENEW = "AUTH_TOKEN_RENEW" } export declare class ConnectionProgress { index: number; length: number; label: string; private constructor(); static create(index: number, length: number, label: string): ConnectionProgress; } export declare class ConnectionState { state: ConnectionStateEnum; reason?: DisconnectionReasonEnum; progress?: ConnectionProgress; private constructor(); static create(state: T, reason?: T extends ConnectionStateEnum.DISCONNECTED ? DisconnectionReasonEnum : never, progress?: ConnectionProgress): ConnectionState; } export type ConnectionServiceEventHandler = (event: RBEvent) => any; /** * ConnectionService service events * Can be listened via connectionService.subscribe() API */ export declare enum ConnectionServiceEvents { /** * @eventProperty RAINBOW_ON_CONNECTION_STATE_CHANGE * This RB event is send when the connectionService state change. */ RAINBOW_ON_CONNECTION_STATE_CHANGE = "RAINBOW_ON_CONNECTION_STATE_CHANGE", /** * @eventProperty RAINBOW_ON_TOKEN_STATE_CHANGE * This RB event is send when the connectionService token state change. */ RAINBOW_ON_TOKEN_STATE_CHANGE = "RAINBOW_ON_TOKEN_STATE_CHANGE" } export interface ConnectionService { /** * Register a evenbt handler function for when the connectionService state change. * @param handler - The handler function to register. * @param eventName - (optional) the name of the event to subscribe on. */ subscribe(handler: ConnectionServiceEventHandler, eventName?: string): Subscription; /** * Allow to start the RainbowSDK. * @returns a promise that resolve when RainbowSDK is started and ready to use. * Return the authenticated contact if the autolog success. */ start(): Promise; /** * Allow to stop the RainbowSDK. * @returns a promise that resolve when RainbowSDK is stopped. */ stop(): Promise; /** * Allow to sign-on to Rainbow from a user account that already exists. * @param login - Rainbow hosted user login. * @param password - Rainbow hosted user password. * @param rememberMe - (default: false) When set to true, user token will be stored in local storage for further connections. */ logon(login: string, password: string, rememberMe: boolean): Promise; /** * Allow to sign-on with JWT token to Rainbow from a user account that already exists. * @param token - Rainbow user existing JWT token. */ logonWithToken(token: string): Promise; /** * Permits to log-on as "guest" in a bubble * @param bubblelink - The bubble link. * @param rememberMe - when set to true, the auth token will be stored in localStorage for further connections. */ logonWithBubbleLink(bubblelink: string, rememberMe?: boolean): Promise; /** * Use this method to update the OAuth token which is being used. It is * obligatory to update the token after each renewing. If the token is not * renewed, an event AUTH_TOKEN_EXPIRE will be emitted and the user will be disconnected * @param token - String representing the new AuthToken received after the renewing * @returns A promise that resolve when token is renewed. */ setRenewedToken(token: string): Promise; /** * Allow to sign-on with JWT token to Rainbow from a user account that already exists. * @returns A promise that resolve when user is log-out. */ logout(): Promise; /** * Get the current connection state with the Rainbow Cloud Services * @returns The connection state */ getState(): ConnectionState; /** * Get the current token associated with the connection * @returns The token */ getToken(): string; /** * Get the splatform server connection * @returns The server */ getServer(): string; } /** * @internal */ export declare class ConnectionServiceRB extends Service implements ConnectionService { private eventSubject; private connectionState; private authService; private loggerService; private xmppService; private contactService; private subscribeService; private launchConfiguration; private servicesStarted; private servicesStarting; private subscriptions; autoLogin: boolean; progressEvents: boolean; static getInstance(): ConnectionServiceRB; static build(): ConnectionServiceRB; private constructor(); subscribe(handler: ConnectionServiceEventHandler, eventNames?: string | string[]): Subscription; start(): Promise; stop(): Promise; logon(login: string, password: string, rememberMe?: boolean): Promise; logonWithToken(token: string): Promise; logonWithBubbleLink(bubbleLink: string, rememberMe?: boolean): Promise; setRenewedToken(token: string): Promise; logout(): Promise; getState(): ConnectionState; getToken(): string; getServer(): string; private startServices; private stopServices; private servicesEventListeners; private onXmppConnectionEvent; private onAuthServiceEvent; private sendTokenEvent; private reconnectServices; /** * Method executeActions * @param actionsList - an array of action to executes\ * - actionsList contains several parameters \{ name, action, deps, notBlocking \}\ * - "name" : the name of the targeted service (ex : 'webinarService') (mandatory)\ * - "action" : the name of the method to call on the service (ex: 'start') (mandatory)\ * - "deps" : an array of parameters (used by the "action" methods) (optional)\ * - "notBlocking" : when set to true, even if this "action" call fails the process continue (optional, default = false)\ * - "noWait" : when set to true asyn "actions" are not "awaited" * @returns a promise that resolve when all actions are executed */ private executeActions; private updateConnectionState; } //# sourceMappingURL=connection.service.d.ts.map