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