@mesh-kit/server 2.0.4 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -112,6 +112,11 @@ interface PostgreSQLAdapterOptions extends PersistenceAdapterOptions {
112
112
  max?: number;
113
113
  }
114
114
 
115
+ interface AuthenticationError {
116
+ code?: number;
117
+ message?: string;
118
+ }
119
+ type AuthenticateConnectionFn = (req: IncomingMessage) => Promise<any> | any;
115
120
  type SocketMiddleware = (context: MeshContext<any>) => any | Promise<any>;
116
121
  interface MeshServerOptions extends ServerOptions {
117
122
  /**
@@ -172,6 +177,31 @@ interface MeshServerOptions extends ServerOptions {
172
177
  * @default "sqlite"
173
178
  */
174
179
  persistenceAdapter?: "sqlite" | "postgres";
180
+ /**
181
+ * Called during WebSocket upgrade to authenticate the connection.
182
+ * Receives the raw HTTP request with headers and cookies.
183
+ *
184
+ * Return any truthy value to accept the connection - the returned data
185
+ * will be automatically stored as the connection's initial metadata.
186
+ *
187
+ * Throw an error or return null/undefined to reject with 401 Unauthorized.
188
+ * Throw an object with { code, message } for custom HTTP status codes.
189
+ *
190
+ * @example
191
+ * ```ts
192
+ * authenticateConnection: async (req) => {
193
+ * const cookies = parseCookie(req.headers.cookie || "");
194
+ * const token = cookies["auth_token"];
195
+ *
196
+ * const user = await validateToken(token);
197
+ * if (!user) throw { code: 401, message: "Invalid token" };
198
+ *
199
+ * // returned data becomes connection metadata
200
+ * return { userId: user.id, email: user.email };
201
+ * }
202
+ * ```
203
+ */
204
+ authenticateConnection?: AuthenticateConnectionFn;
175
205
  }
176
206
  type ChannelPattern$1 = string | RegExp;
177
207
 
@@ -653,6 +683,121 @@ declare class RecordManager {
653
683
  }) => Promise<void> | void): () => void;
654
684
  }
655
685
 
686
+ type RecordPersistencePattern = {
687
+ writePattern: string | RegExp;
688
+ restorePattern: string;
689
+ };
690
+ declare class PersistenceManager extends EventEmitter$1 {
691
+ private defaultAdapter;
692
+ private channelPatterns;
693
+ private recordPatterns;
694
+ private messageBuffer;
695
+ private recordBuffer;
696
+ private flushTimers;
697
+ private recordFlushTimer;
698
+ private isShuttingDown;
699
+ private initialized;
700
+ private recordManager;
701
+ private pendingRecordUpdates;
702
+ private messageStream;
703
+ constructor(options: {
704
+ defaultAdapterOptions?: any;
705
+ adapterType?: "sqlite" | "postgres";
706
+ });
707
+ /**
708
+ * Sets the record manager reference for record restoration
709
+ * @param recordManager The record manager instance
710
+ */
711
+ setRecordManager(recordManager: RecordManager): void;
712
+ /**
713
+ * Waits until the persistence manager is fully ready and initialized.
714
+ *
715
+ * @returns {Promise<void>} A promise that resolves when persistence is ready.
716
+ */
717
+ ready(): Promise<void>;
718
+ /**
719
+ * Processes any record updates that were buffered during initialization
720
+ */
721
+ private processPendingRecordUpdates;
722
+ initialize(): Promise<void>;
723
+ /**
724
+ * Restores persisted records from storage into Redis on startup
725
+ */
726
+ restorePersistedRecords(): Promise<void>;
727
+ /**
728
+ * Handle a message received from the internal message stream.
729
+ */
730
+ private handleStreamMessage;
731
+ /**
732
+ * Enable persistence for channels matching the given pattern.
733
+ * @param pattern string or regexp pattern to match channel names
734
+ * @param options persistence options
735
+ */
736
+ enableChannelPersistence(pattern: string | RegExp, options?: ChannelPersistenceOptions): void;
737
+ /**
738
+ * Enable persistence for records matching the given pattern.
739
+ * @param pattern object with writePattern (for runtime matching) and restorePattern (for database queries)
740
+ * @param options persistence options
741
+ */
742
+ enableRecordPersistence(pattern: RecordPersistencePattern, options?: RecordPersistenceOptions): void;
743
+ /**
744
+ * Check if a channel has persistence enabled and return its options.
745
+ * @param channel channel name to check
746
+ * @returns the persistence options if enabled, undefined otherwise
747
+ */
748
+ getChannelPersistenceOptions(channel: string): Required<ChannelPersistenceOptions> | undefined;
749
+ /**
750
+ * Check if a record has persistence enabled and return its options.
751
+ * @param recordId record ID to check
752
+ * @returns the persistence options if enabled, undefined otherwise
753
+ */
754
+ getRecordPersistenceOptions(recordId: string): Required<RecordPersistenceOptions> | undefined;
755
+ /**
756
+ * Handle an incoming message for potential persistence.
757
+ * @param channel channel the message was published to
758
+ * @param message the message content
759
+ * @param instanceId id of the server instance
760
+ */
761
+ handleChannelMessage(channel: string, message: string, instanceId: string, timestamp?: number): void;
762
+ /**
763
+ * Flush buffered messages for a specific channel to its adapter.
764
+ * @param channel channel to flush
765
+ */
766
+ private flushChannel;
767
+ /**
768
+ * Flush all buffered messages across all channels.
769
+ */
770
+ flushAll(): Promise<void>;
771
+ /**
772
+ * Get persisted messages for a channel.
773
+ * @param channel channel to get messages for
774
+ * @param since optional cursor (timestamp or message id) to retrieve messages after
775
+ * @param limit maximum number of messages to retrieve
776
+ */
777
+ getMessages(channel: string, since?: string | number, limit?: number): Promise<PersistedMessage[]>;
778
+ /**
779
+ * Handles a record update for potential persistence
780
+ * @param recordId ID of the record
781
+ * @param value record value (will be stringified)
782
+ * @param version record version
783
+ */
784
+ handleRecordUpdate(recordId: string, value: any, version: number): void;
785
+ /**
786
+ * Flush all buffered records to storage
787
+ */
788
+ flushRecords(): Promise<void>;
789
+ /**
790
+ * Retrieve persisted records matching a pattern
791
+ * @param pattern pattern to match record IDs
792
+ * @returns array of persisted records
793
+ */
794
+ getPersistedRecords(pattern: string): Promise<PersistedRecord[]>;
795
+ /**
796
+ * Shutdown the persistence manager, flushing pending messages and closing adapters.
797
+ */
798
+ shutdown(): Promise<void>;
799
+ }
800
+
656
801
  declare class MeshServer extends WebSocketServer {
657
802
  readonly instanceId: string;
658
803
  private redisManager;
@@ -664,6 +809,7 @@ declare class MeshServer extends WebSocketServer {
664
809
  private collectionManager;
665
810
  private broadcastManager;
666
811
  private persistenceManager;
812
+ private authenticateConnection?;
667
813
  roomManager: RoomManager;
668
814
  recordManager: RecordManager;
669
815
  connectionManager: ConnectionManager;
@@ -746,11 +892,11 @@ declare class MeshServer extends WebSocketServer {
746
892
  /**
747
893
  * Enables persistence for records matching the specified pattern.
748
894
  *
749
- * @param {ChannelPattern} pattern - The record ID pattern to enable persistence for.
895
+ * @param {RecordPersistencePattern} pattern - The record ID pattern to enable persistence for.
750
896
  * @param {RecordPersistenceOptions} [options] - Options for persistence.
751
897
  * @throws {Error} If persistence is not enabled for this server instance.
752
898
  */
753
- enableRecordPersistence(pattern: ChannelPattern$1, options?: RecordPersistenceOptions): void;
899
+ enableRecordPersistence(pattern: RecordPersistencePattern, options?: RecordPersistenceOptions): void;
754
900
  /**
755
901
  * Exposes a record or pattern for client subscriptions, optionally adding a guard function.
756
902
  *
@@ -1015,115 +1161,4 @@ declare class MessageStream extends EventEmitter$1 {
1015
1161
  }) => void): void;
1016
1162
  }
1017
1163
 
1018
- declare class PersistenceManager extends EventEmitter$1 {
1019
- private defaultAdapter;
1020
- private channelPatterns;
1021
- private recordPatterns;
1022
- private messageBuffer;
1023
- private recordBuffer;
1024
- private flushTimers;
1025
- private recordFlushTimer;
1026
- private isShuttingDown;
1027
- private initialized;
1028
- private recordManager;
1029
- private pendingRecordUpdates;
1030
- private messageStream;
1031
- constructor(options: {
1032
- defaultAdapterOptions?: any;
1033
- adapterType?: "sqlite" | "postgres";
1034
- });
1035
- /**
1036
- * Sets the record manager reference for record restoration
1037
- * @param recordManager The record manager instance
1038
- */
1039
- setRecordManager(recordManager: RecordManager): void;
1040
- /**
1041
- * Waits until the persistence manager is fully ready and initialized.
1042
- *
1043
- * @returns {Promise<void>} A promise that resolves when persistence is ready.
1044
- */
1045
- ready(): Promise<void>;
1046
- /**
1047
- * Processes any record updates that were buffered during initialization
1048
- */
1049
- private processPendingRecordUpdates;
1050
- initialize(): Promise<void>;
1051
- /**
1052
- * Restores persisted records from storage into Redis on startup
1053
- */
1054
- restorePersistedRecords(): Promise<void>;
1055
- /**
1056
- * Handle a message received from the internal message stream.
1057
- */
1058
- private handleStreamMessage;
1059
- /**
1060
- * Enable persistence for channels matching the given pattern.
1061
- * @param pattern string or regexp pattern to match channel names
1062
- * @param options persistence options
1063
- */
1064
- enableChannelPersistence(pattern: string | RegExp, options?: ChannelPersistenceOptions): void;
1065
- /**
1066
- * Enable persistence for records matching the given pattern.
1067
- * @param pattern string or regexp pattern to match record IDs
1068
- * @param options persistence options
1069
- */
1070
- enableRecordPersistence(pattern: string | RegExp, options?: RecordPersistenceOptions): void;
1071
- /**
1072
- * Check if a channel has persistence enabled and return its options.
1073
- * @param channel channel name to check
1074
- * @returns the persistence options if enabled, undefined otherwise
1075
- */
1076
- getChannelPersistenceOptions(channel: string): Required<ChannelPersistenceOptions> | undefined;
1077
- /**
1078
- * Check if a record has persistence enabled and return its options.
1079
- * @param recordId record ID to check
1080
- * @returns the persistence options if enabled, undefined otherwise
1081
- */
1082
- getRecordPersistenceOptions(recordId: string): Required<RecordPersistenceOptions> | undefined;
1083
- /**
1084
- * Handle an incoming message for potential persistence.
1085
- * @param channel channel the message was published to
1086
- * @param message the message content
1087
- * @param instanceId id of the server instance
1088
- */
1089
- handleChannelMessage(channel: string, message: string, instanceId: string, timestamp?: number): void;
1090
- /**
1091
- * Flush buffered messages for a specific channel to its adapter.
1092
- * @param channel channel to flush
1093
- */
1094
- private flushChannel;
1095
- /**
1096
- * Flush all buffered messages across all channels.
1097
- */
1098
- flushAll(): Promise<void>;
1099
- /**
1100
- * Get persisted messages for a channel.
1101
- * @param channel channel to get messages for
1102
- * @param since optional cursor (timestamp or message id) to retrieve messages after
1103
- * @param limit maximum number of messages to retrieve
1104
- */
1105
- getMessages(channel: string, since?: string | number, limit?: number): Promise<PersistedMessage[]>;
1106
- /**
1107
- * Handles a record update for potential persistence
1108
- * @param recordId ID of the record
1109
- * @param value record value (will be stringified)
1110
- * @param version record version
1111
- */
1112
- handleRecordUpdate(recordId: string, value: any, version: number): void;
1113
- /**
1114
- * Flush all buffered records to storage
1115
- */
1116
- flushRecords(): Promise<void>;
1117
- /**
1118
- * Retrieve persisted records matching a pattern
1119
- * @param pattern pattern to match record IDs
1120
- * @returns array of persisted records
1121
- */
1122
- getPersistedRecords(pattern: string): Promise<PersistedRecord[]>;
1123
- /**
1124
- * Shutdown the persistence manager, flushing pending messages and closing adapters.
1125
- */
1126
- shutdown(): Promise<void>;
1127
- }
1128
-
1129
- export { type ChannelPattern$1 as ChannelPattern, Connection, ConnectionManager, MeshContext, MeshServer, type MeshServerOptions, MessageStream, type PersistenceAdapter, type PersistenceAdapterOptions, PersistenceManager, type PostgreSQLAdapterOptions, PostgreSQLPersistenceAdapter, PresenceManager, RecordManager, RoomManager, SQLitePersistenceAdapter, type SocketMiddleware };
1164
+ export { type AuthenticateConnectionFn, type AuthenticationError, type ChannelPattern$1 as ChannelPattern, Connection, ConnectionManager, MeshContext, MeshServer, type MeshServerOptions, MessageStream, type PersistenceAdapter, type PersistenceAdapterOptions, PersistenceManager, type PostgreSQLAdapterOptions, PostgreSQLPersistenceAdapter, PresenceManager, RecordManager, type RecordPersistencePattern, RoomManager, SQLitePersistenceAdapter, type SocketMiddleware };
package/dist/index.d.ts CHANGED
@@ -112,6 +112,11 @@ interface PostgreSQLAdapterOptions extends PersistenceAdapterOptions {
112
112
  max?: number;
113
113
  }
114
114
 
115
+ interface AuthenticationError {
116
+ code?: number;
117
+ message?: string;
118
+ }
119
+ type AuthenticateConnectionFn = (req: IncomingMessage) => Promise<any> | any;
115
120
  type SocketMiddleware = (context: MeshContext<any>) => any | Promise<any>;
116
121
  interface MeshServerOptions extends ServerOptions {
117
122
  /**
@@ -172,6 +177,31 @@ interface MeshServerOptions extends ServerOptions {
172
177
  * @default "sqlite"
173
178
  */
174
179
  persistenceAdapter?: "sqlite" | "postgres";
180
+ /**
181
+ * Called during WebSocket upgrade to authenticate the connection.
182
+ * Receives the raw HTTP request with headers and cookies.
183
+ *
184
+ * Return any truthy value to accept the connection - the returned data
185
+ * will be automatically stored as the connection's initial metadata.
186
+ *
187
+ * Throw an error or return null/undefined to reject with 401 Unauthorized.
188
+ * Throw an object with { code, message } for custom HTTP status codes.
189
+ *
190
+ * @example
191
+ * ```ts
192
+ * authenticateConnection: async (req) => {
193
+ * const cookies = parseCookie(req.headers.cookie || "");
194
+ * const token = cookies["auth_token"];
195
+ *
196
+ * const user = await validateToken(token);
197
+ * if (!user) throw { code: 401, message: "Invalid token" };
198
+ *
199
+ * // returned data becomes connection metadata
200
+ * return { userId: user.id, email: user.email };
201
+ * }
202
+ * ```
203
+ */
204
+ authenticateConnection?: AuthenticateConnectionFn;
175
205
  }
176
206
  type ChannelPattern$1 = string | RegExp;
177
207
 
@@ -653,6 +683,121 @@ declare class RecordManager {
653
683
  }) => Promise<void> | void): () => void;
654
684
  }
655
685
 
686
+ type RecordPersistencePattern = {
687
+ writePattern: string | RegExp;
688
+ restorePattern: string;
689
+ };
690
+ declare class PersistenceManager extends EventEmitter$1 {
691
+ private defaultAdapter;
692
+ private channelPatterns;
693
+ private recordPatterns;
694
+ private messageBuffer;
695
+ private recordBuffer;
696
+ private flushTimers;
697
+ private recordFlushTimer;
698
+ private isShuttingDown;
699
+ private initialized;
700
+ private recordManager;
701
+ private pendingRecordUpdates;
702
+ private messageStream;
703
+ constructor(options: {
704
+ defaultAdapterOptions?: any;
705
+ adapterType?: "sqlite" | "postgres";
706
+ });
707
+ /**
708
+ * Sets the record manager reference for record restoration
709
+ * @param recordManager The record manager instance
710
+ */
711
+ setRecordManager(recordManager: RecordManager): void;
712
+ /**
713
+ * Waits until the persistence manager is fully ready and initialized.
714
+ *
715
+ * @returns {Promise<void>} A promise that resolves when persistence is ready.
716
+ */
717
+ ready(): Promise<void>;
718
+ /**
719
+ * Processes any record updates that were buffered during initialization
720
+ */
721
+ private processPendingRecordUpdates;
722
+ initialize(): Promise<void>;
723
+ /**
724
+ * Restores persisted records from storage into Redis on startup
725
+ */
726
+ restorePersistedRecords(): Promise<void>;
727
+ /**
728
+ * Handle a message received from the internal message stream.
729
+ */
730
+ private handleStreamMessage;
731
+ /**
732
+ * Enable persistence for channels matching the given pattern.
733
+ * @param pattern string or regexp pattern to match channel names
734
+ * @param options persistence options
735
+ */
736
+ enableChannelPersistence(pattern: string | RegExp, options?: ChannelPersistenceOptions): void;
737
+ /**
738
+ * Enable persistence for records matching the given pattern.
739
+ * @param pattern object with writePattern (for runtime matching) and restorePattern (for database queries)
740
+ * @param options persistence options
741
+ */
742
+ enableRecordPersistence(pattern: RecordPersistencePattern, options?: RecordPersistenceOptions): void;
743
+ /**
744
+ * Check if a channel has persistence enabled and return its options.
745
+ * @param channel channel name to check
746
+ * @returns the persistence options if enabled, undefined otherwise
747
+ */
748
+ getChannelPersistenceOptions(channel: string): Required<ChannelPersistenceOptions> | undefined;
749
+ /**
750
+ * Check if a record has persistence enabled and return its options.
751
+ * @param recordId record ID to check
752
+ * @returns the persistence options if enabled, undefined otherwise
753
+ */
754
+ getRecordPersistenceOptions(recordId: string): Required<RecordPersistenceOptions> | undefined;
755
+ /**
756
+ * Handle an incoming message for potential persistence.
757
+ * @param channel channel the message was published to
758
+ * @param message the message content
759
+ * @param instanceId id of the server instance
760
+ */
761
+ handleChannelMessage(channel: string, message: string, instanceId: string, timestamp?: number): void;
762
+ /**
763
+ * Flush buffered messages for a specific channel to its adapter.
764
+ * @param channel channel to flush
765
+ */
766
+ private flushChannel;
767
+ /**
768
+ * Flush all buffered messages across all channels.
769
+ */
770
+ flushAll(): Promise<void>;
771
+ /**
772
+ * Get persisted messages for a channel.
773
+ * @param channel channel to get messages for
774
+ * @param since optional cursor (timestamp or message id) to retrieve messages after
775
+ * @param limit maximum number of messages to retrieve
776
+ */
777
+ getMessages(channel: string, since?: string | number, limit?: number): Promise<PersistedMessage[]>;
778
+ /**
779
+ * Handles a record update for potential persistence
780
+ * @param recordId ID of the record
781
+ * @param value record value (will be stringified)
782
+ * @param version record version
783
+ */
784
+ handleRecordUpdate(recordId: string, value: any, version: number): void;
785
+ /**
786
+ * Flush all buffered records to storage
787
+ */
788
+ flushRecords(): Promise<void>;
789
+ /**
790
+ * Retrieve persisted records matching a pattern
791
+ * @param pattern pattern to match record IDs
792
+ * @returns array of persisted records
793
+ */
794
+ getPersistedRecords(pattern: string): Promise<PersistedRecord[]>;
795
+ /**
796
+ * Shutdown the persistence manager, flushing pending messages and closing adapters.
797
+ */
798
+ shutdown(): Promise<void>;
799
+ }
800
+
656
801
  declare class MeshServer extends WebSocketServer {
657
802
  readonly instanceId: string;
658
803
  private redisManager;
@@ -664,6 +809,7 @@ declare class MeshServer extends WebSocketServer {
664
809
  private collectionManager;
665
810
  private broadcastManager;
666
811
  private persistenceManager;
812
+ private authenticateConnection?;
667
813
  roomManager: RoomManager;
668
814
  recordManager: RecordManager;
669
815
  connectionManager: ConnectionManager;
@@ -746,11 +892,11 @@ declare class MeshServer extends WebSocketServer {
746
892
  /**
747
893
  * Enables persistence for records matching the specified pattern.
748
894
  *
749
- * @param {ChannelPattern} pattern - The record ID pattern to enable persistence for.
895
+ * @param {RecordPersistencePattern} pattern - The record ID pattern to enable persistence for.
750
896
  * @param {RecordPersistenceOptions} [options] - Options for persistence.
751
897
  * @throws {Error} If persistence is not enabled for this server instance.
752
898
  */
753
- enableRecordPersistence(pattern: ChannelPattern$1, options?: RecordPersistenceOptions): void;
899
+ enableRecordPersistence(pattern: RecordPersistencePattern, options?: RecordPersistenceOptions): void;
754
900
  /**
755
901
  * Exposes a record or pattern for client subscriptions, optionally adding a guard function.
756
902
  *
@@ -1015,115 +1161,4 @@ declare class MessageStream extends EventEmitter$1 {
1015
1161
  }) => void): void;
1016
1162
  }
1017
1163
 
1018
- declare class PersistenceManager extends EventEmitter$1 {
1019
- private defaultAdapter;
1020
- private channelPatterns;
1021
- private recordPatterns;
1022
- private messageBuffer;
1023
- private recordBuffer;
1024
- private flushTimers;
1025
- private recordFlushTimer;
1026
- private isShuttingDown;
1027
- private initialized;
1028
- private recordManager;
1029
- private pendingRecordUpdates;
1030
- private messageStream;
1031
- constructor(options: {
1032
- defaultAdapterOptions?: any;
1033
- adapterType?: "sqlite" | "postgres";
1034
- });
1035
- /**
1036
- * Sets the record manager reference for record restoration
1037
- * @param recordManager The record manager instance
1038
- */
1039
- setRecordManager(recordManager: RecordManager): void;
1040
- /**
1041
- * Waits until the persistence manager is fully ready and initialized.
1042
- *
1043
- * @returns {Promise<void>} A promise that resolves when persistence is ready.
1044
- */
1045
- ready(): Promise<void>;
1046
- /**
1047
- * Processes any record updates that were buffered during initialization
1048
- */
1049
- private processPendingRecordUpdates;
1050
- initialize(): Promise<void>;
1051
- /**
1052
- * Restores persisted records from storage into Redis on startup
1053
- */
1054
- restorePersistedRecords(): Promise<void>;
1055
- /**
1056
- * Handle a message received from the internal message stream.
1057
- */
1058
- private handleStreamMessage;
1059
- /**
1060
- * Enable persistence for channels matching the given pattern.
1061
- * @param pattern string or regexp pattern to match channel names
1062
- * @param options persistence options
1063
- */
1064
- enableChannelPersistence(pattern: string | RegExp, options?: ChannelPersistenceOptions): void;
1065
- /**
1066
- * Enable persistence for records matching the given pattern.
1067
- * @param pattern string or regexp pattern to match record IDs
1068
- * @param options persistence options
1069
- */
1070
- enableRecordPersistence(pattern: string | RegExp, options?: RecordPersistenceOptions): void;
1071
- /**
1072
- * Check if a channel has persistence enabled and return its options.
1073
- * @param channel channel name to check
1074
- * @returns the persistence options if enabled, undefined otherwise
1075
- */
1076
- getChannelPersistenceOptions(channel: string): Required<ChannelPersistenceOptions> | undefined;
1077
- /**
1078
- * Check if a record has persistence enabled and return its options.
1079
- * @param recordId record ID to check
1080
- * @returns the persistence options if enabled, undefined otherwise
1081
- */
1082
- getRecordPersistenceOptions(recordId: string): Required<RecordPersistenceOptions> | undefined;
1083
- /**
1084
- * Handle an incoming message for potential persistence.
1085
- * @param channel channel the message was published to
1086
- * @param message the message content
1087
- * @param instanceId id of the server instance
1088
- */
1089
- handleChannelMessage(channel: string, message: string, instanceId: string, timestamp?: number): void;
1090
- /**
1091
- * Flush buffered messages for a specific channel to its adapter.
1092
- * @param channel channel to flush
1093
- */
1094
- private flushChannel;
1095
- /**
1096
- * Flush all buffered messages across all channels.
1097
- */
1098
- flushAll(): Promise<void>;
1099
- /**
1100
- * Get persisted messages for a channel.
1101
- * @param channel channel to get messages for
1102
- * @param since optional cursor (timestamp or message id) to retrieve messages after
1103
- * @param limit maximum number of messages to retrieve
1104
- */
1105
- getMessages(channel: string, since?: string | number, limit?: number): Promise<PersistedMessage[]>;
1106
- /**
1107
- * Handles a record update for potential persistence
1108
- * @param recordId ID of the record
1109
- * @param value record value (will be stringified)
1110
- * @param version record version
1111
- */
1112
- handleRecordUpdate(recordId: string, value: any, version: number): void;
1113
- /**
1114
- * Flush all buffered records to storage
1115
- */
1116
- flushRecords(): Promise<void>;
1117
- /**
1118
- * Retrieve persisted records matching a pattern
1119
- * @param pattern pattern to match record IDs
1120
- * @returns array of persisted records
1121
- */
1122
- getPersistedRecords(pattern: string): Promise<PersistedRecord[]>;
1123
- /**
1124
- * Shutdown the persistence manager, flushing pending messages and closing adapters.
1125
- */
1126
- shutdown(): Promise<void>;
1127
- }
1128
-
1129
- export { type ChannelPattern$1 as ChannelPattern, Connection, ConnectionManager, MeshContext, MeshServer, type MeshServerOptions, MessageStream, type PersistenceAdapter, type PersistenceAdapterOptions, PersistenceManager, type PostgreSQLAdapterOptions, PostgreSQLPersistenceAdapter, PresenceManager, RecordManager, RoomManager, SQLitePersistenceAdapter, type SocketMiddleware };
1164
+ export { type AuthenticateConnectionFn, type AuthenticationError, type ChannelPattern$1 as ChannelPattern, Connection, ConnectionManager, MeshContext, MeshServer, type MeshServerOptions, MessageStream, type PersistenceAdapter, type PersistenceAdapterOptions, PersistenceManager, type PostgreSQLAdapterOptions, PostgreSQLPersistenceAdapter, PresenceManager, RecordManager, type RecordPersistencePattern, RoomManager, SQLitePersistenceAdapter, type SocketMiddleware };