import { AdminUserDetailRow, ProfileRow, SelfProfileRow } from '../dto'; import { User } from '../models'; import type { UserGender } from '../models/userGender'; import { type AdminListPageResult } from './adminListCursor'; /** * Finds a user by their indexed email hash. * @param emailHash - HMAC hash of the normalized email address. * @returns The user record, or null if not found. */ export declare function findByEmailHash(emailHash: string): Promise; /** * Finds a user by their indexed phone hash. * @param phoneHash - HMAC hash of the normalized phone number. * @returns The user record, or null if not found. */ export declare function findByPhoneHash(phoneHash: string): Promise; /** * Finds a user by primary key. * @param id - User UUID. * @returns The user record, or null if not found. */ export declare function findById(id: string): Promise; /** * Creates a new user account. * @param data - User registration fields. * @param data.emailHash - HMAC hash of the normalized email address. * @param data.emailEncrypted - Optional encrypted email for display/recovery. * @param data.passwordHash - Bcrypt hash of the user's password. * @param data.roleId - Optional role ID (defaults to 1). * @returns The newly created user record. */ export declare function create(data: { emailHash: string; emailEncrypted?: string; passwordHash: string; roleId?: number; firstName?: string | null; lastName?: string | null; phoneHash?: string | null; phoneEncrypted?: string | null; countryOfResidence?: string | null; nationality?: string | null; gender?: UserGender; referralCode?: string; referredByUserId?: string | null; registrationIp?: string | null; }): Promise; /** * Updates a user's TOTP (two-factor) configuration. * @param userId - ID of the user to update. * @param totpSecretEncrypted - Encrypted TOTP secret, or null to clear it. * @param enabled - Whether TOTP is enabled for the user. * @returns Resolves when the row has been updated. */ export declare function updateTotp(userId: string, totpSecretEncrypted: string | null, enabled: boolean): Promise; export declare function getLoginLockedUntil(userId: string): Promise; export declare function incrementFailedLoginCount(userId: string): Promise; export declare function setLoginLockedUntil(userId: string, until: Date | null): Promise; export declare function resetFailedLoginState(userId: string): Promise; export declare function getFailedLoginCount(userId: string): Promise; export type TemporarilyLockedUserRow = { id: string; email_encrypted: string | null; phone_encrypted: string | null; first_name: string | null; last_name: string | null; failed_login_count: number; login_locked_until: Date; updated_at: Date; }; /** Users with an active or recently set temporary login lock. */ export declare function listTemporarilyLockedUsers(): Promise; /** * Resolves a role ID to its display name. * @param roleId - Numeric role identifier. * @returns Role name string, or 'user' if the role is not found. */ export declare function getRoleName(roleId: number): Promise; export type AdminSortBy = 'created_at' | 'id' | 'role_name' | 'is_enabled' | 'email_verified' | 'country_of_residence' | 'main_balance_raw' | 'bonus_balance_raw' | 'total_bonus_received_raw' | 'prediction_count' | 'total_stake_raw' | 'total_payout_raw' | 'net_pnl_raw' | 'last_login_at' | 'last_activity_at'; type AdminSortDir = 'asc' | 'desc'; export type { AdminSortDir, AdminListPageResult } from './adminListCursor'; export type UserActivityFilter = 'active_in_period' | 'inactive_before_period' | 'online_now' | 'online_app' | 'staff'; export type AdminListFilters = { search?: string; roleName?: 'user' | 'moderator' | 'admin' | 'super_admin'; emailVerified?: boolean; country?: string; inactiveSinceDays?: number; activityFilter?: UserActivityFilter; activityPeriodFrom?: string; activityPeriodTo?: string; minMainBalance?: bigint; maxMainBalance?: bigint; minBonusReceived?: bigint; maxBonusReceived?: bigint; accountStatus?: 'active' | 'disabled' | 'suspended'; hasReceivedBonus?: boolean; createdFrom?: string; createdTo?: string; minAge?: number; maxAge?: number; totpEnabled?: boolean; underSurveillance?: boolean; userIds?: string[]; }; /** True when any filter narrows the user set (exact COUNT required). */ export declare function adminListHasActiveFilters(filters: AdminListFilters): boolean; /** * Lists users for the admin panel with search, filtering, sorting, and pagination. * Supports keyset (cursor) pagination and optional COUNT skipping for scale. */ export declare function listForAdmin(options: AdminListFilters & { sortBy?: AdminSortBy; sortDir?: AdminSortDir; limit: number; offset?: number; cursor?: string; includeTotal?: boolean; }): Promise; /** * Retrieves detailed user information for the admin panel. * @param userId - ID of the user to fetch. * @returns Admin detail row, or null if the user does not exist. */ export declare function getForAdmin(userId: string): Promise; /** * Updates Spring Security-style account flag fields for a user. * Only flags present in the input object are modified. * @param userId - ID of the user to update. * @param flags - Account flag values to set. * @param flags.is_enabled - Whether the account is enabled. * @param flags.is_account_non_expired - Whether the account has not expired. * @param flags.is_account_non_locked - Whether the account is not locked. * @param flags.is_credentials_non_expired - Whether credentials have not expired. * @returns Resolves when applicable fields have been updated (no-op if flags is empty). */ export declare function updateAccountFlags(userId: string, flags: { is_enabled?: boolean; is_account_non_expired?: boolean; is_account_non_locked?: boolean; is_credentials_non_expired?: boolean; }): Promise; /** * Updates security surveillance and withdrawal suspension flags. */ export declare function updateSecurityFlags(userId: string, flags: { withdrawals_suspended?: boolean; under_surveillance?: boolean; security_reason_encrypted?: string; set_suspended_at?: boolean; clear_security_reason?: boolean; }): Promise; /** * Loads a user's profile fields for display or editing. * @param userId - ID of the user. * @returns Profile row with name, DOB, and encrypted contact fields, or null if not found. */ export declare function getProfileForUser(userId: string): Promise; /** * Loads profile and account metadata for the authenticated user's GET /me response. * @param userId - ID of the user. * @returns Profile with role and security flags, or null if not found. */ export declare function getSelfProfileForUser(userId: string): Promise; /** * Updates a user's profile and contact information. * Only fields present in the data object are modified. * @param userId - ID of the user to update. * @param data - Profile fields to set. * @param data.first_name - Optional given name. * @param data.middle_name - Optional middle name. * @param data.last_name - Optional family name. * @param data.date_of_birth - Optional date of birth (ISO date string). * @param data.emailHash - Optional new indexed email hash. * @param data.emailEncrypted - Optional new encrypted email. * @param data.phoneHash - Optional new indexed phone hash. * @param data.phoneEncrypted - Optional new encrypted phone number. * @returns Resolves when applicable fields have been updated (no-op if data is empty). */ export declare function updateProfile(userId: string, data: { first_name?: string | null; middle_name?: string | null; last_name?: string | null; date_of_birth?: string | null; emailHash?: string; emailEncrypted?: string | null; phoneHash?: string | null; phoneEncrypted?: string | null; country_of_residence?: string | null; nationality?: string | null; gender?: UserGender | null; }): Promise; /** * Updates a user's password hash. * @param userId - ID of the user. * @param passwordHash - New bcrypt password hash. * @returns Resolves when the password has been updated. */ export declare function updatePassword(userId: string, passwordHash: string): Promise; /** * Returns the current JWT invalidation version for a user. */ export declare function getTokenVersion(userId: string): Promise; /** * Bumps token_version to invalidate all outstanding access JWTs (e.g. logout everywhere). */ export declare function incrementTokenVersion(userId: string): Promise; /** * Soft-deletes a user: anonymizes PII, disables account, bumps token version. * @returns false if user was already deleted or not found. */ export declare function softDeleteUser(userId: string, tombstoneEmailHash: string): Promise; /** Main ledger balance (micro-USDT) from admin stats snapshot. */ export declare function getUserMainBalanceRaw(userId: string): Promise; /** * Sets the email_verified flag for a user. * @param userId - User UUID * @param verified - Whether the email has been confirmed */ export declare function setEmailVerified(userId: string, verified: boolean): Promise; export declare function countUsersWithRole(roleName: string): Promise; export declare function getRoleIdByName(roleName: 'user' | 'moderator' | 'admin' | 'super_admin'): Promise; export declare function updateUserRole(userId: string, roleId: number): Promise; //# sourceMappingURL=userRepository.d.ts.map