@naylence/runtime 0.3.5-test.950 → 0.3.5-test.951
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 +150 -108
- package/dist/browser/index.mjs +150 -108
- package/dist/cjs/naylence/fame/connector/broadcast-channel-connector.browser.js +54 -33
- package/dist/cjs/naylence/fame/connector/broadcast-channel-listener.js +33 -32
- package/dist/cjs/naylence/fame/connector/inpage-connector.js +51 -30
- package/dist/cjs/naylence/fame/connector/transport-frame.js +10 -11
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/connector/broadcast-channel-connector.browser.js +54 -33
- package/dist/esm/naylence/fame/connector/broadcast-channel-listener.js +33 -32
- package/dist/esm/naylence/fame/connector/inpage-connector.js +51 -30
- package/dist/esm/naylence/fame/connector/transport-frame.js +10 -11
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +150 -108
- package/dist/node/index.mjs +150 -108
- package/dist/node/node.cjs +150 -108
- package/dist/node/node.mjs +150 -108
- package/dist/types/naylence/fame/connector/transport-frame.d.ts +3 -5
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
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.951
|
|
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.951';
|
|
105
105
|
|
|
106
106
|
/**
|
|
107
107
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -9862,14 +9862,12 @@ function serializeTransportFrame(frame) {
|
|
|
9862
9862
|
return serializable;
|
|
9863
9863
|
}
|
|
9864
9864
|
/**
|
|
9865
|
-
* Unwrap a transport frame
|
|
9865
|
+
* Unwrap a transport frame (pure deserializer - no filtering)
|
|
9866
9866
|
*
|
|
9867
9867
|
* @param raw - Raw data from the bus
|
|
9868
|
-
* @
|
|
9869
|
-
* @param remoteNodeId - Expected remote node ID
|
|
9870
|
-
* @returns Unwrapped payload if frame is valid and addressed to us, null otherwise
|
|
9868
|
+
* @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
|
|
9871
9869
|
*/
|
|
9872
|
-
function unwrapTransportFrame(raw
|
|
9870
|
+
function unwrapTransportFrame(raw) {
|
|
9873
9871
|
// Validate basic structure
|
|
9874
9872
|
if (!raw || typeof raw !== 'object') {
|
|
9875
9873
|
return null;
|
|
@@ -9883,16 +9881,17 @@ function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
|
|
|
9883
9881
|
if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
|
|
9884
9882
|
return null;
|
|
9885
9883
|
}
|
|
9886
|
-
// Only accept frames addressed to us from the expected remote
|
|
9887
|
-
if (frame.dst !== localNodeId || frame.src !== remoteNodeId) {
|
|
9888
|
-
return null;
|
|
9889
|
-
}
|
|
9890
9884
|
// Extract payload
|
|
9891
9885
|
if (!frame.payload || !Array.isArray(frame.payload)) {
|
|
9892
9886
|
return null;
|
|
9893
9887
|
}
|
|
9894
|
-
// Convert array back to Uint8Array
|
|
9895
|
-
return
|
|
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
|
+
};
|
|
9896
9895
|
}
|
|
9897
9896
|
|
|
9898
9897
|
const logger$_ = getLogger('naylence.fame.connector.broadcast_channel_connector');
|
|
@@ -10007,43 +10006,64 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
10007
10006
|
return;
|
|
10008
10007
|
}
|
|
10009
10008
|
// Try to unwrap as transport frame
|
|
10010
|
-
const
|
|
10011
|
-
if (
|
|
10012
|
-
//
|
|
10013
|
-
|
|
10014
|
-
|
|
10015
|
-
|
|
10016
|
-
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10020
|
-
|
|
10021
|
-
|
|
10022
|
-
|
|
10023
|
-
|
|
10024
|
-
|
|
10025
|
-
|
|
10026
|
-
|
|
10027
|
-
|
|
10028
|
-
|
|
10029
|
-
|
|
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;
|
|
10030
10029
|
}
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
}
|
|
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
10038
|
}
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
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
|
+
}
|
|
10044
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;
|
|
10045
10066
|
}
|
|
10046
|
-
return;
|
|
10047
10067
|
}
|
|
10048
10068
|
// Fall back to legacy format (no transport frame)
|
|
10049
10069
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
@@ -20570,40 +20590,61 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20570
20590
|
return;
|
|
20571
20591
|
}
|
|
20572
20592
|
// Try to unwrap as transport frame
|
|
20573
|
-
const
|
|
20574
|
-
if (
|
|
20575
|
-
//
|
|
20576
|
-
|
|
20577
|
-
|
|
20578
|
-
|
|
20579
|
-
|
|
20580
|
-
|
|
20581
|
-
|
|
20582
|
-
|
|
20583
|
-
|
|
20584
|
-
|
|
20585
|
-
|
|
20586
|
-
|
|
20587
|
-
|
|
20588
|
-
|
|
20593
|
+
const frame = unwrapTransportFrame(busMessage.payload);
|
|
20594
|
+
if (frame) {
|
|
20595
|
+
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
20596
|
+
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
20597
|
+
const dstMatches = frame.dst === this.localNodeId;
|
|
20598
|
+
if (dstMatches && srcMatches) {
|
|
20599
|
+
// Successfully received and filtered transport frame
|
|
20600
|
+
logger$G.debug('inpage_transport_frame_received', {
|
|
20601
|
+
channel: this.channelName,
|
|
20602
|
+
sender_id: busMessage.senderId,
|
|
20603
|
+
connector_id: this.connectorId,
|
|
20604
|
+
local_node_id: this.localNodeId,
|
|
20605
|
+
remote_node_id: this.remoteNodeId,
|
|
20606
|
+
frame_src: frame.src,
|
|
20607
|
+
frame_dst: frame.dst,
|
|
20608
|
+
payload_length: frame.payload.byteLength,
|
|
20609
|
+
});
|
|
20610
|
+
const unwrapped = frame.payload;
|
|
20611
|
+
try {
|
|
20612
|
+
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
20613
|
+
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
20614
|
+
if (accepted) {
|
|
20615
|
+
return;
|
|
20616
|
+
}
|
|
20589
20617
|
}
|
|
20618
|
+
this.inbox.enqueue(unwrapped);
|
|
20590
20619
|
}
|
|
20591
|
-
|
|
20592
|
-
|
|
20593
|
-
|
|
20594
|
-
|
|
20595
|
-
|
|
20596
|
-
|
|
20597
|
-
|
|
20598
|
-
|
|
20599
|
-
|
|
20600
|
-
|
|
20601
|
-
|
|
20602
|
-
|
|
20603
|
-
});
|
|
20620
|
+
catch (error) {
|
|
20621
|
+
if (error instanceof QueueFullError) {
|
|
20622
|
+
logger$G.warning('inpage_receive_queue_full', {
|
|
20623
|
+
channel: this.channelName,
|
|
20624
|
+
});
|
|
20625
|
+
}
|
|
20626
|
+
else {
|
|
20627
|
+
logger$G.error('inpage_receive_error', {
|
|
20628
|
+
channel: this.channelName,
|
|
20629
|
+
error: error instanceof Error ? error.message : String(error),
|
|
20630
|
+
});
|
|
20631
|
+
}
|
|
20604
20632
|
}
|
|
20633
|
+
return;
|
|
20634
|
+
}
|
|
20635
|
+
else {
|
|
20636
|
+
// Frame filtered out by addressing rules
|
|
20637
|
+
logger$G.debug('inpage_transport_frame_filtered', {
|
|
20638
|
+
channel: this.channelName,
|
|
20639
|
+
connector_id: this.connectorId,
|
|
20640
|
+
local_node_id: this.localNodeId,
|
|
20641
|
+
remote_node_id: this.remoteNodeId,
|
|
20642
|
+
frame_src: frame.src,
|
|
20643
|
+
frame_dst: frame.dst,
|
|
20644
|
+
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
20645
|
+
});
|
|
20646
|
+
return;
|
|
20605
20647
|
}
|
|
20606
|
-
return;
|
|
20607
20648
|
}
|
|
20608
20649
|
// Fall back to legacy format (no transport frame)
|
|
20609
20650
|
const payload = InPageConnector.coercePayload(busMessage.payload);
|
|
@@ -30138,41 +30179,42 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
30138
30179
|
if (typeof senderId !== 'string' || senderId.length === 0) {
|
|
30139
30180
|
return null;
|
|
30140
30181
|
}
|
|
30141
|
-
|
|
30142
|
-
|
|
30143
|
-
|
|
30144
|
-
|
|
30145
|
-
|
|
30146
|
-
|
|
30147
|
-
|
|
30148
|
-
|
|
30149
|
-
|
|
30150
|
-
|
|
30151
|
-
|
|
30152
|
-
|
|
30153
|
-
|
|
30154
|
-
|
|
30155
|
-
|
|
30156
|
-
|
|
30157
|
-
//
|
|
30158
|
-
|
|
30159
|
-
|
|
30160
|
-
|
|
30161
|
-
|
|
30162
|
-
|
|
30163
|
-
|
|
30164
|
-
dst: frame.dst,
|
|
30165
|
-
});
|
|
30166
|
-
}
|
|
30167
|
-
}
|
|
30182
|
+
// Check if payload is a transport frame object first
|
|
30183
|
+
let envelopePayload = null;
|
|
30184
|
+
if (this._routingNode && record.payload && typeof record.payload === 'object') {
|
|
30185
|
+
// Try to unwrap as transport frame
|
|
30186
|
+
const frame = unwrapTransportFrame(record.payload);
|
|
30187
|
+
if (frame) {
|
|
30188
|
+
// Apply listener's filtering policy: dst must match, src can be anything
|
|
30189
|
+
if (frame.dst === this._routingNode.id) {
|
|
30190
|
+
envelopePayload = frame.payload;
|
|
30191
|
+
logger$o.debug('broadcast_channel_listener_unwrapped_transport_frame', {
|
|
30192
|
+
sender_id: senderId,
|
|
30193
|
+
src: frame.src,
|
|
30194
|
+
dst: frame.dst,
|
|
30195
|
+
});
|
|
30196
|
+
}
|
|
30197
|
+
else {
|
|
30198
|
+
// Frame not addressed to us, ignore it
|
|
30199
|
+
logger$o.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
|
|
30200
|
+
sender_id: senderId,
|
|
30201
|
+
dst: frame.dst,
|
|
30202
|
+
expected: this._routingNode.id,
|
|
30203
|
+
});
|
|
30204
|
+
return null;
|
|
30168
30205
|
}
|
|
30169
30206
|
}
|
|
30170
|
-
|
|
30171
|
-
|
|
30207
|
+
}
|
|
30208
|
+
// If not a transport frame, try to coerce as legacy format
|
|
30209
|
+
if (!envelopePayload) {
|
|
30210
|
+
envelopePayload = coercePayload(record.payload);
|
|
30211
|
+
if (!envelopePayload) {
|
|
30212
|
+
logger$o.debug('broadcast_channel_listener_ignored_event_without_payload', {
|
|
30213
|
+
sender_id: senderId,
|
|
30214
|
+
});
|
|
30215
|
+
return null;
|
|
30172
30216
|
}
|
|
30173
30217
|
}
|
|
30174
|
-
// Use unwrapped payload if available, otherwise use raw payload
|
|
30175
|
-
const envelopePayload = unwrapped ?? payload;
|
|
30176
30218
|
let envelope;
|
|
30177
30219
|
try {
|
|
30178
30220
|
const decoded = new TextDecoder().decode(envelopePayload);
|
|
@@ -30182,7 +30224,7 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
30182
30224
|
catch (error) {
|
|
30183
30225
|
const decoded = (() => {
|
|
30184
30226
|
try {
|
|
30185
|
-
return new TextDecoder().decode(
|
|
30227
|
+
return new TextDecoder().decode(envelopePayload);
|
|
30186
30228
|
}
|
|
30187
30229
|
catch {
|
|
30188
30230
|
return null;
|
|
@@ -119,43 +119,64 @@ class BroadcastChannelConnector extends base_async_connector_js_1.BaseAsyncConne
|
|
|
119
119
|
return;
|
|
120
120
|
}
|
|
121
121
|
// Try to unwrap as transport frame
|
|
122
|
-
const
|
|
123
|
-
if (
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
122
|
+
const frame = (0, transport_frame_js_1.unwrapTransportFrame)(busMessage.payload);
|
|
123
|
+
if (frame) {
|
|
124
|
+
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
125
|
+
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
126
|
+
const dstMatches = frame.dst === this.localNodeId;
|
|
127
|
+
if (dstMatches && srcMatches) {
|
|
128
|
+
// Successfully received and filtered transport frame
|
|
129
|
+
logger.debug('broadcast_channel_transport_frame_received', {
|
|
130
|
+
channel: this.channelName,
|
|
131
|
+
sender_id: busMessage.senderId,
|
|
132
|
+
connector_id: this.connectorId,
|
|
133
|
+
local_node_id: this.localNodeId,
|
|
134
|
+
remote_node_id: this.remoteNodeId,
|
|
135
|
+
frame_src: frame.src,
|
|
136
|
+
frame_dst: frame.dst,
|
|
137
|
+
payload_length: frame.payload.byteLength,
|
|
138
|
+
});
|
|
139
|
+
const unwrapped = frame.payload;
|
|
140
|
+
if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
|
|
141
|
+
return;
|
|
142
142
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
143
|
+
try {
|
|
144
|
+
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
145
|
+
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
146
|
+
if (accepted) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
this.inbox.enqueue(unwrapped);
|
|
150
151
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
catch (error) {
|
|
153
|
+
if (error instanceof bounded_async_queue_js_1.QueueFullError) {
|
|
154
|
+
logger.warning('broadcast_channel_receive_queue_full', {
|
|
155
|
+
channel: this.channelName,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
logger.error('broadcast_channel_receive_error', {
|
|
160
|
+
channel: this.channelName,
|
|
161
|
+
error: error instanceof Error ? error.message : String(error),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
156
164
|
}
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
// Frame filtered out by addressing rules
|
|
169
|
+
logger.debug('broadcast_channel_transport_frame_filtered', {
|
|
170
|
+
channel: this.channelName,
|
|
171
|
+
connector_id: this.connectorId,
|
|
172
|
+
local_node_id: this.localNodeId,
|
|
173
|
+
remote_node_id: this.remoteNodeId,
|
|
174
|
+
frame_src: frame.src,
|
|
175
|
+
frame_dst: frame.dst,
|
|
176
|
+
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
177
|
+
});
|
|
178
|
+
return;
|
|
157
179
|
}
|
|
158
|
-
return;
|
|
159
180
|
}
|
|
160
181
|
// Fall back to legacy format (no transport frame)
|
|
161
182
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
@@ -214,41 +214,42 @@ class BroadcastChannelListener extends transport_listener_js_1.TransportListener
|
|
|
214
214
|
if (typeof senderId !== 'string' || senderId.length === 0) {
|
|
215
215
|
return null;
|
|
216
216
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
//
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
dst: frame.dst,
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
}
|
|
217
|
+
// Check if payload is a transport frame object first
|
|
218
|
+
let envelopePayload = null;
|
|
219
|
+
if (this._routingNode && record.payload && typeof record.payload === 'object') {
|
|
220
|
+
// Try to unwrap as transport frame
|
|
221
|
+
const frame = (0, transport_frame_js_1.unwrapTransportFrame)(record.payload);
|
|
222
|
+
if (frame) {
|
|
223
|
+
// Apply listener's filtering policy: dst must match, src can be anything
|
|
224
|
+
if (frame.dst === this._routingNode.id) {
|
|
225
|
+
envelopePayload = frame.payload;
|
|
226
|
+
logger.debug('broadcast_channel_listener_unwrapped_transport_frame', {
|
|
227
|
+
sender_id: senderId,
|
|
228
|
+
src: frame.src,
|
|
229
|
+
dst: frame.dst,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
// Frame not addressed to us, ignore it
|
|
234
|
+
logger.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
|
|
235
|
+
sender_id: senderId,
|
|
236
|
+
dst: frame.dst,
|
|
237
|
+
expected: this._routingNode.id,
|
|
238
|
+
});
|
|
239
|
+
return null;
|
|
244
240
|
}
|
|
245
241
|
}
|
|
246
|
-
|
|
247
|
-
|
|
242
|
+
}
|
|
243
|
+
// If not a transport frame, try to coerce as legacy format
|
|
244
|
+
if (!envelopePayload) {
|
|
245
|
+
envelopePayload = coercePayload(record.payload);
|
|
246
|
+
if (!envelopePayload) {
|
|
247
|
+
logger.debug('broadcast_channel_listener_ignored_event_without_payload', {
|
|
248
|
+
sender_id: senderId,
|
|
249
|
+
});
|
|
250
|
+
return null;
|
|
248
251
|
}
|
|
249
252
|
}
|
|
250
|
-
// Use unwrapped payload if available, otherwise use raw payload
|
|
251
|
-
const envelopePayload = unwrapped ?? payload;
|
|
252
253
|
let envelope;
|
|
253
254
|
try {
|
|
254
255
|
const decoded = new TextDecoder().decode(envelopePayload);
|
|
@@ -258,7 +259,7 @@ class BroadcastChannelListener extends transport_listener_js_1.TransportListener
|
|
|
258
259
|
catch (error) {
|
|
259
260
|
const decoded = (() => {
|
|
260
261
|
try {
|
|
261
|
-
return new TextDecoder().decode(
|
|
262
|
+
return new TextDecoder().decode(envelopePayload);
|
|
262
263
|
}
|
|
263
264
|
catch {
|
|
264
265
|
return null;
|
|
@@ -129,40 +129,61 @@ class InPageConnector extends base_async_connector_js_1.BaseAsyncConnector {
|
|
|
129
129
|
return;
|
|
130
130
|
}
|
|
131
131
|
// Try to unwrap as transport frame
|
|
132
|
-
const
|
|
133
|
-
if (
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
132
|
+
const frame = (0, transport_frame_js_1.unwrapTransportFrame)(busMessage.payload);
|
|
133
|
+
if (frame) {
|
|
134
|
+
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
135
|
+
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
136
|
+
const dstMatches = frame.dst === this.localNodeId;
|
|
137
|
+
if (dstMatches && srcMatches) {
|
|
138
|
+
// Successfully received and filtered transport frame
|
|
139
|
+
logger.debug('inpage_transport_frame_received', {
|
|
140
|
+
channel: this.channelName,
|
|
141
|
+
sender_id: busMessage.senderId,
|
|
142
|
+
connector_id: this.connectorId,
|
|
143
|
+
local_node_id: this.localNodeId,
|
|
144
|
+
remote_node_id: this.remoteNodeId,
|
|
145
|
+
frame_src: frame.src,
|
|
146
|
+
frame_dst: frame.dst,
|
|
147
|
+
payload_length: frame.payload.byteLength,
|
|
148
|
+
});
|
|
149
|
+
const unwrapped = frame.payload;
|
|
150
|
+
try {
|
|
151
|
+
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
152
|
+
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
153
|
+
if (accepted) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
148
156
|
}
|
|
157
|
+
this.inbox.enqueue(unwrapped);
|
|
149
158
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
159
|
+
catch (error) {
|
|
160
|
+
if (error instanceof bounded_async_queue_js_1.QueueFullError) {
|
|
161
|
+
logger.warning('inpage_receive_queue_full', {
|
|
162
|
+
channel: this.channelName,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
logger.error('inpage_receive_error', {
|
|
167
|
+
channel: this.channelName,
|
|
168
|
+
error: error instanceof Error ? error.message : String(error),
|
|
169
|
+
});
|
|
170
|
+
}
|
|
163
171
|
}
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
// Frame filtered out by addressing rules
|
|
176
|
+
logger.debug('inpage_transport_frame_filtered', {
|
|
177
|
+
channel: this.channelName,
|
|
178
|
+
connector_id: this.connectorId,
|
|
179
|
+
local_node_id: this.localNodeId,
|
|
180
|
+
remote_node_id: this.remoteNodeId,
|
|
181
|
+
frame_src: frame.src,
|
|
182
|
+
frame_dst: frame.dst,
|
|
183
|
+
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
184
|
+
});
|
|
185
|
+
return;
|
|
164
186
|
}
|
|
165
|
-
return;
|
|
166
187
|
}
|
|
167
188
|
// Fall back to legacy format (no transport frame)
|
|
168
189
|
const payload = InPageConnector.coercePayload(busMessage.payload);
|