Socket
Socket
Sign inDemoInstall

@hocuspocus/server

Package Overview
Dependencies
Maintainers
4
Versions
114
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.6 to 1.0.0-beta.7

1

dist/packages/server/src/Hocuspocus.d.ts

@@ -11,2 +11,3 @@ /// <reference types="node" />

port: number;
address: string;
timeout: number;

@@ -13,0 +14,0 @@ debounce: number;

16

dist/packages/server/src/types.d.ts

@@ -33,6 +33,2 @@ /// <reference types="node" />

onAuthenticate?(data: onAuthenticatePayload): Promise<any>;
/**
* @deprecated onCreateDocument is deprecated, use onLoadDocument instead
*/
onCreateDocument?(data: onLoadDocumentPayload): Promise<any>;
onLoadDocument?(data: onLoadDocumentPayload): Promise<any>;

@@ -49,7 +45,3 @@ afterLoadDocument?(data: onLoadDocumentPayload): Promise<any>;

}
export declare type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' |
/**
* @deprecated onCreateDocument is deprecated, use onLoadDocument instead
*/
'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'onDestroy';
export declare type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'onDestroy';
export declare type HookPayload = onConfigurePayload | onListenPayload | onUpgradePayload | onConnectPayload | connectedPayload | onAuthenticatePayload | onLoadDocumentPayload | onChangePayload | onStoreDocumentPayload | afterStoreDocumentPayload | onAwarenessUpdatePayload | onRequestPayload | onDisconnectPayload | onDestroyPayload;

@@ -68,4 +60,8 @@ export interface Configuration extends Extension {

*/
port: number | null;
port?: number;
/**
* The address which the server listens on.
*/
address?: string;
/**
* Defines in which interval the server sends a ping, and closes the connection when no pong is sent back.

@@ -72,0 +68,0 @@ */

import { Hocuspocus, Configuration } from '@hocuspocus/server';
export declare const newHocuspocus: (options?: Partial<Configuration> | undefined) => Hocuspocus;
export declare const newHocuspocus: (options?: Partial<Configuration> | undefined) => Promise<Hocuspocus>;
{
"name": "@hocuspocus/server",
"description": "plug & play collaboration backend",
"version": "1.0.0-beta.6",
"version": "1.0.0-beta.7",
"homepage": "https://hocuspocus.dev",

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

"dependencies": {
"@hocuspocus/common": "^1.0.0-beta.6",
"@hocuspocus/common": "^1.0.0-beta.7",
"@types/async-lock": "^1.1.3",
"@types/uuid": "^8.3.4",
"@types/uuid": "^9.0.0",
"@types/ws": "^8.5.3",

@@ -39,3 +39,3 @@ "async-lock": "^1.3.1",

"lib0": "^0.2.46",
"uuid": "^8.3.2",
"uuid": "^9.0.0",
"ws": "^8.5.0"

@@ -42,0 +42,0 @@ },

@@ -12,6 +12,6 @@ import * as decoding from 'lib0/decoding'

Forbidden,
CloseEvent,
awarenessStatesToArray,
WsReadyStates,
} from '@hocuspocus/common'
import { ListenOptions } from 'net'
import {

@@ -28,3 +28,3 @@ MessageType,

import { OutgoingMessage } from './OutgoingMessage'
import meta from '../package.json' assert { type: 'json' }
import meta from '../package.json' assert {type: 'json'}
import { Debugger } from './Debugger'

@@ -36,2 +36,3 @@ import { onListenPayload } from '.'

port: 80,
address: '0.0.0.0',
timeout: 30000,

@@ -47,4 +48,2 @@ debounce: 2000,

const defaultOnCreateDocument = () => new Promise(r => r(null))
/**

@@ -64,3 +63,2 @@ * Hocuspocus Server

onChange: () => new Promise(r => r(null)),
onCreateDocument: defaultOnCreateDocument,
onLoadDocument: () => new Promise(r => r(null)),

@@ -98,14 +96,2 @@ onStoreDocument: () => new Promise(r => r(null)),

/**
* The `onCreateDocument` hook has been renamed to `onLoadDocument`.
* We’ll keep this workaround to support the deprecated hook for a while, but output a warning.
*/
let onLoadDocument
if (this.configuration.onCreateDocument !== defaultOnCreateDocument) {
console.warn('[hocuspocus warn]: The onCreateDocument hook has been renamed. Use the onLoadDocument hook instead.')
onLoadDocument = this.configuration.onCreateDocument
} else {
onLoadDocument = this.configuration.onLoadDocument
}
this.configuration.extensions.sort((a, b) => {

@@ -133,3 +119,3 @@ const one = typeof a.priority === 'undefined' ? 100 : a.priority

onAuthenticate: this.configuration.onAuthenticate,
onLoadDocument,
onLoadDocument: this.configuration.onLoadDocument,
beforeHandleMessage: this.configuration.beforeHandleMessage,

@@ -229,4 +215,2 @@ onChange: this.configuration.onChange,

// prior hooks don't interfere
// TODO: Argument of type 'Duplex' is not assignable to parameter of type 'Socket'.
// @ts-ignore
webSocketServer.handleUpgrade(request, socket, head, ws => {

@@ -251,3 +235,6 @@ webSocketServer.emit('connection', ws, request)

return new Promise((resolve: Function, reject: Function) => {
server.listen(this.configuration.port, () => {
server.listen({
port: this.configuration.port,
host: this.configuration.address,
} as ListenOptions, () => {
if (!this.configuration.quiet && process.env.NODE_ENV !== 'testing') {

@@ -273,3 +260,3 @@ this.showStartScreen()

port: this.configuration.port,
address: '127.0.0.1',
address: this.configuration.address,
family: 'IPv4',

@@ -280,3 +267,3 @@ }) as AddressInfo

get URL(): string {
return `127.0.0.1:${this.address.port}`
return `${this.configuration.address}:${this.address.port}`
}

@@ -507,4 +494,5 @@

// Catch errors due to failed decoding of data
// Catch errors due to failed decoding of data
} catch (error) {
console.error(error)
incoming.close(Unauthorized.code, Unauthorized.reason)

@@ -532,3 +520,10 @@ incoming.off('message', queueIncomingMessageListener)

// if a hook interrupts, close the websocket connection
incoming.close(error.code ?? Forbidden.code, error.reason ?? Forbidden.reason)
try {
incoming.close(error.code ?? Forbidden.code, error.reason ?? Forbidden.reason)
} catch (closeError) {
// catch is needed in case invalid error code is returned by hook (that would fail sending the close message)
console.error(closeError)
incoming.close(Unauthorized.code, Unauthorized.reason)
}
incoming.off('message', queueIncomingMessageListener)

@@ -535,0 +530,0 @@ })

@@ -39,6 +39,2 @@ import {

onAuthenticate?(data: onAuthenticatePayload): Promise<any>,
/**
* @deprecated onCreateDocument is deprecated, use onLoadDocument instead
*/
onCreateDocument?(data: onLoadDocumentPayload): Promise<any>,
onLoadDocument?(data: onLoadDocumentPayload): Promise<any>,

@@ -63,6 +59,2 @@ afterLoadDocument?(data: onLoadDocumentPayload): Promise<any>,

'onAuthenticate' |
/**
* @deprecated onCreateDocument is deprecated, use onLoadDocument instead
*/
'onCreateDocument' |
'onLoadDocument' |

@@ -107,4 +99,8 @@ 'afterLoadDocument' |

*/
port: number | null,
port?: number,
/**
* The address which the server listens on.
*/
address?: string,
/**
* Defines in which interval the server sends a ping, and closes the connection when no pong is sent back.

@@ -111,0 +107,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