import { ApiTokenInfo } from "../types/auth-token"; /** * A simple API token store interface supporting async operations. This * interface is used to store the API token when it has been refreshed * as well as retrieving a token from the store. * * By providing your own [[ApiTokenStore]] implementation, you can for * example easily store the token in the `localStorage` ([[LocalStorageApiTokenStore]]), * under `~/.dfuse//token.json` file ([[OnDiskApiTokenStore]]) or * more generically at any path ([[FileApiTokenStore]]). * * **Note** The [[OnDiskApiTokenStore]] and [[FileApiTokenStore]] are available * only on a Node.js environment. * * @kind Interfaces */ export interface ApiTokenStore { /** * Release any resources hold by this [[ApiTokenStore]] instance. Must * be tolerant to being called multiple times. * * Once called, the instance is assumed unsuable and should never * be invoked anymore. */ release(): void; set: (apiTokenInfo: ApiTokenInfo) => Promise; get: () => Promise; } /** * Represents an in-memory token storage concrete implementation of * a . This simply keep the token in variable and serves * it from there. * * It is **never** persisted and will be reset upon restart of the Browser tab * or process, leading to a new token being issued. * * You should try hard to use a persistent solution so that you re-use the * same token as long as it's valid. */ export declare class InMemoryApiTokenStore { private apiTokenInfo?; release(): void; get(): Promise; set(apiTokenInfo: ApiTokenInfo): Promise; } /** * Represents an [[ApiTokenStore]] that saves the token as a JSON string * in the `localStorage` of the Browser. * * Trying to use this class when `window.localStorage` is not a function * (like in a Node.js environment) will throw an error at construction * time. Use another implementation. If this error is thrown nonetheless * in your Browser, local storage is probably not supported there. * * It is persisted in the local storage of the Browser it will be picked up * upon restart of the Browser tab. */ export declare class LocalStorageApiTokenStore implements ApiTokenStore { private key; private apiTokenInfo?; constructor(key: string); release(): void; get(): Promise; set(apiTokenInfo: ApiTokenInfo): Promise; } /** * Represents an [[ApiTokenStore]] implementation that will save * as a JSON string in plain text in the given file. * * The directory structure is created when it does not exists. * * **Note** This cannot be used in a browser environment */ export declare class FileApiTokenStore implements ApiTokenStore { private filePath; private apiTokenInfo?; constructor(filePath: string); release(): void; get(): Promise; set(apiTokenInfo: ApiTokenInfo): Promise; } /** * Represents an [[ApiTokenStore]] implementation that will save * as a JSON string in a file located at * `~/.dfuse//token.json`. * * The directory structure is created when it does not exists. * * **Note** This cannot be used in a browser environment. */ export declare class OnDiskApiTokenStore extends FileApiTokenStore { constructor(apiKey: string); } /** * Represents an no-op token storage concrete implementation. All operations * are no-op and this should be used when no authentication is required for a given * instance. */ export declare class NoOpApiTokenStore { release(): void; get(): Promise; set(): Promise; }