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

@hocuspocus/provider

Package Overview
Dependencies
Maintainers
5
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hocuspocus/provider - npm Package Compare versions

Comparing version 2.6.1 to 2.7.0

2

dist/packages/extension-database/src/Database.d.ts

@@ -11,3 +11,3 @@ import { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from '@hocuspocus/server';

*/
store: (data: storePayload) => void;
store: (data: storePayload) => Promise<void>;
}

@@ -14,0 +14,0 @@ export declare class Database implements Extension {

@@ -94,3 +94,2 @@ import * as mutex from 'lib0/mutex';

boundOnOpen: (event: Event) => Promise<void>;
boundOnMessage: (event: MessageEvent) => void;
boundOnClose: (event: CloseEvent) => void;

@@ -97,0 +96,0 @@ boundOnStatus: ({ status }: onStatusParameters) => void;

@@ -80,2 +80,6 @@ import * as mutex from 'lib0/mutex';

quiet: boolean;
/**
* Map of attached providers keyed by documentName.
*/
providerMap: Map<string, HocuspocusProvider>;
}

@@ -82,0 +86,0 @@ export declare class HocuspocusProviderWebsocket extends EventEmitter {

@@ -9,2 +9,3 @@ import { Decoder } from 'lib0/decoding';

constructor(data: any);
peekVarString(): string;
readVarUint(): MessageType;

@@ -11,0 +12,0 @@ readVarString(): string;

@@ -13,3 +13,3 @@ import Document from './Document.js';

transact(transaction: (document: Document) => void, transactionOrigin?: any): Promise<void>;
disconnect(): void;
disconnect(): Promise<void>;
}

@@ -22,2 +22,3 @@ import WebSocket from 'ws';

isLoading: boolean;
isDestroyed: boolean;
/**

@@ -91,3 +92,4 @@ * Constructor.

broadcastStateless(payload: string): void;
destroy(): void;
}
export default Document;

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

createDocument(documentName: string, request: Partial<Pick<IncomingMessage, 'headers' | 'url'>>, socketId: string, connection: ConnectionConfiguration, context?: any): Promise<Document>;
storeDocumentHooks(document: Document, hookPayload: onStoreDocumentPayload): void;
storeDocumentHooks(document: Document, hookPayload: onStoreDocumentPayload): Promise<void>;
/**

@@ -88,0 +88,0 @@ * Run the given hook on all configured extensions.

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

export interface onAuthenticatePayload {
context: any;
documentName: string;

@@ -136,0 +137,0 @@ instance: Hocuspocus;

{
"name": "@hocuspocus/provider",
"version": "2.6.1",
"version": "2.7.0",
"description": "hocuspocus provider",

@@ -32,6 +32,6 @@ "homepage": "https://hocuspocus.dev",

"dependencies": {
"@hocuspocus/common": "^2.6.1",
"@hocuspocus/common": "^2.7.0",
"@lifeomic/attempt": "^3.0.2",
"lib0": "^0.2.47",
"ws": "^7.5.9"
"ws": "^8.14.2"
},

@@ -38,0 +38,0 @@ "peerDependencies": {

@@ -195,4 +195,2 @@ import { awarenessStatesToArray } from '@hocuspocus/common'

this.configuration.websocketProvider.on('message', this.boundOnMessage)
this.configuration.websocketProvider.on('close', this.boundOnClose)

@@ -238,4 +236,2 @@ this.configuration.websocketProvider.on('close', this.configuration.onClose)

boundOnMessage = this.onMessage.bind(this)
boundOnClose = this.onClose.bind(this)

@@ -392,5 +388,13 @@

let token: string | null
try {
token = await this.getToken()
} catch (error) {
this.permissionDeniedHandler(`Failed to get token: ${error}`)
return
}
if (this.isAuthenticationRequired) {
this.send(AuthenticationMessage, {
token: await this.getToken(),
token,
documentName: this.configuration.name,

@@ -445,6 +449,2 @@ })

if (documentName !== this.configuration.name) {
return // message is meant for another provider
}
message.writeVarString(documentName)

@@ -493,3 +493,2 @@

this.configuration.websocketProvider.off('open', this.forwardOpen)
this.configuration.websocketProvider.off('message', this.boundOnMessage)
this.configuration.websocketProvider.off('close', this.boundOnClose)

@@ -496,0 +495,0 @@ this.configuration.websocketProvider.off('close', this.configuration.onClose)

@@ -17,2 +17,3 @@ import {

} from './types.js'
import { IncomingMessage } from './IncomingMessage.js'

@@ -95,2 +96,7 @@ export type HocusPocusWebSocket = WebSocket & { identifier: string };

quiet: boolean,
/**
* Map of attached providers keyed by documentName.
*/
providerMap: Map<string, HocuspocusProvider>,
}

@@ -139,2 +145,3 @@

quiet: false,
providerMap: new Map(),
}

@@ -221,2 +228,4 @@

attach(provider: HocuspocusProvider) {
this.configuration.providerMap.set(provider.configuration.name, provider)
if (this.status === WebSocketStatus.Disconnected && this.shouldConnect) {

@@ -236,3 +245,3 @@ this.connect()

detach(provider: HocuspocusProvider) {
// tell the server to remove the listener
this.configuration.providerMap.delete(provider.configuration.name)
}

@@ -376,2 +385,7 @@

this.lastMessageReceived = time.getUnixTime()
const message = new IncomingMessage(event.data)
const documentName = message.peekVarString()
this.configuration.providerMap.get(documentName)?.onMessage(event)
}

@@ -378,0 +392,0 @@

import {
createDecoder,
peekVarString,
readVarUint,

@@ -32,2 +33,6 @@ readVarUint8Array,

peekVarString(): string {
return peekVarString(this.decoder)
}
readVarUint(): MessageType {

@@ -34,0 +39,0 @@ return readVarUint(this.decoder)

@@ -12,5 +12,2 @@ import * as encoding from 'lib0/encoding'

console.log('queryAwareness: writing string docName', args.documentName)
console.log(this.encoder.cpos)
encoding.writeVarString(this.encoder, args.documentName!)

@@ -17,0 +14,0 @@ encoding.writeVarUint(this.encoder, this.type)

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