-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth-ws.ts
More file actions
39 lines (33 loc) · 886 Bytes
/
Copy pathauth-ws.ts
File metadata and controls
39 lines (33 loc) · 886 Bytes
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
import { browserboxWsCall } from "@/lib/ws-client";
import { WS_OP } from "@/lib/ws-ops";
export type WsAuthMeResponse = {
user?: { name?: string };
};
export type WsSignedInPayload = {
user?: { name?: string };
token?: string;
};
export async function wsAuthMe(): Promise<WsAuthMeResponse> {
return browserboxWsCall<WsAuthMeResponse>(WS_OP.AUTH_ME);
}
export async function wsAuthLogin(
username: string,
password: string,
): Promise<WsSignedInPayload> {
return browserboxWsCall<WsSignedInPayload>(WS_OP.AUTH_LOGIN, {
username,
password,
});
}
export async function wsAuthSignup(
username: string,
password: string,
): Promise<WsSignedInPayload> {
return browserboxWsCall<WsSignedInPayload>(WS_OP.AUTH_SIGNUP, {
username,
password,
});
}
export async function wsAuthLogout(): Promise<void> {
await browserboxWsCall(WS_OP.AUTH_LOGOUT);
}