Bin
2025-12-16 9e0b2ba2c317b1a86212f24cbae3195ad1f3dbfa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { getApiInstance } from "@humansignal/core";
import { atomWithQuery } from "jotai-tanstack-query";
 
type AuthTokenSettings = {
  api_tokens_enabled: boolean;
  legacy_api_tokens_enabled: boolean;
  api_token_ttl_days: number;
};
 
export const TOKEN_SETTINGS_KEY = "api-settings";
 
export const settingsAtom = atomWithQuery(() => ({
  queryKey: [TOKEN_SETTINGS_KEY],
  async queryFn() {
    const api = getApiInstance();
    const result = await api.invoke<AuthTokenSettings>("accessTokenSettings");
 
    if (!result.$meta.ok) {
      return { error: true };
    }
 
    return result;
  },
}));