@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/index.cjs
CHANGED
|
@@ -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.
|
|
17
|
+
// Generated from package.json version: 0.3.5-test.967
|
|
18
18
|
/**
|
|
19
19
|
* The package version, injected at build time.
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
const VERSION = '0.3.5-test.
|
|
22
|
+
const VERSION = '0.3.5-test.967';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -20434,6 +20434,26 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20434
20434
|
}
|
|
20435
20435
|
return null;
|
|
20436
20436
|
}
|
|
20437
|
+
static normalizeNodeId(value) {
|
|
20438
|
+
if (typeof value !== 'string') {
|
|
20439
|
+
return null;
|
|
20440
|
+
}
|
|
20441
|
+
const trimmed = value.trim();
|
|
20442
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
20443
|
+
}
|
|
20444
|
+
static normalizeTargetNodeId(value) {
|
|
20445
|
+
if (typeof value !== 'string') {
|
|
20446
|
+
return undefined;
|
|
20447
|
+
}
|
|
20448
|
+
const trimmed = value.trim();
|
|
20449
|
+
if (trimmed.length === 0) {
|
|
20450
|
+
return undefined;
|
|
20451
|
+
}
|
|
20452
|
+
if (trimmed === '*') {
|
|
20453
|
+
return '*';
|
|
20454
|
+
}
|
|
20455
|
+
return trimmed;
|
|
20456
|
+
}
|
|
20437
20457
|
constructor(config, baseConfig = {}) {
|
|
20438
20458
|
ensureBrowserEnvironment$2();
|
|
20439
20459
|
super(baseConfig);
|
|
@@ -20449,41 +20469,68 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20449
20469
|
? Math.floor(config.inboxCapacity)
|
|
20450
20470
|
: DEFAULT_INBOX_CAPACITY$6;
|
|
20451
20471
|
this.inbox = new BoundedAsyncQueue(preferredCapacity);
|
|
20472
|
+
this.inboxCapacity = preferredCapacity;
|
|
20452
20473
|
this.connectorId = InPageConnector.generateConnectorId();
|
|
20474
|
+
const normalizedLocalNodeId = InPageConnector.normalizeNodeId(config.localNodeId);
|
|
20475
|
+
if (!normalizedLocalNodeId) {
|
|
20476
|
+
throw new Error('InPageConnector requires a non-empty localNodeId');
|
|
20477
|
+
}
|
|
20478
|
+
this.localNodeId = normalizedLocalNodeId;
|
|
20479
|
+
this.targetNodeId = InPageConnector.normalizeTargetNodeId(config.initialTargetNodeId);
|
|
20453
20480
|
logger$G.debug('inpage_connector_initialized', {
|
|
20454
20481
|
channel: this.channelName,
|
|
20455
20482
|
connector_id: this.connectorId,
|
|
20483
|
+
local_node_id: this.localNodeId,
|
|
20484
|
+
target_node_id: this.targetNodeId ?? null,
|
|
20485
|
+
inbox_capacity: preferredCapacity,
|
|
20456
20486
|
});
|
|
20457
20487
|
this.onMsg = (event) => {
|
|
20488
|
+
if (!this.listenerRegistered) {
|
|
20489
|
+
logger$G.warning('inpage_message_after_unregister', {
|
|
20490
|
+
channel: this.channelName,
|
|
20491
|
+
connector_id: this.connectorId,
|
|
20492
|
+
timestamp: new Date().toISOString(),
|
|
20493
|
+
});
|
|
20494
|
+
return;
|
|
20495
|
+
}
|
|
20458
20496
|
const messageEvent = event;
|
|
20459
20497
|
const message = messageEvent.data;
|
|
20460
20498
|
logger$G.debug('inpage_raw_event', {
|
|
20461
20499
|
channel: this.channelName,
|
|
20462
20500
|
connector_id: this.connectorId,
|
|
20463
|
-
message_type: message && typeof message === 'object'
|
|
20464
|
-
|
|
20465
|
-
payload_type: message && typeof message === 'object'
|
|
20466
|
-
? message?.payload instanceof Uint8Array
|
|
20467
|
-
? 'Uint8Array'
|
|
20468
|
-
: message?.payload instanceof ArrayBuffer
|
|
20469
|
-
? 'ArrayBuffer'
|
|
20470
|
-
: typeof message?.payload
|
|
20501
|
+
message_type: message && typeof message === 'object'
|
|
20502
|
+
? message.constructor?.name ?? typeof message
|
|
20471
20503
|
: typeof message,
|
|
20472
|
-
|
|
20473
|
-
|
|
20474
|
-
: undefined,
|
|
20475
|
-
payload_keys: message && typeof message === 'object' && message?.payload && typeof message?.payload === 'object'
|
|
20476
|
-
? Object.keys(message.payload).slice(0, 5)
|
|
20477
|
-
: undefined,
|
|
20504
|
+
has_sender_id: Boolean(message?.senderId),
|
|
20505
|
+
has_sender_node_id: Boolean(message?.senderNodeId),
|
|
20478
20506
|
});
|
|
20479
20507
|
if (!message || typeof message !== 'object') {
|
|
20480
20508
|
return;
|
|
20481
20509
|
}
|
|
20482
20510
|
const busMessage = message;
|
|
20483
|
-
|
|
20511
|
+
const senderId = typeof busMessage.senderId === 'string' && busMessage.senderId.length > 0
|
|
20512
|
+
? busMessage.senderId
|
|
20513
|
+
: null;
|
|
20514
|
+
const senderNodeId = InPageConnector.normalizeNodeId(busMessage.senderNodeId);
|
|
20515
|
+
if (!senderId || !senderNodeId) {
|
|
20516
|
+
logger$G.debug('inpage_message_rejected', {
|
|
20517
|
+
channel: this.channelName,
|
|
20518
|
+
connector_id: this.connectorId,
|
|
20519
|
+
reason: 'missing_sender_metadata',
|
|
20520
|
+
});
|
|
20484
20521
|
return;
|
|
20485
20522
|
}
|
|
20486
|
-
if (
|
|
20523
|
+
if (senderId === this.connectorId || senderNodeId === this.localNodeId) {
|
|
20524
|
+
logger$G.debug('inpage_message_rejected', {
|
|
20525
|
+
channel: this.channelName,
|
|
20526
|
+
connector_id: this.connectorId,
|
|
20527
|
+
reason: 'self_echo',
|
|
20528
|
+
sender_node_id: senderNodeId,
|
|
20529
|
+
});
|
|
20530
|
+
return;
|
|
20531
|
+
}
|
|
20532
|
+
const incomingTargetNodeId = InPageConnector.normalizeTargetNodeId(busMessage.targetNodeId);
|
|
20533
|
+
if (!this._shouldAcceptMessageFromBus(senderNodeId, incomingTargetNodeId)) {
|
|
20487
20534
|
return;
|
|
20488
20535
|
}
|
|
20489
20536
|
const payload = InPageConnector.coercePayload(busMessage.payload);
|
|
@@ -20497,7 +20544,9 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20497
20544
|
}
|
|
20498
20545
|
logger$G.debug('inpage_message_received', {
|
|
20499
20546
|
channel: this.channelName,
|
|
20500
|
-
sender_id:
|
|
20547
|
+
sender_id: senderId,
|
|
20548
|
+
sender_node_id: senderNodeId,
|
|
20549
|
+
target_node_id: incomingTargetNodeId ?? null,
|
|
20501
20550
|
connector_id: this.connectorId,
|
|
20502
20551
|
payload_length: payload.byteLength,
|
|
20503
20552
|
});
|
|
@@ -20505,15 +20554,27 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20505
20554
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
20506
20555
|
const accepted = this.inbox.tryEnqueue(payload);
|
|
20507
20556
|
if (accepted) {
|
|
20557
|
+
this.logInboxSnapshot('inpage_inbox_enqueued', {
|
|
20558
|
+
source: 'listener',
|
|
20559
|
+
enqueue_strategy: 'try',
|
|
20560
|
+
payload_length: payload.byteLength,
|
|
20561
|
+
});
|
|
20508
20562
|
return;
|
|
20509
20563
|
}
|
|
20510
20564
|
}
|
|
20511
20565
|
this.inbox.enqueue(payload);
|
|
20566
|
+
this.logInboxSnapshot('inpage_inbox_enqueued', {
|
|
20567
|
+
source: 'listener',
|
|
20568
|
+
enqueue_strategy: 'enqueue',
|
|
20569
|
+
payload_length: payload.byteLength,
|
|
20570
|
+
});
|
|
20512
20571
|
}
|
|
20513
20572
|
catch (error) {
|
|
20514
20573
|
if (error instanceof QueueFullError) {
|
|
20515
20574
|
logger$G.warning('inpage_receive_queue_full', {
|
|
20516
20575
|
channel: this.channelName,
|
|
20576
|
+
inbox_capacity: this.inboxCapacity,
|
|
20577
|
+
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
20517
20578
|
});
|
|
20518
20579
|
}
|
|
20519
20580
|
else {
|
|
@@ -20620,15 +20681,25 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20620
20681
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
20621
20682
|
const accepted = this.inbox.tryEnqueue(item);
|
|
20622
20683
|
if (accepted) {
|
|
20684
|
+
this.logInboxSnapshot('inpage_push_enqueued', {
|
|
20685
|
+
enqueue_strategy: 'try',
|
|
20686
|
+
item_type: this._describeInboxItem(item),
|
|
20687
|
+
});
|
|
20623
20688
|
return;
|
|
20624
20689
|
}
|
|
20625
20690
|
}
|
|
20626
20691
|
this.inbox.enqueue(item);
|
|
20692
|
+
this.logInboxSnapshot('inpage_push_enqueued', {
|
|
20693
|
+
enqueue_strategy: 'enqueue',
|
|
20694
|
+
item_type: this._describeInboxItem(item),
|
|
20695
|
+
});
|
|
20627
20696
|
}
|
|
20628
20697
|
catch (error) {
|
|
20629
20698
|
if (error instanceof QueueFullError) {
|
|
20630
20699
|
logger$G.warning('inpage_push_queue_full', {
|
|
20631
20700
|
channel: this.channelName,
|
|
20701
|
+
inbox_capacity: this.inboxCapacity,
|
|
20702
|
+
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
20632
20703
|
});
|
|
20633
20704
|
throw error;
|
|
20634
20705
|
}
|
|
@@ -20641,25 +20712,52 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20641
20712
|
}
|
|
20642
20713
|
async _transportSendBytes(data) {
|
|
20643
20714
|
ensureBrowserEnvironment$2();
|
|
20715
|
+
const targetNodeId = this.targetNodeId ?? '*';
|
|
20644
20716
|
logger$G.debug('inpage_message_sending', {
|
|
20645
20717
|
channel: this.channelName,
|
|
20646
20718
|
sender_id: this.connectorId,
|
|
20719
|
+
sender_node_id: this.localNodeId,
|
|
20720
|
+
target_node_id: targetNodeId,
|
|
20647
20721
|
});
|
|
20648
20722
|
const event = new MessageEvent(this.channelName, {
|
|
20649
20723
|
data: {
|
|
20650
20724
|
senderId: this.connectorId,
|
|
20725
|
+
senderNodeId: this.localNodeId,
|
|
20726
|
+
targetNodeId,
|
|
20651
20727
|
payload: data,
|
|
20652
20728
|
},
|
|
20653
20729
|
});
|
|
20654
20730
|
getSharedBus$1().dispatchEvent(event);
|
|
20655
20731
|
}
|
|
20656
20732
|
async _transportReceive() {
|
|
20657
|
-
|
|
20733
|
+
const item = await this.inbox.dequeue();
|
|
20734
|
+
this.logInboxSnapshot('inpage_inbox_dequeued', {
|
|
20735
|
+
item_type: this._describeInboxItem(item),
|
|
20736
|
+
});
|
|
20737
|
+
return item;
|
|
20658
20738
|
}
|
|
20659
20739
|
async _transportClose(code, reason) {
|
|
20740
|
+
logger$G.debug('inpage_transport_closing', {
|
|
20741
|
+
channel: this.channelName,
|
|
20742
|
+
connector_id: this.connectorId,
|
|
20743
|
+
code,
|
|
20744
|
+
reason,
|
|
20745
|
+
listener_registered: this.listenerRegistered,
|
|
20746
|
+
timestamp: new Date().toISOString(),
|
|
20747
|
+
});
|
|
20660
20748
|
if (this.listenerRegistered) {
|
|
20749
|
+
logger$G.debug('inpage_removing_listener', {
|
|
20750
|
+
channel: this.channelName,
|
|
20751
|
+
connector_id: this.connectorId,
|
|
20752
|
+
timestamp: new Date().toISOString(),
|
|
20753
|
+
});
|
|
20661
20754
|
getSharedBus$1().removeEventListener(this.channelName, this.onMsg);
|
|
20662
20755
|
this.listenerRegistered = false;
|
|
20756
|
+
logger$G.debug('inpage_listener_removed', {
|
|
20757
|
+
channel: this.channelName,
|
|
20758
|
+
connector_id: this.connectorId,
|
|
20759
|
+
timestamp: new Date().toISOString(),
|
|
20760
|
+
});
|
|
20663
20761
|
}
|
|
20664
20762
|
if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
|
|
20665
20763
|
document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
|
|
@@ -20677,6 +20775,103 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20677
20775
|
}
|
|
20678
20776
|
return rawOrEnvelope;
|
|
20679
20777
|
}
|
|
20778
|
+
_isWildcardTarget() {
|
|
20779
|
+
return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
|
|
20780
|
+
}
|
|
20781
|
+
_shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
|
|
20782
|
+
if (this._isWildcardTarget()) {
|
|
20783
|
+
if (targetNodeId &&
|
|
20784
|
+
targetNodeId !== '*' &&
|
|
20785
|
+
targetNodeId !== this.localNodeId) {
|
|
20786
|
+
logger$G.debug('inpage_message_rejected', {
|
|
20787
|
+
channel: this.channelName,
|
|
20788
|
+
connector_id: this.connectorId,
|
|
20789
|
+
reason: 'wildcard_target_mismatch',
|
|
20790
|
+
sender_node_id: senderNodeId,
|
|
20791
|
+
target_node_id: targetNodeId,
|
|
20792
|
+
local_node_id: this.localNodeId,
|
|
20793
|
+
});
|
|
20794
|
+
return false;
|
|
20795
|
+
}
|
|
20796
|
+
return true;
|
|
20797
|
+
}
|
|
20798
|
+
const expectedSender = this.targetNodeId;
|
|
20799
|
+
if (expectedSender && expectedSender !== '*' && senderNodeId !== expectedSender) {
|
|
20800
|
+
logger$G.debug('inpage_message_rejected', {
|
|
20801
|
+
channel: this.channelName,
|
|
20802
|
+
connector_id: this.connectorId,
|
|
20803
|
+
reason: 'unexpected_sender',
|
|
20804
|
+
expected_sender_node_id: expectedSender,
|
|
20805
|
+
sender_node_id: senderNodeId,
|
|
20806
|
+
local_node_id: this.localNodeId,
|
|
20807
|
+
});
|
|
20808
|
+
return false;
|
|
20809
|
+
}
|
|
20810
|
+
if (targetNodeId &&
|
|
20811
|
+
targetNodeId !== '*' &&
|
|
20812
|
+
targetNodeId !== this.localNodeId) {
|
|
20813
|
+
logger$G.debug('inpage_message_rejected', {
|
|
20814
|
+
channel: this.channelName,
|
|
20815
|
+
connector_id: this.connectorId,
|
|
20816
|
+
reason: 'unexpected_target',
|
|
20817
|
+
sender_node_id: senderNodeId,
|
|
20818
|
+
target_node_id: targetNodeId,
|
|
20819
|
+
local_node_id: this.localNodeId,
|
|
20820
|
+
});
|
|
20821
|
+
return false;
|
|
20822
|
+
}
|
|
20823
|
+
return true;
|
|
20824
|
+
}
|
|
20825
|
+
_describeInboxItem(item) {
|
|
20826
|
+
if (item instanceof Uint8Array) {
|
|
20827
|
+
return 'bytes';
|
|
20828
|
+
}
|
|
20829
|
+
if (item.envelope) {
|
|
20830
|
+
return 'channel_message';
|
|
20831
|
+
}
|
|
20832
|
+
if (item.frame) {
|
|
20833
|
+
return 'envelope';
|
|
20834
|
+
}
|
|
20835
|
+
return 'unknown';
|
|
20836
|
+
}
|
|
20837
|
+
logInboxSnapshot(event, extra = {}) {
|
|
20838
|
+
logger$G.debug(event, {
|
|
20839
|
+
channel: this.channelName,
|
|
20840
|
+
connector_id: this.connectorId,
|
|
20841
|
+
connector_state: this.state,
|
|
20842
|
+
inbox_capacity: this.inboxCapacity,
|
|
20843
|
+
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
20844
|
+
...extra,
|
|
20845
|
+
});
|
|
20846
|
+
}
|
|
20847
|
+
setTargetNodeId(nodeId) {
|
|
20848
|
+
const normalized = InPageConnector.normalizeNodeId(nodeId);
|
|
20849
|
+
if (!normalized) {
|
|
20850
|
+
throw new Error('InPageConnector target node id must be a non-empty string');
|
|
20851
|
+
}
|
|
20852
|
+
if (normalized === '*') {
|
|
20853
|
+
this.setWildcardTarget();
|
|
20854
|
+
return;
|
|
20855
|
+
}
|
|
20856
|
+
this.targetNodeId = normalized;
|
|
20857
|
+
logger$G.debug('inpage_target_updated', {
|
|
20858
|
+
channel: this.channelName,
|
|
20859
|
+
connector_id: this.connectorId,
|
|
20860
|
+
local_node_id: this.localNodeId,
|
|
20861
|
+
target_node_id: this.targetNodeId,
|
|
20862
|
+
target_mode: 'direct',
|
|
20863
|
+
});
|
|
20864
|
+
}
|
|
20865
|
+
setWildcardTarget() {
|
|
20866
|
+
this.targetNodeId = '*';
|
|
20867
|
+
logger$G.debug('inpage_target_updated', {
|
|
20868
|
+
channel: this.channelName,
|
|
20869
|
+
connector_id: this.connectorId,
|
|
20870
|
+
local_node_id: this.localNodeId,
|
|
20871
|
+
target_node_id: this.targetNodeId,
|
|
20872
|
+
target_mode: 'wildcard',
|
|
20873
|
+
});
|
|
20874
|
+
}
|
|
20680
20875
|
}
|
|
20681
20876
|
|
|
20682
20877
|
const RPC_REGISTRY = Symbol('naylence.rpc.registry');
|
|
@@ -29331,8 +29526,16 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
29331
29526
|
}
|
|
29332
29527
|
const normalized = this._normalizeConfig(config);
|
|
29333
29528
|
const options = (factoryArgs[0] ?? {});
|
|
29529
|
+
const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
|
|
29530
|
+
const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
|
|
29531
|
+
if (!localNodeId) {
|
|
29532
|
+
throw new Error('InPageConnectorFactory requires a localNodeId from config or create() options');
|
|
29533
|
+
}
|
|
29334
29534
|
const channelName = normalized.channelName ?? DEFAULT_CHANNEL$3;
|
|
29335
29535
|
const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$3;
|
|
29536
|
+
const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
|
|
29537
|
+
const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
|
|
29538
|
+
const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
|
|
29336
29539
|
const baseConfig = {
|
|
29337
29540
|
drainTimeout: normalized.drainTimeout,
|
|
29338
29541
|
flowControl: normalized.flowControl,
|
|
@@ -29347,6 +29550,8 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
29347
29550
|
type: INPAGE_CONNECTOR_TYPE,
|
|
29348
29551
|
channelName,
|
|
29349
29552
|
inboxCapacity,
|
|
29553
|
+
localNodeId,
|
|
29554
|
+
initialTargetNodeId: resolvedTarget,
|
|
29350
29555
|
};
|
|
29351
29556
|
const connector = new InPageConnector(connectorConfig, baseConfig);
|
|
29352
29557
|
if (options.authorization) {
|
|
@@ -29382,6 +29587,16 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
29382
29587
|
capacity > 0) {
|
|
29383
29588
|
normalized.inboxCapacity = Math.floor(capacity);
|
|
29384
29589
|
}
|
|
29590
|
+
const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
|
|
29591
|
+
const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
|
|
29592
|
+
if (normalizedLocalNodeId) {
|
|
29593
|
+
normalized.localNodeId = normalizedLocalNodeId;
|
|
29594
|
+
}
|
|
29595
|
+
const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
|
|
29596
|
+
const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
|
|
29597
|
+
if (normalizedTarget) {
|
|
29598
|
+
normalized.initialTargetNodeId = normalizedTarget;
|
|
29599
|
+
}
|
|
29385
29600
|
if (typeof candidate.flowControl === 'boolean') {
|
|
29386
29601
|
normalized.flowControl = candidate.flowControl;
|
|
29387
29602
|
}
|
|
@@ -29420,6 +29635,22 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
29420
29635
|
normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$3;
|
|
29421
29636
|
return normalized;
|
|
29422
29637
|
}
|
|
29638
|
+
_normalizeNodeId(value) {
|
|
29639
|
+
if (typeof value !== 'string') {
|
|
29640
|
+
return null;
|
|
29641
|
+
}
|
|
29642
|
+
const trimmed = value.trim();
|
|
29643
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
29644
|
+
}
|
|
29645
|
+
_normalizeTargetNodeId(value) {
|
|
29646
|
+
if (value === undefined || value === null) {
|
|
29647
|
+
return undefined;
|
|
29648
|
+
}
|
|
29649
|
+
if (value === '*') {
|
|
29650
|
+
return '*';
|
|
29651
|
+
}
|
|
29652
|
+
return this._normalizeNodeId(value) ?? undefined;
|
|
29653
|
+
}
|
|
29423
29654
|
}
|
|
29424
29655
|
|
|
29425
29656
|
var inpageConnectorFactory = /*#__PURE__*/Object.freeze({
|
|
@@ -37457,7 +37688,7 @@ class InPageListener extends TransportListener {
|
|
|
37457
37688
|
node: routingNode,
|
|
37458
37689
|
});
|
|
37459
37690
|
const selection = defaultGrantSelectionPolicy.selectCallbackGrant(selectionContext);
|
|
37460
|
-
connectorConfig = this._grantToConnectorConfig(selection.grant);
|
|
37691
|
+
connectorConfig = this._buildConnectorConfigForSystem(systemId, this._grantToConnectorConfig(selection.grant));
|
|
37461
37692
|
}
|
|
37462
37693
|
catch (error) {
|
|
37463
37694
|
logger$7.debug('inpage_listener_grant_selection_failed', {
|
|
@@ -37465,13 +37696,13 @@ class InPageListener extends TransportListener {
|
|
|
37465
37696
|
system_id: systemId,
|
|
37466
37697
|
error: error instanceof Error ? error.message : String(error),
|
|
37467
37698
|
});
|
|
37468
|
-
|
|
37469
|
-
|
|
37470
|
-
|
|
37471
|
-
|
|
37472
|
-
|
|
37473
|
-
|
|
37474
|
-
|
|
37699
|
+
const fallbackConfig = this._extractInPageConnectorConfig(frame) ??
|
|
37700
|
+
{
|
|
37701
|
+
type: INPAGE_CONNECTOR_TYPE,
|
|
37702
|
+
channelName: this._channelName,
|
|
37703
|
+
inboxCapacity: this._inboxCapacity,
|
|
37704
|
+
};
|
|
37705
|
+
connectorConfig = this._buildConnectorConfigForSystem(systemId, fallbackConfig);
|
|
37475
37706
|
}
|
|
37476
37707
|
try {
|
|
37477
37708
|
const connector = await routingNode.createOriginConnector({
|
|
@@ -37590,6 +37821,65 @@ class InPageListener extends TransportListener {
|
|
|
37590
37821
|
typeof frame === 'object' &&
|
|
37591
37822
|
frame.type === 'NodeAttach');
|
|
37592
37823
|
}
|
|
37824
|
+
_buildConnectorConfigForSystem(systemId, baseConfig) {
|
|
37825
|
+
const localNodeId = this._requireLocalNodeId();
|
|
37826
|
+
const targetSystemId = this._normalizeNodeId(systemId);
|
|
37827
|
+
if (!targetSystemId) {
|
|
37828
|
+
throw new Error('InPageListener requires a valid system id for connector creation');
|
|
37829
|
+
}
|
|
37830
|
+
const candidate = baseConfig ?? null;
|
|
37831
|
+
const channelCandidate = candidate && 'channelName' in candidate
|
|
37832
|
+
? candidate.channelName
|
|
37833
|
+
: undefined;
|
|
37834
|
+
const inboxCandidate = candidate && 'inboxCapacity' in candidate
|
|
37835
|
+
? candidate.inboxCapacity
|
|
37836
|
+
: undefined;
|
|
37837
|
+
const targetCandidate = candidate && 'initialTargetNodeId' in candidate
|
|
37838
|
+
? candidate.initialTargetNodeId
|
|
37839
|
+
: undefined;
|
|
37840
|
+
const channelName = typeof channelCandidate === 'string' && channelCandidate.trim().length > 0
|
|
37841
|
+
? channelCandidate.trim()
|
|
37842
|
+
: this._channelName;
|
|
37843
|
+
const inboxCapacity = typeof inboxCandidate === 'number' &&
|
|
37844
|
+
Number.isFinite(inboxCandidate) &&
|
|
37845
|
+
inboxCandidate > 0
|
|
37846
|
+
? Math.floor(inboxCandidate)
|
|
37847
|
+
: this._inboxCapacity;
|
|
37848
|
+
const normalizedTarget = this._normalizeTargetNodeId(targetCandidate);
|
|
37849
|
+
return {
|
|
37850
|
+
type: INPAGE_CONNECTOR_TYPE,
|
|
37851
|
+
channelName,
|
|
37852
|
+
inboxCapacity,
|
|
37853
|
+
localNodeId,
|
|
37854
|
+
initialTargetNodeId: normalizedTarget ?? targetSystemId,
|
|
37855
|
+
};
|
|
37856
|
+
}
|
|
37857
|
+
_requireLocalNodeId() {
|
|
37858
|
+
if (!this._routingNode) {
|
|
37859
|
+
throw new Error('InPageListener requires routing node context');
|
|
37860
|
+
}
|
|
37861
|
+
const normalized = this._normalizeNodeId(this._routingNode.id);
|
|
37862
|
+
if (!normalized) {
|
|
37863
|
+
throw new Error('InPageListener requires routing node with a stable identifier');
|
|
37864
|
+
}
|
|
37865
|
+
return normalized;
|
|
37866
|
+
}
|
|
37867
|
+
_normalizeNodeId(value) {
|
|
37868
|
+
if (typeof value !== 'string') {
|
|
37869
|
+
return null;
|
|
37870
|
+
}
|
|
37871
|
+
const trimmed = value.trim();
|
|
37872
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
37873
|
+
}
|
|
37874
|
+
_normalizeTargetNodeId(value) {
|
|
37875
|
+
if (value === undefined || value === null) {
|
|
37876
|
+
return undefined;
|
|
37877
|
+
}
|
|
37878
|
+
if (value === '*') {
|
|
37879
|
+
return '*';
|
|
37880
|
+
}
|
|
37881
|
+
return this._normalizeNodeId(value) ?? undefined;
|
|
37882
|
+
}
|
|
37593
37883
|
}
|
|
37594
37884
|
function getInPageListenerInstance() {
|
|
37595
37885
|
return _lastInPageListenerInstance;
|