diff --git a/index.js b/index.js index cc520cc..4b44712 100644 --- a/index.js +++ b/index.js @@ -1,8 +1,12 @@ -import { Hocuspocus } from "@hocuspocus/server"; +import { Server } from "@hocuspocus/server"; -const server = new Hocuspocus({ - async onConnect({ connection }) { - connection.requiresAuthentication = false; +const server = Server.configure({ + async onAuthenticate(data) { + const { token } = data; + + if (token !== "hocuspocus-token") { + throw new Error("Not authorized!"); + } }, port: 4242, });