mirror of
https://github.com/modrinth/code.git
synced 2026-08-30 11:36:05 +00:00
* add account switcher, migrate context menus to overflow menu system, update version filter controls, only pad instance icons * app account switcher, improve some context menus, theme stuff * prepr * handle reauthentication * fix a couple sign in issues, admin page cleanup, fix org status badges, fix official account badge, open in local keybind, publish plus icons * rename generic menus to ButtonMenu (& types) * fix hydration issue w/ dropdowns + middleware error
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
/**
|
|
* All theseus API calls return serialized values (both return values and errors);
|
|
* So, for example, addDefaultInstance creates a blank instance object, where the Rust struct is serialized,
|
|
* and deserialized into a usable JS object.
|
|
*/
|
|
import { invoke } from '@tauri-apps/api/core'
|
|
|
|
export type ModrinthCredentials = {
|
|
session: string
|
|
expires: string
|
|
user_id: string
|
|
active: boolean
|
|
}
|
|
|
|
export type ModrinthAuthFlow = 'sign-in' | 'sign-up'
|
|
|
|
export async function login(
|
|
flow: ModrinthAuthFlow = 'sign-in',
|
|
addAccount = false,
|
|
): Promise<ModrinthCredentials> {
|
|
return await invoke('plugin:mr-auth|modrinth_login', { flow, addAccount })
|
|
}
|
|
|
|
export async function logout(): Promise<void> {
|
|
return await invoke('plugin:mr-auth|logout')
|
|
}
|
|
|
|
export async function get(): Promise<ModrinthCredentials | null> {
|
|
return await invoke('plugin:mr-auth|get')
|
|
}
|
|
|
|
export async function getAll(): Promise<ModrinthCredentials[]> {
|
|
return await invoke('plugin:mr-auth|get_all')
|
|
}
|
|
|
|
export async function setActive(userId: string): Promise<void> {
|
|
return await invoke('plugin:mr-auth|set_active', { userId })
|
|
}
|
|
|
|
export async function removeUser(userId: string): Promise<void> {
|
|
return await invoke('plugin:mr-auth|remove_account', { userId })
|
|
}
|
|
|
|
export async function cancelLogin(): Promise<void> {
|
|
return await invoke('plugin:mr-auth|cancel_modrinth_login')
|
|
}
|