@api.global/typedsocket 6.3.0 → 7.0.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.typedsocket.d.ts +21 -52
- package/dist_ts/classes.typedsocket.js +264 -358
- package/dist_ts/classes.typedsockettagpolicymanager.d.ts +1 -0
- package/dist_ts/classes.typedsockettagpolicymanager.js +26 -2
- package/dist_ts/classes.virtualstreammanager.d.ts +268 -0
- package/dist_ts/classes.virtualstreammanager.js +2085 -0
- package/dist_ts/constants.virtualstream.d.ts +58 -0
- package/dist_ts/constants.virtualstream.js +58 -0
- package/dist_ts/helpers.virtualstreamcodec.d.ts +14 -0
- package/dist_ts/helpers.virtualstreamcodec.js +349 -0
- package/dist_ts/index.d.ts +5 -9
- package/dist_ts/index.js +3 -6
- package/dist_ts/interfaces.diagnostics.d.ts +6 -18
- package/dist_ts/interfaces.virtualstream.d.ts +131 -0
- package/dist_ts/interfaces.virtualstream.js +2 -0
- package/package.json +5 -5
- package/readme.hints.md +11 -59
- package/readme.md +295 -840
- package/dist_ts/classes.nativebyteerror.d.ts +0 -26
- package/dist_ts/classes.nativebyteerror.js +0 -51
- package/dist_ts/classes.nativebytemanager.d.ts +0 -505
- package/dist_ts/classes.nativebytemanager.js +0 -3691
- package/dist_ts/constants.nativebytes.d.ts +0 -59
- package/dist_ts/constants.nativebytes.js +0 -58
- package/dist_ts/constants.nativemessages.d.ts +0 -45
- package/dist_ts/constants.nativemessages.js +0 -44
- package/dist_ts/helpers.nativebytecodec.d.ts +0 -8
- package/dist_ts/helpers.nativebytecodec.js +0 -328
- package/dist_ts/helpers.nativemessagecodec.d.ts +0 -6
- package/dist_ts/helpers.nativemessagecodec.js +0 -267
- package/dist_ts/interfaces.nativebytes.d.ts +0 -187
- package/dist_ts/interfaces.nativebytes.js +0 -2
- package/dist_ts/interfaces.nativemessages.d.ts +0 -144
- package/dist_ts/interfaces.nativemessages.js +0 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@api.global/typedsocket',
|
|
6
|
-
version: '
|
|
6
|
+
version: '7.0.0',
|
|
7
7
|
description: 'A library for creating typed WebSocket connections, supporting bi-directional communication with type safety.'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx5QkFBeUI7SUFDL0IsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLCtHQUErRztDQUM3SCxDQUFBIn0=
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
|
-
import {
|
|
2
|
+
import { VirtualStreamManager } from './classes.virtualstreammanager.js';
|
|
3
3
|
export { toClientWebSocketCloseCode } from './helpers.websocket.js';
|
|
4
4
|
export { TYPEDSOCKET_MAX_RETAINED_CLIENT_TAG_MUTATIONS, TYPEDSOCKET_MAX_RETAINED_CLIENT_TAG_MUTATIONS_PER_NAME, } from './classes.clienttagreconciler.js';
|
|
5
5
|
import type { TTypedSocketDiagnosticEvent } from './interfaces.diagnostics.js';
|
|
6
|
-
import type {
|
|
7
|
-
import type { INativeMessageAuthorizationAdapter, INativeMessageCreateBinaryChannelOptions, INativeMessageReceiveGrant, TNativeMessageCapabilityMode } from './interfaces.nativemessages.js';
|
|
6
|
+
import type { ICreateVirtualStreamOptions, IVirtualStreamAuthorizationAdapter, TVirtualStreamDirection } from './interfaces.virtualstream.js';
|
|
8
7
|
import type { ITypedSocketClientTagPolicy } from './classes.typedsockettagpolicymanager.js';
|
|
9
8
|
export type TTypedSocketSide = 'server' | 'client';
|
|
10
9
|
export type TConnectionStatus = 'new' | 'connecting' | 'connected' | 'disconnected' | 'reconnecting';
|
|
@@ -49,6 +48,9 @@ export interface ITypedSocketRequestContext {
|
|
|
49
48
|
export declare class TypedSocketConnectionRestoreDeniedError extends Error {
|
|
50
49
|
constructor(messageArg: string);
|
|
51
50
|
}
|
|
51
|
+
export declare class TypedSocketHandshakeError extends Error {
|
|
52
|
+
constructor(messageArg: string, optionsArg?: ErrorOptions);
|
|
53
|
+
}
|
|
52
54
|
/**
|
|
53
55
|
* Options for creating a TypedSocket client
|
|
54
56
|
*/
|
|
@@ -58,18 +60,13 @@ export interface ITypedSocketClientOptions {
|
|
|
58
60
|
initialBackoffMs?: number;
|
|
59
61
|
maxBackoffMs?: number;
|
|
60
62
|
abortSignal?: AbortSignal;
|
|
61
|
-
nativeByteCapabilityMode?: TNativeByteCapabilityMode;
|
|
62
|
-
nativeMessageCapabilityMode?: TNativeMessageCapabilityMode;
|
|
63
63
|
/** Limits may lower, but never raise, TypedSocket package ceilings. */
|
|
64
64
|
limits?: Partial<ITypedSocketClientLimits>;
|
|
65
65
|
/** Restores connection-bound authentication before desired tags are reconciled. */
|
|
66
66
|
restoreConnection?: (contextArg: ITypedSocketConnectionRestoreContext) => void | Promise<void>;
|
|
67
67
|
}
|
|
68
68
|
export interface ITypedSocketServerOptions {
|
|
69
|
-
|
|
70
|
-
nativeByteAuthorizationAdapter?: INativeByteAuthorizationAdapter;
|
|
71
|
-
nativeMessageCapabilityMode?: TNativeMessageCapabilityMode;
|
|
72
|
-
nativeMessageAuthorizationAdapter?: INativeMessageAuthorizationAdapter;
|
|
69
|
+
virtualStreamAuthorizationAdapter?: IVirtualStreamAuthorizationAdapter;
|
|
73
70
|
clientTagPolicy?: ITypedSocketClientTagPolicy;
|
|
74
71
|
}
|
|
75
72
|
/**
|
|
@@ -92,7 +89,7 @@ export interface ISmartServeConnectionWrapper {
|
|
|
92
89
|
}
|
|
93
90
|
export declare class TypedSocket {
|
|
94
91
|
/**
|
|
95
|
-
* Creates a TypedSocket client using
|
|
92
|
+
* Creates a TypedSocket client using the platform WebSocket implementation.
|
|
96
93
|
* Works in both browser and Node.js environments.
|
|
97
94
|
*
|
|
98
95
|
* @param typedrouterArg - TypedRouter for handling server-initiated requests
|
|
@@ -122,37 +119,13 @@ export declare class TypedSocket {
|
|
|
122
119
|
* Call attachSmartServe() after constructing the SmartServe transport.
|
|
123
120
|
*/
|
|
124
121
|
static createServer(typedRouterOrRoutersArg: TTypedSocketServerRouterInput, optionsArg?: ITypedSocketServerOptions): TypedSocket;
|
|
125
|
-
/**
|
|
126
|
-
* Creates and attaches a TypedSocket server to an existing SmartServe
|
|
127
|
-
* instance. Prefer createServer() plus attachSmartServe() when transport
|
|
128
|
-
* construction needs the composed routers first.
|
|
129
|
-
*
|
|
130
|
-
* @param smartServeArg - SmartServe instance configured with the application router
|
|
131
|
-
* @param typedRouterArg - Application TypedRouter used by SmartServe
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* ```typescript
|
|
135
|
-
* const typedRouter = new TypedRouter();
|
|
136
|
-
* const smartServe = new SmartServe({
|
|
137
|
-
* port: 3000,
|
|
138
|
-
* websocket: {
|
|
139
|
-
* typedRouter
|
|
140
|
-
* }
|
|
141
|
-
* });
|
|
142
|
-
* await smartServe.start();
|
|
143
|
-
* const typedSocket = TypedSocket.fromSmartServe(smartServe, typedRouter);
|
|
144
|
-
* // Authenticated server handlers assign protected connection metadata with:
|
|
145
|
-
* // typedSocket.setServerTag(peer, 'authenticated', { userId });
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
static fromSmartServe(smartServeArg: plugins.SmartServe, typedRouterArg: TTypedSocketServerRouterInput, optionsArg?: ITypedSocketServerOptions): TypedSocket;
|
|
149
122
|
/**
|
|
150
123
|
* Registers built-in TypedHandlers for tag management
|
|
151
124
|
*/
|
|
152
125
|
private static registerProtocolHandlers;
|
|
153
126
|
readonly side: TTypedSocketSide;
|
|
154
127
|
readonly typedrouter: plugins.typedrequest.TypedRouter;
|
|
155
|
-
readonly
|
|
128
|
+
readonly virtualStreams: VirtualStreamManager;
|
|
156
129
|
readonly webSocketTransportOwner: plugins.IWebSocketTransportOwner;
|
|
157
130
|
statusSubject: plugins.smartrx.rxjs.Subject<TConnectionStatus>;
|
|
158
131
|
/**
|
|
@@ -162,6 +135,7 @@ export declare class TypedSocket {
|
|
|
162
135
|
readonly diagnosticsSubject: plugins.smartrx.rxjs.Subject<TTypedSocketDiagnosticEvent>;
|
|
163
136
|
private connectionStatus;
|
|
164
137
|
private reconnectExhaustedReported;
|
|
138
|
+
private terminalFailure;
|
|
165
139
|
private websocket;
|
|
166
140
|
private connectionGeneration;
|
|
167
141
|
private clientConnectionState;
|
|
@@ -177,19 +151,19 @@ export declare class TypedSocket {
|
|
|
177
151
|
private readonly clientTagReconciler;
|
|
178
152
|
private smartServeRef;
|
|
179
153
|
private serverTypedRouters;
|
|
154
|
+
private serverRoutingSurfaces;
|
|
180
155
|
private detachProtocolRouters;
|
|
181
|
-
private detachLegacyVirtualStreamPolicies;
|
|
182
156
|
private serverStopping;
|
|
183
157
|
private serverLifecycleGeneration;
|
|
184
158
|
private unsubscribeSmartServeConnectionClose;
|
|
185
|
-
private
|
|
159
|
+
private detachVirtualStreamResolvers;
|
|
160
|
+
private detachIncomingRequestAuthorityGuards;
|
|
186
161
|
private detachResponseAuthorityGuards;
|
|
187
162
|
private pendingServerRequests;
|
|
188
163
|
private pendingServerRequestIdsByPeer;
|
|
189
164
|
private retainedServerInterests;
|
|
190
165
|
private retainedServerInterestsByPeer;
|
|
191
|
-
private readonly
|
|
192
|
-
private readonly nativeMessageAuthorizationAdapter;
|
|
166
|
+
private readonly virtualStreamAuthorizationAdapter;
|
|
193
167
|
private readonly tagPolicyManager;
|
|
194
168
|
private constructor();
|
|
195
169
|
/**
|
|
@@ -197,11 +171,10 @@ export declare class TypedSocket {
|
|
|
197
171
|
*/
|
|
198
172
|
attachSmartServe(smartServeArg: plugins.SmartServe): this;
|
|
199
173
|
/**
|
|
200
|
-
* Connects the client to the server using
|
|
174
|
+
* Connects the client to the server using the platform WebSocket implementation.
|
|
201
175
|
*/
|
|
202
176
|
private connect;
|
|
203
|
-
private
|
|
204
|
-
private negotiateClientNativeMessages;
|
|
177
|
+
private checkClientVersion;
|
|
205
178
|
private restoreClientConnection;
|
|
206
179
|
/**
|
|
207
180
|
* Converts an HTTP(S) URL to a WebSocket URL
|
|
@@ -214,6 +187,7 @@ export declare class TypedSocket {
|
|
|
214
187
|
private handleMessage;
|
|
215
188
|
private sendClientTextEnvelope;
|
|
216
189
|
private isCurrentClientConnection;
|
|
190
|
+
private failClientHandshake;
|
|
217
191
|
private abortClientConnectionState;
|
|
218
192
|
/**
|
|
219
193
|
* Handles WebSocket disconnection
|
|
@@ -258,6 +232,8 @@ export declare class TypedSocket {
|
|
|
258
232
|
private retainServerInterestRegistration;
|
|
259
233
|
private authorizeIncomingServerResponse;
|
|
260
234
|
private isAttachedServerPeer;
|
|
235
|
+
private isOwnedServerPeer;
|
|
236
|
+
private findPhysicalServerPeer;
|
|
261
237
|
private findServerPeerFromRequest;
|
|
262
238
|
private sendServerRequest;
|
|
263
239
|
/**
|
|
@@ -266,16 +242,7 @@ export declare class TypedSocket {
|
|
|
266
242
|
* On servers, sends to the specified target connection.
|
|
267
243
|
*/
|
|
268
244
|
createTypedRequest<T extends plugins.typedrequestInterfaces.ITypedRequest>(methodName: T['method'], targetConnection?: ISmartServeConnectionWrapper, optionsArg?: ITypedSocketRequestOptions): plugins.typedrequest.TypedRequest<T>;
|
|
269
|
-
|
|
270
|
-
* Creates an exact authorized native-byte receive facade for one server peer.
|
|
271
|
-
* TypedRequest carries its opaque descriptor when the facade enters a DTO.
|
|
272
|
-
*/
|
|
273
|
-
createVirtualStream(optionsArg: INativeByteCreateVirtualStreamOptions): plugins.typedrequestInterfaces.INativeByteVirtualStreamReceiver<Uint8Array>;
|
|
274
|
-
/**
|
|
275
|
-
* Creates an authorized ephemeral binary-message receive channel for one
|
|
276
|
-
* exact server peer. Its ordinary descriptor must be sent explicitly.
|
|
277
|
-
*/
|
|
278
|
-
createBinaryMessageChannel(optionsArg: INativeMessageCreateBinaryChannelOptions): INativeMessageReceiveGrant;
|
|
245
|
+
createVirtualStream<TDirection extends TVirtualStreamDirection>(optionsArg: ICreateVirtualStreamOptions<TDirection>): plugins.typedrequestInterfaces.TVirtualStream<TDirection>;
|
|
279
246
|
/**
|
|
280
247
|
* Gets the current connection status
|
|
281
248
|
*/
|
|
@@ -301,6 +268,8 @@ export declare class TypedSocket {
|
|
|
301
268
|
* @client-only
|
|
302
269
|
*/
|
|
303
270
|
removeTag(name: string): Promise<void>;
|
|
271
|
+
/** Returns the transport-owned SmartServe routing surface for an application router. */
|
|
272
|
+
getServerRoutingSurface(applicationRouterArg?: plugins.typedrequest.TypedRouter): plugins.typedrequest.TypedRouter;
|
|
304
273
|
/**
|
|
305
274
|
* Resolves the exact SmartServe transport peer for one incoming TypedRequest.
|
|
306
275
|
* Server handlers can pass their TypedTools argument without type assertions.
|