@zyno-io/ts-server-foundation 26.729.1927 → 26.731.113

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.
Files changed (112) hide show
  1. package/dist/src/app/base.d.ts +2 -1
  2. package/dist/src/app/base.d.ts.map +1 -1
  3. package/dist/src/app/base.js +19 -4
  4. package/dist/src/app/base.js.map +1 -1
  5. package/dist/src/app/index.js +1 -1
  6. package/dist/src/di/container.js +1 -1
  7. package/dist/src/helpers/index.d.ts +1 -0
  8. package/dist/src/helpers/index.d.ts.map +1 -1
  9. package/dist/src/helpers/index.js +1 -0
  10. package/dist/src/helpers/index.js.map +1 -1
  11. package/dist/src/helpers/utils/timer.d.ts +3 -0
  12. package/dist/src/helpers/utils/timer.d.ts.map +1 -0
  13. package/dist/src/helpers/utils/timer.js +12 -0
  14. package/dist/src/helpers/utils/timer.js.map +1 -0
  15. package/dist/src/http/base.js +3 -3
  16. package/dist/src/http/base.js.map +1 -1
  17. package/dist/src/http/decorators.d.ts +12 -0
  18. package/dist/src/http/decorators.d.ts.map +1 -1
  19. package/dist/src/http/decorators.js +24 -1
  20. package/dist/src/http/decorators.js.map +1 -1
  21. package/dist/src/http/index.js +1 -1
  22. package/dist/src/http/response.js +1 -1
  23. package/dist/src/http/router.d.ts +16 -2
  24. package/dist/src/http/router.d.ts.map +1 -1
  25. package/dist/src/http/router.js +119 -28
  26. package/dist/src/http/router.js.map +1 -1
  27. package/dist/src/http/static-files.d.ts +4 -3
  28. package/dist/src/http/static-files.d.ts.map +1 -1
  29. package/dist/src/http/static-files.js +12 -4
  30. package/dist/src/http/static-files.js.map +1 -1
  31. package/dist/src/index.js +1 -1
  32. package/dist/src/services/index.js +1 -1
  33. package/dist/src/services/mesh-client/index.d.ts +3 -1
  34. package/dist/src/services/mesh-client/index.d.ts.map +1 -1
  35. package/dist/src/services/mesh-client/index.js +6 -2
  36. package/dist/src/services/mesh-client/index.js.map +1 -1
  37. package/dist/src/services/mesh-client/mesh-client-redis-registry.d.ts +53 -7
  38. package/dist/src/services/mesh-client/mesh-client-redis-registry.d.ts.map +1 -1
  39. package/dist/src/services/mesh-client/mesh-client-redis-registry.js +862 -61
  40. package/dist/src/services/mesh-client/mesh-client-redis-registry.js.map +1 -1
  41. package/dist/src/services/mesh-client/mesh-client-registry.d.ts +17 -6
  42. package/dist/src/services/mesh-client/mesh-client-registry.d.ts.map +1 -1
  43. package/dist/src/services/mesh-client/mesh-client-registry.js +43 -2
  44. package/dist/src/services/mesh-client/mesh-client-registry.js.map +1 -1
  45. package/dist/src/services/mesh-client/mesh-client-service.d.ts +115 -48
  46. package/dist/src/services/mesh-client/mesh-client-service.d.ts.map +1 -1
  47. package/dist/src/services/mesh-client/mesh-client-service.js +790 -101
  48. package/dist/src/services/mesh-client/mesh-client-service.js.map +1 -1
  49. package/dist/src/services/mesh-client/mesh-srpc-link-controller.d.ts +129 -17
  50. package/dist/src/services/mesh-client/mesh-srpc-link-controller.d.ts.map +1 -1
  51. package/dist/src/services/mesh-client/mesh-srpc-link-controller.js +1615 -126
  52. package/dist/src/services/mesh-client/mesh-srpc-link-controller.js.map +1 -1
  53. package/dist/src/services/mesh-client/mesh-srpc-remote-connection.d.ts +38 -6
  54. package/dist/src/services/mesh-client/mesh-srpc-remote-connection.d.ts.map +1 -1
  55. package/dist/src/services/mesh-client/mesh-srpc-remote-connection.js +192 -27
  56. package/dist/src/services/mesh-client/mesh-srpc-remote-connection.js.map +1 -1
  57. package/dist/src/services/mesh-client/mesh-srpc-server.d.ts +57 -8
  58. package/dist/src/services/mesh-client/mesh-srpc-server.d.ts.map +1 -1
  59. package/dist/src/services/mesh-client/mesh-srpc-server.js +479 -131
  60. package/dist/src/services/mesh-client/mesh-srpc-server.js.map +1 -1
  61. package/dist/src/services/mesh-client/types.d.ts +77 -6
  62. package/dist/src/services/mesh-client/types.d.ts.map +1 -1
  63. package/dist/src/services/mesh-client/types.js +1 -1
  64. package/dist/src/services/mesh-client/types.js.map +1 -1
  65. package/dist/src/services/mesh-link/auth.d.ts +36 -2
  66. package/dist/src/services/mesh-link/auth.d.ts.map +1 -1
  67. package/dist/src/services/mesh-link/auth.js +97 -21
  68. package/dist/src/services/mesh-link/auth.js.map +1 -1
  69. package/dist/src/services/mesh-link/index.d.ts +2 -2
  70. package/dist/src/services/mesh-link/index.d.ts.map +1 -1
  71. package/dist/src/services/mesh-link/index.js +5 -2
  72. package/dist/src/services/mesh-link/index.js.map +1 -1
  73. package/dist/src/services/mesh-link/peer.d.ts +26 -1
  74. package/dist/src/services/mesh-link/peer.d.ts.map +1 -1
  75. package/dist/src/services/mesh-link/peer.js +220 -26
  76. package/dist/src/services/mesh-link/peer.js.map +1 -1
  77. package/dist/src/services/mesh-link/protocol.d.ts +16 -3
  78. package/dist/src/services/mesh-link/protocol.d.ts.map +1 -1
  79. package/dist/src/services/mesh-link/protocol.js +8 -4
  80. package/dist/src/services/mesh-link/protocol.js.map +1 -1
  81. package/dist/src/services/mesh-link/runtime.d.ts +57 -4
  82. package/dist/src/services/mesh-link/runtime.d.ts.map +1 -1
  83. package/dist/src/services/mesh-link/runtime.js +557 -67
  84. package/dist/src/services/mesh-link/runtime.js.map +1 -1
  85. package/dist/src/services/mesh.d.ts +72 -28
  86. package/dist/src/services/mesh.d.ts.map +1 -1
  87. package/dist/src/services/mesh.js +587 -278
  88. package/dist/src/services/mesh.js.map +1 -1
  89. package/dist/src/srpc/SrpcByteStream.d.ts +21 -2
  90. package/dist/src/srpc/SrpcByteStream.d.ts.map +1 -1
  91. package/dist/src/srpc/SrpcByteStream.js +271 -61
  92. package/dist/src/srpc/SrpcByteStream.js.map +1 -1
  93. package/dist/src/srpc/SrpcClient.d.ts +57 -13
  94. package/dist/src/srpc/SrpcClient.d.ts.map +1 -1
  95. package/dist/src/srpc/SrpcClient.js +558 -120
  96. package/dist/src/srpc/SrpcClient.js.map +1 -1
  97. package/dist/src/srpc/SrpcServer.d.ts +59 -4
  98. package/dist/src/srpc/SrpcServer.d.ts.map +1 -1
  99. package/dist/src/srpc/SrpcServer.js +683 -80
  100. package/dist/src/srpc/SrpcServer.js.map +1 -1
  101. package/dist/src/srpc/index.js +1 -1
  102. package/dist/src/srpc/observer.js +1 -1
  103. package/dist/src/srpc/types.d.ts +37 -6
  104. package/dist/src/srpc/types.d.ts.map +1 -1
  105. package/dist/src/srpc/types.js +12 -1
  106. package/dist/src/srpc/types.js.map +1 -1
  107. package/docs/content/getting-started.md +22 -20
  108. package/docs/content/http.md +38 -1
  109. package/docs/content/mesh-client.md +175 -53
  110. package/docs/content/mesh-service.md +64 -229
  111. package/docs/content/srpc.md +33 -10
  112. package/package.json +7 -7
@@ -11,10 +11,27 @@ const SrpcByteStream_1 = require("./SrpcByteStream");
11
11
  const observer_1 = require("./observer");
12
12
  const types_1 = require("./types");
13
13
  const http_1 = require("../http");
14
- const __tsf_metadata_type = _a.createCompactMetadataRegistryV1("[1,[{\"kind\":2},{\"kind\":22,\"type\":{\"kind\":8}},{\"kind\":6},{\"kind\":8},{\"kind\":2,\"typeName\":\"TClientOutput['byteStreamOperation']\"},{\"kind\":3},{\"kind\":22,\"type\":{\"kind\":2}},{\"kind\":22,\"type\":{\"kind\":3}},{\"kind\":12,\"types\":[{\"kind\":3},{\"kind\":22,\"type\":{\"kind\":3}}]},{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"disconnect\"},{\"kind\":10,\"literal\":\"conflict\"},{\"kind\":10,\"literal\":\"supersede\"},{\"kind\":10,\"literal\":\"timeout\"},{\"kind\":10,\"literal\":\"badArg\"}],\"typeName\":\"SrpcDisconnectCause\"},{\"kind\":2,\"typeName\":\"(metadata: Record\\u003cstring, unknown\\u003e, req: IncomingMessage) =\\u003e Promise\\u003cboolean | Partial\\u003cTMeta\\u003e\\u003e | boolean | Partial\\u003cTMeta\\u003e\"},{\"kind\":2,\"typeName\":\"(clientId: string) =\\u003e Promise\\u003cfalse | string\\u003e | false | string\"},{\"kind\":2,\"typeName\":\"(stream: SrpcStream\\u003cTMeta\\u003e) =\\u003e void | Promise\\u003cvoid\\u003e\"},{\"kind\":2,\"typeName\":\"P\"},{\"kind\":2,\"typeName\":\"(stream: SrpcStream\\u003cTMeta\\u003e, cause: SrpcDisconnectCause) =\\u003e void\"},{\"kind\":2,\"typeName\":\"(data: any, senderInstanceId: number) =\\u003e void | Promise\\u003cvoid\\u003e\"},{\"kind\":1},{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"skipSelf\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true}]},{\"kind\":0},{\"kind\":18,\"typeName\":\"ResponseData\\u003cTClientOutput, P\\u003e\",\"types\":[{\"kind\":20,\"name\":\"\u00FE@toStringTag@64\",\"type\":{\"kind\":6},\"optional\":false}]},{\"kind\":7},{\"kind\":14,\"type\":{\"kind\":7}},{\"kind\":2,\"typeName\":\"TServerOutput['byteStreamOperation']\"}]]", []);
14
+ const __tsf_metadata_type = _a.createCompactMetadataRegistryV1("[1,[{\"kind\":2},{\"kind\":22,\"type\":{\"kind\":8}},{\"kind\":12,\"types\":[{\"kind\":3},{\"kind\":22,\"type\":{\"kind\":3}}]},{\"kind\":7},{\"kind\":8},{\"kind\":6},{\"kind\":2,\"typeName\":\"TClientOutput['byteStreamOperation']\"},{\"kind\":3},{\"kind\":22,\"type\":{\"kind\":2}},{\"kind\":22,\"type\":{\"kind\":3}},{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"disconnect\"},{\"kind\":10,\"literal\":\"conflict\"},{\"kind\":10,\"literal\":\"supersede\"},{\"kind\":10,\"literal\":\"timeout\"},{\"kind\":10,\"literal\":\"badArg\"}],\"typeName\":\"SrpcDisconnectCause\"},{\"kind\":2,\"typeName\":\"(metadata: Record\\u003cstring, unknown\\u003e, req: IncomingMessage) =\\u003e Promise\\u003cboolean | Partial\\u003cTMeta\\u003e\\u003e | boolean | Partial\\u003cTMeta\\u003e\"},{\"kind\":2,\"typeName\":\"(clientId: string) =\\u003e Promise\\u003cfalse | string\\u003e | false | string\"},{\"kind\":2,\"typeName\":\"(principal: string, nonce: string, expiresAt: number) =\\u003e boolean | Promise\\u003cboolean\\u003e\"},{\"kind\":2,\"typeName\":\"(stream: SrpcStream\\u003cTMeta\\u003e) =\\u003e void | Promise\\u003cvoid\\u003e\"},{\"kind\":2,\"typeName\":\"P\"},{\"kind\":2,\"typeName\":\"(stream: SrpcStream\\u003cTMeta\\u003e, cause: SrpcDisconnectCause) =\\u003e void\"},{\"kind\":2,\"typeName\":\"(data: any, senderInstanceId: number) =\\u003e void | Promise\\u003cvoid\\u003e\"},{\"kind\":1},{\"kind\":18,\"types\":[{\"kind\":20,\"name\":\"skipSelf\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true}]},{\"kind\":0},{\"kind\":18,\"typeName\":\"ResponseData\\u003cTClientOutput, P\\u003e\",\"types\":[{\"kind\":20,\"name\":\"\u00FE@toStringTag@64\",\"type\":{\"kind\":6},\"optional\":false}]},{\"kind\":14,\"type\":{\"kind\":7}},{\"kind\":2,\"typeName\":\"TServerOutput['byteStreamOperation']\"}]]", []);
15
15
  const StreamInfoSymbol = Symbol('srpc-info');
16
16
  const DefaultLateReplyTombstoneTtlMs = 60000;
17
17
  const MaxLateReplyTombstonesPerStream = 256;
18
+ const DefaultMaxPendingClientRequests = 128;
19
+ const DefaultMaxInFlightClientRequests = 64;
20
+ const DefaultMaxPendingClientRequestBytes = 8 * 1024 * 1024;
21
+ const DefaultMaxInFlightClientRequestBytes = 8 * 1024 * 1024;
22
+ const DefaultMaxBufferedBytes = 8 * 1024 * 1024;
23
+ const DefaultMaxMessageBytes = 8 * 1024 * 1024;
24
+ const DefaultMaxPendingServerRequests = 128;
25
+ const DefaultMaxPendingServerRequestBytes = 8 * 1024 * 1024;
26
+ const DefaultMaxPendingHandshakes = 128;
27
+ const DefaultMaxActiveStreams = 10000;
28
+ const DefaultMaxClientIdBytes = 1024;
29
+ const DefaultMaxClientMetadataBytes = 64 * 1024;
30
+ const DefaultMaxAuthReplayPrincipals = 256;
31
+ const MaxBackpressuredByteStreamsPerStream = 1024;
32
+ const MaxBackpressuredByteStreamBytesPerStream = DefaultMaxBufferedBytes;
33
+ const MaxByteStreamId = 0x7fffffff;
34
+ const MaxAuthReplayNoncesPerPrincipal = 256;
18
35
  const noopLogger = {
19
36
  info() { },
20
37
  warn() { },
@@ -25,16 +42,27 @@ let _SrpcServerMetadata_1;
25
42
  class SrpcServer {
26
43
  options;
27
44
  logger;
28
- wsServer = new ws_1.default.Server({ noServer: true });
45
+ wsServer;
29
46
  streamConnectionHandlers = new Set();
30
47
  streamDisconnectionHandlers = new Set();
31
48
  streamMessageHandlers = new Map();
32
49
  broadcastHandlers = new Map();
33
50
  blockedClientRequests = new WeakSet();
34
51
  pendingClientRequests = new WeakMap();
52
+ pendingClientRequestBytes = new WeakMap();
53
+ inFlightClientRequests = new WeakMap();
54
+ inFlightClientRequestBytes = new WeakMap();
55
+ pendingServerRequestBytes = new WeakMap();
35
56
  lateReplyTombstonesByStream = new WeakMap();
57
+ backpressuredByteStreams = new WeakMap();
58
+ backpressuredByteStreamBytes = new WeakMap();
59
+ publishedStreams = new WeakSet();
60
+ authReplayNoncesByPrincipal = new Map();
61
+ authNonceConsumer;
62
+ initialPongWaiters = new WeakMap();
36
63
  cleanupUpgradeHandler;
37
64
  inactivityCheckInterval;
65
+ pendingHandshakeCount = 0;
38
66
  clientAuthorizer;
39
67
  clientKeyFetcher;
40
68
  streamsById = new Map();
@@ -42,7 +70,9 @@ class SrpcServer {
42
70
  pendingStreamsByClientId = new Map();
43
71
  constructor(options) {
44
72
  this.options = options;
73
+ validateServerResourceOptions(options);
45
74
  this.logger = createLogger(options.logger, options.logLevel);
75
+ this.wsServer = new ws_1.default.Server({ noServer: true, maxPayload: this.maxMessageBytes });
46
76
  this.wsServer.on('connection', (ws, request) => this.attachConnection(ws, request));
47
77
  if (options.httpServer) {
48
78
  const handler = (0, http_1.installWebSocketUpgradeHandler)({
@@ -71,11 +101,26 @@ class SrpcServer {
71
101
  const query = Object.fromEntries(url.searchParams.entries());
72
102
  const { id: clientStreamId, cid: clientId, appv: appVersion } = query;
73
103
  const address = this.getRemoteAddress(info.req);
74
- if (!clientStreamId || !clientId || !appVersion) {
104
+ const protocolVersion = Number(query._v);
105
+ if (!clientStreamId || !clientId || !appVersion || protocolVersion !== 2) {
75
106
  cb(false, 400, 'Missing required query parameters');
76
107
  return;
77
108
  }
78
- this.validateClientAuth(query, info.req).then(result => {
109
+ if (Buffer.byteLength(clientId) > this.maxClientIdBytes) {
110
+ cb(false, 400, 'Client ID exceeds the configured limit');
111
+ return;
112
+ }
113
+ if (this.pendingHandshakeCount >= this.maxPendingHandshakes) {
114
+ cb(false, 503, 'Too many pending client handshakes');
115
+ return;
116
+ }
117
+ if (this.streamsById.size >= this.maxActiveStreams) {
118
+ cb(false, 503, 'Too many active client streams');
119
+ return;
120
+ }
121
+ this.pendingHandshakeCount++;
122
+ this.validateClientAuth(query, info.req)
123
+ .then(result => {
79
124
  if (!result) {
80
125
  cb(false, 403, 'Failed authentication');
81
126
  return;
@@ -84,20 +129,39 @@ class SrpcServer {
84
129
  .filter(([key]) => key.startsWith('m--'))
85
130
  .map(([key, value]) => [key.slice(3), value]));
86
131
  const authMeta = result === true ? {} : result;
132
+ const mergedMeta = { ...queryMeta, ...authMeta };
133
+ let metadataBytes;
134
+ try {
135
+ metadataBytes = encodedJsonBytes(mergedMeta);
136
+ }
137
+ catch {
138
+ cb(false, 400, 'Client metadata must be JSON-serializable');
139
+ return;
140
+ }
141
+ if (metadataBytes > this.maxClientMetadataBytes) {
142
+ cb(false, 400, 'Client metadata exceeds the configured limit');
143
+ return;
144
+ }
87
145
  info.req[StreamInfoSymbol] = {
88
146
  clientStreamId,
89
147
  clientId,
90
148
  appVersion,
91
149
  configureTs: Number(query.ts ?? 0),
92
- protocolVersion: Number(query._v ?? 1),
150
+ protocolVersion: 2,
151
+ features: new Set(normalizeFeatures((query._f ?? '').split(',').filter(feature => feature.length > 0))
152
+ .split(',')
153
+ .filter(Boolean)),
93
154
  supersede: query._supersede === '1',
94
155
  address,
95
- meta: { ...queryMeta, ...authMeta }
156
+ meta: mergedMeta
96
157
  };
97
158
  cb(true);
98
159
  }, error => {
99
160
  this.logger.warn('Error validating SRPC client auth', error);
100
161
  cb(false, 403, 'Failed authentication');
162
+ })
163
+ .finally(() => {
164
+ this.pendingHandshakeCount = Math.max(0, this.pendingHandshakeCount - 1);
101
165
  });
102
166
  };
103
167
  attachConnection(ws, request) {
@@ -106,6 +170,10 @@ class SrpcServer {
106
170
  ws.close(4000, 'Missing stream info');
107
171
  return;
108
172
  }
173
+ if (this.streamsById.size >= this.maxActiveStreams) {
174
+ ws.close(1013, 'Too many active client streams');
175
+ return;
176
+ }
109
177
  const stream = this.createStream(ws, info);
110
178
  ws.on('error', error => this.handleStreamError(stream, error));
111
179
  ws.on('close', code => this.handleStreamDisconnected(stream, code));
@@ -113,6 +181,7 @@ class SrpcServer {
113
181
  }
114
182
  createStream(ws, info) {
115
183
  const streamId = (0, helpers_1.uuid7)();
184
+ const thisServer = this;
116
185
  const stream = {
117
186
  $ws: ws,
118
187
  $queue: new Map(),
@@ -123,25 +192,24 @@ class SrpcServer {
123
192
  appVersion: info.appVersion,
124
193
  configureTs: info.configureTs,
125
194
  protocolVersion: info.protocolVersion,
195
+ features: info.features,
126
196
  supersede: info.supersede,
127
197
  meta: info.meta,
128
198
  connectedAt: Date.now(),
129
199
  isActivated: false,
130
200
  lastPingAt: Date.now(),
131
201
  get connected() {
132
- return ws.readyState === ws_1.default.OPEN;
133
- },
134
- close: async (reason) => {
135
- if (stream.lastPingAt < 0)
136
- return;
137
- this.cleanupStream(stream, 'disconnect');
138
- if (reason && ws.readyState === ws_1.default.OPEN)
139
- ws.close(1000, reason.slice(0, 123));
202
+ return stream.lastPingAt >= 0 && thisServer.isCurrentStream(stream) && ws.readyState === ws_1.default.OPEN;
140
203
  },
204
+ close: async (reason) => this.closeStreamGracefully(stream, reason),
141
205
  byteStream: {
142
206
  parentStreamId: streamId,
207
+ remoteSenderIdParity: 1,
143
208
  write: (substreamId, chunk) => this.writeToStreamAsync(stream, {
144
- byteStreamOperation: { streamId: substreamId, write: { chunk: chunk } }
209
+ byteStreamOperation: {
210
+ streamId: substreamId,
211
+ write: { chunk: new Uint8Array(chunk) }
212
+ }
145
213
  }),
146
214
  finish: substreamId => this.writeToStream(stream, {
147
215
  byteStreamOperation: { streamId: substreamId, finish: {} }
@@ -149,12 +217,20 @@ class SrpcServer {
149
217
  destroy: (substreamId, error) => this.writeToStream(stream, {
150
218
  byteStreamOperation: {
151
219
  streamId: substreamId,
152
- destroy: { error: error ? String(error) : undefined }
220
+ destroy: { error: (0, SrpcByteStream_1.byteStreamDestroyReason)(error) }
153
221
  }
154
222
  }),
223
+ receiverBufferChanged: (substreamId, bufferedBytes) => {
224
+ this.updateByteStreamBufferedBytes(stream, substreamId, bufferedBytes);
225
+ },
155
226
  attachDisconnectHandler: handler => ws.on('close', handler),
156
227
  detachDisconnectHandler: handler => ws.off('close', handler),
157
228
  getBufferedAmount: () => ws.bufferedAmount
229
+ },
230
+ resolveByteStream: () => {
231
+ if (!this.isStreamDispatchAvailable(stream))
232
+ throw new Error('SRPC stream generation is revoked');
233
+ return stream.byteStream;
158
234
  }
159
235
  };
160
236
  SrpcByteStream_1.SrpcByteStream.init(stream, { startId: 2, step: 2 });
@@ -163,8 +239,7 @@ class SrpcServer {
163
239
  handleStreamEstablished(stream) {
164
240
  const conflictingStream = this.getCurrentStreamByClientId(stream.clientId);
165
241
  if (conflictingStream) {
166
- if (stream.protocolVersion >= 2 && !stream.supersede) {
167
- stream.lastPingAt = -1;
242
+ if (!stream.supersede) {
168
243
  this.closeStreamWithError(stream, 'conflict', 'Client ID already connected');
169
244
  return;
170
245
  }
@@ -177,14 +252,30 @@ class SrpcServer {
177
252
  .then(async (rejected) => {
178
253
  if (rejected || stream.lastPingAt < 0 || !this.isCurrentStream(stream))
179
254
  return;
255
+ // The protocol listener is installed before user callbacks. A
256
+ // throwing callback therefore cannot leave a live socket without
257
+ // a message consumer.
180
258
  stream.$ws.on('message', data => this.handleWsMessage(stream, data));
181
- this.writeToStream(stream, { pingPong: {} });
259
+ if (!this.writeToStream(stream, { pingPong: {} })) {
260
+ this.cleanupStream(stream, 'disconnect');
261
+ return;
262
+ }
263
+ await this.waitForInitialPong(stream);
264
+ if (stream.lastPingAt < 0 || !this.isCurrentStream(stream))
265
+ return;
266
+ await this.onStreamWillActivate(stream);
267
+ if (stream.lastPingAt < 0 || !this.isCurrentStream(stream))
268
+ return;
182
269
  await this.onStreamConnected(stream);
183
- if (stream.lastPingAt < 0)
270
+ if (stream.lastPingAt < 0 || !this.isCurrentStream(stream))
184
271
  return;
185
272
  this.activateStream(stream);
186
273
  if (!stream.isActivated)
187
274
  return;
275
+ if (!this.writeToStream(stream, { pingPong: {} })) {
276
+ this.cleanupStream(stream, 'disconnect');
277
+ return;
278
+ }
188
279
  await this.onStreamActivated(stream);
189
280
  if (stream.lastPingAt >= 0 && stream.isActivated)
190
281
  this.openClientRequests(stream);
@@ -197,39 +288,84 @@ class SrpcServer {
197
288
  postEstablishCheck(_stream) {
198
289
  return Promise.resolve(false);
199
290
  }
291
+ /**
292
+ * Hook for private/cluster CAS work after liveness is proven but before
293
+ * user connection handlers and public local publication.
294
+ */
295
+ onStreamWillActivate(_stream) { }
296
+ /**
297
+ * Allows a transport extension to recognize a locally-owned sender whose
298
+ * state is maintained outside the core SrpcByteStream sender map.
299
+ * Core remains strict by default.
300
+ */
301
+ hasExternalByteStreamSender(_stream, _streamId) {
302
+ return false;
303
+ }
200
304
  getCurrentStreamByClientId(clientId) {
201
305
  return this.pendingStreamsByClientId.get(clientId) ?? this.streamsByClientId.get(clientId);
202
306
  }
203
307
  isCurrentStream(stream) {
308
+ // Lightweight embedders and focused unit tests may invoke the protocol
309
+ // methods without the registry layer; normal servers always have both.
310
+ if (!this.pendingStreamsByClientId || !this.streamsByClientId)
311
+ return true;
204
312
  return this.getCurrentStreamByClientId(stream.clientId) === stream;
205
313
  }
314
+ waitForInitialPong(stream) {
315
+ return new Promise(resolve => {
316
+ const timer = setTimeout(() => {
317
+ this.initialPongWaiters.delete(stream);
318
+ this.cleanupStream(stream, 'timeout');
319
+ resolve();
320
+ }, 10000);
321
+ timer.unref?.();
322
+ this.initialPongWaiters.set(stream, { resolve, timer });
323
+ });
324
+ }
206
325
  activateStream(stream) {
207
326
  if (stream.lastPingAt < 0 || !this.isCurrentStream(stream))
208
327
  return;
209
328
  this.pendingStreamsByClientId.delete(stream.clientId);
210
329
  stream.isActivated = true;
211
330
  this.streamsByClientId.set(stream.clientId, stream);
331
+ this.publishedStreams.add(stream);
212
332
  (0, observer_1.notifySrpcObservers)({ type: 'connection', stream, at: Date.now() });
213
333
  }
214
334
  handleWsMessage(stream, data) {
335
+ if (!this.isStreamDispatchAvailable(stream))
336
+ return;
215
337
  try {
216
- const decoded = this.options.clientMessage.decode(toBuffer(data));
217
- this.handleStreamDataReceived(stream, decoded);
338
+ const encoded = toBuffer(data);
339
+ const decoded = this.options.clientMessage.decode(encoded);
340
+ this.handleStreamDataReceived(stream, decoded, encoded.length);
218
341
  }
219
342
  catch (error) {
220
343
  this.logger.warn('Failed to decode SRPC message', error);
221
344
  this.closeStreamWithError(stream, 'badArg', 'Invalid message format');
222
345
  }
223
346
  }
224
- handleStreamDataReceived(stream, data) {
347
+ handleStreamDataReceived(stream, data, retainedBytes = estimateMessageBytes(data)) {
348
+ if (!this.isStreamDispatchAvailable(stream))
349
+ return;
225
350
  (0, observer_1.notifySrpcObservers)({ type: 'message', stream, direction: 'inbound', data, at: Date.now() });
226
351
  if (data.pingPong) {
227
352
  stream.lastPingAt = Date.now();
353
+ const waiter = this.initialPongWaiters.get(stream);
354
+ if (waiter) {
355
+ clearTimeout(waiter.timer);
356
+ this.initialPongWaiters.delete(stream);
357
+ waiter.resolve();
358
+ return;
359
+ }
228
360
  this.writeToStream(stream, { pingPong: {} });
229
361
  return;
230
362
  }
231
363
  if (data.byteStreamOperation) {
232
- this.handleByteSubstreamOperation(stream, data.byteStreamOperation);
364
+ if (!this.validRemoteByteStreamOperation(stream, data.byteStreamOperation)) {
365
+ this.closeStreamWithError(stream, 'badArg', 'Invalid byte stream ID');
366
+ return;
367
+ }
368
+ this.handleByteSubstreamOperation(stream, data.byteStreamOperation, data.requestId);
233
369
  return;
234
370
  }
235
371
  if (!data.requestId) {
@@ -247,7 +383,7 @@ class SrpcServer {
247
383
  return;
248
384
  }
249
385
  stream.$queue.delete(data.requestId);
250
- if (data.error)
386
+ if (data.error !== undefined)
251
387
  queueItem.reject(new types_1.SrpcError(data.error, data.userError));
252
388
  else
253
389
  queueItem.resolve(data);
@@ -255,10 +391,30 @@ class SrpcServer {
255
391
  }
256
392
  if (!stream.isActivated || this.blockedClientRequests.has(stream)) {
257
393
  const pending = this.pendingClientRequests.get(stream) ?? [];
258
- pending.push(data);
394
+ if (pending.length >= this.maxPendingClientRequests) {
395
+ this.closeStreamWithError(stream, 'badArg', 'Too many pending client requests');
396
+ return;
397
+ }
398
+ if ((this.pendingClientRequestBytes.get(stream) ?? 0) + retainedBytes > this.maxPendingClientRequestBytes) {
399
+ this.closeStreamWithError(stream, 'badArg', 'Too many pending client request bytes');
400
+ return;
401
+ }
402
+ pending.push({ data, retainedBytes });
259
403
  this.pendingClientRequests.set(stream, pending);
404
+ this.pendingClientRequestBytes.set(stream, (this.pendingClientRequestBytes.get(stream) ?? 0) + retainedBytes);
260
405
  return;
261
406
  }
407
+ const inFlight = this.inFlightClientRequests.get(stream) ?? 0;
408
+ if (inFlight >= this.maxInFlightClientRequests) {
409
+ this.closeStreamWithError(stream, 'badArg', 'Too many in-flight client requests');
410
+ return;
411
+ }
412
+ if ((this.inFlightClientRequestBytes.get(stream) ?? 0) + retainedBytes > this.maxInFlightClientRequestBytes) {
413
+ this.closeStreamWithError(stream, 'badArg', 'Too many in-flight client request bytes');
414
+ return;
415
+ }
416
+ this.inFlightClientRequests.set(stream, inFlight + 1);
417
+ this.inFlightClientRequestBytes.set(stream, (this.inFlightClientRequestBytes.get(stream) ?? 0) + retainedBytes);
262
418
  this.handleClientRequest(stream, data.requestId, data)
263
419
  .then(response => this.writeToStream(stream, {
264
420
  requestId: data.requestId,
@@ -266,13 +422,23 @@ class SrpcServer {
266
422
  ...response
267
423
  }))
268
424
  .catch(error => {
269
- const isUserError = error instanceof types_1.SrpcError && error.isUserError;
270
425
  this.writeToStream(stream, {
271
426
  requestId: data.requestId,
272
427
  reply: true,
273
- error: isUserError ? error.message : String(error),
274
- userError: isUserError
428
+ ...(0, types_1.serializeSrpcError)(error)
275
429
  });
430
+ })
431
+ .finally(() => {
432
+ const remaining = (this.inFlightClientRequests.get(stream) ?? 1) - 1;
433
+ if (remaining > 0)
434
+ this.inFlightClientRequests.set(stream, remaining);
435
+ else
436
+ this.inFlightClientRequests.delete(stream);
437
+ const remainingBytes = Math.max(0, (this.inFlightClientRequestBytes.get(stream) ?? retainedBytes) - retainedBytes);
438
+ if (remainingBytes)
439
+ this.inFlightClientRequestBytes.set(stream, remainingBytes);
440
+ else
441
+ this.inFlightClientRequestBytes.delete(stream);
276
442
  });
277
443
  }
278
444
  openClientRequests(stream) {
@@ -281,16 +447,87 @@ class SrpcServer {
281
447
  if (!pending?.length)
282
448
  return;
283
449
  this.pendingClientRequests.delete(stream);
450
+ // The pending accounting is deliberately cleared only after removing the
451
+ // retained queue; activated request accounting starts from each message's
452
+ // decoded size and cannot inherit stale pre-activation totals.
453
+ this.pendingClientRequestBytes.delete(stream);
284
454
  for (const message of pending)
285
- this.handleStreamDataReceived(stream, message);
455
+ this.handleStreamDataReceived(stream, message.data, message.retainedBytes);
286
456
  }
287
- handleByteSubstreamOperation(stream, op) {
288
- if (op.write)
289
- SrpcByteStream_1.SrpcByteStream.writeReceiver(stream, op.streamId, op.write.chunk);
290
- else if (op.finish)
457
+ handleByteSubstreamOperation(stream, op, requestId) {
458
+ if (op.destroy != null && SrpcByteStream_1.SrpcByteStream.consumeTerminalSender(stream, op.streamId))
459
+ return;
460
+ if (op.write != null) {
461
+ const backpressured = this.backpressuredByteStreams.get(stream);
462
+ const wasBackpressured = backpressured?.has(op.streamId) ?? false;
463
+ const accepted = SrpcByteStream_1.SrpcByteStream.writeReceiver(stream, op.streamId, op.write.chunk);
464
+ this.updateByteStreamBufferedBytes(stream, op.streamId, SrpcByteStream_1.SrpcByteStream.getReceiverBufferedBytes(stream, op.streamId));
465
+ if (!accepted) {
466
+ if (wasBackpressured) {
467
+ SrpcByteStream_1.SrpcByteStream.abortReceiver(stream, op.streamId, new Error(`SRPC byte stream ${op.streamId} receiver is not draining`));
468
+ this.clearByteStreamState(stream, op.streamId);
469
+ return;
470
+ }
471
+ const ids = backpressured ?? new Set();
472
+ if (ids.size >= MaxBackpressuredByteStreamsPerStream) {
473
+ SrpcByteStream_1.SrpcByteStream.abortReceiver(stream, op.streamId, new Error('Too many backpressured SRPC byte streams'));
474
+ this.clearByteStreamState(stream, op.streamId);
475
+ return;
476
+ }
477
+ ids.add(op.streamId);
478
+ this.backpressuredByteStreams.set(stream, ids);
479
+ }
480
+ else if (wasBackpressured) {
481
+ this.clearByteStreamBackpressureFlag(stream, op.streamId);
482
+ }
483
+ if (this.totalBackpressuredByteStreamBytes(stream) > MaxBackpressuredByteStreamBytesPerStream) {
484
+ SrpcByteStream_1.SrpcByteStream.abortReceiver(stream, op.streamId, new Error('Too many buffered SRPC byte stream bytes'));
485
+ this.clearByteStreamState(stream, op.streamId);
486
+ }
487
+ }
488
+ else if (op.finish != null) {
489
+ this.clearByteStreamBackpressureFlag(stream, op.streamId);
291
490
  SrpcByteStream_1.SrpcByteStream.finishReceiver(stream, op.streamId);
292
- else if (op.destroy)
491
+ }
492
+ else if (op.destroy != null) {
493
+ this.clearByteStreamState(stream, op.streamId);
293
494
  SrpcByteStream_1.SrpcByteStream.destroySubstream(stream, op.streamId, op.destroy.error);
495
+ }
496
+ }
497
+ clearByteStreamBackpressureFlag(stream, streamId) {
498
+ const ids = this.backpressuredByteStreams.get(stream);
499
+ if (!ids)
500
+ return;
501
+ ids.delete(streamId);
502
+ if (!ids.size)
503
+ this.backpressuredByteStreams.delete(stream);
504
+ }
505
+ clearByteStreamState(stream, streamId) {
506
+ this.clearByteStreamBackpressureFlag(stream, streamId);
507
+ this.updateByteStreamBufferedBytes(stream, streamId, 0);
508
+ }
509
+ updateByteStreamBufferedBytes(stream, streamId, bufferedBytes) {
510
+ const bytes = this.backpressuredByteStreamBytes.get(stream);
511
+ const previousBytes = bytes?.get(streamId) ?? 0;
512
+ if (bufferedBytes < previousBytes)
513
+ this.clearByteStreamBackpressureFlag(stream, streamId);
514
+ if (bufferedBytes <= 0) {
515
+ if (!bytes)
516
+ return;
517
+ bytes.delete(streamId);
518
+ if (!bytes.size)
519
+ this.backpressuredByteStreamBytes.delete(stream);
520
+ return;
521
+ }
522
+ const next = bytes ?? new Map();
523
+ next.set(streamId, bufferedBytes);
524
+ this.backpressuredByteStreamBytes.set(stream, next);
525
+ }
526
+ totalBackpressuredByteStreamBytes(stream) {
527
+ let total = 0;
528
+ for (const bytes of this.backpressuredByteStreamBytes.get(stream)?.values() ?? [])
529
+ total += bytes;
530
+ return total;
294
531
  }
295
532
  async handleClientRequest(stream, _requestId, message) {
296
533
  for (const [key, handlerMeta] of this.streamMessageHandlers) {
@@ -315,30 +552,76 @@ class SrpcServer {
315
552
  }
316
553
  onStreamActivated(_stream) { }
317
554
  onStreamDisconnected(stream, cause) {
318
- for (const handler of this.streamDisconnectionHandlers)
319
- handler(stream, cause);
555
+ if (!this.publishedStreams?.has(stream))
556
+ return;
557
+ for (const handler of this.streamDisconnectionHandlers) {
558
+ try {
559
+ handler(stream, cause);
560
+ }
561
+ catch (error) {
562
+ this.logger.error('SRPC disconnect handler failed', error);
563
+ }
564
+ }
320
565
  }
321
- cleanupStream(stream, cause = 'disconnect') {
566
+ revokeStream(stream, cause) {
322
567
  if (stream.lastPingAt < 0)
323
- return;
568
+ return false;
324
569
  stream.lastPingAt = -1;
325
- for (const queueItem of stream.$queue.values())
326
- queueItem.reject(new Error('Stream disconnected'));
327
- stream.$queue.clear();
328
- this.lateReplyTombstonesByStream.delete(stream);
329
- this.blockedClientRequests.delete(stream);
330
- this.pendingClientRequests.delete(stream);
331
- this.streamsById.delete(stream.id);
332
- if (this.pendingStreamsByClientId.get(stream.clientId) === stream)
570
+ for (const queueItem of stream.$queue?.values() ?? []) {
571
+ queueItem.reject(new types_1.SrpcIndeterminateDeliveryError(stream.clientId, new Error('Stream disconnected')));
572
+ }
573
+ stream.$queue?.clear();
574
+ const initialPong = this.initialPongWaiters?.get(stream);
575
+ if (initialPong) {
576
+ clearTimeout(initialPong.timer);
577
+ this.initialPongWaiters.delete(stream);
578
+ initialPong.resolve();
579
+ }
580
+ this.blockedClientRequests?.delete(stream);
581
+ this.pendingClientRequests?.delete(stream);
582
+ this.pendingClientRequestBytes?.delete(stream);
583
+ this.inFlightClientRequests?.delete(stream);
584
+ this.inFlightClientRequestBytes?.delete(stream);
585
+ this.pendingServerRequestBytes?.delete(stream);
586
+ this.backpressuredByteStreams?.delete(stream);
587
+ this.backpressuredByteStreamBytes?.delete(stream);
588
+ this.streamsById?.delete(stream.id);
589
+ if (this.pendingStreamsByClientId?.get(stream.clientId) === stream)
333
590
  this.pendingStreamsByClientId.delete(stream.clientId);
334
- if (this.streamsByClientId.get(stream.clientId) === stream)
591
+ if (this.streamsByClientId?.get(stream.clientId) === stream)
335
592
  this.streamsByClientId.delete(stream.clientId);
336
- this.onStreamDisconnected(stream, cause);
337
- (0, observer_1.notifySrpcObservers)({ type: 'disconnection', stream, cause, at: Date.now() });
593
+ const wasPublished = this.publishedStreams?.has(stream) ?? false;
594
+ try {
595
+ this.onStreamDisconnected(stream, cause);
596
+ }
597
+ catch (error) {
598
+ this.logger.error('SRPC disconnect callback failed', error);
599
+ }
600
+ if (wasPublished) {
601
+ try {
602
+ (0, observer_1.notifySrpcObservers)({ type: 'disconnection', stream, cause, at: Date.now() });
603
+ }
604
+ catch (error) {
605
+ this.logger.error('SRPC observer failed', error);
606
+ }
607
+ this.publishedStreams.delete(stream);
608
+ }
609
+ return true;
610
+ }
611
+ cleanupStream(stream, cause = 'disconnect') {
612
+ if (!this.revokeStream(stream, cause))
613
+ return;
338
614
  if (stream.$ws.readyState === ws_1.default.OPEN || stream.$ws.readyState === ws_1.default.CONNECTING) {
339
615
  stream.$ws.close(closeCodeForCause(cause), `Stream terminated with cause: ${cause}`);
340
616
  }
341
617
  }
618
+ closeStreamGracefully(stream, reason) {
619
+ if (!this.revokeStream(stream, 'disconnect'))
620
+ return;
621
+ if (stream.$ws.readyState === ws_1.default.OPEN || stream.$ws.readyState === ws_1.default.CONNECTING) {
622
+ stream.$ws.close(1000, reason ? reason.slice(0, 123) : 'Stream terminated with cause: disconnect');
623
+ }
624
+ }
342
625
  handleStreamDisconnected(stream, code) {
343
626
  this.cleanupStream(stream, causeForCloseCode(code));
344
627
  }
@@ -369,15 +652,63 @@ class SrpcServer {
369
652
  return false;
370
653
  const config = getOptionalAppConfig();
371
654
  const driftMs = config?.SRPC_AUTH_CLOCK_DRIFT_MS ?? 30000;
655
+ if (!Number.isSafeInteger(driftMs) || driftMs <= 0 || driftMs > helpers_1.MAX_SAFE_TIMER_MS)
656
+ return false;
372
657
  if (Math.abs(Date.now() - tsInt) > driftMs)
373
658
  return false;
659
+ if (authv !== '2')
660
+ return false;
661
+ if (!isAuthToken(meta.nonce) || !meta.aud || !Number.isSafeInteger(Number(meta._v)) || Number(meta._v) !== 2)
662
+ return false;
374
663
  const clientKey = await this.fetchClientKey(cid);
375
664
  if (clientKey === false)
376
665
  return false;
377
- const computedSignature = (0, node_crypto_1.createHmac)('sha256', clientKey).update(`${authv}\n${appv}\n${ts}\n${id}\n${cid}\n`).digest('hex');
666
+ const url = new URL(request.url ?? '', 'http://localhost');
667
+ const metadata = normalizeMetadata(Object.fromEntries(Object.entries(meta)
668
+ .filter(([key]) => key.startsWith('m--'))
669
+ .map(([key, value]) => [key.slice(3), String(value)])));
670
+ const features = normalizeFeatures(String(meta._f ?? '')
671
+ .split(',')
672
+ .filter(Boolean));
673
+ const supersede = meta._supersede === '1' ? '1' : '0';
674
+ const computedSignature = (0, node_crypto_1.createHmac)('sha256', clientKey)
675
+ .update(canonicalAuthV2({
676
+ path: url.pathname,
677
+ audience: String(meta.aud),
678
+ appv,
679
+ ts,
680
+ nonce: String(meta.nonce),
681
+ id,
682
+ cid,
683
+ protocol: String(meta._v),
684
+ supersede,
685
+ features,
686
+ metadata
687
+ }))
688
+ .digest('hex');
378
689
  const signatureBuffer = Buffer.from(signature);
379
690
  const computedBuffer = Buffer.from(computedSignature);
380
- return signatureBuffer.length === computedBuffer.length && (0, node_crypto_1.timingSafeEqual)(signatureBuffer, computedBuffer);
691
+ if (signatureBuffer.length !== computedBuffer.length || !(0, node_crypto_1.timingSafeEqual)(signatureBuffer, computedBuffer))
692
+ return false;
693
+ if (String(meta.aud) !== (this.options.authAudience ?? url.pathname))
694
+ return false;
695
+ const nonce = String(meta.nonce);
696
+ const expiresAt = tsInt + driftMs;
697
+ if (this.isLocalAuthNonceReplay(cid, nonce))
698
+ return false;
699
+ if (this.authNonceConsumer) {
700
+ if (!(await this.authNonceConsumer(cid, nonce, expiresAt)))
701
+ return false;
702
+ // The shared consumer is authoritative under saturation. Keep the
703
+ // local duplicate fast path bounded by evicting its least-recent
704
+ // principal/nonce entries instead of imposing a service-wide CID cap.
705
+ if (!this.consumeLocalAuthNonce(cid, nonce, expiresAt, true))
706
+ return false;
707
+ }
708
+ else if (!this.consumeLocalAuthNonce(cid, nonce, expiresAt, false)) {
709
+ return false;
710
+ }
711
+ return true;
381
712
  }
382
713
  async fetchClientKey(clientId) {
383
714
  if (this.clientKeyFetcher)
@@ -395,42 +726,94 @@ class SrpcServer {
395
726
  return request.socket.remoteAddress ?? '127.0.0.1';
396
727
  }
397
728
  writeToStream(stream, data) {
398
- if (stream.$ws.readyState !== ws_1.default.OPEN)
729
+ if (!this.isStreamDispatchAvailable(stream) || stream.$ws.readyState !== ws_1.default.OPEN)
730
+ return false;
731
+ const encoded = (0, types_1.encodeSrpcMessage)(this.options.serverMessage, data);
732
+ return this.writeEncodedToStream(stream, data, encoded);
733
+ }
734
+ writeEncodedToStream(stream, data, encoded) {
735
+ if (!this.isStreamDispatchAvailable(stream) || stream.$ws.readyState !== ws_1.default.OPEN)
399
736
  return false;
400
- stream.$ws.send((0, types_1.encodeSrpcMessage)(this.options.serverMessage, data));
737
+ if (!this.canWriteToStream(stream, encoded.byteLength))
738
+ return false;
739
+ try {
740
+ stream.$ws.send(encoded);
741
+ }
742
+ catch {
743
+ this.closeStreamWithError(stream, 'badArg', 'Failed to send response');
744
+ return false;
745
+ }
401
746
  (0, observer_1.notifySrpcObservers)({ type: 'message', stream, direction: 'outbound', data, at: Date.now() });
402
747
  return true;
403
748
  }
404
749
  writeToStreamAsync(stream, data) {
405
- if (stream.$ws.readyState !== ws_1.default.OPEN)
750
+ if (!this.isStreamDispatchAvailable(stream) || stream.$ws.readyState !== ws_1.default.OPEN) {
406
751
  return Promise.reject(new Error('Failed to send SRPC message: not connected'));
752
+ }
407
753
  const encoded = (0, types_1.encodeSrpcMessage)(this.options.serverMessage, data);
754
+ if (!this.canWriteToStream(stream, encoded.byteLength))
755
+ return Promise.reject(new types_1.SrpcBackpressureError('sRPC stream outgoing buffer limit exceeded'));
408
756
  return new Promise((resolve, reject) => {
409
- stream.$ws.send(encoded, error => {
410
- if (error)
411
- reject(error);
412
- else {
413
- (0, observer_1.notifySrpcObservers)({
414
- type: 'message',
415
- stream,
416
- direction: 'outbound',
417
- data,
418
- at: Date.now()
419
- });
420
- resolve();
421
- }
422
- });
757
+ try {
758
+ stream.$ws.send(encoded, error => {
759
+ if (error) {
760
+ this.closeStreamWithError(stream, 'badArg', 'Failed to send response');
761
+ reject(error);
762
+ }
763
+ else if (!this.isStreamDispatchAvailable(stream))
764
+ reject(new Error('Failed to send SRPC message: stream revoked'));
765
+ else {
766
+ (0, observer_1.notifySrpcObservers)({
767
+ type: 'message',
768
+ stream,
769
+ direction: 'outbound',
770
+ data,
771
+ at: Date.now()
772
+ });
773
+ resolve();
774
+ }
775
+ });
776
+ }
777
+ catch (error) {
778
+ this.closeStreamWithError(stream, 'badArg', 'Failed to send response');
779
+ reject(error instanceof Error ? error : new Error(String(error)));
780
+ }
423
781
  });
424
782
  }
783
+ canWriteToStream(stream, bytes) {
784
+ if (!this.isStreamDispatchAvailable(stream))
785
+ return false;
786
+ if (bytes > this.maxMessageBytes) {
787
+ this.closeStreamWithError(stream, 'badArg', 'sRPC stream outgoing message limit exceeded');
788
+ return false;
789
+ }
790
+ if ((stream.$ws.bufferedAmount ?? 0) + bytes <= this.maxBufferedBytes)
791
+ return true;
792
+ this.closeStreamWithError(stream, 'badArg', 'sRPC stream outgoing buffer limit exceeded');
793
+ return false;
794
+ }
425
795
  closeStreamWithError(stream, cause, message) {
796
+ if (!this.revokeStream(stream, cause))
797
+ return;
426
798
  stream.$ws.close(closeCodeForCause(cause), message.slice(0, 123));
427
799
  }
800
+ isStreamDispatchAvailable(stream) {
801
+ return !(stream.lastPingAt < 0) && this.isCurrentStream(stream);
802
+ }
428
803
  setClientAuthorizer(authorizer) {
429
804
  this.clientAuthorizer = authorizer;
430
805
  }
431
806
  setClientKeyFetcher(fetcher) {
432
807
  this.clientKeyFetcher = fetcher;
433
808
  }
809
+ /**
810
+ * Installs an atomic service-wide auth-v2 nonce consumer. It must return
811
+ * true only for the first `(principal, nonce)` consumption through
812
+ * `expiresAt`; false rejects a replay. Core retains its fair local guard.
813
+ */
814
+ setAuthNonceConsumer(consumer) {
815
+ this.authNonceConsumer = consumer;
816
+ }
434
817
  registerConnectionHandler(handler) {
435
818
  this.streamConnectionHandlers.add(handler);
436
819
  }
@@ -480,21 +863,54 @@ class SrpcServer {
480
863
  return true;
481
864
  }
482
865
  invoke(stream, prefix, data, timeoutMs = 30000) {
866
+ return this.invokeWithRequestId(stream, prefix, data, timeoutMs, (0, helpers_1.uuid7)());
867
+ }
868
+ invokeWithRequestId(stream, prefix, data, timeoutMs, requestId) {
869
+ assertTimeout(timeoutMs);
483
870
  const requestType = `${prefix}Request`;
484
871
  const resultType = `${prefix}Response`;
485
- const requestId = (0, helpers_1.uuid7)();
872
+ const message = { requestId, [requestType]: data };
873
+ if (stream.$queue.has(requestId))
874
+ return Promise.reject(new Error(`Duplicate SRPC request ID ${requestId}`));
875
+ let encoded;
876
+ try {
877
+ encoded = (0, types_1.encodeSrpcMessage)(this.options.serverMessage, message);
878
+ }
879
+ catch (error) {
880
+ return Promise.reject(error);
881
+ }
882
+ if (stream.$queue.size >= this.maxPendingServerRequests) {
883
+ return Promise.reject(new types_1.SrpcBackpressureError('Too many pending server SRPC requests'));
884
+ }
885
+ if ((this.pendingServerRequestBytes.get(stream) ?? 0) + encoded.byteLength > this.maxPendingServerRequestBytes) {
886
+ return Promise.reject(new types_1.SrpcBackpressureError('Too many pending server SRPC request bytes'));
887
+ }
888
+ this.pendingServerRequestBytes.set(stream, (this.pendingServerRequestBytes.get(stream) ?? 0) + encoded.byteLength);
889
+ let retained = true;
890
+ const releaseRetainedBytes = () => {
891
+ if (!retained)
892
+ return;
893
+ retained = false;
894
+ const remaining = Math.max(0, (this.pendingServerRequestBytes.get(stream) ?? encoded.byteLength) - encoded.byteLength);
895
+ if (remaining)
896
+ this.pendingServerRequestBytes.set(stream, remaining);
897
+ else
898
+ this.pendingServerRequestBytes.delete(stream);
899
+ };
486
900
  return new Promise((resolve, reject) => {
487
901
  const timeout = setTimeout(() => {
488
902
  if (!stream.$queue.has(requestId))
489
903
  return;
490
904
  stream.$queue.delete(requestId);
491
905
  this.addLateReplyTombstone(stream, requestId);
492
- reject(new Error(`Request timeout after ${timeoutMs}ms`));
906
+ releaseRetainedBytes();
907
+ reject(new types_1.SrpcIndeterminateDeliveryError(stream.clientId, new Error(`Request timeout after ${timeoutMs}ms`)));
493
908
  }, timeoutMs);
494
909
  const queueItem = {
495
910
  exp: Date.now() + timeoutMs,
496
911
  resolve: response => {
497
912
  clearTimeout(timeout);
913
+ releaseRetainedBytes();
498
914
  const result = response[resultType];
499
915
  if (result == null)
500
916
  reject(new Error('Invalid response from client'));
@@ -503,27 +919,27 @@ class SrpcServer {
503
919
  },
504
920
  reject: error => {
505
921
  clearTimeout(timeout);
922
+ releaseRetainedBytes();
506
923
  reject(error);
507
924
  }
508
925
  };
509
926
  stream.$queue.set(requestId, queueItem);
510
927
  let sent;
511
928
  try {
512
- sent = this.writeToStream(stream, {
513
- requestId,
514
- [requestType]: data
515
- });
929
+ sent = this.writeEncodedToStream(stream, message, encoded);
516
930
  }
517
931
  catch (error) {
518
932
  if (stream.$queue.get(requestId) === queueItem)
519
933
  stream.$queue.delete(requestId);
520
934
  clearTimeout(timeout);
935
+ releaseRetainedBytes();
521
936
  reject(error);
522
937
  return;
523
938
  }
524
939
  if (!sent) {
525
940
  stream.$queue.delete(requestId);
526
941
  clearTimeout(timeout);
942
+ releaseRetainedBytes();
527
943
  reject(new Error('Failed to send request: not connected'));
528
944
  }
529
945
  });
@@ -560,13 +976,16 @@ class SrpcServer {
560
976
  this.lateReplyTombstonesByStream.set(stream, tombstones);
561
977
  }
562
978
  isLateReply(stream, requestId) {
563
- const tombstones = this.lateReplyTombstonesByStream.get(stream);
979
+ const tombstonesByStream = this.lateReplyTombstonesByStream;
980
+ if (!tombstonesByStream)
981
+ return false;
982
+ const tombstones = tombstonesByStream.get(stream);
564
983
  if (!tombstones)
565
984
  return false;
566
985
  const now = Date.now();
567
986
  this.pruneLateReplyTombstones(tombstones, now);
568
987
  if (!tombstones.size)
569
- this.lateReplyTombstonesByStream.delete(stream);
988
+ tombstonesByStream.delete(stream);
570
989
  return (tombstones.get(requestId) ?? 0) > now;
571
990
  }
572
991
  pruneLateReplyTombstones(tombstones, now) {
@@ -576,8 +995,122 @@ class SrpcServer {
576
995
  }
577
996
  }
578
997
  get lateReplyTombstoneTtlMs() {
579
- const configured = this.options.lateReplyTombstoneTtlMs;
580
- return configured != null && Number.isFinite(configured) && configured > 0 ? Math.floor(configured) : DefaultLateReplyTombstoneTtlMs;
998
+ return configuredPositiveInteger(this.options.lateReplyTombstoneTtlMs, DefaultLateReplyTombstoneTtlMs);
999
+ }
1000
+ get maxPendingClientRequests() {
1001
+ return configuredPositiveInteger(this.options.maxPendingClientRequests, DefaultMaxPendingClientRequests);
1002
+ }
1003
+ get maxPendingClientRequestBytes() {
1004
+ return configuredPositiveInteger(this.options.maxPendingClientRequestBytes, DefaultMaxPendingClientRequestBytes);
1005
+ }
1006
+ get maxInFlightClientRequests() {
1007
+ return configuredPositiveInteger(this.options.maxInFlightClientRequests, DefaultMaxInFlightClientRequests);
1008
+ }
1009
+ get maxInFlightClientRequestBytes() {
1010
+ return configuredPositiveInteger(this.options.maxInFlightClientRequestBytes, DefaultMaxInFlightClientRequestBytes);
1011
+ }
1012
+ get maxBufferedBytes() {
1013
+ return configuredPositiveInteger(this.options.maxBufferedBytes, DefaultMaxBufferedBytes);
1014
+ }
1015
+ get maxMessageBytes() {
1016
+ return configuredPositiveInteger(this.options.maxMessageBytes, DefaultMaxMessageBytes);
1017
+ }
1018
+ get maxPendingServerRequests() {
1019
+ return configuredPositiveInteger(this.options.maxPendingServerRequests, DefaultMaxPendingServerRequests);
1020
+ }
1021
+ get maxPendingServerRequestBytes() {
1022
+ return configuredPositiveInteger(this.options.maxPendingServerRequestBytes, DefaultMaxPendingServerRequestBytes);
1023
+ }
1024
+ get maxPendingHandshakes() {
1025
+ return configuredPositiveInteger(this.options.maxPendingHandshakes, DefaultMaxPendingHandshakes);
1026
+ }
1027
+ get maxActiveStreams() {
1028
+ return configuredPositiveInteger(this.options.maxActiveStreams, DefaultMaxActiveStreams);
1029
+ }
1030
+ get maxClientIdBytes() {
1031
+ return configuredPositiveInteger(this.options.maxClientIdBytes, DefaultMaxClientIdBytes);
1032
+ }
1033
+ get maxClientMetadataBytes() {
1034
+ return configuredPositiveInteger(this.options.maxClientMetadataBytes, DefaultMaxClientMetadataBytes);
1035
+ }
1036
+ get maxAuthReplayPrincipals() {
1037
+ return configuredPositiveInteger(this.options.maxAuthReplayPrincipals, DefaultMaxAuthReplayPrincipals);
1038
+ }
1039
+ validRemoteByteStreamOperation(stream, op) {
1040
+ const id = op.streamId;
1041
+ if (typeof id !== 'number' || !Number.isSafeInteger(id) || id <= 0 || id > MaxByteStreamId)
1042
+ return false;
1043
+ const hasWrite = op.write != null;
1044
+ const hasFinish = op.finish != null;
1045
+ const hasDestroy = op.destroy != null;
1046
+ const operationCount = Number(hasWrite) + Number(hasFinish) + Number(hasDestroy);
1047
+ if (operationCount !== 1)
1048
+ return false;
1049
+ if (hasWrite && (!isPlainObject(op.write) || !(op.write.chunk instanceof Uint8Array)))
1050
+ return false;
1051
+ if (hasFinish && !isPlainObject(op.finish))
1052
+ return false;
1053
+ if (hasDestroy && (!isPlainObject(op.destroy) || (op.destroy.error != null && typeof op.destroy.error !== 'string')))
1054
+ return false;
1055
+ if (hasDestroy) {
1056
+ return (id % 2 === 1 ||
1057
+ SrpcByteStream_1.SrpcByteStream.hasSender(stream, id) ||
1058
+ SrpcByteStream_1.SrpcByteStream.hasTerminalSender(stream, id) ||
1059
+ this.hasExternalByteStreamSender(stream, id));
1060
+ }
1061
+ return id % 2 === 1;
1062
+ }
1063
+ isLocalAuthNonceReplay(principal, nonce) {
1064
+ const now = Date.now();
1065
+ const nonces = this.authReplayNoncesByPrincipal.get(principal);
1066
+ if (!nonces)
1067
+ return false;
1068
+ pruneExpiredEntries(nonces, now);
1069
+ if (!nonces.size) {
1070
+ this.authReplayNoncesByPrincipal.delete(principal);
1071
+ return false;
1072
+ }
1073
+ return (nonces.get(nonce) ?? 0) > now;
1074
+ }
1075
+ consumeLocalAuthNonce(principal, nonce, expiresAt, allowEviction) {
1076
+ const now = Date.now();
1077
+ if (expiresAt <= now)
1078
+ return false;
1079
+ let nonces = this.authReplayNoncesByPrincipal.get(principal);
1080
+ if (!nonces) {
1081
+ if (this.authReplayNoncesByPrincipal.size >= this.maxAuthReplayPrincipals) {
1082
+ for (const [candidate, candidateNonces] of this.authReplayNoncesByPrincipal) {
1083
+ pruneExpiredEntries(candidateNonces, now);
1084
+ if (!candidateNonces.size)
1085
+ this.authReplayNoncesByPrincipal.delete(candidate);
1086
+ }
1087
+ }
1088
+ if (this.authReplayNoncesByPrincipal.size >= this.maxAuthReplayPrincipals) {
1089
+ if (!allowEviction)
1090
+ return false;
1091
+ const oldestPrincipal = this.authReplayNoncesByPrincipal.keys().next().value;
1092
+ if (oldestPrincipal != null)
1093
+ this.authReplayNoncesByPrincipal.delete(oldestPrincipal);
1094
+ }
1095
+ nonces = new Map();
1096
+ this.authReplayNoncesByPrincipal.set(principal, nonces);
1097
+ }
1098
+ pruneExpiredEntries(nonces, now);
1099
+ if ((nonces.get(nonce) ?? 0) > now)
1100
+ return false;
1101
+ if (nonces.size >= MaxAuthReplayNoncesPerPrincipal) {
1102
+ if (!allowEviction)
1103
+ return false;
1104
+ const oldestNonce = nonces.keys().next().value;
1105
+ if (oldestNonce != null)
1106
+ nonces.delete(oldestNonce);
1107
+ }
1108
+ nonces.set(nonce, expiresAt);
1109
+ // Refresh principal insertion order so the bounded shared-authority mode
1110
+ // evicts the least recently consumed principal.
1111
+ this.authReplayNoncesByPrincipal.delete(principal);
1112
+ this.authReplayNoncesByPrincipal.set(principal, nonces);
1113
+ return true;
581
1114
  }
582
1115
  close() {
583
1116
  clearInterval(this.inactivityCheckInterval);
@@ -589,7 +1122,7 @@ class SrpcServer {
589
1122
  static createInvoke(instanceFn) {
590
1123
  return ((...args) => instanceFn().invoke(...args));
591
1124
  }
592
- static __tsfType = _SrpcServerMetadata_1 = _a.decodeCompactMetadataV1("[1,{\"kind\":16,\"name\":\"SrpcServer\",\"typeName\":\"SrpcServer\",\"classType\":{\"$tsf\":0},\"properties\":[{\"name\":\"streamsById\",\"type\":{\"$tsfType\":0},\"optional\":false},{\"name\":\"streamsByClientId\",\"type\":{\"$tsfType\":0},\"optional\":false},{\"name\":\"pendingStreamsByClientId\",\"type\":{\"$tsfType\":0},\"optional\":false}],\"methods\":[{\"name\":\"postEstablishCheck\",\"parameters\":[{\"name\":\"_stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":1}},{\"name\":\"getCurrentStreamByClientId\",\"parameters\":[{\"name\":\"clientId\",\"type\":{\"$tsfType\":2},\"optional\":false,\"default\":false}],\"returnType\":{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":4}]}},{\"name\":\"isCurrentStream\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":3}},{\"name\":\"handleByteSubstreamOperation\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"op\",\"type\":{\"$tsfType\":4},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":5}},{\"name\":\"runMessageHandler\",\"parameters\":[{\"name\":\"handler\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2,\"typeName\":\"SrpcMessageHandlerFn\",\"typeArguments\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":2},{\"kind\":2}]},{\"kind\":2,\"typeName\":\"ClassType\",\"typeArguments\":[{\"kind\":18,\"typeName\":\"ISrpcMessageHandler\",\"types\":[{\"kind\":20,\"name\":\"handle\",\"type\":{\"kind\":2,\"typeName\":\"SrpcMessageHandlerFn\",\"typeArguments\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":2},{\"kind\":2}]},\"optional\":false}]}],\"typeName\":\"TSrpcMessageHandlerClass\"}],\"typeName\":\"TSrpcMessageHandlerFnOrClass\"},\"optional\":false,\"default\":false},{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":0},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":6}},{\"name\":\"onStreamConnected\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"onStreamActivated\",\"parameters\":[{\"name\":\"_stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":8}},{\"name\":\"onStreamDisconnected\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"cause\",\"type\":{\"$tsfType\":9},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":5}},{\"name\":\"cleanupStream\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"cause\",\"type\":{\"$tsfType\":9},\"optional\":true,\"default\":true}],\"returnType\":{\"$tsfType\":5}},{\"name\":\"writeToStream\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"kind\":16,\"typeName\":\"TServerOutput\",\"classType\":{\"$tsf\":4}},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":3}},{\"name\":\"writeToStreamAsync\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"kind\":16,\"typeName\":\"TServerOutput\",\"classType\":{\"$tsf\":4}},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"setClientAuthorizer\",\"parameters\":[{\"name\":\"authorizer\",\"type\":{\"$tsfType\":10},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":5}},{\"name\":\"setClientKeyFetcher\",\"parameters\":[{\"name\":\"fetcher\",\"type\":{\"$tsfType\":11},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":5}},{\"name\":\"registerConnectionHandler\",\"parameters\":[{\"name\":\"handler\",\"type\":{\"$tsfType\":12},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":5}},{\"name\":\"registerMessageHandler\",\"parameters\":[{\"name\":\"prefix\",\"type\":{\"$tsfType\":13},\"optional\":false,\"default\":false},{\"name\":\"handler\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2,\"typeName\":\"SrpcMessageHandlerFn\",\"typeArguments\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":2,\"typeName\":\"HandlerRequestData\",\"typeArguments\":[{\"kind\":16,\"typeName\":\"TClientOutput\",\"classType\":{\"$tsf\":5}},{\"kind\":2,\"typeName\":\"P\"}]},{\"kind\":2,\"typeName\":\"ResponseData\",\"typeArguments\":[{\"kind\":16,\"typeName\":\"TServerOutput\",\"classType\":{\"$tsf\":4}},{\"kind\":2,\"typeName\":\"P\"}]}]},{\"kind\":2,\"typeName\":\"ClassType\",\"typeArguments\":[{\"kind\":18,\"typeName\":\"ISrpcMessageHandler\",\"types\":[{\"kind\":20,\"name\":\"handle\",\"type\":{\"kind\":2,\"typeName\":\"SrpcMessageHandlerFn\",\"typeArguments\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":2,\"typeName\":\"HandlerRequestData\",\"typeArguments\":[{\"kind\":16,\"typeName\":\"TClientOutput\",\"classType\":{\"$tsf\":5}},{\"kind\":2,\"typeName\":\"P\"}]},{\"kind\":2,\"typeName\":\"ResponseData\",\"typeArguments\":[{\"kind\":16,\"typeName\":\"TServerOutput\",\"classType\":{\"$tsf\":4}},{\"kind\":2,\"typeName\":\"P\"}]}]},\"optional\":false}]}],\"typeName\":\"TSrpcMessageHandlerClass\"}],\"typeName\":\"TSrpcMessageHandlerFnOrClass\"},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":5}},{\"name\":\"registerDisconnectHandler\",\"parameters\":[{\"name\":\"handler\",\"type\":{\"$tsfType\":14},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":5}},{\"name\":\"registerBroadcastHandler\",\"parameters\":[{\"name\":\"type\",\"type\":{\"$tsfType\":2},\"optional\":false,\"default\":false},{\"name\":\"handler\",\"type\":{\"$tsfType\":15},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":5}},{\"name\":\"broadcast\",\"parameters\":[{\"name\":\"type\",\"type\":{\"$tsfType\":2},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":16},\"optional\":false,\"default\":false},{\"name\":\"options\",\"type\":{\"$tsfType\":17},\"optional\":true,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"resolveClient\",\"parameters\":[{\"name\":\"clientId\",\"type\":{\"$tsfType\":2},\"optional\":false,\"default\":false}],\"returnType\":{\"kind\":22,\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"SrpcConnection\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"readonly id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"readonly clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"readonly meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"readonly connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"readonly connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":4}]}}},{\"name\":\"listClients\",\"parameters\":[],\"returnType\":{\"kind\":22,\"type\":{\"kind\":14,\"type\":{\"kind\":18,\"typeName\":\"SrpcConnection\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"readonly id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"readonly clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"readonly meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"readonly connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"readonly connected\",\"type\":{\"kind\":8},\"optional\":false}]}}}},{\"name\":\"disconnectClient\",\"parameters\":[{\"name\":\"streamOrClientId\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":6}]},\"optional\":false,\"default\":false},{\"name\":\"reason\",\"type\":{\"$tsfType\":2},\"optional\":true,\"default\":false}],\"returnType\":{\"$tsfType\":1}},{\"name\":\"updateClientMetadata\",\"parameters\":[{\"name\":\"streamOrClientId\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":6}]},\"optional\":false,\"default\":false},{\"name\":\"metadata\",\"type\":{\"kind\":18,\"typeName\":\"Partial\",\"utilityType\":\"Partial\",\"typeArguments\":[{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}}],\"utilityKeys\":[],\"types\":[]},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":1}},{\"name\":\"invoke\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"prefix\",\"type\":{\"$tsfType\":13},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":18},\"optional\":false,\"default\":false},{\"name\":\"timeoutMs\",\"type\":{\"$tsfType\":0},\"optional\":true,\"default\":true}],\"returnType\":{\"$tsfType\":19}},{\"name\":\"encodeMeshInvokeRequest\",\"parameters\":[{\"name\":\"prefix\",\"type\":{\"$tsfType\":2},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":0},\"optional\":false,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"Uint8Array\",\"classType\":{\"$tsf\":6}}},{\"name\":\"decodeMeshInvokeRequest\",\"parameters\":[{\"name\":\"prefix\",\"type\":{\"$tsfType\":2},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"kind\":16,\"typeName\":\"Uint8Array\",\"classType\":{\"$tsf\":6}},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":0}},{\"name\":\"encodeMeshInvokeResponse\",\"parameters\":[{\"name\":\"prefix\",\"type\":{\"$tsfType\":2},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":0},\"optional\":false,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"Uint8Array\",\"classType\":{\"$tsf\":6}}},{\"name\":\"decodeMeshInvokeResponse\",\"parameters\":[{\"name\":\"prefix\",\"type\":{\"$tsfType\":2},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"kind\":16,\"typeName\":\"Uint8Array\",\"classType\":{\"$tsf\":6}},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":0}},{\"name\":\"reserveByteStreamSenderIds\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"count\",\"type\":{\"$tsfType\":20},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":21}},{\"name\":\"writeByteStreamOperation\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":3}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"operation\",\"type\":{\"$tsfType\":22},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"close\",\"parameters\":[],\"returnType\":{\"$tsfType\":5}}],\"hasConstructor\":true,\"constructorParameters\":[{\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"ISrpcServerOptions\",\"types\":[{\"kind\":20,\"name\":\"logger\",\"type\":{\"kind\":18,\"typeName\":\"ISrpcLogger\",\"types\":[]},\"optional\":false},{\"kind\":20,\"name\":\"clientMessage\",\"type\":{\"kind\":18,\"typeName\":\"SrpcMessageFns\",\"types\":[]},\"optional\":false},{\"kind\":20,\"name\":\"serverMessage\",\"type\":{\"kind\":18,\"typeName\":\"SrpcMessageFns\",\"types\":[]},\"optional\":false},{\"kind\":20,\"name\":\"wsPath\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"debug\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"logLevel\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"info\"},{\"kind\":10,\"literal\":\"debug\"},{\"kind\":10,\"literal\":false}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"httpServer\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"Server\",\"classType\":{\"$tsfImport\":[7,\"node:http\",\"Server\"]}},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"lateReplyTombstoneTtlMs\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true}]},\"optional\":false,\"default\":false}]}]", [() => SrpcServer, () => (typeof WebSocket !== "undefined" ? WebSocket : (typeof exports !== "undefined" ? exports.WebSocket : undefined)), () => (typeof Map !== "undefined" ? Map : (typeof exports !== "undefined" ? exports.Map : undefined)), () => (typeof TMeta !== "undefined" ? TMeta : (typeof exports !== "undefined" ? exports.TMeta : undefined)), () => (typeof TServerOutput !== "undefined" ? TServerOutput : (typeof exports !== "undefined" ? exports.TServerOutput : undefined)), () => (typeof TClientOutput !== "undefined" ? TClientOutput : (typeof exports !== "undefined" ? exports.TClientOutput : undefined)), () => (typeof Uint8Array !== "undefined" ? Uint8Array : (typeof exports !== "undefined" ? exports.Uint8Array : undefined)), require], __tsf_metadata_type);
1125
+ static __tsfType = _SrpcServerMetadata_1 = _a.decodeCompactMetadataV1("[1,{\"kind\":16,\"name\":\"SrpcServer\",\"typeName\":\"SrpcServer\",\"classType\":{\"$tsf\":0},\"properties\":[{\"name\":\"streamsById\",\"type\":{\"$tsfType\":0},\"optional\":false},{\"name\":\"streamsByClientId\",\"type\":{\"$tsfType\":0},\"optional\":false},{\"name\":\"pendingStreamsByClientId\",\"type\":{\"$tsfType\":0},\"optional\":false}],\"methods\":[{\"name\":\"postEstablishCheck\",\"parameters\":[{\"name\":\"_stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":1}},{\"name\":\"onStreamWillActivate\",\"parameters\":[{\"name\":\"_stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":2},\"description\":\"Hook for private/cluster CAS work after liveness is proven but before user connection handlers and public local publication.\"},{\"name\":\"hasExternalByteStreamSender\",\"parameters\":[{\"name\":\"_stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"_streamId\",\"type\":{\"$tsfType\":3},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":4},\"description\":\"Allows a transport extension to recognize a locally-owned sender whose state is maintained outside the core SrpcByteStream sender map. Core remains strict by default.\"},{\"name\":\"getCurrentStreamByClientId\",\"parameters\":[{\"name\":\"clientId\",\"type\":{\"$tsfType\":5},\"optional\":false,\"default\":false}],\"returnType\":{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":4}]}},{\"name\":\"isCurrentStream\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":4}},{\"name\":\"handleByteSubstreamOperation\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"op\",\"type\":{\"$tsfType\":6},\"optional\":false,\"default\":false},{\"name\":\"requestId\",\"type\":{\"$tsfType\":5},\"optional\":true,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"runMessageHandler\",\"parameters\":[{\"name\":\"handler\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2,\"typeName\":\"SrpcMessageHandlerFn\",\"typeArguments\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":2},{\"kind\":2}]},{\"kind\":2,\"typeName\":\"ClassType\",\"typeArguments\":[{\"kind\":18,\"typeName\":\"ISrpcMessageHandler\",\"types\":[{\"kind\":20,\"name\":\"handle\",\"type\":{\"kind\":2,\"typeName\":\"SrpcMessageHandlerFn\",\"typeArguments\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":2},{\"kind\":2}]},\"optional\":false}]}],\"typeName\":\"TSrpcMessageHandlerClass\"}],\"typeName\":\"TSrpcMessageHandlerFnOrClass\"},\"optional\":false,\"default\":false},{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":0},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":8}},{\"name\":\"onStreamConnected\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":9}},{\"name\":\"onStreamActivated\",\"parameters\":[{\"name\":\"_stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":2}},{\"name\":\"onStreamDisconnected\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"cause\",\"type\":{\"$tsfType\":10},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"cleanupStream\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"cause\",\"type\":{\"$tsfType\":10},\"optional\":true,\"default\":true}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"writeToStream\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"kind\":16,\"typeName\":\"TServerOutput\",\"classType\":{\"$tsf\":5}},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":4}},{\"name\":\"writeToStreamAsync\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"kind\":16,\"typeName\":\"TServerOutput\",\"classType\":{\"$tsf\":5}},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":9}},{\"name\":\"setClientAuthorizer\",\"parameters\":[{\"name\":\"authorizer\",\"type\":{\"$tsfType\":11},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"setClientKeyFetcher\",\"parameters\":[{\"name\":\"fetcher\",\"type\":{\"$tsfType\":12},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"setAuthNonceConsumer\",\"parameters\":[{\"name\":\"consumer\",\"type\":{\"$tsfType\":13},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7},\"description\":\"Installs an atomic service-wide auth-v2 nonce consumer. It must return true only for the first `(principal, nonce)` consumption through `expiresAt`; false rejects a replay. Core retains its fair local guard.\"},{\"name\":\"registerConnectionHandler\",\"parameters\":[{\"name\":\"handler\",\"type\":{\"$tsfType\":14},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"registerMessageHandler\",\"parameters\":[{\"name\":\"prefix\",\"type\":{\"$tsfType\":15},\"optional\":false,\"default\":false},{\"name\":\"handler\",\"type\":{\"kind\":12,\"types\":[{\"kind\":2,\"typeName\":\"SrpcMessageHandlerFn\",\"typeArguments\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":2,\"typeName\":\"HandlerRequestData\",\"typeArguments\":[{\"kind\":16,\"typeName\":\"TClientOutput\",\"classType\":{\"$tsf\":6}},{\"kind\":2,\"typeName\":\"P\"}]},{\"kind\":2,\"typeName\":\"ResponseData\",\"typeArguments\":[{\"kind\":16,\"typeName\":\"TServerOutput\",\"classType\":{\"$tsf\":5}},{\"kind\":2,\"typeName\":\"P\"}]}]},{\"kind\":2,\"typeName\":\"ClassType\",\"typeArguments\":[{\"kind\":18,\"typeName\":\"ISrpcMessageHandler\",\"types\":[{\"kind\":20,\"name\":\"handle\",\"type\":{\"kind\":2,\"typeName\":\"SrpcMessageHandlerFn\",\"typeArguments\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":2,\"typeName\":\"HandlerRequestData\",\"typeArguments\":[{\"kind\":16,\"typeName\":\"TClientOutput\",\"classType\":{\"$tsf\":6}},{\"kind\":2,\"typeName\":\"P\"}]},{\"kind\":2,\"typeName\":\"ResponseData\",\"typeArguments\":[{\"kind\":16,\"typeName\":\"TServerOutput\",\"classType\":{\"$tsf\":5}},{\"kind\":2,\"typeName\":\"P\"}]}]},\"optional\":false}]}],\"typeName\":\"TSrpcMessageHandlerClass\"}],\"typeName\":\"TSrpcMessageHandlerFnOrClass\"},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"registerDisconnectHandler\",\"parameters\":[{\"name\":\"handler\",\"type\":{\"$tsfType\":16},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"registerBroadcastHandler\",\"parameters\":[{\"name\":\"type\",\"type\":{\"$tsfType\":5},\"optional\":false,\"default\":false},{\"name\":\"handler\",\"type\":{\"$tsfType\":17},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":7}},{\"name\":\"broadcast\",\"parameters\":[{\"name\":\"type\",\"type\":{\"$tsfType\":5},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":18},\"optional\":false,\"default\":false},{\"name\":\"options\",\"type\":{\"$tsfType\":19},\"optional\":true,\"default\":false}],\"returnType\":{\"$tsfType\":9}},{\"name\":\"resolveClient\",\"parameters\":[{\"name\":\"clientId\",\"type\":{\"$tsfType\":5},\"optional\":false,\"default\":false}],\"returnType\":{\"kind\":22,\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"SrpcConnection\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"readonly id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"readonly clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"readonly meta\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},{\"kind\":16,\"typeName\":\"TResolvedMeta\",\"classType\":{\"$tsf\":7}}]},\"optional\":false},{\"kind\":20,\"name\":\"readonly connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"readonly connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":4}]}}},{\"name\":\"listClients\",\"parameters\":[],\"returnType\":{\"kind\":22,\"type\":{\"kind\":14,\"type\":{\"kind\":18,\"typeName\":\"SrpcConnection\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"readonly id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"readonly clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"readonly meta\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},{\"kind\":16,\"typeName\":\"TResolvedMeta\",\"classType\":{\"$tsf\":7}}]},\"optional\":false},{\"kind\":20,\"name\":\"readonly connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"readonly connected\",\"type\":{\"kind\":8},\"optional\":false}]}}}},{\"name\":\"disconnectClient\",\"parameters\":[{\"name\":\"streamOrClientId\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":6}]},\"optional\":false,\"default\":false},{\"name\":\"reason\",\"type\":{\"$tsfType\":5},\"optional\":true,\"default\":false}],\"returnType\":{\"$tsfType\":1}},{\"name\":\"updateClientMetadata\",\"parameters\":[{\"name\":\"streamOrClientId\",\"type\":{\"kind\":12,\"types\":[{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},{\"kind\":6}]},\"optional\":false,\"default\":false},{\"name\":\"metadata\",\"type\":{\"kind\":18,\"typeName\":\"Partial\",\"utilityType\":\"Partial\",\"typeArguments\":[{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}}],\"utilityKeys\":[],\"types\":[]},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":1}},{\"name\":\"invoke\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"prefix\",\"type\":{\"$tsfType\":15},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":20},\"optional\":false,\"default\":false},{\"name\":\"timeoutMs\",\"type\":{\"$tsfType\":0},\"optional\":true,\"default\":true}],\"returnType\":{\"$tsfType\":21}},{\"name\":\"invokeWithRequestId\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"prefix\",\"type\":{\"$tsfType\":15},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":20},\"optional\":false,\"default\":false},{\"name\":\"timeoutMs\",\"type\":{\"$tsfType\":3},\"optional\":false,\"default\":false},{\"name\":\"requestId\",\"type\":{\"$tsfType\":5},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":21}},{\"name\":\"encodeMeshInvokeRequest\",\"parameters\":[{\"name\":\"prefix\",\"type\":{\"$tsfType\":5},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":0},\"optional\":false,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"Uint8Array\",\"classType\":{\"$tsf\":8}}},{\"name\":\"decodeMeshInvokeRequest\",\"parameters\":[{\"name\":\"prefix\",\"type\":{\"$tsfType\":5},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"kind\":16,\"typeName\":\"Uint8Array\",\"classType\":{\"$tsf\":8}},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":0}},{\"name\":\"encodeMeshInvokeResponse\",\"parameters\":[{\"name\":\"prefix\",\"type\":{\"$tsfType\":5},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"$tsfType\":0},\"optional\":false,\"default\":false}],\"returnType\":{\"kind\":16,\"typeName\":\"Uint8Array\",\"classType\":{\"$tsf\":8}}},{\"name\":\"decodeMeshInvokeResponse\",\"parameters\":[{\"name\":\"prefix\",\"type\":{\"$tsfType\":5},\"optional\":false,\"default\":false},{\"name\":\"data\",\"type\":{\"kind\":16,\"typeName\":\"Uint8Array\",\"classType\":{\"$tsf\":8}},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":0}},{\"name\":\"reserveByteStreamSenderIds\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"count\",\"type\":{\"$tsfType\":3},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":22}},{\"name\":\"writeByteStreamOperation\",\"parameters\":[{\"name\":\"stream\",\"type\":{\"kind\":18,\"typeName\":\"SrpcStream\",\"types\":[{\"kind\":20,\"name\":\"byteStream\",\"type\":{\"kind\":18,\"typeName\":\"IByteStream\",\"types\":[{\"kind\":20,\"name\":\"parentStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"remoteSenderIdParity\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":0},{\"kind\":10,\"literal\":1}]},{\"kind\":4}]},\"optional\":true}]},\"optional\":false},{\"kind\":20,\"name\":\"$ws\",\"type\":{\"kind\":16,\"typeName\":\"WebSocket\",\"classType\":{\"$tsf\":1}},\"optional\":false},{\"kind\":20,\"name\":\"$queue\",\"type\":{\"kind\":16,\"typeName\":\"Map\",\"classType\":{\"$tsf\":2},\"typeArguments\":[{\"kind\":6},{\"kind\":18,\"typeName\":\"IQueuedRequest\",\"types\":[{\"kind\":20,\"name\":\"exp\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"resolve\",\"type\":{\"kind\":2,\"typeName\":\"(value: unknown) =\\u003e void\"},\"optional\":false},{\"kind\":20,\"name\":\"reject\",\"type\":{\"kind\":2,\"typeName\":\"(err: unknown) =\\u003e void\"},\"optional\":false}]}]},\"optional\":false},{\"kind\":20,\"name\":\"id\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientStreamId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"address\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"clientId\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"appVersion\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"configureTs\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"protocolVersion\",\"type\":{\"kind\":10,\"literal\":2},\"optional\":false},{\"kind\":20,\"name\":\"features\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"ReadonlySet\",\"classType\":{\"$tsf\":3},\"typeArguments\":[{\"kind\":6}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"supersede\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"meta\",\"type\":{\"kind\":16,\"typeName\":\"TMeta\",\"classType\":{\"$tsf\":4}},\"optional\":false},{\"kind\":20,\"name\":\"connectedAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"isActivated\",\"type\":{\"kind\":8},\"optional\":false},{\"kind\":20,\"name\":\"lastPingAt\",\"type\":{\"kind\":7},\"optional\":false},{\"kind\":20,\"name\":\"connected\",\"type\":{\"kind\":8},\"optional\":false}]},\"optional\":false,\"default\":false},{\"name\":\"operation\",\"type\":{\"$tsfType\":23},\"optional\":false,\"default\":false}],\"returnType\":{\"$tsfType\":9}},{\"name\":\"close\",\"parameters\":[],\"returnType\":{\"$tsfType\":7}}],\"hasConstructor\":true,\"constructorParameters\":[{\"name\":\"options\",\"type\":{\"kind\":18,\"typeName\":\"ISrpcServerOptions\",\"types\":[{\"kind\":20,\"name\":\"logger\",\"type\":{\"kind\":18,\"typeName\":\"ISrpcLogger\",\"types\":[]},\"optional\":false},{\"kind\":20,\"name\":\"clientMessage\",\"type\":{\"kind\":18,\"typeName\":\"SrpcMessageFns\",\"types\":[]},\"optional\":false},{\"kind\":20,\"name\":\"serverMessage\",\"type\":{\"kind\":18,\"typeName\":\"SrpcMessageFns\",\"types\":[]},\"optional\":false},{\"kind\":20,\"name\":\"wsPath\",\"type\":{\"kind\":6},\"optional\":false},{\"kind\":20,\"name\":\"debug\",\"type\":{\"kind\":12,\"types\":[{\"kind\":8},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"logLevel\",\"type\":{\"kind\":12,\"types\":[{\"kind\":12,\"types\":[{\"kind\":10,\"literal\":\"info\"},{\"kind\":10,\"literal\":\"debug\"},{\"kind\":10,\"literal\":false}]},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"httpServer\",\"type\":{\"kind\":12,\"types\":[{\"kind\":16,\"typeName\":\"Server\",\"classType\":{\"$tsfImport\":[9,\"node:http\",\"Server\"]}},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"lateReplyTombstoneTtlMs\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingClientRequests\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingClientRequestBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxInFlightClientRequests\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxInFlightClientRequestBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxBufferedBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxMessageBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingServerRequests\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingServerRequestBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxPendingHandshakes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxActiveStreams\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxClientIdBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxClientMetadataBytes\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"maxAuthReplayPrincipals\",\"type\":{\"kind\":12,\"types\":[{\"kind\":7},{\"kind\":4}]},\"optional\":true},{\"kind\":20,\"name\":\"authAudience\",\"type\":{\"kind\":12,\"types\":[{\"kind\":6},{\"kind\":4}]},\"optional\":true}]},\"optional\":false,\"default\":false}]}]", [() => SrpcServer, () => (typeof WebSocket !== "undefined" ? WebSocket : (typeof exports !== "undefined" ? exports.WebSocket : undefined)), () => (typeof Map !== "undefined" ? Map : (typeof exports !== "undefined" ? exports.Map : undefined)), () => (typeof ReadonlySet !== "undefined" ? ReadonlySet : (typeof exports !== "undefined" ? exports.ReadonlySet : undefined)), () => (typeof TMeta !== "undefined" ? TMeta : (typeof exports !== "undefined" ? exports.TMeta : undefined)), () => (typeof TServerOutput !== "undefined" ? TServerOutput : (typeof exports !== "undefined" ? exports.TServerOutput : undefined)), () => (typeof TClientOutput !== "undefined" ? TClientOutput : (typeof exports !== "undefined" ? exports.TClientOutput : undefined)), () => (typeof TResolvedMeta !== "undefined" ? TResolvedMeta : (typeof exports !== "undefined" ? exports.TResolvedMeta : undefined)), () => (typeof Uint8Array !== "undefined" ? Uint8Array : (typeof exports !== "undefined" ? exports.Uint8Array : undefined)), require], __tsf_metadata_type);
593
1126
  }
594
1127
  exports.SrpcServer = SrpcServer;
595
1128
  _SrpcServerMetadata_1.classType = SrpcServer;
@@ -614,6 +1147,76 @@ function toBuffer(data) {
614
1147
  return Buffer.concat(data);
615
1148
  return Buffer.from(data);
616
1149
  }
1150
+ function configuredPositiveInteger(value, defaultValue) {
1151
+ return value != null && Number.isSafeInteger(value) && value > 0 ? value : defaultValue;
1152
+ }
1153
+ function assertTimeout(value) {
1154
+ (0, helpers_1.assertSafeTimerMs)(value, 'Request timeout');
1155
+ }
1156
+ function encodedJsonBytes(value) {
1157
+ const encoded = JSON.stringify(value);
1158
+ if (encoded === undefined)
1159
+ throw new Error('Value must be JSON-serializable');
1160
+ return Buffer.byteLength(encoded);
1161
+ }
1162
+ function validateServerResourceOptions(options) {
1163
+ for (const [name, value] of [
1164
+ ['maxPendingClientRequests', options.maxPendingClientRequests],
1165
+ ['maxPendingClientRequestBytes', options.maxPendingClientRequestBytes],
1166
+ ['maxInFlightClientRequests', options.maxInFlightClientRequests],
1167
+ ['maxInFlightClientRequestBytes', options.maxInFlightClientRequestBytes],
1168
+ ['maxBufferedBytes', options.maxBufferedBytes],
1169
+ ['maxMessageBytes', options.maxMessageBytes],
1170
+ ['maxPendingServerRequests', options.maxPendingServerRequests],
1171
+ ['maxPendingServerRequestBytes', options.maxPendingServerRequestBytes],
1172
+ ['maxPendingHandshakes', options.maxPendingHandshakes],
1173
+ ['maxActiveStreams', options.maxActiveStreams],
1174
+ ['maxClientIdBytes', options.maxClientIdBytes],
1175
+ ['maxClientMetadataBytes', options.maxClientMetadataBytes],
1176
+ ['maxAuthReplayPrincipals', options.maxAuthReplayPrincipals]
1177
+ ]) {
1178
+ if (value !== undefined && (!Number.isSafeInteger(value) || value < 1)) {
1179
+ throw new Error(`sRPC server ${name} must be a positive integer`);
1180
+ }
1181
+ }
1182
+ validateTimerOption('sRPC server lateReplyTombstoneTtlMs', options.lateReplyTombstoneTtlMs);
1183
+ }
1184
+ function validateTimerOption(name, value) {
1185
+ if (value !== undefined && (!Number.isSafeInteger(value) || value < 1 || value > helpers_1.MAX_SAFE_TIMER_MS)) {
1186
+ throw new Error(`${name} must be a safe positive integer between 1 and ${helpers_1.MAX_SAFE_TIMER_MS}`);
1187
+ }
1188
+ }
1189
+ function normalizeFeatures(features) {
1190
+ return [...new Set(features)].sort().join(',');
1191
+ }
1192
+ function normalizeMetadata(meta) {
1193
+ return Object.fromEntries(Object.entries(meta).sort(([a], [b]) => compareCodeUnits(a, b)));
1194
+ }
1195
+ function canonicalAuthV2(fields) {
1196
+ return JSON.stringify({ version: 2, ...fields });
1197
+ }
1198
+ function isAuthToken(value) {
1199
+ return typeof value === 'string' && value.length >= 16 && value.length <= 256 && /^[A-Za-z0-9._-]+$/.test(value);
1200
+ }
1201
+ function compareCodeUnits(a, b) {
1202
+ return a < b ? -1 : a > b ? 1 : 0;
1203
+ }
1204
+ function isPlainObject(value) {
1205
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
1206
+ }
1207
+ function pruneExpiredEntries(entries, now) {
1208
+ for (const [key, expiresAt] of entries)
1209
+ if (expiresAt <= now)
1210
+ entries.delete(key);
1211
+ }
1212
+ function estimateMessageBytes(message) {
1213
+ try {
1214
+ return Buffer.byteLength(JSON.stringify(message));
1215
+ }
1216
+ catch {
1217
+ return DefaultMaxMessageBytes;
1218
+ }
1219
+ }
617
1220
  function closeCodeForCause(cause) {
618
1221
  return { disconnect: 1000, badArg: 4000, conflict: 4001, supersede: 4002, timeout: 4003 }[cause];
619
1222
  }