feat: use state based auth instead of store based (#488)

* misc: switch to state for auth

* fix: class based auth not working
This commit is contained in:
Xylight authored and GitHub committed 2025-02-08 13:49:09 -08:00
1 parent 8c6ff77fac
commit 5651ad475d
83 files changed
+395 -469

No files matched your search

+2 -14
View File
@@ -11,16 +11,6 @@ export const site = writable<GetSiteResponse | undefined>(undefined)
const isURL = (input: RequestInfo | URL): input is URL =>
typeof input == 'object' && 'searchParams' in input
const toURL = (input: RequestInfo | URL): URL | undefined => {
if (isURL(input)) return input
try {
return new URL(input.toString())
} catch (e) {
return
}
}
async function customFetch(
func:
| ((
@@ -67,9 +57,9 @@ export function client({
) => Promise<Response>
auth?: string
} = {}) {
if (!instanceURL) instanceURL = get(profile).instance
if (!instanceURL) instanceURL = profile.data.instance
let jwt = auth ? auth : get(profile)?.jwt
let jwt = auth ? auth : profile.data?.jwt
const headers = jwt ? { authorization: `Bearer ${jwt}` } : {}
@@ -91,8 +81,6 @@ export function getClient(
return client({ instanceURL, func, auth })
}
export const getInstance = () => encodeURIComponent(get(instance))
export async function validateInstance(instance: string): Promise<boolean> {
if (instance == '') return false