@naylence/runtime 0.3.5-test.950 → 0.3.5-test.952

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.950
5481
+ // Generated from package.json version: 0.3.5-test.952
5482
5482
  /**
5483
5483
  * The package version, injected at build time.
5484
5484
  * @internal
5485
5485
  */
5486
- const VERSION = '0.3.5-test.950';
5486
+ const VERSION = '0.3.5-test.952';
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,41 +32938,44 @@ 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;
32906
- }
32907
- // Try to unwrap as transport frame first
32908
- // Use wildcard for remoteNodeId since we don't know the sender's node ID yet
32909
- let unwrapped = null;
32910
- if (this._routingNode) {
32911
- try {
32912
- // First try to deserialize as transport frame
32913
- const parsed = JSON.parse(new TextDecoder().decode(payload));
32914
- if (parsed && typeof parsed === 'object' && 'v' in parsed && 'src' in parsed && 'dst' in parsed) {
32915
- const frame = parsed;
32916
- // Check if this frame is addressed to us (localNodeId)
32917
- if (frame.dst === this._routingNode.id) {
32918
- unwrapped = unwrapTransportFrame(payload, this._routingNode.id, '*');
32919
- if (unwrapped) {
32920
- logger$n.debug('broadcast_channel_listener_unwrapped_transport_frame', {
32921
- sender_id: senderId,
32922
- src: frame.src,
32923
- dst: frame.dst,
32924
- });
32925
- }
32926
- }
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;
32927
32966
  }
32928
32967
  }
32929
- catch {
32930
- // Not a transport frame, continue with legacy format
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;
32931
32977
  }
32932
32978
  }
32933
- // Use unwrapped payload if available, otherwise use raw payload
32934
- const envelopePayload = unwrapped ?? payload;
32935
32979
  let envelope;
32936
32980
  try {
32937
32981
  const decoded = new TextDecoder().decode(envelopePayload);
@@ -32941,7 +32985,7 @@ class BroadcastChannelListener extends TransportListener {
32941
32985
  catch (error) {
32942
32986
  const decoded = (() => {
32943
32987
  try {
32944
- return new TextDecoder().decode(payload);
32988
+ return new TextDecoder().decode(envelopePayload);
32945
32989
  }
32946
32990
  catch {
32947
32991
  return null;