diff --git a/test/types/aedes.test-d.ts b/test/types/aedes.test-d.ts index a9a09b74..1eb10e4a 100644 --- a/test/types/aedes.test-d.ts +++ b/test/types/aedes.test-d.ts @@ -1,4 +1,5 @@ import { expectType } from 'tsd' +import { timingSafeEqual } from 'crypto' import { Socket } from 'net' import type { Aedes, @@ -27,8 +28,8 @@ const broker = Server({ callback(new Error('connection error'), false) } }, - authenticate: (client: Client, username: Readonly, password: Readonly, callback) => { - if (username === 'test' && password === Buffer.from('test') && client.version === 4) { + authenticate: (client: Client, username: string, password: Buffer, callback) => { + if (username === 'test' && timingSafeEqual(password, Buffer.from('test')) && client.version === 4) { callback(null, true) } else { const error = new Error() as AuthenticateError diff --git a/types/instance.d.ts b/types/instance.d.ts index ca18155a..44898a68 100644 --- a/types/instance.d.ts +++ b/types/instance.d.ts @@ -27,8 +27,8 @@ type PreConnectHandler = (client: Client, packet: ConnectPacket, callback: (erro type AuthenticateHandler = ( client: Client, - username: Readonly, - password: Readonly, + username: string, + password: Buffer, done: (error: AuthenticateError | null, success: boolean | null) => void ) => void