@naylence/runtime 0.3.5-test.966 → 0.3.5-test.967

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.
@@ -96,12 +96,12 @@ installProcessEnvShim();
96
96
  // --- END ENV SHIM ---
97
97
 
98
98
  // This file is auto-generated during build - do not edit manually
99
- // Generated from package.json version: 0.3.5-test.966
99
+ // Generated from package.json version: 0.3.5-test.967
100
100
  /**
101
101
  * The package version, injected at build time.
102
102
  * @internal
103
103
  */
104
- const VERSION = '0.3.5-test.966';
104
+ const VERSION = '0.3.5-test.967';
105
105
 
106
106
  /**
107
107
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -20516,6 +20516,26 @@ class InPageConnector extends BaseAsyncConnector {
20516
20516
  }
20517
20517
  return null;
20518
20518
  }
20519
+ static normalizeNodeId(value) {
20520
+ if (typeof value !== 'string') {
20521
+ return null;
20522
+ }
20523
+ const trimmed = value.trim();
20524
+ return trimmed.length > 0 ? trimmed : null;
20525
+ }
20526
+ static normalizeTargetNodeId(value) {
20527
+ if (typeof value !== 'string') {
20528
+ return undefined;
20529
+ }
20530
+ const trimmed = value.trim();
20531
+ if (trimmed.length === 0) {
20532
+ return undefined;
20533
+ }
20534
+ if (trimmed === '*') {
20535
+ return '*';
20536
+ }
20537
+ return trimmed;
20538
+ }
20519
20539
  constructor(config, baseConfig = {}) {
20520
20540
  ensureBrowserEnvironment$2();
20521
20541
  super(baseConfig);
@@ -20531,41 +20551,68 @@ class InPageConnector extends BaseAsyncConnector {
20531
20551
  ? Math.floor(config.inboxCapacity)
20532
20552
  : DEFAULT_INBOX_CAPACITY$6;
20533
20553
  this.inbox = new BoundedAsyncQueue(preferredCapacity);
20554
+ this.inboxCapacity = preferredCapacity;
20534
20555
  this.connectorId = InPageConnector.generateConnectorId();
20556
+ const normalizedLocalNodeId = InPageConnector.normalizeNodeId(config.localNodeId);
20557
+ if (!normalizedLocalNodeId) {
20558
+ throw new Error('InPageConnector requires a non-empty localNodeId');
20559
+ }
20560
+ this.localNodeId = normalizedLocalNodeId;
20561
+ this.targetNodeId = InPageConnector.normalizeTargetNodeId(config.initialTargetNodeId);
20535
20562
  logger$G.debug('inpage_connector_initialized', {
20536
20563
  channel: this.channelName,
20537
20564
  connector_id: this.connectorId,
20565
+ local_node_id: this.localNodeId,
20566
+ target_node_id: this.targetNodeId ?? null,
20567
+ inbox_capacity: preferredCapacity,
20538
20568
  });
20539
20569
  this.onMsg = (event) => {
20570
+ if (!this.listenerRegistered) {
20571
+ logger$G.warning('inpage_message_after_unregister', {
20572
+ channel: this.channelName,
20573
+ connector_id: this.connectorId,
20574
+ timestamp: new Date().toISOString(),
20575
+ });
20576
+ return;
20577
+ }
20540
20578
  const messageEvent = event;
20541
20579
  const message = messageEvent.data;
20542
20580
  logger$G.debug('inpage_raw_event', {
20543
20581
  channel: this.channelName,
20544
20582
  connector_id: this.connectorId,
20545
- message_type: message && typeof message === 'object' ? message.constructor?.name ?? typeof message : typeof message,
20546
- has_sender_id: Boolean(message?.senderId),
20547
- payload_type: message && typeof message === 'object'
20548
- ? message?.payload instanceof Uint8Array
20549
- ? 'Uint8Array'
20550
- : message?.payload instanceof ArrayBuffer
20551
- ? 'ArrayBuffer'
20552
- : typeof message?.payload
20583
+ message_type: message && typeof message === 'object'
20584
+ ? message.constructor?.name ?? typeof message
20553
20585
  : typeof message,
20554
- payload_constructor: message && typeof message === 'object'
20555
- ? message?.payload?.constructor?.name
20556
- : undefined,
20557
- payload_keys: message && typeof message === 'object' && message?.payload && typeof message?.payload === 'object'
20558
- ? Object.keys(message.payload).slice(0, 5)
20559
- : undefined,
20586
+ has_sender_id: Boolean(message?.senderId),
20587
+ has_sender_node_id: Boolean(message?.senderNodeId),
20560
20588
  });
20561
20589
  if (!message || typeof message !== 'object') {
20562
20590
  return;
20563
20591
  }
20564
20592
  const busMessage = message;
20565
- if (typeof busMessage.senderId !== 'string' || busMessage.senderId.length === 0) {
20593
+ const senderId = typeof busMessage.senderId === 'string' && busMessage.senderId.length > 0
20594
+ ? busMessage.senderId
20595
+ : null;
20596
+ const senderNodeId = InPageConnector.normalizeNodeId(busMessage.senderNodeId);
20597
+ if (!senderId || !senderNodeId) {
20598
+ logger$G.debug('inpage_message_rejected', {
20599
+ channel: this.channelName,
20600
+ connector_id: this.connectorId,
20601
+ reason: 'missing_sender_metadata',
20602
+ });
20566
20603
  return;
20567
20604
  }
20568
- if (busMessage.senderId === this.connectorId) {
20605
+ if (senderId === this.connectorId || senderNodeId === this.localNodeId) {
20606
+ logger$G.debug('inpage_message_rejected', {
20607
+ channel: this.channelName,
20608
+ connector_id: this.connectorId,
20609
+ reason: 'self_echo',
20610
+ sender_node_id: senderNodeId,
20611
+ });
20612
+ return;
20613
+ }
20614
+ const incomingTargetNodeId = InPageConnector.normalizeTargetNodeId(busMessage.targetNodeId);
20615
+ if (!this._shouldAcceptMessageFromBus(senderNodeId, incomingTargetNodeId)) {
20569
20616
  return;
20570
20617
  }
20571
20618
  const payload = InPageConnector.coercePayload(busMessage.payload);
@@ -20579,7 +20626,9 @@ class InPageConnector extends BaseAsyncConnector {
20579
20626
  }
20580
20627
  logger$G.debug('inpage_message_received', {
20581
20628
  channel: this.channelName,
20582
- sender_id: busMessage.senderId,
20629
+ sender_id: senderId,
20630
+ sender_node_id: senderNodeId,
20631
+ target_node_id: incomingTargetNodeId ?? null,
20583
20632
  connector_id: this.connectorId,
20584
20633
  payload_length: payload.byteLength,
20585
20634
  });
@@ -20587,15 +20636,27 @@ class InPageConnector extends BaseAsyncConnector {
20587
20636
  if (typeof this.inbox.tryEnqueue === 'function') {
20588
20637
  const accepted = this.inbox.tryEnqueue(payload);
20589
20638
  if (accepted) {
20639
+ this.logInboxSnapshot('inpage_inbox_enqueued', {
20640
+ source: 'listener',
20641
+ enqueue_strategy: 'try',
20642
+ payload_length: payload.byteLength,
20643
+ });
20590
20644
  return;
20591
20645
  }
20592
20646
  }
20593
20647
  this.inbox.enqueue(payload);
20648
+ this.logInboxSnapshot('inpage_inbox_enqueued', {
20649
+ source: 'listener',
20650
+ enqueue_strategy: 'enqueue',
20651
+ payload_length: payload.byteLength,
20652
+ });
20594
20653
  }
20595
20654
  catch (error) {
20596
20655
  if (error instanceof QueueFullError) {
20597
20656
  logger$G.warning('inpage_receive_queue_full', {
20598
20657
  channel: this.channelName,
20658
+ inbox_capacity: this.inboxCapacity,
20659
+ inbox_remaining_capacity: this.inbox.remainingCapacity,
20599
20660
  });
20600
20661
  }
20601
20662
  else {
@@ -20702,15 +20763,25 @@ class InPageConnector extends BaseAsyncConnector {
20702
20763
  if (typeof this.inbox.tryEnqueue === 'function') {
20703
20764
  const accepted = this.inbox.tryEnqueue(item);
20704
20765
  if (accepted) {
20766
+ this.logInboxSnapshot('inpage_push_enqueued', {
20767
+ enqueue_strategy: 'try',
20768
+ item_type: this._describeInboxItem(item),
20769
+ });
20705
20770
  return;
20706
20771
  }
20707
20772
  }
20708
20773
  this.inbox.enqueue(item);
20774
+ this.logInboxSnapshot('inpage_push_enqueued', {
20775
+ enqueue_strategy: 'enqueue',
20776
+ item_type: this._describeInboxItem(item),
20777
+ });
20709
20778
  }
20710
20779
  catch (error) {
20711
20780
  if (error instanceof QueueFullError) {
20712
20781
  logger$G.warning('inpage_push_queue_full', {
20713
20782
  channel: this.channelName,
20783
+ inbox_capacity: this.inboxCapacity,
20784
+ inbox_remaining_capacity: this.inbox.remainingCapacity,
20714
20785
  });
20715
20786
  throw error;
20716
20787
  }
@@ -20723,25 +20794,52 @@ class InPageConnector extends BaseAsyncConnector {
20723
20794
  }
20724
20795
  async _transportSendBytes(data) {
20725
20796
  ensureBrowserEnvironment$2();
20797
+ const targetNodeId = this.targetNodeId ?? '*';
20726
20798
  logger$G.debug('inpage_message_sending', {
20727
20799
  channel: this.channelName,
20728
20800
  sender_id: this.connectorId,
20801
+ sender_node_id: this.localNodeId,
20802
+ target_node_id: targetNodeId,
20729
20803
  });
20730
20804
  const event = new MessageEvent(this.channelName, {
20731
20805
  data: {
20732
20806
  senderId: this.connectorId,
20807
+ senderNodeId: this.localNodeId,
20808
+ targetNodeId,
20733
20809
  payload: data,
20734
20810
  },
20735
20811
  });
20736
20812
  getSharedBus$1().dispatchEvent(event);
20737
20813
  }
20738
20814
  async _transportReceive() {
20739
- return await this.inbox.dequeue();
20815
+ const item = await this.inbox.dequeue();
20816
+ this.logInboxSnapshot('inpage_inbox_dequeued', {
20817
+ item_type: this._describeInboxItem(item),
20818
+ });
20819
+ return item;
20740
20820
  }
20741
20821
  async _transportClose(code, reason) {
20822
+ logger$G.debug('inpage_transport_closing', {
20823
+ channel: this.channelName,
20824
+ connector_id: this.connectorId,
20825
+ code,
20826
+ reason,
20827
+ listener_registered: this.listenerRegistered,
20828
+ timestamp: new Date().toISOString(),
20829
+ });
20742
20830
  if (this.listenerRegistered) {
20831
+ logger$G.debug('inpage_removing_listener', {
20832
+ channel: this.channelName,
20833
+ connector_id: this.connectorId,
20834
+ timestamp: new Date().toISOString(),
20835
+ });
20743
20836
  getSharedBus$1().removeEventListener(this.channelName, this.onMsg);
20744
20837
  this.listenerRegistered = false;
20838
+ logger$G.debug('inpage_listener_removed', {
20839
+ channel: this.channelName,
20840
+ connector_id: this.connectorId,
20841
+ timestamp: new Date().toISOString(),
20842
+ });
20745
20843
  }
20746
20844
  if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
20747
20845
  document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
@@ -20759,6 +20857,103 @@ class InPageConnector extends BaseAsyncConnector {
20759
20857
  }
20760
20858
  return rawOrEnvelope;
20761
20859
  }
20860
+ _isWildcardTarget() {
20861
+ return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
20862
+ }
20863
+ _shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
20864
+ if (this._isWildcardTarget()) {
20865
+ if (targetNodeId &&
20866
+ targetNodeId !== '*' &&
20867
+ targetNodeId !== this.localNodeId) {
20868
+ logger$G.debug('inpage_message_rejected', {
20869
+ channel: this.channelName,
20870
+ connector_id: this.connectorId,
20871
+ reason: 'wildcard_target_mismatch',
20872
+ sender_node_id: senderNodeId,
20873
+ target_node_id: targetNodeId,
20874
+ local_node_id: this.localNodeId,
20875
+ });
20876
+ return false;
20877
+ }
20878
+ return true;
20879
+ }
20880
+ const expectedSender = this.targetNodeId;
20881
+ if (expectedSender && expectedSender !== '*' && senderNodeId !== expectedSender) {
20882
+ logger$G.debug('inpage_message_rejected', {
20883
+ channel: this.channelName,
20884
+ connector_id: this.connectorId,
20885
+ reason: 'unexpected_sender',
20886
+ expected_sender_node_id: expectedSender,
20887
+ sender_node_id: senderNodeId,
20888
+ local_node_id: this.localNodeId,
20889
+ });
20890
+ return false;
20891
+ }
20892
+ if (targetNodeId &&
20893
+ targetNodeId !== '*' &&
20894
+ targetNodeId !== this.localNodeId) {
20895
+ logger$G.debug('inpage_message_rejected', {
20896
+ channel: this.channelName,
20897
+ connector_id: this.connectorId,
20898
+ reason: 'unexpected_target',
20899
+ sender_node_id: senderNodeId,
20900
+ target_node_id: targetNodeId,
20901
+ local_node_id: this.localNodeId,
20902
+ });
20903
+ return false;
20904
+ }
20905
+ return true;
20906
+ }
20907
+ _describeInboxItem(item) {
20908
+ if (item instanceof Uint8Array) {
20909
+ return 'bytes';
20910
+ }
20911
+ if (item.envelope) {
20912
+ return 'channel_message';
20913
+ }
20914
+ if (item.frame) {
20915
+ return 'envelope';
20916
+ }
20917
+ return 'unknown';
20918
+ }
20919
+ logInboxSnapshot(event, extra = {}) {
20920
+ logger$G.debug(event, {
20921
+ channel: this.channelName,
20922
+ connector_id: this.connectorId,
20923
+ connector_state: this.state,
20924
+ inbox_capacity: this.inboxCapacity,
20925
+ inbox_remaining_capacity: this.inbox.remainingCapacity,
20926
+ ...extra,
20927
+ });
20928
+ }
20929
+ setTargetNodeId(nodeId) {
20930
+ const normalized = InPageConnector.normalizeNodeId(nodeId);
20931
+ if (!normalized) {
20932
+ throw new Error('InPageConnector target node id must be a non-empty string');
20933
+ }
20934
+ if (normalized === '*') {
20935
+ this.setWildcardTarget();
20936
+ return;
20937
+ }
20938
+ this.targetNodeId = normalized;
20939
+ logger$G.debug('inpage_target_updated', {
20940
+ channel: this.channelName,
20941
+ connector_id: this.connectorId,
20942
+ local_node_id: this.localNodeId,
20943
+ target_node_id: this.targetNodeId,
20944
+ target_mode: 'direct',
20945
+ });
20946
+ }
20947
+ setWildcardTarget() {
20948
+ this.targetNodeId = '*';
20949
+ logger$G.debug('inpage_target_updated', {
20950
+ channel: this.channelName,
20951
+ connector_id: this.connectorId,
20952
+ local_node_id: this.localNodeId,
20953
+ target_node_id: this.targetNodeId,
20954
+ target_mode: 'wildcard',
20955
+ });
20956
+ }
20762
20957
  }
20763
20958
 
20764
20959
  const RPC_REGISTRY = Symbol('naylence.rpc.registry');
@@ -28746,8 +28941,16 @@ class InPageConnectorFactory extends ConnectorFactory {
28746
28941
  }
28747
28942
  const normalized = this._normalizeConfig(config);
28748
28943
  const options = (factoryArgs[0] ?? {});
28944
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
28945
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
28946
+ if (!localNodeId) {
28947
+ throw new Error('InPageConnectorFactory requires a localNodeId from config or create() options');
28948
+ }
28749
28949
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL$5;
28750
28950
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
28951
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
28952
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
28953
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
28751
28954
  const baseConfig = {
28752
28955
  drainTimeout: normalized.drainTimeout,
28753
28956
  flowControl: normalized.flowControl,
@@ -28762,6 +28965,8 @@ class InPageConnectorFactory extends ConnectorFactory {
28762
28965
  type: INPAGE_CONNECTOR_TYPE,
28763
28966
  channelName,
28764
28967
  inboxCapacity,
28968
+ localNodeId,
28969
+ initialTargetNodeId: resolvedTarget,
28765
28970
  };
28766
28971
  const connector = new InPageConnector(connectorConfig, baseConfig);
28767
28972
  if (options.authorization) {
@@ -28797,6 +29002,16 @@ class InPageConnectorFactory extends ConnectorFactory {
28797
29002
  capacity > 0) {
28798
29003
  normalized.inboxCapacity = Math.floor(capacity);
28799
29004
  }
29005
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
29006
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
29007
+ if (normalizedLocalNodeId) {
29008
+ normalized.localNodeId = normalizedLocalNodeId;
29009
+ }
29010
+ const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
29011
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
29012
+ if (normalizedTarget) {
29013
+ normalized.initialTargetNodeId = normalizedTarget;
29014
+ }
28800
29015
  if (typeof candidate.flowControl === 'boolean') {
28801
29016
  normalized.flowControl = candidate.flowControl;
28802
29017
  }
@@ -28835,6 +29050,22 @@ class InPageConnectorFactory extends ConnectorFactory {
28835
29050
  normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
28836
29051
  return normalized;
28837
29052
  }
29053
+ _normalizeNodeId(value) {
29054
+ if (typeof value !== 'string') {
29055
+ return null;
29056
+ }
29057
+ const trimmed = value.trim();
29058
+ return trimmed.length > 0 ? trimmed : null;
29059
+ }
29060
+ _normalizeTargetNodeId(value) {
29061
+ if (value === undefined || value === null) {
29062
+ return undefined;
29063
+ }
29064
+ if (value === '*') {
29065
+ return '*';
29066
+ }
29067
+ return this._normalizeNodeId(value) ?? undefined;
29068
+ }
28838
29069
  }
28839
29070
 
28840
29071
  var inpageConnectorFactory = /*#__PURE__*/Object.freeze({
@@ -29613,7 +29844,7 @@ class InPageListener extends TransportListener {
29613
29844
  node: routingNode,
29614
29845
  });
29615
29846
  const selection = defaultGrantSelectionPolicy.selectCallbackGrant(selectionContext);
29616
- connectorConfig = this._grantToConnectorConfig(selection.grant);
29847
+ connectorConfig = this._buildConnectorConfigForSystem(systemId, this._grantToConnectorConfig(selection.grant));
29617
29848
  }
29618
29849
  catch (error) {
29619
29850
  logger$p.debug('inpage_listener_grant_selection_failed', {
@@ -29621,13 +29852,13 @@ class InPageListener extends TransportListener {
29621
29852
  system_id: systemId,
29622
29853
  error: error instanceof Error ? error.message : String(error),
29623
29854
  });
29624
- connectorConfig =
29625
- this._extractInPageConnectorConfig(frame) ??
29626
- {
29627
- type: INPAGE_CONNECTOR_TYPE,
29628
- channelName: this._channelName,
29629
- inboxCapacity: this._inboxCapacity,
29630
- };
29855
+ const fallbackConfig = this._extractInPageConnectorConfig(frame) ??
29856
+ {
29857
+ type: INPAGE_CONNECTOR_TYPE,
29858
+ channelName: this._channelName,
29859
+ inboxCapacity: this._inboxCapacity,
29860
+ };
29861
+ connectorConfig = this._buildConnectorConfigForSystem(systemId, fallbackConfig);
29631
29862
  }
29632
29863
  try {
29633
29864
  const connector = await routingNode.createOriginConnector({
@@ -29746,6 +29977,65 @@ class InPageListener extends TransportListener {
29746
29977
  typeof frame === 'object' &&
29747
29978
  frame.type === 'NodeAttach');
29748
29979
  }
29980
+ _buildConnectorConfigForSystem(systemId, baseConfig) {
29981
+ const localNodeId = this._requireLocalNodeId();
29982
+ const targetSystemId = this._normalizeNodeId(systemId);
29983
+ if (!targetSystemId) {
29984
+ throw new Error('InPageListener requires a valid system id for connector creation');
29985
+ }
29986
+ const candidate = baseConfig ?? null;
29987
+ const channelCandidate = candidate && 'channelName' in candidate
29988
+ ? candidate.channelName
29989
+ : undefined;
29990
+ const inboxCandidate = candidate && 'inboxCapacity' in candidate
29991
+ ? candidate.inboxCapacity
29992
+ : undefined;
29993
+ const targetCandidate = candidate && 'initialTargetNodeId' in candidate
29994
+ ? candidate.initialTargetNodeId
29995
+ : undefined;
29996
+ const channelName = typeof channelCandidate === 'string' && channelCandidate.trim().length > 0
29997
+ ? channelCandidate.trim()
29998
+ : this._channelName;
29999
+ const inboxCapacity = typeof inboxCandidate === 'number' &&
30000
+ Number.isFinite(inboxCandidate) &&
30001
+ inboxCandidate > 0
30002
+ ? Math.floor(inboxCandidate)
30003
+ : this._inboxCapacity;
30004
+ const normalizedTarget = this._normalizeTargetNodeId(targetCandidate);
30005
+ return {
30006
+ type: INPAGE_CONNECTOR_TYPE,
30007
+ channelName,
30008
+ inboxCapacity,
30009
+ localNodeId,
30010
+ initialTargetNodeId: normalizedTarget ?? targetSystemId,
30011
+ };
30012
+ }
30013
+ _requireLocalNodeId() {
30014
+ if (!this._routingNode) {
30015
+ throw new Error('InPageListener requires routing node context');
30016
+ }
30017
+ const normalized = this._normalizeNodeId(this._routingNode.id);
30018
+ if (!normalized) {
30019
+ throw new Error('InPageListener requires routing node with a stable identifier');
30020
+ }
30021
+ return normalized;
30022
+ }
30023
+ _normalizeNodeId(value) {
30024
+ if (typeof value !== 'string') {
30025
+ return null;
30026
+ }
30027
+ const trimmed = value.trim();
30028
+ return trimmed.length > 0 ? trimmed : null;
30029
+ }
30030
+ _normalizeTargetNodeId(value) {
30031
+ if (value === undefined || value === null) {
30032
+ return undefined;
30033
+ }
30034
+ if (value === '*') {
30035
+ return '*';
30036
+ }
30037
+ return this._normalizeNodeId(value) ?? undefined;
30038
+ }
29749
30039
  }
29750
30040
  function getInPageListenerInstance() {
29751
30041
  return _lastInPageListenerInstance;
@@ -68,8 +68,16 @@ class InPageConnectorFactory extends connector_factory_js_1.ConnectorFactory {
68
68
  }
69
69
  const normalized = this._normalizeConfig(config);
70
70
  const options = (factoryArgs[0] ?? {});
71
+ const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
72
+ const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
73
+ if (!localNodeId) {
74
+ throw new Error('InPageConnectorFactory requires a localNodeId from config or create() options');
75
+ }
71
76
  const channelName = normalized.channelName ?? DEFAULT_CHANNEL;
72
77
  const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY;
78
+ const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
79
+ const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
80
+ const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
73
81
  const baseConfig = {
74
82
  drainTimeout: normalized.drainTimeout,
75
83
  flowControl: normalized.flowControl,
@@ -84,6 +92,8 @@ class InPageConnectorFactory extends connector_factory_js_1.ConnectorFactory {
84
92
  type: inpage_connector_js_1.INPAGE_CONNECTOR_TYPE,
85
93
  channelName,
86
94
  inboxCapacity,
95
+ localNodeId,
96
+ initialTargetNodeId: resolvedTarget,
87
97
  };
88
98
  const connector = new inpage_connector_js_1.InPageConnector(connectorConfig, baseConfig);
89
99
  if (options.authorization) {
@@ -119,6 +129,16 @@ class InPageConnectorFactory extends connector_factory_js_1.ConnectorFactory {
119
129
  capacity > 0) {
120
130
  normalized.inboxCapacity = Math.floor(capacity);
121
131
  }
132
+ const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
133
+ const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
134
+ if (normalizedLocalNodeId) {
135
+ normalized.localNodeId = normalizedLocalNodeId;
136
+ }
137
+ const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
138
+ const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
139
+ if (normalizedTarget) {
140
+ normalized.initialTargetNodeId = normalizedTarget;
141
+ }
122
142
  if (typeof candidate.flowControl === 'boolean') {
123
143
  normalized.flowControl = candidate.flowControl;
124
144
  }
@@ -157,6 +177,22 @@ class InPageConnectorFactory extends connector_factory_js_1.ConnectorFactory {
157
177
  normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY;
158
178
  return normalized;
159
179
  }
180
+ _normalizeNodeId(value) {
181
+ if (typeof value !== 'string') {
182
+ return null;
183
+ }
184
+ const trimmed = value.trim();
185
+ return trimmed.length > 0 ? trimmed : null;
186
+ }
187
+ _normalizeTargetNodeId(value) {
188
+ if (value === undefined || value === null) {
189
+ return undefined;
190
+ }
191
+ if (value === '*') {
192
+ return '*';
193
+ }
194
+ return this._normalizeNodeId(value) ?? undefined;
195
+ }
160
196
  }
161
197
  exports.InPageConnectorFactory = InPageConnectorFactory;
162
198
  exports.default = InPageConnectorFactory;