@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
@@ -5477,12 +5477,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
5477
5477
  }
5478
5478
 
5479
5479
  // This file is auto-generated during build - do not edit manually
5480
- // Generated from package.json version: 0.3.5-test.952
5480
+ // Generated from package.json version: 0.3.5-test.954
5481
5481
  /**
5482
5482
  * The package version, injected at build time.
5483
5483
  * @internal
5484
5484
  */
5485
- const VERSION = '0.3.5-test.952';
5485
+ const VERSION = '0.3.5-test.954';
5486
5486
 
5487
5487
  /**
5488
5488
  * Fame errors module - Fame protocol specific error classes
@@ -11470,100 +11470,6 @@ class BoundedAsyncQueue {
11470
11470
  }
11471
11471
  }
11472
11472
 
11473
- /**
11474
- * Transport frame layer for multiplexing logical links on physical channels.
11475
- *
11476
- * This lightweight framing layer wraps raw FAME payloads to enable multiple
11477
- * logical connections over a single physical channel (BroadcastChannel or InPage bus).
11478
- *
11479
- * The transport frame does NOT modify FAME envelopes - it only wraps the raw
11480
- * Uint8Array payload at the connector level.
11481
- */
11482
- /**
11483
- * Transport frame version for future compatibility
11484
- */
11485
- const TRANSPORT_FRAME_VERSION = 1;
11486
- /**
11487
- * Wrap a raw payload in a transport frame
11488
- *
11489
- * @param payload - Raw FAME envelope bytes
11490
- * @param srcNodeId - Local node ID (this connector)
11491
- * @param dstNodeId - Remote node ID (target connector)
11492
- * @returns Transport frame ready for transmission
11493
- */
11494
- function wrapTransportFrame(payload, srcNodeId, dstNodeId) {
11495
- return {
11496
- v: TRANSPORT_FRAME_VERSION,
11497
- src: srcNodeId,
11498
- dst: dstNodeId,
11499
- payload,
11500
- };
11501
- }
11502
- /**
11503
- * Serialize a transport frame for transmission over the bus
11504
- *
11505
- * @param frame - Transport frame to serialize
11506
- * @returns Serialized frame data ready for postMessage/dispatchEvent
11507
- */
11508
- function serializeTransportFrame(frame) {
11509
- // Convert Uint8Array to regular array for JSON serialization
11510
- const serializable = {
11511
- v: frame.v,
11512
- src: frame.src,
11513
- dst: frame.dst,
11514
- payload: Array.from(frame.payload),
11515
- };
11516
- return serializable;
11517
- }
11518
- /**
11519
- * Unwrap a transport frame (pure deserializer - no filtering)
11520
- *
11521
- * @param raw - Raw data from the bus
11522
- * @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
11523
- */
11524
- function unwrapTransportFrame(raw) {
11525
- // Validate basic structure
11526
- if (!raw || typeof raw !== 'object') {
11527
- return null;
11528
- }
11529
- const frame = raw;
11530
- // Check version
11531
- if (frame.v !== TRANSPORT_FRAME_VERSION) {
11532
- return null;
11533
- }
11534
- // Check src and dst
11535
- if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
11536
- return null;
11537
- }
11538
- // Extract payload
11539
- if (!frame.payload || !Array.isArray(frame.payload)) {
11540
- return null;
11541
- }
11542
- // Convert array back to Uint8Array and return full frame
11543
- return {
11544
- v: frame.v,
11545
- src: frame.src,
11546
- dst: frame.dst,
11547
- payload: Uint8Array.from(frame.payload),
11548
- };
11549
- }
11550
- /**
11551
- * Check if raw data looks like a transport frame
11552
- *
11553
- * @param raw - Raw data from the bus
11554
- * @returns True if this appears to be a transport frame
11555
- */
11556
- function isTransportFrame(raw) {
11557
- if (!raw || typeof raw !== 'object') {
11558
- return false;
11559
- }
11560
- const frame = raw;
11561
- return (typeof frame.v === 'number' &&
11562
- typeof frame.src === 'string' &&
11563
- typeof frame.dst === 'string' &&
11564
- Array.isArray(frame.payload));
11565
- }
11566
-
11567
11473
  const logger$10 = getLogger('naylence.fame.connector.broadcast_channel_connector');
11568
11474
  const BROADCAST_CHANNEL_CONNECTOR_TYPE$1 = 'broadcast-channel-connector';
11569
11475
  const DEFAULT_CHANNEL$7 = 'naylence-fabric';
@@ -11629,20 +11535,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11629
11535
  this.inbox = new BoundedAsyncQueue(preferredCapacity);
11630
11536
  this.connectorId = BroadcastChannelConnector.generateConnectorId();
11631
11537
  this.channel = new BroadcastChannel(this.channelName);
11632
- // Set local and remote node IDs (defaults to connector ID for backwards compatibility)
11633
- this.localNodeId =
11634
- typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
11635
- ? config.localNodeId.trim()
11636
- : this.connectorId;
11637
- this.remoteNodeId =
11638
- typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
11639
- ? config.remoteNodeId.trim()
11640
- : '*'; // Accept from any remote if not specified
11641
11538
  logger$10.debug('broadcast_channel_connector_created', {
11642
11539
  channel: this.channelName,
11643
11540
  connector_id: this.connectorId,
11644
- local_node_id: this.localNodeId,
11645
- remote_node_id: this.remoteNodeId,
11646
11541
  inbox_capacity: preferredCapacity,
11647
11542
  timestamp: new Date().toISOString(),
11648
11543
  });
@@ -11675,67 +11570,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11675
11570
  if (busMessage.senderId === this.connectorId) {
11676
11571
  return;
11677
11572
  }
11678
- // Try to unwrap as transport frame
11679
- const frame = unwrapTransportFrame(busMessage.payload);
11680
- if (frame) {
11681
- // Apply connector's filtering policy: strict dst check, src accepts wildcard
11682
- const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
11683
- const dstMatches = frame.dst === this.localNodeId;
11684
- if (dstMatches && srcMatches) {
11685
- // Successfully received and filtered transport frame
11686
- logger$10.debug('broadcast_channel_transport_frame_received', {
11687
- channel: this.channelName,
11688
- sender_id: busMessage.senderId,
11689
- connector_id: this.connectorId,
11690
- local_node_id: this.localNodeId,
11691
- remote_node_id: this.remoteNodeId,
11692
- frame_src: frame.src,
11693
- frame_dst: frame.dst,
11694
- payload_length: frame.payload.byteLength,
11695
- });
11696
- const unwrapped = frame.payload;
11697
- if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
11698
- return;
11699
- }
11700
- try {
11701
- if (typeof this.inbox.tryEnqueue === 'function') {
11702
- const accepted = this.inbox.tryEnqueue(unwrapped);
11703
- if (accepted) {
11704
- return;
11705
- }
11706
- }
11707
- this.inbox.enqueue(unwrapped);
11708
- }
11709
- catch (error) {
11710
- if (error instanceof QueueFullError) {
11711
- logger$10.warning('broadcast_channel_receive_queue_full', {
11712
- channel: this.channelName,
11713
- });
11714
- }
11715
- else {
11716
- logger$10.error('broadcast_channel_receive_error', {
11717
- channel: this.channelName,
11718
- error: error instanceof Error ? error.message : String(error),
11719
- });
11720
- }
11721
- }
11722
- return;
11723
- }
11724
- else {
11725
- // Frame filtered out by addressing rules
11726
- logger$10.debug('broadcast_channel_transport_frame_filtered', {
11727
- channel: this.channelName,
11728
- connector_id: this.connectorId,
11729
- local_node_id: this.localNodeId,
11730
- remote_node_id: this.remoteNodeId,
11731
- frame_src: frame.src,
11732
- frame_dst: frame.dst,
11733
- reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
11734
- });
11735
- return;
11736
- }
11737
- }
11738
- // Fall back to legacy format (no transport frame)
11739
11573
  const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
11740
11574
  if (!payload) {
11741
11575
  logger$10.debug('broadcast_channel_payload_rejected', {
@@ -11874,26 +11708,10 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11874
11708
  logger$10.debug('broadcast_channel_message_sending', {
11875
11709
  channel: this.channelName,
11876
11710
  sender_id: this.connectorId,
11877
- local_node_id: this.localNodeId,
11878
- remote_node_id: this.remoteNodeId,
11879
- });
11880
- // Only use transport framing if both localNodeId and remoteNodeId are explicitly set
11881
- // (not using default values). This ensures backwards compatibility.
11882
- const useTransportFrame = this.localNodeId !== this.connectorId ||
11883
- this.remoteNodeId !== '*';
11884
- let payload;
11885
- if (useTransportFrame) {
11886
- // Wrap payload in transport frame
11887
- const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
11888
- payload = serializeTransportFrame(frame);
11889
- }
11890
- else {
11891
- // Legacy format: send raw payload
11892
- payload = data;
11893
- }
11711
+ });
11894
11712
  this.channel.postMessage({
11895
11713
  senderId: this.connectorId,
11896
- payload,
11714
+ payload: data,
11897
11715
  });
11898
11716
  }
11899
11717
  async _transportReceive() {
@@ -12141,12 +11959,9 @@ function isBroadcastChannelConnectionGrant(candidate) {
12141
11959
  record.inboxCapacity <= 0)) {
12142
11960
  return false;
12143
11961
  }
12144
- if (record.localNodeId !== undefined &&
12145
- (typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
12146
- return false;
12147
- }
12148
- if (record.remoteNodeId !== undefined &&
12149
- (typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
11962
+ if (record.initialWindow !== undefined &&
11963
+ (!Number.isFinite(record.initialWindow) ||
11964
+ record.initialWindow <= 0)) {
12150
11965
  return false;
12151
11966
  }
12152
11967
  return true;
@@ -12182,19 +11997,14 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
12182
11997
  }
12183
11998
  result.inboxCapacity = Math.floor(inboxValue);
12184
11999
  }
12185
- const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
12186
- if (localNodeIdValue !== undefined) {
12187
- if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
12188
- throw new TypeError('BroadcastChannelConnectionGrant "localNodeId" must be a non-empty string when provided');
12000
+ const windowValue = candidate.initialWindow ?? candidate['initial_window'];
12001
+ if (windowValue !== undefined) {
12002
+ if (typeof windowValue !== 'number' ||
12003
+ !Number.isFinite(windowValue) ||
12004
+ windowValue <= 0) {
12005
+ throw new TypeError('BroadcastChannelConnectionGrant "initialWindow" must be a positive number when provided');
12189
12006
  }
12190
- result.localNodeId = localNodeIdValue.trim();
12191
- }
12192
- const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
12193
- if (remoteNodeIdValue !== undefined) {
12194
- if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
12195
- throw new TypeError('BroadcastChannelConnectionGrant "remoteNodeId" must be a non-empty string when provided');
12196
- }
12197
- result.remoteNodeId = remoteNodeIdValue.trim();
12007
+ result.initialWindow = Math.floor(windowValue);
12198
12008
  }
12199
12009
  return result;
12200
12010
  }
@@ -12209,11 +12019,8 @@ function broadcastChannelGrantToConnectorConfig(grant) {
12209
12019
  if (normalized.inboxCapacity !== undefined) {
12210
12020
  config.inboxCapacity = normalized.inboxCapacity;
12211
12021
  }
12212
- if (normalized.localNodeId) {
12213
- config.localNodeId = normalized.localNodeId;
12214
- }
12215
- if (normalized.remoteNodeId) {
12216
- config.remoteNodeId = normalized.remoteNodeId;
12022
+ if (normalized.initialWindow !== undefined) {
12023
+ config.initialWindow = normalized.initialWindow;
12217
12024
  }
12218
12025
  return config;
12219
12026
  }
@@ -12505,12 +12312,6 @@ class UpstreamSessionManager extends TaskSpawner {
12505
12312
  cryptoProvider.prepareForAttach(welcome.frame.systemId, welcome.frame.assignedPath, welcome.frame.acceptedLogicals ?? []);
12506
12313
  }
12507
12314
  await this.onWelcome(welcome.frame);
12508
- // Inject node ID into grant for transport frame multiplexing
12509
- // This ensures localNodeId matches the node's systemId for proper frame filtering
12510
- grant.localNodeId = welcome.frame.systemId;
12511
- if (welcome.frame.targetSystemId) {
12512
- grant.remoteNodeId = welcome.frame.targetSystemId;
12513
- }
12514
12315
  const connector = await ConnectorFactory.createConnector(grant, {
12515
12316
  systemId: welcome.frame.systemId,
12516
12317
  });
@@ -21653,20 +21454,9 @@ class InPageConnector extends BaseAsyncConnector {
21653
21454
  : DEFAULT_INBOX_CAPACITY$6;
21654
21455
  this.inbox = new BoundedAsyncQueue(preferredCapacity);
21655
21456
  this.connectorId = InPageConnector.generateConnectorId();
21656
- // Set local and remote node IDs (defaults to connector ID for backwards compatibility)
21657
- this.localNodeId =
21658
- typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
21659
- ? config.localNodeId.trim()
21660
- : this.connectorId;
21661
- this.remoteNodeId =
21662
- typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
21663
- ? config.remoteNodeId.trim()
21664
- : '*'; // Accept from any remote if not specified
21665
21457
  logger$J.debug('inpage_connector_initialized', {
21666
21458
  channel: this.channelName,
21667
21459
  connector_id: this.connectorId,
21668
- local_node_id: this.localNodeId,
21669
- remote_node_id: this.remoteNodeId,
21670
21460
  });
21671
21461
  this.onMsg = (event) => {
21672
21462
  const messageEvent = event;
@@ -21700,64 +21490,6 @@ class InPageConnector extends BaseAsyncConnector {
21700
21490
  if (busMessage.senderId === this.connectorId) {
21701
21491
  return;
21702
21492
  }
21703
- // Try to unwrap as transport frame
21704
- const frame = unwrapTransportFrame(busMessage.payload);
21705
- if (frame) {
21706
- // Apply connector's filtering policy: strict dst check, src accepts wildcard
21707
- const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
21708
- const dstMatches = frame.dst === this.localNodeId;
21709
- if (dstMatches && srcMatches) {
21710
- // Successfully received and filtered transport frame
21711
- logger$J.debug('inpage_transport_frame_received', {
21712
- channel: this.channelName,
21713
- sender_id: busMessage.senderId,
21714
- connector_id: this.connectorId,
21715
- local_node_id: this.localNodeId,
21716
- remote_node_id: this.remoteNodeId,
21717
- frame_src: frame.src,
21718
- frame_dst: frame.dst,
21719
- payload_length: frame.payload.byteLength,
21720
- });
21721
- const unwrapped = frame.payload;
21722
- try {
21723
- if (typeof this.inbox.tryEnqueue === 'function') {
21724
- const accepted = this.inbox.tryEnqueue(unwrapped);
21725
- if (accepted) {
21726
- return;
21727
- }
21728
- }
21729
- this.inbox.enqueue(unwrapped);
21730
- }
21731
- catch (error) {
21732
- if (error instanceof QueueFullError) {
21733
- logger$J.warning('inpage_receive_queue_full', {
21734
- channel: this.channelName,
21735
- });
21736
- }
21737
- else {
21738
- logger$J.error('inpage_receive_error', {
21739
- channel: this.channelName,
21740
- error: error instanceof Error ? error.message : String(error),
21741
- });
21742
- }
21743
- }
21744
- return;
21745
- }
21746
- else {
21747
- // Frame filtered out by addressing rules
21748
- logger$J.debug('inpage_transport_frame_filtered', {
21749
- channel: this.channelName,
21750
- connector_id: this.connectorId,
21751
- local_node_id: this.localNodeId,
21752
- remote_node_id: this.remoteNodeId,
21753
- frame_src: frame.src,
21754
- frame_dst: frame.dst,
21755
- reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
21756
- });
21757
- return;
21758
- }
21759
- }
21760
- // Fall back to legacy format (no transport frame)
21761
21493
  const payload = InPageConnector.coercePayload(busMessage.payload);
21762
21494
  if (!payload) {
21763
21495
  logger$J.debug('inpage_payload_rejected', {
@@ -21916,27 +21648,11 @@ class InPageConnector extends BaseAsyncConnector {
21916
21648
  logger$J.debug('inpage_message_sending', {
21917
21649
  channel: this.channelName,
21918
21650
  sender_id: this.connectorId,
21919
- local_node_id: this.localNodeId,
21920
- remote_node_id: this.remoteNodeId,
21921
- });
21922
- // Only use transport framing if both localNodeId and remoteNodeId are explicitly set
21923
- // (not using default values). This ensures backwards compatibility.
21924
- const useTransportFrame = this.localNodeId !== this.connectorId ||
21925
- this.remoteNodeId !== '*';
21926
- let payload;
21927
- if (useTransportFrame) {
21928
- // Wrap payload in transport frame
21929
- const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
21930
- payload = serializeTransportFrame(frame);
21931
- }
21932
- else {
21933
- // Legacy format: send raw payload
21934
- payload = data;
21935
- }
21651
+ });
21936
21652
  const event = new MessageEvent(this.channelName, {
21937
21653
  data: {
21938
21654
  senderId: this.connectorId,
21939
- payload,
21655
+ payload: data,
21940
21656
  },
21941
21657
  });
21942
21658
  getSharedBus$1().dispatchEvent(event);
@@ -29248,14 +28964,6 @@ function isInPageConnectionGrant(candidate) {
29248
28964
  record.inboxCapacity <= 0)) {
29249
28965
  return false;
29250
28966
  }
29251
- if (record.localNodeId !== undefined &&
29252
- (typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
29253
- return false;
29254
- }
29255
- if (record.remoteNodeId !== undefined &&
29256
- (typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
29257
- return false;
29258
- }
29259
28967
  return true;
29260
28968
  }
29261
28969
  function normalizeInPageConnectionGrant(candidate) {
@@ -29289,20 +28997,6 @@ function normalizeInPageConnectionGrant(candidate) {
29289
28997
  }
29290
28998
  result.inboxCapacity = Math.floor(inboxValue);
29291
28999
  }
29292
- const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
29293
- if (localNodeIdValue !== undefined) {
29294
- if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
29295
- throw new TypeError('InPageConnectionGrant "localNodeId" must be a non-empty string when provided');
29296
- }
29297
- result.localNodeId = localNodeIdValue.trim();
29298
- }
29299
- const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
29300
- if (remoteNodeIdValue !== undefined) {
29301
- if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
29302
- throw new TypeError('InPageConnectionGrant "remoteNodeId" must be a non-empty string when provided');
29303
- }
29304
- result.remoteNodeId = remoteNodeIdValue.trim();
29305
- }
29306
29000
  return result;
29307
29001
  }
29308
29002
  function inPageGrantToConnectorConfig(grant) {
@@ -29316,12 +29010,6 @@ function inPageGrantToConnectorConfig(grant) {
29316
29010
  if (normalized.inboxCapacity !== undefined) {
29317
29011
  config.inboxCapacity = normalized.inboxCapacity;
29318
29012
  }
29319
- if (normalized.localNodeId) {
29320
- config.localNodeId = normalized.localNodeId;
29321
- }
29322
- if (normalized.remoteNodeId) {
29323
- config.remoteNodeId = normalized.remoteNodeId;
29324
- }
29325
29013
  return config;
29326
29014
  }
29327
29015
 
@@ -30589,8 +30277,6 @@ class InPageConnectorFactory extends ConnectorFactory {
30589
30277
  type: INPAGE_CONNECTOR_TYPE,
30590
30278
  channelName,
30591
30279
  inboxCapacity,
30592
- localNodeId: normalized.localNodeId,
30593
- remoteNodeId: normalized.remoteNodeId,
30594
30280
  };
30595
30281
  const connector = new InPageConnector(connectorConfig, baseConfig);
30596
30282
  if (options.authorization) {
@@ -30659,16 +30345,6 @@ class InPageConnectorFactory extends ConnectorFactory {
30659
30345
  if (candidate.authorizationContext !== undefined) {
30660
30346
  normalized.authorizationContext = candidate.authorizationContext;
30661
30347
  }
30662
- // Handle localNodeId
30663
- const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
30664
- if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
30665
- normalized.localNodeId = localNodeId.trim();
30666
- }
30667
- // Handle remoteNodeId
30668
- const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
30669
- if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
30670
- normalized.remoteNodeId = remoteNodeId.trim();
30671
- }
30672
30348
  normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$3;
30673
30349
  normalized.inboxCapacity =
30674
30350
  normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$3;
@@ -30719,8 +30395,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30719
30395
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
30720
30396
  channelName: connectorConfig.channelName,
30721
30397
  inboxCapacity: connectorConfig.inboxCapacity,
30722
- localNodeId: connectorConfig.localNodeId,
30723
- remoteNodeId: connectorConfig.remoteNodeId,
30398
+ initialWindow: connectorConfig.initialWindow,
30724
30399
  };
30725
30400
  }
30726
30401
  const config = {
@@ -30745,6 +30420,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30745
30420
  purpose: 'connection',
30746
30421
  channelName: normalizedConfig.channelName,
30747
30422
  inboxCapacity: normalizedConfig.inboxCapacity,
30423
+ initialWindow: normalizedConfig.initialWindow,
30748
30424
  });
30749
30425
  return grant;
30750
30426
  }
@@ -30770,8 +30446,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30770
30446
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
30771
30447
  channelName,
30772
30448
  inboxCapacity,
30773
- localNodeId: normalized.localNodeId,
30774
- remoteNodeId: normalized.remoteNodeId,
30775
30449
  };
30776
30450
  const connector = new BroadcastChannelConnector(connectorConfig, baseConfig);
30777
30451
  if (options.authorization) {
@@ -30833,16 +30507,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
30833
30507
  if (candidate.authorizationContext !== undefined) {
30834
30508
  normalized.authorizationContext = candidate.authorizationContext;
30835
30509
  }
30836
- // Handle localNodeId
30837
- const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
30838
- if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
30839
- normalized.localNodeId = localNodeId.trim();
30840
- }
30841
- // Handle remoteNodeId
30842
- const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
30843
- if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
30844
- normalized.remoteNodeId = remoteNodeId.trim();
30845
- }
30846
30510
  normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$2;
30847
30511
  normalized.inboxCapacity =
30848
30512
  normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$2;
@@ -32327,7 +31991,6 @@ class InPageListener extends TransportListener {
32327
31991
  this._busHandler = null;
32328
31992
  this._senderRegistry = new Map();
32329
31993
  this._systemToSender = new Map();
32330
- this._flowIdToSender = new Map();
32331
31994
  this._pendingAttachments = new Map();
32332
31995
  ensureBrowserEnvironment$1();
32333
31996
  const channelCandidate = options?.channelName;
@@ -32394,7 +32057,6 @@ class InPageListener extends TransportListener {
32394
32057
  this._unregisterBusListener();
32395
32058
  this._senderRegistry.clear();
32396
32059
  this._systemToSender.clear();
32397
- this._flowIdToSender.clear();
32398
32060
  this._pendingAttachments.clear();
32399
32061
  logger$o.debug('inpage_listener_stopped', {
32400
32062
  channel: this._channelName,
@@ -32448,25 +32110,10 @@ class InPageListener extends TransportListener {
32448
32110
  await this._handleAttachFrame(senderId, envelope);
32449
32111
  return;
32450
32112
  }
32451
- // Try to find connector by sender ID first
32452
- let entry = this._senderRegistry.get(senderId);
32453
- // If not found and we have a flowId, try to route based on flow
32454
- if (!entry && envelope.flowId) {
32455
- const originalSenderId = this._flowIdToSender.get(envelope.flowId);
32456
- if (originalSenderId) {
32457
- entry = this._senderRegistry.get(originalSenderId);
32458
- logger$o.debug('inpage_listener_routed_by_flow_id', {
32459
- sender_id: senderId,
32460
- original_sender_id: originalSenderId,
32461
- flow_id: envelope.flowId,
32462
- frame_type: envelope.frame?.type ?? 'unknown',
32463
- });
32464
- }
32465
- }
32113
+ const entry = this._senderRegistry.get(senderId);
32466
32114
  if (!entry) {
32467
32115
  logger$o.debug('inpage_listener_no_connector_for_sender', {
32468
32116
  sender_id: senderId,
32469
- flow_id: envelope.flowId,
32470
32117
  frame_type: envelope.frame?.type ?? 'unknown',
32471
32118
  });
32472
32119
  return;
@@ -32543,15 +32190,6 @@ class InPageListener extends TransportListener {
32543
32190
  }
32544
32191
  this._senderRegistry.set(senderId, entry);
32545
32192
  this._systemToSender.set(entry.systemId, senderId);
32546
- // Track the flowId if present so we can route responses back
32547
- if (envelope.flowId) {
32548
- this._flowIdToSender.set(envelope.flowId, senderId);
32549
- logger$o.debug('inpage_listener_registered_flow_id', {
32550
- sender_id: senderId,
32551
- system_id: entry.systemId,
32552
- flow_id: envelope.flowId,
32553
- });
32554
- }
32555
32193
  await this._deliverEnvelope(entry, envelope);
32556
32194
  }
32557
32195
  async _createConnectorForAttach(params) {
@@ -32599,7 +32237,7 @@ class InPageListener extends TransportListener {
32599
32237
  origin_type: originType,
32600
32238
  connector_type: connector.constructor?.name ?? 'unknown',
32601
32239
  });
32602
- return { connector, systemId, originType, senderId: params.senderId };
32240
+ return { connector, systemId, originType };
32603
32241
  }
32604
32242
  catch (error) {
32605
32243
  logger$o.error('inpage_listener_connector_creation_failed', {
@@ -32653,12 +32291,6 @@ class InPageListener extends TransportListener {
32653
32291
  if (this._systemToSender.get(systemId) === senderId) {
32654
32292
  this._systemToSender.delete(systemId);
32655
32293
  }
32656
- // Clean up flowId mappings for this sender
32657
- for (const [flowId, sid] of this._flowIdToSender.entries()) {
32658
- if (sid === senderId) {
32659
- this._flowIdToSender.delete(flowId);
32660
- }
32661
- }
32662
32294
  })
32663
32295
  .catch((error) => {
32664
32296
  logger$o.debug('inpage_listener_wait_until_closed_failed', {
@@ -32670,24 +32302,9 @@ class InPageListener extends TransportListener {
32670
32302
  if (this._systemToSender.get(systemId) === senderId) {
32671
32303
  this._systemToSender.delete(systemId);
32672
32304
  }
32673
- // Clean up flowId mappings for this sender
32674
- for (const [flowId, sid] of this._flowIdToSender.entries()) {
32675
- if (sid === senderId) {
32676
- this._flowIdToSender.delete(flowId);
32677
- }
32678
- }
32679
32305
  });
32680
32306
  }
32681
32307
  async _deliverEnvelope(entry, envelope) {
32682
- // Track flowId for routing responses back
32683
- if (envelope.flowId && !this._flowIdToSender.has(envelope.flowId)) {
32684
- this._flowIdToSender.set(envelope.flowId, entry.senderId);
32685
- logger$o.debug('inpage_listener_registered_flow_id_on_delivery', {
32686
- sender_id: entry.senderId,
32687
- system_id: entry.systemId,
32688
- flow_id: envelope.flowId,
32689
- });
32690
- }
32691
32308
  const message = this._buildChannelMessage({
32692
32309
  envelope,
32693
32310
  connector: entry.connector,
@@ -32866,18 +32483,13 @@ class BroadcastChannelListener extends TransportListener {
32866
32483
  });
32867
32484
  }
32868
32485
  asCallbackGrant() {
32869
- const grant = {
32486
+ return this.withLegacySnakeCaseKeys({
32870
32487
  type: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
32871
32488
  connectorType: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
32872
32489
  connectionGrantType: BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE,
32873
32490
  channelName: this._channelName,
32874
32491
  inboxCapacity: this._inboxCapacity,
32875
- };
32876
- // Include localNodeId for transport frame multiplexing if node is available
32877
- if (this._routingNode) {
32878
- grant.localNodeId = this._routingNode.id;
32879
- }
32880
- return this.withLegacySnakeCaseKeys(grant);
32492
+ });
32881
32493
  }
32882
32494
  _registerChannelListener() {
32883
32495
  if (this._channelHandler) {
@@ -32937,54 +32549,23 @@ class BroadcastChannelListener extends TransportListener {
32937
32549
  if (typeof senderId !== 'string' || senderId.length === 0) {
32938
32550
  return null;
32939
32551
  }
32940
- // Check if payload is a transport frame object first
32941
- let envelopePayload = null;
32942
- if (this._routingNode && record.payload && typeof record.payload === 'object') {
32943
- // Try to unwrap as transport frame
32944
- const frame = unwrapTransportFrame(record.payload);
32945
- if (frame) {
32946
- // Apply listener's filtering policy: accept frames addressed to us OR with wildcard destination
32947
- // Wildcard is needed because downstream nodes don't know the sentinel's ID during initial attach
32948
- const isAddressedToUs = frame.dst === this._routingNode.id || frame.dst === '*';
32949
- if (isAddressedToUs) {
32950
- envelopePayload = frame.payload;
32951
- logger$n.debug('broadcast_channel_listener_unwrapped_transport_frame', {
32952
- sender_id: senderId,
32953
- src: frame.src,
32954
- dst: frame.dst,
32955
- });
32956
- }
32957
- else {
32958
- // Frame addressed to a different node, ignore it
32959
- logger$n.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
32960
- sender_id: senderId,
32961
- dst: frame.dst,
32962
- expected: this._routingNode.id,
32963
- });
32964
- return null;
32965
- }
32966
- }
32967
- }
32968
- // If not a transport frame, try to coerce as legacy format
32969
- if (!envelopePayload) {
32970
- envelopePayload = coercePayload(record.payload);
32971
- if (!envelopePayload) {
32972
- logger$n.debug('broadcast_channel_listener_ignored_event_without_payload', {
32973
- sender_id: senderId,
32974
- });
32975
- return null;
32976
- }
32552
+ const payload = coercePayload(record.payload);
32553
+ if (!payload) {
32554
+ logger$n.debug('broadcast_channel_listener_ignored_event_without_payload', {
32555
+ sender_id: senderId,
32556
+ });
32557
+ return null;
32977
32558
  }
32978
32559
  let envelope;
32979
32560
  try {
32980
- const decoded = new TextDecoder().decode(envelopePayload);
32561
+ const decoded = new TextDecoder().decode(payload);
32981
32562
  const parsed = JSON.parse(decoded);
32982
32563
  envelope = deserializeEnvelope(parsed);
32983
32564
  }
32984
32565
  catch (error) {
32985
32566
  const decoded = (() => {
32986
32567
  try {
32987
- return new TextDecoder().decode(envelopePayload);
32568
+ return new TextDecoder().decode(payload);
32988
32569
  }
32989
32570
  catch {
32990
32571
  return null;
@@ -33104,20 +32685,6 @@ class BroadcastChannelListener extends TransportListener {
33104
32685
  inboxCapacity: this._inboxCapacity,
33105
32686
  };
33106
32687
  }
33107
- // Automatically configure transport frame multiplexing:
33108
- // Use node IDs (not connector IDs) for node-to-node targeting
33109
- const broadcastConfig = connectorConfig;
33110
- // Always force localNodeId to be this listener's node ID
33111
- // This ensures the sentinel sets localNodeId=sentinel, not the child's ID
33112
- broadcastConfig.localNodeId = routingNode.id;
33113
- // Always force remoteNodeId to be the attaching child's system ID
33114
- broadcastConfig.remoteNodeId = systemId;
33115
- logger$n.debug('broadcast_channel_listener_configured_node_ids', {
33116
- sender_id: params.senderId,
33117
- system_id: systemId,
33118
- local_node_id: broadcastConfig.localNodeId,
33119
- remote_node_id: broadcastConfig.remoteNodeId,
33120
- });
33121
32688
  try {
33122
32689
  const connector = await routingNode.createOriginConnector({
33123
32690
  originType,
@@ -33187,21 +32754,6 @@ class BroadcastChannelListener extends TransportListener {
33187
32754
  inboxCandidate > 0) {
33188
32755
  config.inboxCapacity = Math.floor(inboxCandidate);
33189
32756
  }
33190
- // Extract transport frame multiplexing node IDs
33191
- const localNodeIdCandidate = candidate.localNodeId ?? candidate['local_node_id'];
33192
- if (typeof localNodeIdCandidate === 'string' && localNodeIdCandidate.trim().length > 0) {
33193
- config.localNodeId = localNodeIdCandidate.trim();
33194
- logger$n.debug('broadcast_channel_listener_extracted_local_node_id', {
33195
- local_node_id: config.localNodeId,
33196
- });
33197
- }
33198
- const remoteNodeIdCandidate = candidate.remoteNodeId ?? candidate['remote_node_id'];
33199
- if (typeof remoteNodeIdCandidate === 'string' && remoteNodeIdCandidate.trim().length > 0) {
33200
- config.remoteNodeId = remoteNodeIdCandidate.trim();
33201
- logger$n.debug('broadcast_channel_listener_extracted_remote_node_id', {
33202
- remote_node_id: config.remoteNodeId,
33203
- });
33204
- }
33205
32757
  return config;
33206
32758
  }
33207
32759
  _monitorConnectorLifecycle(senderId, systemId, connector) {