Simpl-Resultat/src/services/authService.ts
le king fu 3b1c41c48e
Some checks are pending
PR Check / rust (push) Waiting to run
PR Check / frontend (push) Waiting to run
PR Check / rust (pull_request) Successful in 22m28s
PR Check / frontend (pull_request) Successful in 2m19s
feat: settings banner when OAuth tokens fall back to file store (#81)
Adds a visible warning in the Settings page when `token_store` has
landed in the file fallback instead of the OS keychain. Without this,
a user on a keychain-less system would silently lose the security
benefit introduced in #78 and never know.

- New `get_token_store_mode` service wrapper in authService.ts.
- New `TokenStoreFallbackBanner` component: fetches the mode on mount,
  renders nothing when mode is `keychain` or null, renders an
  amber warning card when mode is `file`.
- Mounted in SettingsPage right after AccountCard so it sits next to
  the account state the user can fix (log out + log back in once the
  keychain is available).
- i18n keys under `account.tokenStore.fallback.*` in fr/en.

Refs #66

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-14 08:18:41 -04:00

34 lines
965 B
TypeScript

import { invoke } from "@tauri-apps/api/core";
export interface AccountInfo {
email: string;
name: string | null;
picture: string | null;
subscription_status: string | null;
}
export async function startOAuth(): Promise<string> {
return invoke<string>("start_oauth");
}
export async function refreshAuthToken(): Promise<AccountInfo> {
return invoke<AccountInfo>("refresh_auth_token");
}
export async function getAccountInfo(): Promise<AccountInfo | null> {
return invoke<AccountInfo | null>("get_account_info");
}
export async function checkSubscriptionStatus(): Promise<AccountInfo | null> {
return invoke<AccountInfo | null>("check_subscription_status");
}
export async function logoutAccount(): Promise<void> {
return invoke<void>("logout");
}
export type TokenStoreMode = "keychain" | "file";
export async function getTokenStoreMode(): Promise<TokenStoreMode | null> {
return invoke<TokenStoreMode | null>("get_token_store_mode");
}