fix(#85): resolve TypeScript compilation and validation issues
- Fix @IsNumber() validator on timestamp field (was @IsString() - critical security issue) - Fix TypeScript compilation error in sortObjectKeys array handling - Replace generic Error with UnauthorizedException and ServiceUnavailableException - Document hardcoded workspace ID limitation in handleIncomingConnection - Remove unused BadRequestException import All tests passing (70/70), TypeScript compiles cleanly, linting passes.
This commit is contained in:
@@ -4,7 +4,13 @@
|
||||
* Manages federation connections between instances.
|
||||
*/
|
||||
|
||||
import { Injectable, Logger, NotFoundException } from "@nestjs/common";
|
||||
import {
|
||||
Injectable,
|
||||
Logger,
|
||||
NotFoundException,
|
||||
UnauthorizedException,
|
||||
ServiceUnavailableException,
|
||||
} from "@nestjs/common";
|
||||
import { HttpService } from "@nestjs/axios";
|
||||
import { FederationConnectionStatus, Prisma } from "@prisma/client";
|
||||
import { PrismaService } from "../prisma/prisma.service";
|
||||
@@ -247,7 +253,7 @@ export class ConnectionService {
|
||||
if (!validation.valid) {
|
||||
const errorMsg = validation.error ?? "Unknown error";
|
||||
this.logger.warn(`Invalid connection request from ${request.instanceId}: ${errorMsg}`);
|
||||
throw new Error("Invalid connection request signature");
|
||||
throw new UnauthorizedException("Invalid connection request signature");
|
||||
}
|
||||
|
||||
// Create pending connection
|
||||
@@ -284,7 +290,9 @@ export class ConnectionService {
|
||||
} catch (error: unknown) {
|
||||
this.logger.error(`Failed to fetch remote identity from ${remoteUrl}`, error);
|
||||
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
||||
throw new Error(`Could not connect to remote instance: ${remoteUrl}: ${errorMessage}`);
|
||||
throw new ServiceUnavailableException(
|
||||
`Could not connect to remote instance: ${remoteUrl}: ${errorMessage}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user