@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/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.951
|
|
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.951';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -9779,14 +9779,12 @@ function serializeTransportFrame(frame) {
|
|
|
9779
9779
|
return serializable;
|
|
9780
9780
|
}
|
|
9781
9781
|
/**
|
|
9782
|
-
* Unwrap a transport frame
|
|
9782
|
+
* Unwrap a transport frame (pure deserializer - no filtering)
|
|
9783
9783
|
*
|
|
9784
9784
|
* @param raw - Raw data from the bus
|
|
9785
|
-
* @
|
|
9786
|
-
* @param remoteNodeId - Expected remote node ID
|
|
9787
|
-
* @returns Unwrapped payload if frame is valid and addressed to us, null otherwise
|
|
9785
|
+
* @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
|
|
9788
9786
|
*/
|
|
9789
|
-
function unwrapTransportFrame(raw
|
|
9787
|
+
function unwrapTransportFrame(raw) {
|
|
9790
9788
|
// Validate basic structure
|
|
9791
9789
|
if (!raw || typeof raw !== 'object') {
|
|
9792
9790
|
return null;
|
|
@@ -9800,16 +9798,17 @@ function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
|
|
|
9800
9798
|
if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
|
|
9801
9799
|
return null;
|
|
9802
9800
|
}
|
|
9803
|
-
// Only accept frames addressed to us from the expected remote
|
|
9804
|
-
if (frame.dst !== localNodeId || frame.src !== remoteNodeId) {
|
|
9805
|
-
return null;
|
|
9806
|
-
}
|
|
9807
9801
|
// Extract payload
|
|
9808
9802
|
if (!frame.payload || !Array.isArray(frame.payload)) {
|
|
9809
9803
|
return null;
|
|
9810
9804
|
}
|
|
9811
|
-
// Convert array back to Uint8Array
|
|
9812
|
-
return
|
|
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
|
+
};
|
|
9813
9812
|
}
|
|
9814
9813
|
|
|
9815
9814
|
const logger$_ = getLogger('naylence.fame.connector.broadcast_channel_connector');
|
|
@@ -9924,43 +9923,64 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
9924
9923
|
return;
|
|
9925
9924
|
}
|
|
9926
9925
|
// Try to unwrap as transport frame
|
|
9927
|
-
const
|
|
9928
|
-
if (
|
|
9929
|
-
//
|
|
9930
|
-
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
|
|
9935
|
-
|
|
9936
|
-
|
|
9937
|
-
|
|
9938
|
-
|
|
9939
|
-
|
|
9940
|
-
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9944
|
-
|
|
9945
|
-
|
|
9946
|
-
|
|
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;
|
|
9947
9946
|
}
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9951
|
-
|
|
9952
|
-
|
|
9953
|
-
|
|
9954
|
-
}
|
|
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
9955
|
}
|
|
9956
|
-
|
|
9957
|
-
|
|
9958
|
-
|
|
9959
|
-
|
|
9960
|
-
|
|
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
|
+
}
|
|
9961
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;
|
|
9962
9983
|
}
|
|
9963
|
-
return;
|
|
9964
9984
|
}
|
|
9965
9985
|
// Fall back to legacy format (no transport frame)
|
|
9966
9986
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
@@ -20487,40 +20507,61 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20487
20507
|
return;
|
|
20488
20508
|
}
|
|
20489
20509
|
// Try to unwrap as transport frame
|
|
20490
|
-
const
|
|
20491
|
-
if (
|
|
20492
|
-
//
|
|
20493
|
-
|
|
20494
|
-
|
|
20495
|
-
|
|
20496
|
-
|
|
20497
|
-
|
|
20498
|
-
|
|
20499
|
-
|
|
20500
|
-
|
|
20501
|
-
|
|
20502
|
-
|
|
20503
|
-
|
|
20504
|
-
|
|
20505
|
-
|
|
20510
|
+
const frame = unwrapTransportFrame(busMessage.payload);
|
|
20511
|
+
if (frame) {
|
|
20512
|
+
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
20513
|
+
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
20514
|
+
const dstMatches = frame.dst === this.localNodeId;
|
|
20515
|
+
if (dstMatches && srcMatches) {
|
|
20516
|
+
// Successfully received and filtered transport frame
|
|
20517
|
+
logger$G.debug('inpage_transport_frame_received', {
|
|
20518
|
+
channel: this.channelName,
|
|
20519
|
+
sender_id: busMessage.senderId,
|
|
20520
|
+
connector_id: this.connectorId,
|
|
20521
|
+
local_node_id: this.localNodeId,
|
|
20522
|
+
remote_node_id: this.remoteNodeId,
|
|
20523
|
+
frame_src: frame.src,
|
|
20524
|
+
frame_dst: frame.dst,
|
|
20525
|
+
payload_length: frame.payload.byteLength,
|
|
20526
|
+
});
|
|
20527
|
+
const unwrapped = frame.payload;
|
|
20528
|
+
try {
|
|
20529
|
+
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
20530
|
+
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
20531
|
+
if (accepted) {
|
|
20532
|
+
return;
|
|
20533
|
+
}
|
|
20506
20534
|
}
|
|
20535
|
+
this.inbox.enqueue(unwrapped);
|
|
20507
20536
|
}
|
|
20508
|
-
|
|
20509
|
-
|
|
20510
|
-
|
|
20511
|
-
|
|
20512
|
-
|
|
20513
|
-
|
|
20514
|
-
|
|
20515
|
-
|
|
20516
|
-
|
|
20517
|
-
|
|
20518
|
-
|
|
20519
|
-
|
|
20520
|
-
});
|
|
20537
|
+
catch (error) {
|
|
20538
|
+
if (error instanceof QueueFullError) {
|
|
20539
|
+
logger$G.warning('inpage_receive_queue_full', {
|
|
20540
|
+
channel: this.channelName,
|
|
20541
|
+
});
|
|
20542
|
+
}
|
|
20543
|
+
else {
|
|
20544
|
+
logger$G.error('inpage_receive_error', {
|
|
20545
|
+
channel: this.channelName,
|
|
20546
|
+
error: error instanceof Error ? error.message : String(error),
|
|
20547
|
+
});
|
|
20548
|
+
}
|
|
20521
20549
|
}
|
|
20550
|
+
return;
|
|
20551
|
+
}
|
|
20552
|
+
else {
|
|
20553
|
+
// Frame filtered out by addressing rules
|
|
20554
|
+
logger$G.debug('inpage_transport_frame_filtered', {
|
|
20555
|
+
channel: this.channelName,
|
|
20556
|
+
connector_id: this.connectorId,
|
|
20557
|
+
local_node_id: this.localNodeId,
|
|
20558
|
+
remote_node_id: this.remoteNodeId,
|
|
20559
|
+
frame_src: frame.src,
|
|
20560
|
+
frame_dst: frame.dst,
|
|
20561
|
+
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
20562
|
+
});
|
|
20563
|
+
return;
|
|
20522
20564
|
}
|
|
20523
|
-
return;
|
|
20524
20565
|
}
|
|
20525
20566
|
// Fall back to legacy format (no transport frame)
|
|
20526
20567
|
const payload = InPageConnector.coercePayload(busMessage.payload);
|
|
@@ -36320,41 +36361,42 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
36320
36361
|
if (typeof senderId !== 'string' || senderId.length === 0) {
|
|
36321
36362
|
return null;
|
|
36322
36363
|
}
|
|
36323
|
-
|
|
36324
|
-
|
|
36325
|
-
|
|
36326
|
-
|
|
36327
|
-
|
|
36328
|
-
|
|
36329
|
-
|
|
36330
|
-
|
|
36331
|
-
|
|
36332
|
-
|
|
36333
|
-
|
|
36334
|
-
|
|
36335
|
-
|
|
36336
|
-
|
|
36337
|
-
|
|
36338
|
-
|
|
36339
|
-
//
|
|
36340
|
-
|
|
36341
|
-
|
|
36342
|
-
|
|
36343
|
-
|
|
36344
|
-
|
|
36345
|
-
|
|
36346
|
-
dst: frame.dst,
|
|
36347
|
-
});
|
|
36348
|
-
}
|
|
36349
|
-
}
|
|
36364
|
+
// Check if payload is a transport frame object first
|
|
36365
|
+
let envelopePayload = null;
|
|
36366
|
+
if (this._routingNode && record.payload && typeof record.payload === 'object') {
|
|
36367
|
+
// Try to unwrap as transport frame
|
|
36368
|
+
const frame = unwrapTransportFrame(record.payload);
|
|
36369
|
+
if (frame) {
|
|
36370
|
+
// Apply listener's filtering policy: dst must match, src can be anything
|
|
36371
|
+
if (frame.dst === this._routingNode.id) {
|
|
36372
|
+
envelopePayload = frame.payload;
|
|
36373
|
+
logger$a.debug('broadcast_channel_listener_unwrapped_transport_frame', {
|
|
36374
|
+
sender_id: senderId,
|
|
36375
|
+
src: frame.src,
|
|
36376
|
+
dst: frame.dst,
|
|
36377
|
+
});
|
|
36378
|
+
}
|
|
36379
|
+
else {
|
|
36380
|
+
// Frame not addressed to us, ignore it
|
|
36381
|
+
logger$a.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
|
|
36382
|
+
sender_id: senderId,
|
|
36383
|
+
dst: frame.dst,
|
|
36384
|
+
expected: this._routingNode.id,
|
|
36385
|
+
});
|
|
36386
|
+
return null;
|
|
36350
36387
|
}
|
|
36351
36388
|
}
|
|
36352
|
-
|
|
36353
|
-
|
|
36389
|
+
}
|
|
36390
|
+
// If not a transport frame, try to coerce as legacy format
|
|
36391
|
+
if (!envelopePayload) {
|
|
36392
|
+
envelopePayload = coercePayload$1(record.payload);
|
|
36393
|
+
if (!envelopePayload) {
|
|
36394
|
+
logger$a.debug('broadcast_channel_listener_ignored_event_without_payload', {
|
|
36395
|
+
sender_id: senderId,
|
|
36396
|
+
});
|
|
36397
|
+
return null;
|
|
36354
36398
|
}
|
|
36355
36399
|
}
|
|
36356
|
-
// Use unwrapped payload if available, otherwise use raw payload
|
|
36357
|
-
const envelopePayload = unwrapped ?? payload;
|
|
36358
36400
|
let envelope;
|
|
36359
36401
|
try {
|
|
36360
36402
|
const decoded = new TextDecoder().decode(envelopePayload);
|
|
@@ -36364,7 +36406,7 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
36364
36406
|
catch (error) {
|
|
36365
36407
|
const decoded = (() => {
|
|
36366
36408
|
try {
|
|
36367
|
-
return new TextDecoder().decode(
|
|
36409
|
+
return new TextDecoder().decode(envelopePayload);
|
|
36368
36410
|
}
|
|
36369
36411
|
catch {
|
|
36370
36412
|
return null;
|