@intuitionrobotics/user-account
Version:
81 lines (80 loc) • 2.77 kB
TypeScript
import { ApiWithBody, ApiWithQuery } from "@intuitionrobotics/thunderstorm";
export declare const HeaderKey_SessionId = "x-session-id";
export declare const HeaderKey_Email = "x-email";
export declare const QueryParam_Email = "userEmail";
export declare const QueryParam_JWT = "jwt";
export declare const QueryParam_SessionId = "x-session-id";
export declare const QueryParam_RedirectUrl = "redirectUrl";
export declare const HeaderKey_CurrentPage = "current-page";
export declare enum FrontType {
Web = "web",
App = "app"
}
export type BaseSession = {
userId: string;
timestamp: number;
frontType?: FrontType;
version?: string;
};
export type DB_Session = BaseSession & {
sessionId: string;
};
export type UI_Session = BaseSession & {
isExpired: boolean;
};
export type Response_Auth = UI_Account & {
jwt: string;
sessionId: string;
};
export type Request_UpsertAccount = {
email: string;
password: string;
password_check: string;
frontType?: FrontType;
};
export type Request_CreateAccount = {
email: string;
password: string;
password_check: string;
};
export type Request_AddNewAccount = {
email: string;
password?: string;
password_check?: string;
};
export type Request_LoginAccount = {
email: string;
password: string;
frontType?: FrontType;
};
export type Request_ValidateSession = {
sessionId: string;
};
export type Response_LoginSAML = {
loginUrl: string;
};
export type Response_Validation = UI_Account;
export type UI_Account = {
email: string;
_id: string;
createdTimestamp?: number;
};
export type Response_ListAccounts = {
accounts: UI_Account[];
};
export type RequestParams_LoginSAML = {
[QueryParam_RedirectUrl]: string;
};
export type PostAssertBody = {
SAMLResponse: string;
RelayState: string;
};
export type AccountApi_AddNewAccount = ApiWithBody<'/v1/account/add-new-account', Request_AddNewAccount, UI_Account>;
export type AccountApi_Create = ApiWithBody<'/v1/account/create', Request_CreateAccount, Response_Auth>;
export type AccountApi_Upsert = ApiWithBody<'/v1/account/upsert', Request_UpsertAccount, UI_Account>;
export type AccountApi_Login = ApiWithBody<'/v1/account/login', Request_LoginAccount, Response_Auth>;
export type AccountApi_Logout = ApiWithBody<'/v1/account/logout', {}, void>;
export type AccountApi_LoginSAML = ApiWithQuery<"/v1/account/login-saml", Response_LoginSAML, RequestParams_LoginSAML>;
export type AccountApi_ValidateSession = ApiWithQuery<'/v1/account/validate', Response_Validation>;
export type AccountApi_AssertLoginSAML = ApiWithBody<"/v1/account/assert", PostAssertBody, void>;
export type AccountApi_ListAccounts = ApiWithQuery<'/v1/account/query', Response_ListAccounts>;