pos-transactions-web/src/api/sessionApi.ts
2026-03-08 16:06:28 -06:00

40 lines
1.1 KiB
TypeScript

import { getJson, getThalosAuthBaseUrl, postJson, postNoContent } from './client';
export type SessionProfile = {
isAuthenticated: boolean;
subjectId: string;
tenantId: string;
provider: string;
};
export type SessionLoginRequest = {
subjectId: string;
tenantId: string;
correlationId: string;
provider: string;
externalToken: string;
};
export type SessionLoginResponse = {
subjectId: string;
tenantId: string;
provider: string;
expiresInSeconds: number;
};
export async function loginSession(request: SessionLoginRequest): Promise<SessionLoginResponse> {
return postJson<SessionLoginResponse>('/api/identity/session/login', request, getThalosAuthBaseUrl());
}
export async function refreshSession(): Promise<SessionLoginResponse> {
return postJson<SessionLoginResponse>('/api/identity/session/refresh', {}, getThalosAuthBaseUrl());
}
export async function logoutSession(): Promise<void> {
return postNoContent('/api/identity/session/logout', {}, getThalosAuthBaseUrl());
}
export async function getSessionMe(): Promise<SessionProfile> {
return getJson<SessionProfile>('/api/identity/session/me', getThalosAuthBaseUrl());
}