import { EDecryptionError, ISender, IReceiver, IAnnonymous, IEncryptedMessage } from '@consento/crypto'; import { IEncodable, ITimeoutOptions, IAbortOptions } from '../util'; export * from '@consento/crypto/types'; export interface INotificationsTransport { subscribe(receivers: Iterable, opts?: IAbortOptions): Promise; unsubscribe(receivers: Iterable, opts?: IAbortOptions): Promise; reset(receivers: Iterable, opts?: IAbortOptions): Promise; send(channel: IAnnonymous, message: IEncryptedMessage, opts?: IAbortOptions): Promise; } export interface INotificationControl { error(error: Error): void; message(receiverIdBase64: string, encryptedMessage: IEncryptedMessage): Promise; reset(): Promise; } export declare type INewNotificationsTransport = (control: INotificationControl) => TTransport; export interface INotificationsOptions { transport: INewNotificationsTransport; error?: (error: Error) => void; } export interface ISubscribeOptions extends ITimeoutOptions { force?: boolean; } export interface IReceiveOptions extends ITimeoutOptions { filter?: IBodyFilter; } export declare enum ENotificationType { error = "error", success = "success" } export declare enum EErrorCode { unexpectedReceiver = "unexpected-receiver", transportError = "transport-error", decryptionFailed = "decryption-failed" } export declare type INotificationError = IDecryptionError | IUnexpectedReceiverError | ITransportError | IDecryptionFailedError; export interface IDecryptionError { type: ENotificationType.error; code: EDecryptionError; receiver: IReceiver; channelIdBase64: string; } export interface IUnexpectedReceiverError { type: ENotificationType.error; code: EErrorCode.unexpectedReceiver; channelIdBase64: string; } export interface ITransportError { type: ENotificationType.error; code: EErrorCode.transportError; error: Error; } export interface IDecryptionFailedError { type: ENotificationType.error; code: EErrorCode.decryptionFailed; error: Error; channelIdBase64: string; } export interface ISuccessNotification { type: 'success'; body: T; receiver: IReceiver; channelIdBase64: string; } export declare type IAndroidNotificationPriority = 'min' | 'low' | 'default' | 'high' | 'max'; export interface INotificationContentInput { title?: string; subtitle?: string; body?: string; data?: { [key: string]: unknown; }; badge?: number; sound?: boolean | string; vibrate?: number[]; priority?: IAndroidNotificationPriority; color?: string; autoDismiss?: boolean; sticky?: boolean; launchImageName?: string; attachments?: Array<{ url: string; identifier?: string; typeHint?: string; hideThumbnail?: boolean; thumbnailClipArea?: { x: number; y: number; width: number; height: number; }; thumbnailTime?: number; }>; } export declare type INotification = INotificationError | ISuccessNotification; export declare type INotificationProcessor = (message: INotification) => Promise; export declare type IBodyFilter = (body: IEncodable) => body is T; export interface IConnection { sender: ISender; receiver: IReceiver; } export interface INotifications { readonly transport: TTransport; subscribe(receivers: IReceiver[], opts?: ISubscribeOptions): Promise; unsubscribe(receivers: IReceiver[], opts?: ISubscribeOptions): Promise; reset(receivers: IReceiver[], opts?: ITimeoutOptions): Promise; processors: Set; send(sender: ISender, message: IEncodable, opts?: ITimeoutOptions): Promise; receive(receiver: IReceiver, opts?: IReceiveOptions): Promise<{ afterSubscribe: Promise; }>; sendAndReceive(connection: IConnection, message: IEncodable, opts?: IReceiveOptions): Promise<{ afterSubscribe: Promise; }>; }