import { Schema } from "mongoose"; import { EnumMap,IJson,IDocument,IObject,IInstance,IModel,IAction,IActionTypes,ILocation,MiscInfo } from "@onebro/oba-common"; import { OBAuthIdJson, OBAuthIdModel, OBAuthId, OBAuthIdPulicKeys } from "./auth-ids"; import { OBAuthCredsJson, OBAuthCredsModel, OBAuthCreds } from "./auth-creds"; export enum OBAuthAcctStatuses { A = "Authenticated", E = "Enabled", V = "Verified", L = "Locked", D = "Disabled", X = "Deleted", N = "New", I = "Inactive", O = "Offline"} export type OBAuthAcctStatus = keyof typeof OBAuthAcctStatuses; export enum OBAuthAcctRoles { G = "GUEST", U = "USER", A = "ADMIN", S = "SUPER", SA = "SYSADMIN"} export type OBAuthAcctRole = keyof typeof OBAuthAcctRoles; export type OBAuthAcctFullName = {first:string;last:string;}; export type OBAuthAcctContactInfo = {phn:string;method:"email"|"text"|"push";}; export type OBAuthAcctScope = {name:string;version?:string}; export type OBAuthAcctDevice = {mobile:boolean;name:string;}; export type OBAuthAcctUserInfo = Partial<{ ssn:string; dob:string; addr:string; phn:string; dl:{num:number;st?:string;reg?:string;cty?:string;ctry:string;};}>; export type OBAuthTokenData = {username:string;next:string;role:string;okto:string;}; export type OBAuthAcctConfig = { role:OBAuthAcctRole; scopes:OBAuthAcctScope[]; name?:OBAuthAcctFullName; yob?:string; dob?:string|Date; contact?:OBAuthAcctContactInfo; device?:OBAuthAcctDevice; locs?:ILocation[]; user?:OBAuthAcctUserInfo;}; export type OBAuthAcctType = IObject & Omit & {next:string;user?:string;info?:MiscInfo;}; export interface OBAuthAcctDocument extends IDocument,OBAuthAcctType { age:[number,number]; fullname:string; location:string;} export interface OBAuthAcct extends IInstance,OBAuthAcctDocument {valid():Promise;} export interface OBAuthAcctModel extends IModel {} export type OBAuthAcctPublicKeys = "age"|"location"|"info"; export type OBAuthAcctPublicData = Pick; export type OBAuthAcctJson = IJson & OBAuthAcctPublicData & { role:OBAuthAcctRoles; scopes:string[]; phnEnabled:boolean; name:string; memberSince:Date; user?:OBAuthAcctUserInfo;}; export type OBAuthJson = Omit; export type OBAuthAcctModelMap = { OBAuthAcct:OBAuthAcctModel; OBAuthId:OBAuthIdModel; OBAuthCreds:OBAuthCredsModel;}; export type OBAuthAcctInstanceMap = { authId:OBAuthId; creds?:OBAuthCreds; acct?:OBAuthAcct;}; export type OBAuthAcctSchemaMap = {acct:Schema;}; export type OBAuthAcctActionTypes = IActionTypes|"register$"|"verify$"|"set$"|"autoset$"|"login$"|"forgot$"|"reset$"|"logout$"; export type OBAuthAcctActions = EnumMap;