@aegis-fluxion/core 0.7.2 → 0.8.0
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/README.md +51 -1
- package/dist/index.cjs +580 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -1
- package/dist/index.d.ts +31 -1
- package/dist/index.js +581 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -29,6 +29,11 @@ interface SecureServerRateLimitOptions {
|
|
|
29
29
|
disconnectCode?: number;
|
|
30
30
|
disconnectReason?: string;
|
|
31
31
|
}
|
|
32
|
+
interface SecureServerSessionResumptionOptions {
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
ticketTtlMs?: number;
|
|
35
|
+
maxCachedTickets?: number;
|
|
36
|
+
}
|
|
32
37
|
type SecureServerAdapterMessageScope = "broadcast" | "room";
|
|
33
38
|
interface SecureServerAdapterMessage {
|
|
34
39
|
version: typeof SECURE_SERVER_ADAPTER_MESSAGE_VERSION;
|
|
@@ -47,6 +52,7 @@ interface SecureServerAdapter {
|
|
|
47
52
|
interface SecureServerOptions extends ServerOptions {
|
|
48
53
|
heartbeat?: SecureServerHeartbeatOptions;
|
|
49
54
|
rateLimit?: SecureServerRateLimitOptions;
|
|
55
|
+
sessionResumption?: SecureServerSessionResumptionOptions;
|
|
50
56
|
adapter?: SecureServerAdapter;
|
|
51
57
|
}
|
|
52
58
|
interface SecureClientReconnectOptions {
|
|
@@ -57,11 +63,16 @@ interface SecureClientReconnectOptions {
|
|
|
57
63
|
jitterRatio?: number;
|
|
58
64
|
maxAttempts?: number | null;
|
|
59
65
|
}
|
|
66
|
+
interface SecureClientSessionResumptionOptions {
|
|
67
|
+
enabled?: boolean;
|
|
68
|
+
maxAcceptedTicketTtlMs?: number;
|
|
69
|
+
}
|
|
60
70
|
interface SecureClientOptions {
|
|
61
71
|
protocols?: string | string[];
|
|
62
72
|
wsOptions?: ClientOptions;
|
|
63
73
|
autoConnect?: boolean;
|
|
64
74
|
reconnect?: boolean | SecureClientReconnectOptions;
|
|
75
|
+
sessionResumption?: boolean | SecureClientSessionResumptionOptions;
|
|
65
76
|
}
|
|
66
77
|
interface SecureServerClient {
|
|
67
78
|
id: string;
|
|
@@ -122,6 +133,7 @@ declare class SecureServer {
|
|
|
122
133
|
private adapter;
|
|
123
134
|
private readonly heartbeatConfig;
|
|
124
135
|
private readonly rateLimitConfig;
|
|
136
|
+
private readonly sessionResumptionConfig;
|
|
125
137
|
private heartbeatIntervalHandle;
|
|
126
138
|
private readonly clientsById;
|
|
127
139
|
private readonly clientIdBySocket;
|
|
@@ -143,6 +155,7 @@ declare class SecureServer {
|
|
|
143
155
|
private readonly clientIpByClientId;
|
|
144
156
|
private readonly rateLimitBucketsByClientId;
|
|
145
157
|
private readonly rateLimitBucketsByIp;
|
|
158
|
+
private readonly sessionTicketStore;
|
|
146
159
|
constructor(options: SecureServerOptions);
|
|
147
160
|
get clientCount(): number;
|
|
148
161
|
get serverId(): string;
|
|
@@ -169,6 +182,11 @@ declare class SecureServer {
|
|
|
169
182
|
close(code?: number, reason?: string): void;
|
|
170
183
|
private resolveHeartbeatConfig;
|
|
171
184
|
private resolveRateLimitConfig;
|
|
185
|
+
private resolveSessionResumptionConfig;
|
|
186
|
+
private pruneExpiredSessionTickets;
|
|
187
|
+
private evictSessionTicketsIfNeeded;
|
|
188
|
+
private getSessionTicket;
|
|
189
|
+
private issueSessionTicket;
|
|
172
190
|
private createRateLimitBucket;
|
|
173
191
|
private getOrCreateRateLimitBucket;
|
|
174
192
|
private updateRateLimitBucket;
|
|
@@ -202,6 +220,8 @@ declare class SecureServer {
|
|
|
202
220
|
private notifyError;
|
|
203
221
|
private createServerHandshakeState;
|
|
204
222
|
private sendInternalHandshake;
|
|
223
|
+
private sendResumeAck;
|
|
224
|
+
private handleResumeHandshake;
|
|
205
225
|
private handleInternalHandshake;
|
|
206
226
|
private isClientHandshakeReady;
|
|
207
227
|
private sendOrQueuePayload;
|
|
@@ -221,6 +241,7 @@ declare class SecureClient {
|
|
|
221
241
|
private readonly options;
|
|
222
242
|
private socket;
|
|
223
243
|
private readonly reconnectConfig;
|
|
244
|
+
private readonly sessionResumptionConfig;
|
|
224
245
|
private reconnectAttemptCount;
|
|
225
246
|
private reconnectTimer;
|
|
226
247
|
private isManualDisconnectRequested;
|
|
@@ -232,6 +253,7 @@ declare class SecureClient {
|
|
|
232
253
|
private handshakeState;
|
|
233
254
|
private pendingPayloadQueue;
|
|
234
255
|
private readonly pendingRpcRequests;
|
|
256
|
+
private sessionTicket;
|
|
235
257
|
constructor(url: string, options?: SecureClientOptions);
|
|
236
258
|
get readyState(): number | null;
|
|
237
259
|
isConnected(): boolean;
|
|
@@ -252,6 +274,7 @@ declare class SecureClient {
|
|
|
252
274
|
emit(event: string, data: unknown, options: SecureAckOptions): Promise<unknown>;
|
|
253
275
|
emit(event: string, data: unknown, options: SecureAckOptions, callback: SecureAckCallback): boolean;
|
|
254
276
|
private resolveReconnectConfig;
|
|
277
|
+
private resolveSessionResumptionConfig;
|
|
255
278
|
private scheduleReconnect;
|
|
256
279
|
private computeReconnectDelay;
|
|
257
280
|
private clearReconnectTimer;
|
|
@@ -269,11 +292,18 @@ declare class SecureClient {
|
|
|
269
292
|
private handleRpcRequest;
|
|
270
293
|
private executeRpcRequestHandler;
|
|
271
294
|
private rejectPendingRpcRequests;
|
|
295
|
+
private handleSessionTicket;
|
|
272
296
|
private createClientHandshakeState;
|
|
273
297
|
private sendInternalHandshake;
|
|
298
|
+
private shouldAttemptSessionResumption;
|
|
299
|
+
private sendResumeHandshake;
|
|
300
|
+
private completeFullHandshake;
|
|
301
|
+
private fallbackToFullHandshake;
|
|
302
|
+
private handleServerHelloHandshake;
|
|
303
|
+
private handleResumeAckHandshake;
|
|
274
304
|
private handleInternalHandshake;
|
|
275
305
|
private isHandshakeReady;
|
|
276
306
|
private flushPendingPayloadQueue;
|
|
277
307
|
}
|
|
278
308
|
|
|
279
|
-
export { type SecureAckCallback, type SecureAckOptions, type SecureBinaryPayload, SecureClient, type SecureClientConnectHandler, type SecureClientDisconnectHandler, type SecureClientEventHandler, type SecureClientEventMap, type SecureClientLifecycleEvent, type SecureClientOptions, type SecureClientReadyHandler, type SecureClientReconnectOptions, type SecureEnvelope, type SecureErrorHandler, SecureServer, type SecureServerAdapter, type SecureServerAdapterMessage, type SecureServerAdapterMessageScope, type SecureServerClient, type SecureServerConnectionHandler, type SecureServerConnectionMiddlewareContext, type SecureServerDisconnectHandler, type SecureServerEventHandler, type SecureServerEventMap, type SecureServerHeartbeatOptions, type SecureServerLifecycleEvent, type SecureServerMessageMiddlewareContext, type SecureServerMiddleware, type SecureServerMiddlewareContext, type SecureServerMiddlewareNext, type SecureServerOptions, type SecureServerRateLimitAction, type SecureServerRateLimitOptions, type SecureServerReadyHandler, type SecureServerRoomOperator, normalizeSecureServerAdapterMessage };
|
|
309
|
+
export { type SecureAckCallback, type SecureAckOptions, type SecureBinaryPayload, SecureClient, type SecureClientConnectHandler, type SecureClientDisconnectHandler, type SecureClientEventHandler, type SecureClientEventMap, type SecureClientLifecycleEvent, type SecureClientOptions, type SecureClientReadyHandler, type SecureClientReconnectOptions, type SecureClientSessionResumptionOptions, type SecureEnvelope, type SecureErrorHandler, SecureServer, type SecureServerAdapter, type SecureServerAdapterMessage, type SecureServerAdapterMessageScope, type SecureServerClient, type SecureServerConnectionHandler, type SecureServerConnectionMiddlewareContext, type SecureServerDisconnectHandler, type SecureServerEventHandler, type SecureServerEventMap, type SecureServerHeartbeatOptions, type SecureServerLifecycleEvent, type SecureServerMessageMiddlewareContext, type SecureServerMiddleware, type SecureServerMiddlewareContext, type SecureServerMiddlewareNext, type SecureServerOptions, type SecureServerRateLimitAction, type SecureServerRateLimitOptions, type SecureServerReadyHandler, type SecureServerRoomOperator, type SecureServerSessionResumptionOptions, normalizeSecureServerAdapterMessage };
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,11 @@ interface SecureServerRateLimitOptions {
|
|
|
29
29
|
disconnectCode?: number;
|
|
30
30
|
disconnectReason?: string;
|
|
31
31
|
}
|
|
32
|
+
interface SecureServerSessionResumptionOptions {
|
|
33
|
+
enabled?: boolean;
|
|
34
|
+
ticketTtlMs?: number;
|
|
35
|
+
maxCachedTickets?: number;
|
|
36
|
+
}
|
|
32
37
|
type SecureServerAdapterMessageScope = "broadcast" | "room";
|
|
33
38
|
interface SecureServerAdapterMessage {
|
|
34
39
|
version: typeof SECURE_SERVER_ADAPTER_MESSAGE_VERSION;
|
|
@@ -47,6 +52,7 @@ interface SecureServerAdapter {
|
|
|
47
52
|
interface SecureServerOptions extends ServerOptions {
|
|
48
53
|
heartbeat?: SecureServerHeartbeatOptions;
|
|
49
54
|
rateLimit?: SecureServerRateLimitOptions;
|
|
55
|
+
sessionResumption?: SecureServerSessionResumptionOptions;
|
|
50
56
|
adapter?: SecureServerAdapter;
|
|
51
57
|
}
|
|
52
58
|
interface SecureClientReconnectOptions {
|
|
@@ -57,11 +63,16 @@ interface SecureClientReconnectOptions {
|
|
|
57
63
|
jitterRatio?: number;
|
|
58
64
|
maxAttempts?: number | null;
|
|
59
65
|
}
|
|
66
|
+
interface SecureClientSessionResumptionOptions {
|
|
67
|
+
enabled?: boolean;
|
|
68
|
+
maxAcceptedTicketTtlMs?: number;
|
|
69
|
+
}
|
|
60
70
|
interface SecureClientOptions {
|
|
61
71
|
protocols?: string | string[];
|
|
62
72
|
wsOptions?: ClientOptions;
|
|
63
73
|
autoConnect?: boolean;
|
|
64
74
|
reconnect?: boolean | SecureClientReconnectOptions;
|
|
75
|
+
sessionResumption?: boolean | SecureClientSessionResumptionOptions;
|
|
65
76
|
}
|
|
66
77
|
interface SecureServerClient {
|
|
67
78
|
id: string;
|
|
@@ -122,6 +133,7 @@ declare class SecureServer {
|
|
|
122
133
|
private adapter;
|
|
123
134
|
private readonly heartbeatConfig;
|
|
124
135
|
private readonly rateLimitConfig;
|
|
136
|
+
private readonly sessionResumptionConfig;
|
|
125
137
|
private heartbeatIntervalHandle;
|
|
126
138
|
private readonly clientsById;
|
|
127
139
|
private readonly clientIdBySocket;
|
|
@@ -143,6 +155,7 @@ declare class SecureServer {
|
|
|
143
155
|
private readonly clientIpByClientId;
|
|
144
156
|
private readonly rateLimitBucketsByClientId;
|
|
145
157
|
private readonly rateLimitBucketsByIp;
|
|
158
|
+
private readonly sessionTicketStore;
|
|
146
159
|
constructor(options: SecureServerOptions);
|
|
147
160
|
get clientCount(): number;
|
|
148
161
|
get serverId(): string;
|
|
@@ -169,6 +182,11 @@ declare class SecureServer {
|
|
|
169
182
|
close(code?: number, reason?: string): void;
|
|
170
183
|
private resolveHeartbeatConfig;
|
|
171
184
|
private resolveRateLimitConfig;
|
|
185
|
+
private resolveSessionResumptionConfig;
|
|
186
|
+
private pruneExpiredSessionTickets;
|
|
187
|
+
private evictSessionTicketsIfNeeded;
|
|
188
|
+
private getSessionTicket;
|
|
189
|
+
private issueSessionTicket;
|
|
172
190
|
private createRateLimitBucket;
|
|
173
191
|
private getOrCreateRateLimitBucket;
|
|
174
192
|
private updateRateLimitBucket;
|
|
@@ -202,6 +220,8 @@ declare class SecureServer {
|
|
|
202
220
|
private notifyError;
|
|
203
221
|
private createServerHandshakeState;
|
|
204
222
|
private sendInternalHandshake;
|
|
223
|
+
private sendResumeAck;
|
|
224
|
+
private handleResumeHandshake;
|
|
205
225
|
private handleInternalHandshake;
|
|
206
226
|
private isClientHandshakeReady;
|
|
207
227
|
private sendOrQueuePayload;
|
|
@@ -221,6 +241,7 @@ declare class SecureClient {
|
|
|
221
241
|
private readonly options;
|
|
222
242
|
private socket;
|
|
223
243
|
private readonly reconnectConfig;
|
|
244
|
+
private readonly sessionResumptionConfig;
|
|
224
245
|
private reconnectAttemptCount;
|
|
225
246
|
private reconnectTimer;
|
|
226
247
|
private isManualDisconnectRequested;
|
|
@@ -232,6 +253,7 @@ declare class SecureClient {
|
|
|
232
253
|
private handshakeState;
|
|
233
254
|
private pendingPayloadQueue;
|
|
234
255
|
private readonly pendingRpcRequests;
|
|
256
|
+
private sessionTicket;
|
|
235
257
|
constructor(url: string, options?: SecureClientOptions);
|
|
236
258
|
get readyState(): number | null;
|
|
237
259
|
isConnected(): boolean;
|
|
@@ -252,6 +274,7 @@ declare class SecureClient {
|
|
|
252
274
|
emit(event: string, data: unknown, options: SecureAckOptions): Promise<unknown>;
|
|
253
275
|
emit(event: string, data: unknown, options: SecureAckOptions, callback: SecureAckCallback): boolean;
|
|
254
276
|
private resolveReconnectConfig;
|
|
277
|
+
private resolveSessionResumptionConfig;
|
|
255
278
|
private scheduleReconnect;
|
|
256
279
|
private computeReconnectDelay;
|
|
257
280
|
private clearReconnectTimer;
|
|
@@ -269,11 +292,18 @@ declare class SecureClient {
|
|
|
269
292
|
private handleRpcRequest;
|
|
270
293
|
private executeRpcRequestHandler;
|
|
271
294
|
private rejectPendingRpcRequests;
|
|
295
|
+
private handleSessionTicket;
|
|
272
296
|
private createClientHandshakeState;
|
|
273
297
|
private sendInternalHandshake;
|
|
298
|
+
private shouldAttemptSessionResumption;
|
|
299
|
+
private sendResumeHandshake;
|
|
300
|
+
private completeFullHandshake;
|
|
301
|
+
private fallbackToFullHandshake;
|
|
302
|
+
private handleServerHelloHandshake;
|
|
303
|
+
private handleResumeAckHandshake;
|
|
274
304
|
private handleInternalHandshake;
|
|
275
305
|
private isHandshakeReady;
|
|
276
306
|
private flushPendingPayloadQueue;
|
|
277
307
|
}
|
|
278
308
|
|
|
279
|
-
export { type SecureAckCallback, type SecureAckOptions, type SecureBinaryPayload, SecureClient, type SecureClientConnectHandler, type SecureClientDisconnectHandler, type SecureClientEventHandler, type SecureClientEventMap, type SecureClientLifecycleEvent, type SecureClientOptions, type SecureClientReadyHandler, type SecureClientReconnectOptions, type SecureEnvelope, type SecureErrorHandler, SecureServer, type SecureServerAdapter, type SecureServerAdapterMessage, type SecureServerAdapterMessageScope, type SecureServerClient, type SecureServerConnectionHandler, type SecureServerConnectionMiddlewareContext, type SecureServerDisconnectHandler, type SecureServerEventHandler, type SecureServerEventMap, type SecureServerHeartbeatOptions, type SecureServerLifecycleEvent, type SecureServerMessageMiddlewareContext, type SecureServerMiddleware, type SecureServerMiddlewareContext, type SecureServerMiddlewareNext, type SecureServerOptions, type SecureServerRateLimitAction, type SecureServerRateLimitOptions, type SecureServerReadyHandler, type SecureServerRoomOperator, normalizeSecureServerAdapterMessage };
|
|
309
|
+
export { type SecureAckCallback, type SecureAckOptions, type SecureBinaryPayload, SecureClient, type SecureClientConnectHandler, type SecureClientDisconnectHandler, type SecureClientEventHandler, type SecureClientEventMap, type SecureClientLifecycleEvent, type SecureClientOptions, type SecureClientReadyHandler, type SecureClientReconnectOptions, type SecureClientSessionResumptionOptions, type SecureEnvelope, type SecureErrorHandler, SecureServer, type SecureServerAdapter, type SecureServerAdapterMessage, type SecureServerAdapterMessageScope, type SecureServerClient, type SecureServerConnectionHandler, type SecureServerConnectionMiddlewareContext, type SecureServerDisconnectHandler, type SecureServerEventHandler, type SecureServerEventMap, type SecureServerHeartbeatOptions, type SecureServerLifecycleEvent, type SecureServerMessageMiddlewareContext, type SecureServerMiddleware, type SecureServerMiddlewareContext, type SecureServerMiddlewareNext, type SecureServerOptions, type SecureServerRateLimitAction, type SecureServerRateLimitOptions, type SecureServerReadyHandler, type SecureServerRoomOperator, type SecureServerSessionResumptionOptions, normalizeSecureServerAdapterMessage };
|