12 lines
668 B
JavaScript
12 lines
668 B
JavaScript
import { createCache } from "./lib/createCache.js";
|
|
import { makeAuth } from "./lib/makeAuth.js";
|
|
import { mutexifyAuth } from "./lib/mutexifyAuth.js";
|
|
import { version } from "./lib/version.js";
|
|
const STORAGE_KEY = "_kobold-token";
|
|
const key = (input) => Promise.resolve(`${STORAGE_KEY}-${version(input)}`);
|
|
const cache = createCache(globalThis.localStorage);
|
|
const auth = makeAuth(cache, key);
|
|
export const getAuth = mutexifyAuth(auth);
|
|
export const getUser = (input, init) => getAuth(input, init).then(({ token }) => token?.payload ?? null);
|
|
export const getJwt = (input, init) => getAuth(input, init).then(({ jwt }) => jwt);
|
|
//# sourceMappingURL=browserAuth.js.map
|