type ObjectKey = string | number | symbol; type EmptyObject = Record; type OnValueChangeCallback = (newValue: T, oldValue: T) => unknown | Promise; type UnwatchFunction = () => void; interface WatchOptions { /** * Whether the callback should be called only once. The default value is false. */ once?: boolean; /** * A function that returns a boolean to determine if the callback should be called. * The guard not set by default. * * @since 5.1.0 */ guard?: (newValue: T, oldValue: T) => boolean; /** * Whether the callback should be removed after calling the clear method. The default value is true. */ clearable?: boolean; /** * An AbortSignal. The watch callback will be removed when the abort() method of the AbortController which owns the AbortSignal is called. * See [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) for details. * * @since 5.1.0 */ signal?: AbortSignal; /** * Whether the callback should be called immediately after being added. The default value is false. * * @since 5.1.0 */ immediate?: boolean; } interface Watchable { /** * Current value of the observable property. */ value: T; /** * Previous value of the observable property. */ get oldValue(): T; /** * Subscribes to the value changes. * * When the value is changed, the [Core.Watchable.OnValueChangeCallback] callback is triggered. * * Returns [Core.Watchable.UnwatchFunction], to unwatch observable value changes. * * @param onValueChangeCallback Observer to be triggered when the value is changed * @param options Options */ watch: (onValueChangeCallback: OnValueChangeCallback, options?: WatchOptions) => UnwatchFunction; /** * Stops triggering the specified callback on the value change. * * @param onValueChangeCallback Observer that should not be triggered anymore */ unwatch: (onValueChangeCallback: OnValueChangeCallback) => void; /** * Clears all observers for this watchable excluding the ones created with [Core.Watchable.WatchOptions.clearable]: false. */ clear: () => void; /** * Locks the watchable from mutations. The value becomes readonly. * @hidden */ lock: (key: string) => void; /** * Unlocks the watchable. The value becomes mutable again. * @hidden */ unlock: (key: string) => void; } interface ReadonlyWatchable extends Watchable { } interface BaseBusEvent { name: string; } interface ListenerOptions { /** * Whether a listener should be invoked at most once after being added. * The default value is false. */ once?: boolean; /** * A function that returns a boolean to determine if the listener should be called. * The guard not set by default. * * @since 5.1.0 */ guard?: (event: Extract) => boolean; /** * An AbortSignal. The listener will be removed when the abort() method of the AbortController which owns the AbortSignal is called. * See [AbortController](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) for details. * * @since 5.1.0 */ signal?: AbortSignal; } type Listener = (event: Extract) => void | Promise; type AddEventListener = (event: EventName, listener: Listener, options?: ListenerOptions) => void; type RemoveEventListener = (event: EventName, listener: Listener) => void; declare enum ContainerEvent { ModuleRegistered = "MODULE_REGISTERED" } interface ModuleRegisteredEvent extends BaseBusEvent { name: ContainerEvent.ModuleRegistered; token: Token; } type ContainerEvents = ModuleRegisteredEvent; interface Container { readonly key: string; registerModule: (module: ModuleLoader) => void; registerModules: (modules: ModuleLoader[]) => void; getModule(token: Token, required?: false): Module | undefined; getModule(token: Token, required: true): Module; getModuleAsync: (token: Token) => Promise; addEventListener: AddEventListener; removeEventListener: RemoveEventListener; } interface Token { name: string; module?: ModuleType; } interface InitModuleOptions { container: Container; key: string; } interface ModuleLoader { token: Token; options: Options; required: Token[]; setup: (initOptions: InitModuleOptions) => ModuleType; } type ModuleFactory = Options extends EmptyObject ? () => ModuleLoader : (options: Options) => ModuleLoader; interface BaseModule { /** * @hidden */ container: Container; } interface PasswordLoginOptions { /** * Full user name, including app and account name, e.g., someuser@someapp.youraccount.voximplant.com. */ username: string; /** * User password. */ password: string; /** * Optional device (browser) identifier. * * If a web application is going to authenticate with a renewable tokens via [Core.Client.loginAccessToken], * it is required to provide this identifier. */ deviceToken?: string; } interface OneTimeKeyLoginOptions { /** * Full user name, including app and account name, e.g., someuser@someapp.youraccount.voximplant.com. */ username: string; /** * Hash that has been generated via the following formula: `MD5(oneTimeKey+"|"+MD5(user+":voximplant.com:"+password))`. */ hash: string; /** * Optional device (browser) identifier. * * If a web application is going to authenticate with a renewable tokens via [Core.Client.loginAccessToken], * it is required to provide this identifier. */ deviceToken?: string; } interface RequestOneTimeKeyOptions { /** * Full user name, including app and account name, e.g., someuser@someapp.youraccount.voximplant.com. */ username: string; } interface AccessTokenLoginOptions { /** * Full user name, including app and account name, e.g., someuser@someapp.youraccount.voximplant.com. */ username: string; /** * Access token. * * It is obtained either from [Core.LoginResult.loginTokens], or via [Core.Client.refreshTokens]. */ accessToken: string; /** * Device (browser) identifier. * * Should be the same as the identifier provided for [Core.Client.login] or [Core.Client.loginOneTimeKey]. */ deviceToken: string; } interface RefreshTokenOptions { /** * Full user name, including app and account name, e.g., someuser@someapp.youraccount.voximplant.com. */ username: string; /** * Refresh token obtained from [Core.LoginResult.loginTokens]. */ refreshToken: string; /** * Device (browser) identifier. * * Should be the same as the identifier provided for [Core.Client.login] or [Core.Client.loginOneTimeKey]. */ deviceToken: string; } interface LoginTokens { /** * Time in seconds for the access token to expire. */ accessExpire: number; /** * Access token that can be used before accessExpire. */ accessToken: string; /** * Time in seconds for the refresh token to expire. */ refreshExpire: number; /** * Refresh token that can be used one time before refreshExpire. */ refreshToken: string; } interface LoginResult { /** * Display name of the logged in user. */ displayName?: string; /** * Auth parameters that can be used to log in via an access token. */ loginTokens?: LoginTokens; } declare global { interface Navigator { getBattery?: () => Promise; } } interface BatteryManager extends EventTarget { level: number; charging: boolean; chargingTime: number; dischargingTime: number; } interface ConnectionOptions { /** * * Array of the media gateway servers for connection. The default value is an empty array. */ servers?: string[]; /** * Whether the SDK should try to reconnect to the Voximplant Cloud if the connection has been lost for some reason. * The default value is true. */ autoReconnect?: boolean; /** * Node the Voximplant account belongs to. * * Find more information about [Core.ConnectionNode] in the [getting started guide](/docs/getting-started/platform/web). */ node: ConnectionNode; } declare enum ConnectionNode { NODE_1 = "NODE_1", NODE_2 = "NODE_2", NODE_3 = "NODE_3", NODE_4 = "NODE_4", NODE_5 = "NODE_5", NODE_6 = "NODE_6", NODE_7 = "NODE_7", NODE_8 = "NODE_8", NODE_9 = "NODE_9", NODE_10 = "NODE_10", NODE_11 = "NODE_11", /** * @since 5.1.0 */ NODE_12 = "NODE_12", /** * @since 5.2.0 */ NODE_13 = "NODE_13" } /** * @folder Events */ export declare enum ClientEvent { /** * Triggered if the connection to the Voximplant Cloud has been closed. * @cast Core.Events.ClientDisconnectedPayload */ Disconnected = "DISCONNECTED" } /** * @internal */ export interface BaseClientEvent extends BaseBusEvent { name: Name; payload: Payload; } /** * Enum that contains reasons why the connection to the Voximplant Cloud has been closed, * provided by the [Core.Events.ClientEvent.Disconnected] event. * * @folder Events */ export declare enum ClientDisconnectReason { /** * Connection to the Voximplant Cloud has been closed by the [Core.Client.disconnect] method call. */ UserInitiated = "USER_INITIATED", /** * Connection to the Voximplant Cloud has been closed due to network issues. */ ConnectionLost = "CONNECTION_LOST" } /** * @folder Events */ export interface ClientDisconnectedPayload { /** * Disconnect reason. */ reason: ClientDisconnectReason; } /** * @folder Events * @interface */ export type ClientDisconnected = BaseClientEvent; /** * @folder Events */ export type AnyClientEvent = ClientDisconnected; /** * Enum that contains the client states. */ export declare enum ClientState { /** * Client is currently disconnected. */ Disconnected = "DISCONNECTED", /** * Client is currently disconnecting. */ Disconnecting = "DISCONNECTING", /** * Client is currently connecting. */ Connecting = "CONNECTING", /** * Client is currently connected. */ Connected = "CONNECTED", /** * Client is currently logging in. */ LoggingIn = "LOGGING_IN", /** * Client is currently logged in. */ LoggedIn = "LOGGED_IN", /** * Client is currently reconnecting. */ Reconnecting = "RECONNECTING" } /** * Registers a handler for the specified event. * * One event can have more than one handler; handlers are executed in order of their registration. * @interface * @internal */ export type DocClientAddEventListener = ( /** * Event name */ eventName: ClientEvent, /** * Handler function that is triggered when an event of the specified type occurs */ listener: (event: AnyClientEvent) => void | Promise, /** * Object that specifies characteristics about the event listener */ options: ListenerOptions) => void; /** * Removes a previously registered handler for the specified event. * * @interface * @internal */ export type DocClientRemoveEventListener = ( /** * Event name */ eventName: ClientEvent, /** * Handler function to remove from the event target */ listener: (event: AnyClientEvent) => void | Promise) => void; /** * Interface that provides API to connect and log in to the Voximplant Cloud. */ export interface Client extends BaseModule { /** * Watchable property that allows getting the current client state and observe its changes. */ state: ReadonlyWatchable; /** * Connects to the Voximplant Cloud. * * Returns a promise that is resolved when the connection to the Voximplant Cloud is established. * @param options Connect options * @throws One of [Core.ConnectionErrors] */ connect: (options: ConnectionOptions) => Promise; /** * Disconnects from the Voximplant Cloud. * * Returns a promise that is resolved when the connection to the Voximplant Cloud is closed. */ disconnect: () => Promise; /** * Logs in a user with a password to the Voximplant Cloud. * * Returns a promise that is resolved to a [Core.LoginResult] object. * * @param options Options to log in with a password * @throws One of [Core.LoginErrors] */ login: (options: PasswordLoginOptions) => Promise; /** * Logs in a user with a one-time key to the Voximplant Cloud. * * Returns a promise that is resolved to a [Core.LoginResult] object. * * @param options Options to log in with a one-time key * @throws One of [Core.LoginErrors] */ loginOneTimeKey: (options: OneTimeKeyLoginOptions) => Promise; /** * Logs in a user with an access token to the Voximplant Cloud. * * Returns a promise that is resolved to a [Core.LoginResult] object. * * @param options Options to log in with an access token * @throws One of [Core.LoginErrors] */ loginAccessToken: (options: AccessTokenLoginOptions) => Promise; /** * Generates a one-time login key to use in the automated login process. * * For additional information please see the [guide](/docs/guides/sdk/authorization-onetimekey). * * Returns a promise that is resolved to a string that represents the one-time key. * * @param options Options to request a one-time key * @throws One of [Core.LoginErrors] */ requestOneTimeKey: (options: RequestOneTimeKeyOptions) => Promise; /** * Performs a refresh of login tokens required for [Core.Client.loginAccessToken]. * * Returns a promise that is resolved to a [Core.LoginTokens] object. * * @param options Options to refresh tokens * @throws One of [Core.LoginErrors] */ refreshTokens: (options: RefreshTokenOptions) => Promise; /** * @reinterpret Core.DocClientAddEventListener */ addEventListener: AddEventListener; /** * @reinterpret Core.DocClientRemoveEventListener */ removeEventListener: RemoveEventListener; } /** * @hidden */ export declare const clientToken: Token; /** * @hidden */ export declare const ClientLoader: ModuleFactory; export {};