@naylence/runtime 0.3.5-test.953 → 0.3.5-test.955
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.cjs +133 -530
- package/dist/browser/index.mjs +133 -530
- package/dist/cjs/naylence/fame/channel/flow-controller.js +38 -1
- package/dist/cjs/naylence/fame/connector/broadcast-channel-connector-factory.js +2 -14
- package/dist/cjs/naylence/fame/connector/broadcast-channel-connector.browser.js +51 -109
- package/dist/cjs/naylence/fame/connector/broadcast-channel-listener.js +10 -76
- package/dist/cjs/naylence/fame/connector/inpage-connector-factory.js +0 -12
- package/dist/cjs/naylence/fame/connector/inpage-connector.js +1 -105
- package/dist/cjs/naylence/fame/connector/inpage-listener.js +2 -49
- package/dist/cjs/naylence/fame/grants/broadcast-channel-connection-grant.js +12 -23
- package/dist/cjs/naylence/fame/grants/inpage-connection-grant.js +0 -28
- package/dist/cjs/naylence/fame/node/admission/default-node-attach-client.js +0 -14
- package/dist/cjs/naylence/fame/node/upstream-session-manager.js +0 -6
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/channel/flow-controller.js +38 -1
- package/dist/esm/naylence/fame/connector/broadcast-channel-connector-factory.js +2 -14
- package/dist/esm/naylence/fame/connector/broadcast-channel-connector.browser.js +51 -109
- package/dist/esm/naylence/fame/connector/broadcast-channel-listener.js +10 -76
- package/dist/esm/naylence/fame/connector/inpage-connector-factory.js +0 -12
- package/dist/esm/naylence/fame/connector/inpage-connector.js +1 -105
- package/dist/esm/naylence/fame/connector/inpage-listener.js +2 -49
- package/dist/esm/naylence/fame/grants/broadcast-channel-connection-grant.js +12 -23
- package/dist/esm/naylence/fame/grants/inpage-connection-grant.js +0 -28
- package/dist/esm/naylence/fame/node/admission/default-node-attach-client.js +0 -14
- package/dist/esm/naylence/fame/node/upstream-session-manager.js +0 -6
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +133 -530
- package/dist/node/index.mjs +133 -530
- package/dist/node/node.cjs +133 -546
- package/dist/node/node.mjs +133 -546
- package/dist/types/naylence/fame/connector/broadcast-channel-connector-factory.d.ts +0 -2
- package/dist/types/naylence/fame/connector/broadcast-channel-connector.browser.d.ts +4 -9
- package/dist/types/naylence/fame/connector/inpage-connector-factory.d.ts +0 -2
- package/dist/types/naylence/fame/connector/inpage-connector.d.ts +0 -9
- package/dist/types/naylence/fame/connector/inpage-listener.d.ts +0 -1
- package/dist/types/naylence/fame/grants/broadcast-channel-connection-grant.d.ts +3 -6
- package/dist/types/naylence/fame/grants/inpage-connection-grant.d.ts +0 -8
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/naylence/fame/connector/transport-frame.js +0 -100
- package/dist/esm/naylence/fame/connector/transport-frame.js +0 -93
- package/dist/types/naylence/fame/connector/transport-frame.d.ts +0 -56
|
@@ -7,7 +7,6 @@ import { BROADCAST_CHANNEL_CONNECTOR_TYPE, } from './broadcast-channel-connector
|
|
|
7
7
|
import { GrantSelectionContext, defaultGrantSelectionPolicy, } from './grant-selection-policy.js';
|
|
8
8
|
import { QueueFullError } from '../util/bounded-async-queue.js';
|
|
9
9
|
import { BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE, broadcastChannelGrantToConnectorConfig, } from '../grants/broadcast-channel-connection-grant.js';
|
|
10
|
-
import { unwrapTransportFrame, } from './transport-frame.js';
|
|
11
10
|
const logger = getLogger('naylence.fame.connector.broadcast_channel_listener');
|
|
12
11
|
const DEFAULT_CHANNEL = 'naylence-fabric';
|
|
13
12
|
const DEFAULT_INBOX_CAPACITY = 2048;
|
|
@@ -139,18 +138,13 @@ export class BroadcastChannelListener extends TransportListener {
|
|
|
139
138
|
});
|
|
140
139
|
}
|
|
141
140
|
asCallbackGrant() {
|
|
142
|
-
|
|
141
|
+
return this.withLegacySnakeCaseKeys({
|
|
143
142
|
type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
|
|
144
143
|
connectorType: BROADCAST_CHANNEL_CONNECTOR_TYPE,
|
|
145
144
|
connectionGrantType: BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE,
|
|
146
145
|
channelName: this._channelName,
|
|
147
146
|
inboxCapacity: this._inboxCapacity,
|
|
148
|
-
};
|
|
149
|
-
// Include localNodeId for transport frame multiplexing if node is available
|
|
150
|
-
if (this._routingNode) {
|
|
151
|
-
grant.localNodeId = this._routingNode.id;
|
|
152
|
-
}
|
|
153
|
-
return this.withLegacySnakeCaseKeys(grant);
|
|
147
|
+
});
|
|
154
148
|
}
|
|
155
149
|
_registerChannelListener() {
|
|
156
150
|
if (this._channelHandler) {
|
|
@@ -210,54 +204,23 @@ export class BroadcastChannelListener extends TransportListener {
|
|
|
210
204
|
if (typeof senderId !== 'string' || senderId.length === 0) {
|
|
211
205
|
return null;
|
|
212
206
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
// Apply listener's filtering policy: accept frames addressed to us OR with wildcard destination
|
|
220
|
-
// Wildcard is needed because downstream nodes don't know the sentinel's ID during initial attach
|
|
221
|
-
const isAddressedToUs = frame.dst === this._routingNode.id || frame.dst === '*';
|
|
222
|
-
if (isAddressedToUs) {
|
|
223
|
-
envelopePayload = frame.payload;
|
|
224
|
-
logger.debug('broadcast_channel_listener_unwrapped_transport_frame', {
|
|
225
|
-
sender_id: senderId,
|
|
226
|
-
src: frame.src,
|
|
227
|
-
dst: frame.dst,
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
// Frame addressed to a different node, ignore it
|
|
232
|
-
logger.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
|
|
233
|
-
sender_id: senderId,
|
|
234
|
-
dst: frame.dst,
|
|
235
|
-
expected: this._routingNode.id,
|
|
236
|
-
});
|
|
237
|
-
return null;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
// If not a transport frame, try to coerce as legacy format
|
|
242
|
-
if (!envelopePayload) {
|
|
243
|
-
envelopePayload = coercePayload(record.payload);
|
|
244
|
-
if (!envelopePayload) {
|
|
245
|
-
logger.debug('broadcast_channel_listener_ignored_event_without_payload', {
|
|
246
|
-
sender_id: senderId,
|
|
247
|
-
});
|
|
248
|
-
return null;
|
|
249
|
-
}
|
|
207
|
+
const payload = coercePayload(record.payload);
|
|
208
|
+
if (!payload) {
|
|
209
|
+
logger.debug('broadcast_channel_listener_ignored_event_without_payload', {
|
|
210
|
+
sender_id: senderId,
|
|
211
|
+
});
|
|
212
|
+
return null;
|
|
250
213
|
}
|
|
251
214
|
let envelope;
|
|
252
215
|
try {
|
|
253
|
-
const decoded = new TextDecoder().decode(
|
|
216
|
+
const decoded = new TextDecoder().decode(payload);
|
|
254
217
|
const parsed = JSON.parse(decoded);
|
|
255
218
|
envelope = deserializeEnvelope(parsed);
|
|
256
219
|
}
|
|
257
220
|
catch (error) {
|
|
258
221
|
const decoded = (() => {
|
|
259
222
|
try {
|
|
260
|
-
return new TextDecoder().decode(
|
|
223
|
+
return new TextDecoder().decode(payload);
|
|
261
224
|
}
|
|
262
225
|
catch {
|
|
263
226
|
return null;
|
|
@@ -377,20 +340,6 @@ export class BroadcastChannelListener extends TransportListener {
|
|
|
377
340
|
inboxCapacity: this._inboxCapacity,
|
|
378
341
|
};
|
|
379
342
|
}
|
|
380
|
-
// Automatically configure transport frame multiplexing:
|
|
381
|
-
// Use node IDs (not connector IDs) for node-to-node targeting
|
|
382
|
-
const broadcastConfig = connectorConfig;
|
|
383
|
-
// Always force localNodeId to be this listener's node ID
|
|
384
|
-
// This ensures the sentinel sets localNodeId=sentinel, not the child's ID
|
|
385
|
-
broadcastConfig.localNodeId = routingNode.id;
|
|
386
|
-
// Always force remoteNodeId to be the attaching child's system ID
|
|
387
|
-
broadcastConfig.remoteNodeId = systemId;
|
|
388
|
-
logger.debug('broadcast_channel_listener_configured_node_ids', {
|
|
389
|
-
sender_id: params.senderId,
|
|
390
|
-
system_id: systemId,
|
|
391
|
-
local_node_id: broadcastConfig.localNodeId,
|
|
392
|
-
remote_node_id: broadcastConfig.remoteNodeId,
|
|
393
|
-
});
|
|
394
343
|
try {
|
|
395
344
|
const connector = await routingNode.createOriginConnector({
|
|
396
345
|
originType,
|
|
@@ -460,21 +409,6 @@ export class BroadcastChannelListener extends TransportListener {
|
|
|
460
409
|
inboxCandidate > 0) {
|
|
461
410
|
config.inboxCapacity = Math.floor(inboxCandidate);
|
|
462
411
|
}
|
|
463
|
-
// Extract transport frame multiplexing node IDs
|
|
464
|
-
const localNodeIdCandidate = candidate.localNodeId ?? candidate['local_node_id'];
|
|
465
|
-
if (typeof localNodeIdCandidate === 'string' && localNodeIdCandidate.trim().length > 0) {
|
|
466
|
-
config.localNodeId = localNodeIdCandidate.trim();
|
|
467
|
-
logger.debug('broadcast_channel_listener_extracted_local_node_id', {
|
|
468
|
-
local_node_id: config.localNodeId,
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
const remoteNodeIdCandidate = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
472
|
-
if (typeof remoteNodeIdCandidate === 'string' && remoteNodeIdCandidate.trim().length > 0) {
|
|
473
|
-
config.remoteNodeId = remoteNodeIdCandidate.trim();
|
|
474
|
-
logger.debug('broadcast_channel_listener_extracted_remote_node_id', {
|
|
475
|
-
remote_node_id: config.remoteNodeId,
|
|
476
|
-
});
|
|
477
|
-
}
|
|
478
412
|
return config;
|
|
479
413
|
}
|
|
480
414
|
_monitorConnectorLifecycle(senderId, systemId, connector) {
|
|
@@ -81,8 +81,6 @@ export class InPageConnectorFactory extends ConnectorFactory {
|
|
|
81
81
|
type: INPAGE_CONNECTOR_TYPE,
|
|
82
82
|
channelName,
|
|
83
83
|
inboxCapacity,
|
|
84
|
-
localNodeId: normalized.localNodeId,
|
|
85
|
-
remoteNodeId: normalized.remoteNodeId,
|
|
86
84
|
};
|
|
87
85
|
const connector = new InPageConnector(connectorConfig, baseConfig);
|
|
88
86
|
if (options.authorization) {
|
|
@@ -151,16 +149,6 @@ export class InPageConnectorFactory extends ConnectorFactory {
|
|
|
151
149
|
if (candidate.authorizationContext !== undefined) {
|
|
152
150
|
normalized.authorizationContext = candidate.authorizationContext;
|
|
153
151
|
}
|
|
154
|
-
// Handle localNodeId
|
|
155
|
-
const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
|
|
156
|
-
if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
|
|
157
|
-
normalized.localNodeId = localNodeId.trim();
|
|
158
|
-
}
|
|
159
|
-
// Handle remoteNodeId
|
|
160
|
-
const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
161
|
-
if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
|
|
162
|
-
normalized.remoteNodeId = remoteNodeId.trim();
|
|
163
|
-
}
|
|
164
152
|
normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL;
|
|
165
153
|
normalized.inboxCapacity =
|
|
166
154
|
normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY;
|
|
@@ -7,7 +7,6 @@ import { FameTransportClose } from '../errors/errors.js';
|
|
|
7
7
|
import { getLogger } from '../util/logging.js';
|
|
8
8
|
import { BoundedAsyncQueue, QueueFullError, } from '../util/bounded-async-queue.js';
|
|
9
9
|
import { ConnectorState } from '@naylence/core';
|
|
10
|
-
import { wrapTransportFrame, unwrapTransportFrame, serializeTransportFrame, } from './transport-frame.js';
|
|
11
10
|
const logger = getLogger('naylence.fame.connector.inpage_connector');
|
|
12
11
|
export const INPAGE_CONNECTOR_TYPE = 'inpage-connector';
|
|
13
12
|
const DEFAULT_CHANNEL = 'naylence-fabric';
|
|
@@ -78,20 +77,9 @@ export class InPageConnector extends BaseAsyncConnector {
|
|
|
78
77
|
: DEFAULT_INBOX_CAPACITY;
|
|
79
78
|
this.inbox = new BoundedAsyncQueue(preferredCapacity);
|
|
80
79
|
this.connectorId = InPageConnector.generateConnectorId();
|
|
81
|
-
// Set local and remote node IDs (defaults to connector ID for backwards compatibility)
|
|
82
|
-
this.localNodeId =
|
|
83
|
-
typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
|
|
84
|
-
? config.localNodeId.trim()
|
|
85
|
-
: this.connectorId;
|
|
86
|
-
this.remoteNodeId =
|
|
87
|
-
typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
|
|
88
|
-
? config.remoteNodeId.trim()
|
|
89
|
-
: '*'; // Accept from any remote if not specified
|
|
90
80
|
logger.debug('inpage_connector_initialized', {
|
|
91
81
|
channel: this.channelName,
|
|
92
82
|
connector_id: this.connectorId,
|
|
93
|
-
local_node_id: this.localNodeId,
|
|
94
|
-
remote_node_id: this.remoteNodeId,
|
|
95
83
|
});
|
|
96
84
|
this.onMsg = (event) => {
|
|
97
85
|
const messageEvent = event;
|
|
@@ -125,64 +113,6 @@ export class InPageConnector extends BaseAsyncConnector {
|
|
|
125
113
|
if (busMessage.senderId === this.connectorId) {
|
|
126
114
|
return;
|
|
127
115
|
}
|
|
128
|
-
// Try to unwrap as transport frame
|
|
129
|
-
const frame = unwrapTransportFrame(busMessage.payload);
|
|
130
|
-
if (frame) {
|
|
131
|
-
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
132
|
-
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
133
|
-
const dstMatches = frame.dst === this.localNodeId;
|
|
134
|
-
if (dstMatches && srcMatches) {
|
|
135
|
-
// Successfully received and filtered transport frame
|
|
136
|
-
logger.debug('inpage_transport_frame_received', {
|
|
137
|
-
channel: this.channelName,
|
|
138
|
-
sender_id: busMessage.senderId,
|
|
139
|
-
connector_id: this.connectorId,
|
|
140
|
-
local_node_id: this.localNodeId,
|
|
141
|
-
remote_node_id: this.remoteNodeId,
|
|
142
|
-
frame_src: frame.src,
|
|
143
|
-
frame_dst: frame.dst,
|
|
144
|
-
payload_length: frame.payload.byteLength,
|
|
145
|
-
});
|
|
146
|
-
const unwrapped = frame.payload;
|
|
147
|
-
try {
|
|
148
|
-
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
149
|
-
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
150
|
-
if (accepted) {
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
this.inbox.enqueue(unwrapped);
|
|
155
|
-
}
|
|
156
|
-
catch (error) {
|
|
157
|
-
if (error instanceof QueueFullError) {
|
|
158
|
-
logger.warning('inpage_receive_queue_full', {
|
|
159
|
-
channel: this.channelName,
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
logger.error('inpage_receive_error', {
|
|
164
|
-
channel: this.channelName,
|
|
165
|
-
error: error instanceof Error ? error.message : String(error),
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
// Frame filtered out by addressing rules
|
|
173
|
-
logger.debug('inpage_transport_frame_filtered', {
|
|
174
|
-
channel: this.channelName,
|
|
175
|
-
connector_id: this.connectorId,
|
|
176
|
-
local_node_id: this.localNodeId,
|
|
177
|
-
remote_node_id: this.remoteNodeId,
|
|
178
|
-
frame_src: frame.src,
|
|
179
|
-
frame_dst: frame.dst,
|
|
180
|
-
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
181
|
-
});
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
// Fall back to legacy format (no transport frame)
|
|
186
116
|
const payload = InPageConnector.coercePayload(busMessage.payload);
|
|
187
117
|
if (!payload) {
|
|
188
118
|
logger.debug('inpage_payload_rejected', {
|
|
@@ -341,27 +271,11 @@ export class InPageConnector extends BaseAsyncConnector {
|
|
|
341
271
|
logger.debug('inpage_message_sending', {
|
|
342
272
|
channel: this.channelName,
|
|
343
273
|
sender_id: this.connectorId,
|
|
344
|
-
local_node_id: this.localNodeId,
|
|
345
|
-
remote_node_id: this.remoteNodeId,
|
|
346
274
|
});
|
|
347
|
-
// Only use transport framing if both localNodeId and remoteNodeId are explicitly set
|
|
348
|
-
// (not using default values). This ensures backwards compatibility.
|
|
349
|
-
const useTransportFrame = this.localNodeId !== this.connectorId ||
|
|
350
|
-
this.remoteNodeId !== '*';
|
|
351
|
-
let payload;
|
|
352
|
-
if (useTransportFrame) {
|
|
353
|
-
// Wrap payload in transport frame
|
|
354
|
-
const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
|
|
355
|
-
payload = serializeTransportFrame(frame);
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
// Legacy format: send raw payload
|
|
359
|
-
payload = data;
|
|
360
|
-
}
|
|
361
275
|
const event = new MessageEvent(this.channelName, {
|
|
362
276
|
data: {
|
|
363
277
|
senderId: this.connectorId,
|
|
364
|
-
payload,
|
|
278
|
+
payload: data,
|
|
365
279
|
},
|
|
366
280
|
});
|
|
367
281
|
getSharedBus().dispatchEvent(event);
|
|
@@ -390,22 +304,4 @@ export class InPageConnector extends BaseAsyncConnector {
|
|
|
390
304
|
}
|
|
391
305
|
return rawOrEnvelope;
|
|
392
306
|
}
|
|
393
|
-
/**
|
|
394
|
-
* Update the remote node ID after learning it from NodeAttachAck
|
|
395
|
-
* This allows upstream connectors to switch from wildcard to specific addressing
|
|
396
|
-
*/
|
|
397
|
-
updateRemoteNodeId(newRemoteNodeId) {
|
|
398
|
-
if (typeof newRemoteNodeId !== 'string' || newRemoteNodeId.trim().length === 0) {
|
|
399
|
-
throw new Error('Invalid remote node ID');
|
|
400
|
-
}
|
|
401
|
-
const oldValue = this.remoteNodeId;
|
|
402
|
-
this.remoteNodeId = newRemoteNodeId.trim();
|
|
403
|
-
logger.debug('inpage_connector_remote_node_id_updated', {
|
|
404
|
-
channel: this.channelName,
|
|
405
|
-
connector_id: this.connectorId,
|
|
406
|
-
local_node_id: this.localNodeId,
|
|
407
|
-
old_remote_node_id: oldValue,
|
|
408
|
-
new_remote_node_id: this.remoteNodeId,
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
307
|
}
|
|
@@ -61,7 +61,6 @@ export class InPageListener extends TransportListener {
|
|
|
61
61
|
this._busHandler = null;
|
|
62
62
|
this._senderRegistry = new Map();
|
|
63
63
|
this._systemToSender = new Map();
|
|
64
|
-
this._flowIdToSender = new Map();
|
|
65
64
|
this._pendingAttachments = new Map();
|
|
66
65
|
ensureBrowserEnvironment();
|
|
67
66
|
const channelCandidate = options?.channelName;
|
|
@@ -128,7 +127,6 @@ export class InPageListener extends TransportListener {
|
|
|
128
127
|
this._unregisterBusListener();
|
|
129
128
|
this._senderRegistry.clear();
|
|
130
129
|
this._systemToSender.clear();
|
|
131
|
-
this._flowIdToSender.clear();
|
|
132
130
|
this._pendingAttachments.clear();
|
|
133
131
|
logger.debug('inpage_listener_stopped', {
|
|
134
132
|
channel: this._channelName,
|
|
@@ -182,25 +180,10 @@ export class InPageListener extends TransportListener {
|
|
|
182
180
|
await this._handleAttachFrame(senderId, envelope);
|
|
183
181
|
return;
|
|
184
182
|
}
|
|
185
|
-
|
|
186
|
-
let entry = this._senderRegistry.get(senderId);
|
|
187
|
-
// If not found and we have a flowId, try to route based on flow
|
|
188
|
-
if (!entry && envelope.flowId) {
|
|
189
|
-
const originalSenderId = this._flowIdToSender.get(envelope.flowId);
|
|
190
|
-
if (originalSenderId) {
|
|
191
|
-
entry = this._senderRegistry.get(originalSenderId);
|
|
192
|
-
logger.debug('inpage_listener_routed_by_flow_id', {
|
|
193
|
-
sender_id: senderId,
|
|
194
|
-
original_sender_id: originalSenderId,
|
|
195
|
-
flow_id: envelope.flowId,
|
|
196
|
-
frame_type: envelope.frame?.type ?? 'unknown',
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
}
|
|
183
|
+
const entry = this._senderRegistry.get(senderId);
|
|
200
184
|
if (!entry) {
|
|
201
185
|
logger.debug('inpage_listener_no_connector_for_sender', {
|
|
202
186
|
sender_id: senderId,
|
|
203
|
-
flow_id: envelope.flowId,
|
|
204
187
|
frame_type: envelope.frame?.type ?? 'unknown',
|
|
205
188
|
});
|
|
206
189
|
return;
|
|
@@ -277,15 +260,6 @@ export class InPageListener extends TransportListener {
|
|
|
277
260
|
}
|
|
278
261
|
this._senderRegistry.set(senderId, entry);
|
|
279
262
|
this._systemToSender.set(entry.systemId, senderId);
|
|
280
|
-
// Track the flowId if present so we can route responses back
|
|
281
|
-
if (envelope.flowId) {
|
|
282
|
-
this._flowIdToSender.set(envelope.flowId, senderId);
|
|
283
|
-
logger.debug('inpage_listener_registered_flow_id', {
|
|
284
|
-
sender_id: senderId,
|
|
285
|
-
system_id: entry.systemId,
|
|
286
|
-
flow_id: envelope.flowId,
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
263
|
await this._deliverEnvelope(entry, envelope);
|
|
290
264
|
}
|
|
291
265
|
async _createConnectorForAttach(params) {
|
|
@@ -333,7 +307,7 @@ export class InPageListener extends TransportListener {
|
|
|
333
307
|
origin_type: originType,
|
|
334
308
|
connector_type: connector.constructor?.name ?? 'unknown',
|
|
335
309
|
});
|
|
336
|
-
return { connector, systemId, originType
|
|
310
|
+
return { connector, systemId, originType };
|
|
337
311
|
}
|
|
338
312
|
catch (error) {
|
|
339
313
|
logger.error('inpage_listener_connector_creation_failed', {
|
|
@@ -387,12 +361,6 @@ export class InPageListener extends TransportListener {
|
|
|
387
361
|
if (this._systemToSender.get(systemId) === senderId) {
|
|
388
362
|
this._systemToSender.delete(systemId);
|
|
389
363
|
}
|
|
390
|
-
// Clean up flowId mappings for this sender
|
|
391
|
-
for (const [flowId, sid] of this._flowIdToSender.entries()) {
|
|
392
|
-
if (sid === senderId) {
|
|
393
|
-
this._flowIdToSender.delete(flowId);
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
364
|
})
|
|
397
365
|
.catch((error) => {
|
|
398
366
|
logger.debug('inpage_listener_wait_until_closed_failed', {
|
|
@@ -404,24 +372,9 @@ export class InPageListener extends TransportListener {
|
|
|
404
372
|
if (this._systemToSender.get(systemId) === senderId) {
|
|
405
373
|
this._systemToSender.delete(systemId);
|
|
406
374
|
}
|
|
407
|
-
// Clean up flowId mappings for this sender
|
|
408
|
-
for (const [flowId, sid] of this._flowIdToSender.entries()) {
|
|
409
|
-
if (sid === senderId) {
|
|
410
|
-
this._flowIdToSender.delete(flowId);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
375
|
});
|
|
414
376
|
}
|
|
415
377
|
async _deliverEnvelope(entry, envelope) {
|
|
416
|
-
// Track flowId for routing responses back
|
|
417
|
-
if (envelope.flowId && !this._flowIdToSender.has(envelope.flowId)) {
|
|
418
|
-
this._flowIdToSender.set(envelope.flowId, entry.senderId);
|
|
419
|
-
logger.debug('inpage_listener_registered_flow_id_on_delivery', {
|
|
420
|
-
sender_id: entry.senderId,
|
|
421
|
-
system_id: entry.systemId,
|
|
422
|
-
flow_id: envelope.flowId,
|
|
423
|
-
});
|
|
424
|
-
}
|
|
425
378
|
const message = this._buildChannelMessage({
|
|
426
379
|
envelope,
|
|
427
380
|
connector: entry.connector,
|
|
@@ -19,12 +19,9 @@ export function isBroadcastChannelConnectionGrant(candidate) {
|
|
|
19
19
|
record.inboxCapacity <= 0)) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
|
-
if (record.
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
if (record.remoteNodeId !== undefined &&
|
|
27
|
-
(typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
|
|
22
|
+
if (record.initialWindow !== undefined &&
|
|
23
|
+
(!Number.isFinite(record.initialWindow) ||
|
|
24
|
+
record.initialWindow <= 0)) {
|
|
28
25
|
return false;
|
|
29
26
|
}
|
|
30
27
|
return true;
|
|
@@ -60,19 +57,14 @@ export function normalizeBroadcastChannelConnectionGrant(candidate) {
|
|
|
60
57
|
}
|
|
61
58
|
result.inboxCapacity = Math.floor(inboxValue);
|
|
62
59
|
}
|
|
63
|
-
const
|
|
64
|
-
if (
|
|
65
|
-
if (typeof
|
|
66
|
-
|
|
60
|
+
const windowValue = candidate.initialWindow ?? candidate['initial_window'];
|
|
61
|
+
if (windowValue !== undefined) {
|
|
62
|
+
if (typeof windowValue !== 'number' ||
|
|
63
|
+
!Number.isFinite(windowValue) ||
|
|
64
|
+
windowValue <= 0) {
|
|
65
|
+
throw new TypeError('BroadcastChannelConnectionGrant "initialWindow" must be a positive number when provided');
|
|
67
66
|
}
|
|
68
|
-
result.
|
|
69
|
-
}
|
|
70
|
-
const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
71
|
-
if (remoteNodeIdValue !== undefined) {
|
|
72
|
-
if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
|
|
73
|
-
throw new TypeError('BroadcastChannelConnectionGrant "remoteNodeId" must be a non-empty string when provided');
|
|
74
|
-
}
|
|
75
|
-
result.remoteNodeId = remoteNodeIdValue.trim();
|
|
67
|
+
result.initialWindow = Math.floor(windowValue);
|
|
76
68
|
}
|
|
77
69
|
return result;
|
|
78
70
|
}
|
|
@@ -87,11 +79,8 @@ export function broadcastChannelGrantToConnectorConfig(grant) {
|
|
|
87
79
|
if (normalized.inboxCapacity !== undefined) {
|
|
88
80
|
config.inboxCapacity = normalized.inboxCapacity;
|
|
89
81
|
}
|
|
90
|
-
if (normalized.
|
|
91
|
-
config.
|
|
92
|
-
}
|
|
93
|
-
if (normalized.remoteNodeId) {
|
|
94
|
-
config.remoteNodeId = normalized.remoteNodeId;
|
|
82
|
+
if (normalized.initialWindow !== undefined) {
|
|
83
|
+
config.initialWindow = normalized.initialWindow;
|
|
95
84
|
}
|
|
96
85
|
return config;
|
|
97
86
|
}
|
|
@@ -19,14 +19,6 @@ export function isInPageConnectionGrant(candidate) {
|
|
|
19
19
|
record.inboxCapacity <= 0)) {
|
|
20
20
|
return false;
|
|
21
21
|
}
|
|
22
|
-
if (record.localNodeId !== undefined &&
|
|
23
|
-
(typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
if (record.remoteNodeId !== undefined &&
|
|
27
|
-
(typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
22
|
return true;
|
|
31
23
|
}
|
|
32
24
|
export function normalizeInPageConnectionGrant(candidate) {
|
|
@@ -60,20 +52,6 @@ export function normalizeInPageConnectionGrant(candidate) {
|
|
|
60
52
|
}
|
|
61
53
|
result.inboxCapacity = Math.floor(inboxValue);
|
|
62
54
|
}
|
|
63
|
-
const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
|
|
64
|
-
if (localNodeIdValue !== undefined) {
|
|
65
|
-
if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
|
|
66
|
-
throw new TypeError('InPageConnectionGrant "localNodeId" must be a non-empty string when provided');
|
|
67
|
-
}
|
|
68
|
-
result.localNodeId = localNodeIdValue.trim();
|
|
69
|
-
}
|
|
70
|
-
const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
71
|
-
if (remoteNodeIdValue !== undefined) {
|
|
72
|
-
if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
|
|
73
|
-
throw new TypeError('InPageConnectionGrant "remoteNodeId" must be a non-empty string when provided');
|
|
74
|
-
}
|
|
75
|
-
result.remoteNodeId = remoteNodeIdValue.trim();
|
|
76
|
-
}
|
|
77
55
|
return result;
|
|
78
56
|
}
|
|
79
57
|
export function inPageGrantToConnectorConfig(grant) {
|
|
@@ -87,11 +65,5 @@ export function inPageGrantToConnectorConfig(grant) {
|
|
|
87
65
|
if (normalized.inboxCapacity !== undefined) {
|
|
88
66
|
config.inboxCapacity = normalized.inboxCapacity;
|
|
89
67
|
}
|
|
90
|
-
if (normalized.localNodeId) {
|
|
91
|
-
config.localNodeId = normalized.localNodeId;
|
|
92
|
-
}
|
|
93
|
-
if (normalized.remoteNodeId) {
|
|
94
|
-
config.remoteNodeId = normalized.remoteNodeId;
|
|
95
|
-
}
|
|
96
68
|
return config;
|
|
97
69
|
}
|
|
@@ -163,20 +163,6 @@ export class DefaultNodeAttachClient {
|
|
|
163
163
|
if (!targetSystemId) {
|
|
164
164
|
throw new Error('Target system ID must be set in NodeAttachAckFrame on success');
|
|
165
165
|
}
|
|
166
|
-
// Update connector's remote node ID if it supports it (e.g., BroadcastChannelConnector, InPageConnector)
|
|
167
|
-
// This allows upstream connectors to switch from wildcard '*' to specific node addressing
|
|
168
|
-
const updatableConnector = connector;
|
|
169
|
-
if (typeof updatableConnector.updateRemoteNodeId === 'function') {
|
|
170
|
-
try {
|
|
171
|
-
updatableConnector.updateRemoteNodeId(targetSystemId);
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
logger.debug('connector_remote_node_id_update_failed', {
|
|
175
|
-
target_system_id: targetSystemId,
|
|
176
|
-
error: error instanceof Error ? error.message : String(error),
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
166
|
try {
|
|
181
167
|
if (this.replicaStickinessManager) {
|
|
182
168
|
this.replicaStickinessManager.accept(ackFrame.stickiness ?? null);
|
|
@@ -296,12 +296,6 @@ export class UpstreamSessionManager extends TaskSpawner {
|
|
|
296
296
|
cryptoProvider.prepareForAttach(welcome.frame.systemId, welcome.frame.assignedPath, welcome.frame.acceptedLogicals ?? []);
|
|
297
297
|
}
|
|
298
298
|
await this.onWelcome(welcome.frame);
|
|
299
|
-
// Inject node ID into grant for transport frame multiplexing
|
|
300
|
-
// This ensures localNodeId matches the node's systemId for proper frame filtering
|
|
301
|
-
grant.localNodeId = welcome.frame.systemId;
|
|
302
|
-
if (welcome.frame.targetSystemId) {
|
|
303
|
-
grant.remoteNodeId = welcome.frame.targetSystemId;
|
|
304
|
-
}
|
|
305
299
|
const connector = await ConnectorFactory.createConnector(grant, {
|
|
306
300
|
systemId: welcome.frame.systemId,
|
|
307
301
|
});
|
package/dist/esm/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// This file is auto-generated during build - do not edit manually
|
|
2
|
-
// Generated from package.json version: 0.3.5-test.
|
|
2
|
+
// Generated from package.json version: 0.3.5-test.955
|
|
3
3
|
/**
|
|
4
4
|
* The package version, injected at build time.
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export const VERSION = '0.3.5-test.
|
|
7
|
+
export const VERSION = '0.3.5-test.955';
|