@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.
@@ -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.949
5481
+ // Generated from package.json version: 0.3.5-test.951
5482
5482
  /**
5483
5483
  * The package version, injected at build time.
5484
5484
  * @internal
5485
5485
  */
5486
- const VERSION = '0.3.5-test.949';
5486
+ const VERSION = '0.3.5-test.951';
5487
5487
 
5488
5488
  /**
5489
5489
  * Fame errors module - Fame protocol specific error classes
@@ -11517,14 +11517,12 @@ function serializeTransportFrame(frame) {
11517
11517
  return serializable;
11518
11518
  }
11519
11519
  /**
11520
- * Unwrap a transport frame, validating source and destination
11520
+ * Unwrap a transport frame (pure deserializer - no filtering)
11521
11521
  *
11522
11522
  * @param raw - Raw data from the bus
11523
- * @param localNodeId - This connector's node ID
11524
- * @param remoteNodeId - Expected remote node ID
11525
- * @returns Unwrapped payload if frame is valid and addressed to us, null otherwise
11523
+ * @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
11526
11524
  */
11527
- function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
11525
+ function unwrapTransportFrame(raw) {
11528
11526
  // Validate basic structure
11529
11527
  if (!raw || typeof raw !== 'object') {
11530
11528
  return null;
@@ -11538,16 +11536,17 @@ function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
11538
11536
  if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
11539
11537
  return null;
11540
11538
  }
11541
- // Only accept frames addressed to us from the expected remote
11542
- if (frame.dst !== localNodeId || frame.src !== remoteNodeId) {
11543
- return null;
11544
- }
11545
11539
  // Extract payload
11546
11540
  if (!frame.payload || !Array.isArray(frame.payload)) {
11547
11541
  return null;
11548
11542
  }
11549
- // Convert array back to Uint8Array
11550
- return Uint8Array.from(frame.payload);
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
+ };
11551
11550
  }
11552
11551
  /**
11553
11552
  * Check if raw data looks like a transport frame
@@ -11678,43 +11677,64 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11678
11677
  return;
11679
11678
  }
11680
11679
  // Try to unwrap as transport frame
11681
- const unwrapped = unwrapTransportFrame(busMessage.payload, this.localNodeId, this.remoteNodeId === '*' ? busMessage.senderId : this.remoteNodeId);
11682
- if (unwrapped) {
11683
- // Successfully unwrapped transport frame
11684
- logger$10.debug('broadcast_channel_transport_frame_received', {
11685
- channel: this.channelName,
11686
- sender_id: busMessage.senderId,
11687
- connector_id: this.connectorId,
11688
- local_node_id: this.localNodeId,
11689
- remote_node_id: this.remoteNodeId,
11690
- payload_length: unwrapped.byteLength,
11691
- });
11692
- if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
11693
- return;
11694
- }
11695
- try {
11696
- if (typeof this.inbox.tryEnqueue === 'function') {
11697
- const accepted = this.inbox.tryEnqueue(unwrapped);
11698
- if (accepted) {
11699
- return;
11700
- }
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;
11701
11700
  }
11702
- this.inbox.enqueue(unwrapped);
11703
- }
11704
- catch (error) {
11705
- if (error instanceof QueueFullError) {
11706
- logger$10.warning('broadcast_channel_receive_queue_full', {
11707
- channel: this.channelName,
11708
- });
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
11709
  }
11710
- else {
11711
- logger$10.error('broadcast_channel_receive_error', {
11712
- channel: this.channelName,
11713
- error: error instanceof Error ? error.message : String(error),
11714
- });
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
+ }
11715
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;
11716
11737
  }
11717
- return;
11718
11738
  }
11719
11739
  // Fall back to legacy format (no transport frame)
11720
11740
  const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
@@ -21682,40 +21702,61 @@ class InPageConnector extends BaseAsyncConnector {
21682
21702
  return;
21683
21703
  }
21684
21704
  // Try to unwrap as transport frame
21685
- const unwrapped = unwrapTransportFrame(busMessage.payload, this.localNodeId, this.remoteNodeId === '*' ? busMessage.senderId : this.remoteNodeId);
21686
- if (unwrapped) {
21687
- // Successfully unwrapped transport frame
21688
- logger$J.debug('inpage_transport_frame_received', {
21689
- channel: this.channelName,
21690
- sender_id: busMessage.senderId,
21691
- connector_id: this.connectorId,
21692
- local_node_id: this.localNodeId,
21693
- remote_node_id: this.remoteNodeId,
21694
- payload_length: unwrapped.byteLength,
21695
- });
21696
- try {
21697
- if (typeof this.inbox.tryEnqueue === 'function') {
21698
- const accepted = this.inbox.tryEnqueue(unwrapped);
21699
- if (accepted) {
21700
- return;
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
+ }
21701
21729
  }
21730
+ this.inbox.enqueue(unwrapped);
21702
21731
  }
21703
- this.inbox.enqueue(unwrapped);
21704
- }
21705
- catch (error) {
21706
- if (error instanceof QueueFullError) {
21707
- logger$J.warning('inpage_receive_queue_full', {
21708
- channel: this.channelName,
21709
- });
21710
- }
21711
- else {
21712
- logger$J.error('inpage_receive_error', {
21713
- channel: this.channelName,
21714
- error: error instanceof Error ? error.message : String(error),
21715
- });
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
+ }
21716
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;
21717
21759
  }
21718
- return;
21719
21760
  }
21720
21761
  // Fall back to legacy format (no transport frame)
21721
21762
  const payload = InPageConnector.coercePayload(busMessage.payload);
@@ -32897,23 +32938,52 @@ class BroadcastChannelListener extends TransportListener {
32897
32938
  if (typeof senderId !== 'string' || senderId.length === 0) {
32898
32939
  return null;
32899
32940
  }
32900
- const payload = coercePayload(record.payload);
32901
- if (!payload) {
32902
- logger$n.debug('broadcast_channel_listener_ignored_event_without_payload', {
32903
- sender_id: senderId,
32904
- });
32905
- return null;
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: dst must match, src can be anything
32948
+ if (frame.dst === this._routingNode.id) {
32949
+ envelopePayload = frame.payload;
32950
+ logger$n.debug('broadcast_channel_listener_unwrapped_transport_frame', {
32951
+ sender_id: senderId,
32952
+ src: frame.src,
32953
+ dst: frame.dst,
32954
+ });
32955
+ }
32956
+ else {
32957
+ // Frame not addressed to us, ignore it
32958
+ logger$n.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
32959
+ sender_id: senderId,
32960
+ dst: frame.dst,
32961
+ expected: this._routingNode.id,
32962
+ });
32963
+ return null;
32964
+ }
32965
+ }
32966
+ }
32967
+ // If not a transport frame, try to coerce as legacy format
32968
+ if (!envelopePayload) {
32969
+ envelopePayload = coercePayload(record.payload);
32970
+ if (!envelopePayload) {
32971
+ logger$n.debug('broadcast_channel_listener_ignored_event_without_payload', {
32972
+ sender_id: senderId,
32973
+ });
32974
+ return null;
32975
+ }
32906
32976
  }
32907
32977
  let envelope;
32908
32978
  try {
32909
- const decoded = new TextDecoder().decode(payload);
32979
+ const decoded = new TextDecoder().decode(envelopePayload);
32910
32980
  const parsed = JSON.parse(decoded);
32911
32981
  envelope = core.deserializeEnvelope(parsed);
32912
32982
  }
32913
32983
  catch (error) {
32914
32984
  const decoded = (() => {
32915
32985
  try {
32916
- return new TextDecoder().decode(payload);
32986
+ return new TextDecoder().decode(envelopePayload);
32917
32987
  }
32918
32988
  catch {
32919
32989
  return null;
@@ -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.949
5480
+ // Generated from package.json version: 0.3.5-test.951
5481
5481
  /**
5482
5482
  * The package version, injected at build time.
5483
5483
  * @internal
5484
5484
  */
5485
- const VERSION = '0.3.5-test.949';
5485
+ const VERSION = '0.3.5-test.951';
5486
5486
 
5487
5487
  /**
5488
5488
  * Fame errors module - Fame protocol specific error classes
@@ -11516,14 +11516,12 @@ function serializeTransportFrame(frame) {
11516
11516
  return serializable;
11517
11517
  }
11518
11518
  /**
11519
- * Unwrap a transport frame, validating source and destination
11519
+ * Unwrap a transport frame (pure deserializer - no filtering)
11520
11520
  *
11521
11521
  * @param raw - Raw data from the bus
11522
- * @param localNodeId - This connector's node ID
11523
- * @param remoteNodeId - Expected remote node ID
11524
- * @returns Unwrapped payload if frame is valid and addressed to us, null otherwise
11522
+ * @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
11525
11523
  */
11526
- function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
11524
+ function unwrapTransportFrame(raw) {
11527
11525
  // Validate basic structure
11528
11526
  if (!raw || typeof raw !== 'object') {
11529
11527
  return null;
@@ -11537,16 +11535,17 @@ function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
11537
11535
  if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
11538
11536
  return null;
11539
11537
  }
11540
- // Only accept frames addressed to us from the expected remote
11541
- if (frame.dst !== localNodeId || frame.src !== remoteNodeId) {
11542
- return null;
11543
- }
11544
11538
  // Extract payload
11545
11539
  if (!frame.payload || !Array.isArray(frame.payload)) {
11546
11540
  return null;
11547
11541
  }
11548
- // Convert array back to Uint8Array
11549
- return Uint8Array.from(frame.payload);
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
+ };
11550
11549
  }
11551
11550
  /**
11552
11551
  * Check if raw data looks like a transport frame
@@ -11677,43 +11676,64 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
11677
11676
  return;
11678
11677
  }
11679
11678
  // Try to unwrap as transport frame
11680
- const unwrapped = unwrapTransportFrame(busMessage.payload, this.localNodeId, this.remoteNodeId === '*' ? busMessage.senderId : this.remoteNodeId);
11681
- if (unwrapped) {
11682
- // Successfully unwrapped transport frame
11683
- logger$10.debug('broadcast_channel_transport_frame_received', {
11684
- channel: this.channelName,
11685
- sender_id: busMessage.senderId,
11686
- connector_id: this.connectorId,
11687
- local_node_id: this.localNodeId,
11688
- remote_node_id: this.remoteNodeId,
11689
- payload_length: unwrapped.byteLength,
11690
- });
11691
- if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
11692
- return;
11693
- }
11694
- try {
11695
- if (typeof this.inbox.tryEnqueue === 'function') {
11696
- const accepted = this.inbox.tryEnqueue(unwrapped);
11697
- if (accepted) {
11698
- return;
11699
- }
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;
11700
11699
  }
11701
- this.inbox.enqueue(unwrapped);
11702
- }
11703
- catch (error) {
11704
- if (error instanceof QueueFullError) {
11705
- logger$10.warning('broadcast_channel_receive_queue_full', {
11706
- channel: this.channelName,
11707
- });
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
11708
  }
11709
- else {
11710
- logger$10.error('broadcast_channel_receive_error', {
11711
- channel: this.channelName,
11712
- error: error instanceof Error ? error.message : String(error),
11713
- });
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
+ }
11714
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;
11715
11736
  }
11716
- return;
11717
11737
  }
11718
11738
  // Fall back to legacy format (no transport frame)
11719
11739
  const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
@@ -21681,40 +21701,61 @@ class InPageConnector extends BaseAsyncConnector {
21681
21701
  return;
21682
21702
  }
21683
21703
  // Try to unwrap as transport frame
21684
- const unwrapped = unwrapTransportFrame(busMessage.payload, this.localNodeId, this.remoteNodeId === '*' ? busMessage.senderId : this.remoteNodeId);
21685
- if (unwrapped) {
21686
- // Successfully unwrapped transport frame
21687
- logger$J.debug('inpage_transport_frame_received', {
21688
- channel: this.channelName,
21689
- sender_id: busMessage.senderId,
21690
- connector_id: this.connectorId,
21691
- local_node_id: this.localNodeId,
21692
- remote_node_id: this.remoteNodeId,
21693
- payload_length: unwrapped.byteLength,
21694
- });
21695
- try {
21696
- if (typeof this.inbox.tryEnqueue === 'function') {
21697
- const accepted = this.inbox.tryEnqueue(unwrapped);
21698
- if (accepted) {
21699
- return;
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
+ }
21700
21728
  }
21729
+ this.inbox.enqueue(unwrapped);
21701
21730
  }
21702
- this.inbox.enqueue(unwrapped);
21703
- }
21704
- catch (error) {
21705
- if (error instanceof QueueFullError) {
21706
- logger$J.warning('inpage_receive_queue_full', {
21707
- channel: this.channelName,
21708
- });
21709
- }
21710
- else {
21711
- logger$J.error('inpage_receive_error', {
21712
- channel: this.channelName,
21713
- error: error instanceof Error ? error.message : String(error),
21714
- });
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
+ }
21715
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;
21716
21758
  }
21717
- return;
21718
21759
  }
21719
21760
  // Fall back to legacy format (no transport frame)
21720
21761
  const payload = InPageConnector.coercePayload(busMessage.payload);
@@ -32896,23 +32937,52 @@ class BroadcastChannelListener extends TransportListener {
32896
32937
  if (typeof senderId !== 'string' || senderId.length === 0) {
32897
32938
  return null;
32898
32939
  }
32899
- const payload = coercePayload(record.payload);
32900
- if (!payload) {
32901
- logger$n.debug('broadcast_channel_listener_ignored_event_without_payload', {
32902
- sender_id: senderId,
32903
- });
32904
- return null;
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: dst must match, src can be anything
32947
+ if (frame.dst === this._routingNode.id) {
32948
+ envelopePayload = frame.payload;
32949
+ logger$n.debug('broadcast_channel_listener_unwrapped_transport_frame', {
32950
+ sender_id: senderId,
32951
+ src: frame.src,
32952
+ dst: frame.dst,
32953
+ });
32954
+ }
32955
+ else {
32956
+ // Frame not addressed to us, ignore it
32957
+ logger$n.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
32958
+ sender_id: senderId,
32959
+ dst: frame.dst,
32960
+ expected: this._routingNode.id,
32961
+ });
32962
+ return null;
32963
+ }
32964
+ }
32965
+ }
32966
+ // If not a transport frame, try to coerce as legacy format
32967
+ if (!envelopePayload) {
32968
+ envelopePayload = coercePayload(record.payload);
32969
+ if (!envelopePayload) {
32970
+ logger$n.debug('broadcast_channel_listener_ignored_event_without_payload', {
32971
+ sender_id: senderId,
32972
+ });
32973
+ return null;
32974
+ }
32905
32975
  }
32906
32976
  let envelope;
32907
32977
  try {
32908
- const decoded = new TextDecoder().decode(payload);
32978
+ const decoded = new TextDecoder().decode(envelopePayload);
32909
32979
  const parsed = JSON.parse(decoded);
32910
32980
  envelope = deserializeEnvelope(parsed);
32911
32981
  }
32912
32982
  catch (error) {
32913
32983
  const decoded = (() => {
32914
32984
  try {
32915
- return new TextDecoder().decode(payload);
32985
+ return new TextDecoder().decode(envelopePayload);
32916
32986
  }
32917
32987
  catch {
32918
32988
  return null;
@@ -41,14 +41,12 @@ export declare function wrapTransportFrame(payload: Uint8Array, srcNodeId: strin
41
41
  */
42
42
  export declare function serializeTransportFrame(frame: TransportFrame): unknown;
43
43
  /**
44
- * Unwrap a transport frame, validating source and destination
44
+ * Unwrap a transport frame (pure deserializer - no filtering)
45
45
  *
46
46
  * @param raw - Raw data from the bus
47
- * @param localNodeId - This connector's node ID
48
- * @param remoteNodeId - Expected remote node ID
49
- * @returns Unwrapped payload if frame is valid and addressed to us, null otherwise
47
+ * @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
50
48
  */
51
- export declare function unwrapTransportFrame(raw: unknown, localNodeId: string, remoteNodeId: string): Uint8Array | null;
49
+ export declare function unwrapTransportFrame(raw: unknown): TransportFrame | null;
52
50
  /**
53
51
  * Check if raw data looks like a transport frame
54
52
  *
@@ -2,4 +2,4 @@
2
2
  * The package version, injected at build time.
3
3
  * @internal
4
4
  */
5
- export declare const VERSION = "0.3.5-test.949";
5
+ export declare const VERSION = "0.3.5-test.951";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naylence/runtime",
3
- "version": "0.3.5-test.949",
3
+ "version": "0.3.5-test.951",
4
4
  "type": "module",
5
5
  "description": "Naylence Runtime - Complete TypeScript runtime",
6
6
  "author": "Naylence Dev <naylencedev@gmail.com>",