@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/node.mjs
CHANGED
|
@@ -5477,12 +5477,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
|
|
|
5477
5477
|
}
|
|
5478
5478
|
|
|
5479
5479
|
// This file is auto-generated during build - do not edit manually
|
|
5480
|
-
// Generated from package.json version: 0.3.5-test.
|
|
5480
|
+
// Generated from package.json version: 0.3.5-test.952
|
|
5481
5481
|
/**
|
|
5482
5482
|
* The package version, injected at build time.
|
|
5483
5483
|
* @internal
|
|
5484
5484
|
*/
|
|
5485
|
-
const VERSION = '0.3.5-test.
|
|
5485
|
+
const VERSION = '0.3.5-test.952';
|
|
5486
5486
|
|
|
5487
5487
|
/**
|
|
5488
5488
|
* Fame errors module - Fame protocol specific error classes
|
|
@@ -11516,14 +11516,12 @@ function serializeTransportFrame(frame) {
|
|
|
11516
11516
|
return serializable;
|
|
11517
11517
|
}
|
|
11518
11518
|
/**
|
|
11519
|
-
* Unwrap a transport frame
|
|
11519
|
+
* Unwrap a transport frame (pure deserializer - no filtering)
|
|
11520
11520
|
*
|
|
11521
11521
|
* @param raw - Raw data from the bus
|
|
11522
|
-
* @
|
|
11523
|
-
* @param remoteNodeId - Expected remote node ID
|
|
11524
|
-
* @returns Unwrapped payload if frame is valid and addressed to us, null otherwise
|
|
11522
|
+
* @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
|
|
11525
11523
|
*/
|
|
11526
|
-
function unwrapTransportFrame(raw
|
|
11524
|
+
function unwrapTransportFrame(raw) {
|
|
11527
11525
|
// Validate basic structure
|
|
11528
11526
|
if (!raw || typeof raw !== 'object') {
|
|
11529
11527
|
return null;
|
|
@@ -11537,16 +11535,17 @@ function unwrapTransportFrame(raw, localNodeId, remoteNodeId) {
|
|
|
11537
11535
|
if (typeof frame.src !== 'string' || typeof frame.dst !== 'string') {
|
|
11538
11536
|
return null;
|
|
11539
11537
|
}
|
|
11540
|
-
// Only accept frames addressed to us from the expected remote
|
|
11541
|
-
if (frame.dst !== localNodeId || frame.src !== remoteNodeId) {
|
|
11542
|
-
return null;
|
|
11543
|
-
}
|
|
11544
11538
|
// Extract payload
|
|
11545
11539
|
if (!frame.payload || !Array.isArray(frame.payload)) {
|
|
11546
11540
|
return null;
|
|
11547
11541
|
}
|
|
11548
|
-
// Convert array back to Uint8Array
|
|
11549
|
-
return
|
|
11542
|
+
// Convert array back to Uint8Array and return full frame
|
|
11543
|
+
return {
|
|
11544
|
+
v: frame.v,
|
|
11545
|
+
src: frame.src,
|
|
11546
|
+
dst: frame.dst,
|
|
11547
|
+
payload: Uint8Array.from(frame.payload),
|
|
11548
|
+
};
|
|
11550
11549
|
}
|
|
11551
11550
|
/**
|
|
11552
11551
|
* Check if raw data looks like a transport frame
|
|
@@ -11677,43 +11676,64 @@ let BroadcastChannelConnector$2 = class BroadcastChannelConnector extends BaseAs
|
|
|
11677
11676
|
return;
|
|
11678
11677
|
}
|
|
11679
11678
|
// Try to unwrap as transport frame
|
|
11680
|
-
const
|
|
11681
|
-
if (
|
|
11682
|
-
//
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
|
|
11694
|
-
|
|
11695
|
-
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11679
|
+
const frame = unwrapTransportFrame(busMessage.payload);
|
|
11680
|
+
if (frame) {
|
|
11681
|
+
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
11682
|
+
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
11683
|
+
const dstMatches = frame.dst === this.localNodeId;
|
|
11684
|
+
if (dstMatches && srcMatches) {
|
|
11685
|
+
// Successfully received and filtered transport frame
|
|
11686
|
+
logger$10.debug('broadcast_channel_transport_frame_received', {
|
|
11687
|
+
channel: this.channelName,
|
|
11688
|
+
sender_id: busMessage.senderId,
|
|
11689
|
+
connector_id: this.connectorId,
|
|
11690
|
+
local_node_id: this.localNodeId,
|
|
11691
|
+
remote_node_id: this.remoteNodeId,
|
|
11692
|
+
frame_src: frame.src,
|
|
11693
|
+
frame_dst: frame.dst,
|
|
11694
|
+
payload_length: frame.payload.byteLength,
|
|
11695
|
+
});
|
|
11696
|
+
const unwrapped = frame.payload;
|
|
11697
|
+
if (this._shouldSkipDuplicateAck(busMessage.senderId, unwrapped)) {
|
|
11698
|
+
return;
|
|
11700
11699
|
}
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11705
|
-
|
|
11706
|
-
|
|
11707
|
-
}
|
|
11700
|
+
try {
|
|
11701
|
+
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
11702
|
+
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
11703
|
+
if (accepted) {
|
|
11704
|
+
return;
|
|
11705
|
+
}
|
|
11706
|
+
}
|
|
11707
|
+
this.inbox.enqueue(unwrapped);
|
|
11708
11708
|
}
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
|
|
11713
|
-
|
|
11709
|
+
catch (error) {
|
|
11710
|
+
if (error instanceof QueueFullError) {
|
|
11711
|
+
logger$10.warning('broadcast_channel_receive_queue_full', {
|
|
11712
|
+
channel: this.channelName,
|
|
11713
|
+
});
|
|
11714
|
+
}
|
|
11715
|
+
else {
|
|
11716
|
+
logger$10.error('broadcast_channel_receive_error', {
|
|
11717
|
+
channel: this.channelName,
|
|
11718
|
+
error: error instanceof Error ? error.message : String(error),
|
|
11719
|
+
});
|
|
11720
|
+
}
|
|
11714
11721
|
}
|
|
11722
|
+
return;
|
|
11723
|
+
}
|
|
11724
|
+
else {
|
|
11725
|
+
// Frame filtered out by addressing rules
|
|
11726
|
+
logger$10.debug('broadcast_channel_transport_frame_filtered', {
|
|
11727
|
+
channel: this.channelName,
|
|
11728
|
+
connector_id: this.connectorId,
|
|
11729
|
+
local_node_id: this.localNodeId,
|
|
11730
|
+
remote_node_id: this.remoteNodeId,
|
|
11731
|
+
frame_src: frame.src,
|
|
11732
|
+
frame_dst: frame.dst,
|
|
11733
|
+
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
11734
|
+
});
|
|
11735
|
+
return;
|
|
11715
11736
|
}
|
|
11716
|
-
return;
|
|
11717
11737
|
}
|
|
11718
11738
|
// Fall back to legacy format (no transport frame)
|
|
11719
11739
|
const payload = BroadcastChannelConnector.coercePayload(busMessage.payload);
|
|
@@ -21681,40 +21701,61 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
21681
21701
|
return;
|
|
21682
21702
|
}
|
|
21683
21703
|
// Try to unwrap as transport frame
|
|
21684
|
-
const
|
|
21685
|
-
if (
|
|
21686
|
-
//
|
|
21687
|
-
|
|
21688
|
-
|
|
21689
|
-
|
|
21690
|
-
|
|
21691
|
-
|
|
21692
|
-
|
|
21693
|
-
|
|
21694
|
-
|
|
21695
|
-
|
|
21696
|
-
|
|
21697
|
-
|
|
21698
|
-
|
|
21699
|
-
|
|
21704
|
+
const frame = unwrapTransportFrame(busMessage.payload);
|
|
21705
|
+
if (frame) {
|
|
21706
|
+
// Apply connector's filtering policy: strict dst check, src accepts wildcard
|
|
21707
|
+
const srcMatches = this.remoteNodeId === '*' || frame.src === this.remoteNodeId;
|
|
21708
|
+
const dstMatches = frame.dst === this.localNodeId;
|
|
21709
|
+
if (dstMatches && srcMatches) {
|
|
21710
|
+
// Successfully received and filtered transport frame
|
|
21711
|
+
logger$J.debug('inpage_transport_frame_received', {
|
|
21712
|
+
channel: this.channelName,
|
|
21713
|
+
sender_id: busMessage.senderId,
|
|
21714
|
+
connector_id: this.connectorId,
|
|
21715
|
+
local_node_id: this.localNodeId,
|
|
21716
|
+
remote_node_id: this.remoteNodeId,
|
|
21717
|
+
frame_src: frame.src,
|
|
21718
|
+
frame_dst: frame.dst,
|
|
21719
|
+
payload_length: frame.payload.byteLength,
|
|
21720
|
+
});
|
|
21721
|
+
const unwrapped = frame.payload;
|
|
21722
|
+
try {
|
|
21723
|
+
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
21724
|
+
const accepted = this.inbox.tryEnqueue(unwrapped);
|
|
21725
|
+
if (accepted) {
|
|
21726
|
+
return;
|
|
21727
|
+
}
|
|
21700
21728
|
}
|
|
21729
|
+
this.inbox.enqueue(unwrapped);
|
|
21701
21730
|
}
|
|
21702
|
-
|
|
21703
|
-
|
|
21704
|
-
|
|
21705
|
-
|
|
21706
|
-
|
|
21707
|
-
|
|
21708
|
-
|
|
21709
|
-
|
|
21710
|
-
|
|
21711
|
-
|
|
21712
|
-
|
|
21713
|
-
|
|
21714
|
-
});
|
|
21731
|
+
catch (error) {
|
|
21732
|
+
if (error instanceof QueueFullError) {
|
|
21733
|
+
logger$J.warning('inpage_receive_queue_full', {
|
|
21734
|
+
channel: this.channelName,
|
|
21735
|
+
});
|
|
21736
|
+
}
|
|
21737
|
+
else {
|
|
21738
|
+
logger$J.error('inpage_receive_error', {
|
|
21739
|
+
channel: this.channelName,
|
|
21740
|
+
error: error instanceof Error ? error.message : String(error),
|
|
21741
|
+
});
|
|
21742
|
+
}
|
|
21715
21743
|
}
|
|
21744
|
+
return;
|
|
21745
|
+
}
|
|
21746
|
+
else {
|
|
21747
|
+
// Frame filtered out by addressing rules
|
|
21748
|
+
logger$J.debug('inpage_transport_frame_filtered', {
|
|
21749
|
+
channel: this.channelName,
|
|
21750
|
+
connector_id: this.connectorId,
|
|
21751
|
+
local_node_id: this.localNodeId,
|
|
21752
|
+
remote_node_id: this.remoteNodeId,
|
|
21753
|
+
frame_src: frame.src,
|
|
21754
|
+
frame_dst: frame.dst,
|
|
21755
|
+
reason: !dstMatches ? 'wrong_destination' : 'wrong_source',
|
|
21756
|
+
});
|
|
21757
|
+
return;
|
|
21716
21758
|
}
|
|
21717
|
-
return;
|
|
21718
21759
|
}
|
|
21719
21760
|
// Fall back to legacy format (no transport frame)
|
|
21720
21761
|
const payload = InPageConnector.coercePayload(busMessage.payload);
|
|
@@ -32896,41 +32937,44 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
32896
32937
|
if (typeof senderId !== 'string' || senderId.length === 0) {
|
|
32897
32938
|
return null;
|
|
32898
32939
|
}
|
|
32899
|
-
|
|
32900
|
-
|
|
32901
|
-
|
|
32902
|
-
|
|
32903
|
-
|
|
32904
|
-
|
|
32905
|
-
|
|
32906
|
-
|
|
32907
|
-
|
|
32908
|
-
|
|
32909
|
-
|
|
32910
|
-
|
|
32911
|
-
|
|
32912
|
-
|
|
32913
|
-
|
|
32914
|
-
|
|
32915
|
-
|
|
32916
|
-
|
|
32917
|
-
|
|
32918
|
-
|
|
32919
|
-
|
|
32920
|
-
|
|
32921
|
-
|
|
32922
|
-
|
|
32923
|
-
|
|
32924
|
-
}
|
|
32925
|
-
}
|
|
32940
|
+
// Check if payload is a transport frame object first
|
|
32941
|
+
let envelopePayload = null;
|
|
32942
|
+
if (this._routingNode && record.payload && typeof record.payload === 'object') {
|
|
32943
|
+
// Try to unwrap as transport frame
|
|
32944
|
+
const frame = unwrapTransportFrame(record.payload);
|
|
32945
|
+
if (frame) {
|
|
32946
|
+
// Apply listener's filtering policy: accept frames addressed to us OR with wildcard destination
|
|
32947
|
+
// Wildcard is needed because downstream nodes don't know the sentinel's ID during initial attach
|
|
32948
|
+
const isAddressedToUs = frame.dst === this._routingNode.id || frame.dst === '*';
|
|
32949
|
+
if (isAddressedToUs) {
|
|
32950
|
+
envelopePayload = frame.payload;
|
|
32951
|
+
logger$n.debug('broadcast_channel_listener_unwrapped_transport_frame', {
|
|
32952
|
+
sender_id: senderId,
|
|
32953
|
+
src: frame.src,
|
|
32954
|
+
dst: frame.dst,
|
|
32955
|
+
});
|
|
32956
|
+
}
|
|
32957
|
+
else {
|
|
32958
|
+
// Frame addressed to a different node, ignore it
|
|
32959
|
+
logger$n.debug('broadcast_channel_listener_ignored_frame_wrong_destination', {
|
|
32960
|
+
sender_id: senderId,
|
|
32961
|
+
dst: frame.dst,
|
|
32962
|
+
expected: this._routingNode.id,
|
|
32963
|
+
});
|
|
32964
|
+
return null;
|
|
32926
32965
|
}
|
|
32927
32966
|
}
|
|
32928
|
-
|
|
32929
|
-
|
|
32967
|
+
}
|
|
32968
|
+
// If not a transport frame, try to coerce as legacy format
|
|
32969
|
+
if (!envelopePayload) {
|
|
32970
|
+
envelopePayload = coercePayload(record.payload);
|
|
32971
|
+
if (!envelopePayload) {
|
|
32972
|
+
logger$n.debug('broadcast_channel_listener_ignored_event_without_payload', {
|
|
32973
|
+
sender_id: senderId,
|
|
32974
|
+
});
|
|
32975
|
+
return null;
|
|
32930
32976
|
}
|
|
32931
32977
|
}
|
|
32932
|
-
// Use unwrapped payload if available, otherwise use raw payload
|
|
32933
|
-
const envelopePayload = unwrapped ?? payload;
|
|
32934
32978
|
let envelope;
|
|
32935
32979
|
try {
|
|
32936
32980
|
const decoded = new TextDecoder().decode(envelopePayload);
|
|
@@ -32940,7 +32984,7 @@ class BroadcastChannelListener extends TransportListener {
|
|
|
32940
32984
|
catch (error) {
|
|
32941
32985
|
const decoded = (() => {
|
|
32942
32986
|
try {
|
|
32943
|
-
return new TextDecoder().decode(
|
|
32987
|
+
return new TextDecoder().decode(envelopePayload);
|
|
32944
32988
|
}
|
|
32945
32989
|
catch {
|
|
32946
32990
|
return null;
|
|
@@ -41,14 +41,12 @@ export declare function wrapTransportFrame(payload: Uint8Array, srcNodeId: strin
|
|
|
41
41
|
*/
|
|
42
42
|
export declare function serializeTransportFrame(frame: TransportFrame): unknown;
|
|
43
43
|
/**
|
|
44
|
-
* Unwrap a transport frame
|
|
44
|
+
* Unwrap a transport frame (pure deserializer - no filtering)
|
|
45
45
|
*
|
|
46
46
|
* @param raw - Raw data from the bus
|
|
47
|
-
* @
|
|
48
|
-
* @param remoteNodeId - Expected remote node ID
|
|
49
|
-
* @returns Unwrapped payload if frame is valid and addressed to us, null otherwise
|
|
47
|
+
* @returns Unwrapped frame with payload as Uint8Array, or null if invalid structure
|
|
50
48
|
*/
|
|
51
|
-
export declare function unwrapTransportFrame(raw: unknown
|
|
49
|
+
export declare function unwrapTransportFrame(raw: unknown): TransportFrame | null;
|
|
52
50
|
/**
|
|
53
51
|
* Check if raw data looks like a transport frame
|
|
54
52
|
*
|
package/dist/types/version.d.ts
CHANGED