🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

@hocuspocus/extension-logger

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hocuspocus/extension-logger - npm Package Compare versions

Comparing version

to
3.0.4-rc.0

@@ -5,3 +5,3 @@ import * as encoding from 'lib0/encoding';

export declare const writePermissionDenied: (encoder: encoding.Encoder, reason: string) => void;
export declare const writeAuthenticated: (encoder: encoding.Encoder, scope: "readonly" | "read-write") => void;
export declare const writeAuthenticated: (encoder: encoding.Encoder, scope: 'readonly' | 'read-write') => void;
export declare const readAuthMessage: (decoder: decoding.Decoder, permissionDeniedHandler: (reason: string) => void, authenticatedHandler: (scope: string) => void) => void;

@@ -0,1 +1,3 @@

/// <reference types="node" />
/// <reference types="node" />
import type { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis';

@@ -5,3 +7,2 @@ import RedisClient from 'ioredis';

import type { Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, onConfigurePayload, beforeBroadcastStatelessPayload, Hocuspocus } from '@hocuspocus/server';
import { Debugger } from '@hocuspocus/server';
export type RedisInstance = RedisClient.Cluster | RedisClient.Redis;

@@ -68,4 +69,9 @@ export interface Configuration {

locks: Map<string, Redlock.Lock>;
logger: Debugger;
messagePrefix: Buffer;
/**
* When we have a high frequency of updates to a document we don't need tons of setTimeouts
* piling up, so we'll track them to keep it to the most recent per document.
*/
private pendingDisconnects;
private pendingAfterStoreDocumentResolves;
constructor(configuration: Partial<Configuration>);

@@ -72,0 +78,0 @@ onConfigure({ instance }: onConfigurePayload): Promise<void>;

@@ -0,1 +1,2 @@

/// <reference types="node" />
import type { Extension, onConnectPayload } from '@hocuspocus/server';

@@ -2,0 +3,0 @@ export interface ThrottleConfiguration {

@@ -0,1 +1,2 @@

/// <reference types="node" />
import type { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';

@@ -2,0 +3,0 @@ import type { Doc } from 'yjs';

@@ -1,3 +0,2 @@

import * as mutex from 'lib0/mutex';
import type { CloseEvent, Event, MessageEvent } from 'ws';
import type { Event, MessageEvent } from 'ws';
import { Awareness } from 'y-protocols/awareness';

@@ -8,3 +7,3 @@ import * as Y from 'yjs';

import { HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js';
import type { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onStatusParameters, onSyncedParameters } from './types.js';
import type { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onSyncedParameters } from './types.js';
export type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, 'name'>> & Partial<CompleteHocuspocusProviderConfiguration> & (Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, 'url'>> | Required<Pick<CompleteHocuspocusProviderConfiguration, 'websocketProvider'>>);

@@ -21,6 +20,2 @@ export interface CompleteHocuspocusProviderConfiguration {

/**
* Pass false to disable broadcasting between browser tabs.
*/
broadcast: boolean;
/**
* An Awareness instance to keep the presence state of all clients.

@@ -39,8 +34,2 @@ *

/**
* URL parameters that should be added.
*/
parameters: {
[key: string]: any;
};
/**
* Hocuspocus websocket provider

@@ -59,3 +48,2 @@ */

onOutgoingMessage: (data: onOutgoingMessageParameters) => void;
onStatus: (data: onStatusParameters) => void;
onSynced: (data: onSyncedParameters) => void;

@@ -68,14 +56,2 @@ onDisconnect: (data: onDisconnectParameters) => void;

onStateless: (data: onStatelessParameters) => void;
/**
* Don’t output any warnings.
*/
quiet: boolean;
/**
* Pass `false` to start the connection manually.
*/
connect: boolean;
/**
* Pass `false` to close the connection manually.
*/
preserveConnection: boolean;
}

@@ -87,3 +63,2 @@ export declare class AwarenessError extends Error {

configuration: CompleteHocuspocusProviderConfiguration;
subscribedToBroadcastChannel: boolean;
isSynced: boolean;

@@ -93,10 +68,12 @@ unsyncedChanges: number;

authorizedScope: string | undefined;
mux: mutex.mutex;
manageSocket: boolean;
private isAttached;
intervals: any;
constructor(configuration: HocuspocusProviderConfiguration);
boundDocumentUpdateHandler: (update: Uint8Array, origin: any) => void;
boundAwarenessUpdateHandler: ({ added, updated, removed }: any, origin: any) => void;
boundPageHide: () => void;
boundOnOpen: (event: Event) => Promise<void>;
boundOnClose: (event: CloseEvent) => void;
boundOnClose: () => void;
forwardConnect: (e: any) => this;
forwardOpen: (e: any) => this;
forwardClose: (e: any) => this;

@@ -127,3 +104,2 @@ forwardDisconnect: (e: any) => this;

receiveStateless(payload: string): void;
get isAuthenticationRequired(): boolean;
connect(): Promise<void>;

@@ -134,6 +110,8 @@ disconnect(): void;

startSync(): void;
send(message: ConstructableOutgoingMessage, args: any, broadcast?: boolean): void;
send(message: ConstructableOutgoingMessage, args: any): void;
onMessage(event: MessageEvent): void;
onClose(event: CloseEvent): void;
onClose(): void;
destroy(): void;
detach(): void;
attach(): void;
permissionDeniedHandler(reason: string): void;

@@ -140,0 +118,0 @@ authenticatedHandler(scope: string): void;

@@ -76,6 +76,2 @@ import type { MessageEvent, Event } from 'ws';

/**
* Don’t output any warnings.
*/
quiet: boolean;
/**
* Map of attached providers keyed by documentName.

@@ -82,0 +78,0 @@ */

export * from './HocuspocusProvider.js';
export * from './TiptapCollabProvider.js';
export * from './TiptapCollabProviderWebsocket.js';
export * from './HocuspocusProviderWebsocket.js';
export * from './types.js';

@@ -5,5 +5,3 @@ import type { HocuspocusProvider } from './HocuspocusProvider.js';

message: IncomingMessage;
broadcasted: boolean;
constructor(message: IncomingMessage);
setBroadcasted(value: boolean): this;
apply(provider: HocuspocusProvider, emitSynced: boolean): void;

@@ -10,0 +8,0 @@ private applySyncMessage;

@@ -91,4 +91,6 @@ import type { Encoder } from 'lib0/encoding';

updatedAt: number;
deletedAt: number | null;
resolvedAt?: string;
comments: TCollabComment<CommentData>[];
deletedComments: TCollabComment<CommentData>[];
data: Data;

@@ -98,4 +100,5 @@ };

id: string;
createdAt: number;
updatedAt: number;
createdAt: string;
updatedAt: string;
deletedAt?: string;
data: Data;

@@ -149,1 +152,38 @@ content: any;

};
export type DeleteCommentOptions = {
/**
* If `true`, the thread will also be deleted if the deleted comment was the first comment in the thread.
*/
deleteThread?: boolean;
/**
* If `true`, will remove the content of the deleted comment
*/
deleteContent?: boolean;
};
export type DeleteThreadOptions = {
/**
* If `true`, will remove the comments on the thread,
* otherwise will only mark the thread as deleted
* and keep the comments
* @default false
*/
deleteComments?: boolean;
/**
* If `true`, will forcefully remove the thread and all comments,
* otherwise will only mark the thread as deleted
* and keep the comments
* @default false
*/
force?: boolean;
};
/**
* The type of thread
*/
export type ThreadType = 'archived' | 'unarchived';
export type GetThreadsOptions = {
/**
* The types of threads to get
* @default ['unarchived']
*/
types?: Array<ThreadType>;
};

@@ -0,4 +1,6 @@

/// <reference types="node" />
/// <reference types="node" />
import type { IncomingMessage } from 'http';
import { type CloseEvent } from '@hocuspocus/common';
import type WebSocket from 'ws';
import type { Debugger } from './Debugger.js';
import type Document from './Document.js';

@@ -18,3 +20,2 @@ import type { Hocuspocus } from './Hocuspocus.js';

private readonly hooks;
private readonly debuggerTool;
private readonly opts;

@@ -27,4 +28,6 @@ private readonly defaultContext;

private readonly callbacks;
private readonly closeIdleConnectionTimeout;
private readonly socketId;
timeout: number;
pingInterval: NodeJS.Timeout;
pongReceived: boolean;
/**

@@ -42,7 +45,14 @@ * The `ClientConnection` class receives incoming WebSocket connections,

createDocument: Hocuspocus['createDocument'];
}, hooks: Hocuspocus['hooks'], debuggerTool: Debugger, opts: {
requiresAuthentication: boolean;
}, hooks: Hocuspocus['hooks'], opts: {
timeout: number;
}, defaultContext?: any);
private handleWebsocketClose;
close(event?: CloseEvent): void;
handlePong: () => void;
/**
* Check if pong was received and close the connection otherwise
* @private
*/
private check;
/**
* Set a callback that will be triggered when the connection is closed

@@ -49,0 +59,0 @@ */

@@ -0,7 +1,6 @@

/// <reference types="node" />
import type { IncomingMessage as HTTPIncomingMessage } from 'http';
import AsyncLock from 'async-lock';
import type WebSocket from 'ws';
import type { CloseEvent } from '@hocuspocus/common';
import { type CloseEvent } from '@hocuspocus/common';
import type Document from './Document.js';
import type { Debugger } from './Debugger.js';
import type { onStatelessPayload } from './types.js';

@@ -12,18 +11,10 @@ export declare class Connection {

document: Document;
pingInterval: NodeJS.Timeout;
pongReceived: boolean;
request: HTTPIncomingMessage;
timeout: number;
callbacks: any;
socketId: string;
lock: AsyncLock;
readOnly: boolean;
logger: Debugger;
/**
* Constructor.
*/
constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document, timeout: number, socketId: string, context: any, readOnly: boolean | undefined, logger: Debugger);
boundClose: (event?: CloseEvent) => void;
boundHandlePong: () => void;
handlePong(): void;
constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document, socketId: string, context: any, readOnly?: boolean);
/**

@@ -54,7 +45,2 @@ * Set a callback that will be triggered when the connection is closed

/**
* Check if pong was received and close the connection otherwise
* @private
*/
private check;
/**
* Send the current document awareness to the client, if any

@@ -61,0 +47,0 @@ * @private

@@ -12,4 +12,4 @@ import type Document from './Document.js';

constructor(document: Document, instance: Hocuspocus, context?: any);
transact(transaction: (document: Document) => void, transactionOrigin?: any): Promise<void>;
transact(transaction: (document: Document) => void): Promise<void>;
disconnect(): Promise<void>;
}
import type WebSocket from 'ws';
import { Awareness } from 'y-protocols/awareness';
import { Doc } from 'yjs';
import type { mutex } from 'lib0/mutex.js';
import type Connection from './Connection.js';
import type { Debugger } from './Debugger.js';
export declare class Document extends Doc {

@@ -19,4 +17,2 @@ awareness: Awareness;

name: string;
mux: mutex;
logger?: Debugger;
isLoading: boolean;

@@ -27,3 +23,3 @@ isDestroyed: boolean;

*/
constructor(name: string, logger?: Debugger, yDocOptions?: object);
constructor(name: string, yDocOptions?: object);
/**

@@ -30,0 +26,0 @@ * Check if the Document (XMLFragment or Map) is empty

@@ -0,5 +1,5 @@

/// <reference types="node" />
import type { IncomingMessage } from 'http';
import type WebSocket from 'ws';
import type { Server } from './Server.js';
import { Debugger } from './Debugger.js';
import { DirectConnection } from './DirectConnection.js';

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

server?: Server;
debugger: Debugger;
debouncer: {

@@ -37,3 +36,2 @@ debounce: (id: string, func: Function, debounce: number, maxDebounce: number) => any;

configure(configuration: Partial<Configuration>): Hocuspocus;
get requiresAuthentication(): boolean;
/**

@@ -73,3 +71,3 @@ * Get the total number of active documents

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

@@ -81,10 +79,4 @@ /**

hooks<T extends HookName>(name: T, payload: HookPayloadByName[T], callback?: Function | null): Promise<any>;
unloadDocument(document: Document): void;
enableDebugging(): void;
enableMessageLogging(): void;
disableLogging(): void;
disableDebugging(): void;
flushMessageLogs(): this;
getMessageLogs(): any[];
unloadDocument(document: Document): Promise<any>;
openDirectConnection(documentName: string, context?: any): Promise<DirectConnection>;
}
export * from './Connection.js';
export * from './Debugger.js';
export * from './Document.js';

@@ -4,0 +3,0 @@ export * from './Hocuspocus.js';

import type Connection from './Connection.js';
import type { Debugger } from './Debugger.js';
import type Document from './Document.js';

@@ -7,5 +6,4 @@ import type { IncomingMessage } from './IncomingMessage.js';

message: IncomingMessage;
logger: Debugger;
defaultTransactionOrigin?: string;
constructor(message: IncomingMessage, logger: Debugger, defaultTransactionOrigin?: string);
constructor(message: IncomingMessage, defaultTransactionOrigin?: string);
apply(document: Document, connection?: Connection, reply?: (message: Uint8Array) => void): void;

@@ -12,0 +10,0 @@ readSyncMessage(message: IncomingMessage, document: Document, connection?: Connection, reply?: (message: Uint8Array) => void, requestFirstSync?: boolean): 0 | 1 | 2;

@@ -20,3 +20,4 @@ import type { Encoder } from 'lib0/encoding';

writeSyncStatus(updateSaved: boolean): OutgoingMessage;
writeCloseMessage(reason: string): OutgoingMessage;
toUint8Array(): Uint8Array;
}

@@ -0,4 +1,5 @@

/// <reference types="node" />
import type { IncomingMessage, Server as HTTPServer, ServerResponse } from 'http';
import type { AddressInfo } from 'ws';
import { WebSocketServer } from 'ws';
import type { AddressInfo, ServerOptions } from 'ws';
import { Hocuspocus } from './Hocuspocus.js';

@@ -21,3 +22,3 @@ import type { Configuration } from './types';

configuration: ServerConfiguration;
constructor(configuration?: Partial<ServerConfiguration>);
constructor(configuration?: Partial<ServerConfiguration>, websocketOptions?: ServerOptions);
setupWebsocketConnection: () => void;

@@ -24,0 +25,0 @@ setupHttpUpgrade: () => void;

@@ -0,1 +1,5 @@

/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'http';

@@ -13,3 +17,3 @@ import type { URLSearchParams } from 'url';

QueryAwareness = 3,
SyncReply = 4,// same as Sync, but won't trigger another 'SyncStep1'
SyncReply = 4,
Stateless = 5,

@@ -27,3 +31,2 @@ BroadcastStateless = 6,

readOnly: boolean;
requiresAuthentication: boolean;
isAuthenticated: boolean;

@@ -52,6 +55,7 @@ }

onDisconnect?(data: onDisconnectPayload): Promise<any>;
beforeUnloadDocument?(data: beforeUnloadDocumentPayload): Promise<any>;
afterUnloadDocument?(data: afterUnloadDocumentPayload): Promise<any>;
onDestroy?(data: onDestroyPayload): Promise<any>;
}
export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'afterUnloadDocument' | 'onDestroy';
export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'beforeUnloadDocument' | 'afterUnloadDocument' | 'onDestroy';
export type HookPayloadByName = {

@@ -77,2 +81,3 @@ onConfigure: onConfigurePayload;

afterUnloadDocument: afterUnloadDocumentPayload;
beforeUnloadDocument: beforeUnloadDocumentPayload;
onDestroy: onDestroyPayload;

@@ -137,3 +142,3 @@ };

token: string;
connection: ConnectionConfiguration;
connectionConfig: ConnectionConfiguration;
}

@@ -147,3 +152,3 @@ export interface onCreateDocumentPayload {

socketId: string;
connection: ConnectionConfiguration;
connectionConfig: ConnectionConfiguration;
}

@@ -158,3 +163,3 @@ export interface onConnectPayload {

socketId: string;
connection: ConnectionConfiguration;
connectionConfig: ConnectionConfiguration;
}

@@ -169,4 +174,4 @@ export interface connectedPayload {

socketId: string;
connection: ConnectionConfiguration;
connectionInstance: Connection;
connectionConfig: ConnectionConfiguration;
connection: Connection;
}

@@ -181,3 +186,3 @@ export interface onLoadDocumentPayload {

socketId: string;
connection: ConnectionConfiguration;
connectionConfig: ConnectionConfiguration;
}

@@ -192,3 +197,3 @@ export interface afterLoadDocumentPayload {

socketId: string;
connection: ConnectionConfiguration;
connectionConfig: ConnectionConfiguration;
}

@@ -263,3 +268,3 @@ export interface onChangePayload {

socketId: string;
connection: ConnectionConfiguration;
connectionConfig: ConnectionConfiguration;
}

@@ -307,2 +312,6 @@ export interface storePayload extends onStoreDocumentPayload {

}
export interface beforeUnloadDocumentPayload {
instance: Hocuspocus;
documentName: string;
}
export interface DirectConnection {

@@ -309,0 +318,0 @@ transact(transaction: (document: Document) => void): Promise<void>;

@@ -0,1 +1,3 @@

/// <reference types="node" />
/// <reference types="node" />
import type { IncomingMessage } from 'http';

@@ -2,0 +4,0 @@ import { URLSearchParams } from 'url';

@@ -1,3 +0,3 @@

import { HocuspocusProvider, type HocuspocusProviderConfiguration, type HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
import { HocuspocusProvider, type HocuspocusProviderConfiguration, type HocuspocusProviderWebsocket, type HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
import type { Hocuspocus } from '@hocuspocus/server';
export declare const newHocuspocusProvider: (server: Hocuspocus, options?: Partial<HocuspocusProviderConfiguration>, websocketOptions?: Partial<HocuspocusProviderWebsocketConfiguration>) => HocuspocusProvider;
export declare const newHocuspocusProvider: (server: Hocuspocus, options?: Partial<HocuspocusProviderConfiguration>, websocketOptions?: Partial<HocuspocusProviderWebsocketConfiguration>, websocketProvider?: HocuspocusProviderWebsocket) => HocuspocusProvider;
import type { HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
import { HocuspocusProviderWebsocket } from '@hocuspocus/provider';
import type { Hocuspocus } from '@hocuspocus/server';
export declare const newHocuspocusProviderWebsocket: (hocuspocus: Hocuspocus, options?: Partial<Omit<HocuspocusProviderWebsocketConfiguration, "url">>) => HocuspocusProviderWebsocket;
export declare const newHocuspocusProviderWebsocket: (hocuspocus: Hocuspocus, options?: Partial<Omit<HocuspocusProviderWebsocketConfiguration, 'url'>>) => HocuspocusProviderWebsocket;
{
"name": "@hocuspocus/extension-logger",
"version": "3.0.0-rc.0",
"version": "3.0.4-rc.0",
"description": "hocuspocus logging extension",

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

"dependencies": {
"@hocuspocus/server": "^3.0.0-rc.0"
"@hocuspocus/server": "^3.0.4-rc.0"
},
"gitHead": "b3454a4ca289a84ddfb7fa5607a2d4b8d5c37e9d"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet