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