type ObjectKey = string | number | symbol; type EmptyObject = Record; type UnknownObject = Record; 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; } declare class BaseModuleImpl implements BaseModule { /** * @hidden */ container: Container; /** * @hidden */ constructor(initOptions: InitModuleOptions); } declare global { interface Navigator { getBattery?: () => Promise; } } interface BatteryManager extends EventTarget { level: number; charging: boolean; chargingTime: number; dischargingTime: number; } declare const WEB_SDK_ERROR_SYMBOL: unique symbol; declare class WebSDKError extends Error { /** * @hidden */ [WEB_SDK_ERROR_SYMBOL]?: boolean; /** * Because of using class in different modules (bundled js files) need to override instanceof operator - * different physical instances of the class in different modules should be treated as the same class * @hidden */ static [Symbol.hasInstance](instance: unknown): instance is WebSDKError; } /** * Options to register or unregister a push token. * * @since 5.2.0 */ export interface PushTokenOptions { /** * Push token obtained from a push service provider. * * Must be a non-empty string. */ token: string; /** * Identifier matching the bundle ID specified for a push notification certificate in the Voximplant Control Panel. * * Set it only if push notifications are being sent across multiple web apps via a single Voximplant application, or if multiple push certificates are used. */ bundleId?: string; } /** * Interface for registering push tokens and handling push notifications for incoming calls. * * @since 5.2.0 */ export interface PushService extends BaseModule { /** * Registers a push token for the logged in user in the Voximplant cloud. * * If the user is not yet logged in, the request is queued and sent automatically * once the login process completes. * * Returns a promise that resolves when the token is successfully registered. * * @param options Push token registration options * * @throws * - [PushService.Errors.PushServiceInvalidTokenError] – if the push token is empty or consists entirely of whitespace characters * - [PushService.Errors.PushServiceConnectionClosedError] – if the connection to the Voximplant cloud is closed * before the request can complete * - [PushService.Errors.PushServiceTimeoutError] – if no response is received within the timeout period * after the request is sent to the Voximplant cloud * - [PushService.Errors.PushServiceCancelledError] – if the pending request is canceled, typically when multiple * registration or unregistration requests are made rapidly one after another * - [PushService.Errors.PushServiceInternalError] – if an internal error occurs * * @since 5.2.0 */ registerPushToken: (options: PushTokenOptions) => Promise; /** * Unregisters a push token for the logged in user in the Voximplant cloud. * * If the user is not yet logged in, the request is queued and sent automatically * once the login process completes. * * Returns a promise that resolves when the token is successfully unregistered. * * @param options Push token unregistration options * @throws * - [PushService.Errors.PushServiceInvalidTokenError] – if the push token is empty or consists entirely of whitespace characters * - [PushService.Errors.PushServiceConnectionClosedError] – if the connection to the Voximplant cloud is closed * before the request can complete * - [PushService.Errors.PushServiceTimeoutError] – if no response is received within the timeout period * after the request is sent to the Voximplant cloud * - [PushService.Errors.PushServiceCancelledError] – if the pending request is canceled, typically when multiple * registration or unregistration requests are made rapidly one after another * - [PushService.Errors.PushServiceInternalError] – if an internal error occurs * * @since 5.2.0 */ unregisterPushToken: (options: PushTokenOptions) => Promise; /** * Reports a received push notification back to the Voximplant Cloud. * * The notification data is sent as a JSON string within the notification data message, * available at the `messagePayload.data.voximplant` path. It should be parsed via `JSON.parse()` * before being passed to this method. * * If the user is not yet logged in, the request is queued and the data is sent automatically * once the login process completes. * * Returns a promise that resolves after the notification data is successfully sent to the cloud. * * @param notificationData Voximplant-specific payload from the push notification * @since 5.2.0 */ handlePushNotification: (notificationData: UnknownObject) => Promise; } /** * @hidden */ export declare class PushServiceImpl extends BaseModuleImpl implements PushService { private readonly connection; private readonly login; private readonly logger; private readonly requests; constructor(initModuleOptions: InitModuleOptions); registerPushToken(options: PushTokenOptions): Promise; private registerPushTokenRoutine; unregisterPushToken(options: PushTokenOptions): Promise; private unregisterPushTokenRoutine; handlePushNotification(notificationData: Record): Promise; } /** * Thrown when an internal error occurs. * * @see [PushService.PushService.registerPushToken], [PushService.PushService.unregisterPushToken] * * @folder Errors * @hideconstructor * @since 5.2.0 */ export declare class PushServiceInternalError extends WebSDKError { constructor(); } /** * Thrown when the connection to the Voximplant cloud is closed before a pending * [PushService.PushService.registerPushToken] or [PushService.PushService.unregisterPushToken] * request can complete. * * This indicates that the registration or unregistration process has been interrupted by a loss * of network connectivity or a manual client termination. * * @see [PushService.PushService.registerPushToken], [PushService.PushService.unregisterPushToken] * * @folder Errors * @hideconstructor * @since 5.2.0 */ export declare class PushServiceConnectionClosedError extends WebSDKError { constructor(); } /** * Thrown when the push token provided to [PushService.PushService.registerPushToken] * or [PushService.PushService.unregisterPushToken] is empty or consists entirely of whitespace characters. * * To resolve this, ensure that a valid, non-empty token string obtained from the push service * provider is passed in the options object before calling these methods. * * @see [PushService.PushService.registerPushToken], [PushService.PushService.unregisterPushToken] * * @folder Errors * @hideconstructor * @since 5.2.0 */ export declare class PushServiceInvalidTokenError extends WebSDKError { constructor(); } /** * Thrown when no response to a [PushService.PushService.registerPushToken] or * [PushService.PushService.unregisterPushToken] request is received within the * timeout period after being sent to the Voximplant cloud. * * This typically occurs due to high network latency. Applications should safely * handle this error and consider retrying the operation. * * @see [PushService.PushService.registerPushToken], [PushService.PushService.unregisterPushToken] * * @folder Errors * @hideconstructor * @since 5.2.0 */ export declare class PushServiceTimeoutError extends WebSDKError { constructor(); } /** * Thrown when a pending [PushService.PushService.registerPushToken] or * [PushService.PushService.unregisterPushToken] request is canceled. * * This typically occurs if multiple registration or unregistration requests are made * rapidly one after another, causing earlier pending requests to be aborted. * * @see [PushService.PushService.registerPushToken], [PushService.PushService.unregisterPushToken] * * @folder Errors * @hideconstructor * @since 5.2.0 */ export declare class PushServiceCancelledError extends WebSDKError { constructor(); } /** * @function * * @since 5.2.0 */ export declare const PushServiceLoader: ModuleFactory; export declare const pushServiceToken: Token; export {};