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:
Jason Woltje
2026-02-03 11:48:23 -06:00
parent fc3919012f
commit df2086ffe8
4 changed files with 35 additions and 25 deletions

View File

@@ -156,23 +156,22 @@ export class SignatureService {
* @returns A new object with sorted keys
*/
private sortObjectKeys(obj: SignableMessage): SignableMessage {
// Handle null
if (obj === null) {
return obj;
}
// Handle arrays - map recursively
// Handle null and primitives
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (Array.isArray(obj)) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-argument
return obj.map((item: any) =>
typeof item === "object" && item !== null ? this.sortObjectKeys(item) : item
) as SignableMessage;
if (obj === null || typeof obj !== "object") {
return obj;
}
// Handle non-objects (primitives)
if (typeof obj !== "object") {
return obj;
// Handle arrays - recursively sort elements
if (Array.isArray(obj)) {
const sortedArray = obj.map((item: unknown) => {
if (typeof item === "object" && item !== null) {
return this.sortObjectKeys(item as SignableMessage);
}
return item;
});
// Arrays are valid SignableMessage values when nested in objects
return sortedArray as unknown as SignableMessage;
}
// Handle objects - sort keys alphabetically
@@ -181,10 +180,11 @@ export class SignatureService {
for (const key of keys) {
const value = obj[key];
sorted[key] =
typeof value === "object" && value !== null
? this.sortObjectKeys(value as SignableMessage)
: value;
if (typeof value === "object" && value !== null) {
sorted[key] = this.sortObjectKeys(value as SignableMessage);
} else {
sorted[key] = value;
}
}
return sorted;