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