@api.global/typedsocket 6.3.0 → 7.1.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 +24 -52
- package/dist_ts/classes.typedsocket.js +277 -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 +274 -0
- package/dist_ts/classes.virtualstreammanager.js +2115 -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 +306 -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.1.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,19 +60,16 @@ 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;
|
|
71
|
+
/** Runs synchronously after the exact server handshake response is settled. */
|
|
72
|
+
onServerConnectionReady?: (connectionArg: ISmartServeConnectionWrapper) => undefined;
|
|
74
73
|
}
|
|
75
74
|
/**
|
|
76
75
|
* Lifecycle controls for one TypedRequest sent over a TypedSocket.
|
|
@@ -92,7 +91,7 @@ export interface ISmartServeConnectionWrapper {
|
|
|
92
91
|
}
|
|
93
92
|
export declare class TypedSocket {
|
|
94
93
|
/**
|
|
95
|
-
* Creates a TypedSocket client using
|
|
94
|
+
* Creates a TypedSocket client using the platform WebSocket implementation.
|
|
96
95
|
* Works in both browser and Node.js environments.
|
|
97
96
|
*
|
|
98
97
|
* @param typedrouterArg - TypedRouter for handling server-initiated requests
|
|
@@ -122,37 +121,13 @@ export declare class TypedSocket {
|
|
|
122
121
|
* Call attachSmartServe() after constructing the SmartServe transport.
|
|
123
122
|
*/
|
|
124
123
|
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
124
|
/**
|
|
150
125
|
* Registers built-in TypedHandlers for tag management
|
|
151
126
|
*/
|
|
152
127
|
private static registerProtocolHandlers;
|
|
153
128
|
readonly side: TTypedSocketSide;
|
|
154
129
|
readonly typedrouter: plugins.typedrequest.TypedRouter;
|
|
155
|
-
readonly
|
|
130
|
+
readonly virtualStreams: VirtualStreamManager;
|
|
156
131
|
readonly webSocketTransportOwner: plugins.IWebSocketTransportOwner;
|
|
157
132
|
statusSubject: plugins.smartrx.rxjs.Subject<TConnectionStatus>;
|
|
158
133
|
/**
|
|
@@ -162,6 +137,7 @@ export declare class TypedSocket {
|
|
|
162
137
|
readonly diagnosticsSubject: plugins.smartrx.rxjs.Subject<TTypedSocketDiagnosticEvent>;
|
|
163
138
|
private connectionStatus;
|
|
164
139
|
private reconnectExhaustedReported;
|
|
140
|
+
private terminalFailure;
|
|
165
141
|
private websocket;
|
|
166
142
|
private connectionGeneration;
|
|
167
143
|
private clientConnectionState;
|
|
@@ -177,19 +153,20 @@ export declare class TypedSocket {
|
|
|
177
153
|
private readonly clientTagReconciler;
|
|
178
154
|
private smartServeRef;
|
|
179
155
|
private serverTypedRouters;
|
|
156
|
+
private serverRoutingSurfaces;
|
|
180
157
|
private detachProtocolRouters;
|
|
181
|
-
private detachLegacyVirtualStreamPolicies;
|
|
182
158
|
private serverStopping;
|
|
183
159
|
private serverLifecycleGeneration;
|
|
184
160
|
private unsubscribeSmartServeConnectionClose;
|
|
185
|
-
private
|
|
161
|
+
private detachVirtualStreamResolvers;
|
|
162
|
+
private detachIncomingRequestAuthorityGuards;
|
|
186
163
|
private detachResponseAuthorityGuards;
|
|
187
164
|
private pendingServerRequests;
|
|
188
165
|
private pendingServerRequestIdsByPeer;
|
|
189
166
|
private retainedServerInterests;
|
|
190
167
|
private retainedServerInterestsByPeer;
|
|
191
|
-
private readonly
|
|
192
|
-
private readonly
|
|
168
|
+
private readonly serverReadyCallbackPeers;
|
|
169
|
+
private readonly virtualStreamAuthorizationAdapter;
|
|
193
170
|
private readonly tagPolicyManager;
|
|
194
171
|
private constructor();
|
|
195
172
|
/**
|
|
@@ -197,11 +174,10 @@ export declare class TypedSocket {
|
|
|
197
174
|
*/
|
|
198
175
|
attachSmartServe(smartServeArg: plugins.SmartServe): this;
|
|
199
176
|
/**
|
|
200
|
-
* Connects the client to the server using
|
|
177
|
+
* Connects the client to the server using the platform WebSocket implementation.
|
|
201
178
|
*/
|
|
202
179
|
private connect;
|
|
203
|
-
private
|
|
204
|
-
private negotiateClientNativeMessages;
|
|
180
|
+
private checkClientVersion;
|
|
205
181
|
private restoreClientConnection;
|
|
206
182
|
/**
|
|
207
183
|
* Converts an HTTP(S) URL to a WebSocket URL
|
|
@@ -214,6 +190,7 @@ export declare class TypedSocket {
|
|
|
214
190
|
private handleMessage;
|
|
215
191
|
private sendClientTextEnvelope;
|
|
216
192
|
private isCurrentClientConnection;
|
|
193
|
+
private failClientHandshake;
|
|
217
194
|
private abortClientConnectionState;
|
|
218
195
|
/**
|
|
219
196
|
* Handles WebSocket disconnection
|
|
@@ -258,6 +235,8 @@ export declare class TypedSocket {
|
|
|
258
235
|
private retainServerInterestRegistration;
|
|
259
236
|
private authorizeIncomingServerResponse;
|
|
260
237
|
private isAttachedServerPeer;
|
|
238
|
+
private isOwnedServerPeer;
|
|
239
|
+
private findPhysicalServerPeer;
|
|
261
240
|
private findServerPeerFromRequest;
|
|
262
241
|
private sendServerRequest;
|
|
263
242
|
/**
|
|
@@ -266,16 +245,7 @@ export declare class TypedSocket {
|
|
|
266
245
|
* On servers, sends to the specified target connection.
|
|
267
246
|
*/
|
|
268
247
|
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;
|
|
248
|
+
createVirtualStream<TDirection extends TVirtualStreamDirection>(optionsArg: ICreateVirtualStreamOptions<TDirection>): plugins.typedrequestInterfaces.TVirtualStream<TDirection>;
|
|
279
249
|
/**
|
|
280
250
|
* Gets the current connection status
|
|
281
251
|
*/
|
|
@@ -301,6 +271,8 @@ export declare class TypedSocket {
|
|
|
301
271
|
* @client-only
|
|
302
272
|
*/
|
|
303
273
|
removeTag(name: string): Promise<void>;
|
|
274
|
+
/** Returns the transport-owned SmartServe routing surface for an application router. */
|
|
275
|
+
getServerRoutingSurface(applicationRouterArg?: plugins.typedrequest.TypedRouter): plugins.typedrequest.TypedRouter;
|
|
304
276
|
/**
|
|
305
277
|
* Resolves the exact SmartServe transport peer for one incoming TypedRequest.
|
|
306
278
|
* Server handlers can pass their TypedTools argument without type assertions.
|