Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hocuspocus/server

Package Overview
Dependencies
Maintainers
4
Versions
116
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hocuspocus/server - npm Package Compare versions

Comparing version 1.0.0-beta.4 to 1.0.0-beta.5

4

package.json
{
"name": "@hocuspocus/server",
"description": "plug & play collaboration backend",
"version": "1.0.0-beta.4",
"version": "1.0.0-beta.5",
"homepage": "https://hocuspocus.dev",

@@ -31,3 +31,3 @@ "keywords": [

"dependencies": {
"@hocuspocus/common": "^1.0.0-beta.4",
"@hocuspocus/common": "^1.0.0-beta.5",
"@types/async-lock": "^1.1.3",

@@ -34,0 +34,0 @@ "@types/uuid": "^8.3.4",

@@ -434,61 +434,68 @@ import * as decoding from 'lib0/decoding'

const queueIncomingMessageListener = (data: Uint8Array) => {
const decoder = decoding.createDecoder(data)
const type = decoding.readVarUint(decoder)
try {
const decoder = decoding.createDecoder(data)
const type = decoding.readVarUint(decoder)
// Okay, we’ve got the authentication message we’re waiting for:
if (type === MessageType.Auth) {
// The 2nd integer contains the submessage type
// which will always be authentication when sent from client -> server
decoding.readVarUint(decoder)
const token = decoding.readVarString(decoder)
// Okay, we’ve got the authentication message we’re waiting for:
if (type === MessageType.Auth) {
// The 2nd integer contains the submessage type
// which will always be authentication when sent from client -> server
decoding.readVarUint(decoder)
const token = decoding.readVarString(decoder)
this.debugger.log({
direction: 'in',
type,
category: 'Token',
})
this.debugger.log({
direction: 'in',
type,
category: 'Token',
})
this.hooks('onAuthenticate', { token, ...hookPayload }, (contextAdditions: any) => {
// Hooks are allowed to give us even more context and we’ll merge everything together.
// We’ll pass the context to other hooks then.
context = { ...context, ...contextAdditions }
})
.then(() => {
// All `onAuthenticate` hooks passed.
connection.isAuthenticated = true
this.hooks('onAuthenticate', { token, ...hookPayload }, (contextAdditions: any) => {
// Hooks are allowed to give us even more context and we’ll merge everything together.
// We’ll pass the context to other hooks then.
context = { ...context, ...contextAdditions }
})
.then(() => {
// All `onAuthenticate` hooks passed.
connection.isAuthenticated = true
// Let the client know that authentication was successful.
const message = new OutgoingMessage().writeAuthenticated()
// Let the client know that authentication was successful.
const message = new OutgoingMessage().writeAuthenticated()
this.debugger.log({
direction: 'out',
type: message.type,
category: message.category,
this.debugger.log({
direction: 'out',
type: message.type,
category: message.category,
})
incoming.send(message.toUint8Array())
})
.then(() => {
// Time to actually establish the connection.
return setUpNewConnection(queueIncomingMessageListener)
})
.catch((error = Forbidden) => {
const message = new OutgoingMessage().writePermissionDenied(error.reason ?? 'permission-denied')
incoming.send(message.toUint8Array())
})
.then(() => {
// Time to actually establish the connection.
return setUpNewConnection(queueIncomingMessageListener)
})
.catch((error = Forbidden) => {
const message = new OutgoingMessage().writePermissionDenied(error.reason ?? 'permission-denied')
this.debugger.log({
direction: 'out',
type: message.type,
category: message.category,
})
this.debugger.log({
direction: 'out',
type: message.type,
category: message.category,
// Ensure that the permission denied message is sent before the
// connection is closed
incoming.send(message.toUint8Array(), () => {
incoming.close(error.code ?? Forbidden.code, error.reason ?? Forbidden.reason)
incoming.off('message', queueIncomingMessageListener)
})
})
} else {
// It’s not the Auth message we’re waiting for, so just queue it.
incomingMessageQueue.push(data)
}
// Ensure that the permission denied message is sent before the
// connection is closed
incoming.send(message.toUint8Array(), () => {
incoming.close(error.code ?? Forbidden.code, error.reason ?? Forbidden.reason)
incoming.off('message', queueIncomingMessageListener)
})
})
} else {
// It’s not the Auth message we’re waiting for, so just queue it.
incomingMessageQueue.push(data)
// Catch errors due to failed decoding of data
} catch (error) {
incoming.close(Unauthorized.code, Unauthorized.reason)
incoming.off('message', queueIncomingMessageListener)
}

@@ -495,0 +502,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc