@naylence/runtime 0.3.5-test.953 → 0.3.5-test.954
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 +32 -514
- package/dist/browser/index.mjs +32 -514
- package/dist/cjs/naylence/fame/connector/broadcast-channel-connector-factory.js +2 -14
- package/dist/cjs/naylence/fame/connector/broadcast-channel-connector.browser.js +1 -108
- package/dist/cjs/naylence/fame/connector/broadcast-channel-listener.js +10 -76
- package/dist/cjs/naylence/fame/connector/inpage-connector-factory.js +0 -12
- package/dist/cjs/naylence/fame/connector/inpage-connector.js +1 -105
- package/dist/cjs/naylence/fame/connector/inpage-listener.js +2 -49
- package/dist/cjs/naylence/fame/grants/broadcast-channel-connection-grant.js +12 -23
- package/dist/cjs/naylence/fame/grants/inpage-connection-grant.js +0 -28
- package/dist/cjs/naylence/fame/node/admission/default-node-attach-client.js +0 -14
- package/dist/cjs/naylence/fame/node/upstream-session-manager.js +0 -6
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/connector/broadcast-channel-connector-factory.js +2 -14
- package/dist/esm/naylence/fame/connector/broadcast-channel-connector.browser.js +1 -108
- package/dist/esm/naylence/fame/connector/broadcast-channel-listener.js +10 -76
- package/dist/esm/naylence/fame/connector/inpage-connector-factory.js +0 -12
- package/dist/esm/naylence/fame/connector/inpage-connector.js +1 -105
- package/dist/esm/naylence/fame/connector/inpage-listener.js +2 -49
- package/dist/esm/naylence/fame/grants/broadcast-channel-connection-grant.js +12 -23
- package/dist/esm/naylence/fame/grants/inpage-connection-grant.js +0 -28
- package/dist/esm/naylence/fame/node/admission/default-node-attach-client.js +0 -14
- package/dist/esm/naylence/fame/node/upstream-session-manager.js +0 -6
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +32 -514
- package/dist/node/index.mjs +32 -514
- package/dist/node/node.cjs +32 -530
- package/dist/node/node.mjs +32 -530
- package/dist/types/naylence/fame/connector/broadcast-channel-connector-factory.d.ts +0 -2
- package/dist/types/naylence/fame/connector/broadcast-channel-connector.browser.d.ts +1 -9
- package/dist/types/naylence/fame/connector/inpage-connector-factory.d.ts +0 -2
- package/dist/types/naylence/fame/connector/inpage-connector.d.ts +0 -9
- package/dist/types/naylence/fame/connector/inpage-listener.d.ts +0 -1
- package/dist/types/naylence/fame/grants/broadcast-channel-connection-grant.d.ts +3 -6
- package/dist/types/naylence/fame/grants/inpage-connection-grant.d.ts +0 -8
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/naylence/fame/connector/transport-frame.js +0 -100
- package/dist/esm/naylence/fame/connector/transport-frame.js +0 -93
- package/dist/types/naylence/fame/connector/transport-frame.d.ts +0 -56
package/dist/node/node.mjs
CHANGED
|
@@ -5477,12 +5477,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
|
|
|
5477
5477
|
}
|
|
5478
5478
|
|
|
5479
5479
|
// This file is auto-generated during build - do not edit manually
|
|
5480
|
-
// Generated from package.json version: 0.3.5-test.
|
|
5480
|
+
// Generated from package.json version: 0.3.5-test.954
|
|
5481
5481
|
/**
|
|
5482
5482
|
* The package version, injected at build time.
|
|
5483
5483
|
* @internal
|
|
5484
5484
|
*/
|
|
5485
|
-
const VERSION = '0.3.5-test.
|
|
5485
|
+
const VERSION = '0.3.5-test.954';
|
|
5486
5486
|
|
|
5487
5487
|
/**
|
|
5488
5488
|
* Fame errors module - Fame protocol specific error classes
|
|
@@ -11470,100 +11470,6 @@ class BoundedAsyncQueue {
|
|
|
11470
11470
|
}
|
|
11471
11471
|
}
|
|
11472
11472
|
|
|
11473
|
-
/**
|
|
11474
|
-
* Transport frame layer for multiplexing logical links on physical channels.
|
|
11475
|
-
*
|
|
11476
|
-
* This lightweight framing layer wraps raw FAME payloads to enable multiple
|
|
11477
|
-
* logical connections over a single physical channel (BroadcastChannel or InPage bus).
|
|
11478
|
-
*
|
|
11479
|
-
* The transport frame does NOT modify FAME envelopes - it only wraps the raw
|
|
11480
|
-
* Uint8Array payload at the connector level.
|
|
11481
|
-
*/
|
|
11482
|
-
/**
|
|
11483
|
-
* Transport frame version for future compatibility
|
|
11484
|
-
*/
|
|
11485
|
-
const TRANSPORT_FRAME_VERSION = 1;
|
|
11486
|
-
/**
|
|
11487
|
-
* Wrap a raw payload in a transport frame
|
|
11488
|
-
*
|
|
11489
|
-
* @param payload - Raw FAME envelope bytes
|
|
11490
|
-
* @param srcNodeId - Local node ID (this connector)
|
|
11491
|
-
* @param dstNodeId - Remote node ID (target connector)
|
|
11492
|
-
* @returns Transport frame ready for transmission
|
|
11493
|
-
*/
|
|
11494
|
-
function wrapTransportFrame(payload, srcNodeId, dstNodeId) {
|
|
11495
|
-
return {
|
|
11496
|
-
v: TRANSPORT_FRAME_VERSION,
|
|
11497
|
-
src: srcNodeId,
|
|
11498
|
-
dst: dstNodeId,
|
|
11499
|
-
payload,
|
|
11500
|
-
};
|
|
11501
|
-
}
|
|
11502
|
-
/**
|
|
11503
|
-
* Serialize a transport frame for transmission over the bus
|
|
11504
|
-
*
|
|
11505
|
-
* @param frame - Transport frame to serialize
|
|
11506
|
-
* @returns Serialized frame data ready for postMessage/dispatchEvent
|
|
11507
|
-
*/
|
|
11508
|
-
function serializeTransportFrame(frame) {
|
|
11509
|
-
// Convert Uint8Array to regular array for JSON serialization
|
|
11510
|
-
const serializable = {
|
|
11511
|
-
v: frame.v,
|
|
11512
|
-
src: frame.src,
|
|
11513
|
-
dst: frame.dst,
|
|
11514
|
-
payload: Array.from(frame.payload),
|
|
11515
|
-
};
|
|
11516
|
-
return serializable;
|
|
11517
|
-
}
|
|
11518
|
-
/**
|
|
11519
|
-
* Unwrap a transport frame (pure deserializer - no filtering)
|
|
11520
|
-
*
|
|
11521
|
-
* @param raw - Raw data from the bus
|
|
11522
|
-
* @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
|
|
11523
|
-
*/
|
|
11524
|
-
function unwrapTransportFrame(raw) {
|
|
11525
|
-
// Validate basic structure
|
|
11526
|
-
if (!raw || typeof raw !== 'object') {
|
|
11527
|
-
return null;
|
|
11528
|
-
}
|
|
11529
|
-
const frame = raw;
|
|
11530
|
-
// Check version
|
|
11531
|
-
if (frame.v !== TRANSPORT_FRAME_VERSION) {
|
|
11532
|
-
return null;
|
|
11533
|
-
}
|
|
11534
|
-
// Check src and dst
|
|
11535
|
-
if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
|
|
11536
|
-
return null;
|
|
11537
|
-
}
|
|
11538
|
-
// Extract payload
|
|
11539
|
-
if (!frame.payload || !Array.isArray(frame.payload)) {
|
|
11540
|
-
return null;
|
|
11541
|
-
}
|
|
11542
|
-
// Convert array back to Uint8Array and return full frame
|
|
11543
|
-
return {
|
|
11544
|
-
v: frame.v,
|
|
11545
|
-
src: frame.src,
|
|
11546
|
-
dst: frame.dst,
|
|
11547
|
-
payload: Uint8Array.from(frame.payload),
|
|
11548
|
-
};
|
|
11549
|
-
}
|
|
11550
|
-
/**
|
|
11551
|
-
* Check if raw data looks like a transport frame
|
|
11552
|
-
*
|
|
11553
|
-
* @param raw - Raw data from the bus
|
|
11554
|
-
* @returns True if this appears to be a transport frame
|
|
11555
|
-
*/
|
|
11556
|
-
function isTransportFrame(raw) {
|
|
11557
|
-
if (!raw || typeof raw !== 'object') {
|
|
11558
|
-
return false;
|
|
11559
|
-
}
|
|
11560
|
-
const frame = raw;
|
|
11561
|
-
return (typeof frame.v === 'number' &&
|
|
11562
|
-
typeof frame.src === 'string' &&
|
|
11563
|
-
typeof frame.dst === 'string' &&
|
|
11564
|
-
Array.isArray(frame.payload));
|
|
11565
|
-
}
|
|
11566
|
-
|
|
11567
11473
|
const logger$10 = getLogger('naylence.fame.connector.broadcast_channel_connector');
|
|
11568
11474
|
const BROADCAST_CHANNEL_CONNECTOR_TYPE$1 = 'broadcast-channel-connector';
|
|
11569
11475
|
const DEFAULT_CHANNEL$7 = 'naylence-fabric';
|
|
@@ -11629,20 +11535,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
11629
11535
|
this.inbox = new BoundedAsyncQueue(preferredCapacity);
|
|
11630
11536
|
this.connectorId = BroadcastChannelConnector.generateConnectorId();
|
|
11631
11537
|
this.channel = new BroadcastChannel(this.channelName);
|
|
11632
|
-
// Set local and remote node IDs (defaults to connector ID for backwards compatibility)
|
|
11633
|
-
this.localNodeId =
|
|
11634
|
-
typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
|
|
11635
|
-
? config.localNodeId.trim()
|
|
11636
|
-
: this.connectorId;
|
|
11637
|
-
this.remoteNodeId =
|
|
11638
|
-
typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
|
|
11639
|
-
? config.remoteNodeId.trim()
|
|
11640
|
-
: '*'; // Accept from any remote if not specified
|
|
11641
11538
|
logger$10.debug('broadcast_channel_connector_created', {
|
|
11642
11539
|
channel: this.channelName,
|
|
11643
11540
|
connector_id: this.connectorId,
|
|
11644
|
-
local_node_id: this.localNodeId,
|
|
11645
|
-
remote_node_id: this.remoteNodeId,
|
|
11646
11541
|
inbox_capacity: preferredCapacity,
|
|
11647
11542
|
timestamp: new Date().toISOString(),
|
|
11648
11543
|
});
|
|
@@ -11675,67 +11570,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
11675
11570
|
if (busMessage.senderId === this.connectorId) {
|
|
11676
11571
|
return;
|
|
11677
11572
|
}
|
|
11678
|
-
// Try to unwrap as transport frame
|
|
11679
|
-
const frame = unwrapTransportFrame(busMessage.payload);
|
|
11680
|
-
if (frame) {
|
|
11681
|
-
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
11682
|
-
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
11683
|
-
const dstMatches = frame.dst === this.localNodeId;
|
|
11684
|
-
if (dstMatches && srcMatches) {
|
|
11685
|
-
// Successfully received and filtered transport frame
|
|
11686
|
-
logger$10.debug('broadcast_channel_transport_frame_received', {
|
|
11687
|
-
channel: this.channelName,
|
|
11688
|
-
sender_id: busMessage.senderId,
|
|
11689
|
-
connector_id: this.connectorId,
|
|
11690
|
-
local_node_id: this.localNodeId,
|
|
11691
|
-
remote_node_id: this.remoteNodeId,
|
|
11692
|
-
frame_src: frame.src,
|
|
11693
|
-
frame_dst: frame.dst,
|
|
11694
|
-
payload_length: frame.payload.byteLength,
|
|
11695
|
-
});
|
|
11696
|
-
const unwrapped = frame.payload;
|
|
11697
|
-
if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
|
|
11698
|
-
return;
|
|
11699
|
-
}
|
|
11700
|
-
try {
|
|
11701
|
-
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
11702
|
-
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
11703
|
-
if (accepted) {
|
|
11704
|
-
return;
|
|
11705
|
-
}
|
|
11706
|
-
}
|
|
11707
|
-
this.inbox.enqueue(unwrapped);
|
|
11708
|
-
}
|
|
11709
|
-
catch (error) {
|
|
11710
|
-
if (error instanceof QueueFullError) {
|
|
11711
|
-
logger$10.warning('broadcast_channel_receive_queue_full', {
|
|
11712
|
-
channel: this.channelName,
|
|
11713
|
-
});
|
|
11714
|
-
}
|
|
11715
|
-
else {
|
|
11716
|
-
logger$10.error('broadcast_channel_receive_error', {
|
|
11717
|
-
channel: this.channelName,
|
|
11718
|
-
error: error instanceof Error ? error.message : String(error),
|
|
11719
|
-
});
|
|
11720
|
-
}
|
|
11721
|
-
}
|
|
11722
|
-
return;
|
|
11723
|
-
}
|
|
11724
|
-
else {
|
|
11725
|
-
// Frame filtered out by addressing rules
|
|
11726
|
-
logger$10.debug('broadcast_channel_transport_frame_filtered', {
|
|
11727
|
-
channel: this.channelName,
|
|
11728
|
-
connector_id: this.connectorId,
|
|
11729
|
-
local_node_id: this.localNodeId,
|
|
11730
|
-
remote_node_id: this.remoteNodeId,
|
|
11731
|
-
frame_src: frame.src,
|
|
11732
|
-
frame_dst: frame.dst,
|
|
11733
|
-
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
11734
|
-
});
|
|
11735
|
-
return;
|
|
11736
|
-
}
|
|
11737
|
-
}
|
|
11738
|
-
// Fall back to legacy format (no transport frame)
|
|
11739
11573
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
11740
11574
|
if (!payload) {
|
|
11741
11575
|
logger$10.debug('broadcast_channel_payload_rejected', {
|
|
@@ -11874,26 +11708,10 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
11874
11708
|
logger$10.debug('broadcast_channel_message_sending', {
|
|
11875
11709
|
channel: this.channelName,
|
|
11876
11710
|
sender_id: this.connectorId,
|
|
11877
|
-
|
|
11878
|
-
remote_node_id: this.remoteNodeId,
|
|
11879
|
-
});
|
|
11880
|
-
// Only use transport framing if both localNodeId and remoteNodeId are explicitly set
|
|
11881
|
-
// (not using default values). This ensures backwards compatibility.
|
|
11882
|
-
const useTransportFrame = this.localNodeId !== this.connectorId ||
|
|
11883
|
-
this.remoteNodeId !== '*';
|
|
11884
|
-
let payload;
|
|
11885
|
-
if (useTransportFrame) {
|
|
11886
|
-
// Wrap payload in transport frame
|
|
11887
|
-
const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
|
|
11888
|
-
payload = serializeTransportFrame(frame);
|
|
11889
|
-
}
|
|
11890
|
-
else {
|
|
11891
|
-
// Legacy format: send raw payload
|
|
11892
|
-
payload = data;
|
|
11893
|
-
}
|
|
11711
|
+
});
|
|
11894
11712
|
this.channel.postMessage({
|
|
11895
11713
|
senderId: this.connectorId,
|
|
11896
|
-
payload,
|
|
11714
|
+
payload: data,
|
|
11897
11715
|
});
|
|
11898
11716
|
}
|
|
11899
11717
|
async _transportReceive() {
|
|
@@ -12049,24 +11867,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
12049
11867
|
});
|
|
12050
11868
|
}
|
|
12051
11869
|
}
|
|
12052
|
-
/**
|
|
12053
|
-
* Update the remote node ID after learning it from NodeAttachAck
|
|
12054
|
-
* This allows upstream connectors to switch from wildcard to specific addressing
|
|
12055
|
-
*/
|
|
12056
|
-
updateRemoteNodeId(newRemoteNodeId) {
|
|
12057
|
-
if (typeof newRemoteNodeId !== 'string' || newRemoteNodeId.trim().length === 0) {
|
|
12058
|
-
throw new Error('Invalid remote node ID');
|
|
12059
|
-
}
|
|
12060
|
-
const oldValue = this.remoteNodeId;
|
|
12061
|
-
this.remoteNodeId = newRemoteNodeId.trim();
|
|
12062
|
-
logger$10.debug('broadcast_channel_connector_remote_node_id_updated', {
|
|
12063
|
-
channel: this.channelName,
|
|
12064
|
-
connector_id: this.connectorId,
|
|
12065
|
-
local_node_id: this.localNodeId,
|
|
12066
|
-
old_remote_node_id: oldValue,
|
|
12067
|
-
new_remote_node_id: this.remoteNodeId,
|
|
12068
|
-
});
|
|
12069
|
-
}
|
|
12070
11870
|
_trimSeenAcks(now) {
|
|
12071
11871
|
while (this.seenAckOrder.length > 0) {
|
|
12072
11872
|
const candidate = this.seenAckOrder[0];
|
|
@@ -12159,12 +11959,9 @@ function isBroadcastChannelConnectionGrant(candidate) {
|
|
|
12159
11959
|
record.inboxCapacity <= 0)) {
|
|
12160
11960
|
return false;
|
|
12161
11961
|
}
|
|
12162
|
-
if (record.
|
|
12163
|
-
(
|
|
12164
|
-
|
|
12165
|
-
}
|
|
12166
|
-
if (record.remoteNodeId !== undefined &&
|
|
12167
|
-
(typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
|
|
11962
|
+
if (record.initialWindow !== undefined &&
|
|
11963
|
+
(!Number.isFinite(record.initialWindow) ||
|
|
11964
|
+
record.initialWindow <= 0)) {
|
|
12168
11965
|
return false;
|
|
12169
11966
|
}
|
|
12170
11967
|
return true;
|
|
@@ -12200,19 +11997,14 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
|
|
|
12200
11997
|
}
|
|
12201
11998
|
result.inboxCapacity = Math.floor(inboxValue);
|
|
12202
11999
|
}
|
|
12203
|
-
const
|
|
12204
|
-
if (
|
|
12205
|
-
if (typeof
|
|
12206
|
-
|
|
12207
|
-
|
|
12208
|
-
|
|
12209
|
-
}
|
|
12210
|
-
const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
12211
|
-
if (remoteNodeIdValue !== undefined) {
|
|
12212
|
-
if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
|
|
12213
|
-
throw new TypeError('BroadcastChannelConnectionGrant "remoteNodeId" must be a non-empty string when provided');
|
|
12000
|
+
const windowValue = candidate.initialWindow ?? candidate['initial_window'];
|
|
12001
|
+
if (windowValue !== undefined) {
|
|
12002
|
+
if (typeof windowValue !== 'number' ||
|
|
12003
|
+
!Number.isFinite(windowValue) ||
|
|
12004
|
+
windowValue <= 0) {
|
|
12005
|
+
throw new TypeError('BroadcastChannelConnectionGrant "initialWindow" must be a positive number when provided');
|
|
12214
12006
|
}
|
|
12215
|
-
result.
|
|
12007
|
+
result.initialWindow = Math.floor(windowValue);
|
|
12216
12008
|
}
|
|
12217
12009
|
return result;
|
|
12218
12010
|
}
|
|
@@ -12227,11 +12019,8 @@ function broadcastChannelGrantToConnectorConfig(grant) {
|
|
|
12227
12019
|
if (normalized.inboxCapacity !== undefined) {
|
|
12228
12020
|
config.inboxCapacity = normalized.inboxCapacity;
|
|
12229
12021
|
}
|
|
12230
|
-
if (normalized.
|
|
12231
|
-
config.
|
|
12232
|
-
}
|
|
12233
|
-
if (normalized.remoteNodeId) {
|
|
12234
|
-
config.remoteNodeId = normalized.remoteNodeId;
|
|
12022
|
+
if (normalized.initialWindow !== undefined) {
|
|
12023
|
+
config.initialWindow = normalized.initialWindow;
|
|
12235
12024
|
}
|
|
12236
12025
|
return config;
|
|
12237
12026
|
}
|
|
@@ -12523,12 +12312,6 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
12523
12312
|
cryptoProvider.prepareForAttach(welcome.frame.systemId, welcome.frame.assignedPath, welcome.frame.acceptedLogicals ?? []);
|
|
12524
12313
|
}
|
|
12525
12314
|
await this.onWelcome(welcome.frame);
|
|
12526
|
-
// Inject node ID into grant for transport frame multiplexing
|
|
12527
|
-
// This ensures localNodeId matches the node's systemId for proper frame filtering
|
|
12528
|
-
grant.localNodeId = welcome.frame.systemId;
|
|
12529
|
-
if (welcome.frame.targetSystemId) {
|
|
12530
|
-
grant.remoteNodeId = welcome.frame.targetSystemId;
|
|
12531
|
-
}
|
|
12532
12315
|
const connector = await ConnectorFactory.createConnector(grant, {
|
|
12533
12316
|
systemId: welcome.frame.systemId,
|
|
12534
12317
|
});
|
|
@@ -14485,20 +14268,6 @@ class DefaultNodeAttachClient {
|
|
|
14485
14268
|
if (!targetSystemId) {
|
|
14486
14269
|
throw new Error('Target system ID must be set in NodeAttachAckFrame on success');
|
|
14487
14270
|
}
|
|
14488
|
-
// Update connector's remote node ID if it supports it (e.g., BroadcastChannelConnector, InPageConnector)
|
|
14489
|
-
// This allows upstream connectors to switch from wildcard '*' to specific node addressing
|
|
14490
|
-
const updatableConnector = connector;
|
|
14491
|
-
if (typeof updatableConnector.updateRemoteNodeId === 'function') {
|
|
14492
|
-
try {
|
|
14493
|
-
updatableConnector.updateRemoteNodeId(targetSystemId);
|
|
14494
|
-
}
|
|
14495
|
-
catch (error) {
|
|
14496
|
-
logger$Y.debug('connector_remote_node_id_update_failed', {
|
|
14497
|
-
target_system_id: targetSystemId,
|
|
14498
|
-
error: error instanceof Error ? error.message : String(error),
|
|
14499
|
-
});
|
|
14500
|
-
}
|
|
14501
|
-
}
|
|
14502
14271
|
try {
|
|
14503
14272
|
if (this.replicaStickinessManager) {
|
|
14504
14273
|
this.replicaStickinessManager.accept(ackFrame.stickiness ?? null);
|
|
@@ -21685,20 +21454,9 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
21685
21454
|
: DEFAULT_INBOX_CAPACITY$6;
|
|
21686
21455
|
this.inbox = new BoundedAsyncQueue(preferredCapacity);
|
|
21687
21456
|
this.connectorId = InPageConnector.generateConnectorId();
|
|
21688
|
-
// Set local and remote node IDs (defaults to connector ID for backwards compatibility)
|
|
21689
|
-
this.localNodeId =
|
|
21690
|
-
typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
|
|
21691
|
-
? config.localNodeId.trim()
|
|
21692
|
-
: this.connectorId;
|
|
21693
|
-
this.remoteNodeId =
|
|
21694
|
-
typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
|
|
21695
|
-
? config.remoteNodeId.trim()
|
|
21696
|
-
: '*'; // Accept from any remote if not specified
|
|
21697
21457
|
logger$J.debug('inpage_connector_initialized', {
|
|
21698
21458
|
channel: this.channelName,
|
|
21699
21459
|
connector_id: this.connectorId,
|
|
21700
|
-
local_node_id: this.localNodeId,
|
|
21701
|
-
remote_node_id: this.remoteNodeId,
|
|
21702
21460
|
});
|
|
21703
21461
|
this.onMsg = (event) => {
|
|
21704
21462
|
const messageEvent = event;
|
|
@@ -21732,64 +21490,6 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
21732
21490
|
if (busMessage.senderId === this.connectorId) {
|
|
21733
21491
|
return;
|
|
21734
21492
|
}
|
|
21735
|
-
// Try to unwrap as transport frame
|
|
21736
|
-
const frame = unwrapTransportFrame(busMessage.payload);
|
|
21737
|
-
if (frame) {
|
|
21738
|
-
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
21739
|
-
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
21740
|
-
const dstMatches = frame.dst === this.localNodeId;
|
|
21741
|
-
if (dstMatches && srcMatches) {
|
|
21742
|
-
// Successfully received and filtered transport frame
|
|
21743
|
-
logger$J.debug('inpage_transport_frame_received', {
|
|
21744
|
-
channel: this.channelName,
|
|
21745
|
-
sender_id: busMessage.senderId,
|
|
21746
|
-
connector_id: this.connectorId,
|
|
21747
|
-
local_node_id: this.localNodeId,
|
|
21748
|
-
remote_node_id: this.remoteNodeId,
|
|
21749
|
-
frame_src: frame.src,
|
|
21750
|
-
frame_dst: frame.dst,
|
|
21751
|
-
payload_length: frame.payload.byteLength,
|
|
21752
|
-
});
|
|
21753
|
-
const unwrapped = frame.payload;
|
|
21754
|
-
try {
|
|
21755
|
-
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
21756
|
-
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
21757
|
-
if (accepted) {
|
|
21758
|
-
return;
|
|
21759
|
-
}
|
|
21760
|
-
}
|
|
21761
|
-
this.inbox.enqueue(unwrapped);
|
|
21762
|
-
}
|
|
21763
|
-
catch (error) {
|
|
21764
|
-
if (error instanceof QueueFullError) {
|
|
21765
|
-
logger$J.warning('inpage_receive_queue_full', {
|
|
21766
|
-
channel: this.channelName,
|
|
21767
|
-
});
|
|
21768
|
-
}
|
|
21769
|
-
else {
|
|
21770
|
-
logger$J.error('inpage_receive_error', {
|
|
21771
|
-
channel: this.channelName,
|
|
21772
|
-
error: error instanceof Error ? error.message : String(error),
|
|
21773
|
-
});
|
|
21774
|
-
}
|
|
21775
|
-
}
|
|
21776
|
-
return;
|
|
21777
|
-
}
|
|
21778
|
-
else {
|
|
21779
|
-
// Frame filtered out by addressing rules
|
|
21780
|
-
logger$J.debug('inpage_transport_frame_filtered', {
|
|
21781
|
-
channel: this.channelName,
|
|
21782
|
-
connector_id: this.connectorId,
|
|
21783
|
-
local_node_id: this.localNodeId,
|
|
21784
|
-
remote_node_id: this.remoteNodeId,
|
|
21785
|
-
frame_src: frame.src,
|
|
21786
|
-
frame_dst: frame.dst,
|
|
21787
|
-
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
21788
|
-
});
|
|
21789
|
-
return;
|
|
21790
|
-
}
|
|
21791
|
-
}
|
|
21792
|
-
// Fall back to legacy format (no transport frame)
|
|
21793
21493
|
const payload = InPageConnector.coercePayload(busMessage.payload);
|
|
21794
21494
|
if (!payload) {
|
|
21795
21495
|
logger$J.debug('inpage_payload_rejected', {
|
|
@@ -21948,27 +21648,11 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
21948
21648
|
logger$J.debug('inpage_message_sending', {
|
|
21949
21649
|
channel: this.channelName,
|
|
21950
21650
|
sender_id: this.connectorId,
|
|
21951
|
-
|
|
21952
|
-
remote_node_id: this.remoteNodeId,
|
|
21953
|
-
});
|
|
21954
|
-
// Only use transport framing if both localNodeId and remoteNodeId are explicitly set
|
|
21955
|
-
// (not using default values). This ensures backwards compatibility.
|
|
21956
|
-
const useTransportFrame = this.localNodeId !== this.connectorId ||
|
|
21957
|
-
this.remoteNodeId !== '*';
|
|
21958
|
-
let payload;
|
|
21959
|
-
if (useTransportFrame) {
|
|
21960
|
-
// Wrap payload in transport frame
|
|
21961
|
-
const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
|
|
21962
|
-
payload = serializeTransportFrame(frame);
|
|
21963
|
-
}
|
|
21964
|
-
else {
|
|
21965
|
-
// Legacy format: send raw payload
|
|
21966
|
-
payload = data;
|
|
21967
|
-
}
|
|
21651
|
+
});
|
|
21968
21652
|
const event = new MessageEvent(this.channelName, {
|
|
21969
21653
|
data: {
|
|
21970
21654
|
senderId: this.connectorId,
|
|
21971
|
-
payload,
|
|
21655
|
+
payload: data,
|
|
21972
21656
|
},
|
|
21973
21657
|
});
|
|
21974
21658
|
getSharedBus$1().dispatchEvent(event);
|
|
@@ -21997,24 +21681,6 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
21997
21681
|
}
|
|
21998
21682
|
return rawOrEnvelope;
|
|
21999
21683
|
}
|
|
22000
|
-
/**
|
|
22001
|
-
* Update the remote node ID after learning it from NodeAttachAck
|
|
22002
|
-
* This allows upstream connectors to switch from wildcard to specific addressing
|
|
22003
|
-
*/
|
|
22004
|
-
updateRemoteNodeId(newRemoteNodeId) {
|
|
22005
|
-
if (typeof newRemoteNodeId !== 'string' || newRemoteNodeId.trim().length === 0) {
|
|
22006
|
-
throw new Error('Invalid remote node ID');
|
|
22007
|
-
}
|
|
22008
|
-
const oldValue = this.remoteNodeId;
|
|
22009
|
-
this.remoteNodeId = newRemoteNodeId.trim();
|
|
22010
|
-
logger$J.debug('inpage_connector_remote_node_id_updated', {
|
|
22011
|
-
channel: this.channelName,
|
|
22012
|
-
connector_id: this.connectorId,
|
|
22013
|
-
local_node_id: this.localNodeId,
|
|
22014
|
-
old_remote_node_id: oldValue,
|
|
22015
|
-
new_remote_node_id: this.remoteNodeId,
|
|
22016
|
-
});
|
|
22017
|
-
}
|
|
22018
21684
|
}
|
|
22019
21685
|
|
|
22020
21686
|
const RPC_REGISTRY = Symbol('naylence.rpc.registry');
|
|
@@ -29298,14 +28964,6 @@ function isInPageConnectionGrant(candidate) {
|
|
|
29298
28964
|
record.inboxCapacity <= 0)) {
|
|
29299
28965
|
return false;
|
|
29300
28966
|
}
|
|
29301
|
-
if (record.localNodeId !== undefined &&
|
|
29302
|
-
(typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
|
|
29303
|
-
return false;
|
|
29304
|
-
}
|
|
29305
|
-
if (record.remoteNodeId !== undefined &&
|
|
29306
|
-
(typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
|
|
29307
|
-
return false;
|
|
29308
|
-
}
|
|
29309
28967
|
return true;
|
|
29310
28968
|
}
|
|
29311
28969
|
function normalizeInPageConnectionGrant(candidate) {
|
|
@@ -29339,20 +28997,6 @@ function normalizeInPageConnectionGrant(candidate) {
|
|
|
29339
28997
|
}
|
|
29340
28998
|
result.inboxCapacity = Math.floor(inboxValue);
|
|
29341
28999
|
}
|
|
29342
|
-
const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
|
|
29343
|
-
if (localNodeIdValue !== undefined) {
|
|
29344
|
-
if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
|
|
29345
|
-
throw new TypeError('InPageConnectionGrant "localNodeId" must be a non-empty string when provided');
|
|
29346
|
-
}
|
|
29347
|
-
result.localNodeId = localNodeIdValue.trim();
|
|
29348
|
-
}
|
|
29349
|
-
const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
29350
|
-
if (remoteNodeIdValue !== undefined) {
|
|
29351
|
-
if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
|
|
29352
|
-
throw new TypeError('InPageConnectionGrant "remoteNodeId" must be a non-empty string when provided');
|
|
29353
|
-
}
|
|
29354
|
-
result.remoteNodeId = remoteNodeIdValue.trim();
|
|
29355
|
-
}
|
|
29356
29000
|
return result;
|
|
29357
29001
|
}
|
|
29358
29002
|
function inPageGrantToConnectorConfig(grant) {
|
|
@@ -29366,12 +29010,6 @@ function inPageGrantToConnectorConfig(grant) {
|
|
|
29366
29010
|
if (normalized.inboxCapacity !== undefined) {
|
|
29367
29011
|
config.inboxCapacity = normalized.inboxCapacity;
|
|
29368
29012
|
}
|
|
29369
|
-
if (normalized.localNodeId) {
|
|
29370
|
-
config.localNodeId = normalized.localNodeId;
|
|
29371
|
-
}
|
|
29372
|
-
if (normalized.remoteNodeId) {
|
|
29373
|
-
config.remoteNodeId = normalized.remoteNodeId;
|
|
29374
|
-
}
|
|
29375
29013
|
return config;
|
|
29376
29014
|
}
|
|
29377
29015
|
|
|
@@ -30639,8 +30277,6 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
30639
30277
|
type: INPAGE_CONNECTOR_TYPE,
|
|
30640
30278
|
channelName,
|
|
30641
30279
|
inboxCapacity,
|
|
30642
|
-
localNodeId: normalized.localNodeId,
|
|
30643
|
-
remoteNodeId: normalized.remoteNodeId,
|
|
30644
30280
|
};
|
|
30645
30281
|
const connector = new InPageConnector(connectorConfig, baseConfig);
|
|
30646
30282
|
if (options.authorization) {
|
|
@@ -30709,16 +30345,6 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
30709
30345
|
if (candidate.authorizationContext !== undefined) {
|
|
30710
30346
|
normalized.authorizationContext = candidate.authorizationContext;
|
|
30711
30347
|
}
|
|
30712
|
-
// Handle localNodeId
|
|
30713
|
-
const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
|
|
30714
|
-
if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
|
|
30715
|
-
normalized.localNodeId = localNodeId.trim();
|
|
30716
|
-
}
|
|
30717
|
-
// Handle remoteNodeId
|
|
30718
|
-
const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
30719
|
-
if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
|
|
30720
|
-
normalized.remoteNodeId = remoteNodeId.trim();
|
|
30721
|
-
}
|
|
30722
30348
|
normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$3;
|
|
30723
30349
|
normalized.inboxCapacity =
|
|
30724
30350
|
normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$3;
|
|
@@ -30769,8 +30395,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
30769
30395
|
type: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
|
|
30770
30396
|
channelName: connectorConfig.channelName,
|
|
30771
30397
|
inboxCapacity: connectorConfig.inboxCapacity,
|
|
30772
|
-
|
|
30773
|
-
remoteNodeId: connectorConfig.remoteNodeId,
|
|
30398
|
+
initialWindow: connectorConfig.initialWindow,
|
|
30774
30399
|
};
|
|
30775
30400
|
}
|
|
30776
30401
|
const config = {
|
|
@@ -30795,6 +30420,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
30795
30420
|
purpose: 'connection',
|
|
30796
30421
|
channelName: normalizedConfig.channelName,
|
|
30797
30422
|
inboxCapacity: normalizedConfig.inboxCapacity,
|
|
30423
|
+
initialWindow: normalizedConfig.initialWindow,
|
|
30798
30424
|
});
|
|
30799
30425
|
return grant;
|
|
30800
30426
|
}
|
|
@@ -30820,8 +30446,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
30820
30446
|
type: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
|
|
30821
30447
|
channelName,
|
|
30822
30448
|
inboxCapacity,
|
|
30823
|
-
localNodeId: normalized.localNodeId,
|
|
30824
|
-
remoteNodeId: normalized.remoteNodeId,
|
|
30825
30449
|
};
|
|
30826
30450
|
const connector = new BroadcastChannelConnector(connectorConfig, baseConfig);
|
|
30827
30451
|
if (options.authorization) {
|
|
@@ -30883,16 +30507,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
30883
30507
|
if (candidate.authorizationContext !== undefined) {
|
|
30884
30508
|
normalized.authorizationContext = candidate.authorizationContext;
|
|
30885
30509
|
}
|
|
30886
|
-
// Handle localNodeId
|
|
30887
|
-
const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
|
|
30888
|
-
if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
|
|
30889
|
-
normalized.localNodeId = localNodeId.trim();
|
|
30890
|
-
}
|
|
30891
|
-
// Handle remoteNodeId
|
|
30892
|
-
const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
30893
|
-
if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
|
|
30894
|
-
normalized.remoteNodeId = remoteNodeId.trim();
|
|
30895
|
-
}
|
|
30896
30510
|
normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$2;
|
|
30897
30511
|
normalized.inboxCapacity =
|
|
30898
30512
|
normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$2;
|
|
@@ -32377,7 +31991,6 @@ class InPageListener extends TransportListener {
|
|
|
32377
31991
|
this._busHandler = null;
|
|
32378
31992
|
this._senderRegistry = new Map();
|
|
32379
31993
|
this._systemToSender = new Map();
|
|
32380
|
-
this._flowIdToSender = new Map();
|
|
32381
31994
|
this._pendingAttachments = new Map();
|
|
32382
31995
|
ensureBrowserEnvironment$1();
|
|
32383
31996
|
const channelCandidate = options?.channelName;
|
|
@@ -32444,7 +32057,6 @@ class InPageListener extends TransportListener {
|
|
|
32444
32057
|
this._unregisterBusListener();
|
|
32445
32058
|
this._senderRegistry.clear();
|
|
32446
32059
|
this._systemToSender.clear();
|
|
32447
|
-
this._flowIdToSender.clear();
|
|
32448
32060
|
this._pendingAttachments.clear();
|
|
32449
32061
|
logger$o.debug('inpage_listener_stopped', {
|
|
32450
32062
|
channel: this._channelName,
|
|
@@ -32498,25 +32110,10 @@ class InPageListener extends TransportListener {
|
|
|
32498
32110
|
await this._handleAttachFrame(senderId, envelope);
|
|
32499
32111
|
return;
|
|
32500
32112
|
}
|
|
32501
|
-
|
|
32502
|
-
let entry = this._senderRegistry.get(senderId);
|
|
32503
|
-
// If not found and we have a flowId, try to route based on flow
|
|
32504
|
-
if (!entry && envelope.flowId) {
|
|
32505
|
-
const originalSenderId = this._flowIdToSender.get(envelope.flowId);
|
|
32506
|
-
if (originalSenderId) {
|
|
32507
|
-
entry = this._senderRegistry.get(originalSenderId);
|
|
32508
|
-
logger$o.debug('inpage_listener_routed_by_flow_id', {
|
|
32509
|
-
sender_id: senderId,
|
|
32510
|
-
original_sender_id: originalSenderId,
|
|
32511
|
-
flow_id: envelope.flowId,
|
|
32512
|
-
frame_type: envelope.frame?.type ?? 'unknown',
|
|
32513
|
-
});
|
|
32514
|
-
}
|
|
32515
|
-
}
|
|
32113
|
+
const entry = this._senderRegistry.get(senderId);
|
|
32516
32114
|
if (!entry) {
|
|
32517
32115
|
logger$o.debug('inpage_listener_no_connector_for_sender', {
|
|
32518
32116
|
sender_id: senderId,
|
|
32519
|
-
flow_id: envelope.flowId,
|
|
32520
32117
|
frame_type: envelope.frame?.type ?? 'unknown',
|
|
32521
32118
|
});
|
|
32522
32119
|
return;
|
|
@@ -32593,15 +32190,6 @@ class InPageListener extends TransportListener {
|
|
|
32593
32190
|
}
|
|
32594
32191
|
this._senderRegistry.set(senderId, entry);
|
|
32595
32192
|
this._systemToSender.set(entry.systemId, senderId);
|
|
32596
|
-
// Track the flowId if present so we can route responses back
|
|
32597
|
-
if (envelope.flowId) {
|
|
32598
|
-
this._flowIdToSender.set(envelope.flowId, senderId);
|
|
32599
|
-
logger$o.debug('inpage_listener_registered_flow_id', {
|
|
32600
|
-
sender_id: senderId,
|
|
32601
|
-
system_id: entry.systemId,
|
|
32602
|
-
flow_id: envelope.flowId,
|
|
32603
|
-
});
|
|
32604
|
-
}
|
|
32605
32193
|
await this._deliverEnvelope(entry, envelope);
|
|
32606
32194
|
}
|
|
32607
32195
|
async _createConnectorForAttach(params) {
|
|
@@ -32649,7 +32237,7 @@ class InPageListener extends TransportListener {
|
|
|
32649
32237
|
origin_type: originType,
|
|
32650
32238
|
connector_type: connector.constructor?.name ?? 'unknown',
|
|
32651
32239
|
});
|
|
32652
|
-
return { connector, systemId, originType
|
|
32240
|
+
return { connector, systemId, originType };
|
|
32653
32241
|
}
|
|
32654
32242
|
catch (error) {
|
|
32655
32243
|
logger$o.error('inpage_listener_connector_creation_failed', {
|
|
@@ -32703,12 +32291,6 @@ class InPageListener extends TransportListener {
|
|
|
32703
32291
|
if (this._systemToSender.get(systemId) === senderId) {
|
|
32704
32292
|
this._systemToSender.delete(systemId);
|
|
32705
32293
|
}
|
|
32706
|
-
// Clean up flowId mappings for this sender
|
|
32707
|
-
for (const [flowId, sid] of this._flowIdToSender.entries()) {
|
|
32708
|
-
if (sid === senderId) {
|
|
32709
|
-
this._flowIdToSender.delete(flowId);
|
|
32710
|
-
}
|
|
32711
|
-
}
|
|
32712
32294
|
})
|
|
32713
32295
|
.catch((error) => {
|
|
32714
32296
|
logger$o.debug('inpage_listener_wait_until_closed_failed', {
|
|
@@ -32720,24 +32302,9 @@ class InPageListener extends TransportListener {
|
|
|
32720
32302
|
if (this._systemToSender.get(systemId) === senderId) {
|
|
32721
32303
|
this._systemToSender.delete(systemId);
|
|
32722
32304
|
}
|
|
32723
|
-
// Clean up flowId mappings for this sender
|
|
32724
|
-
for (const [flowId, sid] of this._flowIdToSender.entries()) {
|
|
32725
|
-
if (sid === senderId) {
|
|
32726
|
-
this._flowIdToSender.delete(flowId);
|
|
32727
|
-
}
|
|
32728
|
-
}
|
|
32729
32305
|
});
|
|
32730
32306
|
}
|
|
32731
32307
|
async _deliverEnvelope(entry, envelope) {
|
|
32732
|
-
// Track flowId for routing responses back
|
|
32733
|
-
if (envelope.flowId && !this._flowIdToSender.has(envelope.flowId)) {
|
|
32734
|
-
this._flowIdToSender.set(envelope.flowId, entry.senderId);
|
|
32735
|
-
logger$o.debug('inpage_listener_registered_flow_id_on_delivery', {
|
|
32736
|
-
sender_id: entry.senderId,
|
|
32737
|
-
system_id: entry.systemId,
|
|
32738
|
-
flow_id: envelope.flowId,
|
|
32739
|
-
});
|
|
32740
|
-
}
|
|
32741
32308
|
const message = this._buildChannelMessage({
|
|
32742
32309
|
envelope,
|
|
32743
32310
|
connector: entry.connector,
|
|
@@ -32916,18 +32483,13 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
32916
32483
|
});
|
|
32917
32484
|
}
|
|
32918
32485
|
asCallbackGrant() {
|
|
32919
|
-
|
|
32486
|
+
return this.withLegacySnakeCaseKeys({
|
|
32920
32487
|
type: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
|
|
32921
32488
|
connectorType: BROADCAST_CHANNEL_CONNECTOR_TYPE$1,
|
|
32922
32489
|
connectionGrantType: BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE,
|
|
32923
32490
|
channelName: this._channelName,
|
|
32924
32491
|
inboxCapacity: this._inboxCapacity,
|
|
32925
|
-
};
|
|
32926
|
-
// Include localNodeId for transport frame multiplexing if node is available
|
|
32927
|
-
if (this._routingNode) {
|
|
32928
|
-
grant.localNodeId = this._routingNode.id;
|
|
32929
|
-
}
|
|
32930
|
-
return this.withLegacySnakeCaseKeys(grant);
|
|
32492
|
+
});
|
|
32931
32493
|
}
|
|
32932
32494
|
_registerChannelListener() {
|
|
32933
32495
|
if (this._channelHandler) {
|
|
@@ -32987,54 +32549,23 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
32987
32549
|
if (typeof senderId !== 'string' || senderId.length === 0) {
|
|
32988
32550
|
return null;
|
|
32989
32551
|
}
|
|
32990
|
-
|
|
32991
|
-
|
|
32992
|
-
|
|
32993
|
-
|
|
32994
|
-
|
|
32995
|
-
|
|
32996
|
-
// Apply listener's filtering policy: accept frames addressed to us OR with wildcard destination
|
|
32997
|
-
// Wildcard is needed because downstream nodes don't know the sentinel's ID during initial attach
|
|
32998
|
-
const isAddressedToUs = frame.dst === this._routingNode.id || frame.dst === '*';
|
|
32999
|
-
if (isAddressedToUs) {
|
|
33000
|
-
envelopePayload = frame.payload;
|
|
33001
|
-
logger$n.debug('broadcast_channel_listener_unwrapped_transport_frame', {
|
|
33002
|
-
sender_id: senderId,
|
|
33003
|
-
src: frame.src,
|
|
33004
|
-
dst: frame.dst,
|
|
33005
|
-
});
|
|
33006
|
-
}
|
|
33007
|
-
else {
|
|
33008
|
-
// Frame addressed to a different node, ignore it
|
|
33009
|
-
logger$n.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
|
|
33010
|
-
sender_id: senderId,
|
|
33011
|
-
dst: frame.dst,
|
|
33012
|
-
expected: this._routingNode.id,
|
|
33013
|
-
});
|
|
33014
|
-
return null;
|
|
33015
|
-
}
|
|
33016
|
-
}
|
|
33017
|
-
}
|
|
33018
|
-
// If not a transport frame, try to coerce as legacy format
|
|
33019
|
-
if (!envelopePayload) {
|
|
33020
|
-
envelopePayload = coercePayload(record.payload);
|
|
33021
|
-
if (!envelopePayload) {
|
|
33022
|
-
logger$n.debug('broadcast_channel_listener_ignored_event_without_payload', {
|
|
33023
|
-
sender_id: senderId,
|
|
33024
|
-
});
|
|
33025
|
-
return null;
|
|
33026
|
-
}
|
|
32552
|
+
const payload = coercePayload(record.payload);
|
|
32553
|
+
if (!payload) {
|
|
32554
|
+
logger$n.debug('broadcast_channel_listener_ignored_event_without_payload', {
|
|
32555
|
+
sender_id: senderId,
|
|
32556
|
+
});
|
|
32557
|
+
return null;
|
|
33027
32558
|
}
|
|
33028
32559
|
let envelope;
|
|
33029
32560
|
try {
|
|
33030
|
-
const decoded = new TextDecoder().decode(
|
|
32561
|
+
const decoded = new TextDecoder().decode(payload);
|
|
33031
32562
|
const parsed = JSON.parse(decoded);
|
|
33032
32563
|
envelope = deserializeEnvelope(parsed);
|
|
33033
32564
|
}
|
|
33034
32565
|
catch (error) {
|
|
33035
32566
|
const decoded = (() => {
|
|
33036
32567
|
try {
|
|
33037
|
-
return new TextDecoder().decode(
|
|
32568
|
+
return new TextDecoder().decode(payload);
|
|
33038
32569
|
}
|
|
33039
32570
|
catch {
|
|
33040
32571
|
return null;
|
|
@@ -33154,20 +32685,6 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
33154
32685
|
inboxCapacity: this._inboxCapacity,
|
|
33155
32686
|
};
|
|
33156
32687
|
}
|
|
33157
|
-
// Automatically configure transport frame multiplexing:
|
|
33158
|
-
// Use node IDs (not connector IDs) for node-to-node targeting
|
|
33159
|
-
const broadcastConfig = connectorConfig;
|
|
33160
|
-
// Always force localNodeId to be this listener's node ID
|
|
33161
|
-
// This ensures the sentinel sets localNodeId=sentinel, not the child's ID
|
|
33162
|
-
broadcastConfig.localNodeId = routingNode.id;
|
|
33163
|
-
// Always force remoteNodeId to be the attaching child's system ID
|
|
33164
|
-
broadcastConfig.remoteNodeId = systemId;
|
|
33165
|
-
logger$n.debug('broadcast_channel_listener_configured_node_ids', {
|
|
33166
|
-
sender_id: params.senderId,
|
|
33167
|
-
system_id: systemId,
|
|
33168
|
-
local_node_id: broadcastConfig.localNodeId,
|
|
33169
|
-
remote_node_id: broadcastConfig.remoteNodeId,
|
|
33170
|
-
});
|
|
33171
32688
|
try {
|
|
33172
32689
|
const connector = await routingNode.createOriginConnector({
|
|
33173
32690
|
originType,
|
|
@@ -33237,21 +32754,6 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
33237
32754
|
inboxCandidate > 0) {
|
|
33238
32755
|
config.inboxCapacity = Math.floor(inboxCandidate);
|
|
33239
32756
|
}
|
|
33240
|
-
// Extract transport frame multiplexing node IDs
|
|
33241
|
-
const localNodeIdCandidate = candidate.localNodeId ?? candidate['local_node_id'];
|
|
33242
|
-
if (typeof localNodeIdCandidate === 'string' && localNodeIdCandidate.trim().length > 0) {
|
|
33243
|
-
config.localNodeId = localNodeIdCandidate.trim();
|
|
33244
|
-
logger$n.debug('broadcast_channel_listener_extracted_local_node_id', {
|
|
33245
|
-
local_node_id: config.localNodeId,
|
|
33246
|
-
});
|
|
33247
|
-
}
|
|
33248
|
-
const remoteNodeIdCandidate = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
33249
|
-
if (typeof remoteNodeIdCandidate === 'string' && remoteNodeIdCandidate.trim().length > 0) {
|
|
33250
|
-
config.remoteNodeId = remoteNodeIdCandidate.trim();
|
|
33251
|
-
logger$n.debug('broadcast_channel_listener_extracted_remote_node_id', {
|
|
33252
|
-
remote_node_id: config.remoteNodeId,
|
|
33253
|
-
});
|
|
33254
|
-
}
|
|
33255
32757
|
return config;
|
|
33256
32758
|
}
|
|
33257
32759
|
_monitorConnectorLifecycle(senderId, systemId, connector) {
|