42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { getJson, getThalosAuthBaseUrl, postJson, postNoContent } from './client';
|
|
|
|
export type IdentityProvider = 0 | 1 | 2 | string | number;
|
|
|
|
export type SessionProfile = {
|
|
isAuthenticated: boolean;
|
|
subjectId: string;
|
|
tenantId: string;
|
|
provider: IdentityProvider;
|
|
};
|
|
|
|
export type SessionLoginRequest = {
|
|
subjectId: string;
|
|
tenantId: string;
|
|
correlationId: string;
|
|
provider: IdentityProvider;
|
|
externalToken: string;
|
|
};
|
|
|
|
export type SessionLoginResponse = {
|
|
subjectId: string;
|
|
tenantId: string;
|
|
provider: IdentityProvider;
|
|
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());
|
|
}
|