import { isBrowser } from "./env"; export type StoredData = { anonymousId: string; auth: { [endpoint: string]: { jwt: string } }; }; export interface DataStore { data: Partial; load(): PromiseLike; save(): PromiseLike; } export const dataStore: DataStore = isBrowser ? null : (() => { const dataFile = require("path").join(require("os").homedir(), ".tabby-client", "agent", "data.json"); const fs = require("fs-extra"); return { data: {}, load: async function () { this.data = (await fs.readJson(dataFile, { throws: false })) || {}; }, save: async function () { await fs.outputJson(dataFile, this.data); }, }; })();