aboutsummaryrefslogtreecommitdiffstats
path: root/code/app/src/lib/services/abstractions/IAccountService.ts
blob: 736c3ae92d2b93961345e0d8a40b5f5b16119984 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import type { KnownProblem } from "$lib/models/internal/KnownProblem"

export interface IAccountService {
    session: Session,
    login_async(payload: LoginPayload): Promise<LoginResponse>,
    logout_async(): Promise<void>,
    create_account_async(payload: CreateAccountPayload): Promise<CreateAccountResponse>,
    delete_current_async(): Promise<DeleteAccountResponse>,
    update_current_async(payload: UpdateAccountPayload): Promise<UpdateAccountResponse>,
}

export type Session = {
    profile: {
        username: string,
        displayName: string,
        id: string,
    },
    lastChecked: number,
}

export type LoginPayload = {
    username: string,
    password: string,
    persist: boolean
}

export type LoginResponse = {
    isLoggedIn: boolean
}

export type CreateAccountPayload = {
    username: string,
    password: string,
}

export type CreateAccountResponse = {
    isCreated: boolean,
    knownProblem?: KnownProblem
}

export type DeleteAccountResponse = {
    isDeleted: boolean
}

export type UpdateAccountPayload = {
    username: string,
    password: string
}

export type UpdateAccountResponse = {
    isUpdated: boolean,
    knownProblem?: KnownProblem
}