@naylence/runtime 0.3.5-test.950 → 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.
@@ -98,12 +98,12 @@ installProcessEnvShim();
98
98
  // --- END ENV SHIM ---
99
99
 
100
100
  // This file is auto-generated during build - do not edit manually
101
- // Generated from package.json version: 0.3.5-test.950
101
+ // Generated from package.json version: 0.3.5-test.951
102
102
  /**
103
103
  * The package version, injected at build time.
104
104
  * @internal
105
105
  */
106
- const VERSION = '0.3.5-test.950';
106
+ const VERSION = '0.3.5-test.951';
107
107
 
108
108
  /**
109
109
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -9864,14 +9864,12 @@ function serializeTransportFrame(frame) {
9864
9864
  return serializable;
9865
9865
  }
9866
9866
  /**
9867
- * Unwrap a transport frame, validating source and destination
9867
+ * Unwrap a transport frame (pure deserializer - no filtering)
9868
9868
  *
9869
9869
  * @param raw - Raw data from the bus
9870
- * @param localNodeId - This connector's node ID
9871
- * @param remoteNodeId - Expected remote node ID
9872
- * @returns Unwrapped payload if frame is valid and addressed to us, null otherwise
9870
+ * @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
9873
9871
  */
9874
- function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
9872
+ function unwrapTransportFrame(raw) {
9875
9873
  // Validate basic structure
9876
9874
  if (!raw || typeof raw !== 'object') {
9877
9875
  return null;
@@ -9885,16 +9883,17 @@ function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
9885
9883
  if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
9886
9884
  return null;
9887
9885
  }
9888
- // Only accept frames addressed to us from the expected remote
9889
- if (frame.dst !== localNodeId || frame.src !== remoteNodeId) {
9890
- return null;
9891
- }
9892
9886
  // Extract payload
9893
9887
  if (!frame.payload || !Array.isArray(frame.payload)) {
9894
9888
  return null;
9895
9889
  }
9896
- // Convert array back to Uint8Array
9897
- return Uint8Array.from(frame.payload);
9890
+ // Convert array back to Uint8Array and return full frame
9891
+ return {
9892
+ v: frame.v,
9893
+ src: frame.src,
9894
+ dst: frame.dst,
9895
+ payload: Uint8Array.from(frame.payload),
9896
+ };
9898
9897
  }
9899
9898
 
9900
9899
  const logger$_ = getLogger('naylence.fame.connector.broadcast_channel_connector');
@@ -10009,43 +10008,64 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
10009
10008
  return;
10010
10009
  }
10011
10010
  // Try to unwrap as transport frame
10012
- const unwrapped = unwrapTransportFrame(busMessage.payload, this.localNodeId, this.remoteNodeId === '*' ? busMessage.senderId : this.remoteNodeId);
10013
- if (unwrapped) {
10014
- // Successfully unwrapped transport frame
10015
- logger$_.debug('broadcast_channel_transport_frame_received', {
10016
- channel: this.channelName,
10017
- sender_id: busMessage.senderId,
10018
- connector_id: this.connectorId,
10019
- local_node_id: this.localNodeId,
10020
- remote_node_id: this.remoteNodeId,
10021
- payload_length: unwrapped.byteLength,
10022
- });
10023
- if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
10024
- return;
10025
- }
10026
- try {
10027
- if (typeof this.inbox.tryEnqueue === 'function') {
10028
- const accepted = this.inbox.tryEnqueue(unwrapped);
10029
- if (accepted) {
10030
- return;
10031
- }
10011
+ const frame = unwrapTransportFrame(busMessage.payload);
10012
+ if (frame) {
10013
+ // Apply connector's filtering policy: strict dst check, src accepts wildcard
10014
+ const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
10015
+ const dstMatches = frame.dst === this.localNodeId;
10016
+ if (dstMatches && srcMatches) {
10017
+ // Successfully received and filtered transport frame
10018
+ logger$_.debug('broadcast_channel_transport_frame_received', {
10019
+ channel: this.channelName,
10020
+ sender_id: busMessage.senderId,
10021
+ connector_id: this.connectorId,
10022
+ local_node_id: this.localNodeId,
10023
+ remote_node_id: this.remoteNodeId,
10024
+ frame_src: frame.src,
10025
+ frame_dst: frame.dst,
10026
+ payload_length: frame.payload.byteLength,
10027
+ });
10028
+ const unwrapped = frame.payload;
10029
+ if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
10030
+ return;
10032
10031
  }
10033
- this.inbox.enqueue(unwrapped);
10034
- }
10035
- catch (error) {
10036
- if (error instanceof QueueFullError) {
10037
- logger$_.warning('broadcast_channel_receive_queue_full', {
10038
- channel: this.channelName,
10039
- });
10032
+ try {
10033
+ if (typeof this.inbox.tryEnqueue === 'function') {
10034
+ const accepted = this.inbox.tryEnqueue(unwrapped);
10035
+ if (accepted) {
10036
+ return;
10037
+ }
10038
+ }
10039
+ this.inbox.enqueue(unwrapped);
10040
10040
  }
10041
- else {
10042
- logger$_.error('broadcast_channel_receive_error', {
10043
- channel: this.channelName,
10044
- error: error instanceof Error ? error.message : String(error),
10045
- });
10041
+ catch (error) {
10042
+ if (error instanceof QueueFullError) {
10043
+ logger$_.warning('broadcast_channel_receive_queue_full', {
10044
+ channel: this.channelName,
10045
+ });
10046
+ }
10047
+ else {
10048
+ logger$_.error('broadcast_channel_receive_error', {
10049
+ channel: this.channelName,
10050
+ error: error instanceof Error ? error.message : String(error),
10051
+ });
10052
+ }
10046
10053
  }
10054
+ return;
10055
+ }
10056
+ else {
10057
+ // Frame filtered out by addressing rules
10058
+ logger$_.debug('broadcast_channel_transport_frame_filtered', {
10059
+ channel: this.channelName,
10060
+ connector_id: this.connectorId,
10061
+ local_node_id: this.localNodeId,
10062
+ remote_node_id: this.remoteNodeId,
10063
+ frame_src: frame.src,
10064
+ frame_dst: frame.dst,
10065
+ reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
10066
+ });
10067
+ return;
10047
10068
  }
10048
- return;
10049
10069
  }
10050
10070
  // Fall back to legacy format (no transport frame)
10051
10071
  const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
@@ -20572,40 +20592,61 @@ class InPageConnector extends BaseAsyncConnector {
20572
20592
  return;
20573
20593
  }
20574
20594
  // Try to unwrap as transport frame
20575
- const unwrapped = unwrapTransportFrame(busMessage.payload, this.localNodeId, this.remoteNodeId === '*' ? busMessage.senderId : this.remoteNodeId);
20576
- if (unwrapped) {
20577
- // Successfully unwrapped transport frame
20578
- logger$G.debug('inpage_transport_frame_received', {
20579
- channel: this.channelName,
20580
- sender_id: busMessage.senderId,
20581
- connector_id: this.connectorId,
20582
- local_node_id: this.localNodeId,
20583
- remote_node_id: this.remoteNodeId,
20584
- payload_length: unwrapped.byteLength,
20585
- });
20586
- try {
20587
- if (typeof this.inbox.tryEnqueue === 'function') {
20588
- const accepted = this.inbox.tryEnqueue(unwrapped);
20589
- if (accepted) {
20590
- return;
20595
+ const frame = unwrapTransportFrame(busMessage.payload);
20596
+ if (frame) {
20597
+ // Apply connector's filtering policy: strict dst check, src accepts wildcard
20598
+ const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
20599
+ const dstMatches = frame.dst === this.localNodeId;
20600
+ if (dstMatches && srcMatches) {
20601
+ // Successfully received and filtered transport frame
20602
+ logger$G.debug('inpage_transport_frame_received', {
20603
+ channel: this.channelName,
20604
+ sender_id: busMessage.senderId,
20605
+ connector_id: this.connectorId,
20606
+ local_node_id: this.localNodeId,
20607
+ remote_node_id: this.remoteNodeId,
20608
+ frame_src: frame.src,
20609
+ frame_dst: frame.dst,
20610
+ payload_length: frame.payload.byteLength,
20611
+ });
20612
+ const unwrapped = frame.payload;
20613
+ try {
20614
+ if (typeof this.inbox.tryEnqueue === 'function') {
20615
+ const accepted = this.inbox.tryEnqueue(unwrapped);
20616
+ if (accepted) {
20617
+ return;
20618
+ }
20591
20619
  }
20620
+ this.inbox.enqueue(unwrapped);
20592
20621
  }
20593
- this.inbox.enqueue(unwrapped);
20594
- }
20595
- catch (error) {
20596
- if (error instanceof QueueFullError) {
20597
- logger$G.warning('inpage_receive_queue_full', {
20598
- channel: this.channelName,
20599
- });
20600
- }
20601
- else {
20602
- logger$G.error('inpage_receive_error', {
20603
- channel: this.channelName,
20604
- error: error instanceof Error ? error.message : String(error),
20605
- });
20622
+ catch (error) {
20623
+ if (error instanceof QueueFullError) {
20624
+ logger$G.warning('inpage_receive_queue_full', {
20625
+ channel: this.channelName,
20626
+ });
20627
+ }
20628
+ else {
20629
+ logger$G.error('inpage_receive_error', {
20630
+ channel: this.channelName,
20631
+ error: error instanceof Error ? error.message : String(error),
20632
+ });
20633
+ }
20606
20634
  }
20635
+ return;
20636
+ }
20637
+ else {
20638
+ // Frame filtered out by addressing rules
20639
+ logger$G.debug('inpage_transport_frame_filtered', {
20640
+ channel: this.channelName,
20641
+ connector_id: this.connectorId,
20642
+ local_node_id: this.localNodeId,
20643
+ remote_node_id: this.remoteNodeId,
20644
+ frame_src: frame.src,
20645
+ frame_dst: frame.dst,
20646
+ reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
20647
+ });
20648
+ return;
20607
20649
  }
20608
- return;
20609
20650
  }
20610
20651
  // Fall back to legacy format (no transport frame)
20611
20652
  const payload = InPageConnector.coercePayload(busMessage.payload);
@@ -30140,41 +30181,42 @@ class BroadcastChannelListener extends TransportListener {
30140
30181
  if (typeof senderId !== 'string' || senderId.length === 0) {
30141
30182
  return null;
30142
30183
  }
30143
- const payload = coercePayload(record.payload);
30144
- if (!payload) {
30145
- logger$o.debug('broadcast_channel_listener_ignored_event_without_payload', {
30146
- sender_id: senderId,
30147
- });
30148
- return null;
30149
- }
30150
- // Try to unwrap as transport frame first
30151
- // Use wildcard for remoteNodeId since we don't know the sender's node ID yet
30152
- let unwrapped = null;
30153
- if (this._routingNode) {
30154
- try {
30155
- // First try to deserialize as transport frame
30156
- const parsed = JSON.parse(new TextDecoder().decode(payload));
30157
- if (parsed && typeof parsed === 'object' && 'v' in parsed && 'src' in parsed && 'dst' in parsed) {
30158
- const frame = parsed;
30159
- // Check if this frame is addressed to us (localNodeId)
30160
- if (frame.dst === this._routingNode.id) {
30161
- unwrapped = unwrapTransportFrame(payload, this._routingNode.id, '*');
30162
- if (unwrapped) {
30163
- logger$o.debug('broadcast_channel_listener_unwrapped_transport_frame', {
30164
- sender_id: senderId,
30165
- src: frame.src,
30166
- dst: frame.dst,
30167
- });
30168
- }
30169
- }
30184
+ // Check if payload is a transport frame object first
30185
+ let envelopePayload = null;
30186
+ if (this._routingNode && record.payload && typeof record.payload === 'object') {
30187
+ // Try to unwrap as transport frame
30188
+ const frame = unwrapTransportFrame(record.payload);
30189
+ if (frame) {
30190
+ // Apply listener's filtering policy: dst must match, src can be anything
30191
+ if (frame.dst === this._routingNode.id) {
30192
+ envelopePayload = frame.payload;
30193
+ logger$o.debug('broadcast_channel_listener_unwrapped_transport_frame', {
30194
+ sender_id: senderId,
30195
+ src: frame.src,
30196
+ dst: frame.dst,
30197
+ });
30198
+ }
30199
+ else {
30200
+ // Frame not addressed to us, ignore it
30201
+ logger$o.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
30202
+ sender_id: senderId,
30203
+ dst: frame.dst,
30204
+ expected: this._routingNode.id,
30205
+ });
30206
+ return null;
30170
30207
  }
30171
30208
  }
30172
- catch {
30173
- // Not a transport frame, continue with legacy format
30209
+ }
30210
+ // If not a transport frame, try to coerce as legacy format
30211
+ if (!envelopePayload) {
30212
+ envelopePayload = coercePayload(record.payload);
30213
+ if (!envelopePayload) {
30214
+ logger$o.debug('broadcast_channel_listener_ignored_event_without_payload', {
30215
+ sender_id: senderId,
30216
+ });
30217
+ return null;
30174
30218
  }
30175
30219
  }
30176
- // Use unwrapped payload if available, otherwise use raw payload
30177
- const envelopePayload = unwrapped ?? payload;
30178
30220
  let envelope;
30179
30221
  try {
30180
30222
  const decoded = new TextDecoder().decode(envelopePayload);
@@ -30184,7 +30226,7 @@ class BroadcastChannelListener extends TransportListener {
30184
30226
  catch (error) {
30185
30227
  const decoded = (() => {
30186
30228
  try {
30187
- return new TextDecoder().decode(payload);
30229
+ return new TextDecoder().decode(envelopePayload);
30188
30230
  }
30189
30231
  catch {
30190
30232
  return null;