import { IEncryptedPayload } from "matrix-js-sdk/src/crypto/aes";
/**
 * Utility functions related to the storage and retrieval of access tokens
 */
export declare const ACCESS_TOKEN_STORAGE_KEY = "mx_access_token";
export declare const REFRESH_TOKEN_STORAGE_KEY = "mx_refresh_token";
export declare const ACCESS_TOKEN_IV = "access_token";
export declare const REFRESH_TOKEN_IV = "refresh_token";
export declare const HAS_ACCESS_TOKEN_STORAGE_KEY = "mx_has_access_token";
export declare const HAS_REFRESH_TOKEN_STORAGE_KEY = "mx_has_refresh_token";
/**
 * Try to decrypt a token retrieved from storage
 * Where token is not encrypted (plain text) returns the plain text token
 * Where token is encrypted, attempts decryption. Returns successfully decrypted token, else undefined.
 * @param pickleKey pickle key used during encryption of token, or undefined
 * @param token
 * @param tokenIv initialization vector used during encryption of token eg ACCESS_TOKEN_IV
 * @returns the decrypted token, or the plain text token. Returns undefined when token cannot be decrypted
 */
export declare function tryDecryptToken(pickleKey: string | undefined, token: IEncryptedPayload | string | undefined, tokenIv: string): Promise<string | undefined>;
/**
 * Persist a token in storage
 * When pickle key is present, will attempt to encrypt the token
 * Stores in idb, falling back to localStorage
 *
 * @param storageKey key used to store the token
 * @param initializationVector Initialization vector for encrypting the token. Only used when `pickleKey` is present
 * @param token the token to store, when undefined any existing token at the storageKey is removed from storage
 * @param pickleKey optional pickle key used to encrypt token
 * @param hasTokenStorageKey Localstorage key for an item which stores whether we expect to have a token in indexeddb, eg "mx_has_access_token".
 */
export declare function persistTokenInStorage(storageKey: string, initializationVector: string, token: string | undefined, pickleKey: string | undefined, hasTokenStorageKey: string): Promise<void>;
/**
 * Wraps persistTokenInStorage with accessToken storage keys
 * @param token the token to store, when undefined any existing accessToken is removed from storage
 * @param pickleKey optional pickle key used to encrypt token
 */
export declare function persistAccessTokenInStorage(token: string | undefined, pickleKey: string | undefined): Promise<void>;
/**
 * Wraps persistTokenInStorage with refreshToken storage keys
 * @param token the token to store, when undefined any existing refreshToken is removed from storage
 * @param pickleKey optional pickle key used to encrypt token
 */
export declare function persistRefreshTokenInStorage(token: string | undefined, pickleKey: string | undefined): Promise<void>;
