fix federation authentication

This commit is contained in:
einhornimmond 2025-10-03 15:38:10 +02:00
parent 097fcd7103
commit 7b0e7f05b6
2 changed files with 15 additions and 3 deletions

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()
})
})