@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/index.mjs
CHANGED
|
@@ -13,12 +13,12 @@ import fastify from 'fastify';
|
|
|
13
13
|
import websocketPlugin from '@fastify/websocket';
|
|
14
14
|
|
|
15
15
|
// This file is auto-generated during build - do not edit manually
|
|
16
|
-
// Generated from package.json version: 0.3.5-test.
|
|
16
|
+
// Generated from package.json version: 0.3.5-test.954
|
|
17
17
|
/**
|
|
18
18
|
* The package version, injected at build time.
|
|
19
19
|
* @internal
|
|
20
20
|
*/
|
|
21
|
-
const VERSION = '0.3.5-test.
|
|
21
|
+
const VERSION = '0.3.5-test.954';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -9733,84 +9733,6 @@ class BoundedAsyncQueue {
|
|
|
9733
9733
|
}
|
|
9734
9734
|
}
|
|
9735
9735
|
|
|
9736
|
-
/**
|
|
9737
|
-
* Transport frame layer for multiplexing logical links on physical channels.
|
|
9738
|
-
*
|
|
9739
|
-
* This lightweight framing layer wraps raw FAME payloads to enable multiple
|
|
9740
|
-
* logical connections over a single physical channel (BroadcastChannel or InPage bus).
|
|
9741
|
-
*
|
|
9742
|
-
* The transport frame does NOT modify FAME envelopes - it only wraps the raw
|
|
9743
|
-
* Uint8Array payload at the connector level.
|
|
9744
|
-
*/
|
|
9745
|
-
/**
|
|
9746
|
-
* Transport frame version for future compatibility
|
|
9747
|
-
*/
|
|
9748
|
-
const TRANSPORT_FRAME_VERSION = 1;
|
|
9749
|
-
/**
|
|
9750
|
-
* Wrap a raw payload in a transport frame
|
|
9751
|
-
*
|
|
9752
|
-
* @param payload - Raw FAME envelope bytes
|
|
9753
|
-
* @param srcNodeId - Local node ID (this connector)
|
|
9754
|
-
* @param dstNodeId - Remote node ID (target connector)
|
|
9755
|
-
* @returns Transport frame ready for transmission
|
|
9756
|
-
*/
|
|
9757
|
-
function wrapTransportFrame(payload, srcNodeId, dstNodeId) {
|
|
9758
|
-
return {
|
|
9759
|
-
v: TRANSPORT_FRAME_VERSION,
|
|
9760
|
-
src: srcNodeId,
|
|
9761
|
-
dst: dstNodeId,
|
|
9762
|
-
payload,
|
|
9763
|
-
};
|
|
9764
|
-
}
|
|
9765
|
-
/**
|
|
9766
|
-
* Serialize a transport frame for transmission over the bus
|
|
9767
|
-
*
|
|
9768
|
-
* @param frame - Transport frame to serialize
|
|
9769
|
-
* @returns Serialized frame data ready for postMessage/dispatchEvent
|
|
9770
|
-
*/
|
|
9771
|
-
function serializeTransportFrame(frame) {
|
|
9772
|
-
// Convert Uint8Array to regular array for JSON serialization
|
|
9773
|
-
const serializable = {
|
|
9774
|
-
v: frame.v,
|
|
9775
|
-
src: frame.src,
|
|
9776
|
-
dst: frame.dst,
|
|
9777
|
-
payload: Array.from(frame.payload),
|
|
9778
|
-
};
|
|
9779
|
-
return serializable;
|
|
9780
|
-
}
|
|
9781
|
-
/**
|
|
9782
|
-
* Unwrap a transport frame (pure deserializer - no filtering)
|
|
9783
|
-
*
|
|
9784
|
-
* @param raw - Raw data from the bus
|
|
9785
|
-
* @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
|
|
9786
|
-
*/
|
|
9787
|
-
function unwrapTransportFrame(raw) {
|
|
9788
|
-
// Validate basic structure
|
|
9789
|
-
if (!raw || typeof raw !== 'object') {
|
|
9790
|
-
return null;
|
|
9791
|
-
}
|
|
9792
|
-
const frame = raw;
|
|
9793
|
-
// Check version
|
|
9794
|
-
if (frame.v !== TRANSPORT_FRAME_VERSION) {
|
|
9795
|
-
return null;
|
|
9796
|
-
}
|
|
9797
|
-
// Check src and dst
|
|
9798
|
-
if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
|
|
9799
|
-
return null;
|
|
9800
|
-
}
|
|
9801
|
-
// Extract payload
|
|
9802
|
-
if (!frame.payload || !Array.isArray(frame.payload)) {
|
|
9803
|
-
return null;
|
|
9804
|
-
}
|
|
9805
|
-
// Convert array back to Uint8Array and return full frame
|
|
9806
|
-
return {
|
|
9807
|
-
v: frame.v,
|
|
9808
|
-
src: frame.src,
|
|
9809
|
-
dst: frame.dst,
|
|
9810
|
-
payload: Uint8Array.from(frame.payload),
|
|
9811
|
-
};
|
|
9812
|
-
}
|
|
9813
|
-
|
|
9814
9736
|
const logger$_ = getLogger('naylence.fame.connector.broadcast_channel_connector');
|
|
9815
9737
|
const BROADCAST_CHANNEL_CONNECTOR_TYPE = 'broadcast-channel-connector';
|
|
9816
9738
|
const DEFAULT_CHANNEL$7 = 'naylence-fabric';
|
|
@@ -9876,20 +9798,9 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9876
9798
|
this.inbox = new BoundedAsyncQueue(preferredCapacity);
|
|
9877
9799
|
this.connectorId = BroadcastChannelConnector.generateConnectorId();
|
|
9878
9800
|
this.channel = new BroadcastChannel(this.channelName);
|
|
9879
|
-
// Set local and remote node IDs (defaults to connector ID for backwards compatibility)
|
|
9880
|
-
this.localNodeId =
|
|
9881
|
-
typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
|
|
9882
|
-
? config.localNodeId.trim()
|
|
9883
|
-
: this.connectorId;
|
|
9884
|
-
this.remoteNodeId =
|
|
9885
|
-
typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
|
|
9886
|
-
? config.remoteNodeId.trim()
|
|
9887
|
-
: '*'; // Accept from any remote if not specified
|
|
9888
9801
|
logger$_.debug('broadcast_channel_connector_created', {
|
|
9889
9802
|
channel: this.channelName,
|
|
9890
9803
|
connector_id: this.connectorId,
|
|
9891
|
-
local_node_id: this.localNodeId,
|
|
9892
|
-
remote_node_id: this.remoteNodeId,
|
|
9893
9804
|
inbox_capacity: preferredCapacity,
|
|
9894
9805
|
timestamp: new Date().toISOString(),
|
|
9895
9806
|
});
|
|
@@ -9922,67 +9833,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9922
9833
|
if (busMessage.senderId === this.connectorId) {
|
|
9923
9834
|
return;
|
|
9924
9835
|
}
|
|
9925
|
-
// Try to unwrap as transport frame
|
|
9926
|
-
const frame = unwrapTransportFrame(busMessage.payload);
|
|
9927
|
-
if (frame) {
|
|
9928
|
-
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
9929
|
-
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
9930
|
-
const dstMatches = frame.dst === this.localNodeId;
|
|
9931
|
-
if (dstMatches && srcMatches) {
|
|
9932
|
-
// Successfully received and filtered transport frame
|
|
9933
|
-
logger$_.debug('broadcast_channel_transport_frame_received', {
|
|
9934
|
-
channel: this.channelName,
|
|
9935
|
-
sender_id: busMessage.senderId,
|
|
9936
|
-
connector_id: this.connectorId,
|
|
9937
|
-
local_node_id: this.localNodeId,
|
|
9938
|
-
remote_node_id: this.remoteNodeId,
|
|
9939
|
-
frame_src: frame.src,
|
|
9940
|
-
frame_dst: frame.dst,
|
|
9941
|
-
payload_length: frame.payload.byteLength,
|
|
9942
|
-
});
|
|
9943
|
-
const unwrapped = frame.payload;
|
|
9944
|
-
if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
|
|
9945
|
-
return;
|
|
9946
|
-
}
|
|
9947
|
-
try {
|
|
9948
|
-
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
9949
|
-
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
9950
|
-
if (accepted) {
|
|
9951
|
-
return;
|
|
9952
|
-
}
|
|
9953
|
-
}
|
|
9954
|
-
this.inbox.enqueue(unwrapped);
|
|
9955
|
-
}
|
|
9956
|
-
catch (error) {
|
|
9957
|
-
if (error instanceof QueueFullError) {
|
|
9958
|
-
logger$_.warning('broadcast_channel_receive_queue_full', {
|
|
9959
|
-
channel: this.channelName,
|
|
9960
|
-
});
|
|
9961
|
-
}
|
|
9962
|
-
else {
|
|
9963
|
-
logger$_.error('broadcast_channel_receive_error', {
|
|
9964
|
-
channel: this.channelName,
|
|
9965
|
-
error: error instanceof Error ? error.message : String(error),
|
|
9966
|
-
});
|
|
9967
|
-
}
|
|
9968
|
-
}
|
|
9969
|
-
return;
|
|
9970
|
-
}
|
|
9971
|
-
else {
|
|
9972
|
-
// Frame filtered out by addressing rules
|
|
9973
|
-
logger$_.debug('broadcast_channel_transport_frame_filtered', {
|
|
9974
|
-
channel: this.channelName,
|
|
9975
|
-
connector_id: this.connectorId,
|
|
9976
|
-
local_node_id: this.localNodeId,
|
|
9977
|
-
remote_node_id: this.remoteNodeId,
|
|
9978
|
-
frame_src: frame.src,
|
|
9979
|
-
frame_dst: frame.dst,
|
|
9980
|
-
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
9981
|
-
});
|
|
9982
|
-
return;
|
|
9983
|
-
}
|
|
9984
|
-
}
|
|
9985
|
-
// Fall back to legacy format (no transport frame)
|
|
9986
9836
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
9987
9837
|
if (!payload) {
|
|
9988
9838
|
logger$_.debug('broadcast_channel_payload_rejected', {
|
|
@@ -10121,26 +9971,10 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10121
9971
|
logger$_.debug('broadcast_channel_message_sending', {
|
|
10122
9972
|
channel: this.channelName,
|
|
10123
9973
|
sender_id: this.connectorId,
|
|
10124
|
-
|
|
10125
|
-
remote_node_id: this.remoteNodeId,
|
|
10126
|
-
});
|
|
10127
|
-
// Only use transport framing if both localNodeId and remoteNodeId are explicitly set
|
|
10128
|
-
// (not using default values). This ensures backwards compatibility.
|
|
10129
|
-
const useTransportFrame = this.localNodeId !== this.connectorId ||
|
|
10130
|
-
this.remoteNodeId !== '*';
|
|
10131
|
-
let payload;
|
|
10132
|
-
if (useTransportFrame) {
|
|
10133
|
-
// Wrap payload in transport frame
|
|
10134
|
-
const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
|
|
10135
|
-
payload = serializeTransportFrame(frame);
|
|
10136
|
-
}
|
|
10137
|
-
else {
|
|
10138
|
-
// Legacy format: send raw payload
|
|
10139
|
-
payload = data;
|
|
10140
|
-
}
|
|
9974
|
+
});
|
|
10141
9975
|
this.channel.postMessage({
|
|
10142
9976
|
senderId: this.connectorId,
|
|
10143
|
-
payload,
|
|
9977
|
+
payload: data,
|
|
10144
9978
|
});
|
|
10145
9979
|
}
|
|
10146
9980
|
async _transportReceive() {
|
|
@@ -10296,24 +10130,6 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10296
10130
|
});
|
|
10297
10131
|
}
|
|
10298
10132
|
}
|
|
10299
|
-
/**
|
|
10300
|
-
* Update the remote node ID after learning it from NodeAttachAck
|
|
10301
|
-
* This allows upstream connectors to switch from wildcard to specific addressing
|
|
10302
|
-
*/
|
|
10303
|
-
updateRemoteNodeId(newRemoteNodeId) {
|
|
10304
|
-
if (typeof newRemoteNodeId !== 'string' || newRemoteNodeId.trim().length === 0) {
|
|
10305
|
-
throw new Error('Invalid remote node ID');
|
|
10306
|
-
}
|
|
10307
|
-
const oldValue = this.remoteNodeId;
|
|
10308
|
-
this.remoteNodeId = newRemoteNodeId.trim();
|
|
10309
|
-
logger$_.debug('broadcast_channel_connector_remote_node_id_updated', {
|
|
10310
|
-
channel: this.channelName,
|
|
10311
|
-
connector_id: this.connectorId,
|
|
10312
|
-
local_node_id: this.localNodeId,
|
|
10313
|
-
old_remote_node_id: oldValue,
|
|
10314
|
-
new_remote_node_id: this.remoteNodeId,
|
|
10315
|
-
});
|
|
10316
|
-
}
|
|
10317
10133
|
_trimSeenAcks(now) {
|
|
10318
10134
|
while (this.seenAckOrder.length > 0) {
|
|
10319
10135
|
const candidate = this.seenAckOrder[0];
|
|
@@ -10451,12 +10267,9 @@ function isBroadcastChannelConnectionGrant(candidate) {
|
|
|
10451
10267
|
record.inboxCapacity <= 0)) {
|
|
10452
10268
|
return false;
|
|
10453
10269
|
}
|
|
10454
|
-
if (record.
|
|
10455
|
-
(
|
|
10456
|
-
|
|
10457
|
-
}
|
|
10458
|
-
if (record.remoteNodeId !== undefined &&
|
|
10459
|
-
(typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
|
|
10270
|
+
if (record.initialWindow !== undefined &&
|
|
10271
|
+
(!Number.isFinite(record.initialWindow) ||
|
|
10272
|
+
record.initialWindow <= 0)) {
|
|
10460
10273
|
return false;
|
|
10461
10274
|
}
|
|
10462
10275
|
return true;
|
|
@@ -10492,19 +10305,14 @@ function normalizeBroadcastChannelConnectionGrant(candidate) {
|
|
|
10492
10305
|
}
|
|
10493
10306
|
result.inboxCapacity = Math.floor(inboxValue);
|
|
10494
10307
|
}
|
|
10495
|
-
const
|
|
10496
|
-
if (
|
|
10497
|
-
if (typeof
|
|
10498
|
-
|
|
10308
|
+
const windowValue = candidate.initialWindow ?? candidate['initial_window'];
|
|
10309
|
+
if (windowValue !== undefined) {
|
|
10310
|
+
if (typeof windowValue !== 'number' ||
|
|
10311
|
+
!Number.isFinite(windowValue) ||
|
|
10312
|
+
windowValue <= 0) {
|
|
10313
|
+
throw new TypeError('BroadcastChannelConnectionGrant "initialWindow" must be a positive number when provided');
|
|
10499
10314
|
}
|
|
10500
|
-
result.
|
|
10501
|
-
}
|
|
10502
|
-
const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
10503
|
-
if (remoteNodeIdValue !== undefined) {
|
|
10504
|
-
if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
|
|
10505
|
-
throw new TypeError('BroadcastChannelConnectionGrant "remoteNodeId" must be a non-empty string when provided');
|
|
10506
|
-
}
|
|
10507
|
-
result.remoteNodeId = remoteNodeIdValue.trim();
|
|
10315
|
+
result.initialWindow = Math.floor(windowValue);
|
|
10508
10316
|
}
|
|
10509
10317
|
return result;
|
|
10510
10318
|
}
|
|
@@ -10519,11 +10327,8 @@ function broadcastChannelGrantToConnectorConfig(grant) {
|
|
|
10519
10327
|
if (normalized.inboxCapacity !== undefined) {
|
|
10520
10328
|
config.inboxCapacity = normalized.inboxCapacity;
|
|
10521
10329
|
}
|
|
10522
|
-
if (normalized.
|
|
10523
|
-
config.
|
|
10524
|
-
}
|
|
10525
|
-
if (normalized.remoteNodeId) {
|
|
10526
|
-
config.remoteNodeId = normalized.remoteNodeId;
|
|
10330
|
+
if (normalized.initialWindow !== undefined) {
|
|
10331
|
+
config.initialWindow = normalized.initialWindow;
|
|
10527
10332
|
}
|
|
10528
10333
|
return config;
|
|
10529
10334
|
}
|
|
@@ -10815,12 +10620,6 @@ class UpstreamSessionManager extends TaskSpawner {
|
|
|
10815
10620
|
cryptoProvider.prepareForAttach(welcome.frame.systemId, welcome.frame.assignedPath, welcome.frame.acceptedLogicals ?? []);
|
|
10816
10621
|
}
|
|
10817
10622
|
await this.onWelcome(welcome.frame);
|
|
10818
|
-
// Inject node ID into grant for transport frame multiplexing
|
|
10819
|
-
// This ensures localNodeId matches the node's systemId for proper frame filtering
|
|
10820
|
-
grant.localNodeId = welcome.frame.systemId;
|
|
10821
|
-
if (welcome.frame.targetSystemId) {
|
|
10822
|
-
grant.remoteNodeId = welcome.frame.targetSystemId;
|
|
10823
|
-
}
|
|
10824
10623
|
const connector = await ConnectorFactory.createConnector(grant, {
|
|
10825
10624
|
systemId: welcome.frame.systemId,
|
|
10826
10625
|
});
|
|
@@ -12777,20 +12576,6 @@ class DefaultNodeAttachClient {
|
|
|
12777
12576
|
if (!targetSystemId) {
|
|
12778
12577
|
throw new Error('Target system ID must be set in NodeAttachAckFrame on success');
|
|
12779
12578
|
}
|
|
12780
|
-
// Update connector's remote node ID if it supports it (e.g., BroadcastChannelConnector, InPageConnector)
|
|
12781
|
-
// This allows upstream connectors to switch from wildcard '*' to specific node addressing
|
|
12782
|
-
const updatableConnector = connector;
|
|
12783
|
-
if (typeof updatableConnector.updateRemoteNodeId === 'function') {
|
|
12784
|
-
try {
|
|
12785
|
-
updatableConnector.updateRemoteNodeId(targetSystemId);
|
|
12786
|
-
}
|
|
12787
|
-
catch (error) {
|
|
12788
|
-
logger$W.debug('connector_remote_node_id_update_failed', {
|
|
12789
|
-
target_system_id: targetSystemId,
|
|
12790
|
-
error: error instanceof Error ? error.message : String(error),
|
|
12791
|
-
});
|
|
12792
|
-
}
|
|
12793
|
-
}
|
|
12794
12579
|
try {
|
|
12795
12580
|
if (this.replicaStickinessManager) {
|
|
12796
12581
|
this.replicaStickinessManager.accept(ackFrame.stickiness ?? null);
|
|
@@ -20491,20 +20276,9 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20491
20276
|
: DEFAULT_INBOX_CAPACITY$6;
|
|
20492
20277
|
this.inbox = new BoundedAsyncQueue(preferredCapacity);
|
|
20493
20278
|
this.connectorId = InPageConnector.generateConnectorId();
|
|
20494
|
-
// Set local and remote node IDs (defaults to connector ID for backwards compatibility)
|
|
20495
|
-
this.localNodeId =
|
|
20496
|
-
typeof config.localNodeId === 'string' && config.localNodeId.trim().length > 0
|
|
20497
|
-
? config.localNodeId.trim()
|
|
20498
|
-
: this.connectorId;
|
|
20499
|
-
this.remoteNodeId =
|
|
20500
|
-
typeof config.remoteNodeId === 'string' && config.remoteNodeId.trim().length > 0
|
|
20501
|
-
? config.remoteNodeId.trim()
|
|
20502
|
-
: '*'; // Accept from any remote if not specified
|
|
20503
20279
|
logger$G.debug('inpage_connector_initialized', {
|
|
20504
20280
|
channel: this.channelName,
|
|
20505
20281
|
connector_id: this.connectorId,
|
|
20506
|
-
local_node_id: this.localNodeId,
|
|
20507
|
-
remote_node_id: this.remoteNodeId,
|
|
20508
20282
|
});
|
|
20509
20283
|
this.onMsg = (event) => {
|
|
20510
20284
|
const messageEvent = event;
|
|
@@ -20538,64 +20312,6 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20538
20312
|
if (busMessage.senderId === this.connectorId) {
|
|
20539
20313
|
return;
|
|
20540
20314
|
}
|
|
20541
|
-
// Try to unwrap as transport frame
|
|
20542
|
-
const frame = unwrapTransportFrame(busMessage.payload);
|
|
20543
|
-
if (frame) {
|
|
20544
|
-
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
20545
|
-
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
20546
|
-
const dstMatches = frame.dst === this.localNodeId;
|
|
20547
|
-
if (dstMatches && srcMatches) {
|
|
20548
|
-
// Successfully received and filtered transport frame
|
|
20549
|
-
logger$G.debug('inpage_transport_frame_received', {
|
|
20550
|
-
channel: this.channelName,
|
|
20551
|
-
sender_id: busMessage.senderId,
|
|
20552
|
-
connector_id: this.connectorId,
|
|
20553
|
-
local_node_id: this.localNodeId,
|
|
20554
|
-
remote_node_id: this.remoteNodeId,
|
|
20555
|
-
frame_src: frame.src,
|
|
20556
|
-
frame_dst: frame.dst,
|
|
20557
|
-
payload_length: frame.payload.byteLength,
|
|
20558
|
-
});
|
|
20559
|
-
const unwrapped = frame.payload;
|
|
20560
|
-
try {
|
|
20561
|
-
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
20562
|
-
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
20563
|
-
if (accepted) {
|
|
20564
|
-
return;
|
|
20565
|
-
}
|
|
20566
|
-
}
|
|
20567
|
-
this.inbox.enqueue(unwrapped);
|
|
20568
|
-
}
|
|
20569
|
-
catch (error) {
|
|
20570
|
-
if (error instanceof QueueFullError) {
|
|
20571
|
-
logger$G.warning('inpage_receive_queue_full', {
|
|
20572
|
-
channel: this.channelName,
|
|
20573
|
-
});
|
|
20574
|
-
}
|
|
20575
|
-
else {
|
|
20576
|
-
logger$G.error('inpage_receive_error', {
|
|
20577
|
-
channel: this.channelName,
|
|
20578
|
-
error: error instanceof Error ? error.message : String(error),
|
|
20579
|
-
});
|
|
20580
|
-
}
|
|
20581
|
-
}
|
|
20582
|
-
return;
|
|
20583
|
-
}
|
|
20584
|
-
else {
|
|
20585
|
-
// Frame filtered out by addressing rules
|
|
20586
|
-
logger$G.debug('inpage_transport_frame_filtered', {
|
|
20587
|
-
channel: this.channelName,
|
|
20588
|
-
connector_id: this.connectorId,
|
|
20589
|
-
local_node_id: this.localNodeId,
|
|
20590
|
-
remote_node_id: this.remoteNodeId,
|
|
20591
|
-
frame_src: frame.src,
|
|
20592
|
-
frame_dst: frame.dst,
|
|
20593
|
-
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
20594
|
-
});
|
|
20595
|
-
return;
|
|
20596
|
-
}
|
|
20597
|
-
}
|
|
20598
|
-
// Fall back to legacy format (no transport frame)
|
|
20599
20315
|
const payload = InPageConnector.coercePayload(busMessage.payload);
|
|
20600
20316
|
if (!payload) {
|
|
20601
20317
|
logger$G.debug('inpage_payload_rejected', {
|
|
@@ -20754,27 +20470,11 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20754
20470
|
logger$G.debug('inpage_message_sending', {
|
|
20755
20471
|
channel: this.channelName,
|
|
20756
20472
|
sender_id: this.connectorId,
|
|
20757
|
-
|
|
20758
|
-
remote_node_id: this.remoteNodeId,
|
|
20759
|
-
});
|
|
20760
|
-
// Only use transport framing if both localNodeId and remoteNodeId are explicitly set
|
|
20761
|
-
// (not using default values). This ensures backwards compatibility.
|
|
20762
|
-
const useTransportFrame = this.localNodeId !== this.connectorId ||
|
|
20763
|
-
this.remoteNodeId !== '*';
|
|
20764
|
-
let payload;
|
|
20765
|
-
if (useTransportFrame) {
|
|
20766
|
-
// Wrap payload in transport frame
|
|
20767
|
-
const frame = wrapTransportFrame(data, this.localNodeId, this.remoteNodeId);
|
|
20768
|
-
payload = serializeTransportFrame(frame);
|
|
20769
|
-
}
|
|
20770
|
-
else {
|
|
20771
|
-
// Legacy format: send raw payload
|
|
20772
|
-
payload = data;
|
|
20773
|
-
}
|
|
20473
|
+
});
|
|
20774
20474
|
const event = new MessageEvent(this.channelName, {
|
|
20775
20475
|
data: {
|
|
20776
20476
|
senderId: this.connectorId,
|
|
20777
|
-
payload,
|
|
20477
|
+
payload: data,
|
|
20778
20478
|
},
|
|
20779
20479
|
});
|
|
20780
20480
|
getSharedBus$1().dispatchEvent(event);
|
|
@@ -20803,24 +20503,6 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20803
20503
|
}
|
|
20804
20504
|
return rawOrEnvelope;
|
|
20805
20505
|
}
|
|
20806
|
-
/**
|
|
20807
|
-
* Update the remote node ID after learning it from NodeAttachAck
|
|
20808
|
-
* This allows upstream connectors to switch from wildcard to specific addressing
|
|
20809
|
-
*/
|
|
20810
|
-
updateRemoteNodeId(newRemoteNodeId) {
|
|
20811
|
-
if (typeof newRemoteNodeId !== 'string' || newRemoteNodeId.trim().length === 0) {
|
|
20812
|
-
throw new Error('Invalid remote node ID');
|
|
20813
|
-
}
|
|
20814
|
-
const oldValue = this.remoteNodeId;
|
|
20815
|
-
this.remoteNodeId = newRemoteNodeId.trim();
|
|
20816
|
-
logger$G.debug('inpage_connector_remote_node_id_updated', {
|
|
20817
|
-
channel: this.channelName,
|
|
20818
|
-
connector_id: this.connectorId,
|
|
20819
|
-
local_node_id: this.localNodeId,
|
|
20820
|
-
old_remote_node_id: oldValue,
|
|
20821
|
-
new_remote_node_id: this.remoteNodeId,
|
|
20822
|
-
});
|
|
20823
|
-
}
|
|
20824
20506
|
}
|
|
20825
20507
|
|
|
20826
20508
|
const RPC_REGISTRY = Symbol('naylence.rpc.registry');
|
|
@@ -28157,14 +27839,6 @@ function isInPageConnectionGrant(candidate) {
|
|
|
28157
27839
|
record.inboxCapacity <= 0)) {
|
|
28158
27840
|
return false;
|
|
28159
27841
|
}
|
|
28160
|
-
if (record.localNodeId !== undefined &&
|
|
28161
|
-
(typeof record.localNodeId !== 'string' || record.localNodeId.length === 0)) {
|
|
28162
|
-
return false;
|
|
28163
|
-
}
|
|
28164
|
-
if (record.remoteNodeId !== undefined &&
|
|
28165
|
-
(typeof record.remoteNodeId !== 'string' || record.remoteNodeId.length === 0)) {
|
|
28166
|
-
return false;
|
|
28167
|
-
}
|
|
28168
27842
|
return true;
|
|
28169
27843
|
}
|
|
28170
27844
|
function normalizeInPageConnectionGrant(candidate) {
|
|
@@ -28198,20 +27872,6 @@ function normalizeInPageConnectionGrant(candidate) {
|
|
|
28198
27872
|
}
|
|
28199
27873
|
result.inboxCapacity = Math.floor(inboxValue);
|
|
28200
27874
|
}
|
|
28201
|
-
const localNodeIdValue = candidate.localNodeId ?? candidate['local_node_id'];
|
|
28202
|
-
if (localNodeIdValue !== undefined) {
|
|
28203
|
-
if (typeof localNodeIdValue !== 'string' || localNodeIdValue.trim().length === 0) {
|
|
28204
|
-
throw new TypeError('InPageConnectionGrant "localNodeId" must be a non-empty string when provided');
|
|
28205
|
-
}
|
|
28206
|
-
result.localNodeId = localNodeIdValue.trim();
|
|
28207
|
-
}
|
|
28208
|
-
const remoteNodeIdValue = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
28209
|
-
if (remoteNodeIdValue !== undefined) {
|
|
28210
|
-
if (typeof remoteNodeIdValue !== 'string' || remoteNodeIdValue.trim().length === 0) {
|
|
28211
|
-
throw new TypeError('InPageConnectionGrant "remoteNodeId" must be a non-empty string when provided');
|
|
28212
|
-
}
|
|
28213
|
-
result.remoteNodeId = remoteNodeIdValue.trim();
|
|
28214
|
-
}
|
|
28215
27875
|
return result;
|
|
28216
27876
|
}
|
|
28217
27877
|
function inPageGrantToConnectorConfig(grant) {
|
|
@@ -28225,12 +27885,6 @@ function inPageGrantToConnectorConfig(grant) {
|
|
|
28225
27885
|
if (normalized.inboxCapacity !== undefined) {
|
|
28226
27886
|
config.inboxCapacity = normalized.inboxCapacity;
|
|
28227
27887
|
}
|
|
28228
|
-
if (normalized.localNodeId) {
|
|
28229
|
-
config.localNodeId = normalized.localNodeId;
|
|
28230
|
-
}
|
|
28231
|
-
if (normalized.remoteNodeId) {
|
|
28232
|
-
config.remoteNodeId = normalized.remoteNodeId;
|
|
28233
|
-
}
|
|
28234
27888
|
return config;
|
|
28235
27889
|
}
|
|
28236
27890
|
|
|
@@ -28808,8 +28462,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
28808
28462
|
type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
|
|
28809
28463
|
channelName: connectorConfig.channelName,
|
|
28810
28464
|
inboxCapacity: connectorConfig.inboxCapacity,
|
|
28811
|
-
|
|
28812
|
-
remoteNodeId: connectorConfig.remoteNodeId,
|
|
28465
|
+
initialWindow: connectorConfig.initialWindow,
|
|
28813
28466
|
};
|
|
28814
28467
|
}
|
|
28815
28468
|
const config = {
|
|
@@ -28834,6 +28487,7 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
28834
28487
|
purpose: 'connection',
|
|
28835
28488
|
channelName: normalizedConfig.channelName,
|
|
28836
28489
|
inboxCapacity: normalizedConfig.inboxCapacity,
|
|
28490
|
+
initialWindow: normalizedConfig.initialWindow,
|
|
28837
28491
|
});
|
|
28838
28492
|
return grant;
|
|
28839
28493
|
}
|
|
@@ -28859,8 +28513,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
28859
28513
|
type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
|
|
28860
28514
|
channelName,
|
|
28861
28515
|
inboxCapacity,
|
|
28862
|
-
localNodeId: normalized.localNodeId,
|
|
28863
|
-
remoteNodeId: normalized.remoteNodeId,
|
|
28864
28516
|
};
|
|
28865
28517
|
const connector = new BroadcastChannelConnector(connectorConfig, baseConfig);
|
|
28866
28518
|
if (options.authorization) {
|
|
@@ -28922,16 +28574,6 @@ class BroadcastChannelConnectorFactory extends ConnectorFactory {
|
|
|
28922
28574
|
if (candidate.authorizationContext !== undefined) {
|
|
28923
28575
|
normalized.authorizationContext = candidate.authorizationContext;
|
|
28924
28576
|
}
|
|
28925
|
-
// Handle localNodeId
|
|
28926
|
-
const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
|
|
28927
|
-
if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
|
|
28928
|
-
normalized.localNodeId = localNodeId.trim();
|
|
28929
|
-
}
|
|
28930
|
-
// Handle remoteNodeId
|
|
28931
|
-
const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
28932
|
-
if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
|
|
28933
|
-
normalized.remoteNodeId = remoteNodeId.trim();
|
|
28934
|
-
}
|
|
28935
28577
|
normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$5;
|
|
28936
28578
|
normalized.inboxCapacity =
|
|
28937
28579
|
normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
|
|
@@ -29495,8 +29137,6 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
29495
29137
|
type: INPAGE_CONNECTOR_TYPE,
|
|
29496
29138
|
channelName,
|
|
29497
29139
|
inboxCapacity,
|
|
29498
|
-
localNodeId: normalized.localNodeId,
|
|
29499
|
-
remoteNodeId: normalized.remoteNodeId,
|
|
29500
29140
|
};
|
|
29501
29141
|
const connector = new InPageConnector(connectorConfig, baseConfig);
|
|
29502
29142
|
if (options.authorization) {
|
|
@@ -29565,16 +29205,6 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
29565
29205
|
if (candidate.authorizationContext !== undefined) {
|
|
29566
29206
|
normalized.authorizationContext = candidate.authorizationContext;
|
|
29567
29207
|
}
|
|
29568
|
-
// Handle localNodeId
|
|
29569
|
-
const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
|
|
29570
|
-
if (typeof localNodeId === 'string' && localNodeId.trim().length > 0) {
|
|
29571
|
-
normalized.localNodeId = localNodeId.trim();
|
|
29572
|
-
}
|
|
29573
|
-
// Handle remoteNodeId
|
|
29574
|
-
const remoteNodeId = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
29575
|
-
if (typeof remoteNodeId === 'string' && remoteNodeId.trim().length > 0) {
|
|
29576
|
-
normalized.remoteNodeId = remoteNodeId.trim();
|
|
29577
|
-
}
|
|
29578
29208
|
normalized.channelName = normalized.channelName ?? DEFAULT_CHANNEL$3;
|
|
29579
29209
|
normalized.inboxCapacity =
|
|
29580
29210
|
normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$3;
|
|
@@ -36340,18 +35970,13 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
36340
35970
|
});
|
|
36341
35971
|
}
|
|
36342
35972
|
asCallbackGrant() {
|
|
36343
|
-
|
|
35973
|
+
return this.withLegacySnakeCaseKeys({
|
|
36344
35974
|
type: BROADCAST_CHANNEL_CONNECTOR_TYPE,
|
|
36345
35975
|
connectorType: BROADCAST_CHANNEL_CONNECTOR_TYPE,
|
|
36346
35976
|
connectionGrantType: BROADCAST_CHANNEL_CONNECTION_GRANT_TYPE,
|
|
36347
35977
|
channelName: this._channelName,
|
|
36348
35978
|
inboxCapacity: this._inboxCapacity,
|
|
36349
|
-
};
|
|
36350
|
-
// Include localNodeId for transport frame multiplexing if node is available
|
|
36351
|
-
if (this._routingNode) {
|
|
36352
|
-
grant.localNodeId = this._routingNode.id;
|
|
36353
|
-
}
|
|
36354
|
-
return this.withLegacySnakeCaseKeys(grant);
|
|
35979
|
+
});
|
|
36355
35980
|
}
|
|
36356
35981
|
_registerChannelListener() {
|
|
36357
35982
|
if (this._channelHandler) {
|
|
@@ -36411,54 +36036,23 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
36411
36036
|
if (typeof senderId !== 'string' || senderId.length === 0) {
|
|
36412
36037
|
return null;
|
|
36413
36038
|
}
|
|
36414
|
-
|
|
36415
|
-
|
|
36416
|
-
|
|
36417
|
-
|
|
36418
|
-
|
|
36419
|
-
|
|
36420
|
-
// Apply listener's filtering policy: accept frames addressed to us OR with wildcard destination
|
|
36421
|
-
// Wildcard is needed because downstream nodes don't know the sentinel's ID during initial attach
|
|
36422
|
-
const isAddressedToUs = frame.dst === this._routingNode.id || frame.dst === '*';
|
|
36423
|
-
if (isAddressedToUs) {
|
|
36424
|
-
envelopePayload = frame.payload;
|
|
36425
|
-
logger$a.debug('broadcast_channel_listener_unwrapped_transport_frame', {
|
|
36426
|
-
sender_id: senderId,
|
|
36427
|
-
src: frame.src,
|
|
36428
|
-
dst: frame.dst,
|
|
36429
|
-
});
|
|
36430
|
-
}
|
|
36431
|
-
else {
|
|
36432
|
-
// Frame addressed to a different node, ignore it
|
|
36433
|
-
logger$a.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
|
|
36434
|
-
sender_id: senderId,
|
|
36435
|
-
dst: frame.dst,
|
|
36436
|
-
expected: this._routingNode.id,
|
|
36437
|
-
});
|
|
36438
|
-
return null;
|
|
36439
|
-
}
|
|
36440
|
-
}
|
|
36441
|
-
}
|
|
36442
|
-
// If not a transport frame, try to coerce as legacy format
|
|
36443
|
-
if (!envelopePayload) {
|
|
36444
|
-
envelopePayload = coercePayload$1(record.payload);
|
|
36445
|
-
if (!envelopePayload) {
|
|
36446
|
-
logger$a.debug('broadcast_channel_listener_ignored_event_without_payload', {
|
|
36447
|
-
sender_id: senderId,
|
|
36448
|
-
});
|
|
36449
|
-
return null;
|
|
36450
|
-
}
|
|
36039
|
+
const payload = coercePayload$1(record.payload);
|
|
36040
|
+
if (!payload) {
|
|
36041
|
+
logger$a.debug('broadcast_channel_listener_ignored_event_without_payload', {
|
|
36042
|
+
sender_id: senderId,
|
|
36043
|
+
});
|
|
36044
|
+
return null;
|
|
36451
36045
|
}
|
|
36452
36046
|
let envelope;
|
|
36453
36047
|
try {
|
|
36454
|
-
const decoded = new TextDecoder().decode(
|
|
36048
|
+
const decoded = new TextDecoder().decode(payload);
|
|
36455
36049
|
const parsed = JSON.parse(decoded);
|
|
36456
36050
|
envelope = deserializeEnvelope(parsed);
|
|
36457
36051
|
}
|
|
36458
36052
|
catch (error) {
|
|
36459
36053
|
const decoded = (() => {
|
|
36460
36054
|
try {
|
|
36461
|
-
return new TextDecoder().decode(
|
|
36055
|
+
return new TextDecoder().decode(payload);
|
|
36462
36056
|
}
|
|
36463
36057
|
catch {
|
|
36464
36058
|
return null;
|
|
@@ -36578,20 +36172,6 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
36578
36172
|
inboxCapacity: this._inboxCapacity,
|
|
36579
36173
|
};
|
|
36580
36174
|
}
|
|
36581
|
-
// Automatically configure transport frame multiplexing:
|
|
36582
|
-
// Use node IDs (not connector IDs) for node-to-node targeting
|
|
36583
|
-
const broadcastConfig = connectorConfig;
|
|
36584
|
-
// Always force localNodeId to be this listener's node ID
|
|
36585
|
-
// This ensures the sentinel sets localNodeId=sentinel, not the child's ID
|
|
36586
|
-
broadcastConfig.localNodeId = routingNode.id;
|
|
36587
|
-
// Always force remoteNodeId to be the attaching child's system ID
|
|
36588
|
-
broadcastConfig.remoteNodeId = systemId;
|
|
36589
|
-
logger$a.debug('broadcast_channel_listener_configured_node_ids', {
|
|
36590
|
-
sender_id: params.senderId,
|
|
36591
|
-
system_id: systemId,
|
|
36592
|
-
local_node_id: broadcastConfig.localNodeId,
|
|
36593
|
-
remote_node_id: broadcastConfig.remoteNodeId,
|
|
36594
|
-
});
|
|
36595
36175
|
try {
|
|
36596
36176
|
const connector = await routingNode.createOriginConnector({
|
|
36597
36177
|
originType,
|
|
@@ -36661,21 +36241,6 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
36661
36241
|
inboxCandidate > 0) {
|
|
36662
36242
|
config.inboxCapacity = Math.floor(inboxCandidate);
|
|
36663
36243
|
}
|
|
36664
|
-
// Extract transport frame multiplexing node IDs
|
|
36665
|
-
const localNodeIdCandidate = candidate.localNodeId ?? candidate['local_node_id'];
|
|
36666
|
-
if (typeof localNodeIdCandidate === 'string' && localNodeIdCandidate.trim().length > 0) {
|
|
36667
|
-
config.localNodeId = localNodeIdCandidate.trim();
|
|
36668
|
-
logger$a.debug('broadcast_channel_listener_extracted_local_node_id', {
|
|
36669
|
-
local_node_id: config.localNodeId,
|
|
36670
|
-
});
|
|
36671
|
-
}
|
|
36672
|
-
const remoteNodeIdCandidate = candidate.remoteNodeId ?? candidate['remote_node_id'];
|
|
36673
|
-
if (typeof remoteNodeIdCandidate === 'string' && remoteNodeIdCandidate.trim().length > 0) {
|
|
36674
|
-
config.remoteNodeId = remoteNodeIdCandidate.trim();
|
|
36675
|
-
logger$a.debug('broadcast_channel_listener_extracted_remote_node_id', {
|
|
36676
|
-
remote_node_id: config.remoteNodeId,
|
|
36677
|
-
});
|
|
36678
|
-
}
|
|
36679
36244
|
return config;
|
|
36680
36245
|
}
|
|
36681
36246
|
_monitorConnectorLifecycle(senderId, systemId, connector) {
|
|
@@ -37398,7 +36963,6 @@ class InPageListener extends TransportListener {
|
|
|
37398
36963
|
this._busHandler = null;
|
|
37399
36964
|
this._senderRegistry = new Map();
|
|
37400
36965
|
this._systemToSender = new Map();
|
|
37401
|
-
this._flowIdToSender = new Map();
|
|
37402
36966
|
this._pendingAttachments = new Map();
|
|
37403
36967
|
ensureBrowserEnvironment();
|
|
37404
36968
|
const channelCandidate = options?.channelName;
|
|
@@ -37465,7 +37029,6 @@ class InPageListener extends TransportListener {
|
|
|
37465
37029
|
this._unregisterBusListener();
|
|
37466
37030
|
this._senderRegistry.clear();
|
|
37467
37031
|
this._systemToSender.clear();
|
|
37468
|
-
this._flowIdToSender.clear();
|
|
37469
37032
|
this._pendingAttachments.clear();
|
|
37470
37033
|
logger$7.debug('inpage_listener_stopped', {
|
|
37471
37034
|
channel: this._channelName,
|
|
@@ -37519,25 +37082,10 @@ class InPageListener extends TransportListener {
|
|
|
37519
37082
|
await this._handleAttachFrame(senderId, envelope);
|
|
37520
37083
|
return;
|
|
37521
37084
|
}
|
|
37522
|
-
|
|
37523
|
-
let entry = this._senderRegistry.get(senderId);
|
|
37524
|
-
// If not found and we have a flowId, try to route based on flow
|
|
37525
|
-
if (!entry && envelope.flowId) {
|
|
37526
|
-
const originalSenderId = this._flowIdToSender.get(envelope.flowId);
|
|
37527
|
-
if (originalSenderId) {
|
|
37528
|
-
entry = this._senderRegistry.get(originalSenderId);
|
|
37529
|
-
logger$7.debug('inpage_listener_routed_by_flow_id', {
|
|
37530
|
-
sender_id: senderId,
|
|
37531
|
-
original_sender_id: originalSenderId,
|
|
37532
|
-
flow_id: envelope.flowId,
|
|
37533
|
-
frame_type: envelope.frame?.type ?? 'unknown',
|
|
37534
|
-
});
|
|
37535
|
-
}
|
|
37536
|
-
}
|
|
37085
|
+
const entry = this._senderRegistry.get(senderId);
|
|
37537
37086
|
if (!entry) {
|
|
37538
37087
|
logger$7.debug('inpage_listener_no_connector_for_sender', {
|
|
37539
37088
|
sender_id: senderId,
|
|
37540
|
-
flow_id: envelope.flowId,
|
|
37541
37089
|
frame_type: envelope.frame?.type ?? 'unknown',
|
|
37542
37090
|
});
|
|
37543
37091
|
return;
|
|
@@ -37614,15 +37162,6 @@ class InPageListener extends TransportListener {
|
|
|
37614
37162
|
}
|
|
37615
37163
|
this._senderRegistry.set(senderId, entry);
|
|
37616
37164
|
this._systemToSender.set(entry.systemId, senderId);
|
|
37617
|
-
// Track the flowId if present so we can route responses back
|
|
37618
|
-
if (envelope.flowId) {
|
|
37619
|
-
this._flowIdToSender.set(envelope.flowId, senderId);
|
|
37620
|
-
logger$7.debug('inpage_listener_registered_flow_id', {
|
|
37621
|
-
sender_id: senderId,
|
|
37622
|
-
system_id: entry.systemId,
|
|
37623
|
-
flow_id: envelope.flowId,
|
|
37624
|
-
});
|
|
37625
|
-
}
|
|
37626
37165
|
await this._deliverEnvelope(entry, envelope);
|
|
37627
37166
|
}
|
|
37628
37167
|
async _createConnectorForAttach(params) {
|
|
@@ -37670,7 +37209,7 @@ class InPageListener extends TransportListener {
|
|
|
37670
37209
|
origin_type: originType,
|
|
37671
37210
|
connector_type: connector.constructor?.name ?? 'unknown',
|
|
37672
37211
|
});
|
|
37673
|
-
return { connector, systemId, originType
|
|
37212
|
+
return { connector, systemId, originType };
|
|
37674
37213
|
}
|
|
37675
37214
|
catch (error) {
|
|
37676
37215
|
logger$7.error('inpage_listener_connector_creation_failed', {
|
|
@@ -37724,12 +37263,6 @@ class InPageListener extends TransportListener {
|
|
|
37724
37263
|
if (this._systemToSender.get(systemId) === senderId) {
|
|
37725
37264
|
this._systemToSender.delete(systemId);
|
|
37726
37265
|
}
|
|
37727
|
-
// Clean up flowId mappings for this sender
|
|
37728
|
-
for (const [flowId, sid] of this._flowIdToSender.entries()) {
|
|
37729
|
-
if (sid === senderId) {
|
|
37730
|
-
this._flowIdToSender.delete(flowId);
|
|
37731
|
-
}
|
|
37732
|
-
}
|
|
37733
37266
|
})
|
|
37734
37267
|
.catch((error) => {
|
|
37735
37268
|
logger$7.debug('inpage_listener_wait_until_closed_failed', {
|
|
@@ -37741,24 +37274,9 @@ class InPageListener extends TransportListener {
|
|
|
37741
37274
|
if (this._systemToSender.get(systemId) === senderId) {
|
|
37742
37275
|
this._systemToSender.delete(systemId);
|
|
37743
37276
|
}
|
|
37744
|
-
// Clean up flowId mappings for this sender
|
|
37745
|
-
for (const [flowId, sid] of this._flowIdToSender.entries()) {
|
|
37746
|
-
if (sid === senderId) {
|
|
37747
|
-
this._flowIdToSender.delete(flowId);
|
|
37748
|
-
}
|
|
37749
|
-
}
|
|
37750
37277
|
});
|
|
37751
37278
|
}
|
|
37752
37279
|
async _deliverEnvelope(entry, envelope) {
|
|
37753
|
-
// Track flowId for routing responses back
|
|
37754
|
-
if (envelope.flowId && !this._flowIdToSender.has(envelope.flowId)) {
|
|
37755
|
-
this._flowIdToSender.set(envelope.flowId, entry.senderId);
|
|
37756
|
-
logger$7.debug('inpage_listener_registered_flow_id_on_delivery', {
|
|
37757
|
-
sender_id: entry.senderId,
|
|
37758
|
-
system_id: entry.systemId,
|
|
37759
|
-
flow_id: envelope.flowId,
|
|
37760
|
-
});
|
|
37761
|
-
}
|
|
37762
37280
|
const message = this._buildChannelMessage({
|
|
37763
37281
|
envelope,
|
|
37764
37282
|
connector: entry.connector,
|