Add JRPC API, reworked Login and User pages
This commit is contained in:
16
InternalAPI/account.jrpc
Normal file
16
InternalAPI/account.jrpc
Normal file
@ -0,0 +1,16 @@
|
||||
type UserRegisterInfo {
|
||||
username: string;
|
||||
name: string;
|
||||
gender: string;
|
||||
mail: string;
|
||||
password: string;
|
||||
salt: string;
|
||||
}
|
||||
|
||||
service AccountService {
|
||||
Register(regcode: string, info: UserRegisterInfo): void;
|
||||
GetProfile(): Profile;
|
||||
UpdateProfile(info: Profile): void;
|
||||
GetContactInfos(): ContactInfo;
|
||||
}
|
||||
|
@ -1,77 +1,5 @@
|
||||
type UserRegisterInfo {
|
||||
username: string;
|
||||
name: string;
|
||||
gender: string;
|
||||
mail: string;
|
||||
password: string;
|
||||
salt: string;
|
||||
}
|
||||
|
||||
type Token {
|
||||
id: string;
|
||||
special: boolean;
|
||||
ip: string;
|
||||
browser: string;
|
||||
isthis: boolean;
|
||||
}
|
||||
|
||||
enum Gender {
|
||||
None = 0,
|
||||
Male = 1,
|
||||
Female = 2,
|
||||
Other = 3
|
||||
}
|
||||
|
||||
type Account {
|
||||
id: string;
|
||||
name: string;
|
||||
username: string;
|
||||
birthday: int;
|
||||
gender: Gender;
|
||||
}
|
||||
|
||||
type Mail {
|
||||
mail: string;
|
||||
verified: boolean;
|
||||
primary: boolean;
|
||||
}
|
||||
|
||||
type Phone {
|
||||
phone: string;
|
||||
verified: boolean;
|
||||
primary: boolean;
|
||||
}
|
||||
|
||||
type ContactInfo {
|
||||
mail: Mail[];
|
||||
phone: Phone[];
|
||||
}
|
||||
|
||||
enum TFAType {
|
||||
TOTP = 0,
|
||||
BACKUP_CODE = 1,
|
||||
WEBAUTHN = 2,
|
||||
APP_ALLOW = 3
|
||||
}
|
||||
|
||||
|
||||
type TwoFactor {
|
||||
id: string;
|
||||
name?: string;
|
||||
expires?: int;
|
||||
tfatype: TFAType;
|
||||
}
|
||||
|
||||
service AccountService {
|
||||
Register(regcode: string, info: UserRegisterInfo): void;
|
||||
GetProfile(): Account;
|
||||
UpdateProfile(info: Account): void;
|
||||
GetContactInfos(): ContactInfo;
|
||||
}
|
||||
|
||||
service SecurityService {
|
||||
GetTokens(): Token[];
|
||||
RevokeToken(id: string): void;
|
||||
|
||||
GetTwofactorOptions(): TwoFactor[];
|
||||
}
|
||||
import "./types";
|
||||
import "./twofactor";
|
||||
import "./login";
|
||||
import "./account";
|
||||
import "./security";
|
||||
|
21
InternalAPI/login.jrpc
Normal file
21
InternalAPI/login.jrpc
Normal file
@ -0,0 +1,21 @@
|
||||
import "./twofactor";
|
||||
|
||||
type LoginState {
|
||||
success: boolean;
|
||||
username?: string;
|
||||
password?: boolean;
|
||||
passwordSalt?: string;
|
||||
requireTwoFactor?: TFAOption[];
|
||||
}
|
||||
|
||||
|
||||
service LoginService {
|
||||
GetState(): LoginState;
|
||||
Start(username: string): LoginState;
|
||||
UsePassword(password_hash: string, date: int): LoginState;
|
||||
|
||||
UseTOTP(id: string, code: string): LoginState;
|
||||
UseBackupCode(id: string, code:string): LoginState;
|
||||
GetWebAuthnChallenge(id: string): string;
|
||||
UseWebAuthn(id: string, response: string): LoginState;
|
||||
}
|
14
InternalAPI/security.jrpc
Normal file
14
InternalAPI/security.jrpc
Normal file
@ -0,0 +1,14 @@
|
||||
type Session {
|
||||
id: string;
|
||||
special: boolean;
|
||||
ip: string;
|
||||
browser: string;
|
||||
isthis: boolean;
|
||||
}
|
||||
|
||||
service SecurityService {
|
||||
GetSessions(): Session[];
|
||||
RevokeSession(id: string): void;
|
||||
|
||||
ChangePassword(old: string, new_pw: string): void;
|
||||
}
|
38
InternalAPI/twofactor.jrpc
Normal file
38
InternalAPI/twofactor.jrpc
Normal file
@ -0,0 +1,38 @@
|
||||
enum TFAType {
|
||||
TOTP = 0,
|
||||
BACKUP_CODE = 1,
|
||||
WEBAUTHN = 2,
|
||||
APP_ALLOW = 3
|
||||
}
|
||||
|
||||
type TFAOption {
|
||||
id: string;
|
||||
name?: string;
|
||||
expires?: int;
|
||||
tfatype: TFAType;
|
||||
}
|
||||
|
||||
type TFANewTOTP {
|
||||
id: string;
|
||||
secret: string;
|
||||
qr: string;
|
||||
}
|
||||
|
||||
type TFAWebAuthRegister {
|
||||
id: string;
|
||||
challenge: string;
|
||||
}
|
||||
|
||||
service TFAService {
|
||||
GetOptions(): TFAOption[];
|
||||
Delete(id: string): void;
|
||||
|
||||
AddTOTP(name: string): TFANewTOTP;
|
||||
VerifyTOTP(id: string, code: string): void;
|
||||
|
||||
AddWebauthn(name: string): TFAWebAuthRegister;
|
||||
VerifyWebAuthn(id: string, registration_response: string): void;
|
||||
|
||||
AddBackupCodes(name:string): string[];
|
||||
RemoveBackupCodes(id: string): void;
|
||||
}
|
31
InternalAPI/types.jrpc
Normal file
31
InternalAPI/types.jrpc
Normal file
@ -0,0 +1,31 @@
|
||||
enum Gender {
|
||||
None = 0,
|
||||
Male = 1,
|
||||
Female = 2,
|
||||
Other = 3
|
||||
}
|
||||
|
||||
type Profile {
|
||||
id: string;
|
||||
name: string;
|
||||
username: string;
|
||||
birthday: int;
|
||||
gender: Gender;
|
||||
}
|
||||
|
||||
type Mail {
|
||||
mail: string;
|
||||
verified: boolean;
|
||||
primary: boolean;
|
||||
}
|
||||
|
||||
type Phone {
|
||||
phone: string;
|
||||
verified: boolean;
|
||||
primary: boolean;
|
||||
}
|
||||
|
||||
type ContactInfo {
|
||||
mail: Mail[];
|
||||
phone: Phone[];
|
||||
}
|
Reference in New Issue
Block a user