UNPKG

@repugraf/cross-domain-storage

Version:

Enables shared cross domain localStorage and sessionStorage

42 lines 1.37 kB
import { IResponseMessage, IStorageType } from "./shared.js"; interface IClientConfig { /** Domain to connect to */ domain: string; /** Timeout limit in ms after which action will be rejected (default - `10000`) */ timeout?: number; /** Will log errors and warnings */ debug?: boolean; /** Target element for iframe (default `document.body`) */ target?: HTMLElement; /** Duplicates storage operation into current domain storage */ duplicate?: boolean; /** If cross domain operation fails will fallback to current domain storage operations */ fallback?: boolean; } /** * Creates client instance * * Call `connect` to start communications with the server * * ```js * const client = getClient({ * domain: "https://www.example.com" * }); * * await client.connect(); * * await client.set("key", "val"); * * await client.get("key"); * ``` */ declare const getClient: (config: IClientConfig) => { connect: (_timeout?: number) => Promise<void>; disconnect: () => void; set: (key: string, value: string, storageType?: IStorageType) => Promise<IResponseMessage>; get: (key: string, storageType?: IStorageType) => Promise<any>; remove: (key: string, storageType?: IStorageType) => Promise<any>; readonly isConnected: boolean; }; export { getClient }; //# sourceMappingURL=client.d.ts.map