createSocketAuthMiddleware
createSocketAuthMiddleware(
__namedParameters): (socket,next) =>void
Build the Socket.io auth middleware from a validator chain: validators run in order and the first success wins; when all fail the connection is rejected with the last error.
Parameters
__namedParameters
betterAuth?
Enables the Better Auth session validator after the legacy JWT validator.
extraValidators?
SocketAuthValidator[] = []
Additional validators appended to the chain (after JWT and Better Auth).
issuer?
string | (() => string | undefined)
JWT issuer to require (D1 parity with the HTTP path's jwt.verify(token, secret, {issuer})). Omitted means no issuer check, matching pre-D1 behavior. A thunk is
resolved fresh on every handshake (see createLegacyJwtValidator).
tokenSecret
string
Secret for the legacy JWT validator (same handling as before the refactor).
Returns
(socket, next) => void