@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.
@@ -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.950
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.950';
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,41 +36362,42 @@ 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;
36330
- }
36331
- // Try to unwrap as transport frame first
36332
- // Use wildcard for remoteNodeId since we don't know the sender's node ID yet
36333
- let unwrapped = null;
36334
- if (this._routingNode) {
36335
- try {
36336
- // First try to deserialize as transport frame
36337
- const parsed = JSON.parse(new TextDecoder().decode(payload));
36338
- if (parsed && typeof parsed === 'object' && 'v' in parsed && 'src' in parsed && 'dst' in parsed) {
36339
- const frame = parsed;
36340
- // Check if this frame is addressed to us (localNodeId)
36341
- if (frame.dst === this._routingNode.id) {
36342
- unwrapped = unwrapTransportFrame(payload, this._routingNode.id, '*');
36343
- if (unwrapped) {
36344
- logger$a.debug('broadcast_channel_listener_unwrapped_transport_frame', {
36345
- sender_id: senderId,
36346
- src: frame.src,
36347
- dst: frame.dst,
36348
- });
36349
- }
36350
- }
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;
36351
36388
  }
36352
36389
  }
36353
- catch {
36354
- // Not a transport frame, continue with legacy format
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;
36355
36399
  }
36356
36400
  }
36357
- // Use unwrapped payload if available, otherwise use raw payload
36358
- const envelopePayload = unwrapped ?? payload;
36359
36401
  let envelope;
36360
36402
  try {
36361
36403
  const decoded = new TextDecoder().decode(envelopePayload);
@@ -36365,7 +36407,7 @@ class BroadcastChannelListener extends TransportListener {
36365
36407
  catch (error) {
36366
36408
  const decoded = (() => {
36367
36409
  try {
36368
- return new TextDecoder().decode(payload);
36410
+ return new TextDecoder().decode(envelopePayload);
36369
36411
  }
36370
36412
  catch {
36371
36413
  return null;