Compare commits

...
Author SHA1 Message Date
GRAB Racem a20628d334 fix(config): fail on a malformed config.json and escape install.sh values
config.Load discarded the json.Unmarshal error, so a config.json that did not
parse was treated as absent: startup reported "no database config found"
and skill_dir silently fell back to the default. Load now returns read and
parse errors (a missing file is still not an error); PostgresDSN and SkillDir
pass them up, and main exits with the message.

install.sh wrote the database values into config.json unescaped, so a password
containing " or \ produced invalid JSON, which the old Load then ignored. The
values are now JSON-escaped and the port must be numeric. The .env sed
replacements escape \, | and & so those characters no longer break the
substitution or get rewritten by it.
2026-11-03 23:22:34 +01:00
BaaRai 23cf14cf0a Merge pull request #137 from BaaRai/fix/auth-init-setup-token
fix(auth): require a setup token for /api/auth/init and bind 8787 to localhost
2026-11-03 22:22:30 +01:00
BaaRai 5bad722593 fix(auth): make the published bind address configurable
Publishing 127.0.0.1:8787 removed the only working access path for installs
reached through a host or WSL IP, without an obvious way back. Keep loopback as
the default and let ARTEX_BIND_ADDR override it (0.0.0.0 restores the old
behaviour; the setup token still protects the first-run claim).
2026-11-03 22:18:27 +01:00
GRAB Racem 2aab3e8210 fix(auth): require a setup token for /api/auth/init and bind 8787 to localhost
POST /api/auth/init accepted any caller while auth.password_hash was empty,
so whoever reached port 8787 first could set the admin password and take the
instance. When no password is set at startup, the server now generates a
random one-time setup token and writes it to the server log. authInit
compares it in constant time, rejects a missing or wrong token with 403, and
clears it once the password is stored.

The setup page has a field for the token and api.initPassword sends it.
docker-compose publishes 8787 on 127.0.0.1 only, like 8788. README says where
to find the token.
2026-11-03 22:18:27 +01:00
BaaRai d45f0c7811 Merge pull request #136 from BaaRai/fix/shell-env-secrets
fix(security): remove startup secrets from the environment before child processes spawn
2026-11-03 22:17:26 +01:00
12 changed files with 206 additions and 30 deletions
+3
View File
@@ -1,5 +1,8 @@
# Docker deployment configuration (copy to .env) # Docker deployment configuration (copy to .env)
# The image is built locally by `docker compose build`; there is no registry tag. # The image is built locally by `docker compose build`; there is no registry tag.
# Address the web UI is published on. 127.0.0.1 keeps it host-local; set 0.0.0.0
# to reach it from another machine or from Windows when ARTEX runs inside WSL.
ARTEX_BIND_ADDR=127.0.0.1
POSTGRES_USER=artex POSTGRES_USER=artex
POSTGRES_PASSWORD=change-me-please POSTGRES_PASSWORD=change-me-please
POSTGRES_DB=artex POSTGRES_DB=artex
+3
View File
@@ -88,6 +88,9 @@ The script will: detect / auto-install Docker → then let you choose **① all-
- **② Local run**: choose a database (connect to an existing one / start one with Docker) → generates `config.json` → `go` builds the embedded single binary → starts. - **② Local run**: choose a database (connect to an existing one / start one with Docker) → generates `config.json` → `go` builds the embedded single binary → starts.
Once installed, open **http://localhost:8787** (on first entry, `/setup` sets the admin password). Once installed, open **http://localhost:8787** (on first entry, `/setup` sets the admin password).
`/setup` asks for a one-time setup token: while no password is set, the backend prints it at startup in its log (`docker compose logs artex | grep "Setup token"`, or the terminal running `./start.sh`).
The web UI is published on `127.0.0.1` by default. To reach it from another machine, or from Windows when ARTEX runs inside WSL, set `ARTEX_BIND_ADDR=0.0.0.0` in `.env` (the setup token still protects the first-run claim), or keep loopback and use a reverse proxy or an SSH tunnel.
### Option 2: Docker Compose (manual) ### Option 2: Docker Compose (manual)
+5 -1
View File
@@ -88,7 +88,11 @@ func run() int {
} }
defer mgr.Close() defer mgr.Close()
skillDir := config.SkillDir() skillDir, err := config.SkillDir()
if err != nil {
log.Printf("[config] %v", err)
return 1
}
if abs, err := filepath.Abs(skillDir); err == nil { if abs, err := filepath.Abs(skillDir); err == nil {
skillDir = abs skillDir = abs
} }
+33 -14
View File
@@ -4,7 +4,9 @@ package config
import ( import (
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io/fs"
"net/url" "net/url"
"os" "os"
"path/filepath" "path/filepath"
@@ -96,16 +98,23 @@ func Path() string {
return candidates[0] return candidates[0]
} }
// Load reads and parses the config file. A missing/unreadable file yields a zero // Load reads and parses the config file. A missing file yields a zero Config (so
// Config (so callers fall back to defaults) rather than an error. // callers fall back to defaults). A file that exists but cannot be read or parsed
func Load() Config { // is an error: ignoring it would run with defaults the operator did not choose.
func Load() (Config, error) {
var c Config var c Config
b, err := os.ReadFile(Path()) path := Path()
if err != nil { b, err := os.ReadFile(path)
return c if errors.Is(err, fs.ErrNotExist) {
return c, nil
} }
_ = json.Unmarshal(b, &c) if err != nil {
return c return c, fmt.Errorf("read config file %s: %w", path, err)
}
if err := json.Unmarshal(b, &c); err != nil {
return Config{}, fmt.Errorf("parse config file %s: %w", path, err)
}
return c, nil
} }
// SkillDir returns the skill root directory with precedence: // SkillDir returns the skill root directory with precedence:
@@ -113,17 +122,23 @@ func Load() Config {
// env ARTEX_SKILL_DIR > config file (skill_dir) > BaseDir()/skills // env ARTEX_SKILL_DIR > config file (skill_dir) > BaseDir()/skills
// //
// The directory is created if it does not exist. // The directory is created if it does not exist.
func SkillDir() string { func SkillDir() (string, error) {
var d string var d string
if v := strings.TrimSpace(os.Getenv("ARTEX_SKILL_DIR")); v != "" { if v := strings.TrimSpace(os.Getenv("ARTEX_SKILL_DIR")); v != "" {
d = v d = v
} else if v := strings.TrimSpace(Load().SkillDir); v != "" {
d = v
} else { } else {
d = filepath.Join(BaseDir(), "skills") c, err := Load()
if err != nil {
return "", err
}
if v := strings.TrimSpace(c.SkillDir); v != "" {
d = v
} else {
d = filepath.Join(BaseDir(), "skills")
}
} }
_ = os.MkdirAll(d, 0o755) _ = os.MkdirAll(d, 0o755)
return d return d, nil
} }
// PostgresDSN resolves the connection string with precedence: // PostgresDSN resolves the connection string with precedence:
@@ -138,7 +153,11 @@ func PostgresDSN() (dsn, source string, err error) {
if v := strings.TrimSpace(os.Getenv("ARTEX_PG_DSN")); v != "" { if v := strings.TrimSpace(os.Getenv("ARTEX_PG_DSN")); v != "" {
return v, "environment variable ARTEX_PG_DSN", nil return v, "environment variable ARTEX_PG_DSN", nil
} }
db := Load().Database c, err := Load()
if err != nil {
return "", "", err
}
db := c.Database
if d := strings.TrimSpace(db.DSN); d != "" { if d := strings.TrimSpace(db.DSN); d != "" {
return d, "config file " + Path() + " (database.dsn)", nil return d, "config file " + Path() + " (database.dsn)", nil
} }
+22
View File
@@ -3,6 +3,7 @@ package config
import ( import (
"os" "os"
"path/filepath" "path/filepath"
"strings"
"testing" "testing"
) )
@@ -40,3 +41,24 @@ func TestPostgresDSNPrecedence(t *testing.T) {
t.Fatalf("file dsn verbatim, got %q err %v", got, err) t.Fatalf("file dsn verbatim, got %q err %v", got, err)
} }
} }
// A config file that exists but is not valid JSON must fail loudly, not run with
// defaults (or report "no database config") as if the file were absent.
func TestMalformedConfigIsAnError(t *testing.T) {
cfgPath := filepath.Join(t.TempDir(), "config.json")
// What install.sh used to write for a password containing a double quote.
os.WriteFile(cfgPath, []byte(`{"database":{"host":"h","password":"a"b","dbname":"d"},"skill_dir":"/s"}`), 0o644)
t.Setenv("ARTEX_CONFIG", cfgPath)
t.Setenv("ARTEX_PG_DSN", "")
t.Setenv("ARTEX_SKILL_DIR", "")
if _, _, err := PostgresDSN(); err == nil || !strings.Contains(err.Error(), "parse config file") {
t.Fatalf("PostgresDSN: want a parse error, got %v", err)
}
if d, err := SkillDir(); err == nil {
t.Fatalf("SkillDir: want a parse error, got dir %q", d)
}
if _, err := Load(); err == nil {
t.Fatal("Load: want a parse error")
}
}
+1 -1
View File
@@ -35,7 +35,7 @@ services:
ARTEX_LLM_BASE_URL: ${ARTEX_LLM_BASE_URL:-} ARTEX_LLM_BASE_URL: ${ARTEX_LLM_BASE_URL:-}
ARTEX_LLM_PROXY: ${ARTEX_LLM_PROXY:-} ARTEX_LLM_PROXY: ${ARTEX_LLM_PROXY:-}
ports: ports:
- "8787:8787" - "${ARTEX_BIND_ADDR:-127.0.0.1}:8787:8787"
- "127.0.0.1:8788:8788" - "127.0.0.1:8788:8788"
volumes: volumes:
# Bind the data directory (jwt.key, SQLite, etc.) to data/ in the project root, # Bind the data directory (jwt.key, SQLite, etc.) to data/ in the project root,
+19 -8
View File
@@ -9,6 +9,16 @@ warn(){ printf '\033[33m[!]\033[0m %s\n' "$*"; }
die(){ printf '\033[31m[x]\033[0m %s\n' "$*" >&2; exit 1; } die(){ printf '\033[31m[x]\033[0m %s\n' "$*" >&2; exit 1; }
ask(){ local p="$1" d="${2:-}" a; read -rp "$p${d:+ [$d]}: " a; echo "${a:-$d}"; } ask(){ local p="$1" d="${2:-}" a; read -rp "$p${d:+ [$d]}: " a; echo "${a:-$d}"; }
rand(){ head -c 18 /dev/urandom | base64 | tr -dc 'A-Za-z0-9' | head -c 24; } rand(){ head -c 18 /dev/urandom | base64 | tr -dc 'A-Za-z0-9' | head -c 24; }
# json_str prints $1 as a JSON string literal: backslash, double quote and the
# control characters read -r can return are escaped.
json_str(){
local s="$1"
s="${s//\\/\\\\}"; s="${s//\"/\\\"}"
s="${s//$'\t'/\\t}"; s="${s//$'\r'/\\r}"
printf '"%s"' "$s"
}
# sed_repl escapes $1 for the replacement side of s|...|...|: \, | and &.
sed_repl(){ printf '%s' "$1" | sed 's/[\\|&]/\\&/g'; }
# ── docker environment check / auto-install ─────────────────── # ── docker environment check / auto-install ───────────────────
ensure_docker(){ ensure_docker(){
@@ -38,8 +48,8 @@ install_docker(){
local pw key local pw key
pw="$(ask 'Postgres password (press Enter to generate randomly)' "$(rand)")" pw="$(ask 'Postgres password (press Enter to generate randomly)' "$(rand)")"
key="$(ask 'ANTHROPIC_API_KEY (may be empty, configure later in the UI)' '')" key="$(ask 'ANTHROPIC_API_KEY (may be empty, configure later in the UI)' '')"
sed -i.bak "s|^POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=${pw}|" .env sed -i.bak "s|^POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=$(sed_repl "$pw")|" .env
sed -i.bak "s|^ANTHROPIC_API_KEY=.*|ANTHROPIC_API_KEY=${key}|" .env sed -i.bak "s|^ANTHROPIC_API_KEY=.*|ANTHROPIC_API_KEY=$(sed_repl "$key")|" .env
rm -f .env.bak rm -f .env.bak
ok ".env generated (POSTGRES_PASSWORD set)" ok ".env generated (POSTGRES_PASSWORD set)"
else else
@@ -76,16 +86,17 @@ install_local(){
DB_SSL="$(ask 'sslmode (disable/require)' disable)" ;; DB_SSL="$(ask 'sslmode (disable/require)' disable)" ;;
esac esac
# generate config.json # generate config.json (string values JSON-escaped: a password may contain " or \)
case "$DB_PORT" in (*[!0-9]*|'') die "port must be a number: $DB_PORT" ;; esac
cat > config.json <<JSON cat > config.json <<JSON
{ {
"database": { "database": {
"host": "${DB_HOST}", "host": $(json_str "$DB_HOST"),
"port": ${DB_PORT}, "port": ${DB_PORT},
"user": "${DB_USER}", "user": $(json_str "$DB_USER"),
"password": "${DB_PASS}", "password": $(json_str "$DB_PASS"),
"dbname": "${DB_NAME}", "dbname": $(json_str "$DB_NAME"),
"sslmode": "${DB_SSL}" "sslmode": $(json_str "$DB_SSL")
} }
} }
JSON JSON
+39 -1
View File
@@ -2,6 +2,8 @@ package server
import ( import (
"crypto/rand" "crypto/rand"
"crypto/subtle"
"encoding/hex"
"fmt" "fmt"
"log" "log"
"math/big" "math/big"
@@ -154,7 +156,34 @@ func (s *Server) authStatus(w http.ResponseWriter, r *http.Request) {
writeJSON(w, 200, map[string]any{"initialized": hash != ""}) writeJSON(w, 200, map[string]any{"initialized": hash != ""})
} }
// initSetupToken generates the one-time setup token when no admin password is set
// and writes it to the server log. Without it, anyone who can reach the port
// before the operator could claim the instance through POST /api/auth/init.
func (s *Server) initSetupToken() {
if s.m == nil || s.m.pg == nil {
return
}
if hash, _, err := s.m.pg.GetSetting(authPassKey); err == nil && hash != "" {
return
}
buf := make([]byte, 16)
if _, err := rand.Read(buf); err != nil {
log.Fatalf("[auth] generate setup token: %v", err)
}
s.setupToken = hex.EncodeToString(buf)
log.Printf("[auth] no admin password is set. Setup token for the /setup page: %s", s.setupToken)
}
// checkSetupToken compares got with the active setup token in constant time.
// It fails when no token is active.
func (s *Server) checkSetupToken(got string) bool {
s.setupMu.Lock()
defer s.setupMu.Unlock()
return s.setupToken != "" && subtle.ConstantTimeCompare([]byte(got), []byte(s.setupToken)) == 1
}
// POST /api/auth/init — sets the password for the first time; rejected if already set. // POST /api/auth/init — sets the password for the first time; rejected if already set.
// Requires the setup token from the server log.
func (s *Server) authInit(w http.ResponseWriter, r *http.Request) { func (s *Server) authInit(w http.ResponseWriter, r *http.Request) {
pg := s.pg(w) pg := s.pg(w)
if pg == nil { if pg == nil {
@@ -170,12 +199,18 @@ func (s *Server) authInit(w http.ResponseWriter, r *http.Request) {
return return
} }
var req struct { var req struct {
Password string `json:"password"` Password string `json:"password"`
SetupToken string `json:"setup_token"`
} }
if err := decode(r, &req); err != nil || req.Password == "" { if err := decode(r, &req); err != nil || req.Password == "" {
writeErr(w, 400, "Password cannot be empty") writeErr(w, 400, "Password cannot be empty")
return return
} }
// 403, not 401: the frontend treats any 401 as an expired session and redirects to /login.
if !s.checkSetupToken(req.SetupToken) {
writeErr(w, 403, "Invalid setup token. The server log prints it at startup while no password is set")
return
}
if msg := validatePassword(req.Password); msg != "" { if msg := validatePassword(req.Password); msg != "" {
writeErr(w, 400, msg) writeErr(w, 400, msg)
return return
@@ -197,6 +232,9 @@ func (s *Server) authInit(w http.ResponseWriter, r *http.Request) {
writeErr(w, 403, "Password is already set") writeErr(w, 403, "Password is already set")
return return
} }
s.setupMu.Lock()
s.setupToken = ""
s.setupMu.Unlock()
tok, err := signJWT(s.jwtKey) tok, err := signJWT(s.jwtKey)
if err != nil { if err != nil {
writeErr(w, 500, "token generation failed") writeErr(w, 500, "token generation failed")
+56
View File
@@ -62,6 +62,62 @@ func TestAuthInitFailsClosedWhenDataSourceUnavailable(t *testing.T) {
} }
} }
// While no password is set, authInit must reject a missing or wrong setup token
// and accept the one generated at startup, once.
func TestAuthInitRequiresSetupToken(t *testing.T) {
m, err := NewManager(t.TempDir(), "")
if err != nil {
t.Skipf("postgres unavailable (%v)", err)
}
defer m.Close()
clearPassword := func() {
if _, err := m.pg.Exec(`DELETE FROM settings WHERE key=$1`, authPassKey); err != nil {
t.Fatal(err)
}
}
clearPassword()
defer clearPassword()
s := &Server{m: m, jwtKey: []byte("0123456789abcdef0123456789abcdef")}
s.initSetupToken()
setupToken := s.setupToken
if setupToken == "" {
t.Fatal("no setup token generated while no password is set")
}
post := func(body string) *httptest.ResponseRecorder {
w := httptest.NewRecorder()
s.authInit(w, httptest.NewRequest("POST", "/api/auth/init", strings.NewReader(body)))
return w
}
for name, body := range map[string]string{
"missing": `{"password":"correct horse battery"}`,
"empty": `{"password":"correct horse battery","setup_token":""}`,
"wrong": `{"password":"correct horse battery","setup_token":"0000"}`,
} {
if w := post(body); w.Code != 403 || strings.Contains(w.Body.String(), `"token"`) {
t.Fatalf("%s setup token: status=%d want 403 without a token; body=%s", name, w.Code, w.Body.String())
}
}
if hash, _, err := m.pg.GetSetting(authPassKey); err != nil || hash != "" {
t.Fatalf("a rejected request changed the password state: hash set=%v err=%v", hash != "", err)
}
ok := `{"password":"correct horse battery","setup_token":"` + setupToken + `"}`
if w := post(ok); w.Code != 200 || !strings.Contains(w.Body.String(), `"token"`) {
t.Fatalf("right setup token: status=%d want 200 with a token; body=%s", w.Code, w.Body.String())
}
if hash, _, err := m.pg.GetSetting(authPassKey); err != nil || hash == "" {
t.Fatalf("password not stored: err=%v", err)
}
// The token is spent: even with the password row removed, it is refused.
clearPassword()
if w := post(ok); w.Code != 403 {
t.Fatalf("reused setup token: status=%d want 403; body=%s", w.Code, w.Body.String())
}
}
func TestValidatePassword(t *testing.T) { func TestValidatePassword(t *testing.T) {
for _, tc := range []struct { for _, tc := range []struct {
name, pw string name, pw string
+4
View File
@@ -48,6 +48,9 @@ type Server struct {
scrubSecrets bool // drop ARTEX_PG_DSN and the API keys from the environment once read (binary only) scrubSecrets bool // drop ARTEX_PG_DSN and the API keys from the environment once read (binary only)
setupMu sync.Mutex
setupToken string // one-time token POST /api/auth/init requires; empty when none is active
// concMu serializes concurrency-cap decisions (admission + reconcile) so a // concMu serializes concurrency-cap decisions (admission + reconcile) so a
// scheduler tick and an HTTP settings change / task creation can't both count // scheduler tick and an HTTP settings change / task creation can't both count
// free slots off the same snapshot and over-promote past the limit. // free slots off the same snapshot and over-promote past the limit.
@@ -153,6 +156,7 @@ func New(ctx context.Context, m *Manager, skillDir string, dataDir string, keyDi
profChatAgents: map[int64]*agent.ChatAgent{}, profChatAgents: map[int64]*agent.ChatAgent{},
provByProfile: map[int64]*provEntry{}, llmHealth: newLLMHealthRegistry(m.pg), provByProfile: map[int64]*provEntry{}, llmHealth: newLLMHealthRegistry(m.pg),
taskAgents: map[string]*taskAgentBundle{}, archiveWake: make(chan struct{}, 1)} taskAgents: map[string]*taskAgentBundle{}, archiveWake: make(chan struct{}, 1)}
s.initSetupToken()
s.initSideQuestions() s.initSideQuestions()
// Circuit-breaker thresholds/cooldowns are hot parameters on the failure path; push the global retry policy to the Registry once at startup, // Circuit-breaker thresholds/cooldowns are hot parameters on the failure path; push the global retry policy to the Registry once at startup,
// and again on every policy save (saveLLMRetryPolicy). // and again on every policy save (saveLLMRetryPolicy).
+19 -4
View File
@@ -14,6 +14,7 @@ export default function SetupPage() {
const router = useRouter(); const router = useRouter();
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [confirm, setConfirm] = useState(""); const [confirm, setConfirm] = useState("");
const [setupToken, setSetupToken] = useState("");
const [error, setError] = useState(""); const [error, setError] = useState("");
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [checking, setChecking] = useState(true); const [checking, setChecking] = useState(true);
@@ -47,7 +48,7 @@ export default function SetupPage() {
setLoading(true); setLoading(true);
setError(""); setError("");
try { try {
const { token } = await api.initPassword(password); const { token } = await api.initPassword(password, setupToken.trim());
auth.setToken(token); auth.setToken(token);
router.replace("/function/tasks"); router.replace("/function/tasks");
} catch (err) { } catch (err) {
@@ -80,7 +81,7 @@ export default function SetupPage() {
<p className="mx-auto max-w-xl text-muted-foreground"> <p className="mx-auto max-w-xl text-muted-foreground">
{unavailable {unavailable
? "The backend or database is temporarily unavailable. To avoid overwriting a password already set on this instance, setup is temporarily closed — restore the service and try again." ? "The backend or database is temporarily unavailable. To avoid overwriting a password already set on this instance, setup is temporarily closed — restore the service and try again."
: "First time using ARTEX? Set a login password for the account (at least 8 characters)"} : "First time using ARTEX? Enter the setup token from the server log, then set a login password for the account (at least 8 characters)"}
</p> </p>
</div> </div>
{unavailable ? ( {unavailable ? (
@@ -92,6 +93,17 @@ export default function SetupPage() {
</div> </div>
) : ( ) : (
<form onSubmit={handleSubmit} className="flex flex-col gap-4"> <form onSubmit={handleSubmit} className="flex flex-col gap-4">
<div className="space-y-1.5">
<Label htmlFor="setup-token">Setup token</Label>
<Input
id="setup-token"
value={setupToken}
onChange={(e) => setSetupToken(e.target.value)}
placeholder="Printed in the server log at startup"
autoFocus
autoComplete="off"
/>
</div>
<div className="space-y-1.5"> <div className="space-y-1.5">
<Label htmlFor="password">New password</Label> <Label htmlFor="password">New password</Label>
<Input <Input
@@ -100,7 +112,6 @@ export default function SetupPage() {
value={password} value={password}
onChange={(e) => setPassword(e.target.value)} onChange={(e) => setPassword(e.target.value)}
placeholder="At least 8 characters" placeholder="At least 8 characters"
autoFocus
autoComplete="new-password" autoComplete="new-password"
/> />
</div> </div>
@@ -116,7 +127,11 @@ export default function SetupPage() {
/> />
</div> </div>
{error && <p className="text-sm text-destructive">{error}</p>} {error && <p className="text-sm text-destructive">{error}</p>}
<Button type="submit" className="w-full" disabled={loading || !password || !confirm}> <Button
type="submit"
className="w-full"
disabled={loading || !setupToken.trim() || !password || !confirm}
>
{loading ? "Saving..." : "Set password and sign in"} {loading ? "Saving..." : "Set password and sign in"}
</Button> </Button>
</form> </form>
+2 -1
View File
@@ -240,7 +240,8 @@ export const api = {
// ---- auth ---- // ---- auth ----
authStatus: () => get<{ initialized: boolean }>("/auth/status"), authStatus: () => get<{ initialized: boolean }>("/auth/status"),
login: (username: string, password: string) => post<{ token: string }>("/auth/login", { username, password }), login: (username: string, password: string) => post<{ token: string }>("/auth/login", { username, password }),
initPassword: (password: string) => post<{ token: string }>("/auth/init", { password }), initPassword: (password: string, setupToken: string) =>
post<{ token: string }>("/auth/init", { password, setup_token: setupToken }),
changePassword: (oldPassword: string, newPassword: string) => changePassword: (oldPassword: string, newPassword: string) =>
post<{ ok: boolean }>("/auth/change-password", { old_password: oldPassword, new_password: newPassword }), post<{ ok: boolean }>("/auth/change-password", { old_password: oldPassword, new_password: newPassword }),