// Copyright: (c) 2026 TWWIM UG. All rights reserved. (www.twwim.com) import { apiClient } from './ApiClient'; /** * Force a refresh-token round-trip and rebuild the AuthenticatedUser store * from the new JWT. Use in mutation `onSuccess` handlers when the mutation * changed claim-derived state (account type, company data, profile fields, * legal acceptance, plan, capabilities, currency, etc). * * Why round-trip instead of patching the store locally: * - Claims are minted server-side from current DB state. A round-trip is * the only way to keep the cached identity coherent with the DB. * - Single writer for AuthenticatedUser: login + refresh. Mutations don't * need to know HOW each field maps into the store. * - Future-proof: any new JWT claim is reflected automatically without * touching every caller. * * Failure semantics: bubbles whatever ApiClient.refreshAccessToken throws. * Caller decides whether to surface the error or fall through (a transient * refresh failure leaves the previous AuthenticatedUser snapshot intact). */ export async function forceTokenRefresh(): Promise { await apiClient.forceRefresh(); }