@api.global/typedsocket 6.2.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.
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@api.global/typedsocket',
6
- version: '6.2.0',
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,9 +1,9 @@
1
1
  import * as plugins from './plugins.js';
2
- import { NativeByteManager } from './classes.nativebytemanager.js';
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 { INativeByteAuthorizationAdapter, INativeByteCreateVirtualStreamOptions, TNativeByteCapabilityMode } from './interfaces.nativebytes.js';
6
+ import type { ICreateVirtualStreamOptions, IVirtualStreamAuthorizationAdapter, TVirtualStreamDirection } from './interfaces.virtualstream.js';
7
7
  import type { ITypedSocketClientTagPolicy } from './classes.typedsockettagpolicymanager.js';
8
8
  export type TTypedSocketSide = 'server' | 'client';
9
9
  export type TConnectionStatus = 'new' | 'connecting' | 'connected' | 'disconnected' | 'reconnecting';
@@ -48,6 +48,9 @@ export interface ITypedSocketRequestContext {
48
48
  export declare class TypedSocketConnectionRestoreDeniedError extends Error {
49
49
  constructor(messageArg: string);
50
50
  }
51
+ export declare class TypedSocketHandshakeError extends Error {
52
+ constructor(messageArg: string, optionsArg?: ErrorOptions);
53
+ }
51
54
  /**
52
55
  * Options for creating a TypedSocket client
53
56
  */
@@ -57,15 +60,13 @@ export interface ITypedSocketClientOptions {
57
60
  initialBackoffMs?: number;
58
61
  maxBackoffMs?: number;
59
62
  abortSignal?: AbortSignal;
60
- nativeByteCapabilityMode?: TNativeByteCapabilityMode;
61
63
  /** Limits may lower, but never raise, TypedSocket package ceilings. */
62
64
  limits?: Partial<ITypedSocketClientLimits>;
63
65
  /** Restores connection-bound authentication before desired tags are reconciled. */
64
66
  restoreConnection?: (contextArg: ITypedSocketConnectionRestoreContext) => void | Promise<void>;
65
67
  }
66
68
  export interface ITypedSocketServerOptions {
67
- nativeByteCapabilityMode?: TNativeByteCapabilityMode;
68
- nativeByteAuthorizationAdapter?: INativeByteAuthorizationAdapter;
69
+ virtualStreamAuthorizationAdapter?: IVirtualStreamAuthorizationAdapter;
69
70
  clientTagPolicy?: ITypedSocketClientTagPolicy;
70
71
  }
71
72
  /**
@@ -88,7 +89,7 @@ export interface ISmartServeConnectionWrapper {
88
89
  }
89
90
  export declare class TypedSocket {
90
91
  /**
91
- * Creates a TypedSocket client using native WebSocket.
92
+ * Creates a TypedSocket client using the platform WebSocket implementation.
92
93
  * Works in both browser and Node.js environments.
93
94
  *
94
95
  * @param typedrouterArg - TypedRouter for handling server-initiated requests
@@ -118,37 +119,13 @@ export declare class TypedSocket {
118
119
  * Call attachSmartServe() after constructing the SmartServe transport.
119
120
  */
120
121
  static createServer(typedRouterOrRoutersArg: TTypedSocketServerRouterInput, optionsArg?: ITypedSocketServerOptions): TypedSocket;
121
- /**
122
- * Creates and attaches a TypedSocket server to an existing SmartServe
123
- * instance. Prefer createServer() plus attachSmartServe() when transport
124
- * construction needs the composed routers first.
125
- *
126
- * @param smartServeArg - SmartServe instance configured with the application router
127
- * @param typedRouterArg - Application TypedRouter used by SmartServe
128
- *
129
- * @example
130
- * ```typescript
131
- * const typedRouter = new TypedRouter();
132
- * const smartServe = new SmartServe({
133
- * port: 3000,
134
- * websocket: {
135
- * typedRouter
136
- * }
137
- * });
138
- * await smartServe.start();
139
- * const typedSocket = TypedSocket.fromSmartServe(smartServe, typedRouter);
140
- * // Authenticated server handlers assign protected connection metadata with:
141
- * // typedSocket.setServerTag(peer, 'authenticated', { userId });
142
- * ```
143
- */
144
- static fromSmartServe(smartServeArg: plugins.SmartServe, typedRouterArg: TTypedSocketServerRouterInput, optionsArg?: ITypedSocketServerOptions): TypedSocket;
145
122
  /**
146
123
  * Registers built-in TypedHandlers for tag management
147
124
  */
148
125
  private static registerProtocolHandlers;
149
126
  readonly side: TTypedSocketSide;
150
127
  readonly typedrouter: plugins.typedrequest.TypedRouter;
151
- readonly nativeBytes: NativeByteManager;
128
+ readonly virtualStreams: VirtualStreamManager;
152
129
  readonly webSocketTransportOwner: plugins.IWebSocketTransportOwner;
153
130
  statusSubject: plugins.smartrx.rxjs.Subject<TConnectionStatus>;
154
131
  /**
@@ -158,6 +135,7 @@ export declare class TypedSocket {
158
135
  readonly diagnosticsSubject: plugins.smartrx.rxjs.Subject<TTypedSocketDiagnosticEvent>;
159
136
  private connectionStatus;
160
137
  private reconnectExhaustedReported;
138
+ private terminalFailure;
161
139
  private websocket;
162
140
  private connectionGeneration;
163
141
  private clientConnectionState;
@@ -173,18 +151,19 @@ export declare class TypedSocket {
173
151
  private readonly clientTagReconciler;
174
152
  private smartServeRef;
175
153
  private serverTypedRouters;
154
+ private serverRoutingSurfaces;
176
155
  private detachProtocolRouters;
177
- private detachLegacyVirtualStreamPolicies;
178
156
  private serverStopping;
179
157
  private serverLifecycleGeneration;
180
158
  private unsubscribeSmartServeConnectionClose;
181
- private detachNativeStreamResolvers;
159
+ private detachVirtualStreamResolvers;
160
+ private detachIncomingRequestAuthorityGuards;
182
161
  private detachResponseAuthorityGuards;
183
162
  private pendingServerRequests;
184
163
  private pendingServerRequestIdsByPeer;
185
164
  private retainedServerInterests;
186
165
  private retainedServerInterestsByPeer;
187
- private readonly nativeByteAuthorizationAdapter;
166
+ private readonly virtualStreamAuthorizationAdapter;
188
167
  private readonly tagPolicyManager;
189
168
  private constructor();
190
169
  /**
@@ -192,10 +171,10 @@ export declare class TypedSocket {
192
171
  */
193
172
  attachSmartServe(smartServeArg: plugins.SmartServe): this;
194
173
  /**
195
- * Connects the client to the server using native WebSocket
174
+ * Connects the client to the server using the platform WebSocket implementation.
196
175
  */
197
176
  private connect;
198
- private negotiateClientCapabilities;
177
+ private checkClientVersion;
199
178
  private restoreClientConnection;
200
179
  /**
201
180
  * Converts an HTTP(S) URL to a WebSocket URL
@@ -208,6 +187,7 @@ export declare class TypedSocket {
208
187
  private handleMessage;
209
188
  private sendClientTextEnvelope;
210
189
  private isCurrentClientConnection;
190
+ private failClientHandshake;
211
191
  private abortClientConnectionState;
212
192
  /**
213
193
  * Handles WebSocket disconnection
@@ -252,6 +232,8 @@ export declare class TypedSocket {
252
232
  private retainServerInterestRegistration;
253
233
  private authorizeIncomingServerResponse;
254
234
  private isAttachedServerPeer;
235
+ private isOwnedServerPeer;
236
+ private findPhysicalServerPeer;
255
237
  private findServerPeerFromRequest;
256
238
  private sendServerRequest;
257
239
  /**
@@ -260,11 +242,7 @@ export declare class TypedSocket {
260
242
  * On servers, sends to the specified target connection.
261
243
  */
262
244
  createTypedRequest<T extends plugins.typedrequestInterfaces.ITypedRequest>(methodName: T['method'], targetConnection?: ISmartServeConnectionWrapper, optionsArg?: ITypedSocketRequestOptions): plugins.typedrequest.TypedRequest<T>;
263
- /**
264
- * Creates an exact authorized native-byte receive facade for one server peer.
265
- * TypedRequest carries its opaque descriptor when the facade enters a DTO.
266
- */
267
- createVirtualStream(optionsArg: INativeByteCreateVirtualStreamOptions): plugins.typedrequestInterfaces.INativeByteVirtualStreamReceiver<Uint8Array>;
245
+ createVirtualStream<TDirection extends TVirtualStreamDirection>(optionsArg: ICreateVirtualStreamOptions<TDirection>): plugins.typedrequestInterfaces.TVirtualStream<TDirection>;
268
246
  /**
269
247
  * Gets the current connection status
270
248
  */
@@ -290,6 +268,8 @@ export declare class TypedSocket {
290
268
  * @client-only
291
269
  */
292
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;
293
273
  /**
294
274
  * Resolves the exact SmartServe transport peer for one incoming TypedRequest.
295
275
  * Server handlers can pass their TypedTools argument without type assertions.