@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
@@ -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.952
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.952';
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() {
@@ -10434,12 +10268,9 @@ function isBroadcastChannelConnectionGrant(candidate) {
10434
10268
  record.inboxCapacity <= 0)) {
10435
10269
  return false;
10436
10270
  }
10437
- if (record.localNodeId !== undefined &&
10438
- (typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
10439
- return false;
10440
- }
10441
- if (record.remoteNodeId !== undefined &&
10442
- (typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
10271
+ if (record.initialWindow !== undefined &&
10272
+ (!Number.isFinite(record.initialWindow) ||
10273
+ record.initialWindow <= 0)) {
10443
10274
  return false;
10444
10275
  }
10445
10276
  return true;
@@ -10475,19 +10306,14 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
10475
10306
  }
10476
10307
  result.inboxCapacity = Math.floor(inboxValue);
10477
10308
  }
10478
- const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
10479
- if (localNodeIdValue !== undefined) {
10480
- if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
10481
- throw new TypeError('BroadcastChannelConnectionGrant "localNodeId" must be a non-empty string when provided');
10482
- }
10483
- result.localNodeId = localNodeIdValue.trim();
10484
- }
10485
- const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
10486
- if (remoteNodeIdValue !== undefined) {
10487
- if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
10488
- throw new TypeError('BroadcastChannelConnectionGrant "remoteNodeId" 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');
10489
10315
  }
10490
- result.remoteNodeId = remoteNodeIdValue.trim();
10316
+ result.initialWindow = Math.floor(windowValue);
10491
10317
  }
10492
10318
  return result;
10493
10319
  }
@@ -10502,11 +10328,8 @@ function broadcastChannelGrantToConnectorConfig(grant) {
10502
10328
  if (normalized.inboxCapacity !== undefined) {
10503
10329
  config.inboxCapacity = normalized.inboxCapacity;
10504
10330
  }
10505
- if (normalized.localNodeId) {
10506
- config.localNodeId = normalized.localNodeId;
10507
- }
10508
- if (normalized.remoteNodeId) {
10509
- config.remoteNodeId = normalized.remoteNodeId;
10331
+ if (normalized.initialWindow !== undefined) {
10332
+ config.initialWindow = normalized.initialWindow;
10510
10333
  }
10511
10334
  return config;
10512
10335
  }
@@ -10798,12 +10621,6 @@ class UpstreamSessionManager extends TaskSpawner {
10798
10621
  cryptoProvider.prepareForAttach(welcome.frame.systemId, welcome.frame.assignedPath, welcome.frame.acceptedLogicals ?? []);
10799
10622
  }
10800
10623
  await this.onWelcome(welcome.frame);
10801
- // Inject node ID into grant for transport frame multiplexing
10802
- // This ensures localNodeId matches the node's systemId for proper frame filtering
10803
- grant.localNodeId = welcome.frame.systemId;
10804
- if (welcome.frame.targetSystemId) {
10805
- grant.remoteNodeId = welcome.frame.targetSystemId;
10806
- }
10807
10624
  const connector = await ConnectorFactory.createConnector(grant, {
10808
10625
  systemId: welcome.frame.systemId,
10809
10626
  });
@@ -20460,20 +20277,9 @@ class InPageConnector extends BaseAsyncConnector {
20460
20277
  : DEFAULT_INBOX_CAPACITY$6;
20461
20278
  this.inbox = new BoundedAsyncQueue(preferredCapacity);
20462
20279
  this.connectorId = InPageConnector.generateConnectorId();
20463
- // Set local and remote node IDs (defaults to connector ID for backwards compatibility)
20464
- this.localNodeId =
20465
- typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
20466
- ? config.localNodeId.trim()
20467
- : this.connectorId;
20468
- this.remoteNodeId =
20469
- typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
20470
- ? config.remoteNodeId.trim()
20471
- : '*'; // Accept from any remote if not specified
20472
20280
  logger$G.debug('inpage_connector_initialized', {
20473
20281
  channel: this.channelName,
20474
20282
  connector_id: this.connectorId,
20475
- local_node_id: this.localNodeId,
20476
- remote_node_id: this.remoteNodeId,
20477
20283
  });
20478
20284
  this.onMsg = (event) => {
20479
20285
  const messageEvent = event;
@@ -20507,64 +20313,6 @@ class InPageConnector extends BaseAsyncConnector {
20507
20313
  if (busMessage.senderId === this.connectorId) {
20508
20314
  return;
20509
20315
  }
20510
- // Try to unwrap as transport frame
20511
- const frame = unwrapTransportFrame(busMessage.payload);
20512
- if (frame) {
20513
- // Apply connector's filtering policy: strict dst check, src accepts wildcard
20514
- const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
20515
- const dstMatches = frame.dst === this.localNodeId;
20516
- if (dstMatches && srcMatches) {
20517
- // Successfully received and filtered transport frame
20518
- logger$G.debug('inpage_transport_frame_received', {
20519
- channel: this.channelName,
20520
- sender_id: busMessage.senderId,
20521
- connector_id: this.connectorId,
20522
- local_node_id: this.localNodeId,
20523
- remote_node_id: this.remoteNodeId,
20524
- frame_src: frame.src,
20525
- frame_dst: frame.dst,
20526
- payload_length: frame.payload.byteLength,
20527
- });
20528
- const unwrapped = frame.payload;
20529
- try {
20530
- if (typeof this.inbox.tryEnqueue === 'function') {
20531
- const accepted = this.inbox.tryEnqueue(unwrapped);
20532
- if (accepted) {
20533
- return;
20534
- }
20535
- }
20536
- this.inbox.enqueue(unwrapped);
20537
- }
20538
- catch (error) {
20539
- if (error instanceof QueueFullError) {
20540
- logger$G.warning('inpage_receive_queue_full', {
20541
- channel: this.channelName,
20542
- });
20543
- }
20544
- else {
20545
- logger$G.error('inpage_receive_error', {
20546
- channel: this.channelName,
20547
- error: error instanceof Error ? error.message : String(error),
20548
- });
20549
- }
20550
- }
20551
- return;
20552
- }
20553
- else {
20554
- // Frame filtered out by addressing rules
20555
- logger$G.debug('inpage_transport_frame_filtered', {
20556
- channel: this.channelName,
20557
- connector_id: this.connectorId,
20558
- local_node_id: this.localNodeId,
20559
- remote_node_id: this.remoteNodeId,
20560
- frame_src: frame.src,
20561
- frame_dst: frame.dst,
20562
- reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
20563
- });
20564
- return;
20565
- }
20566
- }
20567
- // Fall back to legacy format (no transport frame)
20568
20316
  const payload = InPageConnector.coercePayload(busMessage.payload);
20569
20317
  if (!payload) {
20570
20318
  logger$G.debug('inpage_payload_rejected', {
@@ -20723,27 +20471,11 @@ class InPageConnector extends BaseAsyncConnector {
20723
20471
  logger$G.debug('inpage_message_sending', {
20724
20472
  channel: this.channelName,
20725
20473
  sender_id: this.connectorId,
20726
- local_node_id: this.localNodeId,
20727
- remote_node_id: this.remoteNodeId,
20728
- });
20729
- // Only use transport framing if both localNodeId and remoteNodeId are explicitly set
20730
- // (not using default values). This ensures backwards compatibility.
20731
- const useTransportFrame = this.localNodeId !== this.connectorId ||
20732
- this.remoteNodeId !== '*';
20733
- let payload;
20734
- if (useTransportFrame) {
20735
- // Wrap payload in transport frame
20736
- const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
20737
- payload = serializeTransportFrame(frame);
20738
- }
20739
- else {
20740
- // Legacy format: send raw payload
20741
- payload = data;
20742
- }
20474
+ });
20743
20475
  const event = new MessageEvent(this.channelName, {
20744
20476
  data: {
20745
20477
  senderId: this.connectorId,
20746
- payload,
20478
+ payload: data,
20747
20479
  },
20748
20480
  });
20749
20481
  getSharedBus$1().dispatchEvent(event);
@@ -28108,14 +27840,6 @@ function isInPageConnectionGrant(candidate) {
28108
27840
  record.inboxCapacity <= 0)) {
28109
27841
  return false;
28110
27842
  }
28111
- if (record.localNodeId !== undefined &&
28112
- (typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
28113
- return false;
28114
- }
28115
- if (record.remoteNodeId !== undefined &&
28116
- (typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
28117
- return false;
28118
- }
28119
27843
  return true;
28120
27844
  }
28121
27845
  function normalizeInPageConnectionGrant(candidate) {
@@ -28149,20 +27873,6 @@ function normalizeInPageConnectionGrant(candidate) {
28149
27873
  }
28150
27874
  result.inboxCapacity = Math.floor(inboxValue);
28151
27875
  }
28152
- const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
28153
- if (localNodeIdValue !== undefined) {
28154
- if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
28155
- throw new TypeError('InPageConnectionGrant "localNodeId" must be a non-empty string when provided');
28156
- }
28157
- result.localNodeId = localNodeIdValue.trim();
28158
- }
28159
- const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
28160
- if (remoteNodeIdValue !== undefined) {
28161
- if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
28162
- throw new TypeError('InPageConnectionGrant "remoteNodeId" must be a non-empty string when provided');
28163
- }
28164
- result.remoteNodeId = remoteNodeIdValue.trim();
28165
- }
28166
27876
  return result;
28167
27877
  }
28168
27878
  function inPageGrantToConnectorConfig(grant) {
@@ -28176,12 +27886,6 @@ function inPageGrantToConnectorConfig(grant) {
28176
27886
  if (normalized.inboxCapacity !== undefined) {
28177
27887
  config.inboxCapacity = normalized.inboxCapacity;
28178
27888
  }
28179
- if (normalized.localNodeId) {
28180
- config.localNodeId = normalized.localNodeId;
28181
- }
28182
- if (normalized.remoteNodeId) {
28183
- config.remoteNodeId = normalized.remoteNodeId;
28184
- }
28185
27889
  return config;
28186
27890
  }
28187
27891
 
@@ -28759,8 +28463,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28759
28463
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
28760
28464
  channelName: connectorConfig.channelName,
28761
28465
  inboxCapacity: connectorConfig.inboxCapacity,
28762
- localNodeId: connectorConfig.localNodeId,
28763
- remoteNodeId: connectorConfig.remoteNodeId,
28466
+ initialWindow: connectorConfig.initialWindow,
28764
28467
  };
28765
28468
  }
28766
28469
  const config = {
@@ -28785,6 +28488,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28785
28488
  purpose: 'connection',
28786
28489
  channelName: normalizedConfig.channelName,
28787
28490
  inboxCapacity: normalizedConfig.inboxCapacity,
28491
+ initialWindow: normalizedConfig.initialWindow,
28788
28492
  });
28789
28493
  return grant;
28790
28494
  }
@@ -28810,8 +28514,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28810
28514
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
28811
28515
  channelName,
28812
28516
  inboxCapacity,
28813
- localNodeId: normalized.localNodeId,
28814
- remoteNodeId: normalized.remoteNodeId,
28815
28517
  };
28816
28518
  const connector = new BroadcastChannelConnector(connectorConfig, baseConfig);
28817
28519
  if (options.authorization) {
@@ -28873,16 +28575,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
28873
28575
  if (candidate.authorizationContext !== undefined) {
28874
28576
  normalized.authorizationContext = candidate.authorizationContext;
28875
28577
  }
28876
- // Handle localNodeId
28877
- const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
28878
- if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
28879
- normalized.localNodeId = localNodeId.trim();
28880
- }
28881
- // Handle remoteNodeId
28882
- const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
28883
- if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
28884
- normalized.remoteNodeId = remoteNodeId.trim();
28885
- }
28886
28578
  normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$5;
28887
28579
  normalized.inboxCapacity =
28888
28580
  normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
@@ -29446,8 +29138,6 @@ class InPageConnectorFactory extends ConnectorFactory {
29446
29138
  type: INPAGE_CONNECTOR_TYPE,
29447
29139
  channelName,
29448
29140
  inboxCapacity,
29449
- localNodeId: normalized.localNodeId,
29450
- remoteNodeId: normalized.remoteNodeId,
29451
29141
  };
29452
29142
  const connector = new InPageConnector(connectorConfig, baseConfig);
29453
29143
  if (options.authorization) {
@@ -29516,16 +29206,6 @@ class InPageConnectorFactory extends ConnectorFactory {
29516
29206
  if (candidate.authorizationContext !== undefined) {
29517
29207
  normalized.authorizationContext = candidate.authorizationContext;
29518
29208
  }
29519
- // Handle localNodeId
29520
- const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
29521
- if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
29522
- normalized.localNodeId = localNodeId.trim();
29523
- }
29524
- // Handle remoteNodeId
29525
- const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
29526
- if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
29527
- normalized.remoteNodeId = remoteNodeId.trim();
29528
- }
29529
29209
  normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$3;
29530
29210
  normalized.inboxCapacity =
29531
29211
  normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$3;
@@ -36291,18 +35971,13 @@ class BroadcastChannelListener extends TransportListener {
36291
35971
  });
36292
35972
  }
36293
35973
  asCallbackGrant() {
36294
- const grant = {
35974
+ return this.withLegacySnakeCaseKeys({
36295
35975
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
36296
35976
  connectorType: BROADCAST_CHANNEL_CONNECTOR_TYPE,
36297
35977
  connectionGrantType: BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE,
36298
35978
  channelName: this._channelName,
36299
35979
  inboxCapacity: this._inboxCapacity,
36300
- };
36301
- // Include localNodeId for transport frame multiplexing if node is available
36302
- if (this._routingNode) {
36303
- grant.localNodeId = this._routingNode.id;
36304
- }
36305
- return this.withLegacySnakeCaseKeys(grant);
35980
+ });
36306
35981
  }
36307
35982
  _registerChannelListener() {
36308
35983
  if (this._channelHandler) {
@@ -36362,54 +36037,23 @@ class BroadcastChannelListener extends TransportListener {
36362
36037
  if (typeof senderId !== 'string' || senderId.length === 0) {
36363
36038
  return null;
36364
36039
  }
36365
- // Check if payload is a transport frame object first
36366
- let envelopePayload = null;
36367
- if (this._routingNode && record.payload && typeof record.payload === 'object') {
36368
- // Try to unwrap as transport frame
36369
- const frame = unwrapTransportFrame(record.payload);
36370
- if (frame) {
36371
- // Apply listener's filtering policy: accept frames addressed to us OR with wildcard destination
36372
- // Wildcard is needed because downstream nodes don't know the sentinel's ID during initial attach
36373
- const isAddressedToUs = frame.dst === this._routingNode.id || frame.dst === '*';
36374
- if (isAddressedToUs) {
36375
- envelopePayload = frame.payload;
36376
- logger$a.debug('broadcast_channel_listener_unwrapped_transport_frame', {
36377
- sender_id: senderId,
36378
- src: frame.src,
36379
- dst: frame.dst,
36380
- });
36381
- }
36382
- else {
36383
- // Frame addressed to a different node, ignore it
36384
- logger$a.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
36385
- sender_id: senderId,
36386
- dst: frame.dst,
36387
- expected: this._routingNode.id,
36388
- });
36389
- return null;
36390
- }
36391
- }
36392
- }
36393
- // If not a transport frame, try to coerce as legacy format
36394
- if (!envelopePayload) {
36395
- envelopePayload = coercePayload$1(record.payload);
36396
- if (!envelopePayload) {
36397
- logger$a.debug('broadcast_channel_listener_ignored_event_without_payload', {
36398
- sender_id: senderId,
36399
- });
36400
- return null;
36401
- }
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;
36402
36046
  }
36403
36047
  let envelope;
36404
36048
  try {
36405
- const decoded = new TextDecoder().decode(envelopePayload);
36049
+ const decoded = new TextDecoder().decode(payload);
36406
36050
  const parsed = JSON.parse(decoded);
36407
36051
  envelope = core.deserializeEnvelope(parsed);
36408
36052
  }
36409
36053
  catch (error) {
36410
36054
  const decoded = (() => {
36411
36055
  try {
36412
- return new TextDecoder().decode(envelopePayload);
36056
+ return new TextDecoder().decode(payload);
36413
36057
  }
36414
36058
  catch {
36415
36059
  return null;
@@ -36529,20 +36173,6 @@ class BroadcastChannelListener extends TransportListener {
36529
36173
  inboxCapacity: this._inboxCapacity,
36530
36174
  };
36531
36175
  }
36532
- // Automatically configure transport frame multiplexing:
36533
- // Use node IDs (not connector IDs) for node-to-node targeting
36534
- const broadcastConfig = connectorConfig;
36535
- // Always force localNodeId to be this listener's node ID
36536
- // This ensures the sentinel sets localNodeId=sentinel, not the child's ID
36537
- broadcastConfig.localNodeId = routingNode.id;
36538
- // Always force remoteNodeId to be the attaching child's system ID
36539
- broadcastConfig.remoteNodeId = systemId;
36540
- logger$a.debug('broadcast_channel_listener_configured_node_ids', {
36541
- sender_id: params.senderId,
36542
- system_id: systemId,
36543
- local_node_id: broadcastConfig.localNodeId,
36544
- remote_node_id: broadcastConfig.remoteNodeId,
36545
- });
36546
36176
  try {
36547
36177
  const connector = await routingNode.createOriginConnector({
36548
36178
  originType,
@@ -36612,21 +36242,6 @@ class BroadcastChannelListener extends TransportListener {
36612
36242
  inboxCandidate > 0) {
36613
36243
  config.inboxCapacity = Math.floor(inboxCandidate);
36614
36244
  }
36615
- // Extract transport frame multiplexing node IDs
36616
- const localNodeIdCandidate = candidate.localNodeId ?? candidate['local_node_id'];
36617
- if (typeof localNodeIdCandidate === 'string' && localNodeIdCandidate.trim().length > 0) {
36618
- config.localNodeId = localNodeIdCandidate.trim();
36619
- logger$a.debug('broadcast_channel_listener_extracted_local_node_id', {
36620
- local_node_id: config.localNodeId,
36621
- });
36622
- }
36623
- const remoteNodeIdCandidate = candidate.remoteNodeId ?? candidate['remote_node_id'];
36624
- if (typeof remoteNodeIdCandidate === 'string' && remoteNodeIdCandidate.trim().length > 0) {
36625
- config.remoteNodeId = remoteNodeIdCandidate.trim();
36626
- logger$a.debug('broadcast_channel_listener_extracted_remote_node_id', {
36627
- remote_node_id: config.remoteNodeId,
36628
- });
36629
- }
36630
36245
  return config;
36631
36246
  }
36632
36247
  _monitorConnectorLifecycle(senderId, systemId, connector) {
@@ -37349,7 +36964,6 @@ class InPageListener extends TransportListener {
37349
36964
  this._busHandler = null;
37350
36965
  this._senderRegistry = new Map();
37351
36966
  this._systemToSender = new Map();
37352
- this._flowIdToSender = new Map();
37353
36967
  this._pendingAttachments = new Map();
37354
36968
  ensureBrowserEnvironment();
37355
36969
  const channelCandidate = options?.channelName;
@@ -37416,7 +37030,6 @@ class InPageListener extends TransportListener {
37416
37030
  this._unregisterBusListener();
37417
37031
  this._senderRegistry.clear();
37418
37032
  this._systemToSender.clear();
37419
- this._flowIdToSender.clear();
37420
37033
  this._pendingAttachments.clear();
37421
37034
  logger$7.debug('inpage_listener_stopped', {
37422
37035
  channel: this._channelName,
@@ -37470,25 +37083,10 @@ class InPageListener extends TransportListener {
37470
37083
  await this._handleAttachFrame(senderId, envelope);
37471
37084
  return;
37472
37085
  }
37473
- // Try to find connector by sender ID first
37474
- let entry = this._senderRegistry.get(senderId);
37475
- // If not found and we have a flowId, try to route based on flow
37476
- if (!entry && envelope.flowId) {
37477
- const originalSenderId = this._flowIdToSender.get(envelope.flowId);
37478
- if (originalSenderId) {
37479
- entry = this._senderRegistry.get(originalSenderId);
37480
- logger$7.debug('inpage_listener_routed_by_flow_id', {
37481
- sender_id: senderId,
37482
- original_sender_id: originalSenderId,
37483
- flow_id: envelope.flowId,
37484
- frame_type: envelope.frame?.type ?? 'unknown',
37485
- });
37486
- }
37487
- }
37086
+ const entry = this._senderRegistry.get(senderId);
37488
37087
  if (!entry) {
37489
37088
  logger$7.debug('inpage_listener_no_connector_for_sender', {
37490
37089
  sender_id: senderId,
37491
- flow_id: envelope.flowId,
37492
37090
  frame_type: envelope.frame?.type ?? 'unknown',
37493
37091
  });
37494
37092
  return;
@@ -37565,15 +37163,6 @@ class InPageListener extends TransportListener {
37565
37163
  }
37566
37164
  this._senderRegistry.set(senderId, entry);
37567
37165
  this._systemToSender.set(entry.systemId, senderId);
37568
- // Track the flowId if present so we can route responses back
37569
- if (envelope.flowId) {
37570
- this._flowIdToSender.set(envelope.flowId, senderId);
37571
- logger$7.debug('inpage_listener_registered_flow_id', {
37572
- sender_id: senderId,
37573
- system_id: entry.systemId,
37574
- flow_id: envelope.flowId,
37575
- });
37576
- }
37577
37166
  await this._deliverEnvelope(entry, envelope);
37578
37167
  }
37579
37168
  async _createConnectorForAttach(params) {
@@ -37621,7 +37210,7 @@ class InPageListener extends TransportListener {
37621
37210
  origin_type: originType,
37622
37211
  connector_type: connector.constructor?.name ?? 'unknown',
37623
37212
  });
37624
- return { connector, systemId, originType, senderId: params.senderId };
37213
+ return { connector, systemId, originType };
37625
37214
  }
37626
37215
  catch (error) {
37627
37216
  logger$7.error('inpage_listener_connector_creation_failed', {
@@ -37675,12 +37264,6 @@ class InPageListener extends TransportListener {
37675
37264
  if (this._systemToSender.get(systemId) === senderId) {
37676
37265
  this._systemToSender.delete(systemId);
37677
37266
  }
37678
- // Clean up flowId mappings for this sender
37679
- for (const [flowId, sid] of this._flowIdToSender.entries()) {
37680
- if (sid === senderId) {
37681
- this._flowIdToSender.delete(flowId);
37682
- }
37683
- }
37684
37267
  })
37685
37268
  .catch((error) => {
37686
37269
  logger$7.debug('inpage_listener_wait_until_closed_failed', {
@@ -37692,24 +37275,9 @@ class InPageListener extends TransportListener {
37692
37275
  if (this._systemToSender.get(systemId) === senderId) {
37693
37276
  this._systemToSender.delete(systemId);
37694
37277
  }
37695
- // Clean up flowId mappings for this sender
37696
- for (const [flowId, sid] of this._flowIdToSender.entries()) {
37697
- if (sid === senderId) {
37698
- this._flowIdToSender.delete(flowId);
37699
- }
37700
- }
37701
37278
  });
37702
37279
  }
37703
37280
  async _deliverEnvelope(entry, envelope) {
37704
- // Track flowId for routing responses back
37705
- if (envelope.flowId && !this._flowIdToSender.has(envelope.flowId)) {
37706
- this._flowIdToSender.set(envelope.flowId, entry.senderId);
37707
- logger$7.debug('inpage_listener_registered_flow_id_on_delivery', {
37708
- sender_id: entry.senderId,
37709
- system_id: entry.systemId,
37710
- flow_id: envelope.flowId,
37711
- });
37712
- }
37713
37281
  const message = this._buildChannelMessage({
37714
37282
  envelope,
37715
37283
  connector: entry.connector,