more fix and update

This commit is contained in:
lendry
2026-06-24 20:15:19 +03:00
parent dcab6557d3
commit 9727cf3f35
53 changed files with 3479 additions and 494 deletions

View File

@@ -20,6 +20,7 @@ import { FamilyService } from './family.service';
import { MediaService } from './media.service';
import { NotificationsService } from './notifications.service';
import { ChatService } from './chat.service';
import { TotpService } from './totp.service';
import { MessagingService } from '../infra/messaging.service';
@Controller()
@@ -43,7 +44,8 @@ export class AuthGrpcController {
private readonly media: MediaService,
private readonly notifications: NotificationsService,
private readonly chat: ChatService,
private readonly messaging: MessagingService
private readonly messaging: MessagingService,
private readonly totp: TotpService
) {}
@GrpcMethod('AuthService', 'Register')
@@ -62,8 +64,8 @@ export class AuthGrpcController {
}
@GrpcMethod('AuthService', 'SendOtp')
sendPasswordlessOtp(command: { recipient: string; channel?: string }) {
return this.auth.sendOtp(command.recipient, command.channel);
sendPasswordlessOtp(command: { recipient: string; channel?: string; ipAddress?: string }) {
return this.auth.sendOtp(command.recipient, command.channel, command.ipAddress);
}
@GrpcMethod('AuthService', 'VerifyOtp')
@@ -89,6 +91,23 @@ export class AuthGrpcController {
return this.auth.loginWithLdap(command);
}
@GrpcMethod('AuthService', 'VerifyTotpLogin')
verifyTotpLogin(command: { totpChallengeToken: string; code: string }) {
return this.auth.verifyTotpLogin(command.totpChallengeToken, command.code);
}
@GrpcMethod('AuthService', 'BeginTotpLogin')
beginTotpLogin(command: {
recipient: string;
fingerprint: string;
deviceName?: string;
deviceType?: string;
ipAddress?: string;
userAgent?: string;
}) {
return this.auth.beginTotpLogin(command);
}
@GrpcMethod('AuthService', 'VerifyPin')
verifyPin(command: VerifyPinCommand) {
return this.pin.verifyPin(command.sessionId, command.pin);
@@ -283,8 +302,8 @@ export class AuthGrpcController {
}
@GrpcMethod('SecurityService', 'ListActiveDevices')
async listActiveDevices(command: { userId: string }) {
const devices = await this.security.listActiveDevices(command.userId);
async listActiveDevices(command: { userId: string; exceptSessionId?: string }) {
const devices = await this.security.listActiveDevices(command.userId, command.exceptSessionId);
return {
devices: devices.map((device) => ({
id: device.id,
@@ -337,11 +356,31 @@ export class AuthGrpcController {
}
@GrpcMethod('SecurityService', 'RevokeAllSessions')
async revokeAllSessions(command: { userId: string }) {
const result = await this.security.revokeAllSessions(command.userId);
async revokeAllSessions(command: { userId: string; exceptSessionId?: string }) {
const result = await this.security.revokeAllSessions(command.userId, command.exceptSessionId);
return { count: result.count };
}
@GrpcMethod('SecurityService', 'GetTotpStatus')
getTotpStatus(command: { userId: string }) {
return this.totp.getStatus(command.userId);
}
@GrpcMethod('SecurityService', 'SetupTotp')
setupTotp(command: { userId: string }) {
return this.totp.setup(command.userId);
}
@GrpcMethod('SecurityService', 'EnableTotp')
enableTotp(command: { userId: string; code: string }) {
return this.totp.enable(command.userId, command.code);
}
@GrpcMethod('SecurityService', 'DisableTotp')
disableTotp(command: { userId: string; code: string }) {
return this.totp.disable(command.userId, command.code);
}
@GrpcMethod('SecurityService', 'SetupPin')
setupPin(command: { userId: string; pin: string }) {
return this.pin.setupPin(command.userId, command.pin);
@@ -459,7 +498,7 @@ export class AuthGrpcController {
}
@GrpcMethod('ProfileService', 'UpdateProfile')
updateProfile(command: { userId: string; firstName?: string; lastName?: string; bio?: string; age?: number; gender?: string }) {
updateProfile(command: { userId: string; firstName?: string; lastName?: string; bio?: string; age?: number; gender?: string; birthDate?: string }) {
return this.profile.updateProfile(command);
}
@@ -621,8 +660,14 @@ export class AuthGrpcController {
}
@GrpcMethod('AdvancedAuthService', 'CreateQrSession')
createQrSession(command: { deviceName: string }) {
return this.advancedAuth.createQrSession();
createQrSession(command: { deviceName: string; fingerprint?: string; deviceType?: string; ipAddress?: string; userAgent?: string }) {
return this.advancedAuth.createQrSession({
deviceName: command.deviceName,
fingerprint: command.fingerprint ?? command.deviceName,
deviceType: command.deviceType,
ipAddress: command.ipAddress,
userAgent: command.userAgent
});
}
@GrpcMethod('AdvancedAuthService', 'PollQrSession')
@@ -630,6 +675,11 @@ export class AuthGrpcController {
return this.advancedAuth.pollQrSession(command.sessionId);
}
@GrpcMethod('AdvancedAuthService', 'ApproveQrSession')
approveQrSession(command: { sessionId: string; userId: string }) {
return this.advancedAuth.approveQrSession(command.sessionId, command.userId);
}
@GrpcMethod('FamilyService', 'CreateFamilyGroup')
createFamilyGroup(command: { ownerId: string; name: string }) {
return this.family.create(command.ownerId, command.name);
@@ -666,8 +716,16 @@ export class AuthGrpcController {
}
@GrpcMethod('FamilyService', 'SendFamilyInvite')
sendFamilyInvite(command: { requesterId: string; groupId: string; target: string }) {
return this.family.sendInvite(command.requesterId, command.groupId, command.target);
sendFamilyInvite(command: { requesterId: string; groupId: string; target?: string; inviteeUserId?: string }) {
return this.family.sendInvite(command.requesterId, command.groupId, {
target: command.target,
inviteeUserId: command.inviteeUserId
});
}
@GrpcMethod('FamilyService', 'SearchFamilyInviteUsers')
searchFamilyInviteUsers(command: { requesterId: string; groupId: string; query: string }) {
return this.family.searchInviteUsers(command.requesterId, command.groupId, command.query);
}
@GrpcMethod('FamilyService', 'RespondFamilyInvite')