@naylence/runtime 0.3.5-test.949 → 0.3.5-test.951

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.
@@ -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.949
17
+ // Generated from package.json version: 0.3.5-test.951
18
18
  /**
19
19
  * The package version, injected at build time.
20
20
  * @internal
21
21
  */
22
- const VERSION = '0.3.5-test.949';
22
+ const VERSION = '0.3.5-test.951';
23
23
 
24
24
  /**
25
25
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -9780,14 +9780,12 @@ function serializeTransportFrame(frame) {
9780
9780
  return serializable;
9781
9781
  }
9782
9782
  /**
9783
- * Unwrap a transport frame, validating source and destination
9783
+ * Unwrap a transport frame (pure deserializer - no filtering)
9784
9784
  *
9785
9785
  * @param raw - Raw data from the bus
9786
- * @param localNodeId - This connector's node ID
9787
- * @param remoteNodeId - Expected remote node ID
9788
- * @returns Unwrapped payload if frame is valid and addressed to us, null otherwise
9786
+ * @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
9789
9787
  */
9790
- function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
9788
+ function unwrapTransportFrame(raw) {
9791
9789
  // Validate basic structure
9792
9790
  if (!raw || typeof raw !== 'object') {
9793
9791
  return null;
@@ -9801,16 +9799,17 @@ function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
9801
9799
  if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
9802
9800
  return null;
9803
9801
  }
9804
- // Only accept frames addressed to us from the expected remote
9805
- if (frame.dst !== localNodeId || frame.src !== remoteNodeId) {
9806
- return null;
9807
- }
9808
9802
  // Extract payload
9809
9803
  if (!frame.payload || !Array.isArray(frame.payload)) {
9810
9804
  return null;
9811
9805
  }
9812
- // Convert array back to Uint8Array
9813
- return Uint8Array.from(frame.payload);
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
+ };
9814
9813
  }
9815
9814
 
9816
9815
  const logger$_ = getLogger('naylence.fame.connector.broadcast_channel_connector');
@@ -9925,43 +9924,64 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9925
9924
  return;
9926
9925
  }
9927
9926
  // Try to unwrap as transport frame
9928
- const unwrapped = unwrapTransportFrame(busMessage.payload, this.localNodeId, this.remoteNodeId === '*' ? busMessage.senderId : this.remoteNodeId);
9929
- if (unwrapped) {
9930
- // Successfully unwrapped transport frame
9931
- logger$_.debug('broadcast_channel_transport_frame_received', {
9932
- channel: this.channelName,
9933
- sender_id: busMessage.senderId,
9934
- connector_id: this.connectorId,
9935
- local_node_id: this.localNodeId,
9936
- remote_node_id: this.remoteNodeId,
9937
- payload_length: unwrapped.byteLength,
9938
- });
9939
- if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
9940
- return;
9941
- }
9942
- try {
9943
- if (typeof this.inbox.tryEnqueue === 'function') {
9944
- const accepted = this.inbox.tryEnqueue(unwrapped);
9945
- if (accepted) {
9946
- return;
9947
- }
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;
9948
9947
  }
9949
- this.inbox.enqueue(unwrapped);
9950
- }
9951
- catch (error) {
9952
- if (error instanceof QueueFullError) {
9953
- logger$_.warning('broadcast_channel_receive_queue_full', {
9954
- channel: this.channelName,
9955
- });
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
9956
  }
9957
- else {
9958
- logger$_.error('broadcast_channel_receive_error', {
9959
- channel: this.channelName,
9960
- error: error instanceof Error ? error.message : String(error),
9961
- });
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
+ }
9962
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;
9963
9984
  }
9964
- return;
9965
9985
  }
9966
9986
  // Fall back to legacy format (no transport frame)
9967
9987
  const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
@@ -20488,40 +20508,61 @@ class InPageConnector extends BaseAsyncConnector {
20488
20508
  return;
20489
20509
  }
20490
20510
  // Try to unwrap as transport frame
20491
- const unwrapped = unwrapTransportFrame(busMessage.payload, this.localNodeId, this.remoteNodeId === '*' ? busMessage.senderId : this.remoteNodeId);
20492
- if (unwrapped) {
20493
- // Successfully unwrapped transport frame
20494
- logger$G.debug('inpage_transport_frame_received', {
20495
- channel: this.channelName,
20496
- sender_id: busMessage.senderId,
20497
- connector_id: this.connectorId,
20498
- local_node_id: this.localNodeId,
20499
- remote_node_id: this.remoteNodeId,
20500
- payload_length: unwrapped.byteLength,
20501
- });
20502
- try {
20503
- if (typeof this.inbox.tryEnqueue === 'function') {
20504
- const accepted = this.inbox.tryEnqueue(unwrapped);
20505
- if (accepted) {
20506
- return;
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
+ }
20507
20535
  }
20536
+ this.inbox.enqueue(unwrapped);
20508
20537
  }
20509
- this.inbox.enqueue(unwrapped);
20510
- }
20511
- catch (error) {
20512
- if (error instanceof QueueFullError) {
20513
- logger$G.warning('inpage_receive_queue_full', {
20514
- channel: this.channelName,
20515
- });
20516
- }
20517
- else {
20518
- logger$G.error('inpage_receive_error', {
20519
- channel: this.channelName,
20520
- error: error instanceof Error ? error.message : String(error),
20521
- });
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
+ }
20522
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;
20523
20565
  }
20524
- return;
20525
20566
  }
20526
20567
  // Fall back to legacy format (no transport frame)
20527
20568
  const payload = InPageConnector.coercePayload(busMessage.payload);
@@ -36321,23 +36362,52 @@ class BroadcastChannelListener extends TransportListener {
36321
36362
  if (typeof senderId !== 'string' || senderId.length === 0) {
36322
36363
  return null;
36323
36364
  }
36324
- const payload = coercePayload$1(record.payload);
36325
- if (!payload) {
36326
- logger$a.debug('broadcast_channel_listener_ignored_event_without_payload', {
36327
- sender_id: senderId,
36328
- });
36329
- return null;
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: dst must match, src can be anything
36372
+ if (frame.dst === this._routingNode.id) {
36373
+ envelopePayload = frame.payload;
36374
+ logger$a.debug('broadcast_channel_listener_unwrapped_transport_frame', {
36375
+ sender_id: senderId,
36376
+ src: frame.src,
36377
+ dst: frame.dst,
36378
+ });
36379
+ }
36380
+ else {
36381
+ // Frame not addressed to us, ignore it
36382
+ logger$a.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
36383
+ sender_id: senderId,
36384
+ dst: frame.dst,
36385
+ expected: this._routingNode.id,
36386
+ });
36387
+ return null;
36388
+ }
36389
+ }
36390
+ }
36391
+ // If not a transport frame, try to coerce as legacy format
36392
+ if (!envelopePayload) {
36393
+ envelopePayload = coercePayload$1(record.payload);
36394
+ if (!envelopePayload) {
36395
+ logger$a.debug('broadcast_channel_listener_ignored_event_without_payload', {
36396
+ sender_id: senderId,
36397
+ });
36398
+ return null;
36399
+ }
36330
36400
  }
36331
36401
  let envelope;
36332
36402
  try {
36333
- const decoded = new TextDecoder().decode(payload);
36403
+ const decoded = new TextDecoder().decode(envelopePayload);
36334
36404
  const parsed = JSON.parse(decoded);
36335
36405
  envelope = core.deserializeEnvelope(parsed);
36336
36406
  }
36337
36407
  catch (error) {
36338
36408
  const decoded = (() => {
36339
36409
  try {
36340
- return new TextDecoder().decode(payload);
36410
+ return new TextDecoder().decode(envelopePayload);
36341
36411
  }
36342
36412
  catch {
36343
36413
  return null;
@@ -13,12 +13,12 @@ import fastify from 'fastify';
13
13
  import websocketPlugin from '@fastify/websocket';
14
14
 
15
15
  // This file is auto-generated during build - do not edit manually
16
- // Generated from package.json version: 0.3.5-test.949
16
+ // Generated from package.json version: 0.3.5-test.951
17
17
  /**
18
18
  * The package version, injected at build time.
19
19
  * @internal
20
20
  */
21
- const VERSION = '0.3.5-test.949';
21
+ const VERSION = '0.3.5-test.951';
22
22
 
23
23
  /**
24
24
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -9779,14 +9779,12 @@ function serializeTransportFrame(frame) {
9779
9779
  return serializable;
9780
9780
  }
9781
9781
  /**
9782
- * Unwrap a transport frame, validating source and destination
9782
+ * Unwrap a transport frame (pure deserializer - no filtering)
9783
9783
  *
9784
9784
  * @param raw - Raw data from the bus
9785
- * @param localNodeId - This connector's node ID
9786
- * @param remoteNodeId - Expected remote node ID
9787
- * @returns Unwrapped payload if frame is valid and addressed to us, null otherwise
9785
+ * @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
9788
9786
  */
9789
- function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
9787
+ function unwrapTransportFrame(raw) {
9790
9788
  // Validate basic structure
9791
9789
  if (!raw || typeof raw !== 'object') {
9792
9790
  return null;
@@ -9800,16 +9798,17 @@ function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
9800
9798
  if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
9801
9799
  return null;
9802
9800
  }
9803
- // Only accept frames addressed to us from the expected remote
9804
- if (frame.dst !== localNodeId || frame.src !== remoteNodeId) {
9805
- return null;
9806
- }
9807
9801
  // Extract payload
9808
9802
  if (!frame.payload || !Array.isArray(frame.payload)) {
9809
9803
  return null;
9810
9804
  }
9811
- // Convert array back to Uint8Array
9812
- return Uint8Array.from(frame.payload);
9805
+ // Convert array back to Uint8Array and return full frame
9806
+ return {
9807
+ v: frame.v,
9808
+ src: frame.src,
9809
+ dst: frame.dst,
9810
+ payload: Uint8Array.from(frame.payload),
9811
+ };
9813
9812
  }
9814
9813
 
9815
9814
  const logger$_ = getLogger('naylence.fame.connector.broadcast_channel_connector');
@@ -9924,43 +9923,64 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
9924
9923
  return;
9925
9924
  }
9926
9925
  // Try to unwrap as transport frame
9927
- const unwrapped = unwrapTransportFrame(busMessage.payload, this.localNodeId, this.remoteNodeId === '*' ? busMessage.senderId : this.remoteNodeId);
9928
- if (unwrapped) {
9929
- // Successfully unwrapped transport frame
9930
- logger$_.debug('broadcast_channel_transport_frame_received', {
9931
- channel: this.channelName,
9932
- sender_id: busMessage.senderId,
9933
- connector_id: this.connectorId,
9934
- local_node_id: this.localNodeId,
9935
- remote_node_id: this.remoteNodeId,
9936
- payload_length: unwrapped.byteLength,
9937
- });
9938
- if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
9939
- return;
9940
- }
9941
- try {
9942
- if (typeof this.inbox.tryEnqueue === 'function') {
9943
- const accepted = this.inbox.tryEnqueue(unwrapped);
9944
- if (accepted) {
9945
- return;
9946
- }
9926
+ const frame = unwrapTransportFrame(busMessage.payload);
9927
+ if (frame) {
9928
+ // Apply connector's filtering policy: strict dst check, src accepts wildcard
9929
+ const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
9930
+ const dstMatches = frame.dst === this.localNodeId;
9931
+ if (dstMatches && srcMatches) {
9932
+ // Successfully received and filtered transport frame
9933
+ logger$_.debug('broadcast_channel_transport_frame_received', {
9934
+ channel: this.channelName,
9935
+ sender_id: busMessage.senderId,
9936
+ connector_id: this.connectorId,
9937
+ local_node_id: this.localNodeId,
9938
+ remote_node_id: this.remoteNodeId,
9939
+ frame_src: frame.src,
9940
+ frame_dst: frame.dst,
9941
+ payload_length: frame.payload.byteLength,
9942
+ });
9943
+ const unwrapped = frame.payload;
9944
+ if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
9945
+ return;
9947
9946
  }
9948
- this.inbox.enqueue(unwrapped);
9949
- }
9950
- catch (error) {
9951
- if (error instanceof QueueFullError) {
9952
- logger$_.warning('broadcast_channel_receive_queue_full', {
9953
- channel: this.channelName,
9954
- });
9947
+ try {
9948
+ if (typeof this.inbox.tryEnqueue === 'function') {
9949
+ const accepted = this.inbox.tryEnqueue(unwrapped);
9950
+ if (accepted) {
9951
+ return;
9952
+ }
9953
+ }
9954
+ this.inbox.enqueue(unwrapped);
9955
9955
  }
9956
- else {
9957
- logger$_.error('broadcast_channel_receive_error', {
9958
- channel: this.channelName,
9959
- error: error instanceof Error ? error.message : String(error),
9960
- });
9956
+ catch (error) {
9957
+ if (error instanceof QueueFullError) {
9958
+ logger$_.warning('broadcast_channel_receive_queue_full', {
9959
+ channel: this.channelName,
9960
+ });
9961
+ }
9962
+ else {
9963
+ logger$_.error('broadcast_channel_receive_error', {
9964
+ channel: this.channelName,
9965
+ error: error instanceof Error ? error.message : String(error),
9966
+ });
9967
+ }
9961
9968
  }
9969
+ return;
9970
+ }
9971
+ else {
9972
+ // Frame filtered out by addressing rules
9973
+ logger$_.debug('broadcast_channel_transport_frame_filtered', {
9974
+ channel: this.channelName,
9975
+ connector_id: this.connectorId,
9976
+ local_node_id: this.localNodeId,
9977
+ remote_node_id: this.remoteNodeId,
9978
+ frame_src: frame.src,
9979
+ frame_dst: frame.dst,
9980
+ reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
9981
+ });
9982
+ return;
9962
9983
  }
9963
- return;
9964
9984
  }
9965
9985
  // Fall back to legacy format (no transport frame)
9966
9986
  const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
@@ -20487,40 +20507,61 @@ class InPageConnector extends BaseAsyncConnector {
20487
20507
  return;
20488
20508
  }
20489
20509
  // Try to unwrap as transport frame
20490
- const unwrapped = unwrapTransportFrame(busMessage.payload, this.localNodeId, this.remoteNodeId === '*' ? busMessage.senderId : this.remoteNodeId);
20491
- if (unwrapped) {
20492
- // Successfully unwrapped transport frame
20493
- logger$G.debug('inpage_transport_frame_received', {
20494
- channel: this.channelName,
20495
- sender_id: busMessage.senderId,
20496
- connector_id: this.connectorId,
20497
- local_node_id: this.localNodeId,
20498
- remote_node_id: this.remoteNodeId,
20499
- payload_length: unwrapped.byteLength,
20500
- });
20501
- try {
20502
- if (typeof this.inbox.tryEnqueue === 'function') {
20503
- const accepted = this.inbox.tryEnqueue(unwrapped);
20504
- if (accepted) {
20505
- return;
20510
+ const frame = unwrapTransportFrame(busMessage.payload);
20511
+ if (frame) {
20512
+ // Apply connector's filtering policy: strict dst check, src accepts wildcard
20513
+ const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
20514
+ const dstMatches = frame.dst === this.localNodeId;
20515
+ if (dstMatches && srcMatches) {
20516
+ // Successfully received and filtered transport frame
20517
+ logger$G.debug('inpage_transport_frame_received', {
20518
+ channel: this.channelName,
20519
+ sender_id: busMessage.senderId,
20520
+ connector_id: this.connectorId,
20521
+ local_node_id: this.localNodeId,
20522
+ remote_node_id: this.remoteNodeId,
20523
+ frame_src: frame.src,
20524
+ frame_dst: frame.dst,
20525
+ payload_length: frame.payload.byteLength,
20526
+ });
20527
+ const unwrapped = frame.payload;
20528
+ try {
20529
+ if (typeof this.inbox.tryEnqueue === 'function') {
20530
+ const accepted = this.inbox.tryEnqueue(unwrapped);
20531
+ if (accepted) {
20532
+ return;
20533
+ }
20506
20534
  }
20535
+ this.inbox.enqueue(unwrapped);
20507
20536
  }
20508
- this.inbox.enqueue(unwrapped);
20509
- }
20510
- catch (error) {
20511
- if (error instanceof QueueFullError) {
20512
- logger$G.warning('inpage_receive_queue_full', {
20513
- channel: this.channelName,
20514
- });
20515
- }
20516
- else {
20517
- logger$G.error('inpage_receive_error', {
20518
- channel: this.channelName,
20519
- error: error instanceof Error ? error.message : String(error),
20520
- });
20537
+ catch (error) {
20538
+ if (error instanceof QueueFullError) {
20539
+ logger$G.warning('inpage_receive_queue_full', {
20540
+ channel: this.channelName,
20541
+ });
20542
+ }
20543
+ else {
20544
+ logger$G.error('inpage_receive_error', {
20545
+ channel: this.channelName,
20546
+ error: error instanceof Error ? error.message : String(error),
20547
+ });
20548
+ }
20521
20549
  }
20550
+ return;
20551
+ }
20552
+ else {
20553
+ // Frame filtered out by addressing rules
20554
+ logger$G.debug('inpage_transport_frame_filtered', {
20555
+ channel: this.channelName,
20556
+ connector_id: this.connectorId,
20557
+ local_node_id: this.localNodeId,
20558
+ remote_node_id: this.remoteNodeId,
20559
+ frame_src: frame.src,
20560
+ frame_dst: frame.dst,
20561
+ reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
20562
+ });
20563
+ return;
20522
20564
  }
20523
- return;
20524
20565
  }
20525
20566
  // Fall back to legacy format (no transport frame)
20526
20567
  const payload = InPageConnector.coercePayload(busMessage.payload);
@@ -36320,23 +36361,52 @@ class BroadcastChannelListener extends TransportListener {
36320
36361
  if (typeof senderId !== 'string' || senderId.length === 0) {
36321
36362
  return null;
36322
36363
  }
36323
- const payload = coercePayload$1(record.payload);
36324
- if (!payload) {
36325
- logger$a.debug('broadcast_channel_listener_ignored_event_without_payload', {
36326
- sender_id: senderId,
36327
- });
36328
- return null;
36364
+ // Check if payload is a transport frame object first
36365
+ let envelopePayload = null;
36366
+ if (this._routingNode && record.payload && typeof record.payload === 'object') {
36367
+ // Try to unwrap as transport frame
36368
+ const frame = unwrapTransportFrame(record.payload);
36369
+ if (frame) {
36370
+ // Apply listener's filtering policy: dst must match, src can be anything
36371
+ if (frame.dst === this._routingNode.id) {
36372
+ envelopePayload = frame.payload;
36373
+ logger$a.debug('broadcast_channel_listener_unwrapped_transport_frame', {
36374
+ sender_id: senderId,
36375
+ src: frame.src,
36376
+ dst: frame.dst,
36377
+ });
36378
+ }
36379
+ else {
36380
+ // Frame not addressed to us, ignore it
36381
+ logger$a.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
36382
+ sender_id: senderId,
36383
+ dst: frame.dst,
36384
+ expected: this._routingNode.id,
36385
+ });
36386
+ return null;
36387
+ }
36388
+ }
36389
+ }
36390
+ // If not a transport frame, try to coerce as legacy format
36391
+ if (!envelopePayload) {
36392
+ envelopePayload = coercePayload$1(record.payload);
36393
+ if (!envelopePayload) {
36394
+ logger$a.debug('broadcast_channel_listener_ignored_event_without_payload', {
36395
+ sender_id: senderId,
36396
+ });
36397
+ return null;
36398
+ }
36329
36399
  }
36330
36400
  let envelope;
36331
36401
  try {
36332
- const decoded = new TextDecoder().decode(payload);
36402
+ const decoded = new TextDecoder().decode(envelopePayload);
36333
36403
  const parsed = JSON.parse(decoded);
36334
36404
  envelope = deserializeEnvelope(parsed);
36335
36405
  }
36336
36406
  catch (error) {
36337
36407
  const decoded = (() => {
36338
36408
  try {
36339
- return new TextDecoder().decode(payload);
36409
+ return new TextDecoder().decode(envelopePayload);
36340
36410
  }
36341
36411
  catch {
36342
36412
  return null;