@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.
- package/dist/browser/index.cjs +318 -28
- package/dist/browser/index.mjs +318 -28
- package/dist/cjs/naylence/fame/connector/inpage-connector-factory.js +36 -0
- package/dist/cjs/naylence/fame/connector/inpage-connector.js +213 -18
- package/dist/cjs/naylence/fame/connector/inpage-listener.js +67 -8
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/connector/inpage-connector-factory.js +36 -0
- package/dist/esm/naylence/fame/connector/inpage-connector.js +213 -18
- package/dist/esm/naylence/fame/connector/inpage-listener.js +67 -8
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +318 -28
- package/dist/node/index.mjs +318 -28
- package/dist/node/node.cjs +318 -28
- package/dist/node/node.mjs +318 -28
- package/dist/types/naylence/fame/connector/inpage-connector-factory.d.ts +6 -0
- package/dist/types/naylence/fame/connector/inpage-connector.d.ts +13 -0
- package/dist/types/naylence/fame/connector/inpage-listener.d.ts +4 -0
- package/dist/types/naylence/fame/grants/inpage-connection-grant.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/node/node.cjs
CHANGED
|
@@ -5563,12 +5563,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
|
|
|
5563
5563
|
}
|
|
5564
5564
|
|
|
5565
5565
|
// This file is auto-generated during build - do not edit manually
|
|
5566
|
-
// Generated from package.json version: 0.3.5-test.
|
|
5566
|
+
// Generated from package.json version: 0.3.5-test.967
|
|
5567
5567
|
/**
|
|
5568
5568
|
* The package version, injected at build time.
|
|
5569
5569
|
* @internal
|
|
5570
5570
|
*/
|
|
5571
|
-
const VERSION = '0.3.5-test.
|
|
5571
|
+
const VERSION = '0.3.5-test.967';
|
|
5572
5572
|
|
|
5573
5573
|
/**
|
|
5574
5574
|
* Fame errors module - Fame protocol specific error classes
|
|
@@ -21612,6 +21612,26 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
21612
21612
|
}
|
|
21613
21613
|
return null;
|
|
21614
21614
|
}
|
|
21615
|
+
static normalizeNodeId(value) {
|
|
21616
|
+
if (typeof value !== 'string') {
|
|
21617
|
+
return null;
|
|
21618
|
+
}
|
|
21619
|
+
const trimmed = value.trim();
|
|
21620
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
21621
|
+
}
|
|
21622
|
+
static normalizeTargetNodeId(value) {
|
|
21623
|
+
if (typeof value !== 'string') {
|
|
21624
|
+
return undefined;
|
|
21625
|
+
}
|
|
21626
|
+
const trimmed = value.trim();
|
|
21627
|
+
if (trimmed.length === 0) {
|
|
21628
|
+
return undefined;
|
|
21629
|
+
}
|
|
21630
|
+
if (trimmed === '*') {
|
|
21631
|
+
return '*';
|
|
21632
|
+
}
|
|
21633
|
+
return trimmed;
|
|
21634
|
+
}
|
|
21615
21635
|
constructor(config, baseConfig = {}) {
|
|
21616
21636
|
ensureBrowserEnvironment$2();
|
|
21617
21637
|
super(baseConfig);
|
|
@@ -21627,41 +21647,68 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
21627
21647
|
? Math.floor(config.inboxCapacity)
|
|
21628
21648
|
: DEFAULT_INBOX_CAPACITY$6;
|
|
21629
21649
|
this.inbox = new BoundedAsyncQueue(preferredCapacity);
|
|
21650
|
+
this.inboxCapacity = preferredCapacity;
|
|
21630
21651
|
this.connectorId = InPageConnector.generateConnectorId();
|
|
21652
|
+
const normalizedLocalNodeId = InPageConnector.normalizeNodeId(config.localNodeId);
|
|
21653
|
+
if (!normalizedLocalNodeId) {
|
|
21654
|
+
throw new Error('InPageConnector requires a non-empty localNodeId');
|
|
21655
|
+
}
|
|
21656
|
+
this.localNodeId = normalizedLocalNodeId;
|
|
21657
|
+
this.targetNodeId = InPageConnector.normalizeTargetNodeId(config.initialTargetNodeId);
|
|
21631
21658
|
logger$J.debug('inpage_connector_initialized', {
|
|
21632
21659
|
channel: this.channelName,
|
|
21633
21660
|
connector_id: this.connectorId,
|
|
21661
|
+
local_node_id: this.localNodeId,
|
|
21662
|
+
target_node_id: this.targetNodeId ?? null,
|
|
21663
|
+
inbox_capacity: preferredCapacity,
|
|
21634
21664
|
});
|
|
21635
21665
|
this.onMsg = (event) => {
|
|
21666
|
+
if (!this.listenerRegistered) {
|
|
21667
|
+
logger$J.warning('inpage_message_after_unregister', {
|
|
21668
|
+
channel: this.channelName,
|
|
21669
|
+
connector_id: this.connectorId,
|
|
21670
|
+
timestamp: new Date().toISOString(),
|
|
21671
|
+
});
|
|
21672
|
+
return;
|
|
21673
|
+
}
|
|
21636
21674
|
const messageEvent = event;
|
|
21637
21675
|
const message = messageEvent.data;
|
|
21638
21676
|
logger$J.debug('inpage_raw_event', {
|
|
21639
21677
|
channel: this.channelName,
|
|
21640
21678
|
connector_id: this.connectorId,
|
|
21641
|
-
message_type: message && typeof message === 'object'
|
|
21642
|
-
|
|
21643
|
-
payload_type: message && typeof message === 'object'
|
|
21644
|
-
? message?.payload instanceof Uint8Array
|
|
21645
|
-
? 'Uint8Array'
|
|
21646
|
-
: message?.payload instanceof ArrayBuffer
|
|
21647
|
-
? 'ArrayBuffer'
|
|
21648
|
-
: typeof message?.payload
|
|
21679
|
+
message_type: message && typeof message === 'object'
|
|
21680
|
+
? message.constructor?.name ?? typeof message
|
|
21649
21681
|
: typeof message,
|
|
21650
|
-
|
|
21651
|
-
|
|
21652
|
-
: undefined,
|
|
21653
|
-
payload_keys: message && typeof message === 'object' && message?.payload && typeof message?.payload === 'object'
|
|
21654
|
-
? Object.keys(message.payload).slice(0, 5)
|
|
21655
|
-
: undefined,
|
|
21682
|
+
has_sender_id: Boolean(message?.senderId),
|
|
21683
|
+
has_sender_node_id: Boolean(message?.senderNodeId),
|
|
21656
21684
|
});
|
|
21657
21685
|
if (!message || typeof message !== 'object') {
|
|
21658
21686
|
return;
|
|
21659
21687
|
}
|
|
21660
21688
|
const busMessage = message;
|
|
21661
|
-
|
|
21689
|
+
const senderId = typeof busMessage.senderId === 'string' && busMessage.senderId.length > 0
|
|
21690
|
+
? busMessage.senderId
|
|
21691
|
+
: null;
|
|
21692
|
+
const senderNodeId = InPageConnector.normalizeNodeId(busMessage.senderNodeId);
|
|
21693
|
+
if (!senderId || !senderNodeId) {
|
|
21694
|
+
logger$J.debug('inpage_message_rejected', {
|
|
21695
|
+
channel: this.channelName,
|
|
21696
|
+
connector_id: this.connectorId,
|
|
21697
|
+
reason: 'missing_sender_metadata',
|
|
21698
|
+
});
|
|
21662
21699
|
return;
|
|
21663
21700
|
}
|
|
21664
|
-
if (
|
|
21701
|
+
if (senderId === this.connectorId || senderNodeId === this.localNodeId) {
|
|
21702
|
+
logger$J.debug('inpage_message_rejected', {
|
|
21703
|
+
channel: this.channelName,
|
|
21704
|
+
connector_id: this.connectorId,
|
|
21705
|
+
reason: 'self_echo',
|
|
21706
|
+
sender_node_id: senderNodeId,
|
|
21707
|
+
});
|
|
21708
|
+
return;
|
|
21709
|
+
}
|
|
21710
|
+
const incomingTargetNodeId = InPageConnector.normalizeTargetNodeId(busMessage.targetNodeId);
|
|
21711
|
+
if (!this._shouldAcceptMessageFromBus(senderNodeId, incomingTargetNodeId)) {
|
|
21665
21712
|
return;
|
|
21666
21713
|
}
|
|
21667
21714
|
const payload = InPageConnector.coercePayload(busMessage.payload);
|
|
@@ -21675,7 +21722,9 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
21675
21722
|
}
|
|
21676
21723
|
logger$J.debug('inpage_message_received', {
|
|
21677
21724
|
channel: this.channelName,
|
|
21678
|
-
sender_id:
|
|
21725
|
+
sender_id: senderId,
|
|
21726
|
+
sender_node_id: senderNodeId,
|
|
21727
|
+
target_node_id: incomingTargetNodeId ?? null,
|
|
21679
21728
|
connector_id: this.connectorId,
|
|
21680
21729
|
payload_length: payload.byteLength,
|
|
21681
21730
|
});
|
|
@@ -21683,15 +21732,27 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
21683
21732
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
21684
21733
|
const accepted = this.inbox.tryEnqueue(payload);
|
|
21685
21734
|
if (accepted) {
|
|
21735
|
+
this.logInboxSnapshot('inpage_inbox_enqueued', {
|
|
21736
|
+
source: 'listener',
|
|
21737
|
+
enqueue_strategy: 'try',
|
|
21738
|
+
payload_length: payload.byteLength,
|
|
21739
|
+
});
|
|
21686
21740
|
return;
|
|
21687
21741
|
}
|
|
21688
21742
|
}
|
|
21689
21743
|
this.inbox.enqueue(payload);
|
|
21744
|
+
this.logInboxSnapshot('inpage_inbox_enqueued', {
|
|
21745
|
+
source: 'listener',
|
|
21746
|
+
enqueue_strategy: 'enqueue',
|
|
21747
|
+
payload_length: payload.byteLength,
|
|
21748
|
+
});
|
|
21690
21749
|
}
|
|
21691
21750
|
catch (error) {
|
|
21692
21751
|
if (error instanceof QueueFullError) {
|
|
21693
21752
|
logger$J.warning('inpage_receive_queue_full', {
|
|
21694
21753
|
channel: this.channelName,
|
|
21754
|
+
inbox_capacity: this.inboxCapacity,
|
|
21755
|
+
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
21695
21756
|
});
|
|
21696
21757
|
}
|
|
21697
21758
|
else {
|
|
@@ -21798,15 +21859,25 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
21798
21859
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
21799
21860
|
const accepted = this.inbox.tryEnqueue(item);
|
|
21800
21861
|
if (accepted) {
|
|
21862
|
+
this.logInboxSnapshot('inpage_push_enqueued', {
|
|
21863
|
+
enqueue_strategy: 'try',
|
|
21864
|
+
item_type: this._describeInboxItem(item),
|
|
21865
|
+
});
|
|
21801
21866
|
return;
|
|
21802
21867
|
}
|
|
21803
21868
|
}
|
|
21804
21869
|
this.inbox.enqueue(item);
|
|
21870
|
+
this.logInboxSnapshot('inpage_push_enqueued', {
|
|
21871
|
+
enqueue_strategy: 'enqueue',
|
|
21872
|
+
item_type: this._describeInboxItem(item),
|
|
21873
|
+
});
|
|
21805
21874
|
}
|
|
21806
21875
|
catch (error) {
|
|
21807
21876
|
if (error instanceof QueueFullError) {
|
|
21808
21877
|
logger$J.warning('inpage_push_queue_full', {
|
|
21809
21878
|
channel: this.channelName,
|
|
21879
|
+
inbox_capacity: this.inboxCapacity,
|
|
21880
|
+
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
21810
21881
|
});
|
|
21811
21882
|
throw error;
|
|
21812
21883
|
}
|
|
@@ -21819,25 +21890,52 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
21819
21890
|
}
|
|
21820
21891
|
async _transportSendBytes(data) {
|
|
21821
21892
|
ensureBrowserEnvironment$2();
|
|
21893
|
+
const targetNodeId = this.targetNodeId ?? '*';
|
|
21822
21894
|
logger$J.debug('inpage_message_sending', {
|
|
21823
21895
|
channel: this.channelName,
|
|
21824
21896
|
sender_id: this.connectorId,
|
|
21897
|
+
sender_node_id: this.localNodeId,
|
|
21898
|
+
target_node_id: targetNodeId,
|
|
21825
21899
|
});
|
|
21826
21900
|
const event = new MessageEvent(this.channelName, {
|
|
21827
21901
|
data: {
|
|
21828
21902
|
senderId: this.connectorId,
|
|
21903
|
+
senderNodeId: this.localNodeId,
|
|
21904
|
+
targetNodeId,
|
|
21829
21905
|
payload: data,
|
|
21830
21906
|
},
|
|
21831
21907
|
});
|
|
21832
21908
|
getSharedBus$1().dispatchEvent(event);
|
|
21833
21909
|
}
|
|
21834
21910
|
async _transportReceive() {
|
|
21835
|
-
|
|
21911
|
+
const item = await this.inbox.dequeue();
|
|
21912
|
+
this.logInboxSnapshot('inpage_inbox_dequeued', {
|
|
21913
|
+
item_type: this._describeInboxItem(item),
|
|
21914
|
+
});
|
|
21915
|
+
return item;
|
|
21836
21916
|
}
|
|
21837
21917
|
async _transportClose(code, reason) {
|
|
21918
|
+
logger$J.debug('inpage_transport_closing', {
|
|
21919
|
+
channel: this.channelName,
|
|
21920
|
+
connector_id: this.connectorId,
|
|
21921
|
+
code,
|
|
21922
|
+
reason,
|
|
21923
|
+
listener_registered: this.listenerRegistered,
|
|
21924
|
+
timestamp: new Date().toISOString(),
|
|
21925
|
+
});
|
|
21838
21926
|
if (this.listenerRegistered) {
|
|
21927
|
+
logger$J.debug('inpage_removing_listener', {
|
|
21928
|
+
channel: this.channelName,
|
|
21929
|
+
connector_id: this.connectorId,
|
|
21930
|
+
timestamp: new Date().toISOString(),
|
|
21931
|
+
});
|
|
21839
21932
|
getSharedBus$1().removeEventListener(this.channelName, this.onMsg);
|
|
21840
21933
|
this.listenerRegistered = false;
|
|
21934
|
+
logger$J.debug('inpage_listener_removed', {
|
|
21935
|
+
channel: this.channelName,
|
|
21936
|
+
connector_id: this.connectorId,
|
|
21937
|
+
timestamp: new Date().toISOString(),
|
|
21938
|
+
});
|
|
21841
21939
|
}
|
|
21842
21940
|
if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
|
|
21843
21941
|
document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
|
|
@@ -21855,6 +21953,103 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
21855
21953
|
}
|
|
21856
21954
|
return rawOrEnvelope;
|
|
21857
21955
|
}
|
|
21956
|
+
_isWildcardTarget() {
|
|
21957
|
+
return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
|
|
21958
|
+
}
|
|
21959
|
+
_shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
|
|
21960
|
+
if (this._isWildcardTarget()) {
|
|
21961
|
+
if (targetNodeId &&
|
|
21962
|
+
targetNodeId !== '*' &&
|
|
21963
|
+
targetNodeId !== this.localNodeId) {
|
|
21964
|
+
logger$J.debug('inpage_message_rejected', {
|
|
21965
|
+
channel: this.channelName,
|
|
21966
|
+
connector_id: this.connectorId,
|
|
21967
|
+
reason: 'wildcard_target_mismatch',
|
|
21968
|
+
sender_node_id: senderNodeId,
|
|
21969
|
+
target_node_id: targetNodeId,
|
|
21970
|
+
local_node_id: this.localNodeId,
|
|
21971
|
+
});
|
|
21972
|
+
return false;
|
|
21973
|
+
}
|
|
21974
|
+
return true;
|
|
21975
|
+
}
|
|
21976
|
+
const expectedSender = this.targetNodeId;
|
|
21977
|
+
if (expectedSender && expectedSender !== '*' && senderNodeId !== expectedSender) {
|
|
21978
|
+
logger$J.debug('inpage_message_rejected', {
|
|
21979
|
+
channel: this.channelName,
|
|
21980
|
+
connector_id: this.connectorId,
|
|
21981
|
+
reason: 'unexpected_sender',
|
|
21982
|
+
expected_sender_node_id: expectedSender,
|
|
21983
|
+
sender_node_id: senderNodeId,
|
|
21984
|
+
local_node_id: this.localNodeId,
|
|
21985
|
+
});
|
|
21986
|
+
return false;
|
|
21987
|
+
}
|
|
21988
|
+
if (targetNodeId &&
|
|
21989
|
+
targetNodeId !== '*' &&
|
|
21990
|
+
targetNodeId !== this.localNodeId) {
|
|
21991
|
+
logger$J.debug('inpage_message_rejected', {
|
|
21992
|
+
channel: this.channelName,
|
|
21993
|
+
connector_id: this.connectorId,
|
|
21994
|
+
reason: 'unexpected_target',
|
|
21995
|
+
sender_node_id: senderNodeId,
|
|
21996
|
+
target_node_id: targetNodeId,
|
|
21997
|
+
local_node_id: this.localNodeId,
|
|
21998
|
+
});
|
|
21999
|
+
return false;
|
|
22000
|
+
}
|
|
22001
|
+
return true;
|
|
22002
|
+
}
|
|
22003
|
+
_describeInboxItem(item) {
|
|
22004
|
+
if (item instanceof Uint8Array) {
|
|
22005
|
+
return 'bytes';
|
|
22006
|
+
}
|
|
22007
|
+
if (item.envelope) {
|
|
22008
|
+
return 'channel_message';
|
|
22009
|
+
}
|
|
22010
|
+
if (item.frame) {
|
|
22011
|
+
return 'envelope';
|
|
22012
|
+
}
|
|
22013
|
+
return 'unknown';
|
|
22014
|
+
}
|
|
22015
|
+
logInboxSnapshot(event, extra = {}) {
|
|
22016
|
+
logger$J.debug(event, {
|
|
22017
|
+
channel: this.channelName,
|
|
22018
|
+
connector_id: this.connectorId,
|
|
22019
|
+
connector_state: this.state,
|
|
22020
|
+
inbox_capacity: this.inboxCapacity,
|
|
22021
|
+
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
22022
|
+
...extra,
|
|
22023
|
+
});
|
|
22024
|
+
}
|
|
22025
|
+
setTargetNodeId(nodeId) {
|
|
22026
|
+
const normalized = InPageConnector.normalizeNodeId(nodeId);
|
|
22027
|
+
if (!normalized) {
|
|
22028
|
+
throw new Error('InPageConnector target node id must be a non-empty string');
|
|
22029
|
+
}
|
|
22030
|
+
if (normalized === '*') {
|
|
22031
|
+
this.setWildcardTarget();
|
|
22032
|
+
return;
|
|
22033
|
+
}
|
|
22034
|
+
this.targetNodeId = normalized;
|
|
22035
|
+
logger$J.debug('inpage_target_updated', {
|
|
22036
|
+
channel: this.channelName,
|
|
22037
|
+
connector_id: this.connectorId,
|
|
22038
|
+
local_node_id: this.localNodeId,
|
|
22039
|
+
target_node_id: this.targetNodeId,
|
|
22040
|
+
target_mode: 'direct',
|
|
22041
|
+
});
|
|
22042
|
+
}
|
|
22043
|
+
setWildcardTarget() {
|
|
22044
|
+
this.targetNodeId = '*';
|
|
22045
|
+
logger$J.debug('inpage_target_updated', {
|
|
22046
|
+
channel: this.channelName,
|
|
22047
|
+
connector_id: this.connectorId,
|
|
22048
|
+
local_node_id: this.localNodeId,
|
|
22049
|
+
target_node_id: this.targetNodeId,
|
|
22050
|
+
target_mode: 'wildcard',
|
|
22051
|
+
});
|
|
22052
|
+
}
|
|
21858
22053
|
}
|
|
21859
22054
|
|
|
21860
22055
|
const RPC_REGISTRY = Symbol('naylence.rpc.registry');
|
|
@@ -30435,8 +30630,16 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
30435
30630
|
}
|
|
30436
30631
|
const normalized = this._normalizeConfig(config);
|
|
30437
30632
|
const options = (factoryArgs[0] ?? {});
|
|
30633
|
+
const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
|
|
30634
|
+
const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
|
|
30635
|
+
if (!localNodeId) {
|
|
30636
|
+
throw new Error('InPageConnectorFactory requires a localNodeId from config or create() options');
|
|
30637
|
+
}
|
|
30438
30638
|
const channelName = normalized.channelName ?? DEFAULT_CHANNEL$3;
|
|
30439
30639
|
const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$3;
|
|
30640
|
+
const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
|
|
30641
|
+
const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
|
|
30642
|
+
const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
|
|
30440
30643
|
const baseConfig = {
|
|
30441
30644
|
drainTimeout: normalized.drainTimeout,
|
|
30442
30645
|
flowControl: normalized.flowControl,
|
|
@@ -30451,6 +30654,8 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
30451
30654
|
type: INPAGE_CONNECTOR_TYPE,
|
|
30452
30655
|
channelName,
|
|
30453
30656
|
inboxCapacity,
|
|
30657
|
+
localNodeId,
|
|
30658
|
+
initialTargetNodeId: resolvedTarget,
|
|
30454
30659
|
};
|
|
30455
30660
|
const connector = new InPageConnector(connectorConfig, baseConfig);
|
|
30456
30661
|
if (options.authorization) {
|
|
@@ -30486,6 +30691,16 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
30486
30691
|
capacity > 0) {
|
|
30487
30692
|
normalized.inboxCapacity = Math.floor(capacity);
|
|
30488
30693
|
}
|
|
30694
|
+
const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
|
|
30695
|
+
const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
|
|
30696
|
+
if (normalizedLocalNodeId) {
|
|
30697
|
+
normalized.localNodeId = normalizedLocalNodeId;
|
|
30698
|
+
}
|
|
30699
|
+
const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
|
|
30700
|
+
const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
|
|
30701
|
+
if (normalizedTarget) {
|
|
30702
|
+
normalized.initialTargetNodeId = normalizedTarget;
|
|
30703
|
+
}
|
|
30489
30704
|
if (typeof candidate.flowControl === 'boolean') {
|
|
30490
30705
|
normalized.flowControl = candidate.flowControl;
|
|
30491
30706
|
}
|
|
@@ -30524,6 +30739,22 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
30524
30739
|
normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$3;
|
|
30525
30740
|
return normalized;
|
|
30526
30741
|
}
|
|
30742
|
+
_normalizeNodeId(value) {
|
|
30743
|
+
if (typeof value !== 'string') {
|
|
30744
|
+
return null;
|
|
30745
|
+
}
|
|
30746
|
+
const trimmed = value.trim();
|
|
30747
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
30748
|
+
}
|
|
30749
|
+
_normalizeTargetNodeId(value) {
|
|
30750
|
+
if (value === undefined || value === null) {
|
|
30751
|
+
return undefined;
|
|
30752
|
+
}
|
|
30753
|
+
if (value === '*') {
|
|
30754
|
+
return '*';
|
|
30755
|
+
}
|
|
30756
|
+
return this._normalizeNodeId(value) ?? undefined;
|
|
30757
|
+
}
|
|
30527
30758
|
}
|
|
30528
30759
|
|
|
30529
30760
|
var inpageConnectorFactory = /*#__PURE__*/Object.freeze({
|
|
@@ -32418,7 +32649,7 @@ class InPageListener extends TransportListener {
|
|
|
32418
32649
|
node: routingNode,
|
|
32419
32650
|
});
|
|
32420
32651
|
const selection = defaultGrantSelectionPolicy.selectCallbackGrant(selectionContext);
|
|
32421
|
-
connectorConfig = this._grantToConnectorConfig(selection.grant);
|
|
32652
|
+
connectorConfig = this._buildConnectorConfigForSystem(systemId, this._grantToConnectorConfig(selection.grant));
|
|
32422
32653
|
}
|
|
32423
32654
|
catch (error) {
|
|
32424
32655
|
logger$o.debug('inpage_listener_grant_selection_failed', {
|
|
@@ -32426,13 +32657,13 @@ class InPageListener extends TransportListener {
|
|
|
32426
32657
|
system_id: systemId,
|
|
32427
32658
|
error: error instanceof Error ? error.message : String(error),
|
|
32428
32659
|
});
|
|
32429
|
-
|
|
32430
|
-
|
|
32431
|
-
|
|
32432
|
-
|
|
32433
|
-
|
|
32434
|
-
|
|
32435
|
-
|
|
32660
|
+
const fallbackConfig = this._extractInPageConnectorConfig(frame) ??
|
|
32661
|
+
{
|
|
32662
|
+
type: INPAGE_CONNECTOR_TYPE,
|
|
32663
|
+
channelName: this._channelName,
|
|
32664
|
+
inboxCapacity: this._inboxCapacity,
|
|
32665
|
+
};
|
|
32666
|
+
connectorConfig = this._buildConnectorConfigForSystem(systemId, fallbackConfig);
|
|
32436
32667
|
}
|
|
32437
32668
|
try {
|
|
32438
32669
|
const connector = await routingNode.createOriginConnector({
|
|
@@ -32551,6 +32782,65 @@ class InPageListener extends TransportListener {
|
|
|
32551
32782
|
typeof frame === 'object' &&
|
|
32552
32783
|
frame.type === 'NodeAttach');
|
|
32553
32784
|
}
|
|
32785
|
+
_buildConnectorConfigForSystem(systemId, baseConfig) {
|
|
32786
|
+
const localNodeId = this._requireLocalNodeId();
|
|
32787
|
+
const targetSystemId = this._normalizeNodeId(systemId);
|
|
32788
|
+
if (!targetSystemId) {
|
|
32789
|
+
throw new Error('InPageListener requires a valid system id for connector creation');
|
|
32790
|
+
}
|
|
32791
|
+
const candidate = baseConfig ?? null;
|
|
32792
|
+
const channelCandidate = candidate && 'channelName' in candidate
|
|
32793
|
+
? candidate.channelName
|
|
32794
|
+
: undefined;
|
|
32795
|
+
const inboxCandidate = candidate && 'inboxCapacity' in candidate
|
|
32796
|
+
? candidate.inboxCapacity
|
|
32797
|
+
: undefined;
|
|
32798
|
+
const targetCandidate = candidate && 'initialTargetNodeId' in candidate
|
|
32799
|
+
? candidate.initialTargetNodeId
|
|
32800
|
+
: undefined;
|
|
32801
|
+
const channelName = typeof channelCandidate === 'string' && channelCandidate.trim().length > 0
|
|
32802
|
+
? channelCandidate.trim()
|
|
32803
|
+
: this._channelName;
|
|
32804
|
+
const inboxCapacity = typeof inboxCandidate === 'number' &&
|
|
32805
|
+
Number.isFinite(inboxCandidate) &&
|
|
32806
|
+
inboxCandidate > 0
|
|
32807
|
+
? Math.floor(inboxCandidate)
|
|
32808
|
+
: this._inboxCapacity;
|
|
32809
|
+
const normalizedTarget = this._normalizeTargetNodeId(targetCandidate);
|
|
32810
|
+
return {
|
|
32811
|
+
type: INPAGE_CONNECTOR_TYPE,
|
|
32812
|
+
channelName,
|
|
32813
|
+
inboxCapacity,
|
|
32814
|
+
localNodeId,
|
|
32815
|
+
initialTargetNodeId: normalizedTarget ?? targetSystemId,
|
|
32816
|
+
};
|
|
32817
|
+
}
|
|
32818
|
+
_requireLocalNodeId() {
|
|
32819
|
+
if (!this._routingNode) {
|
|
32820
|
+
throw new Error('InPageListener requires routing node context');
|
|
32821
|
+
}
|
|
32822
|
+
const normalized = this._normalizeNodeId(this._routingNode.id);
|
|
32823
|
+
if (!normalized) {
|
|
32824
|
+
throw new Error('InPageListener requires routing node with a stable identifier');
|
|
32825
|
+
}
|
|
32826
|
+
return normalized;
|
|
32827
|
+
}
|
|
32828
|
+
_normalizeNodeId(value) {
|
|
32829
|
+
if (typeof value !== 'string') {
|
|
32830
|
+
return null;
|
|
32831
|
+
}
|
|
32832
|
+
const trimmed = value.trim();
|
|
32833
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
32834
|
+
}
|
|
32835
|
+
_normalizeTargetNodeId(value) {
|
|
32836
|
+
if (value === undefined || value === null) {
|
|
32837
|
+
return undefined;
|
|
32838
|
+
}
|
|
32839
|
+
if (value === '*') {
|
|
32840
|
+
return '*';
|
|
32841
|
+
}
|
|
32842
|
+
return this._normalizeNodeId(value) ?? undefined;
|
|
32843
|
+
}
|
|
32554
32844
|
}
|
|
32555
32845
|
function getInPageListenerInstance() {
|
|
32556
32846
|
return _lastInPageListenerInstance;
|