Merge pull request #3545 from gradido/fix_federation

fix(federation): fix bug
This commit is contained in:
einhornimmond 2025-10-03 15:49:28 +02:00 committed by GitHub
commit e06f6a629e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 4 deletions

View File

@ -33,7 +33,7 @@ function composeDataString(data: (string | Object)[]): string {
return data
.map((d) => {
// if it is a object and his toString function return only garbage
if (typeof d === 'object' && d.toString() === '[object Object]') {
if (d && typeof d === 'object' && d.toString() === '[object Object]') {
return inspect(d, )
}
if (d) {

View File

@ -109,7 +109,7 @@ export class AuthenticationResolver {
}
}
@Mutation(() => String)
@Mutation(() => String, { nullable: true })
async authenticate(
@Arg('data')
args: EncryptedTransferArgs,
@ -125,7 +125,7 @@ export class AuthenticationResolver {
// no infos to the caller
return null
}
if (!uint32Schema.safeParse(authArgs.oneTimeCode).success) {
if (!uint32Schema.safeParse(Number(authArgs.oneTimeCode)).success) {
const errmsg = `invalid oneTimeCode: ${authArgs.oneTimeCode} for community with publicKey ${authArgs.publicKey}, expect uint32`
methodLogger.error(errmsg)
// no infos to the caller

View File

@ -1,5 +1,5 @@
import { describe, expect, it } from 'bun:test'
import { uuidv4Schema } from './base.schema'
import { uuidv4Schema, uint32Schema } from './base.schema'
import { v4 as uuidv4 } from 'uuid'
describe('uuidv4 schema', () => {
@ -10,3 +10,15 @@ describe('uuidv4 schema', () => {
}
})
})
describe('uint32 schema', () => {
it('should validate uint32 (40x)', () => {
for (let i = 0; i < 40; i++) {
const uint32 = Math.floor(Math.random() * 4294967295)
expect(uint32Schema.safeParse(uint32).success).toBeTruthy()
}
})
it('should validate 2092352810', () => {
expect(uint32Schema.safeParse(2092352810).success).toBeTruthy()
})
})