import { ExecutionContext, RequestHandler, RequestInterceptor, TapResponseFrame } from '@iotize/tap/client/api';
import { ScramService } from '@iotize/tap/service/impl/scram';
import { Observable } from 'rxjs';
export interface EncryptionOptions {
    /**
     * true if encryption is enabled, false otherwise
     */
    encryption: boolean;
    /**
     * Initialization vector period is the number of requests sent
     * before API will change the initialization vector keys
     * The lower the period, the more secure it gets, however il will reduce communication
     * performances.
     */
    initializationVectorResetPeriod: number;
    /**
     * Encryption algo options
     */
    keys: EncryptionKeys;
    /**
     * Encrypted frame counter
     */
    frameCounter: number;
}
export interface EncryptionKeys {
    /**
     * Initialization vector used for encoding
     * If undefined, the default initialization vector will be used
     */
    ivEncode?: Uint8Array;
    /**
     * Initialization vector used for decoding
     * If undefined, the default initialization vector will be used
     */
    ivDecode?: Uint8Array;
    /**
     * Session key
     * If undefined, the session key will be regenerated when executing the first command (and if encryption is enabled)
     */
    sessionKey?: Uint8Array;
}
export declare const INITIALIZATION_VECTOR_LENGTH = 16;
export declare type InitializationVectorGeneratorFct = (length: number) => Uint8Array;
declare type ExtenedExecutionContext = ExecutionContext & {
    skipEncryption?: boolean;
};
export declare class ScramInterceptor implements RequestInterceptor {
    scramService: ScramService;
    private _encryptionAlgo?;
    private _ivFrameCounter;
    private _ivSupported;
    private _refreshingInitializationVectorObs?;
    private get encryptionAlgo();
    private _options;
    private _encryptedFrameConverter;
    set ivSupported(v: boolean);
    /**
     * 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 sessionKey(): Uint8Array | undefined;
    /**
     * Get a copy of encryption options
     */
    get options(): EncryptionOptions;
    constructor(scramService: ScramService);
    setEncryptionKeys(options: EncryptionKeys): void;
    getEncryptionKeys(): EncryptionKeys;
    setFrameCounter(value: number): void;
    setInitializationVectorRefreshPeriod(period: number): void;
    intercept(context: ExtenedExecutionContext, next: RequestHandler): Observable<TapResponseFrame>;
    private _sendWithEncryption;
    private _buildEncryptedFrame;
    private _setEncodeIV;
    private _setDecodeIV;
    private _toCallObservable;
    /**
     * Refresh initialization vectors
     */
    refreshInitializationVectors(): Promise<void>;
    initializationVectorGenerator: InitializationVectorGeneratorFct;
    /**
     * Resume encryption session
     */
    resumeEncryption(): void;
    /**
     * Pause encryption without destorying session (session keys will not be removed)
     */
    pauseEncryption(): void;
    /**
     * Initialize a new encrypted sesssion
     * Session key will be changed. Initialization vector too (if firmware supports it)
     */
    newSession(): Promise<Uint8Array>;
    /**
     * Clear encrypted session.
     * Destroys frame counter, session keys and initialization vectors
     * This will also stop encrypted communication if it was running
     */
    clearSession(): void;
    private refreshEncryptionAlgo;
}
export {};
