@naylence/runtime 0.3.5-test.953 → 0.3.5-test.954

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 (40) hide show
  1. package/dist/browser/index.cjs +32 -514
  2. package/dist/browser/index.mjs +32 -514
  3. package/dist/cjs/naylence/fame/connector/broadcast-channel-connector-factory.js +2 -14
  4. package/dist/cjs/naylence/fame/connector/broadcast-channel-connector.browser.js +1 -108
  5. package/dist/cjs/naylence/fame/connector/broadcast-channel-listener.js +10 -76
  6. package/dist/cjs/naylence/fame/connector/inpage-connector-factory.js +0 -12
  7. package/dist/cjs/naylence/fame/connector/inpage-connector.js +1 -105
  8. package/dist/cjs/naylence/fame/connector/inpage-listener.js +2 -49
  9. package/dist/cjs/naylence/fame/grants/broadcast-channel-connection-grant.js +12 -23
  10. package/dist/cjs/naylence/fame/grants/inpage-connection-grant.js +0 -28
  11. package/dist/cjs/naylence/fame/node/admission/default-node-attach-client.js +0 -14
  12. package/dist/cjs/naylence/fame/node/upstream-session-manager.js +0 -6
  13. package/dist/cjs/version.js +2 -2
  14. package/dist/esm/naylence/fame/connector/broadcast-channel-connector-factory.js +2 -14
  15. package/dist/esm/naylence/fame/connector/broadcast-channel-connector.browser.js +1 -108
  16. package/dist/esm/naylence/fame/connector/broadcast-channel-listener.js +10 -76
  17. package/dist/esm/naylence/fame/connector/inpage-connector-factory.js +0 -12
  18. package/dist/esm/naylence/fame/connector/inpage-connector.js +1 -105
  19. package/dist/esm/naylence/fame/connector/inpage-listener.js +2 -49
  20. package/dist/esm/naylence/fame/grants/broadcast-channel-connection-grant.js +12 -23
  21. package/dist/esm/naylence/fame/grants/inpage-connection-grant.js +0 -28
  22. package/dist/esm/naylence/fame/node/admission/default-node-attach-client.js +0 -14
  23. package/dist/esm/naylence/fame/node/upstream-session-manager.js +0 -6
  24. package/dist/esm/version.js +2 -2
  25. package/dist/node/index.cjs +32 -514
  26. package/dist/node/index.mjs +32 -514
  27. package/dist/node/node.cjs +32 -530
  28. package/dist/node/node.mjs +32 -530
  29. package/dist/types/naylence/fame/connector/broadcast-channel-connector-factory.d.ts +0 -2
  30. package/dist/types/naylence/fame/connector/broadcast-channel-connector.browser.d.ts +1 -9
  31. package/dist/types/naylence/fame/connector/inpage-connector-factory.d.ts +0 -2
  32. package/dist/types/naylence/fame/connector/inpage-connector.d.ts +0 -9
  33. package/dist/types/naylence/fame/connector/inpage-listener.d.ts +0 -1
  34. package/dist/types/naylence/fame/grants/broadcast-channel-connection-grant.d.ts +3 -6
  35. package/dist/types/naylence/fame/grants/inpage-connection-grant.d.ts +0 -8
  36. package/dist/types/version.d.ts +1 -1
  37. package/package.json +1 -1
  38. package/dist/cjs/naylence/fame/connector/transport-frame.js +0 -100
  39. package/dist/esm/naylence/fame/connector/transport-frame.js +0 -93
  40. package/dist/types/naylence/fame/connector/transport-frame.d.ts +0 -56
@@ -14,12 +14,12 @@ var fastify = require('fastify');
14
14
  var websocketPlugin = require('@fastify/websocket');
15
15
 
16
16
  // This file is auto-generated during build - do not edit manually
17
- // Generated from package.json version: 0.3.5-test.953
17
+ // Generated from package.json version: 0.3.5-test.954
18
18
  /**
19
19
  * The package version, injected at build time.
20
20
  * @internal
21
21
  */
22
- const VERSION = '0.3.5-test.953';
22
+ const VERSION = '0.3.5-test.954';
23
23
 
24
24
  /**
25
25
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -9734,84 +9734,6 @@ class BoundedAsyncQueue {
9734
9734
  }
9735
9735
  }
9736
9736
 
9737
- /**
9738
- * Transport frame layer for multiplexing logical links on physical channels.
9739
- *
9740
- * This lightweight framing layer wraps raw FAME payloads to enable multiple
9741
- * logical connections over a single physical channel (BroadcastChannel or InPage bus).
9742
- *
9743
- * The transport frame does NOT modify FAME envelopes - it only wraps the raw
9744
- * Uint8Array payload at the connector level.
9745
- */
9746
- /**
9747
- * Transport frame version for future compatibility
9748
- */
9749
- const TRANSPORT_FRAME_VERSION = 1;
9750
- /**
9751
- * Wrap a raw payload in a transport frame
9752
- *
9753
- * @param payload - Raw FAME envelope bytes
9754
- * @param srcNodeId - Local node ID (this connector)
9755
- * @param dstNodeId - Remote node ID (target connector)
9756
- * @returns Transport frame ready for transmission
9757
- */
9758
- function wrapTransportFrame(payload, srcNodeId, dstNodeId) {
9759
- return {
9760
- v: TRANSPORT_FRAME_VERSION,
9761
- src: srcNodeId,
9762
- dst: dstNodeId,
9763
- payload,
9764
- };
9765
- }
9766
- /**
9767
- * Serialize a transport frame for transmission over the bus
9768
- *
9769
- * @param frame - Transport frame to serialize
9770
- * @returns Serialized frame data ready for postMessage/dispatchEvent
9771
- */
9772
- function serializeTransportFrame(frame) {
9773
- // Convert Uint8Array to regular array for JSON serialization
9774
- const serializable = {
9775
- v: frame.v,
9776
- src: frame.src,
9777
- dst: frame.dst,
9778
- payload: Array.from(frame.payload),
9779
- };
9780
- return serializable;
9781
- }
9782
- /**
9783
- * Unwrap a transport frame (pure deserializer - no filtering)
9784
- *
9785
- * @param raw - Raw data from the bus
9786
- * @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
9787
- */
9788
- function unwrapTransportFrame(raw) {
9789
- // Validate basic structure
9790
- if (!raw || typeof raw !== 'object') {
9791
- return null;
9792
- }
9793
- const frame = raw;
9794
- // Check version
9795
- if (frame.v !== TRANSPORT_FRAME_VERSION) {
9796
- return null;
9797
- }
9798
- // Check src and dst
9799
- if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
9800
- return null;
9801
- }
9802
- // Extract payload
9803
- if (!frame.payload || !Array.isArray(frame.payload)) {
9804
- return null;
9805
- }
9806
- // Convert array back to Uint8Array and return full frame
9807
- return {
9808
- v: frame.v,
9809
- src: frame.src,
9810
- dst: frame.dst,
9811
- payload: Uint8Array.from(frame.payload),
9812
- };
9813
- }
9814
-
9815
9737
  const logger$_ = getLogger('naylence.fame.connector.broadcast_channel_connector');
9816
9738
  const BROADCAST_CHANNEL_CONNECTOR_TYPE = 'broadcast-channel-connector';
9817
9739
  const DEFAULT_CHANNEL$7 = 'naylence-fabric';
@@ -9877,20 +9799,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9877
9799
  this.inbox = new BoundedAsyncQueue(preferredCapacity);
9878
9800
  this.connectorId = BroadcastChannelConnector.generateConnectorId();
9879
9801
  this.channel = new BroadcastChannel(this.channelName);
9880
- // Set local and remote node IDs (defaults to connector ID for backwards compatibility)
9881
- this.localNodeId =
9882
- typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
9883
- ? config.localNodeId.trim()
9884
- : this.connectorId;
9885
- this.remoteNodeId =
9886
- typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
9887
- ? config.remoteNodeId.trim()
9888
- : '*'; // Accept from any remote if not specified
9889
9802
  logger$_.debug('broadcast_channel_connector_created', {
9890
9803
  channel: this.channelName,
9891
9804
  connector_id: this.connectorId,
9892
- local_node_id: this.localNodeId,
9893
- remote_node_id: this.remoteNodeId,
9894
9805
  inbox_capacity: preferredCapacity,
9895
9806
  timestamp: new Date().toISOString(),
9896
9807
  });
@@ -9923,67 +9834,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9923
9834
  if (busMessage.senderId === this.connectorId) {
9924
9835
  return;
9925
9836
  }
9926
- // Try to unwrap as transport frame
9927
- const frame = unwrapTransportFrame(busMessage.payload);
9928
- if (frame) {
9929
- // Apply connector's filtering policy: strict dst check, src accepts wildcard
9930
- const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
9931
- const dstMatches = frame.dst === this.localNodeId;
9932
- if (dstMatches && srcMatches) {
9933
- // Successfully received and filtered transport frame
9934
- logger$_.debug('broadcast_channel_transport_frame_received', {
9935
- channel: this.channelName,
9936
- sender_id: busMessage.senderId,
9937
- connector_id: this.connectorId,
9938
- local_node_id: this.localNodeId,
9939
- remote_node_id: this.remoteNodeId,
9940
- frame_src: frame.src,
9941
- frame_dst: frame.dst,
9942
- payload_length: frame.payload.byteLength,
9943
- });
9944
- const unwrapped = frame.payload;
9945
- if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
9946
- return;
9947
- }
9948
- try {
9949
- if (typeof this.inbox.tryEnqueue === 'function') {
9950
- const accepted = this.inbox.tryEnqueue(unwrapped);
9951
- if (accepted) {
9952
- return;
9953
- }
9954
- }
9955
- this.inbox.enqueue(unwrapped);
9956
- }
9957
- catch (error) {
9958
- if (error instanceof QueueFullError) {
9959
- logger$_.warning('broadcast_channel_receive_queue_full', {
9960
- channel: this.channelName,
9961
- });
9962
- }
9963
- else {
9964
- logger$_.error('broadcast_channel_receive_error', {
9965
- channel: this.channelName,
9966
- error: error instanceof Error ? error.message : String(error),
9967
- });
9968
- }
9969
- }
9970
- return;
9971
- }
9972
- else {
9973
- // Frame filtered out by addressing rules
9974
- logger$_.debug('broadcast_channel_transport_frame_filtered', {
9975
- channel: this.channelName,
9976
- connector_id: this.connectorId,
9977
- local_node_id: this.localNodeId,
9978
- remote_node_id: this.remoteNodeId,
9979
- frame_src: frame.src,
9980
- frame_dst: frame.dst,
9981
- reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
9982
- });
9983
- return;
9984
- }
9985
- }
9986
- // Fall back to legacy format (no transport frame)
9987
9837
  const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
9988
9838
  if (!payload) {
9989
9839
  logger$_.debug('broadcast_channel_payload_rejected', {
@@ -10122,26 +9972,10 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10122
9972
  logger$_.debug('broadcast_channel_message_sending', {
10123
9973
  channel: this.channelName,
10124
9974
  sender_id: this.connectorId,
10125
- local_node_id: this.localNodeId,
10126
- remote_node_id: this.remoteNodeId,
10127
- });
10128
- // Only use transport framing if both localNodeId and remoteNodeId are explicitly set
10129
- // (not using default values). This ensures backwards compatibility.
10130
- const useTransportFrame = this.localNodeId !== this.connectorId ||
10131
- this.remoteNodeId !== '*';
10132
- let payload;
10133
- if (useTransportFrame) {
10134
- // Wrap payload in transport frame
10135
- const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
10136
- payload = serializeTransportFrame(frame);
10137
- }
10138
- else {
10139
- // Legacy format: send raw payload
10140
- payload = data;
10141
- }
9975
+ });
10142
9976
  this.channel.postMessage({
10143
9977
  senderId: this.connectorId,
10144
- payload,
9978
+ payload: data,
10145
9979
  });
10146
9980
  }
10147
9981
  async _transportReceive() {
@@ -10297,24 +10131,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10297
10131
  });
10298
10132
  }
10299
10133
  }
10300
- /**
10301
- * Update the remote node ID after learning it from NodeAttachAck
10302
- * This allows upstream connectors to switch from wildcard to specific addressing
10303
- */
10304
- updateRemoteNodeId(newRemoteNodeId) {
10305
- if (typeof newRemoteNodeId !== 'string' || newRemoteNodeId.trim().length === 0) {
10306
- throw new Error('Invalid remote node ID');
10307
- }
10308
- const oldValue = this.remoteNodeId;
10309
- this.remoteNodeId = newRemoteNodeId.trim();
10310
- logger$_.debug('broadcast_channel_connector_remote_node_id_updated', {
10311
- channel: this.channelName,
10312
- connector_id: this.connectorId,
10313
- local_node_id: this.localNodeId,
10314
- old_remote_node_id: oldValue,
10315
- new_remote_node_id: this.remoteNodeId,
10316
- });
10317
- }
10318
10134
  _trimSeenAcks(now) {
10319
10135
  while (this.seenAckOrder.length > 0) {
10320
10136
  const candidate = this.seenAckOrder[0];
@@ -10452,12 +10268,9 @@ function isBroadcastChannelConnectionGrant(candidate) {
10452
10268
  record.inboxCapacity <= 0)) {
10453
10269
  return false;
10454
10270
  }
10455
- if (record.localNodeId !== undefined &&
10456
- (typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
10457
- return false;
10458
- }
10459
- if (record.remoteNodeId !== undefined &&
10460
- (typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
10271
+ if (record.initialWindow !== undefined &&
10272
+ (!Number.isFinite(record.initialWindow) ||
10273
+ record.initialWindow <= 0)) {
10461
10274
  return false;
10462
10275
  }
10463
10276
  return true;
@@ -10493,19 +10306,14 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
10493
10306
  }
10494
10307
  result.inboxCapacity = Math.floor(inboxValue);
10495
10308
  }
10496
- const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
10497
- if (localNodeIdValue !== undefined) {
10498
- if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
10499
- throw new TypeError('BroadcastChannelConnectionGrant "localNodeId" must be a non-empty string when provided');
10309
+ const windowValue = candidate.initialWindow ?? candidate['initial_window'];
10310
+ if (windowValue !== undefined) {
10311
+ if (typeof windowValue !== 'number' ||
10312
+ !Number.isFinite(windowValue) ||
10313
+ windowValue <= 0) {
10314
+ throw new TypeError('BroadcastChannelConnectionGrant "initialWindow" must be a positive number when provided');
10500
10315
  }
10501
- result.localNodeId = localNodeIdValue.trim();
10502
- }
10503
- const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
10504
- if (remoteNodeIdValue !== undefined) {
10505
- if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
10506
- throw new TypeError('BroadcastChannelConnectionGrant "remoteNodeId" must be a non-empty string when provided');
10507
- }
10508
- result.remoteNodeId = remoteNodeIdValue.trim();
10316
+ result.initialWindow = Math.floor(windowValue);
10509
10317
  }
10510
10318
  return result;
10511
10319
  }
@@ -10520,11 +10328,8 @@ function broadcastChannelGrantToConnectorConfig(grant) {
10520
10328
  if (normalized.inboxCapacity !== undefined) {
10521
10329
  config.inboxCapacity = normalized.inboxCapacity;
10522
10330
  }
10523
- if (normalized.localNodeId) {
10524
- config.localNodeId = normalized.localNodeId;
10525
- }
10526
- if (normalized.remoteNodeId) {
10527
- config.remoteNodeId = normalized.remoteNodeId;
10331
+ if (normalized.initialWindow !== undefined) {
10332
+ config.initialWindow = normalized.initialWindow;
10528
10333
  }
10529
10334
  return config;
10530
10335
  }
@@ -10816,12 +10621,6 @@ class UpstreamSessionManager extends TaskSpawner {
10816
10621
  cryptoProvider.prepareForAttach(welcome.frame.systemId, welcome.frame.assignedPath, welcome.frame.acceptedLogicals ?? []);
10817
10622
  }
10818
10623
  await this.onWelcome(welcome.frame);
10819
- // Inject node ID into grant for transport frame multiplexing
10820
- // This ensures localNodeId matches the node's systemId for proper frame filtering
10821
- grant.localNodeId = welcome.frame.systemId;
10822
- if (welcome.frame.targetSystemId) {
10823
- grant.remoteNodeId = welcome.frame.targetSystemId;
10824
- }
10825
10624
  const connector = await ConnectorFactory.createConnector(grant, {
10826
10625
  systemId: welcome.frame.systemId,
10827
10626
  });
@@ -12778,20 +12577,6 @@ class DefaultNodeAttachClient {
12778
12577
  if (!targetSystemId) {
12779
12578
  throw new Error('Target system ID must be set in NodeAttachAckFrame on success');
12780
12579
  }
12781
- // Update connector's remote node ID if it supports it (e.g., BroadcastChannelConnector, InPageConnector)
12782
- // This allows upstream connectors to switch from wildcard '*' to specific node addressing
12783
- const updatableConnector = connector;
12784
- if (typeof updatableConnector.updateRemoteNodeId === 'function') {
12785
- try {
12786
- updatableConnector.updateRemoteNodeId(targetSystemId);
12787
- }
12788
- catch (error) {
12789
- logger$W.debug('connector_remote_node_id_update_failed', {
12790
- target_system_id: targetSystemId,
12791
- error: error instanceof Error ? error.message : String(error),
12792
- });
12793
- }
12794
- }
12795
12580
  try {
12796
12581
  if (this.replicaStickinessManager) {
12797
12582
  this.replicaStickinessManager.accept(ackFrame.stickiness ?? null);
@@ -20492,20 +20277,9 @@ class InPageConnector extends BaseAsyncConnector {
20492
20277
  : DEFAULT_INBOX_CAPACITY$6;
20493
20278
  this.inbox = new BoundedAsyncQueue(preferredCapacity);
20494
20279
  this.connectorId = InPageConnector.generateConnectorId();
20495
- // Set local and remote node IDs (defaults to connector ID for backwards compatibility)
20496
- this.localNodeId =
20497
- typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
20498
- ? config.localNodeId.trim()
20499
- : this.connectorId;
20500
- this.remoteNodeId =
20501
- typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
20502
- ? config.remoteNodeId.trim()
20503
- : '*'; // Accept from any remote if not specified
20504
20280
  logger$G.debug('inpage_connector_initialized', {
20505
20281
  channel: this.channelName,
20506
20282
  connector_id: this.connectorId,
20507
- local_node_id: this.localNodeId,
20508
- remote_node_id: this.remoteNodeId,
20509
20283
  });
20510
20284
  this.onMsg = (event) => {
20511
20285
  const messageEvent = event;
@@ -20539,64 +20313,6 @@ class InPageConnector extends BaseAsyncConnector {
20539
20313
  if (busMessage.senderId === this.connectorId) {
20540
20314
  return;
20541
20315
  }
20542
- // Try to unwrap as transport frame
20543
- const frame = unwrapTransportFrame(busMessage.payload);
20544
- if (frame) {
20545
- // Apply connector's filtering policy: strict dst check, src accepts wildcard
20546
- const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
20547
- const dstMatches = frame.dst === this.localNodeId;
20548
- if (dstMatches && srcMatches) {
20549
- // Successfully received and filtered transport frame
20550
- logger$G.debug('inpage_transport_frame_received', {
20551
- channel: this.channelName,
20552
- sender_id: busMessage.senderId,
20553
- connector_id: this.connectorId,
20554
- local_node_id: this.localNodeId,
20555
- remote_node_id: this.remoteNodeId,
20556
- frame_src: frame.src,
20557
- frame_dst: frame.dst,
20558
- payload_length: frame.payload.byteLength,
20559
- });
20560
- const unwrapped = frame.payload;
20561
- try {
20562
- if (typeof this.inbox.tryEnqueue === 'function') {
20563
- const accepted = this.inbox.tryEnqueue(unwrapped);
20564
- if (accepted) {
20565
- return;
20566
- }
20567
- }
20568
- this.inbox.enqueue(unwrapped);
20569
- }
20570
- catch (error) {
20571
- if (error instanceof QueueFullError) {
20572
- logger$G.warning('inpage_receive_queue_full', {
20573
- channel: this.channelName,
20574
- });
20575
- }
20576
- else {
20577
- logger$G.error('inpage_receive_error', {
20578
- channel: this.channelName,
20579
- error: error instanceof Error ? error.message : String(error),
20580
- });
20581
- }
20582
- }
20583
- return;
20584
- }
20585
- else {
20586
- // Frame filtered out by addressing rules
20587
- logger$G.debug('inpage_transport_frame_filtered', {
20588
- channel: this.channelName,
20589
- connector_id: this.connectorId,
20590
- local_node_id: this.localNodeId,
20591
- remote_node_id: this.remoteNodeId,
20592
- frame_src: frame.src,
20593
- frame_dst: frame.dst,
20594
- reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
20595
- });
20596
- return;
20597
- }
20598
- }
20599
- // Fall back to legacy format (no transport frame)
20600
20316
  const payload = InPageConnector.coercePayload(busMessage.payload);
20601
20317
  if (!payload) {
20602
20318
  logger$G.debug('inpage_payload_rejected', {
@@ -20755,27 +20471,11 @@ class InPageConnector extends BaseAsyncConnector {
20755
20471
  logger$G.debug('inpage_message_sending', {
20756
20472
  channel: this.channelName,
20757
20473
  sender_id: this.connectorId,
20758
- local_node_id: this.localNodeId,
20759
- remote_node_id: this.remoteNodeId,
20760
- });
20761
- // Only use transport framing if both localNodeId and remoteNodeId are explicitly set
20762
- // (not using default values). This ensures backwards compatibility.
20763
- const useTransportFrame = this.localNodeId !== this.connectorId ||
20764
- this.remoteNodeId !== '*';
20765
- let payload;
20766
- if (useTransportFrame) {
20767
- // Wrap payload in transport frame
20768
- const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
20769
- payload = serializeTransportFrame(frame);
20770
- }
20771
- else {
20772
- // Legacy format: send raw payload
20773
- payload = data;
20774
- }
20474
+ });
20775
20475
  const event = new MessageEvent(this.channelName, {
20776
20476
  data: {
20777
20477
  senderId: this.connectorId,
20778
- payload,
20478
+ payload: data,
20779
20479
  },
20780
20480
  });
20781
20481
  getSharedBus$1().dispatchEvent(event);
@@ -20804,24 +20504,6 @@ class InPageConnector extends BaseAsyncConnector {
20804
20504
  }
20805
20505
  return rawOrEnvelope;
20806
20506
  }
20807
- /**
20808
- * Update the remote node ID after learning it from NodeAttachAck
20809
- * This allows upstream connectors to switch from wildcard to specific addressing
20810
- */
20811
- updateRemoteNodeId(newRemoteNodeId) {
20812
- if (typeof newRemoteNodeId !== 'string' || newRemoteNodeId.trim().length === 0) {
20813
- throw new Error('Invalid remote node ID');
20814
- }
20815
- const oldValue = this.remoteNodeId;
20816
- this.remoteNodeId = newRemoteNodeId.trim();
20817
- logger$G.debug('inpage_connector_remote_node_id_updated', {
20818
- channel: this.channelName,
20819
- connector_id: this.connectorId,
20820
- local_node_id: this.localNodeId,
20821
- old_remote_node_id: oldValue,
20822
- new_remote_node_id: this.remoteNodeId,
20823
- });
20824
- }
20825
20507
  }
20826
20508
 
20827
20509
  const RPC_REGISTRY = Symbol('naylence.rpc.registry');
@@ -28158,14 +27840,6 @@ function isInPageConnectionGrant(candidate) {
28158
27840
  record.inboxCapacity <= 0)) {
28159
27841
  return false;
28160
27842
  }
28161
- if (record.localNodeId !== undefined &&
28162
- (typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
28163
- return false;
28164
- }
28165
- if (record.remoteNodeId !== undefined &&
28166
- (typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
28167
- return false;
28168
- }
28169
27843
  return true;
28170
27844
  }
28171
27845
  function normalizeInPageConnectionGrant(candidate) {
@@ -28199,20 +27873,6 @@ function normalizeInPageConnectionGrant(candidate) {
28199
27873
  }
28200
27874
  result.inboxCapacity = Math.floor(inboxValue);
28201
27875
  }
28202
- const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
28203
- if (localNodeIdValue !== undefined) {
28204
- if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
28205
- throw new TypeError('InPageConnectionGrant "localNodeId" must be a non-empty string when provided');
28206
- }
28207
- result.localNodeId = localNodeIdValue.trim();
28208
- }
28209
- const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
28210
- if (remoteNodeIdValue !== undefined) {
28211
- if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
28212
- throw new TypeError('InPageConnectionGrant "remoteNodeId" must be a non-empty string when provided');
28213
- }
28214
- result.remoteNodeId = remoteNodeIdValue.trim();
28215
- }
28216
27876
  return result;
28217
27877
  }
28218
27878
  function inPageGrantToConnectorConfig(grant) {
@@ -28226,12 +27886,6 @@ function inPageGrantToConnectorConfig(grant) {
28226
27886
  if (normalized.inboxCapacity !== undefined) {
28227
27887
  config.inboxCapacity = normalized.inboxCapacity;
28228
27888
  }
28229
- if (normalized.localNodeId) {
28230
- config.localNodeId = normalized.localNodeId;
28231
- }
28232
- if (normalized.remoteNodeId) {
28233
- config.remoteNodeId = normalized.remoteNodeId;
28234
- }
28235
27889
  return config;
28236
27890
  }
28237
27891
 
@@ -28809,8 +28463,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28809
28463
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
28810
28464
  channelName: connectorConfig.channelName,
28811
28465
  inboxCapacity: connectorConfig.inboxCapacity,
28812
- localNodeId: connectorConfig.localNodeId,
28813
- remoteNodeId: connectorConfig.remoteNodeId,
28466
+ initialWindow: connectorConfig.initialWindow,
28814
28467
  };
28815
28468
  }
28816
28469
  const config = {
@@ -28835,6 +28488,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28835
28488
  purpose: 'connection',
28836
28489
  channelName: normalizedConfig.channelName,
28837
28490
  inboxCapacity: normalizedConfig.inboxCapacity,
28491
+ initialWindow: normalizedConfig.initialWindow,
28838
28492
  });
28839
28493
  return grant;
28840
28494
  }
@@ -28860,8 +28514,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28860
28514
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
28861
28515
  channelName,
28862
28516
  inboxCapacity,
28863
- localNodeId: normalized.localNodeId,
28864
- remoteNodeId: normalized.remoteNodeId,
28865
28517
  };
28866
28518
  const connector = new BroadcastChannelConnector(connectorConfig, baseConfig);
28867
28519
  if (options.authorization) {
@@ -28923,16 +28575,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28923
28575
  if (candidate.authorizationContext !== undefined) {
28924
28576
  normalized.authorizationContext = candidate.authorizationContext;
28925
28577
  }
28926
- // Handle localNodeId
28927
- const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
28928
- if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
28929
- normalized.localNodeId = localNodeId.trim();
28930
- }
28931
- // Handle remoteNodeId
28932
- const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
28933
- if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
28934
- normalized.remoteNodeId = remoteNodeId.trim();
28935
- }
28936
28578
  normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$5;
28937
28579
  normalized.inboxCapacity =
28938
28580
  normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
@@ -29496,8 +29138,6 @@ class InPageConnectorFactory extends ConnectorFactory {
29496
29138
  type: INPAGE_CONNECTOR_TYPE,
29497
29139
  channelName,
29498
29140
  inboxCapacity,
29499
- localNodeId: normalized.localNodeId,
29500
- remoteNodeId: normalized.remoteNodeId,
29501
29141
  };
29502
29142
  const connector = new InPageConnector(connectorConfig, baseConfig);
29503
29143
  if (options.authorization) {
@@ -29566,16 +29206,6 @@ class InPageConnectorFactory extends ConnectorFactory {
29566
29206
  if (candidate.authorizationContext !== undefined) {
29567
29207
  normalized.authorizationContext = candidate.authorizationContext;
29568
29208
  }
29569
- // Handle localNodeId
29570
- const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
29571
- if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
29572
- normalized.localNodeId = localNodeId.trim();
29573
- }
29574
- // Handle remoteNodeId
29575
- const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
29576
- if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
29577
- normalized.remoteNodeId = remoteNodeId.trim();
29578
- }
29579
29209
  normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$3;
29580
29210
  normalized.inboxCapacity =
29581
29211
  normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$3;
@@ -36341,18 +35971,13 @@ class BroadcastChannelListener extends TransportListener {
36341
35971
  });
36342
35972
  }
36343
35973
  asCallbackGrant() {
36344
- const grant = {
35974
+ return this.withLegacySnakeCaseKeys({
36345
35975
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
36346
35976
  connectorType: BROADCAST_CHANNEL_CONNECTOR_TYPE,
36347
35977
  connectionGrantType: BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE,
36348
35978
  channelName: this._channelName,
36349
35979
  inboxCapacity: this._inboxCapacity,
36350
- };
36351
- // Include localNodeId for transport frame multiplexing if node is available
36352
- if (this._routingNode) {
36353
- grant.localNodeId = this._routingNode.id;
36354
- }
36355
- return this.withLegacySnakeCaseKeys(grant);
35980
+ });
36356
35981
  }
36357
35982
  _registerChannelListener() {
36358
35983
  if (this._channelHandler) {
@@ -36412,54 +36037,23 @@ class BroadcastChannelListener extends TransportListener {
36412
36037
  if (typeof senderId !== 'string' || senderId.length === 0) {
36413
36038
  return null;
36414
36039
  }
36415
- // Check if payload is a transport frame object first
36416
- let envelopePayload = null;
36417
- if (this._routingNode && record.payload && typeof record.payload === 'object') {
36418
- // Try to unwrap as transport frame
36419
- const frame = unwrapTransportFrame(record.payload);
36420
- if (frame) {
36421
- // Apply listener's filtering policy: accept frames addressed to us OR with wildcard destination
36422
- // Wildcard is needed because downstream nodes don't know the sentinel's ID during initial attach
36423
- const isAddressedToUs = frame.dst === this._routingNode.id || frame.dst === '*';
36424
- if (isAddressedToUs) {
36425
- envelopePayload = frame.payload;
36426
- logger$a.debug('broadcast_channel_listener_unwrapped_transport_frame', {
36427
- sender_id: senderId,
36428
- src: frame.src,
36429
- dst: frame.dst,
36430
- });
36431
- }
36432
- else {
36433
- // Frame addressed to a different node, ignore it
36434
- logger$a.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
36435
- sender_id: senderId,
36436
- dst: frame.dst,
36437
- expected: this._routingNode.id,
36438
- });
36439
- return null;
36440
- }
36441
- }
36442
- }
36443
- // If not a transport frame, try to coerce as legacy format
36444
- if (!envelopePayload) {
36445
- envelopePayload = coercePayload$1(record.payload);
36446
- if (!envelopePayload) {
36447
- logger$a.debug('broadcast_channel_listener_ignored_event_without_payload', {
36448
- sender_id: senderId,
36449
- });
36450
- return null;
36451
- }
36040
+ const payload = coercePayload$1(record.payload);
36041
+ if (!payload) {
36042
+ logger$a.debug('broadcast_channel_listener_ignored_event_without_payload', {
36043
+ sender_id: senderId,
36044
+ });
36045
+ return null;
36452
36046
  }
36453
36047
  let envelope;
36454
36048
  try {
36455
- const decoded = new TextDecoder().decode(envelopePayload);
36049
+ const decoded = new TextDecoder().decode(payload);
36456
36050
  const parsed = JSON.parse(decoded);
36457
36051
  envelope = core.deserializeEnvelope(parsed);
36458
36052
  }
36459
36053
  catch (error) {
36460
36054
  const decoded = (() => {
36461
36055
  try {
36462
- return new TextDecoder().decode(envelopePayload);
36056
+ return new TextDecoder().decode(payload);
36463
36057
  }
36464
36058
  catch {
36465
36059
  return null;
@@ -36579,20 +36173,6 @@ class BroadcastChannelListener extends TransportListener {
36579
36173
  inboxCapacity: this._inboxCapacity,
36580
36174
  };
36581
36175
  }
36582
- // Automatically configure transport frame multiplexing:
36583
- // Use node IDs (not connector IDs) for node-to-node targeting
36584
- const broadcastConfig = connectorConfig;
36585
- // Always force localNodeId to be this listener's node ID
36586
- // This ensures the sentinel sets localNodeId=sentinel, not the child's ID
36587
- broadcastConfig.localNodeId = routingNode.id;
36588
- // Always force remoteNodeId to be the attaching child's system ID
36589
- broadcastConfig.remoteNodeId = systemId;
36590
- logger$a.debug('broadcast_channel_listener_configured_node_ids', {
36591
- sender_id: params.senderId,
36592
- system_id: systemId,
36593
- local_node_id: broadcastConfig.localNodeId,
36594
- remote_node_id: broadcastConfig.remoteNodeId,
36595
- });
36596
36176
  try {
36597
36177
  const connector = await routingNode.createOriginConnector({
36598
36178
  originType,
@@ -36662,21 +36242,6 @@ class BroadcastChannelListener extends TransportListener {
36662
36242
  inboxCandidate > 0) {
36663
36243
  config.inboxCapacity = Math.floor(inboxCandidate);
36664
36244
  }
36665
- // Extract transport frame multiplexing node IDs
36666
- const localNodeIdCandidate = candidate.localNodeId ?? candidate['local_node_id'];
36667
- if (typeof localNodeIdCandidate === 'string' && localNodeIdCandidate.trim().length > 0) {
36668
- config.localNodeId = localNodeIdCandidate.trim();
36669
- logger$a.debug('broadcast_channel_listener_extracted_local_node_id', {
36670
- local_node_id: config.localNodeId,
36671
- });
36672
- }
36673
- const remoteNodeIdCandidate = candidate.remoteNodeId ?? candidate['remote_node_id'];
36674
- if (typeof remoteNodeIdCandidate === 'string' && remoteNodeIdCandidate.trim().length > 0) {
36675
- config.remoteNodeId = remoteNodeIdCandidate.trim();
36676
- logger$a.debug('broadcast_channel_listener_extracted_remote_node_id', {
36677
- remote_node_id: config.remoteNodeId,
36678
- });
36679
- }
36680
36245
  return config;
36681
36246
  }
36682
36247
  _monitorConnectorLifecycle(senderId, systemId, connector) {
@@ -37399,7 +36964,6 @@ class InPageListener extends TransportListener {
37399
36964
  this._busHandler = null;
37400
36965
  this._senderRegistry = new Map();
37401
36966
  this._systemToSender = new Map();
37402
- this._flowIdToSender = new Map();
37403
36967
  this._pendingAttachments = new Map();
37404
36968
  ensureBrowserEnvironment();
37405
36969
  const channelCandidate = options?.channelName;
@@ -37466,7 +37030,6 @@ class InPageListener extends TransportListener {
37466
37030
  this._unregisterBusListener();
37467
37031
  this._senderRegistry.clear();
37468
37032
  this._systemToSender.clear();
37469
- this._flowIdToSender.clear();
37470
37033
  this._pendingAttachments.clear();
37471
37034
  logger$7.debug('inpage_listener_stopped', {
37472
37035
  channel: this._channelName,
@@ -37520,25 +37083,10 @@ class InPageListener extends TransportListener {
37520
37083
  await this._handleAttachFrame(senderId, envelope);
37521
37084
  return;
37522
37085
  }
37523
- // Try to find connector by sender ID first
37524
- let entry = this._senderRegistry.get(senderId);
37525
- // If not found and we have a flowId, try to route based on flow
37526
- if (!entry && envelope.flowId) {
37527
- const originalSenderId = this._flowIdToSender.get(envelope.flowId);
37528
- if (originalSenderId) {
37529
- entry = this._senderRegistry.get(originalSenderId);
37530
- logger$7.debug('inpage_listener_routed_by_flow_id', {
37531
- sender_id: senderId,
37532
- original_sender_id: originalSenderId,
37533
- flow_id: envelope.flowId,
37534
- frame_type: envelope.frame?.type ?? 'unknown',
37535
- });
37536
- }
37537
- }
37086
+ const entry = this._senderRegistry.get(senderId);
37538
37087
  if (!entry) {
37539
37088
  logger$7.debug('inpage_listener_no_connector_for_sender', {
37540
37089
  sender_id: senderId,
37541
- flow_id: envelope.flowId,
37542
37090
  frame_type: envelope.frame?.type ?? 'unknown',
37543
37091
  });
37544
37092
  return;
@@ -37615,15 +37163,6 @@ class InPageListener extends TransportListener {
37615
37163
  }
37616
37164
  this._senderRegistry.set(senderId, entry);
37617
37165
  this._systemToSender.set(entry.systemId, senderId);
37618
- // Track the flowId if present so we can route responses back
37619
- if (envelope.flowId) {
37620
- this._flowIdToSender.set(envelope.flowId, senderId);
37621
- logger$7.debug('inpage_listener_registered_flow_id', {
37622
- sender_id: senderId,
37623
- system_id: entry.systemId,
37624
- flow_id: envelope.flowId,
37625
- });
37626
- }
37627
37166
  await this._deliverEnvelope(entry, envelope);
37628
37167
  }
37629
37168
  async _createConnectorForAttach(params) {
@@ -37671,7 +37210,7 @@ class InPageListener extends TransportListener {
37671
37210
  origin_type: originType,
37672
37211
  connector_type: connector.constructor?.name ?? 'unknown',
37673
37212
  });
37674
- return { connector, systemId, originType, senderId: params.senderId };
37213
+ return { connector, systemId, originType };
37675
37214
  }
37676
37215
  catch (error) {
37677
37216
  logger$7.error('inpage_listener_connector_creation_failed', {
@@ -37725,12 +37264,6 @@ class InPageListener extends TransportListener {
37725
37264
  if (this._systemToSender.get(systemId) === senderId) {
37726
37265
  this._systemToSender.delete(systemId);
37727
37266
  }
37728
- // Clean up flowId mappings for this sender
37729
- for (const [flowId, sid] of this._flowIdToSender.entries()) {
37730
- if (sid === senderId) {
37731
- this._flowIdToSender.delete(flowId);
37732
- }
37733
- }
37734
37267
  })
37735
37268
  .catch((error) => {
37736
37269
  logger$7.debug('inpage_listener_wait_until_closed_failed', {
@@ -37742,24 +37275,9 @@ class InPageListener extends TransportListener {
37742
37275
  if (this._systemToSender.get(systemId) === senderId) {
37743
37276
  this._systemToSender.delete(systemId);
37744
37277
  }
37745
- // Clean up flowId mappings for this sender
37746
- for (const [flowId, sid] of this._flowIdToSender.entries()) {
37747
- if (sid === senderId) {
37748
- this._flowIdToSender.delete(flowId);
37749
- }
37750
- }
37751
37278
  });
37752
37279
  }
37753
37280
  async _deliverEnvelope(entry, envelope) {
37754
- // Track flowId for routing responses back
37755
- if (envelope.flowId && !this._flowIdToSender.has(envelope.flowId)) {
37756
- this._flowIdToSender.set(envelope.flowId, entry.senderId);
37757
- logger$7.debug('inpage_listener_registered_flow_id_on_delivery', {
37758
- sender_id: entry.senderId,
37759
- system_id: entry.systemId,
37760
- flow_id: envelope.flowId,
37761
- });
37762
- }
37763
37281
  const message = this._buildChannelMessage({
37764
37282
  envelope,
37765
37283
  connector: entry.connector,