import { IoTizeClient, Response, ResponseInterface } from '@iotize/device-client.js/client/api';
import { ComProtocol } from '@iotize/device-client.js/protocol/api';
import { BehaviorSubject, Observable } from 'rxjs';
import { ApiConfig, Routes } from './config/api-config';
import { EncryptionKeys, ScramInterceptor, ScramInterceptorOptions } from './interceptors/scram-interceptor';
import { IoTizeDeviceService } from './iotize-device-services';
import { InterfaceLock, MultiRequest } from './model';
import { ScramAuth } from './scram';
import { ServiceCallType } from './service';
import { SinglePacketLoader } from './single-packet/single-packet-loader';
import { TapConfigurator } from './tap-configurator';
import { TapInterface } from './tap-device';
import { VariableManager } from './target-variable';
import { BundleManager } from './target-variable/bundle-manager';
import { ConverterProvider } from './util/converter-provider';
export { EncryptionKeys };
export declare type ServiceClass = {
    new (client: IoTizeClient, converterProvider: ConverterProvider): any;
};
export interface Lwm2mCall {
    commandType: 'GET' | 'PUT' | 'POST';
    path: string;
    responseType?: string;
    params?: {
        [key: string]: string;
    };
}
export interface SessionState {
    groupId: number;
    startTime?: Date;
    lifeTime: number;
    name: string;
}
export interface EncryptionSessionState {
    enabled?: boolean;
    keys?: EncryptionKeys;
    frameCounter?: number;
}
export interface SecurityOptions {
    disableFactoryResetByResource: boolean;
    disableLoginWithUID: boolean;
    disableFactoryResetByHardware: boolean;
    scramActivated: boolean;
    hashPassword: boolean;
}
export interface DisconnectOptions {
    clearSession?: boolean;
    clearCache?: boolean;
}
export declare const NFC_PAIRING_COMMAND: Uint8Array;
export declare type Tap = IoTizeDevice;
export declare namespace Tap {
    function create(): Tap;
    function fromProtocol(protocol: ComProtocol): Tap;
}
/**
 *
 * @deprecated Use Tap instead
 */
export declare class IoTizeDevice implements TapInterface {
    static TAG: string;
    static IOTIZE_TRAME_MAX_SIZE: number;
    static INITIAL_SESSION_STATE: SessionState;
    /**
     * Cache log info
     */
    protected _interfaceLockOptions?: InterfaceLock;
    protected _variableManager?: VariableManager;
    protected _bundleManager?: BundleManager;
    protected _services: IoTizeDeviceService;
    protected _client: IoTizeClient;
    protected _sessionState$: BehaviorSubject<SessionState>;
    protected _apiConfig: ApiConfig;
    protected _lwm2m: Lwm2mInterface;
    protected _scramAuth?: ScramAuth;
    protected _scramInterceptor: ScramInterceptor;
    private _singlePacket?;
    set lockOptions(value: InterfaceLock);
    get currentSessionState(): SessionState;
    get singlePacket(): SinglePacketLoader;
    /**
     * Get cached lock options
     * May no be synchronized with real device state
     */
    get lockOptions(): InterfaceLock;
    /**
     * Setter for the session key
     * @param key if null, it will stop encryption and remove session key. If true it will update session key used for encryption
     */
    set sessionKey(key: Uint8Array | undefined);
    /**
     * Get current session key for encrypted communicatioin
     */
    get sessionKey(): Uint8Array | undefined;
    get client(): IoTizeClient;
    set client(client: IoTizeClient);
    /**
     * Listen to session state changed
     */
    get sessionState(): Observable<SessionState>;
    constructor(client: IoTizeClient);
    /**
     * @deprecated use {@link Tap.create()} instead
     *
     */
    static create(): IoTizeDevice;
    /**
     * @deprecated
     * @param protocol
     */
    static fromProtocol(protocol: ComProtocol): IoTizeDevice;
    /**
     * Enable/Disable encrytion when communicating with a device
     * @param enable true if requests must be encrypted
     * @param resetSessionKey true if you want to reset the the session key.
     * @param refreshInitializationVector true if you want to change initialization vectors
     *
     */
    encryption(enable: boolean, resetSessionKey?: boolean, refreshInitializationVector?: boolean): Promise<void>;
    setEncryptionKeys(keys: EncryptionKeys): void;
    setEncryptedFrameCounter(frameCounter: number): void;
    getEncryptionOptions(): ScramInterceptorOptions;
    refreshEncryptionInitializationVector(): Promise<void>;
    setInitializationVectorRefreshPeriod(period: number): void;
    /**
     * Enable/Disable encrytion when communicating with a device
     * @param enable true if requests must be encrypted
     * @param resetSessionKey true if you want to reset the the session key.
     * @param refreshInitializationVector true if you want to change initialization vectors
     *
     * @deprecated use {@link encryption()} instead
     */
    enableEncryption(enable: boolean, resetSessionKey?: boolean, refreshInitializationVector?: boolean): Promise<void>;
    get protocol(): ComProtocol;
    /**
     * Connect with the given communication protocol
     * TODO what if there is already a connected communication protocol
     * @param protocol
     */
    connect(protocol?: ComProtocol): Promise<void>;
    /**
     * Disconnect device
     */
    disconnect(options?: DisconnectOptions): Promise<void>;
    isConnected(): boolean;
    get variables(): VariableManager;
    get bundles(): BundleManager;
    getMaxFrameSize(): Promise<number>;
    /**
     * Setter for hashPassword option
     * @deprecated this should not be used anymore as this configuration must be read from the tap
     */
    /**
     * Return true if password will be hashed
     * @deprecated
     */
    /**
     * Tap logout
     * Reject if logout failed
     */
    logout(): Promise<void>;
    /**
     * Change password for the groupId (If groupId is not specified, it will be changed for the current group id)
     * @param newPassword the new password
     * @param userIdOrName default to the current group id
     * @param userPassword the current user password. if provided it will perform a login before changing password
     */
    changePassword(newPassword: string, userId?: number, userPassword?: string): Promise<void>;
    /**
     * Configure current tap instance thanks to a TapConfigurator
     * @param configurator
     */
    configure<DataType>(configurator: TapConfigurator<DataType>): Promise<DataType>;
    /**
     *
     * @param protocol
     */
    useComProtocol(protocol: ComProtocol | string): this;
    /**
     * Tap login
     *
     */
    login(username: string, password: string, refreshSessionState?: boolean): Promise<boolean>;
    private _isLoggedIn;
    /**
     *
     * @param commands run mutiple requests in one
     * @param expectedCodeRet
     */
    multiRequests(commands: ServiceCallType[], expectedCodeRet?: MultiRequest.ExpectedResultCode | number): Promise<ResponseInterface<any>[]>;
    /**
     * Send an NFC pairing request
     */
    nfcPairing(): Promise<Response<Uint8Array>>;
    get scramAuth(): ScramAuth;
    get rooter(): Routes;
    get apiConfig(): ApiConfig;
    get service(): IoTizeDeviceService;
    /**
     * @experimental
     */
    get lwm2m(): Lwm2mInterface;
    /**
     * Initialize device cache
     */
    protected _initCache(): void;
    /**
     * Clear cache
     */
    clearCache(): void;
    /**
     * Clear session encryption keys
     */
    clearSession(): void;
    /**
     * Read session state from the device
     * This will perform a few tap requests
     *
     * TODO we should invalidate encryption key if session state changed
     * TODO we should use multi commands to improve performance
     */
    refreshSessionState(): Promise<SessionState>;
    /**
     * Get lock info
     */
    protected getLockInfo(): Promise<InterfaceLock>;
    getSecurityOptions(): Promise<SecurityOptions>;
}
export declare class Lwm2mInterface {
    client: IoTizeClient;
    apiConfig: ApiConfig;
    constructor(client: IoTizeClient, apiConfig: ApiConfig);
    get(path: string, body?: any): Promise<Response<any>>;
    put(path: string, body: any): Promise<Response<any>>;
    post(path: string, body?: any): Promise<Response<any>>;
    call(call: ServiceCallType): Promise<Response<any>>;
}
