@naylence/runtime 0.3.5-test.966 → 0.3.6-test.1
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 +363 -72
- package/dist/browser/index.mjs +363 -73
- package/dist/cjs/naylence/fame/connector/index.js +2 -1
- package/dist/cjs/naylence/fame/connector/inpage-connector-factory.js +36 -0
- package/dist/cjs/naylence/fame/connector/inpage-connector.js +213 -18
- package/dist/cjs/naylence/fame/connector/inpage-listener.js +67 -8
- package/dist/cjs/naylence/fame/util/index.js +3 -1
- package/dist/cjs/node.js +4 -1
- package/dist/cjs/version.js +2 -2
- package/dist/esm/naylence/fame/connector/index.js +1 -1
- package/dist/esm/naylence/fame/connector/inpage-connector-factory.js +36 -0
- package/dist/esm/naylence/fame/connector/inpage-connector.js +213 -18
- package/dist/esm/naylence/fame/connector/inpage-listener.js +67 -8
- package/dist/esm/naylence/fame/util/index.js +1 -0
- package/dist/esm/node.js +2 -1
- package/dist/esm/version.js +2 -2
- package/dist/node/index.cjs +363 -72
- package/dist/node/index.mjs +363 -73
- package/dist/node/node.cjs +320 -28
- package/dist/node/node.mjs +319 -29
- package/dist/types/naylence/fame/connector/index.d.ts +2 -2
- package/dist/types/naylence/fame/connector/inpage-connector-factory.d.ts +6 -0
- package/dist/types/naylence/fame/connector/inpage-connector.d.ts +13 -0
- package/dist/types/naylence/fame/connector/inpage-listener.d.ts +4 -0
- package/dist/types/naylence/fame/grants/inpage-connection-grant.d.ts +2 -0
- package/dist/types/naylence/fame/util/index.d.ts +1 -0
- package/dist/types/node.d.ts +2 -1
- package/dist/types/version.d.ts +1 -1
- package/package.json +1 -1
package/dist/browser/index.cjs
CHANGED
|
@@ -98,12 +98,12 @@ installProcessEnvShim();
|
|
|
98
98
|
// --- END ENV SHIM ---
|
|
99
99
|
|
|
100
100
|
// This file is auto-generated during build - do not edit manually
|
|
101
|
-
// Generated from package.json version: 0.3.
|
|
101
|
+
// Generated from package.json version: 0.3.6-test.001
|
|
102
102
|
/**
|
|
103
103
|
* The package version, injected at build time.
|
|
104
104
|
* @internal
|
|
105
105
|
*/
|
|
106
|
-
const VERSION = '0.3.
|
|
106
|
+
const VERSION = '0.3.6-test.001';
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Fame protocol specific error classes with WebSocket close codes and proper inheritance.
|
|
@@ -2332,6 +2332,50 @@ function validateKeyCorrelationTtlSec(ttlSec) {
|
|
|
2332
2332
|
});
|
|
2333
2333
|
}
|
|
2334
2334
|
|
|
2335
|
+
function isModuleNotFoundError(error) {
|
|
2336
|
+
if (!(error instanceof Error)) {
|
|
2337
|
+
return false;
|
|
2338
|
+
}
|
|
2339
|
+
const message = error.message || '';
|
|
2340
|
+
if (message.includes('Cannot find module') ||
|
|
2341
|
+
message.includes('ERR_MODULE_NOT_FOUND') ||
|
|
2342
|
+
message.includes('MODULE_NOT_FOUND')) {
|
|
2343
|
+
return true;
|
|
2344
|
+
}
|
|
2345
|
+
const code = error.code;
|
|
2346
|
+
if (typeof code === 'string') {
|
|
2347
|
+
return code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND';
|
|
2348
|
+
}
|
|
2349
|
+
return false;
|
|
2350
|
+
}
|
|
2351
|
+
/**
|
|
2352
|
+
* Wraps a dynamic import loader and enriches "module not found" failures with an actionable error message.
|
|
2353
|
+
*/
|
|
2354
|
+
async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
|
|
2355
|
+
const options = typeof dependencyNameOrOptions === 'string'
|
|
2356
|
+
? { dependencyName: dependencyNameOrOptions, ...(maybeOptions ?? {}) }
|
|
2357
|
+
: dependencyNameOrOptions;
|
|
2358
|
+
const dependencyName = options.dependencyName;
|
|
2359
|
+
try {
|
|
2360
|
+
return await loader();
|
|
2361
|
+
}
|
|
2362
|
+
catch (error) {
|
|
2363
|
+
if (isModuleNotFoundError(error)) {
|
|
2364
|
+
const message = options.helpMessage ??
|
|
2365
|
+
`Missing optional dependency "${dependencyName}". Install it to enable this feature.`;
|
|
2366
|
+
const enrichedError = new Error(message);
|
|
2367
|
+
try {
|
|
2368
|
+
enrichedError.cause = error;
|
|
2369
|
+
}
|
|
2370
|
+
catch {
|
|
2371
|
+
// Ignore environments that do not support attaching a cause.
|
|
2372
|
+
}
|
|
2373
|
+
throw enrichedError;
|
|
2374
|
+
}
|
|
2375
|
+
throw error;
|
|
2376
|
+
}
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2335
2379
|
/**
|
|
2336
2380
|
* flow_controller.ts - credit window management with cooperative back-pressure.
|
|
2337
2381
|
*
|
|
@@ -3536,50 +3580,6 @@ function normalizeSecretSource(value) {
|
|
|
3536
3580
|
return SecretSource.normalize(value);
|
|
3537
3581
|
}
|
|
3538
3582
|
|
|
3539
|
-
function isModuleNotFoundError(error) {
|
|
3540
|
-
if (!(error instanceof Error)) {
|
|
3541
|
-
return false;
|
|
3542
|
-
}
|
|
3543
|
-
const message = error.message || '';
|
|
3544
|
-
if (message.includes('Cannot find module') ||
|
|
3545
|
-
message.includes('ERR_MODULE_NOT_FOUND') ||
|
|
3546
|
-
message.includes('MODULE_NOT_FOUND')) {
|
|
3547
|
-
return true;
|
|
3548
|
-
}
|
|
3549
|
-
const code = error.code;
|
|
3550
|
-
if (typeof code === 'string') {
|
|
3551
|
-
return code === 'MODULE_NOT_FOUND' || code === 'ERR_MODULE_NOT_FOUND';
|
|
3552
|
-
}
|
|
3553
|
-
return false;
|
|
3554
|
-
}
|
|
3555
|
-
/**
|
|
3556
|
-
* Wraps a dynamic import loader and enriches "module not found" failures with an actionable error message.
|
|
3557
|
-
*/
|
|
3558
|
-
async function safeImport(loader, dependencyNameOrOptions, maybeOptions) {
|
|
3559
|
-
const options = typeof dependencyNameOrOptions === 'string'
|
|
3560
|
-
? { dependencyName: dependencyNameOrOptions, ...(maybeOptions ?? {}) }
|
|
3561
|
-
: dependencyNameOrOptions;
|
|
3562
|
-
const dependencyName = options.dependencyName;
|
|
3563
|
-
try {
|
|
3564
|
-
return await loader();
|
|
3565
|
-
}
|
|
3566
|
-
catch (error) {
|
|
3567
|
-
if (isModuleNotFoundError(error)) {
|
|
3568
|
-
const message = options.helpMessage ??
|
|
3569
|
-
`Missing optional dependency "${dependencyName}". Install it to enable this feature.`;
|
|
3570
|
-
const enrichedError = new Error(message);
|
|
3571
|
-
try {
|
|
3572
|
-
enrichedError.cause = error;
|
|
3573
|
-
}
|
|
3574
|
-
catch {
|
|
3575
|
-
// Ignore environments that do not support attaching a cause.
|
|
3576
|
-
}
|
|
3577
|
-
throw enrichedError;
|
|
3578
|
-
}
|
|
3579
|
-
throw error;
|
|
3580
|
-
}
|
|
3581
|
-
}
|
|
3582
|
-
|
|
3583
3583
|
const indexedDBConfigSchema = zod.z
|
|
3584
3584
|
.object({
|
|
3585
3585
|
type: zod.z
|
|
@@ -20518,6 +20518,26 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20518
20518
|
}
|
|
20519
20519
|
return null;
|
|
20520
20520
|
}
|
|
20521
|
+
static normalizeNodeId(value) {
|
|
20522
|
+
if (typeof value !== 'string') {
|
|
20523
|
+
return null;
|
|
20524
|
+
}
|
|
20525
|
+
const trimmed = value.trim();
|
|
20526
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
20527
|
+
}
|
|
20528
|
+
static normalizeTargetNodeId(value) {
|
|
20529
|
+
if (typeof value !== 'string') {
|
|
20530
|
+
return undefined;
|
|
20531
|
+
}
|
|
20532
|
+
const trimmed = value.trim();
|
|
20533
|
+
if (trimmed.length === 0) {
|
|
20534
|
+
return undefined;
|
|
20535
|
+
}
|
|
20536
|
+
if (trimmed === '*') {
|
|
20537
|
+
return '*';
|
|
20538
|
+
}
|
|
20539
|
+
return trimmed;
|
|
20540
|
+
}
|
|
20521
20541
|
constructor(config, baseConfig = {}) {
|
|
20522
20542
|
ensureBrowserEnvironment$2();
|
|
20523
20543
|
super(baseConfig);
|
|
@@ -20533,41 +20553,68 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20533
20553
|
? Math.floor(config.inboxCapacity)
|
|
20534
20554
|
: DEFAULT_INBOX_CAPACITY$6;
|
|
20535
20555
|
this.inbox = new BoundedAsyncQueue(preferredCapacity);
|
|
20556
|
+
this.inboxCapacity = preferredCapacity;
|
|
20536
20557
|
this.connectorId = InPageConnector.generateConnectorId();
|
|
20558
|
+
const normalizedLocalNodeId = InPageConnector.normalizeNodeId(config.localNodeId);
|
|
20559
|
+
if (!normalizedLocalNodeId) {
|
|
20560
|
+
throw new Error('InPageConnector requires a non-empty localNodeId');
|
|
20561
|
+
}
|
|
20562
|
+
this.localNodeId = normalizedLocalNodeId;
|
|
20563
|
+
this.targetNodeId = InPageConnector.normalizeTargetNodeId(config.initialTargetNodeId);
|
|
20537
20564
|
logger$G.debug('inpage_connector_initialized', {
|
|
20538
20565
|
channel: this.channelName,
|
|
20539
20566
|
connector_id: this.connectorId,
|
|
20567
|
+
local_node_id: this.localNodeId,
|
|
20568
|
+
target_node_id: this.targetNodeId ?? null,
|
|
20569
|
+
inbox_capacity: preferredCapacity,
|
|
20540
20570
|
});
|
|
20541
20571
|
this.onMsg = (event) => {
|
|
20572
|
+
if (!this.listenerRegistered) {
|
|
20573
|
+
logger$G.warning('inpage_message_after_unregister', {
|
|
20574
|
+
channel: this.channelName,
|
|
20575
|
+
connector_id: this.connectorId,
|
|
20576
|
+
timestamp: new Date().toISOString(),
|
|
20577
|
+
});
|
|
20578
|
+
return;
|
|
20579
|
+
}
|
|
20542
20580
|
const messageEvent = event;
|
|
20543
20581
|
const message = messageEvent.data;
|
|
20544
20582
|
logger$G.debug('inpage_raw_event', {
|
|
20545
20583
|
channel: this.channelName,
|
|
20546
20584
|
connector_id: this.connectorId,
|
|
20547
|
-
message_type: message && typeof message === 'object'
|
|
20548
|
-
|
|
20549
|
-
payload_type: message && typeof message === 'object'
|
|
20550
|
-
? message?.payload instanceof Uint8Array
|
|
20551
|
-
? 'Uint8Array'
|
|
20552
|
-
: message?.payload instanceof ArrayBuffer
|
|
20553
|
-
? 'ArrayBuffer'
|
|
20554
|
-
: typeof message?.payload
|
|
20585
|
+
message_type: message && typeof message === 'object'
|
|
20586
|
+
? message.constructor?.name ?? typeof message
|
|
20555
20587
|
: typeof message,
|
|
20556
|
-
|
|
20557
|
-
|
|
20558
|
-
: undefined,
|
|
20559
|
-
payload_keys: message && typeof message === 'object' && message?.payload && typeof message?.payload === 'object'
|
|
20560
|
-
? Object.keys(message.payload).slice(0, 5)
|
|
20561
|
-
: undefined,
|
|
20588
|
+
has_sender_id: Boolean(message?.senderId),
|
|
20589
|
+
has_sender_node_id: Boolean(message?.senderNodeId),
|
|
20562
20590
|
});
|
|
20563
20591
|
if (!message || typeof message !== 'object') {
|
|
20564
20592
|
return;
|
|
20565
20593
|
}
|
|
20566
20594
|
const busMessage = message;
|
|
20567
|
-
|
|
20595
|
+
const senderId = typeof busMessage.senderId === 'string' && busMessage.senderId.length > 0
|
|
20596
|
+
? busMessage.senderId
|
|
20597
|
+
: null;
|
|
20598
|
+
const senderNodeId = InPageConnector.normalizeNodeId(busMessage.senderNodeId);
|
|
20599
|
+
if (!senderId || !senderNodeId) {
|
|
20600
|
+
logger$G.debug('inpage_message_rejected', {
|
|
20601
|
+
channel: this.channelName,
|
|
20602
|
+
connector_id: this.connectorId,
|
|
20603
|
+
reason: 'missing_sender_metadata',
|
|
20604
|
+
});
|
|
20605
|
+
return;
|
|
20606
|
+
}
|
|
20607
|
+
if (senderId === this.connectorId || senderNodeId === this.localNodeId) {
|
|
20608
|
+
logger$G.debug('inpage_message_rejected', {
|
|
20609
|
+
channel: this.channelName,
|
|
20610
|
+
connector_id: this.connectorId,
|
|
20611
|
+
reason: 'self_echo',
|
|
20612
|
+
sender_node_id: senderNodeId,
|
|
20613
|
+
});
|
|
20568
20614
|
return;
|
|
20569
20615
|
}
|
|
20570
|
-
|
|
20616
|
+
const incomingTargetNodeId = InPageConnector.normalizeTargetNodeId(busMessage.targetNodeId);
|
|
20617
|
+
if (!this._shouldAcceptMessageFromBus(senderNodeId, incomingTargetNodeId)) {
|
|
20571
20618
|
return;
|
|
20572
20619
|
}
|
|
20573
20620
|
const payload = InPageConnector.coercePayload(busMessage.payload);
|
|
@@ -20581,7 +20628,9 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20581
20628
|
}
|
|
20582
20629
|
logger$G.debug('inpage_message_received', {
|
|
20583
20630
|
channel: this.channelName,
|
|
20584
|
-
sender_id:
|
|
20631
|
+
sender_id: senderId,
|
|
20632
|
+
sender_node_id: senderNodeId,
|
|
20633
|
+
target_node_id: incomingTargetNodeId ?? null,
|
|
20585
20634
|
connector_id: this.connectorId,
|
|
20586
20635
|
payload_length: payload.byteLength,
|
|
20587
20636
|
});
|
|
@@ -20589,15 +20638,27 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20589
20638
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
20590
20639
|
const accepted = this.inbox.tryEnqueue(payload);
|
|
20591
20640
|
if (accepted) {
|
|
20641
|
+
this.logInboxSnapshot('inpage_inbox_enqueued', {
|
|
20642
|
+
source: 'listener',
|
|
20643
|
+
enqueue_strategy: 'try',
|
|
20644
|
+
payload_length: payload.byteLength,
|
|
20645
|
+
});
|
|
20592
20646
|
return;
|
|
20593
20647
|
}
|
|
20594
20648
|
}
|
|
20595
20649
|
this.inbox.enqueue(payload);
|
|
20650
|
+
this.logInboxSnapshot('inpage_inbox_enqueued', {
|
|
20651
|
+
source: 'listener',
|
|
20652
|
+
enqueue_strategy: 'enqueue',
|
|
20653
|
+
payload_length: payload.byteLength,
|
|
20654
|
+
});
|
|
20596
20655
|
}
|
|
20597
20656
|
catch (error) {
|
|
20598
20657
|
if (error instanceof QueueFullError) {
|
|
20599
20658
|
logger$G.warning('inpage_receive_queue_full', {
|
|
20600
20659
|
channel: this.channelName,
|
|
20660
|
+
inbox_capacity: this.inboxCapacity,
|
|
20661
|
+
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
20601
20662
|
});
|
|
20602
20663
|
}
|
|
20603
20664
|
else {
|
|
@@ -20704,15 +20765,25 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20704
20765
|
if (typeof this.inbox.tryEnqueue === 'function') {
|
|
20705
20766
|
const accepted = this.inbox.tryEnqueue(item);
|
|
20706
20767
|
if (accepted) {
|
|
20768
|
+
this.logInboxSnapshot('inpage_push_enqueued', {
|
|
20769
|
+
enqueue_strategy: 'try',
|
|
20770
|
+
item_type: this._describeInboxItem(item),
|
|
20771
|
+
});
|
|
20707
20772
|
return;
|
|
20708
20773
|
}
|
|
20709
20774
|
}
|
|
20710
20775
|
this.inbox.enqueue(item);
|
|
20776
|
+
this.logInboxSnapshot('inpage_push_enqueued', {
|
|
20777
|
+
enqueue_strategy: 'enqueue',
|
|
20778
|
+
item_type: this._describeInboxItem(item),
|
|
20779
|
+
});
|
|
20711
20780
|
}
|
|
20712
20781
|
catch (error) {
|
|
20713
20782
|
if (error instanceof QueueFullError) {
|
|
20714
20783
|
logger$G.warning('inpage_push_queue_full', {
|
|
20715
20784
|
channel: this.channelName,
|
|
20785
|
+
inbox_capacity: this.inboxCapacity,
|
|
20786
|
+
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
20716
20787
|
});
|
|
20717
20788
|
throw error;
|
|
20718
20789
|
}
|
|
@@ -20725,25 +20796,52 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20725
20796
|
}
|
|
20726
20797
|
async _transportSendBytes(data) {
|
|
20727
20798
|
ensureBrowserEnvironment$2();
|
|
20799
|
+
const targetNodeId = this.targetNodeId ?? '*';
|
|
20728
20800
|
logger$G.debug('inpage_message_sending', {
|
|
20729
20801
|
channel: this.channelName,
|
|
20730
20802
|
sender_id: this.connectorId,
|
|
20803
|
+
sender_node_id: this.localNodeId,
|
|
20804
|
+
target_node_id: targetNodeId,
|
|
20731
20805
|
});
|
|
20732
20806
|
const event = new MessageEvent(this.channelName, {
|
|
20733
20807
|
data: {
|
|
20734
20808
|
senderId: this.connectorId,
|
|
20809
|
+
senderNodeId: this.localNodeId,
|
|
20810
|
+
targetNodeId,
|
|
20735
20811
|
payload: data,
|
|
20736
20812
|
},
|
|
20737
20813
|
});
|
|
20738
20814
|
getSharedBus$1().dispatchEvent(event);
|
|
20739
20815
|
}
|
|
20740
20816
|
async _transportReceive() {
|
|
20741
|
-
|
|
20817
|
+
const item = await this.inbox.dequeue();
|
|
20818
|
+
this.logInboxSnapshot('inpage_inbox_dequeued', {
|
|
20819
|
+
item_type: this._describeInboxItem(item),
|
|
20820
|
+
});
|
|
20821
|
+
return item;
|
|
20742
20822
|
}
|
|
20743
20823
|
async _transportClose(code, reason) {
|
|
20824
|
+
logger$G.debug('inpage_transport_closing', {
|
|
20825
|
+
channel: this.channelName,
|
|
20826
|
+
connector_id: this.connectorId,
|
|
20827
|
+
code,
|
|
20828
|
+
reason,
|
|
20829
|
+
listener_registered: this.listenerRegistered,
|
|
20830
|
+
timestamp: new Date().toISOString(),
|
|
20831
|
+
});
|
|
20744
20832
|
if (this.listenerRegistered) {
|
|
20833
|
+
logger$G.debug('inpage_removing_listener', {
|
|
20834
|
+
channel: this.channelName,
|
|
20835
|
+
connector_id: this.connectorId,
|
|
20836
|
+
timestamp: new Date().toISOString(),
|
|
20837
|
+
});
|
|
20745
20838
|
getSharedBus$1().removeEventListener(this.channelName, this.onMsg);
|
|
20746
20839
|
this.listenerRegistered = false;
|
|
20840
|
+
logger$G.debug('inpage_listener_removed', {
|
|
20841
|
+
channel: this.channelName,
|
|
20842
|
+
connector_id: this.connectorId,
|
|
20843
|
+
timestamp: new Date().toISOString(),
|
|
20844
|
+
});
|
|
20747
20845
|
}
|
|
20748
20846
|
if (this.visibilityChangeListenerRegistered && this.visibilityChangeHandler && typeof document !== 'undefined') {
|
|
20749
20847
|
document.removeEventListener('visibilitychange', this.visibilityChangeHandler);
|
|
@@ -20761,6 +20859,103 @@ class InPageConnector extends BaseAsyncConnector {
|
|
|
20761
20859
|
}
|
|
20762
20860
|
return rawOrEnvelope;
|
|
20763
20861
|
}
|
|
20862
|
+
_isWildcardTarget() {
|
|
20863
|
+
return this.targetNodeId === '*' || typeof this.targetNodeId === 'undefined';
|
|
20864
|
+
}
|
|
20865
|
+
_shouldAcceptMessageFromBus(senderNodeId, targetNodeId) {
|
|
20866
|
+
if (this._isWildcardTarget()) {
|
|
20867
|
+
if (targetNodeId &&
|
|
20868
|
+
targetNodeId !== '*' &&
|
|
20869
|
+
targetNodeId !== this.localNodeId) {
|
|
20870
|
+
logger$G.debug('inpage_message_rejected', {
|
|
20871
|
+
channel: this.channelName,
|
|
20872
|
+
connector_id: this.connectorId,
|
|
20873
|
+
reason: 'wildcard_target_mismatch',
|
|
20874
|
+
sender_node_id: senderNodeId,
|
|
20875
|
+
target_node_id: targetNodeId,
|
|
20876
|
+
local_node_id: this.localNodeId,
|
|
20877
|
+
});
|
|
20878
|
+
return false;
|
|
20879
|
+
}
|
|
20880
|
+
return true;
|
|
20881
|
+
}
|
|
20882
|
+
const expectedSender = this.targetNodeId;
|
|
20883
|
+
if (expectedSender && expectedSender !== '*' && senderNodeId !== expectedSender) {
|
|
20884
|
+
logger$G.debug('inpage_message_rejected', {
|
|
20885
|
+
channel: this.channelName,
|
|
20886
|
+
connector_id: this.connectorId,
|
|
20887
|
+
reason: 'unexpected_sender',
|
|
20888
|
+
expected_sender_node_id: expectedSender,
|
|
20889
|
+
sender_node_id: senderNodeId,
|
|
20890
|
+
local_node_id: this.localNodeId,
|
|
20891
|
+
});
|
|
20892
|
+
return false;
|
|
20893
|
+
}
|
|
20894
|
+
if (targetNodeId &&
|
|
20895
|
+
targetNodeId !== '*' &&
|
|
20896
|
+
targetNodeId !== this.localNodeId) {
|
|
20897
|
+
logger$G.debug('inpage_message_rejected', {
|
|
20898
|
+
channel: this.channelName,
|
|
20899
|
+
connector_id: this.connectorId,
|
|
20900
|
+
reason: 'unexpected_target',
|
|
20901
|
+
sender_node_id: senderNodeId,
|
|
20902
|
+
target_node_id: targetNodeId,
|
|
20903
|
+
local_node_id: this.localNodeId,
|
|
20904
|
+
});
|
|
20905
|
+
return false;
|
|
20906
|
+
}
|
|
20907
|
+
return true;
|
|
20908
|
+
}
|
|
20909
|
+
_describeInboxItem(item) {
|
|
20910
|
+
if (item instanceof Uint8Array) {
|
|
20911
|
+
return 'bytes';
|
|
20912
|
+
}
|
|
20913
|
+
if (item.envelope) {
|
|
20914
|
+
return 'channel_message';
|
|
20915
|
+
}
|
|
20916
|
+
if (item.frame) {
|
|
20917
|
+
return 'envelope';
|
|
20918
|
+
}
|
|
20919
|
+
return 'unknown';
|
|
20920
|
+
}
|
|
20921
|
+
logInboxSnapshot(event, extra = {}) {
|
|
20922
|
+
logger$G.debug(event, {
|
|
20923
|
+
channel: this.channelName,
|
|
20924
|
+
connector_id: this.connectorId,
|
|
20925
|
+
connector_state: this.state,
|
|
20926
|
+
inbox_capacity: this.inboxCapacity,
|
|
20927
|
+
inbox_remaining_capacity: this.inbox.remainingCapacity,
|
|
20928
|
+
...extra,
|
|
20929
|
+
});
|
|
20930
|
+
}
|
|
20931
|
+
setTargetNodeId(nodeId) {
|
|
20932
|
+
const normalized = InPageConnector.normalizeNodeId(nodeId);
|
|
20933
|
+
if (!normalized) {
|
|
20934
|
+
throw new Error('InPageConnector target node id must be a non-empty string');
|
|
20935
|
+
}
|
|
20936
|
+
if (normalized === '*') {
|
|
20937
|
+
this.setWildcardTarget();
|
|
20938
|
+
return;
|
|
20939
|
+
}
|
|
20940
|
+
this.targetNodeId = normalized;
|
|
20941
|
+
logger$G.debug('inpage_target_updated', {
|
|
20942
|
+
channel: this.channelName,
|
|
20943
|
+
connector_id: this.connectorId,
|
|
20944
|
+
local_node_id: this.localNodeId,
|
|
20945
|
+
target_node_id: this.targetNodeId,
|
|
20946
|
+
target_mode: 'direct',
|
|
20947
|
+
});
|
|
20948
|
+
}
|
|
20949
|
+
setWildcardTarget() {
|
|
20950
|
+
this.targetNodeId = '*';
|
|
20951
|
+
logger$G.debug('inpage_target_updated', {
|
|
20952
|
+
channel: this.channelName,
|
|
20953
|
+
connector_id: this.connectorId,
|
|
20954
|
+
local_node_id: this.localNodeId,
|
|
20955
|
+
target_node_id: this.targetNodeId,
|
|
20956
|
+
target_mode: 'wildcard',
|
|
20957
|
+
});
|
|
20958
|
+
}
|
|
20764
20959
|
}
|
|
20765
20960
|
|
|
20766
20961
|
const RPC_REGISTRY = Symbol('naylence.rpc.registry');
|
|
@@ -28748,8 +28943,16 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
28748
28943
|
}
|
|
28749
28944
|
const normalized = this._normalizeConfig(config);
|
|
28750
28945
|
const options = (factoryArgs[0] ?? {});
|
|
28946
|
+
const normalizedLocalNodeFromConfig = this._normalizeNodeId(normalized.localNodeId);
|
|
28947
|
+
const localNodeId = this._normalizeNodeId(options.localNodeId) ?? normalizedLocalNodeFromConfig;
|
|
28948
|
+
if (!localNodeId) {
|
|
28949
|
+
throw new Error('InPageConnectorFactory requires a localNodeId from config or create() options');
|
|
28950
|
+
}
|
|
28751
28951
|
const channelName = normalized.channelName ?? DEFAULT_CHANNEL$5;
|
|
28752
28952
|
const inboxCapacity = normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
|
|
28953
|
+
const targetFromOptions = this._normalizeTargetNodeId(options.initialTargetNodeId);
|
|
28954
|
+
const targetFromConfig = this._normalizeTargetNodeId(normalized.initialTargetNodeId);
|
|
28955
|
+
const resolvedTarget = targetFromOptions ?? targetFromConfig ?? '*';
|
|
28753
28956
|
const baseConfig = {
|
|
28754
28957
|
drainTimeout: normalized.drainTimeout,
|
|
28755
28958
|
flowControl: normalized.flowControl,
|
|
@@ -28764,6 +28967,8 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
28764
28967
|
type: INPAGE_CONNECTOR_TYPE,
|
|
28765
28968
|
channelName,
|
|
28766
28969
|
inboxCapacity,
|
|
28970
|
+
localNodeId,
|
|
28971
|
+
initialTargetNodeId: resolvedTarget,
|
|
28767
28972
|
};
|
|
28768
28973
|
const connector = new InPageConnector(connectorConfig, baseConfig);
|
|
28769
28974
|
if (options.authorization) {
|
|
@@ -28799,6 +29004,16 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
28799
29004
|
capacity > 0) {
|
|
28800
29005
|
normalized.inboxCapacity = Math.floor(capacity);
|
|
28801
29006
|
}
|
|
29007
|
+
const localNodeId = candidate.localNodeId ?? candidate['local_node_id'];
|
|
29008
|
+
const normalizedLocalNodeId = this._normalizeNodeId(localNodeId);
|
|
29009
|
+
if (normalizedLocalNodeId) {
|
|
29010
|
+
normalized.localNodeId = normalizedLocalNodeId;
|
|
29011
|
+
}
|
|
29012
|
+
const initialTargetNodeId = candidate.initialTargetNodeId ?? candidate['initial_target_node_id'];
|
|
29013
|
+
const normalizedTarget = this._normalizeTargetNodeId(initialTargetNodeId);
|
|
29014
|
+
if (normalizedTarget) {
|
|
29015
|
+
normalized.initialTargetNodeId = normalizedTarget;
|
|
29016
|
+
}
|
|
28802
29017
|
if (typeof candidate.flowControl === 'boolean') {
|
|
28803
29018
|
normalized.flowControl = candidate.flowControl;
|
|
28804
29019
|
}
|
|
@@ -28837,6 +29052,22 @@ class InPageConnectorFactory extends ConnectorFactory {
|
|
|
28837
29052
|
normalized.inboxCapacity ?? DEFAULT_INBOX_CAPACITY$5;
|
|
28838
29053
|
return normalized;
|
|
28839
29054
|
}
|
|
29055
|
+
_normalizeNodeId(value) {
|
|
29056
|
+
if (typeof value !== 'string') {
|
|
29057
|
+
return null;
|
|
29058
|
+
}
|
|
29059
|
+
const trimmed = value.trim();
|
|
29060
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
29061
|
+
}
|
|
29062
|
+
_normalizeTargetNodeId(value) {
|
|
29063
|
+
if (value === undefined || value === null) {
|
|
29064
|
+
return undefined;
|
|
29065
|
+
}
|
|
29066
|
+
if (value === '*') {
|
|
29067
|
+
return '*';
|
|
29068
|
+
}
|
|
29069
|
+
return this._normalizeNodeId(value) ?? undefined;
|
|
29070
|
+
}
|
|
28840
29071
|
}
|
|
28841
29072
|
|
|
28842
29073
|
var inpageConnectorFactory = /*#__PURE__*/Object.freeze({
|
|
@@ -29615,7 +29846,7 @@ class InPageListener extends TransportListener {
|
|
|
29615
29846
|
node: routingNode,
|
|
29616
29847
|
});
|
|
29617
29848
|
const selection = defaultGrantSelectionPolicy.selectCallbackGrant(selectionContext);
|
|
29618
|
-
connectorConfig = this._grantToConnectorConfig(selection.grant);
|
|
29849
|
+
connectorConfig = this._buildConnectorConfigForSystem(systemId, this._grantToConnectorConfig(selection.grant));
|
|
29619
29850
|
}
|
|
29620
29851
|
catch (error) {
|
|
29621
29852
|
logger$p.debug('inpage_listener_grant_selection_failed', {
|
|
@@ -29623,13 +29854,13 @@ class InPageListener extends TransportListener {
|
|
|
29623
29854
|
system_id: systemId,
|
|
29624
29855
|
error: error instanceof Error ? error.message : String(error),
|
|
29625
29856
|
});
|
|
29626
|
-
|
|
29627
|
-
|
|
29628
|
-
|
|
29629
|
-
|
|
29630
|
-
|
|
29631
|
-
|
|
29632
|
-
|
|
29857
|
+
const fallbackConfig = this._extractInPageConnectorConfig(frame) ??
|
|
29858
|
+
{
|
|
29859
|
+
type: INPAGE_CONNECTOR_TYPE,
|
|
29860
|
+
channelName: this._channelName,
|
|
29861
|
+
inboxCapacity: this._inboxCapacity,
|
|
29862
|
+
};
|
|
29863
|
+
connectorConfig = this._buildConnectorConfigForSystem(systemId, fallbackConfig);
|
|
29633
29864
|
}
|
|
29634
29865
|
try {
|
|
29635
29866
|
const connector = await routingNode.createOriginConnector({
|
|
@@ -29748,6 +29979,65 @@ class InPageListener extends TransportListener {
|
|
|
29748
29979
|
typeof frame === 'object' &&
|
|
29749
29980
|
frame.type === 'NodeAttach');
|
|
29750
29981
|
}
|
|
29982
|
+
_buildConnectorConfigForSystem(systemId, baseConfig) {
|
|
29983
|
+
const localNodeId = this._requireLocalNodeId();
|
|
29984
|
+
const targetSystemId = this._normalizeNodeId(systemId);
|
|
29985
|
+
if (!targetSystemId) {
|
|
29986
|
+
throw new Error('InPageListener requires a valid system id for connector creation');
|
|
29987
|
+
}
|
|
29988
|
+
const candidate = baseConfig ?? null;
|
|
29989
|
+
const channelCandidate = candidate && 'channelName' in candidate
|
|
29990
|
+
? candidate.channelName
|
|
29991
|
+
: undefined;
|
|
29992
|
+
const inboxCandidate = candidate && 'inboxCapacity' in candidate
|
|
29993
|
+
? candidate.inboxCapacity
|
|
29994
|
+
: undefined;
|
|
29995
|
+
const targetCandidate = candidate && 'initialTargetNodeId' in candidate
|
|
29996
|
+
? candidate.initialTargetNodeId
|
|
29997
|
+
: undefined;
|
|
29998
|
+
const channelName = typeof channelCandidate === 'string' && channelCandidate.trim().length > 0
|
|
29999
|
+
? channelCandidate.trim()
|
|
30000
|
+
: this._channelName;
|
|
30001
|
+
const inboxCapacity = typeof inboxCandidate === 'number' &&
|
|
30002
|
+
Number.isFinite(inboxCandidate) &&
|
|
30003
|
+
inboxCandidate > 0
|
|
30004
|
+
? Math.floor(inboxCandidate)
|
|
30005
|
+
: this._inboxCapacity;
|
|
30006
|
+
const normalizedTarget = this._normalizeTargetNodeId(targetCandidate);
|
|
30007
|
+
return {
|
|
30008
|
+
type: INPAGE_CONNECTOR_TYPE,
|
|
30009
|
+
channelName,
|
|
30010
|
+
inboxCapacity,
|
|
30011
|
+
localNodeId,
|
|
30012
|
+
initialTargetNodeId: normalizedTarget ?? targetSystemId,
|
|
30013
|
+
};
|
|
30014
|
+
}
|
|
30015
|
+
_requireLocalNodeId() {
|
|
30016
|
+
if (!this._routingNode) {
|
|
30017
|
+
throw new Error('InPageListener requires routing node context');
|
|
30018
|
+
}
|
|
30019
|
+
const normalized = this._normalizeNodeId(this._routingNode.id);
|
|
30020
|
+
if (!normalized) {
|
|
30021
|
+
throw new Error('InPageListener requires routing node with a stable identifier');
|
|
30022
|
+
}
|
|
30023
|
+
return normalized;
|
|
30024
|
+
}
|
|
30025
|
+
_normalizeNodeId(value) {
|
|
30026
|
+
if (typeof value !== 'string') {
|
|
30027
|
+
return null;
|
|
30028
|
+
}
|
|
30029
|
+
const trimmed = value.trim();
|
|
30030
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
30031
|
+
}
|
|
30032
|
+
_normalizeTargetNodeId(value) {
|
|
30033
|
+
if (value === undefined || value === null) {
|
|
30034
|
+
return undefined;
|
|
30035
|
+
}
|
|
30036
|
+
if (value === '*') {
|
|
30037
|
+
return '*';
|
|
30038
|
+
}
|
|
30039
|
+
return this._normalizeNodeId(value) ?? undefined;
|
|
30040
|
+
}
|
|
29751
30041
|
}
|
|
29752
30042
|
function getInPageListenerInstance() {
|
|
29753
30043
|
return _lastInPageListenerInstance;
|
|
@@ -40871,6 +41161,7 @@ exports.registerRuntimeFactories = registerRuntimeFactories;
|
|
|
40871
41161
|
exports.requireCryptoSupport = requireCryptoSupport;
|
|
40872
41162
|
exports.retryWithBackoff = retryWithBackoff;
|
|
40873
41163
|
exports.safeColor = safeColor;
|
|
41164
|
+
exports.safeImport = safeImport;
|
|
40874
41165
|
exports.sealedDecrypt = sealedDecrypt;
|
|
40875
41166
|
exports.sealedEncrypt = sealedEncrypt;
|
|
40876
41167
|
exports.secureDigest = secureDigest;
|