Files
AstralRinth/packages/api-client/src/state/node-auth.ts
Calum H. 099011a177 feat: modrinth hosting - files tab refactor (#4912)
* feat: api-client module for content v0

* feat: delete unused components + modules + setting

* feat: xhr uploading

* feat: fs module -> api-client

* feat: migrate files.vue to use tanstack

* fix: mem leak + other issues

* fix: build

* feat: switch to monaco

* fix: go back to using ace, but improve preloading + theme

* fix: styling + dead attrs

* feat: match figma

* fix: padding

* feat: files-new for ui page structure

* feat: finalize files.vue

* fix: lint

* fix: qa

* fix: dep

* fix: lint

* fix: lockfile merge

* feat: icons on navtab

* fix: surface alternating on table

* fix: hover surface color

---------

Signed-off-by: Calum H. <contact@cal.engineer>
Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
2026-01-06 00:35:51 +00:00

46 lines
1.1 KiB
TypeScript

import type { NodeAuth } from '../features/node-auth'
/**
* Global node auth state.
* Set by server management pages, read by NodeAuthFeature.
*/
export const nodeAuthState = {
getAuth: null as (() => NodeAuth | null) | null,
refreshAuth: null as (() => Promise<void>) | null,
}
/**
* Configure the node auth state. Call this when entering server management.
*
* @param getAuth - Function that returns current auth or null
* @param refreshAuth - Function to refresh the auth token
*
* @example
* ```typescript
* // In server management page setup
* setNodeAuthState(
* () => fsAuth.value,
* refreshFsAuth,
* )
* ```
*/
export function setNodeAuthState(getAuth: () => NodeAuth | null, refreshAuth: () => Promise<void>) {
nodeAuthState.getAuth = getAuth
nodeAuthState.refreshAuth = refreshAuth
}
/**
* Clear the node auth state. Call this when leaving server management.
*
* @example
* ```typescript
* onUnmounted(() => {
* clearNodeAuthState()
* })
* ```
*/
export function clearNodeAuthState() {
nodeAuthState.getAuth = null
nodeAuthState.refreshAuth = null
}