@intuitionrobotics/user-account
Version:
67 lines (66 loc) • 3.27 kB
TypeScript
import { Module } from "@intuitionrobotics/ts-common";
import { FirestoreTransaction } from "@intuitionrobotics/firebase/backend";
import { DB_Account, DB_Session, FrontType, PostAssertBody, Request_CreateAccount, Request_LoginAccount, Request_UpsertAccount, Response_Auth, Response_Validation, UI_Account, UI_Session } from "./_imports";
import { ApiResponse, ExpressRequest, HeaderKey, QueryRequestInfo } from "@intuitionrobotics/thunderstorm/backend";
export declare const Header_SessionId: HeaderKey;
type Config = {
projectId: string;
sessionTTLms: {
web: number;
app: number;
jwt: number;
};
jwtSecretKey: string;
};
export declare const Collection_Sessions = "user-account--sessions";
export declare const Collection_Accounts = "user-account--accounts";
export interface OnNewUserRegistered {
__onNewUserRegistered(account: UI_Account): void;
}
export interface OnUserLogin {
__onUserLogin(account: UI_Account): void;
}
export declare class AccountsModule_Class extends Module<Config> implements QueryRequestInfo {
constructor();
__queryRequestInfo(request: ExpressRequest): Promise<{
key: string;
data: any;
}>;
private sessions;
private accounts;
protected init(): void;
getUser(_email: string): Promise<UI_Account | undefined>;
getUsers(_emails: string[]): Promise<UI_Account[]>;
listUsers(): Promise<UI_Account[]>;
listSessions(): Promise<DB_Session[]>;
getSession(_email: string): Promise<DB_Account | undefined>;
querySessions(_email: string): Promise<UI_Session[] | undefined>;
create(request: Request_CreateAccount, response: ApiResponse): Promise<Response_Auth>;
upsert(request: Request_UpsertAccount): Promise<UI_Account>;
addNewAccount(email: string, password?: string, password_check?: string): Promise<UI_Account>;
changePassword(userEmail: string, newPassword: string, _transaction?: FirestoreTransaction): Promise<DB_Account>;
createAccount(request: Request_CreateAccount): Promise<DB_Account>;
private createImpl;
logout(sessionId: string): Promise<void>;
logoutAccount(accountId: string): Promise<void>;
login(request: Request_LoginAccount, response: ApiResponse): Promise<Response_Auth>;
private loginValidate;
loginSAML(__email: string): Promise<Response_Auth>;
private createSAML;
private isAuthRequest;
private verifyAccount;
validateAuthenticationHeader(request: ExpressRequest, scopes: string[], response?: ApiResponse): Promise<Response_Validation>;
setJWTinResp(response: ApiResponse, jwt: string): void;
generateJWT(account: UI_Account, sessionId: string): string;
validateSession: (request: ExpressRequest, scopes: string[], response?: ApiResponse) => Promise<Response_Validation>;
validateSessionId(sessionId: string): Promise<UI_Account>;
private getUserEmailFromSession;
private getUserEmailFromUserId;
private TTLExpired;
private getAccountFromParams;
upsertSession(p: string | UI_Account, frontType?: FrontType): Promise<Response_Auth>;
private getSessionFromAccount;
assertApi(body: PostAssertBody, response: ApiResponse): Promise<void>;
}
export declare const AccountModule: AccountsModule_Class;
export {};