@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/browser/index.mjs
CHANGED
|
@@ -96,12 +96,12 @@ installProcessEnvShim();
|
|
|
96
96
|
// --- END ENV SHIM ---
|
|
97
97
|
|
|
98
98
|
// This file is auto-generated during build - do not edit manually
|
|
99
|
-
// Generated from package.json version: 0.3.5-test.
|
|
99
|
+
// Generated from package.json version: 0.3.5-test.954
|
|
100
100
|
/**
|
|
101
101
|
* The package version, injected at build time.
|
|
102
102
|
* @internal
|
|
103
103
|
*/
|
|
104
|
-
const VERSION = '0.3.5-test.
|
|
104
|
+
const VERSION = '0.3.5-test.954';
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -9816,84 +9816,6 @@ class BoundedAsyncQueue {
|
|
|
9816
9816
|
}
|
|
9817
9817
|
}
|
|
9818
9818
|
|
|
9819
|
-
/**
|
|
9820
|
-
* Transport frame layer for multiplexing logical links on physical channels.
|
|
9821
|
-
*
|
|
9822
|
-
* This lightweight framing layer wraps raw FAME payloads to enable multiple
|
|
9823
|
-
* logical connections over a single physical channel (BroadcastChannel or InPage bus).
|
|
9824
|
-
*
|
|
9825
|
-
* The transport frame does NOT modify FAME envelopes - it only wraps the raw
|
|
9826
|
-
* Uint8Array payload at the connector level.
|
|
9827
|
-
*/
|
|
9828
|
-
/**
|
|
9829
|
-
* Transport frame version for future compatibility
|
|
9830
|
-
*/
|
|
9831
|
-
const TRANSPORT_FRAME_VERSION = 1;
|
|
9832
|
-
/**
|
|
9833
|
-
* Wrap a raw payload in a transport frame
|
|
9834
|
-
*
|
|
9835
|
-
* @param payload - Raw FAME envelope bytes
|
|
9836
|
-
* @param srcNodeId - Local node ID (this connector)
|
|
9837
|
-
* @param dstNodeId - Remote node ID (target connector)
|
|
9838
|
-
* @returns Transport frame ready for transmission
|
|
9839
|
-
*/
|
|
9840
|
-
function wrapTransportFrame(payload, srcNodeId, dstNodeId) {
|
|
9841
|
-
return {
|
|
9842
|
-
v: TRANSPORT_FRAME_VERSION,
|
|
9843
|
-
src: srcNodeId,
|
|
9844
|
-
dst: dstNodeId,
|
|
9845
|
-
payload,
|
|
9846
|
-
};
|
|
9847
|
-
}
|
|
9848
|
-
/**
|
|
9849
|
-
* Serialize a transport frame for transmission over the bus
|
|
9850
|
-
*
|
|
9851
|
-
* @param frame - Transport frame to serialize
|
|
9852
|
-
* @returns Serialized frame data ready for postMessage/dispatchEvent
|
|
9853
|
-
*/
|
|
9854
|
-
function serializeTransportFrame(frame) {
|
|
9855
|
-
// Convert Uint8Array to regular array for JSON serialization
|
|
9856
|
-
const serializable = {
|
|
9857
|
-
v: frame.v,
|
|
9858
|
-
src: frame.src,
|
|
9859
|
-
dst: frame.dst,
|
|
9860
|
-
payload: Array.from(frame.payload),
|
|
9861
|
-
};
|
|
9862
|
-
return serializable;
|
|
9863
|
-
}
|
|
9864
|
-
/**
|
|
9865
|
-
* Unwrap a transport frame (pure deserializer - no filtering)
|
|
9866
|
-
*
|
|
9867
|
-
* @param raw - Raw data from the bus
|
|
9868
|
-
* @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
|
|
9869
|
-
*/
|
|
9870
|
-
function unwrapTransportFrame(raw) {
|
|
9871
|
-
// Validate basic structure
|
|
9872
|
-
if (!raw || typeof raw !== 'object') {
|
|
9873
|
-
return null;
|
|
9874
|
-
}
|
|
9875
|
-
const frame = raw;
|
|
9876
|
-
// Check version
|
|
9877
|
-
if (frame.v !== TRANSPORT_FRAME_VERSION) {
|
|
9878
|
-
return null;
|
|
9879
|
-
}
|
|
9880
|
-
// Check src and dst
|
|
9881
|
-
if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
|
|
9882
|
-
return null;
|
|
9883
|
-
}
|
|
9884
|
-
// Extract payload
|
|
9885
|
-
if (!frame.payload || !Array.isArray(frame.payload)) {
|
|
9886
|
-
return null;
|
|
9887
|
-
}
|
|
9888
|
-
// Convert array back to Uint8Array and return full frame
|
|
9889
|
-
return {
|
|
9890
|
-
v: frame.v,
|
|
9891
|
-
src: frame.src,
|
|
9892
|
-
dst: frame.dst,
|
|
9893
|
-
payload: Uint8Array.from(frame.payload),
|
|
9894
|
-
};
|
|
9895
|
-
}
|
|
9896
|
-
|
|
9897
9819
|
const logger$_ = getLogger('naylence.fame.connector.broadcast_channel_connector');
|
|
9898
9820
|
const BROADCAST_CHANNEL_CONNECTOR_TYPE = 'broadcast-channel-connector';
|
|
9899
9821
|
const DEFAULT_CHANNEL$7 = 'naylence-fabric';
|
|
@@ -9959,20 +9881,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9959
9881
|
this.inbox = new BoundedAsyncQueue(preferredCapacity);
|
|
9960
9882
|
this.connectorId = BroadcastChannelConnector.generateConnectorId();
|
|
9961
9883
|
this.channel = new BroadcastChannel(this.channelName);
|
|
9962
|
-
// Set local and remote node IDs (defaults to connector ID for backwards compatibility)
|
|
9963
|
-
this.localNodeId =
|
|
9964
|
-
typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
|
|
9965
|
-
? config.localNodeId.trim()
|
|
9966
|
-
: this.connectorId;
|
|
9967
|
-
this.remoteNodeId =
|
|
9968
|
-
typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
|
|
9969
|
-
? config.remoteNodeId.trim()
|
|
9970
|
-
: '*'; // Accept from any remote if not specified
|
|
9971
9884
|
logger$_.debug('broadcast_channel_connector_created', {
|
|
9972
9885
|
channel: this.channelName,
|
|
9973
9886
|
connector_id: this.connectorId,
|
|
9974
|
-
local_node_id: this.localNodeId,
|
|
9975
|
-
remote_node_id: this.remoteNodeId,
|
|
9976
9887
|
inbox_capacity: preferredCapacity,
|
|
9977
9888
|
timestamp: new Date().toISOString(),
|
|
9978
9889
|
});
|
|
@@ -10005,67 +9916,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10005
9916
|
if (busMessage.senderId === this.connectorId) {
|
|
10006
9917
|
return;
|
|
10007
9918
|
}
|
|
10008
|
-
// Try to unwrap as transport frame
|
|
10009
|
-
const frame = unwrapTransportFrame(busMessage.payload);
|
|
10010
|
-
if (frame) {
|
|
10011
|
-
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
10012
|
-
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
10013
|
-
const dstMatches = frame.dst === this.localNodeId;
|
|
10014
|
-
if (dstMatches && srcMatches) {
|
|
10015
|
-
// Successfully received and filtered transport frame
|
|
10016
|
-
logger$_.debug('broadcast_channel_transport_frame_received', {
|
|
10017
|
-
channel: this.channelName,
|
|
10018
|
-
sender_id: busMessage.senderId,
|
|
10019
|
-
connector_id: this.connectorId,
|
|
10020
|
-
local_node_id: this.localNodeId,
|
|
10021
|
-
remote_node_id: this.remoteNodeId,
|
|
10022
|
-
frame_src: frame.src,
|
|
10023
|
-
frame_dst: frame.dst,
|
|
10024
|
-
payload_length: frame.payload.byteLength,
|
|
10025
|
-
});
|
|
10026
|
-
const unwrapped = frame.payload;
|
|
10027
|
-
if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
|
|
10028
|
-
return;
|
|
10029
|
-
}
|
|
10030
|
-
try {
|
|
10031
|
-
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
10032
|
-
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
10033
|
-
if (accepted) {
|
|
10034
|
-
return;
|
|
10035
|
-
}
|
|
10036
|
-
}
|
|
10037
|
-
this.inbox.enqueue(unwrapped);
|
|
10038
|
-
}
|
|
10039
|
-
catch (error) {
|
|
10040
|
-
if (error instanceof QueueFullError) {
|
|
10041
|
-
logger$_.warning('broadcast_channel_receive_queue_full', {
|
|
10042
|
-
channel: this.channelName,
|
|
10043
|
-
});
|
|
10044
|
-
}
|
|
10045
|
-
else {
|
|
10046
|
-
logger$_.error('broadcast_channel_receive_error', {
|
|
10047
|
-
channel: this.channelName,
|
|
10048
|
-
error: error instanceof Error ? error.message : String(error),
|
|
10049
|
-
});
|
|
10050
|
-
}
|
|
10051
|
-
}
|
|
10052
|
-
return;
|
|
10053
|
-
}
|
|
10054
|
-
else {
|
|
10055
|
-
// Frame filtered out by addressing rules
|
|
10056
|
-
logger$_.debug('broadcast_channel_transport_frame_filtered', {
|
|
10057
|
-
channel: this.channelName,
|
|
10058
|
-
connector_id: this.connectorId,
|
|
10059
|
-
local_node_id: this.localNodeId,
|
|
10060
|
-
remote_node_id: this.remoteNodeId,
|
|
10061
|
-
frame_src: frame.src,
|
|
10062
|
-
frame_dst: frame.dst,
|
|
10063
|
-
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
10064
|
-
});
|
|
10065
|
-
return;
|
|
10066
|
-
}
|
|
10067
|
-
}
|
|
10068
|
-
// Fall back to legacy format (no transport frame)
|
|
10069
9919
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
10070
9920
|
if (!payload) {
|
|
10071
9921
|
logger$_.debug('broadcast_channel_payload_rejected', {
|
|
@@ -10204,26 +10054,10 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10204
10054
|
logger$_.debug('broadcast_channel_message_sending', {
|
|
10205
10055
|
channel: this.channelName,
|
|
10206
10056
|
sender_id: this.connectorId,
|
|
10207
|
-
|
|
10208
|
-
remote_node_id: this.remoteNodeId,
|
|
10209
|
-
});
|
|
10210
|
-
// Only use transport framing if both localNodeId and remoteNodeId are explicitly set
|
|
10211
|
-
// (not using default values). This ensures backwards compatibility.
|
|
10212
|
-
const useTransportFrame = this.localNodeId !== this.connectorId ||
|
|
10213
|
-
this.remoteNodeId !== '*';
|
|
10214
|
-
let payload;
|
|
10215
|
-
if (useTransportFrame) {
|
|
10216
|
-
// Wrap payload in transport frame
|
|
10217
|
-
const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
|
|
10218
|
-
payload = serializeTransportFrame(frame);
|
|
10219
|
-
}
|
|
10220
|
-
else {
|
|
10221
|
-
// Legacy format: send raw payload
|
|
10222
|
-
payload = data;
|
|
10223
|
-
}
|
|
10057
|
+
});
|
|
10224
10058
|
this.channel.postMessage({
|
|
10225
10059
|
senderId: this.connectorId,
|
|
10226
|
-
payload,
|
|
10060
|
+
payload: data,
|
|
10227
10061
|
});
|
|
10228
10062
|
}
|
|
10229
10063
|
async _transportReceive() {
|
|
@@ -10379,24 +10213,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10379
10213
|
});
|
|
10380
10214
|
}
|
|
10381
10215
|
}
|
|
10382
|
-
/**
|
|
10383
|
-
* Update the remote node ID after learning it from NodeAttachAck
|
|
10384
|
-
* This allows upstream connectors to switch from wildcard to specific addressing
|
|
10385
|
-
*/
|
|
10386
|
-
updateRemoteNodeId(newRemoteNodeId) {
|
|
10387
|
-
if (typeof newRemoteNodeId !== 'string' || newRemoteNodeId.trim().length === 0) {
|
|
10388
|
-
throw new Error('Invalid remote node ID');
|
|
10389
|
-
}
|
|
10390
|
-
const oldValue = this.remoteNodeId;
|
|
10391
|
-
this.remoteNodeId = newRemoteNodeId.trim();
|
|
10392
|
-
logger$_.debug('broadcast_channel_connector_remote_node_id_updated', {
|
|
10393
|
-
channel: this.channelName,
|
|
10394
|
-
connector_id: this.connectorId,
|
|
10395
|
-
local_node_id: this.localNodeId,
|
|
10396
|
-
old_remote_node_id: oldValue,
|
|
10397
|
-
new_remote_node_id: this.remoteNodeId,
|
|
10398
|
-
});
|
|
10399
|
-
}
|
|
10400
10216
|
_trimSeenAcks(now) {
|
|
10401
10217
|
while (this.seenAckOrder.length > 0) {
|
|
10402
10218
|
const candidate = this.seenAckOrder[0];
|
|
@@ -10534,12 +10350,9 @@ function isBroadcastChannelConnectionGrant(candidate) {
|
|
|
10534
10350
|
record.inboxCapacity <= 0)) {
|
|
10535
10351
|
return false;
|
|
10536
10352
|
}
|
|
10537
|
-
if (record.
|
|
10538
|
-
(
|
|
10539
|
-
|
|
10540
|
-
}
|
|
10541
|
-
if (record.remoteNodeId !== undefined &&
|
|
10542
|
-
(typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
|
|
10353
|
+
if (record.initialWindow !== undefined &&
|
|
10354
|
+
(!Number.isFinite(record.initialWindow) ||
|
|
10355
|
+
record.initialWindow <= 0)) {
|
|
10543
10356
|
return false;
|
|
10544
10357
|
}
|
|
10545
10358
|
return true;
|
|
@@ -10575,19 +10388,14 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
|
|
|
10575
10388
|
}
|
|
10576
10389
|
result.inboxCapacity = Math.floor(inboxValue);
|
|
10577
10390
|
}
|
|
10578
|
-
const
|
|
10579
|
-
if (
|
|
10580
|
-
if (typeof
|
|
10581
|
-
|
|
10391
|
+
const windowValue = candidate.initialWindow ?? candidate['initial_window'];
|
|
10392
|
+
if (windowValue !== undefined) {
|
|
10393
|
+
if (typeof windowValue !== 'number' ||
|
|
10394
|
+
!Number.isFinite(windowValue) ||
|
|
10395
|
+
windowValue <= 0) {
|
|
10396
|
+
throw new TypeError('BroadcastChannelConnectionGrant "initialWindow" must be a positive number when provided');
|
|
10582
10397
|
}
|
|
10583
|
-
result.
|
|
10584
|
-
}
|
|
10585
|
-
const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
10586
|
-
if (remoteNodeIdValue !== undefined) {
|
|
10587
|
-
if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
|
|
10588
|
-
throw new TypeError('BroadcastChannelConnectionGrant "remoteNodeId" must be a non-empty string when provided');
|
|
10589
|
-
}
|
|
10590
|
-
result.remoteNodeId = remoteNodeIdValue.trim();
|
|
10398
|
+
result.initialWindow = Math.floor(windowValue);
|
|
10591
10399
|
}
|
|
10592
10400
|
return result;
|
|
10593
10401
|
}
|
|
@@ -10602,11 +10410,8 @@ function broadcastChannelGrantToConnectorConfig(grant) {
|
|
|
10602
10410
|
if (normalized.inboxCapacity !== undefined) {
|
|
10603
10411
|
config.inboxCapacity = normalized.inboxCapacity;
|
|
10604
10412
|
}
|
|
10605
|
-
if (normalized.
|
|
10606
|
-
config.
|
|
10607
|
-
}
|
|
10608
|
-
if (normalized.remoteNodeId) {
|
|
10609
|
-
config.remoteNodeId = normalized.remoteNodeId;
|
|
10413
|
+
if (normalized.initialWindow !== undefined) {
|
|
10414
|
+
config.initialWindow = normalized.initialWindow;
|
|
10610
10415
|
}
|
|
10611
10416
|
return config;
|
|
10612
10417
|
}
|
|
@@ -10898,12 +10703,6 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10898
10703
|
cryptoProvider.prepareForAttach(welcome.frame.systemId, welcome.frame.assignedPath, welcome.frame.acceptedLogicals ?? []);
|
|
10899
10704
|
}
|
|
10900
10705
|
await this.onWelcome(welcome.frame);
|
|
10901
|
-
// Inject node ID into grant for transport frame multiplexing
|
|
10902
|
-
// This ensures localNodeId matches the node's systemId for proper frame filtering
|
|
10903
|
-
grant.localNodeId = welcome.frame.systemId;
|
|
10904
|
-
if (welcome.frame.targetSystemId) {
|
|
10905
|
-
grant.remoteNodeId = welcome.frame.targetSystemId;
|
|
10906
|
-
}
|
|
10907
10706
|
const connector = await ConnectorFactory.createConnector(grant, {
|
|
10908
10707
|
systemId: welcome.frame.systemId,
|
|
10909
10708
|
});
|
|
@@ -12860,20 +12659,6 @@ class DefaultNodeAttachClient {
|
|
|
12860
12659
|
if (!targetSystemId) {
|
|
12861
12660
|
throw new Error('Target system ID must be set in NodeAttachAckFrame on success');
|
|
12862
12661
|
}
|
|
12863
|
-
// Update connector's remote node ID if it supports it (e.g., BroadcastChannelConnector, InPageConnector)
|
|
12864
|
-
// This allows upstream connectors to switch from wildcard '*' to specific node addressing
|
|
12865
|
-
const updatableConnector = connector;
|
|
12866
|
-
if (typeof updatableConnector.updateRemoteNodeId === 'function') {
|
|
12867
|
-
try {
|
|
12868
|
-
updatableConnector.updateRemoteNodeId(targetSystemId);
|
|
12869
|
-
}
|
|
12870
|
-
catch (error) {
|
|
12871
|
-
logger$W.debug('connector_remote_node_id_update_failed', {
|
|
12872
|
-
target_system_id: targetSystemId,
|
|
12873
|
-
error: error instanceof Error ? error.message : String(error),
|
|
12874
|
-
});
|
|
12875
|
-
}
|
|
12876
|
-
}
|
|
12877
12662
|
try {
|
|
12878
12663
|
if (this.replicaStickinessManager) {
|
|
12879
12664
|
this.replicaStickinessManager.accept(ackFrame.stickiness ?? null);
|
|
@@ -20574,20 +20359,9 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20574
20359
|
: DEFAULT_INBOX_CAPACITY$6;
|
|
20575
20360
|
this.inbox = new BoundedAsyncQueue(preferredCapacity);
|
|
20576
20361
|
this.connectorId = InPageConnector.generateConnectorId();
|
|
20577
|
-
// Set local and remote node IDs (defaults to connector ID for backwards compatibility)
|
|
20578
|
-
this.localNodeId =
|
|
20579
|
-
typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
|
|
20580
|
-
? config.localNodeId.trim()
|
|
20581
|
-
: this.connectorId;
|
|
20582
|
-
this.remoteNodeId =
|
|
20583
|
-
typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
|
|
20584
|
-
? config.remoteNodeId.trim()
|
|
20585
|
-
: '*'; // Accept from any remote if not specified
|
|
20586
20362
|
logger$G.debug('inpage_connector_initialized', {
|
|
20587
20363
|
channel: this.channelName,
|
|
20588
20364
|
connector_id: this.connectorId,
|
|
20589
|
-
local_node_id: this.localNodeId,
|
|
20590
|
-
remote_node_id: this.remoteNodeId,
|
|
20591
20365
|
});
|
|
20592
20366
|
this.onMsg = (event) => {
|
|
20593
20367
|
const messageEvent = event;
|
|
@@ -20621,64 +20395,6 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20621
20395
|
if (busMessage.senderId === this.connectorId) {
|
|
20622
20396
|
return;
|
|
20623
20397
|
}
|
|
20624
|
-
// Try to unwrap as transport frame
|
|
20625
|
-
const frame = unwrapTransportFrame(busMessage.payload);
|
|
20626
|
-
if (frame) {
|
|
20627
|
-
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
20628
|
-
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
20629
|
-
const dstMatches = frame.dst === this.localNodeId;
|
|
20630
|
-
if (dstMatches && srcMatches) {
|
|
20631
|
-
// Successfully received and filtered transport frame
|
|
20632
|
-
logger$G.debug('inpage_transport_frame_received', {
|
|
20633
|
-
channel: this.channelName,
|
|
20634
|
-
sender_id: busMessage.senderId,
|
|
20635
|
-
connector_id: this.connectorId,
|
|
20636
|
-
local_node_id: this.localNodeId,
|
|
20637
|
-
remote_node_id: this.remoteNodeId,
|
|
20638
|
-
frame_src: frame.src,
|
|
20639
|
-
frame_dst: frame.dst,
|
|
20640
|
-
payload_length: frame.payload.byteLength,
|
|
20641
|
-
});
|
|
20642
|
-
const unwrapped = frame.payload;
|
|
20643
|
-
try {
|
|
20644
|
-
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
20645
|
-
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
20646
|
-
if (accepted) {
|
|
20647
|
-
return;
|
|
20648
|
-
}
|
|
20649
|
-
}
|
|
20650
|
-
this.inbox.enqueue(unwrapped);
|
|
20651
|
-
}
|
|
20652
|
-
catch (error) {
|
|
20653
|
-
if (error instanceof QueueFullError) {
|
|
20654
|
-
logger$G.warning('inpage_receive_queue_full', {
|
|
20655
|
-
channel: this.channelName,
|
|
20656
|
-
});
|
|
20657
|
-
}
|
|
20658
|
-
else {
|
|
20659
|
-
logger$G.error('inpage_receive_error', {
|
|
20660
|
-
channel: this.channelName,
|
|
20661
|
-
error: error instanceof Error ? error.message : String(error),
|
|
20662
|
-
});
|
|
20663
|
-
}
|
|
20664
|
-
}
|
|
20665
|
-
return;
|
|
20666
|
-
}
|
|
20667
|
-
else {
|
|
20668
|
-
// Frame filtered out by addressing rules
|
|
20669
|
-
logger$G.debug('inpage_transport_frame_filtered', {
|
|
20670
|
-
channel: this.channelName,
|
|
20671
|
-
connector_id: this.connectorId,
|
|
20672
|
-
local_node_id: this.localNodeId,
|
|
20673
|
-
remote_node_id: this.remoteNodeId,
|
|
20674
|
-
frame_src: frame.src,
|
|
20675
|
-
frame_dst: frame.dst,
|
|
20676
|
-
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
20677
|
-
});
|
|
20678
|
-
return;
|
|
20679
|
-
}
|
|
20680
|
-
}
|
|
20681
|
-
// Fall back to legacy format (no transport frame)
|
|
20682
20398
|
const payload = InPageConnector.coercePayload(busMessage.payload);
|
|
20683
20399
|
if (!payload) {
|
|
20684
20400
|
logger$G.debug('inpage_payload_rejected', {
|
|
@@ -20837,27 +20553,11 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20837
20553
|
logger$G.debug('inpage_message_sending', {
|
|
20838
20554
|
channel: this.channelName,
|
|
20839
20555
|
sender_id: this.connectorId,
|
|
20840
|
-
|
|
20841
|
-
remote_node_id: this.remoteNodeId,
|
|
20842
|
-
});
|
|
20843
|
-
// Only use transport framing if both localNodeId and remoteNodeId are explicitly set
|
|
20844
|
-
// (not using default values). This ensures backwards compatibility.
|
|
20845
|
-
const useTransportFrame = this.localNodeId !== this.connectorId ||
|
|
20846
|
-
this.remoteNodeId !== '*';
|
|
20847
|
-
let payload;
|
|
20848
|
-
if (useTransportFrame) {
|
|
20849
|
-
// Wrap payload in transport frame
|
|
20850
|
-
const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
|
|
20851
|
-
payload = serializeTransportFrame(frame);
|
|
20852
|
-
}
|
|
20853
|
-
else {
|
|
20854
|
-
// Legacy format: send raw payload
|
|
20855
|
-
payload = data;
|
|
20856
|
-
}
|
|
20556
|
+
});
|
|
20857
20557
|
const event = new MessageEvent(this.channelName, {
|
|
20858
20558
|
data: {
|
|
20859
20559
|
senderId: this.connectorId,
|
|
20860
|
-
payload,
|
|
20560
|
+
payload: data,
|
|
20861
20561
|
},
|
|
20862
20562
|
});
|
|
20863
20563
|
getSharedBus$1().dispatchEvent(event);
|
|
@@ -20886,24 +20586,6 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20886
20586
|
}
|
|
20887
20587
|
return rawOrEnvelope;
|
|
20888
20588
|
}
|
|
20889
|
-
/**
|
|
20890
|
-
* Update the remote node ID after learning it from NodeAttachAck
|
|
20891
|
-
* This allows upstream connectors to switch from wildcard to specific addressing
|
|
20892
|
-
*/
|
|
20893
|
-
updateRemoteNodeId(newRemoteNodeId) {
|
|
20894
|
-
if (typeof newRemoteNodeId !== 'string' || newRemoteNodeId.trim().length === 0) {
|
|
20895
|
-
throw new Error('Invalid remote node ID');
|
|
20896
|
-
}
|
|
20897
|
-
const oldValue = this.remoteNodeId;
|
|
20898
|
-
this.remoteNodeId = newRemoteNodeId.trim();
|
|
20899
|
-
logger$G.debug('inpage_connector_remote_node_id_updated', {
|
|
20900
|
-
channel: this.channelName,
|
|
20901
|
-
connector_id: this.connectorId,
|
|
20902
|
-
local_node_id: this.localNodeId,
|
|
20903
|
-
old_remote_node_id: oldValue,
|
|
20904
|
-
new_remote_node_id: this.remoteNodeId,
|
|
20905
|
-
});
|
|
20906
|
-
}
|
|
20907
20589
|
}
|
|
20908
20590
|
|
|
20909
20591
|
const RPC_REGISTRY = Symbol('naylence.rpc.registry');
|
|
@@ -28240,14 +27922,6 @@ function isInPageConnectionGrant(candidate) {
|
|
|
28240
27922
|
record.inboxCapacity <= 0)) {
|
|
28241
27923
|
return false;
|
|
28242
27924
|
}
|
|
28243
|
-
if (record.localNodeId !== undefined &&
|
|
28244
|
-
(typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
|
|
28245
|
-
return false;
|
|
28246
|
-
}
|
|
28247
|
-
if (record.remoteNodeId !== undefined &&
|
|
28248
|
-
(typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
|
|
28249
|
-
return false;
|
|
28250
|
-
}
|
|
28251
27925
|
return true;
|
|
28252
27926
|
}
|
|
28253
27927
|
function normalizeInPageConnectionGrant(candidate) {
|
|
@@ -28281,20 +27955,6 @@ function normalizeInPageConnectionGrant(candidate) {
|
|
|
28281
27955
|
}
|
|
28282
27956
|
result.inboxCapacity = Math.floor(inboxValue);
|
|
28283
27957
|
}
|
|
28284
|
-
const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
|
|
28285
|
-
if (localNodeIdValue !== undefined) {
|
|
28286
|
-
if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
|
|
28287
|
-
throw new TypeError('InPageConnectionGrant "localNodeId" must be a non-empty string when provided');
|
|
28288
|
-
}
|
|
28289
|
-
result.localNodeId = localNodeIdValue.trim();
|
|
28290
|
-
}
|
|
28291
|
-
const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
28292
|
-
if (remoteNodeIdValue !== undefined) {
|
|
28293
|
-
if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
|
|
28294
|
-
throw new TypeError('InPageConnectionGrant "remoteNodeId" must be a non-empty string when provided');
|
|
28295
|
-
}
|
|
28296
|
-
result.remoteNodeId = remoteNodeIdValue.trim();
|
|
28297
|
-
}
|
|
28298
27958
|
return result;
|
|
28299
27959
|
}
|
|
28300
27960
|
function inPageGrantToConnectorConfig(grant) {
|
|
@@ -28308,12 +27968,6 @@ function inPageGrantToConnectorConfig(grant) {
|
|
|
28308
27968
|
if (normalized.inboxCapacity !== undefined) {
|
|
28309
27969
|
config.inboxCapacity = normalized.inboxCapacity;
|
|
28310
27970
|
}
|
|
28311
|
-
if (normalized.localNodeId) {
|
|
28312
|
-
config.localNodeId = normalized.localNodeId;
|
|
28313
|
-
}
|
|
28314
|
-
if (normalized.remoteNodeId) {
|
|
28315
|
-
config.remoteNodeId = normalized.remoteNodeId;
|
|
28316
|
-
}
|
|
28317
27971
|
return config;
|
|
28318
27972
|
}
|
|
28319
27973
|
|
|
@@ -28935,8 +28589,6 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
28935
28589
|
type: INPAGE_CONNECTOR_TYPE,
|
|
28936
28590
|
channelName,
|
|
28937
28591
|
inboxCapacity,
|
|
28938
|
-
localNodeId: normalized.localNodeId,
|
|
28939
|
-
remoteNodeId: normalized.remoteNodeId,
|
|
28940
28592
|
};
|
|
28941
28593
|
const connector = new InPageConnector(connectorConfig, baseConfig);
|
|
28942
28594
|
if (options.authorization) {
|
|
@@ -29005,16 +28657,6 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
29005
28657
|
if (candidate.authorizationContext !== undefined) {
|
|
29006
28658
|
normalized.authorizationContext = candidate.authorizationContext;
|
|
29007
28659
|
}
|
|
29008
|
-
// Handle localNodeId
|
|
29009
|
-
const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
|
|
29010
|
-
if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
|
|
29011
|
-
normalized.localNodeId = localNodeId.trim();
|
|
29012
|
-
}
|
|
29013
|
-
// Handle remoteNodeId
|
|
29014
|
-
const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
29015
|
-
if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
|
|
29016
|
-
normalized.remoteNodeId = remoteNodeId.trim();
|
|
29017
|
-
}
|
|
29018
28660
|
normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$5;
|
|
29019
28661
|
normalized.inboxCapacity =
|
|
29020
28662
|
normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
|
|
@@ -29065,8 +28707,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
29065
28707
|
type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
|
|
29066
28708
|
channelName: connectorConfig.channelName,
|
|
29067
28709
|
inboxCapacity: connectorConfig.inboxCapacity,
|
|
29068
|
-
|
|
29069
|
-
remoteNodeId: connectorConfig.remoteNodeId,
|
|
28710
|
+
initialWindow: connectorConfig.initialWindow,
|
|
29070
28711
|
};
|
|
29071
28712
|
}
|
|
29072
28713
|
const config = {
|
|
@@ -29091,6 +28732,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
29091
28732
|
purpose: 'connection',
|
|
29092
28733
|
channelName: normalizedConfig.channelName,
|
|
29093
28734
|
inboxCapacity: normalizedConfig.inboxCapacity,
|
|
28735
|
+
initialWindow: normalizedConfig.initialWindow,
|
|
29094
28736
|
});
|
|
29095
28737
|
return grant;
|
|
29096
28738
|
}
|
|
@@ -29116,8 +28758,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
29116
28758
|
type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
|
|
29117
28759
|
channelName,
|
|
29118
28760
|
inboxCapacity,
|
|
29119
|
-
localNodeId: normalized.localNodeId,
|
|
29120
|
-
remoteNodeId: normalized.remoteNodeId,
|
|
29121
28761
|
};
|
|
29122
28762
|
const connector = new BroadcastChannelConnector(connectorConfig, baseConfig);
|
|
29123
28763
|
if (options.authorization) {
|
|
@@ -29179,16 +28819,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
29179
28819
|
if (candidate.authorizationContext !== undefined) {
|
|
29180
28820
|
normalized.authorizationContext = candidate.authorizationContext;
|
|
29181
28821
|
}
|
|
29182
|
-
// Handle localNodeId
|
|
29183
|
-
const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
|
|
29184
|
-
if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
|
|
29185
|
-
normalized.localNodeId = localNodeId.trim();
|
|
29186
|
-
}
|
|
29187
|
-
// Handle remoteNodeId
|
|
29188
|
-
const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
29189
|
-
if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
|
|
29190
|
-
normalized.remoteNodeId = remoteNodeId.trim();
|
|
29191
|
-
}
|
|
29192
28822
|
normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$4;
|
|
29193
28823
|
normalized.inboxCapacity =
|
|
29194
28824
|
normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$4;
|
|
@@ -29557,7 +29187,6 @@ class InPageListener extends TransportListener {
|
|
|
29557
29187
|
this._busHandler = null;
|
|
29558
29188
|
this._senderRegistry = new Map();
|
|
29559
29189
|
this._systemToSender = new Map();
|
|
29560
|
-
this._flowIdToSender = new Map();
|
|
29561
29190
|
this._pendingAttachments = new Map();
|
|
29562
29191
|
ensureBrowserEnvironment$1();
|
|
29563
29192
|
const channelCandidate = options?.channelName;
|
|
@@ -29624,7 +29253,6 @@ class InPageListener extends TransportListener {
|
|
|
29624
29253
|
this._unregisterBusListener();
|
|
29625
29254
|
this._senderRegistry.clear();
|
|
29626
29255
|
this._systemToSender.clear();
|
|
29627
|
-
this._flowIdToSender.clear();
|
|
29628
29256
|
this._pendingAttachments.clear();
|
|
29629
29257
|
logger$p.debug('inpage_listener_stopped', {
|
|
29630
29258
|
channel: this._channelName,
|
|
@@ -29678,25 +29306,10 @@ class InPageListener extends TransportListener {
|
|
|
29678
29306
|
await this._handleAttachFrame(senderId, envelope);
|
|
29679
29307
|
return;
|
|
29680
29308
|
}
|
|
29681
|
-
|
|
29682
|
-
let entry = this._senderRegistry.get(senderId);
|
|
29683
|
-
// If not found and we have a flowId, try to route based on flow
|
|
29684
|
-
if (!entry && envelope.flowId) {
|
|
29685
|
-
const originalSenderId = this._flowIdToSender.get(envelope.flowId);
|
|
29686
|
-
if (originalSenderId) {
|
|
29687
|
-
entry = this._senderRegistry.get(originalSenderId);
|
|
29688
|
-
logger$p.debug('inpage_listener_routed_by_flow_id', {
|
|
29689
|
-
sender_id: senderId,
|
|
29690
|
-
original_sender_id: originalSenderId,
|
|
29691
|
-
flow_id: envelope.flowId,
|
|
29692
|
-
frame_type: envelope.frame?.type ?? 'unknown',
|
|
29693
|
-
});
|
|
29694
|
-
}
|
|
29695
|
-
}
|
|
29309
|
+
const entry = this._senderRegistry.get(senderId);
|
|
29696
29310
|
if (!entry) {
|
|
29697
29311
|
logger$p.debug('inpage_listener_no_connector_for_sender', {
|
|
29698
29312
|
sender_id: senderId,
|
|
29699
|
-
flow_id: envelope.flowId,
|
|
29700
29313
|
frame_type: envelope.frame?.type ?? 'unknown',
|
|
29701
29314
|
});
|
|
29702
29315
|
return;
|
|
@@ -29773,15 +29386,6 @@ class InPageListener extends TransportListener {
|
|
|
29773
29386
|
}
|
|
29774
29387
|
this._senderRegistry.set(senderId, entry);
|
|
29775
29388
|
this._systemToSender.set(entry.systemId, senderId);
|
|
29776
|
-
// Track the flowId if present so we can route responses back
|
|
29777
|
-
if (envelope.flowId) {
|
|
29778
|
-
this._flowIdToSender.set(envelope.flowId, senderId);
|
|
29779
|
-
logger$p.debug('inpage_listener_registered_flow_id', {
|
|
29780
|
-
sender_id: senderId,
|
|
29781
|
-
system_id: entry.systemId,
|
|
29782
|
-
flow_id: envelope.flowId,
|
|
29783
|
-
});
|
|
29784
|
-
}
|
|
29785
29389
|
await this._deliverEnvelope(entry, envelope);
|
|
29786
29390
|
}
|
|
29787
29391
|
async _createConnectorForAttach(params) {
|
|
@@ -29829,7 +29433,7 @@ class InPageListener extends TransportListener {
|
|
|
29829
29433
|
origin_type: originType,
|
|
29830
29434
|
connector_type: connector.constructor?.name ?? 'unknown',
|
|
29831
29435
|
});
|
|
29832
|
-
return { connector, systemId, originType
|
|
29436
|
+
return { connector, systemId, originType };
|
|
29833
29437
|
}
|
|
29834
29438
|
catch (error) {
|
|
29835
29439
|
logger$p.error('inpage_listener_connector_creation_failed', {
|
|
@@ -29883,12 +29487,6 @@ class InPageListener extends TransportListener {
|
|
|
29883
29487
|
if (this._systemToSender.get(systemId) === senderId) {
|
|
29884
29488
|
this._systemToSender.delete(systemId);
|
|
29885
29489
|
}
|
|
29886
|
-
// Clean up flowId mappings for this sender
|
|
29887
|
-
for (const [flowId, sid] of this._flowIdToSender.entries()) {
|
|
29888
|
-
if (sid === senderId) {
|
|
29889
|
-
this._flowIdToSender.delete(flowId);
|
|
29890
|
-
}
|
|
29891
|
-
}
|
|
29892
29490
|
})
|
|
29893
29491
|
.catch((error) => {
|
|
29894
29492
|
logger$p.debug('inpage_listener_wait_until_closed_failed', {
|
|
@@ -29900,24 +29498,9 @@ class InPageListener extends TransportListener {
|
|
|
29900
29498
|
if (this._systemToSender.get(systemId) === senderId) {
|
|
29901
29499
|
this._systemToSender.delete(systemId);
|
|
29902
29500
|
}
|
|
29903
|
-
// Clean up flowId mappings for this sender
|
|
29904
|
-
for (const [flowId, sid] of this._flowIdToSender.entries()) {
|
|
29905
|
-
if (sid === senderId) {
|
|
29906
|
-
this._flowIdToSender.delete(flowId);
|
|
29907
|
-
}
|
|
29908
|
-
}
|
|
29909
29501
|
});
|
|
29910
29502
|
}
|
|
29911
29503
|
async _deliverEnvelope(entry, envelope) {
|
|
29912
|
-
// Track flowId for routing responses back
|
|
29913
|
-
if (envelope.flowId && !this._flowIdToSender.has(envelope.flowId)) {
|
|
29914
|
-
this._flowIdToSender.set(envelope.flowId, entry.senderId);
|
|
29915
|
-
logger$p.debug('inpage_listener_registered_flow_id_on_delivery', {
|
|
29916
|
-
sender_id: entry.senderId,
|
|
29917
|
-
system_id: entry.systemId,
|
|
29918
|
-
flow_id: envelope.flowId,
|
|
29919
|
-
});
|
|
29920
|
-
}
|
|
29921
29504
|
const message = this._buildChannelMessage({
|
|
29922
29505
|
envelope,
|
|
29923
29506
|
connector: entry.connector,
|
|
@@ -30158,18 +29741,13 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
30158
29741
|
});
|
|
30159
29742
|
}
|
|
30160
29743
|
asCallbackGrant() {
|
|
30161
|
-
|
|
29744
|
+
return this.withLegacySnakeCaseKeys({
|
|
30162
29745
|
type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
|
|
30163
29746
|
connectorType: BROADCAST_CHANNEL_CONNECTOR_TYPE,
|
|
30164
29747
|
connectionGrantType: BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE,
|
|
30165
29748
|
channelName: this._channelName,
|
|
30166
29749
|
inboxCapacity: this._inboxCapacity,
|
|
30167
|
-
};
|
|
30168
|
-
// Include localNodeId for transport frame multiplexing if node is available
|
|
30169
|
-
if (this._routingNode) {
|
|
30170
|
-
grant.localNodeId = this._routingNode.id;
|
|
30171
|
-
}
|
|
30172
|
-
return this.withLegacySnakeCaseKeys(grant);
|
|
29750
|
+
});
|
|
30173
29751
|
}
|
|
30174
29752
|
_registerChannelListener() {
|
|
30175
29753
|
if (this._channelHandler) {
|
|
@@ -30229,54 +29807,23 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
30229
29807
|
if (typeof senderId !== 'string' || senderId.length === 0) {
|
|
30230
29808
|
return null;
|
|
30231
29809
|
}
|
|
30232
|
-
|
|
30233
|
-
|
|
30234
|
-
|
|
30235
|
-
|
|
30236
|
-
|
|
30237
|
-
|
|
30238
|
-
// Apply listener's filtering policy: accept frames addressed to us OR with wildcard destination
|
|
30239
|
-
// Wildcard is needed because downstream nodes don't know the sentinel's ID during initial attach
|
|
30240
|
-
const isAddressedToUs = frame.dst === this._routingNode.id || frame.dst === '*';
|
|
30241
|
-
if (isAddressedToUs) {
|
|
30242
|
-
envelopePayload = frame.payload;
|
|
30243
|
-
logger$o.debug('broadcast_channel_listener_unwrapped_transport_frame', {
|
|
30244
|
-
sender_id: senderId,
|
|
30245
|
-
src: frame.src,
|
|
30246
|
-
dst: frame.dst,
|
|
30247
|
-
});
|
|
30248
|
-
}
|
|
30249
|
-
else {
|
|
30250
|
-
// Frame addressed to a different node, ignore it
|
|
30251
|
-
logger$o.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
|
|
30252
|
-
sender_id: senderId,
|
|
30253
|
-
dst: frame.dst,
|
|
30254
|
-
expected: this._routingNode.id,
|
|
30255
|
-
});
|
|
30256
|
-
return null;
|
|
30257
|
-
}
|
|
30258
|
-
}
|
|
30259
|
-
}
|
|
30260
|
-
// If not a transport frame, try to coerce as legacy format
|
|
30261
|
-
if (!envelopePayload) {
|
|
30262
|
-
envelopePayload = coercePayload(record.payload);
|
|
30263
|
-
if (!envelopePayload) {
|
|
30264
|
-
logger$o.debug('broadcast_channel_listener_ignored_event_without_payload', {
|
|
30265
|
-
sender_id: senderId,
|
|
30266
|
-
});
|
|
30267
|
-
return null;
|
|
30268
|
-
}
|
|
29810
|
+
const payload = coercePayload(record.payload);
|
|
29811
|
+
if (!payload) {
|
|
29812
|
+
logger$o.debug('broadcast_channel_listener_ignored_event_without_payload', {
|
|
29813
|
+
sender_id: senderId,
|
|
29814
|
+
});
|
|
29815
|
+
return null;
|
|
30269
29816
|
}
|
|
30270
29817
|
let envelope;
|
|
30271
29818
|
try {
|
|
30272
|
-
const decoded = new TextDecoder().decode(
|
|
29819
|
+
const decoded = new TextDecoder().decode(payload);
|
|
30273
29820
|
const parsed = JSON.parse(decoded);
|
|
30274
29821
|
envelope = deserializeEnvelope(parsed);
|
|
30275
29822
|
}
|
|
30276
29823
|
catch (error) {
|
|
30277
29824
|
const decoded = (() => {
|
|
30278
29825
|
try {
|
|
30279
|
-
return new TextDecoder().decode(
|
|
29826
|
+
return new TextDecoder().decode(payload);
|
|
30280
29827
|
}
|
|
30281
29828
|
catch {
|
|
30282
29829
|
return null;
|
|
@@ -30396,20 +29943,6 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
30396
29943
|
inboxCapacity: this._inboxCapacity,
|
|
30397
29944
|
};
|
|
30398
29945
|
}
|
|
30399
|
-
// Automatically configure transport frame multiplexing:
|
|
30400
|
-
// Use node IDs (not connector IDs) for node-to-node targeting
|
|
30401
|
-
const broadcastConfig = connectorConfig;
|
|
30402
|
-
// Always force localNodeId to be this listener's node ID
|
|
30403
|
-
// This ensures the sentinel sets localNodeId=sentinel, not the child's ID
|
|
30404
|
-
broadcastConfig.localNodeId = routingNode.id;
|
|
30405
|
-
// Always force remoteNodeId to be the attaching child's system ID
|
|
30406
|
-
broadcastConfig.remoteNodeId = systemId;
|
|
30407
|
-
logger$o.debug('broadcast_channel_listener_configured_node_ids', {
|
|
30408
|
-
sender_id: params.senderId,
|
|
30409
|
-
system_id: systemId,
|
|
30410
|
-
local_node_id: broadcastConfig.localNodeId,
|
|
30411
|
-
remote_node_id: broadcastConfig.remoteNodeId,
|
|
30412
|
-
});
|
|
30413
29946
|
try {
|
|
30414
29947
|
const connector = await routingNode.createOriginConnector({
|
|
30415
29948
|
originType,
|
|
@@ -30479,21 +30012,6 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
30479
30012
|
inboxCandidate > 0) {
|
|
30480
30013
|
config.inboxCapacity = Math.floor(inboxCandidate);
|
|
30481
30014
|
}
|
|
30482
|
-
// Extract transport frame multiplexing node IDs
|
|
30483
|
-
const localNodeIdCandidate = candidate.localNodeId ?? candidate['local_node_id'];
|
|
30484
|
-
if (typeof localNodeIdCandidate === 'string' && localNodeIdCandidate.trim().length > 0) {
|
|
30485
|
-
config.localNodeId = localNodeIdCandidate.trim();
|
|
30486
|
-
logger$o.debug('broadcast_channel_listener_extracted_local_node_id', {
|
|
30487
|
-
local_node_id: config.localNodeId,
|
|
30488
|
-
});
|
|
30489
|
-
}
|
|
30490
|
-
const remoteNodeIdCandidate = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
30491
|
-
if (typeof remoteNodeIdCandidate === 'string' && remoteNodeIdCandidate.trim().length > 0) {
|
|
30492
|
-
config.remoteNodeId = remoteNodeIdCandidate.trim();
|
|
30493
|
-
logger$o.debug('broadcast_channel_listener_extracted_remote_node_id', {
|
|
30494
|
-
remote_node_id: config.remoteNodeId,
|
|
30495
|
-
});
|
|
30496
|
-
}
|
|
30497
30015
|
return config;
|
|
30498
30016
|
}
|
|
30499
30017
|
_monitorConnectorLifecycle(senderId, systemId, connector) {
|