@naylence/runtime 0.3.5-test.952 → 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 (38) hide show
  1. package/dist/browser/index.cjs +32 -464
  2. package/dist/browser/index.mjs +32 -464
  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 -90
  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 -87
  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/upstream-session-manager.js +0 -6
  12. package/dist/cjs/version.js +2 -2
  13. package/dist/esm/naylence/fame/connector/broadcast-channel-connector-factory.js +2 -14
  14. package/dist/esm/naylence/fame/connector/broadcast-channel-connector.browser.js +1 -90
  15. package/dist/esm/naylence/fame/connector/broadcast-channel-listener.js +10 -76
  16. package/dist/esm/naylence/fame/connector/inpage-connector-factory.js +0 -12
  17. package/dist/esm/naylence/fame/connector/inpage-connector.js +1 -87
  18. package/dist/esm/naylence/fame/connector/inpage-listener.js +2 -49
  19. package/dist/esm/naylence/fame/grants/broadcast-channel-connection-grant.js +12 -23
  20. package/dist/esm/naylence/fame/grants/inpage-connection-grant.js +0 -28
  21. package/dist/esm/naylence/fame/node/upstream-session-manager.js +0 -6
  22. package/dist/esm/version.js +2 -2
  23. package/dist/node/index.cjs +32 -464
  24. package/dist/node/index.mjs +32 -464
  25. package/dist/node/node.cjs +32 -480
  26. package/dist/node/node.mjs +32 -480
  27. package/dist/types/naylence/fame/connector/broadcast-channel-connector-factory.d.ts +0 -2
  28. package/dist/types/naylence/fame/connector/broadcast-channel-connector.browser.d.ts +1 -4
  29. package/dist/types/naylence/fame/connector/inpage-connector-factory.d.ts +0 -2
  30. package/dist/types/naylence/fame/connector/inpage-connector.d.ts +0 -4
  31. package/dist/types/naylence/fame/connector/inpage-listener.d.ts +0 -1
  32. package/dist/types/naylence/fame/grants/broadcast-channel-connection-grant.d.ts +3 -6
  33. package/dist/types/naylence/fame/grants/inpage-connection-grant.d.ts +0 -8
  34. package/dist/types/version.d.ts +1 -1
  35. package/package.json +1 -1
  36. package/dist/cjs/naylence/fame/connector/transport-frame.js +0 -100
  37. package/dist/esm/naylence/fame/connector/transport-frame.js +0 -93
  38. package/dist/types/naylence/fame/connector/transport-frame.d.ts +0 -56
@@ -13,12 +13,12 @@ import fastify from 'fastify';
13
13
  import websocketPlugin from '@fastify/websocket';
14
14
 
15
15
  // This file is auto-generated during build - do not edit manually
16
- // Generated from package.json version: 0.3.5-test.952
16
+ // Generated from package.json version: 0.3.5-test.954
17
17
  /**
18
18
  * The package version, injected at build time.
19
19
  * @internal
20
20
  */
21
- const VERSION = '0.3.5-test.952';
21
+ const VERSION = '0.3.5-test.954';
22
22
 
23
23
  /**
24
24
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -9733,84 +9733,6 @@ class BoundedAsyncQueue {
9733
9733
  }
9734
9734
  }
9735
9735
 
9736
- /**
9737
- * Transport frame layer for multiplexing logical links on physical channels.
9738
- *
9739
- * This lightweight framing layer wraps raw FAME payloads to enable multiple
9740
- * logical connections over a single physical channel (BroadcastChannel or InPage bus).
9741
- *
9742
- * The transport frame does NOT modify FAME envelopes - it only wraps the raw
9743
- * Uint8Array payload at the connector level.
9744
- */
9745
- /**
9746
- * Transport frame version for future compatibility
9747
- */
9748
- const TRANSPORT_FRAME_VERSION = 1;
9749
- /**
9750
- * Wrap a raw payload in a transport frame
9751
- *
9752
- * @param payload - Raw FAME envelope bytes
9753
- * @param srcNodeId - Local node ID (this connector)
9754
- * @param dstNodeId - Remote node ID (target connector)
9755
- * @returns Transport frame ready for transmission
9756
- */
9757
- function wrapTransportFrame(payload, srcNodeId, dstNodeId) {
9758
- return {
9759
- v: TRANSPORT_FRAME_VERSION,
9760
- src: srcNodeId,
9761
- dst: dstNodeId,
9762
- payload,
9763
- };
9764
- }
9765
- /**
9766
- * Serialize a transport frame for transmission over the bus
9767
- *
9768
- * @param frame - Transport frame to serialize
9769
- * @returns Serialized frame data ready for postMessage/dispatchEvent
9770
- */
9771
- function serializeTransportFrame(frame) {
9772
- // Convert Uint8Array to regular array for JSON serialization
9773
- const serializable = {
9774
- v: frame.v,
9775
- src: frame.src,
9776
- dst: frame.dst,
9777
- payload: Array.from(frame.payload),
9778
- };
9779
- return serializable;
9780
- }
9781
- /**
9782
- * Unwrap a transport frame (pure deserializer - no filtering)
9783
- *
9784
- * @param raw - Raw data from the bus
9785
- * @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
9786
- */
9787
- function unwrapTransportFrame(raw) {
9788
- // Validate basic structure
9789
- if (!raw || typeof raw !== 'object') {
9790
- return null;
9791
- }
9792
- const frame = raw;
9793
- // Check version
9794
- if (frame.v !== TRANSPORT_FRAME_VERSION) {
9795
- return null;
9796
- }
9797
- // Check src and dst
9798
- if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
9799
- return null;
9800
- }
9801
- // Extract payload
9802
- if (!frame.payload || !Array.isArray(frame.payload)) {
9803
- return null;
9804
- }
9805
- // Convert array back to Uint8Array and return full frame
9806
- return {
9807
- v: frame.v,
9808
- src: frame.src,
9809
- dst: frame.dst,
9810
- payload: Uint8Array.from(frame.payload),
9811
- };
9812
- }
9813
-
9814
9736
  const logger$_ = getLogger('naylence.fame.connector.broadcast_channel_connector');
9815
9737
  const BROADCAST_CHANNEL_CONNECTOR_TYPE = 'broadcast-channel-connector';
9816
9738
  const DEFAULT_CHANNEL$7 = 'naylence-fabric';
@@ -9876,20 +9798,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9876
9798
  this.inbox = new BoundedAsyncQueue(preferredCapacity);
9877
9799
  this.connectorId = BroadcastChannelConnector.generateConnectorId();
9878
9800
  this.channel = new BroadcastChannel(this.channelName);
9879
- // Set local and remote node IDs (defaults to connector ID for backwards compatibility)
9880
- this.localNodeId =
9881
- typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
9882
- ? config.localNodeId.trim()
9883
- : this.connectorId;
9884
- this.remoteNodeId =
9885
- typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
9886
- ? config.remoteNodeId.trim()
9887
- : '*'; // Accept from any remote if not specified
9888
9801
  logger$_.debug('broadcast_channel_connector_created', {
9889
9802
  channel: this.channelName,
9890
9803
  connector_id: this.connectorId,
9891
- local_node_id: this.localNodeId,
9892
- remote_node_id: this.remoteNodeId,
9893
9804
  inbox_capacity: preferredCapacity,
9894
9805
  timestamp: new Date().toISOString(),
9895
9806
  });
@@ -9922,67 +9833,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9922
9833
  if (busMessage.senderId === this.connectorId) {
9923
9834
  return;
9924
9835
  }
9925
- // Try to unwrap as transport frame
9926
- const frame = unwrapTransportFrame(busMessage.payload);
9927
- if (frame) {
9928
- // Apply connector's filtering policy: strict dst check, src accepts wildcard
9929
- const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
9930
- const dstMatches = frame.dst === this.localNodeId;
9931
- if (dstMatches && srcMatches) {
9932
- // Successfully received and filtered transport frame
9933
- logger$_.debug('broadcast_channel_transport_frame_received', {
9934
- channel: this.channelName,
9935
- sender_id: busMessage.senderId,
9936
- connector_id: this.connectorId,
9937
- local_node_id: this.localNodeId,
9938
- remote_node_id: this.remoteNodeId,
9939
- frame_src: frame.src,
9940
- frame_dst: frame.dst,
9941
- payload_length: frame.payload.byteLength,
9942
- });
9943
- const unwrapped = frame.payload;
9944
- if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
9945
- return;
9946
- }
9947
- try {
9948
- if (typeof this.inbox.tryEnqueue === 'function') {
9949
- const accepted = this.inbox.tryEnqueue(unwrapped);
9950
- if (accepted) {
9951
- return;
9952
- }
9953
- }
9954
- this.inbox.enqueue(unwrapped);
9955
- }
9956
- catch (error) {
9957
- if (error instanceof QueueFullError) {
9958
- logger$_.warning('broadcast_channel_receive_queue_full', {
9959
- channel: this.channelName,
9960
- });
9961
- }
9962
- else {
9963
- logger$_.error('broadcast_channel_receive_error', {
9964
- channel: this.channelName,
9965
- error: error instanceof Error ? error.message : String(error),
9966
- });
9967
- }
9968
- }
9969
- return;
9970
- }
9971
- else {
9972
- // Frame filtered out by addressing rules
9973
- logger$_.debug('broadcast_channel_transport_frame_filtered', {
9974
- channel: this.channelName,
9975
- connector_id: this.connectorId,
9976
- local_node_id: this.localNodeId,
9977
- remote_node_id: this.remoteNodeId,
9978
- frame_src: frame.src,
9979
- frame_dst: frame.dst,
9980
- reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
9981
- });
9982
- return;
9983
- }
9984
- }
9985
- // Fall back to legacy format (no transport frame)
9986
9836
  const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
9987
9837
  if (!payload) {
9988
9838
  logger$_.debug('broadcast_channel_payload_rejected', {
@@ -10121,26 +9971,10 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10121
9971
  logger$_.debug('broadcast_channel_message_sending', {
10122
9972
  channel: this.channelName,
10123
9973
  sender_id: this.connectorId,
10124
- local_node_id: this.localNodeId,
10125
- remote_node_id: this.remoteNodeId,
10126
- });
10127
- // Only use transport framing if both localNodeId and remoteNodeId are explicitly set
10128
- // (not using default values). This ensures backwards compatibility.
10129
- const useTransportFrame = this.localNodeId !== this.connectorId ||
10130
- this.remoteNodeId !== '*';
10131
- let payload;
10132
- if (useTransportFrame) {
10133
- // Wrap payload in transport frame
10134
- const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
10135
- payload = serializeTransportFrame(frame);
10136
- }
10137
- else {
10138
- // Legacy format: send raw payload
10139
- payload = data;
10140
- }
9974
+ });
10141
9975
  this.channel.postMessage({
10142
9976
  senderId: this.connectorId,
10143
- payload,
9977
+ payload: data,
10144
9978
  });
10145
9979
  }
10146
9980
  async _transportReceive() {
@@ -10433,12 +10267,9 @@ function isBroadcastChannelConnectionGrant(candidate) {
10433
10267
  record.inboxCapacity <= 0)) {
10434
10268
  return false;
10435
10269
  }
10436
- if (record.localNodeId !== undefined &&
10437
- (typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
10438
- return false;
10439
- }
10440
- if (record.remoteNodeId !== undefined &&
10441
- (typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
10270
+ if (record.initialWindow !== undefined &&
10271
+ (!Number.isFinite(record.initialWindow) ||
10272
+ record.initialWindow <= 0)) {
10442
10273
  return false;
10443
10274
  }
10444
10275
  return true;
@@ -10474,19 +10305,14 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
10474
10305
  }
10475
10306
  result.inboxCapacity = Math.floor(inboxValue);
10476
10307
  }
10477
- const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
10478
- if (localNodeIdValue !== undefined) {
10479
- if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
10480
- throw new TypeError('BroadcastChannelConnectionGrant "localNodeId" must be a non-empty string when provided');
10481
- }
10482
- result.localNodeId = localNodeIdValue.trim();
10483
- }
10484
- const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
10485
- if (remoteNodeIdValue !== undefined) {
10486
- if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
10487
- throw new TypeError('BroadcastChannelConnectionGrant "remoteNodeId" must be a non-empty string when provided');
10308
+ const windowValue = candidate.initialWindow ?? candidate['initial_window'];
10309
+ if (windowValue !== undefined) {
10310
+ if (typeof windowValue !== 'number' ||
10311
+ !Number.isFinite(windowValue) ||
10312
+ windowValue <= 0) {
10313
+ throw new TypeError('BroadcastChannelConnectionGrant "initialWindow" must be a positive number when provided');
10488
10314
  }
10489
- result.remoteNodeId = remoteNodeIdValue.trim();
10315
+ result.initialWindow = Math.floor(windowValue);
10490
10316
  }
10491
10317
  return result;
10492
10318
  }
@@ -10501,11 +10327,8 @@ function broadcastChannelGrantToConnectorConfig(grant) {
10501
10327
  if (normalized.inboxCapacity !== undefined) {
10502
10328
  config.inboxCapacity = normalized.inboxCapacity;
10503
10329
  }
10504
- if (normalized.localNodeId) {
10505
- config.localNodeId = normalized.localNodeId;
10506
- }
10507
- if (normalized.remoteNodeId) {
10508
- config.remoteNodeId = normalized.remoteNodeId;
10330
+ if (normalized.initialWindow !== undefined) {
10331
+ config.initialWindow = normalized.initialWindow;
10509
10332
  }
10510
10333
  return config;
10511
10334
  }
@@ -10797,12 +10620,6 @@ class UpstreamSessionManager extends TaskSpawner {
10797
10620
  cryptoProvider.prepareForAttach(welcome.frame.systemId, welcome.frame.assignedPath, welcome.frame.acceptedLogicals ?? []);
10798
10621
  }
10799
10622
  await this.onWelcome(welcome.frame);
10800
- // Inject node ID into grant for transport frame multiplexing
10801
- // This ensures localNodeId matches the node's systemId for proper frame filtering
10802
- grant.localNodeId = welcome.frame.systemId;
10803
- if (welcome.frame.targetSystemId) {
10804
- grant.remoteNodeId = welcome.frame.targetSystemId;
10805
- }
10806
10623
  const connector = await ConnectorFactory.createConnector(grant, {
10807
10624
  systemId: welcome.frame.systemId,
10808
10625
  });
@@ -20459,20 +20276,9 @@ class InPageConnector extends BaseAsyncConnector {
20459
20276
  : DEFAULT_INBOX_CAPACITY$6;
20460
20277
  this.inbox = new BoundedAsyncQueue(preferredCapacity);
20461
20278
  this.connectorId = InPageConnector.generateConnectorId();
20462
- // Set local and remote node IDs (defaults to connector ID for backwards compatibility)
20463
- this.localNodeId =
20464
- typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
20465
- ? config.localNodeId.trim()
20466
- : this.connectorId;
20467
- this.remoteNodeId =
20468
- typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
20469
- ? config.remoteNodeId.trim()
20470
- : '*'; // Accept from any remote if not specified
20471
20279
  logger$G.debug('inpage_connector_initialized', {
20472
20280
  channel: this.channelName,
20473
20281
  connector_id: this.connectorId,
20474
- local_node_id: this.localNodeId,
20475
- remote_node_id: this.remoteNodeId,
20476
20282
  });
20477
20283
  this.onMsg = (event) => {
20478
20284
  const messageEvent = event;
@@ -20506,64 +20312,6 @@ class InPageConnector extends BaseAsyncConnector {
20506
20312
  if (busMessage.senderId === this.connectorId) {
20507
20313
  return;
20508
20314
  }
20509
- // Try to unwrap as transport frame
20510
- const frame = unwrapTransportFrame(busMessage.payload);
20511
- if (frame) {
20512
- // Apply connector's filtering policy: strict dst check, src accepts wildcard
20513
- const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
20514
- const dstMatches = frame.dst === this.localNodeId;
20515
- if (dstMatches && srcMatches) {
20516
- // Successfully received and filtered transport frame
20517
- logger$G.debug('inpage_transport_frame_received', {
20518
- channel: this.channelName,
20519
- sender_id: busMessage.senderId,
20520
- connector_id: this.connectorId,
20521
- local_node_id: this.localNodeId,
20522
- remote_node_id: this.remoteNodeId,
20523
- frame_src: frame.src,
20524
- frame_dst: frame.dst,
20525
- payload_length: frame.payload.byteLength,
20526
- });
20527
- const unwrapped = frame.payload;
20528
- try {
20529
- if (typeof this.inbox.tryEnqueue === 'function') {
20530
- const accepted = this.inbox.tryEnqueue(unwrapped);
20531
- if (accepted) {
20532
- return;
20533
- }
20534
- }
20535
- this.inbox.enqueue(unwrapped);
20536
- }
20537
- catch (error) {
20538
- if (error instanceof QueueFullError) {
20539
- logger$G.warning('inpage_receive_queue_full', {
20540
- channel: this.channelName,
20541
- });
20542
- }
20543
- else {
20544
- logger$G.error('inpage_receive_error', {
20545
- channel: this.channelName,
20546
- error: error instanceof Error ? error.message : String(error),
20547
- });
20548
- }
20549
- }
20550
- return;
20551
- }
20552
- else {
20553
- // Frame filtered out by addressing rules
20554
- logger$G.debug('inpage_transport_frame_filtered', {
20555
- channel: this.channelName,
20556
- connector_id: this.connectorId,
20557
- local_node_id: this.localNodeId,
20558
- remote_node_id: this.remoteNodeId,
20559
- frame_src: frame.src,
20560
- frame_dst: frame.dst,
20561
- reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
20562
- });
20563
- return;
20564
- }
20565
- }
20566
- // Fall back to legacy format (no transport frame)
20567
20315
  const payload = InPageConnector.coercePayload(busMessage.payload);
20568
20316
  if (!payload) {
20569
20317
  logger$G.debug('inpage_payload_rejected', {
@@ -20722,27 +20470,11 @@ class InPageConnector extends BaseAsyncConnector {
20722
20470
  logger$G.debug('inpage_message_sending', {
20723
20471
  channel: this.channelName,
20724
20472
  sender_id: this.connectorId,
20725
- local_node_id: this.localNodeId,
20726
- remote_node_id: this.remoteNodeId,
20727
- });
20728
- // Only use transport framing if both localNodeId and remoteNodeId are explicitly set
20729
- // (not using default values). This ensures backwards compatibility.
20730
- const useTransportFrame = this.localNodeId !== this.connectorId ||
20731
- this.remoteNodeId !== '*';
20732
- let payload;
20733
- if (useTransportFrame) {
20734
- // Wrap payload in transport frame
20735
- const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
20736
- payload = serializeTransportFrame(frame);
20737
- }
20738
- else {
20739
- // Legacy format: send raw payload
20740
- payload = data;
20741
- }
20473
+ });
20742
20474
  const event = new MessageEvent(this.channelName, {
20743
20475
  data: {
20744
20476
  senderId: this.connectorId,
20745
- payload,
20477
+ payload: data,
20746
20478
  },
20747
20479
  });
20748
20480
  getSharedBus$1().dispatchEvent(event);
@@ -28107,14 +27839,6 @@ function isInPageConnectionGrant(candidate) {
28107
27839
  record.inboxCapacity <= 0)) {
28108
27840
  return false;
28109
27841
  }
28110
- if (record.localNodeId !== undefined &&
28111
- (typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
28112
- return false;
28113
- }
28114
- if (record.remoteNodeId !== undefined &&
28115
- (typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
28116
- return false;
28117
- }
28118
27842
  return true;
28119
27843
  }
28120
27844
  function normalizeInPageConnectionGrant(candidate) {
@@ -28148,20 +27872,6 @@ function normalizeInPageConnectionGrant(candidate) {
28148
27872
  }
28149
27873
  result.inboxCapacity = Math.floor(inboxValue);
28150
27874
  }
28151
- const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
28152
- if (localNodeIdValue !== undefined) {
28153
- if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
28154
- throw new TypeError('InPageConnectionGrant "localNodeId" must be a non-empty string when provided');
28155
- }
28156
- result.localNodeId = localNodeIdValue.trim();
28157
- }
28158
- const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
28159
- if (remoteNodeIdValue !== undefined) {
28160
- if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
28161
- throw new TypeError('InPageConnectionGrant "remoteNodeId" must be a non-empty string when provided');
28162
- }
28163
- result.remoteNodeId = remoteNodeIdValue.trim();
28164
- }
28165
27875
  return result;
28166
27876
  }
28167
27877
  function inPageGrantToConnectorConfig(grant) {
@@ -28175,12 +27885,6 @@ function inPageGrantToConnectorConfig(grant) {
28175
27885
  if (normalized.inboxCapacity !== undefined) {
28176
27886
  config.inboxCapacity = normalized.inboxCapacity;
28177
27887
  }
28178
- if (normalized.localNodeId) {
28179
- config.localNodeId = normalized.localNodeId;
28180
- }
28181
- if (normalized.remoteNodeId) {
28182
- config.remoteNodeId = normalized.remoteNodeId;
28183
- }
28184
27888
  return config;
28185
27889
  }
28186
27890
 
@@ -28758,8 +28462,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28758
28462
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
28759
28463
  channelName: connectorConfig.channelName,
28760
28464
  inboxCapacity: connectorConfig.inboxCapacity,
28761
- localNodeId: connectorConfig.localNodeId,
28762
- remoteNodeId: connectorConfig.remoteNodeId,
28465
+ initialWindow: connectorConfig.initialWindow,
28763
28466
  };
28764
28467
  }
28765
28468
  const config = {
@@ -28784,6 +28487,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28784
28487
  purpose: 'connection',
28785
28488
  channelName: normalizedConfig.channelName,
28786
28489
  inboxCapacity: normalizedConfig.inboxCapacity,
28490
+ initialWindow: normalizedConfig.initialWindow,
28787
28491
  });
28788
28492
  return grant;
28789
28493
  }
@@ -28809,8 +28513,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28809
28513
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
28810
28514
  channelName,
28811
28515
  inboxCapacity,
28812
- localNodeId: normalized.localNodeId,
28813
- remoteNodeId: normalized.remoteNodeId,
28814
28516
  };
28815
28517
  const connector = new BroadcastChannelConnector(connectorConfig, baseConfig);
28816
28518
  if (options.authorization) {
@@ -28872,16 +28574,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28872
28574
  if (candidate.authorizationContext !== undefined) {
28873
28575
  normalized.authorizationContext = candidate.authorizationContext;
28874
28576
  }
28875
- // Handle localNodeId
28876
- const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
28877
- if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
28878
- normalized.localNodeId = localNodeId.trim();
28879
- }
28880
- // Handle remoteNodeId
28881
- const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
28882
- if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
28883
- normalized.remoteNodeId = remoteNodeId.trim();
28884
- }
28885
28577
  normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$5;
28886
28578
  normalized.inboxCapacity =
28887
28579
  normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
@@ -29445,8 +29137,6 @@ class InPageConnectorFactory extends ConnectorFactory {
29445
29137
  type: INPAGE_CONNECTOR_TYPE,
29446
29138
  channelName,
29447
29139
  inboxCapacity,
29448
- localNodeId: normalized.localNodeId,
29449
- remoteNodeId: normalized.remoteNodeId,
29450
29140
  };
29451
29141
  const connector = new InPageConnector(connectorConfig, baseConfig);
29452
29142
  if (options.authorization) {
@@ -29515,16 +29205,6 @@ class InPageConnectorFactory extends ConnectorFactory {
29515
29205
  if (candidate.authorizationContext !== undefined) {
29516
29206
  normalized.authorizationContext = candidate.authorizationContext;
29517
29207
  }
29518
- // Handle localNodeId
29519
- const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
29520
- if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
29521
- normalized.localNodeId = localNodeId.trim();
29522
- }
29523
- // Handle remoteNodeId
29524
- const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
29525
- if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
29526
- normalized.remoteNodeId = remoteNodeId.trim();
29527
- }
29528
29208
  normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$3;
29529
29209
  normalized.inboxCapacity =
29530
29210
  normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$3;
@@ -36290,18 +35970,13 @@ class BroadcastChannelListener extends TransportListener {
36290
35970
  });
36291
35971
  }
36292
35972
  asCallbackGrant() {
36293
- const grant = {
35973
+ return this.withLegacySnakeCaseKeys({
36294
35974
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
36295
35975
  connectorType: BROADCAST_CHANNEL_CONNECTOR_TYPE,
36296
35976
  connectionGrantType: BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE,
36297
35977
  channelName: this._channelName,
36298
35978
  inboxCapacity: this._inboxCapacity,
36299
- };
36300
- // Include localNodeId for transport frame multiplexing if node is available
36301
- if (this._routingNode) {
36302
- grant.localNodeId = this._routingNode.id;
36303
- }
36304
- return this.withLegacySnakeCaseKeys(grant);
35979
+ });
36305
35980
  }
36306
35981
  _registerChannelListener() {
36307
35982
  if (this._channelHandler) {
@@ -36361,54 +36036,23 @@ class BroadcastChannelListener extends TransportListener {
36361
36036
  if (typeof senderId !== 'string' || senderId.length === 0) {
36362
36037
  return null;
36363
36038
  }
36364
- // Check if payload is a transport frame object first
36365
- let envelopePayload = null;
36366
- if (this._routingNode && record.payload && typeof record.payload === 'object') {
36367
- // Try to unwrap as transport frame
36368
- const frame = unwrapTransportFrame(record.payload);
36369
- if (frame) {
36370
- // Apply listener's filtering policy: accept frames addressed to us OR with wildcard destination
36371
- // Wildcard is needed because downstream nodes don't know the sentinel's ID during initial attach
36372
- const isAddressedToUs = frame.dst === this._routingNode.id || frame.dst === '*';
36373
- if (isAddressedToUs) {
36374
- envelopePayload = frame.payload;
36375
- logger$a.debug('broadcast_channel_listener_unwrapped_transport_frame', {
36376
- sender_id: senderId,
36377
- src: frame.src,
36378
- dst: frame.dst,
36379
- });
36380
- }
36381
- else {
36382
- // Frame addressed to a different node, ignore it
36383
- logger$a.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
36384
- sender_id: senderId,
36385
- dst: frame.dst,
36386
- expected: this._routingNode.id,
36387
- });
36388
- return null;
36389
- }
36390
- }
36391
- }
36392
- // If not a transport frame, try to coerce as legacy format
36393
- if (!envelopePayload) {
36394
- envelopePayload = coercePayload$1(record.payload);
36395
- if (!envelopePayload) {
36396
- logger$a.debug('broadcast_channel_listener_ignored_event_without_payload', {
36397
- sender_id: senderId,
36398
- });
36399
- return null;
36400
- }
36039
+ const payload = coercePayload$1(record.payload);
36040
+ if (!payload) {
36041
+ logger$a.debug('broadcast_channel_listener_ignored_event_without_payload', {
36042
+ sender_id: senderId,
36043
+ });
36044
+ return null;
36401
36045
  }
36402
36046
  let envelope;
36403
36047
  try {
36404
- const decoded = new TextDecoder().decode(envelopePayload);
36048
+ const decoded = new TextDecoder().decode(payload);
36405
36049
  const parsed = JSON.parse(decoded);
36406
36050
  envelope = deserializeEnvelope(parsed);
36407
36051
  }
36408
36052
  catch (error) {
36409
36053
  const decoded = (() => {
36410
36054
  try {
36411
- return new TextDecoder().decode(envelopePayload);
36055
+ return new TextDecoder().decode(payload);
36412
36056
  }
36413
36057
  catch {
36414
36058
  return null;
@@ -36528,20 +36172,6 @@ class BroadcastChannelListener extends TransportListener {
36528
36172
  inboxCapacity: this._inboxCapacity,
36529
36173
  };
36530
36174
  }
36531
- // Automatically configure transport frame multiplexing:
36532
- // Use node IDs (not connector IDs) for node-to-node targeting
36533
- const broadcastConfig = connectorConfig;
36534
- // Always force localNodeId to be this listener's node ID
36535
- // This ensures the sentinel sets localNodeId=sentinel, not the child's ID
36536
- broadcastConfig.localNodeId = routingNode.id;
36537
- // Always force remoteNodeId to be the attaching child's system ID
36538
- broadcastConfig.remoteNodeId = systemId;
36539
- logger$a.debug('broadcast_channel_listener_configured_node_ids', {
36540
- sender_id: params.senderId,
36541
- system_id: systemId,
36542
- local_node_id: broadcastConfig.localNodeId,
36543
- remote_node_id: broadcastConfig.remoteNodeId,
36544
- });
36545
36175
  try {
36546
36176
  const connector = await routingNode.createOriginConnector({
36547
36177
  originType,
@@ -36611,21 +36241,6 @@ class BroadcastChannelListener extends TransportListener {
36611
36241
  inboxCandidate > 0) {
36612
36242
  config.inboxCapacity = Math.floor(inboxCandidate);
36613
36243
  }
36614
- // Extract transport frame multiplexing node IDs
36615
- const localNodeIdCandidate = candidate.localNodeId ?? candidate['local_node_id'];
36616
- if (typeof localNodeIdCandidate === 'string' && localNodeIdCandidate.trim().length > 0) {
36617
- config.localNodeId = localNodeIdCandidate.trim();
36618
- logger$a.debug('broadcast_channel_listener_extracted_local_node_id', {
36619
- local_node_id: config.localNodeId,
36620
- });
36621
- }
36622
- const remoteNodeIdCandidate = candidate.remoteNodeId ?? candidate['remote_node_id'];
36623
- if (typeof remoteNodeIdCandidate === 'string' && remoteNodeIdCandidate.trim().length > 0) {
36624
- config.remoteNodeId = remoteNodeIdCandidate.trim();
36625
- logger$a.debug('broadcast_channel_listener_extracted_remote_node_id', {
36626
- remote_node_id: config.remoteNodeId,
36627
- });
36628
- }
36629
36244
  return config;
36630
36245
  }
36631
36246
  _monitorConnectorLifecycle(senderId, systemId, connector) {
@@ -37348,7 +36963,6 @@ class InPageListener extends TransportListener {
37348
36963
  this._busHandler = null;
37349
36964
  this._senderRegistry = new Map();
37350
36965
  this._systemToSender = new Map();
37351
- this._flowIdToSender = new Map();
37352
36966
  this._pendingAttachments = new Map();
37353
36967
  ensureBrowserEnvironment();
37354
36968
  const channelCandidate = options?.channelName;
@@ -37415,7 +37029,6 @@ class InPageListener extends TransportListener {
37415
37029
  this._unregisterBusListener();
37416
37030
  this._senderRegistry.clear();
37417
37031
  this._systemToSender.clear();
37418
- this._flowIdToSender.clear();
37419
37032
  this._pendingAttachments.clear();
37420
37033
  logger$7.debug('inpage_listener_stopped', {
37421
37034
  channel: this._channelName,
@@ -37469,25 +37082,10 @@ class InPageListener extends TransportListener {
37469
37082
  await this._handleAttachFrame(senderId, envelope);
37470
37083
  return;
37471
37084
  }
37472
- // Try to find connector by sender ID first
37473
- let entry = this._senderRegistry.get(senderId);
37474
- // If not found and we have a flowId, try to route based on flow
37475
- if (!entry && envelope.flowId) {
37476
- const originalSenderId = this._flowIdToSender.get(envelope.flowId);
37477
- if (originalSenderId) {
37478
- entry = this._senderRegistry.get(originalSenderId);
37479
- logger$7.debug('inpage_listener_routed_by_flow_id', {
37480
- sender_id: senderId,
37481
- original_sender_id: originalSenderId,
37482
- flow_id: envelope.flowId,
37483
- frame_type: envelope.frame?.type ?? 'unknown',
37484
- });
37485
- }
37486
- }
37085
+ const entry = this._senderRegistry.get(senderId);
37487
37086
  if (!entry) {
37488
37087
  logger$7.debug('inpage_listener_no_connector_for_sender', {
37489
37088
  sender_id: senderId,
37490
- flow_id: envelope.flowId,
37491
37089
  frame_type: envelope.frame?.type ?? 'unknown',
37492
37090
  });
37493
37091
  return;
@@ -37564,15 +37162,6 @@ class InPageListener extends TransportListener {
37564
37162
  }
37565
37163
  this._senderRegistry.set(senderId, entry);
37566
37164
  this._systemToSender.set(entry.systemId, senderId);
37567
- // Track the flowId if present so we can route responses back
37568
- if (envelope.flowId) {
37569
- this._flowIdToSender.set(envelope.flowId, senderId);
37570
- logger$7.debug('inpage_listener_registered_flow_id', {
37571
- sender_id: senderId,
37572
- system_id: entry.systemId,
37573
- flow_id: envelope.flowId,
37574
- });
37575
- }
37576
37165
  await this._deliverEnvelope(entry, envelope);
37577
37166
  }
37578
37167
  async _createConnectorForAttach(params) {
@@ -37620,7 +37209,7 @@ class InPageListener extends TransportListener {
37620
37209
  origin_type: originType,
37621
37210
  connector_type: connector.constructor?.name ?? 'unknown',
37622
37211
  });
37623
- return { connector, systemId, originType, senderId: params.senderId };
37212
+ return { connector, systemId, originType };
37624
37213
  }
37625
37214
  catch (error) {
37626
37215
  logger$7.error('inpage_listener_connector_creation_failed', {
@@ -37674,12 +37263,6 @@ class InPageListener extends TransportListener {
37674
37263
  if (this._systemToSender.get(systemId) === senderId) {
37675
37264
  this._systemToSender.delete(systemId);
37676
37265
  }
37677
- // Clean up flowId mappings for this sender
37678
- for (const [flowId, sid] of this._flowIdToSender.entries()) {
37679
- if (sid === senderId) {
37680
- this._flowIdToSender.delete(flowId);
37681
- }
37682
- }
37683
37266
  })
37684
37267
  .catch((error) => {
37685
37268
  logger$7.debug('inpage_listener_wait_until_closed_failed', {
@@ -37691,24 +37274,9 @@ class InPageListener extends TransportListener {
37691
37274
  if (this._systemToSender.get(systemId) === senderId) {
37692
37275
  this._systemToSender.delete(systemId);
37693
37276
  }
37694
- // Clean up flowId mappings for this sender
37695
- for (const [flowId, sid] of this._flowIdToSender.entries()) {
37696
- if (sid === senderId) {
37697
- this._flowIdToSender.delete(flowId);
37698
- }
37699
- }
37700
37277
  });
37701
37278
  }
37702
37279
  async _deliverEnvelope(entry, envelope) {
37703
- // Track flowId for routing responses back
37704
- if (envelope.flowId && !this._flowIdToSender.has(envelope.flowId)) {
37705
- this._flowIdToSender.set(envelope.flowId, entry.senderId);
37706
- logger$7.debug('inpage_listener_registered_flow_id_on_delivery', {
37707
- sender_id: entry.senderId,
37708
- system_id: entry.systemId,
37709
- flow_id: envelope.flowId,
37710
- });
37711
- }
37712
37280
  const message = this._buildChannelMessage({
37713
37281
  envelope,
37714
37282
  connector: entry.connector,