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