diff --git a/packages/client/lib/createOnAuthenticate.js b/packages/client/lib/createOnAuthenticate.js index 8d8c4ea1..e795c150 100644 --- a/packages/client/lib/createOnAuthenticate.js +++ b/packages/client/lib/createOnAuthenticate.js @@ -2,12 +2,14 @@ const ANONYMOUS = "ANONYMOUS"; const PLAIN = "PLAIN"; export default function createOnAuthenticate(credentials, userAgent) { - return async function onAuthenticate(authenticate, mechanisms, fast, entity) { + return async function onAuthenticate(...args) { if (typeof credentials === "function") { - await credentials(authenticate, mechanisms, fast); + await credentials(...args); return; } + const [authenticate, mechanisms, fast, entity] = args; + credentials.token ??= await fast?.fetch(); const mechanism = getMechanism({ mechanisms, entity, credentials });